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

Commit 5756875f authored by Sham Rathod's avatar Sham Rathod
Browse files

Remove flag and version from CSD of APV.

As encoder is creating CSD without version and flag,
CSD should follow same pattern in case of setting CSD
from extractor and ignore first four byte of version and flag
which comes from FullBox. CSD will only have the
ApvDecoderConfigurationBox data.

Bug: 391716515
Bug: 392976813
Bug: 392976819
Test: atest MediaExtractorTest
Change-Id: If761576be822bbdd2395f6d7fb99a9d72b7322f4
parent 2e264b11
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;