Try to fix timestamps (step 1). Looks OK on H55.

This commit is contained in:
gb 2010-05-03 08:32:46 +00:00 committed by Gwenole Beauchesne
parent cf29e752de
commit ecff33db03
3 changed files with 17 additions and 6 deletions

View file

@ -195,7 +195,11 @@ destroy_surface(DecodedSurface *ds)
}
static gboolean
push_surface(GstVaapiDecoder *decoder, GstVaapiSurface *surface)
push_surface(
GstVaapiDecoder *decoder,
GstVaapiSurface *surface,
GstClockTime timestamp
)
{
GstVaapiDecoderPrivate * const priv = decoder->priv;
DecodedSurface *ds;
@ -209,7 +213,7 @@ push_surface(GstVaapiDecoder *decoder, GstVaapiSurface *surface)
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;
@ -586,8 +590,9 @@ gst_vaapi_decoder_ensure_context(
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);
}

View file

@ -54,6 +54,7 @@ struct _GstVaapiContextFfmpeg {
};
struct _GstVaapiDecoderFfmpegPrivate {
GstClockTime in_timestamp; /* timestamp from the demuxer */
AVFrame *frame;
AVCodecParserContext *pctx;
AVCodecContext *avctx;
@ -233,6 +234,7 @@ gst_vaapi_decoder_ffmpeg_get_format(AVCodecContext *avctx, const enum PixelForma
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;
@ -260,6 +262,7 @@ gst_vaapi_decoder_ffmpeg_get_buffer(AVCodecContext *avctx, AVFrame *pic)
pic->linesize[1] = 0;
pic->linesize[2] = 0;
pic->linesize[3] = 0;
pic->pts = vactx->decoder->priv->in_timestamp;
return 0;
}
@ -446,7 +449,7 @@ decode_frame(GstVaapiDecoderFfmpeg *ffdecoder, guchar *buf, guint buf_size)
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;
}
@ -489,6 +492,7 @@ gst_vaapi_decoder_ffmpeg_decode(GstVaapiDecoder *decoder, GstBuffer *buffer)
inbuf_size -= parsed_size;
}
} while (!got_frame && inbuf_size > 0);
inbuf_ts = priv->pctx->pts;
}
else {
outbuf = inbuf;
@ -499,6 +503,7 @@ gst_vaapi_decoder_ffmpeg_decode(GstVaapiDecoder *decoder, GstBuffer *buffer)
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);
}

View file

@ -112,7 +112,8 @@ gst_vaapi_decoder_ensure_context(
gboolean
gst_vaapi_decoder_push_surface(
GstVaapiDecoder *decoder,
GstVaapiSurface *surface
GstVaapiSurface *surface,
GstClockTime timestamp
) attribute_hidden;
G_END_DECLS