Bug 1219134: P1. Fix pts calculation in FFmpeg video decoder. r=edwin

This is the primary reason why we got no pts returned (pts were set to 0) when using early version of LibAV. Apparently you are expected to set the pts when allocating the buffer of a frame.
This is undocumented, but both LibAV and FFmpeg do so internally. So do the same.
This commit is contained in:
Jean-Yves Avenard 2015-10-30 12:47:38 +11:00
parent 5d07bdc7b7
commit fe233d60f5

View File

@ -16,8 +16,6 @@
#include "FFmpegLog.h"
#include "mozilla/PodOperations.h"
#define GECKO_FRAME_TYPE 0x00093CC0
typedef mozilla::layers::Image Image;
typedef mozilla::layers::PlanarYCbCrImage PlanarYCbCrImage;
@ -317,15 +315,19 @@ FFmpegH264Decoder<LIBAV_VER>::AllocateYUV420PVideoBuffer(
aFrame->data[i] = buffer + offsets[i] + planesEdgeWidth[i];
}
// Unused, but needs to be non-zero to keep ffmpeg happy.
aFrame->type = GECKO_FRAME_TYPE;
aFrame->extended_data = aFrame->data;
aFrame->width = aCodecContext->width;
aFrame->height = aCodecContext->height;
aFrame->opaque = static_cast<void*>(image.forget().take());
aFrame->type = FF_BUFFER_TYPE_USER;
aFrame->reordered_opaque = aCodecContext->reordered_opaque;
#if LIBAVCODEC_VERSION_MAJOR == 53
if (aCodecContext->pkt) {
aFrame->pkt_pts = aCodecContext->pkt->pts;
}
#endif
return 0;
}