From 95fcef25b48e35b625899288971ab628efbf8584 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Thu, 23 Sep 2010 14:08:32 -0700 Subject: Depending on our preference to write 2-byte or 4-byte NALs, patch the codec specific data 'avcC' accordingly. Change-Id: I1423923fafbcac6911218277e2bbfa068e49dcc6 --- media/libstagefright/MPEG4Writer.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'media/libstagefright') diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp index f0d8943..ba1e218 100644 --- a/media/libstagefright/MPEG4Writer.cpp +++ b/media/libstagefright/MPEG4Writer.cpp @@ -2111,7 +2111,15 @@ void MPEG4Writer::Track::writeTrackHeader( mOwner->endBox(); // d263 } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_AVC, mime)) { CHECK(mCodecSpecificData); - CHECK(mCodecSpecificDataSize > 0); + CHECK(mCodecSpecificDataSize >= 5); + + // Patch avcc's lengthSize field to match the number + // of bytes we use to indicate the size of a nal unit. + uint8_t *ptr = (uint8_t *)mCodecSpecificData; + ptr[4] = + (ptr[4] & 0xfc) + | (mOwner->useNalLengthFour() ? 3 : 1); + mOwner->beginBox("avcC"); mOwner->write(mCodecSpecificData, mCodecSpecificDataSize); mOwner->endBox(); // avcC -- cgit v1.1