[vlc-devel] [PATCH] avcodec: keep the multiview mode between format updates

Steve Lhomme robux4 at ycbcr.xyz
Sat Oct 27 08:38:30 CEST 2018


It's a state in extra data that is kept until it changes in the stream
---
 modules/codec/avcodec/video.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 91ee22f878..9a4b99a0f1 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -370,11 +370,12 @@ static int lavc_UpdateVideoFormat(decoder_t *dec, AVCodecContext *ctx,
     fmt_out.p_palette = dec->fmt_out.video.p_palette;
     dec->fmt_out.video.p_palette = NULL;
 
+    fmt_out.multiview_mode = dec->fmt_out.video.multiview_mode;
+
     es_format_Change(&dec->fmt_out, VIDEO_ES, fmt_out.i_chroma);
     dec->fmt_out.video = fmt_out;
     dec->fmt_out.video.orientation = dec->fmt_in.video.orientation;
     dec->fmt_out.video.projection_mode = dec->fmt_in.video.projection_mode;
-    dec->fmt_out.video.multiview_mode = dec->fmt_in.video.multiview_mode;
     dec->fmt_out.video.pose = dec->fmt_in.video.pose;
     if ( dec->fmt_in.video.mastering.max_luminance )
         dec->fmt_out.video.mastering = dec->fmt_in.video.mastering;
@@ -913,31 +914,32 @@ static int DecodeSidedata( decoder_t *p_dec, const AVFrame *frame, picture_t *p_
                                     AV_FRAME_DATA_STEREO3D );
     if( p_stereo3d_data )
     {
+        video_multiview_mode_t current_mode = p_dec->fmt_out.video.multiview_mode;
         const struct AVStereo3D *stereo_data =
                 (const AVStereo3D *) p_stereo3d_data->data;
         switch (stereo_data->type)
         {
         case AV_STEREO3D_SIDEBYSIDE:
-            p_pic->format.multiview_mode = MULTIVIEW_STEREO_SBS;
+            p_dec->fmt_out.video.multiview_mode = MULTIVIEW_STEREO_SBS;
             break;
         case AV_STEREO3D_TOPBOTTOM:
-            p_pic->format.multiview_mode = MULTIVIEW_STEREO_TB;
+            p_dec->fmt_out.video.multiview_mode = MULTIVIEW_STEREO_TB;
             break;
         case AV_STEREO3D_FRAMESEQUENCE:
-            p_pic->format.multiview_mode = MULTIVIEW_STEREO_FRAME;
+            p_dec->fmt_out.video.multiview_mode = MULTIVIEW_STEREO_FRAME;
             break;
         case AV_STEREO3D_COLUMNS:
-            p_pic->format.multiview_mode = MULTIVIEW_STEREO_ROW;
+            p_dec->fmt_out.video.multiview_mode = MULTIVIEW_STEREO_ROW;
             break;
         case AV_STEREO3D_LINES:
-            p_pic->format.multiview_mode = MULTIVIEW_STEREO_COL;
+            p_dec->fmt_out.video.multiview_mode = MULTIVIEW_STEREO_COL;
             break;
         case AV_STEREO3D_CHECKERBOARD:
-            p_pic->format.multiview_mode = MULTIVIEW_STEREO_CHECKERBOARD;
+            p_dec->fmt_out.video.multiview_mode = MULTIVIEW_STEREO_CHECKERBOARD;
             break;
         default:
         case AV_STEREO3D_2D:
-            p_pic->format.multiview_mode = MULTIVIEW_2D;
+            p_dec->fmt_out.video.multiview_mode = MULTIVIEW_2D;
             break;
         }
 #if LIBAVUTIL_VERSION_CHECK( 56, 7, 0, 4, 100 )
@@ -947,14 +949,10 @@ static int DecodeSidedata( decoder_t *p_dec, const AVFrame *frame, picture_t *p_
         p_dec->fmt_out.video.b_multiview_right_eye_first = p_pic->format.b_multiview_right_eye_first;
 #endif
 
-        if (p_dec->fmt_out.video.multiview_mode != p_pic->format.multiview_mode)
-        {
-            p_dec->fmt_out.video.multiview_mode = p_pic->format.multiview_mode;
+        if (p_dec->fmt_out.video.multiview_mode != current_mode)
             format_changed = true;
-        }
     }
-    else
-        p_pic->format.multiview_mode = p_dec->fmt_out.video.multiview_mode;
+    p_pic->format.multiview_mode = p_dec->fmt_out.video.multiview_mode;
 
     if (format_changed && decoder_UpdateVideoFormat( p_dec ))
         return -1;
-- 
2.17.0



More information about the vlc-devel mailing list