Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69bb03aa authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Remove flag and version from CSD of APV." into main

parents d023a087 5756875f
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -741,13 +741,15 @@ static void parseAPVProfileLevelFromCsd(const sp<ABuffer>& csd, sp<AMessage>& fo
    // https://github.com/openapv/openapv/blob/main/readme/apv_isobmff.md#syntax-1
    const uint8_t* data = csd->data();
    size_t csdSize = csd->size();
    if (csdSize < 21 || data[5] != 0x01) {  // configurationVersion == 1
    if (csdSize < 17 || data[0] != 0x01) {  // configurationVersion == 1
        ALOGE("CSD is not according APV Configuration Standard");
        return;
    }
    uint8_t profileData = data[9];           // profile_idc
    uint8_t levelData = data[10];            // level_idc
    uint8_t band = data[11];                 // band_idc
    uint8_t bitDepth = (data[20] >> 4) + 8;  // bit_depth_minus8
    uint8_t profileData = data[5];             // profile_idc
    uint8_t levelData = data[6];               // level_idc
    uint8_t band = data[7];                    // band_idc
    uint8_t bitDepth = (data[16] & 0x0F) + 8;  // bit_depth_minus8

    const static ALookup<std::pair<uint8_t, uint8_t>, int32_t> profiles{
            {{33, 10}, APVProfile422_10},
            {{44, 12}, APVProfile422_10HDR10Plus},
+35 −5
Original line number Diff line number Diff line
@@ -2633,11 +2633,8 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
            break;
        }

        case FOURCC("apvC"):
        case FOURCC("av1C"):
        {
            if (!com::android::media::extractor::flags::extractor_mp4_enable_apv() &&
                chunk_type == FOURCC("apvC")) {
        case FOURCC("apvC"): {
            if (!com::android::media::extractor::flags::extractor_mp4_enable_apv()) {
                ALOGV("APV support not enabled");
                *offset += chunk_size;
                break;
@@ -2650,6 +2647,39 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
                return NO_MEMORY;
            }

            if (mDataSource->readAt(data_offset, buffer.get(), chunk_data_size) < chunk_data_size) {
                return ERROR_IO;
            }

            if (mLastTrack == NULL)
                return ERROR_MALFORMED;

            int bytes_to_skip = 4;
            if (chunk_data_size < bytes_to_skip) {
                return ERROR_MALFORMED;
            }
            // apvC extends FullBox so first 4 bytes of version and flag should be zero.
            for (int i = 0; i < bytes_to_skip; i++) {
                if (buffer[i] != 0) {
                    return ERROR_MALFORMED;
                }
            }

            // Advance the buffer pointer by 4 bytes as it contains 4 bytes of flag and version.
            AMediaFormat_setBuffer(mLastTrack->meta, AMEDIAFORMAT_KEY_CSD_0,
                                   buffer.get() + bytes_to_skip, chunk_data_size - bytes_to_skip);

            *offset += chunk_size;
            break;
        }
        case FOURCC("av1C"): {
            auto buffer = heapbuffer<uint8_t>(chunk_data_size);

            if (buffer.get() == NULL) {
                ALOGE("b/28471206");
                return NO_MEMORY;
            }

            if (mDataSource->readAt(
                        data_offset, buffer.get(), chunk_data_size) < chunk_data_size) {
                return ERROR_IO;