}
static gboolean
-push_surface(GstVaapiDecoder *decoder, GstVaapiSurface *surface)
+push_surface(
+ GstVaapiDecoder *decoder,
+ GstVaapiSurface *surface,
+ GstClockTime timestamp
+)
{
GstVaapiDecoderPrivate * const priv = decoder->priv;
DecodedSurface *ds;
ds->proxy = gst_vaapi_surface_proxy_new(priv->context, surface);
if (ds->proxy) {
ds->status = GST_VAAPI_DECODER_STATUS_SUCCESS;
- gst_vaapi_surface_proxy_set_timestamp(ds->proxy, priv->surface_timestamp);
+ gst_vaapi_surface_proxy_set_timestamp(ds->proxy, timestamp);
}
else
ds->status = GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
gboolean
gst_vaapi_decoder_push_surface(
GstVaapiDecoder *decoder,
- GstVaapiSurface *surface
+ GstVaapiSurface *surface,
+ GstClockTime timestamp
)
{
- return push_surface(decoder, surface);
+ return push_surface(decoder, surface, timestamp);
}
};
struct _GstVaapiDecoderFfmpegPrivate {
+ GstClockTime in_timestamp; /* timestamp from the demuxer */
AVFrame *frame;
AVCodecParserContext *pctx;
AVCodecContext *avctx;
static int
gst_vaapi_decoder_ffmpeg_get_buffer(AVCodecContext *avctx, AVFrame *pic)
{
+ GstVaapiContextFfmpeg * const vactx = avctx->hwaccel_context;
GstVaapiContext *context;
GstVaapiSurface *surface;
GstVaapiID surface_id;
pic->linesize[1] = 0;
pic->linesize[2] = 0;
pic->linesize[3] = 0;
+ pic->pts = vactx->decoder->priv->in_timestamp;
return 0;
}
if (!surface)
return GST_VAAPI_DECODER_STATUS_ERROR_INVALID_SURFACE;
- gst_vaapi_decoder_push_surface(GST_VAAPI_DECODER_CAST(ffdecoder), surface);
+ gst_vaapi_decoder_push_surface(GST_VAAPI_DECODER_CAST(ffdecoder), surface, priv->frame->pts);
return GST_VAAPI_DECODER_STATUS_SUCCESS;
}
inbuf_size -= parsed_size;
}
} while (!got_frame && inbuf_size > 0);
+ inbuf_ts = priv->pctx->pts;
}
else {
outbuf = inbuf;
if (!got_frame && !GST_BUFFER_IS_EOS(buffer))
return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA;
+ priv->in_timestamp = inbuf_ts;
return decode_frame(ffdecoder, outbuf, outbuf_size);
}
gboolean
gst_vaapi_decoder_push_surface(
GstVaapiDecoder *decoder,
- GstVaapiSurface *surface
+ GstVaapiSurface *surface,
+ GstClockTime timestamp
) attribute_hidden;
G_END_DECLS