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

Commit 4f684351 authored by Leena Winterrowd's avatar Leena Winterrowd Committed by Steve Kondik
Browse files

mpeg2ts: Clean up HEVC format checks

- Fix an invalid IDR frame check in ATSParser to avoid a crash on seek
- Move custom HEVC TS parsing logic to private namespace

CRs-Fixed: 808563
Change-Id: I1c5ce6719fedd1e2cc9a68c04eb8a7ad795ad3c8
parent 9fe3b80f
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -736,6 +736,14 @@ sp<MetaData> ExtendedUtils::MakeHEVCCodecSpecificData(const sp<ABuffer> &accessU
    meta->setInt32(kKeyWidth, (int32_t)177);
    meta->setInt32(kKeyHeight, (int32_t)144);

    // Let the decoder do the frame parsing for HEVC in case access unit data is
    // not aligned to frame boundaries.
    meta->setInt32(kKeyUseArbitraryMode, 1);

    // Set the container format as TS, so that timestamp reordering can be
    // enabled for HEVC TS clips.
    meta->setCString(kKeyFileFormat, MEDIA_MIMETYPE_CONTAINER_MPEG2TS);

    return meta;
}

+9 −7
Original line number Diff line number Diff line
@@ -937,14 +937,16 @@ void ATSParser::Stream::onPayloadData(
                     mElementaryPID, mStreamType);

                const char *mime;
                bool isAvcIDR = !strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)
                if (meta->findCString(kKeyMIMEType, &mime)) {
                    bool isAvcNonIdr = !strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)
                            && !IsIDR(accessUnit);
                bool isHevcIDR = !strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_HEVC)
                    bool isHevcNonIdr = !strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_HEVC)
                            && !ExtendedUtils::IsHevcIDR(accessUnit);
                if (meta->findCString(kKeyMIMEType, &mime)
                        && (isAvcIDR || isHevcIDR)) {
                    if (isAvcNonIdr || isHevcNonIdr) {
                        // Keep dequeuing until we find the first IDR frame
                        continue;
                    }
                }
                mSource = new AnotherPacketSource(meta);
                mSource->queueAccessUnit(accessUnit);
            }
+0 −15
Original line number Diff line number Diff line
@@ -47,9 +47,6 @@
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MetaData.h>
#include <media/stagefright/Utils.h>
#ifdef ENABLE_AV_ENHANCEMENTS
#include <QCMetaData.h>
#endif

#include "include/avc_utils.h"
#include "include/ExtendedUtils.h"
@@ -539,18 +536,6 @@ sp<ABuffer> ElementaryStreamQueue::dequeueAccessUnit() {
                mFormat = MakeAVCCodecSpecificData(accessUnit);
            } else if (mMode == H265) {
                mFormat = ExtendedUtils::MakeHEVCCodecSpecificData(accessUnit);
#ifdef ENABLE_AV_ENHANCEMENTS
                if (mFormat != NULL) {
                    // Unlike H264, we do not require HEVC data to be aligned.
                    // To handle this, let the decoder do the frame parsing.
                    mFormat->setInt32(kKeyUseArbitraryMode, 1);

                    // Set the container format as TS, so that timestamp
                    // reordering can be enable for HEVC TS clips
                    mFormat->setCString(kKeyFileFormat,
                            MEDIA_MIMETYPE_CONTAINER_MPEG2TS);
                }
#endif
            }
        }