[vlc-commits] Revert "avcodec: do not use deprecated reordered_opaque"

Rémi Denis-Courmont git at videolan.org
Sun May 26 16:36:08 CEST 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun May 26 17:24:04 2013 +0300| [4759f121a53d8119221b0077b6469c80ff254149] | committer: Rémi Denis-Courmont

Revert "avcodec: do not use deprecated reordered_opaque"

This reverts commit e8c82fb8a9ea01dbc6b1dd98b527d2afce98e82d.
This broke DVD menus (fixes #8547).

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

 modules/codec/avcodec/video.c |   63 ++++++++++++++++++++++++++++++++---------
 1 file changed, 50 insertions(+), 13 deletions(-)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 1269542..c59b9d6 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -104,6 +104,7 @@ struct decoder_sys_t
 static void ffmpeg_InitCodec      ( decoder_t * );
 static void ffmpeg_CopyPicture    ( decoder_t *, picture_t *, AVFrame * );
 static int  ffmpeg_GetFrameBuf    ( struct AVCodecContext *, AVFrame * );
+static int  ffmpeg_ReGetFrameBuf( struct AVCodecContext *, AVFrame * );
 static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *, AVFrame * );
 static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *,
                                           const enum PixelFormat * );
@@ -313,7 +314,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
     /* Always use our get_buffer wrapper so we can calculate the
      * PTS correctly */
     p_sys->p_context->get_buffer = ffmpeg_GetFrameBuf;
-    p_sys->p_context->reget_buffer = avcodec_default_reget_buffer;
+    p_sys->p_context->reget_buffer = ffmpeg_ReGetFrameBuf;
     p_sys->p_context->release_buffer = ffmpeg_ReleaseFrameBuf;
     p_sys->p_context->opaque = p_dec;
 
@@ -567,18 +568,24 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
         picture_t *p_pic;
         AVPacket pkt;
 
-        post_mt( p_sys );
-
-        av_init_packet( &pkt );
-        pkt.data = p_block->p_buffer;
-        pkt.size = p_block->i_buffer;
-        pkt.pts = p_block->i_pts;
-        pkt.dts = p_block->i_dts;
+        /* Set the PTS/DTS in the context reordered_opaque field */
+        if( p_block->i_pts > VLC_TS_INVALID  )
+            p_context->reordered_opaque = (p_block->i_pts << 1) | 0;
+        else if( p_block->i_dts > VLC_TS_INVALID )
+            p_context->reordered_opaque = (p_block->i_dts << 1) | 1;
+        else
+            p_context->reordered_opaque = INT64_MIN;
+        p_sys->p_ff_pic->reordered_opaque = p_context->reordered_opaque;
 
         /* Make sure we don't reuse the same timestamps twice */
         p_block->i_pts =
         p_block->i_dts = VLC_TS_INVALID;
 
+        post_mt( p_sys );
+
+        av_init_packet( &pkt );
+        pkt.data = p_block->p_buffer;
+        pkt.size = p_block->i_buffer;
         i_used = avcodec_decode_video2( p_context, p_sys->p_ff_pic,
                                        &b_gotpicture, &pkt );
 
@@ -632,11 +639,33 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
         }
 
         /* Compute the PTS */
-        mtime_t i_pts =
-                    p_sys->p_ff_pic->pkt_pts;
-        if (i_pts <= VLC_TS_INVALID)
-            i_pts = p_sys->p_ff_pic->pkt_dts;
-
+        mtime_t i_pts = VLC_TS_INVALID;
+        if( p_sys->p_ff_pic->reordered_opaque != INT64_MIN )
+        {
+            mtime_t i_ts = p_sys->p_ff_pic->reordered_opaque >> 1;
+            bool    b_dts = p_sys->p_ff_pic->reordered_opaque & 1;
+            if( b_dts )
+            {
+                if( !p_context->has_b_frames ||
+                    !p_sys->b_has_b_frames ||
+                    !p_sys->p_ff_pic->reference ||
+                    p_sys->i_pts <= VLC_TS_INVALID )
+                    i_pts = i_ts;
+
+                /* Guess what ? The rules are different for Real Video :( */
+                if( (p_dec->fmt_in.i_codec == VLC_CODEC_RV30 ||
+                     p_dec->fmt_in.i_codec == VLC_CODEC_RV40) &&
+                    p_sys->b_has_b_frames )
+                {
+                    i_pts = VLC_TS_INVALID;
+                    if(p_sys->p_ff_pic->reference) i_pts = i_ts;
+                }
+            }
+            else
+            {
+                i_pts = i_ts;
+            }
+        }
         if( i_pts <= VLC_TS_INVALID )
             i_pts = p_sys->i_pts;
 
@@ -900,6 +929,7 @@ static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context,
     picture_t *p_pic;
 
     /* */
+    p_ff_pic->reordered_opaque = p_context->reordered_opaque;
     p_ff_pic->opaque = NULL;
 
     if( p_sys->p_va )
@@ -1024,6 +1054,13 @@ no_dr:
     post_mt( p_sys );
     return avcodec_default_get_buffer( p_context, p_ff_pic );
 }
+static int  ffmpeg_ReGetFrameBuf( struct AVCodecContext *p_context, AVFrame *p_ff_pic )
+{
+    p_ff_pic->reordered_opaque = p_context->reordered_opaque;
+
+    /* We always use default reget function, it works perfectly fine */
+    return avcodec_default_reget_buffer( p_context, p_ff_pic );
+}
 
 static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *p_context,
                                     AVFrame *p_ff_pic )



More information about the vlc-commits mailing list