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

Commit 856a9b56 authored by Ray Essick's avatar Ray Essick
Browse files

Dolbyvision parsing used disallowed functions

The Dolbyvision box parsing uses raw access to the AMessage routines
underneath the AMediaFormat_* routines. This violates the mainline
api boundary rules and causes crashes now that the underlying
AMessage implementation has changed.

The code wanted to delete a CSD stored in an AMediaFormat, but there is
no ndk/stable interface to do that.  The available solution was to
replace that buffer with an empty one; I don't know if this will impact
the dolbyvision decoders.

Bug: 129367182
Bug: 193017338
Test: atest android.media.cts.MediaExtractor
Change-Id: Ib70db91c7b5209a95b8bcfd89fbb2dfc41194eba
parent 38a8ef7c
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -1126,7 +1126,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
                    void *data;
                    size_t size;

                    if (AMediaFormat_getBuffer(mLastTrack->meta, AMEDIAFORMAT_KEY_CSD_2, &data, &size)) {
                    if (AMediaFormat_getBuffer(mLastTrack->meta, AMEDIAFORMAT_KEY_CSD_2,
                                               &data, &size)
                        && size >= 5) {
                        const uint8_t *ptr = (const uint8_t *)data;
                        const uint8_t profile = ptr[2] >> 1;
                        const uint8_t bl_compatibility_id = (ptr[4]) >> 4;
@@ -1163,8 +1165,12 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
                            mLastTrack->next = track_b;
                            track_b->next = NULL;

                            auto id = track_b->meta->mFormat->findEntryByName(AMEDIAFORMAT_KEY_CSD_2);
                            track_b->meta->mFormat->removeEntryAt(id);
                            // we want to remove the csd-2 key from the metadata, but
                            // don't have an AMediaFormat_* function to do so. Settle
                            // for replacing this csd-2 with an empty csd-2.
                            uint8_t emptybuffer[8] = {};
                            AMediaFormat_setBuffer(track_b->meta, AMEDIAFORMAT_KEY_CSD_2,
                                                   emptybuffer, 0);

                            if (4 == profile || 7 == profile || 8 == profile ) {
                                AMediaFormat_setString(track_b->meta,