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

Vittorio Giovara vittorio.giovara at gmail.com
Sat Aug 9 15:21:07 CEST 2014


On Fri, Aug 8, 2014 at 7:13 PM, Felix Abecassis
<felix.abecassis at gmail.com> wrote:
> ---
>  modules/codec/avcodec/video.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>
> diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
> index d1fa89b..9e0a7c9 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"
> @@ -368,6 +369,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_format = p_dec->fmt_in.video.stereo_format;
>
>      if( p_dec->fmt_in.video.p_palette ) {
>          p_sys->palette_sent = false;
> @@ -711,6 +713,30 @@ 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_format.mode )
> +            p_dec->fmt_out.video.stereo_format = p_dec->fmt_in.video.stereo_format;
> +
> +        AVFrameSideData *side_data = av_frame_get_side_data( p_sys->p_ff_pic, AV_FRAME_DATA_STEREO3D );
> +        if( side_data )
> +        {
> +            AVStereo3D *stereo_format = (AVStereo3D*)side_data->data;
> +            vlc_stereo3d_mode stereo_mode;
> +            switch (stereo_format->type)
> +            {
> +            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_LINES: stereo_mode = VLC_STEREO3D_ROW; break;
> +            case AV_STEREO3D_COLUMNS: stereo_mode = VLC_STEREO3D_COL; break;
> +            default: stereo_mode = VLC_STEREO3D_2D; break;

y u no love quincunx? :)

> +            }
> +            p_dec->fmt_out.video.stereo_format.mode = stereo_mode;
> +
> +            if( stereo_format->flags == AV_STEREO3D_FLAG_INVERT )

flags is just a mask so you might want to check it with a bitwise operation

> +                p_dec->fmt_out.video.stereo_format.flags = VLC_STEREO3D_SWAP_EYES;
> +        }
> +
>          /* Send decoded frame to vout */
>          if( i_pts > VLC_TS_INVALID)
>          {

seems ok besides the version check

-- 
Vittorio



More information about the vlc-devel mailing list