[vlc-devel] commit: Fixed timestamp in ffmpeg reget_buffer callback. (Laurent Aimar )

git version control git at videolan.org
Tue Sep 2 01:18:29 CEST 2008


vlc | branch: 0.9-bugfix | Laurent Aimar <fenrir at videolan.org> | Tue Sep  2 01:09:29 2008 +0200| [144e48a76abe187c7789134f4c4cc403deccea76] | committer: Christophe Mutricy 

Fixed timestamp in ffmpeg reget_buffer callback.
(cherry picked from commit 0ef30fab8dc334392f4425fc63033a1e9b324cf8)

Signed-off-by: Christophe Mutricy <xtophe at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=144e48a76abe187c7789134f4c4cc403deccea76
---

 modules/codec/avcodec/video.c |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 973aff4..4381853 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -871,12 +871,20 @@ static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context,
 static int  ffmpeg_ReGetFrameBuf( struct AVCodecContext *p_context, AVFrame *p_ff_pic )
 {
     decoder_t *p_dec = (decoder_t *)p_context->opaque;
+    int i_ret;
 
-    /* Set picture PTS */
-    ffmpeg_SetFrameBufferPts( p_dec, p_ff_pic );
+    /* */
+    p_ff_pic->pts = AV_NOPTS_VALUE;
 
     /* We always use default reget function, it works perfectly fine */
-    return avcodec_default_reget_buffer( p_context, p_ff_pic );
+    i_ret = avcodec_default_reget_buffer( p_context, p_ff_pic );
+
+    /* Set picture PTS if avcodec_default_reget_buffer didn't set it (through a
+     * ffmpeg_GetFrameBuf call) */
+    if( !i_ret && p_ff_pic->pts == AV_NOPTS_VALUE )
+        ffmpeg_SetFrameBufferPts( p_dec, p_ff_pic );
+
+    return i_ret;
 }
 
 static void ffmpeg_SetFrameBufferPts( decoder_t *p_dec, AVFrame *p_ff_pic )
@@ -897,9 +905,15 @@ static void ffmpeg_SetFrameBufferPts( decoder_t *p_dec, AVFrame *p_ff_pic )
         {
             p_ff_pic->pts = p_sys->input_dts;
         }
-        else p_ff_pic->pts = 0;
+        else
+        {
+            p_ff_pic->pts = 0;
+        }
+    }
+    else
+    {
+        p_ff_pic->pts = 0;
     }
-    else p_ff_pic->pts = 0;
 
     if( p_sys->i_pts ) /* make sure 1st frame has a pts > 0 */
     {




More information about the vlc-devel mailing list