Bug 1110534: Add AnnexB support to FFmpeg h264 decoder. r=kentuckyfriedtakahe

This commit is contained in:
Jean-Yves Avenard 2014-12-23 14:36:09 +11:00
parent 4f568fc6f0
commit 98dd294493
2 changed files with 11 additions and 5 deletions

View File

@ -24,6 +24,7 @@ FFmpegDataDecoder<LIBAV_VER>::FFmpegDataDecoder(MediaTaskQueue* aTaskQueue,
: mTaskQueue(aTaskQueue)
, mCodecContext(nullptr)
, mFrame(NULL)
, mExtraData(nullptr)
, mCodecID(aCodecID)
{
MOZ_COUNT_CTOR(FFmpegDataDecoder);
@ -93,11 +94,15 @@ FFmpegDataDecoder<LIBAV_VER>::Init()
mCodecContext->thread_type = FF_THREAD_SLICE | FF_THREAD_FRAME;
mCodecContext->thread_safe_callbacks = false;
mCodecContext->extradata_size = mExtraData->Length();
for (int i = 0; i < FF_INPUT_BUFFER_PADDING_SIZE; i++) {
mExtraData->AppendElement(0);
if (mExtraData) {
mCodecContext->extradata_size = mExtraData->Length();
for (int i = 0; i < FF_INPUT_BUFFER_PADDING_SIZE; i++) {
mExtraData->AppendElement(0);
}
mCodecContext->extradata = mExtraData->Elements();
} else {
mCodecContext->extradata_size = 0;
}
mCodecContext->extradata = mExtraData->Elements();
if (codec->capabilities & CODEC_CAP_DR1) {
mCodecContext->flags |= CODEC_FLAG_EMU_EDGE;

View File

@ -10,6 +10,7 @@
#include "ImageContainer.h"
#include "mp4_demuxer/mp4_demuxer.h"
#include "mp4_demuxer/AnnexB.h"
#include "FFmpegH264Decoder.h"
@ -32,7 +33,6 @@ FFmpegH264Decoder<LIBAV_VER>::FFmpegH264Decoder(
, mImageContainer(aImageContainer)
{
MOZ_COUNT_CTOR(FFmpegH264Decoder);
mExtraData = aConfig.extra_data;
}
nsresult
@ -53,6 +53,7 @@ FFmpegH264Decoder<LIBAV_VER>::DoDecodeFrame(mp4_demuxer::MP4Sample* aSample)
AVPacket packet;
av_init_packet(&packet);
mp4_demuxer::AnnexB::ConvertSampleToAnnexB(aSample);
aSample->Pad(FF_INPUT_BUFFER_PADDING_SIZE);
packet.data = aSample->data;
packet.size = aSample->size;