summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/avc
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2012-08-29 15:06:31 +0300
committerMartin Storsjo <martin@martin.st>2013-09-25 11:30:38 +0300
commit67606c31f41959589d46fbd9e845a2974a48e505 (patch)
tree8b79e824c25568a811b3dd773788a0d47bb85ec0 /media/libstagefright/codecs/avc
parente56f3c96fa6e7550b67e8b049f999aaa2ada1192 (diff)
downloadframeworks_av-67606c31f41959589d46fbd9e845a2974a48e505.zip
frameworks_av-67606c31f41959589d46fbd9e845a2974a48e505.tar.gz
frameworks_av-67606c31f41959589d46fbd9e845a2974a48e505.tar.bz2
avcenc: Prepend startcodes to output buffers
This makes the encoder output data that is similar to what actual HW encoders output. This form is also what is expected by virtually every other component - the only exception seems to be stagefright's MPEG4Writer which happens to work with this format. This also makes the encoder's output work in other decoders when passing through directly. If feeding the encoded data straight through to a decoder (such as in the EncodeDecodeTest CTS test), the output from OMX.google.h264.encoder cannot be decoded by e.g. OMX.Nvidia.h264.decode on a Nexus 7 or OMX.SEC.avc.dec on a Galaxy S3. Change-Id: I6e16433a4a66936e3080723c8233681f53bd55e5
Diffstat (limited to 'media/libstagefright/codecs/avc')
-rw-r--r--media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp
index 1d66120..4a21a3e 100644
--- a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp
+++ b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp
@@ -871,7 +871,13 @@ void SoftAVCEncoder::onQueueFilled(OMX_U32 portIndex) {
CHECK(encoderStatus == AVCENC_SUCCESS || encoderStatus == AVCENC_NEW_IDR);
dataLength = outHeader->nAllocLen; // Reset the output buffer length
if (inHeader->nFilledLen > 0) {
+ if (outHeader->nAllocLen >= 4) {
+ memcpy(outPtr, "\x00\x00\x00\x01", 4);
+ outPtr += 4;
+ dataLength -= 4;
+ }
encoderStatus = PVAVCEncodeNAL(mHandle, outPtr, &dataLength, &type);
+ dataLength = outPtr + dataLength - outHeader->pBuffer;
if (encoderStatus == AVCENC_SUCCESS) {
CHECK(NULL == PVAVCEncGetOverrunBuffer(mHandle));
} else if (encoderStatus == AVCENC_PICTURE_READY) {