Try to fix timestamps (step 1). Looks OK on H55.
authorgb <gb@5584edef-b1fe-4b99-b61b-dd2bab72e969>
Mon, 3 May 2010 08:32:46 +0000 (08:32 +0000)
committerGwenole Beauchesne <gbeauchesne@splitted-desktop.com>
Mon, 20 Sep 2010 10:55:42 +0000 (12:55 +0200)
gst-libs/gst/vaapi/gstvaapidecoder.c
gst-libs/gst/vaapi/gstvaapidecoder_ffmpeg.c
gst-libs/gst/vaapi/gstvaapidecoder_priv.h

index 2cca2e0..675600e 100644 (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);
 }
index 05ded90..cbb9845 100644 (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);
 }
 
index 9b9a7be..fae29f6 100644 (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