зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1035059 - Add input padding for libav; r=edwin
This commit is contained in:
Родитель
9cfc85031c
Коммит
77a674148c
|
@ -71,6 +71,7 @@ FFmpegAACDecoder<LIBAV_VER>::DecodePacket(MP4Sample* aSample)
|
|||
AVPacket packet;
|
||||
av_init_packet(&packet);
|
||||
|
||||
aSample->Pad(FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
packet.data = aSample->data;
|
||||
packet.size = aSample->size;
|
||||
packet.pos = aSample->byte_offset;
|
||||
|
|
|
@ -88,8 +88,11 @@ FFmpegDataDecoder<LIBAV_VER>::Init()
|
|||
mCodecContext.thread_type = FF_THREAD_SLICE | FF_THREAD_FRAME;
|
||||
mCodecContext.thread_safe_callbacks = false;
|
||||
|
||||
mCodecContext.extradata = mExtraData.begin();
|
||||
mCodecContext.extradata_size = mExtraData.length();
|
||||
for (int i = 0; i < FF_INPUT_BUFFER_PADDING_SIZE; i++) {
|
||||
mExtraData.append(0);
|
||||
}
|
||||
mCodecContext.extradata = mExtraData.begin();
|
||||
|
||||
AVDictionary* opts = nullptr;
|
||||
if (avcodec_open2(&mCodecContext, codec, &opts) < 0) {
|
||||
|
|
|
@ -53,6 +53,7 @@ FFmpegH264Decoder<LIBAV_VER>::DecodeFrame(mp4_demuxer::MP4Sample* aSample)
|
|||
AVPacket packet;
|
||||
av_init_packet(&packet);
|
||||
|
||||
aSample->Pad(FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
packet.data = aSample->data;
|
||||
packet.size = aSample->size;
|
||||
packet.pts = aSample->composition_timestamp;
|
||||
|
|
|
@ -128,6 +128,31 @@ MP4Sample::Update()
|
|||
size = mMediaBuffer->range_length();
|
||||
}
|
||||
|
||||
void
|
||||
MP4Sample::Pad(size_t aPaddingBytes)
|
||||
{
|
||||
MOZ_ASSERT(data == mMediaBuffer->data());
|
||||
|
||||
size_t newSize = size + aPaddingBytes;
|
||||
|
||||
// If the existing MediaBuffer has enough space then we just recycle it. If
|
||||
// not then we copy to a new buffer.
|
||||
uint8_t* newData = mMediaBuffer && newSize <= mMediaBuffer->size()
|
||||
? data
|
||||
: new uint8_t[newSize];
|
||||
|
||||
memset(newData + size, 0, aPaddingBytes);
|
||||
|
||||
if (newData != data) {
|
||||
memcpy(newData, data, size);
|
||||
extra_buffer = data = newData;
|
||||
if (mMediaBuffer) {
|
||||
mMediaBuffer->release();
|
||||
mMediaBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MP4Sample::Prepend(const uint8_t* aData, size_t aSize)
|
||||
{
|
||||
|
|
|
@ -80,6 +80,7 @@ public:
|
|||
MP4Sample();
|
||||
~MP4Sample();
|
||||
void Update();
|
||||
void Pad(size_t aPaddingBytes);
|
||||
|
||||
stagefright::MediaBuffer* mMediaBuffer;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче