[vlc-devel] [PATCH 05/14] avcodec: retrieve decoded 3D stereo format if available

Felix Abecassis felix.abecassis at gmail.com
Tue Sep 9 19:08:24 CEST 2014


---
 modules/codec/avcodec/video.c | 44 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index d20276b..88fed49 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -38,6 +38,7 @@
 #include <libavcodec/avcodec.h>
 #include <libavutil/mem.h>
 #include <libavutil/pixdesc.h>
+#include <libavutil/stereo3d.h>
 
 #include "avcodec.h"
 #include "va.h"
@@ -383,6 +384,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
     p_dec->fmt_out.i_codec = p_dec->fmt_out.video.i_chroma;
 
     p_dec->fmt_out.video.orientation = p_dec->fmt_in.video.orientation;
+    p_dec->fmt_out.video.stereo = p_dec->fmt_in.video.stereo;
 
     if( p_dec->fmt_in.video.p_palette ) {
         p_sys->palette_sent = false;
@@ -727,6 +729,48 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
             }
         }
 
+        /* Forward the 3D stereo format in case it changed (e.g. modified by the packetizer) */
+        if( p_dec->fmt_in.video.stereo.mode )
+            p_dec->fmt_out.video.stereo = p_dec->fmt_in.video.stereo;
+
+#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT( 52, 20, 0 )
+        AVFrameSideData *side_data = av_frame_get_side_data( p_sys->p_ff_pic, AV_FRAME_DATA_STEREO3D );
+        if( side_data )
+        {
+            AVStereo3D *stereo = (AVStereo3D*)side_data->data;
+            vlc_stereo3d_mode stereo_mode;
+            switch( stereo->type )
+            {
+            case AV_STEREO3D_SIDEBYSIDE_QUINCUNX:
+            case AV_STEREO3D_SIDEBYSIDE:
+                stereo_mode = VLC_STEREO3D_SBS;
+                break;
+            case AV_STEREO3D_TOPBOTTOM:
+                stereo_mode = VLC_STEREO3D_TB;
+                break;
+            case AV_STEREO3D_FRAMESEQUENCE:
+                stereo_mode = VLC_STEREO3D_FRAME;
+                break;
+            case AV_STEREO3D_CHECKERBOARD:
+                stereo_mode = VLC_STEREO3D_CHECKERBOARD;
+                break;
+            case AV_STEREO3D_LINES:
+                stereo_mode = VLC_STEREO3D_ROW;
+                break;
+            case AV_STEREO3D_COLUMNS:
+                stereo_mode = VLC_STEREO3D_COL;
+                break;
+            default:
+                stereo_mode = VLC_STEREO3D_2D;
+                break;
+            }
+            p_dec->fmt_out.video.stereo.mode = stereo_mode;
+
+            if( stereo->flags & AV_STEREO3D_FLAG_INVERT )
+                p_dec->fmt_out.video.stereo.flags = VLC_STEREO3D_SWAP_EYES;
+        }
+#endif
+
         /* Send decoded frame to vout */
         if( i_pts > VLC_TS_INVALID)
         {
-- 
1.9.1




More information about the vlc-devel mailing list