6.1、CTS测试4in1size,本地相机使用插值size

  • Post author:
  • Post category:其他


#

1、GMS 实践过程总结目录

1、cts存在差值case测试不过的问题

因此考虑一种方案,就是本地相机使用差值size,cts测试和三方相机非差值(4in1)size

2、改动逻辑

app下发配流size ->framework(对流配置size进行与streamConfigs进行匹配)->hal层


3、

答主按照这个逻辑app设置(拍照size),然后到hal层,size发生变化;

断定framework逻辑把size改动了

如下是framework相关代码:

E:\Q\framework\av\services\camera\libcameraservice\api2\CameraDeviceClient.cpp

createSurfaceFromGbp->roundBufferDimensionNearest

此函数内部将app下发的size与streamconfig中的预览、拍照、callback 三路数据流size进行匹配;

如果宽高匹配,将这个size设为最佳size;

或者宽高不匹配选择最接近的size,

bool CameraDeviceClient::roundBufferDimensionNearest(int32_t width, int32_t height,
        int32_t format, android_dataspace dataSpace, const CameraMetadata& info,
        /*out*/int32_t* outWidth, /*out*/int32_t* outHeight) {

    camera_metadata_ro_entry streamConfigs =
            (dataSpace == HAL_DATASPACE_DEPTH) ?
            info.find(ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS) :
            (dataSpace == static_cast<android_dataspace>(HAL_DATASPACE_HEIF)) ?
            info.find(ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS) :
            info.find(ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS);

    int32_t bestWidth = -1;
    int32_t bestHeight = -1;

    // Iterate through listed stream configurations and find the one with the smallest euclidean
    // distance from the given dimensions for the given format.
    for (size_t i = 0; i < streamConfigs.count; i += 4) {
        int32_t fmt = streamConfigs.data.i32[i];
        int32_t w = streamConfigs.data.i32[i + 1];
        int32_t h = streamConfigs.data.i32[i + 2];

        // Ignore input/output type for now
        if (fmt == format) {
            if (w == width && h == height) {//宽高匹配
                bestWidth = width;
                bestHeight = height;
                break;
            } else if (w <= ROUNDING_WIDTH_CAP && (bestWidth == -1 ||//宽高不匹配选择最接近的size
                    CameraDeviceClient::euclidDistSquare(w, h, width, height) <
                    CameraDeviceClient::euclidDistSquare(bestWidth, bestHeight, width, height))) {
                bestWidth = w;
                bestHeight = h;
            }
        }
    }

    if (bestWidth == -1) {
        // Return false if no configurations for this format were listed
        return false;
    }

    // Set the outputs to the closet width/height
    if (outWidth != NULL) {
        *outWidth = bestWidth;
    }
    if (outHeight != NULL) {
        *outHeight = bestHeight;
    }

    // Return true if at least one configuration for this format was listed
    return true;
}

4、如何跳过framework层对下发的流size进行匹配

int32_t format不同的流有不同的格式

HAL_PIXEL_FORMAT_BLOB = 33, // 0x21    拍照流

HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 34, // 0x22  预览流

HAL_PIXEL_FORMAT_YCBCR_420_888 = 35, // 0x23  callback流

定义位置:system\core\libsystem\include\system\graphics-base.h



版权声明:本文为qq_20678703原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。