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 4e0d8487b0
commit b9466da3da

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,20 @@ 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 (aCodecContext->pkt) {
aFrame->pkt_pts = aCodecContext->pkt->pts;
} else {
aFrame->pkt_pts = AV_NOPTS_VALUE;
}
return 0;
}