[FFmpeg-devel] [PATCH v4 16/21] cbs_h264: Add a function to turn stereo 3D metadata into SEI

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Mon Feb 24 03:57:00 EET 2020


Mark Thompson:
> ---
>  libavcodec/cbs_h264.c | 47 +++++++++++++++++++++++++++++++++++++++++++
>  libavcodec/cbs_h264.h |  8 ++++++++
>  2 files changed, 55 insertions(+)
> 
> diff --git a/libavcodec/cbs_h264.c b/libavcodec/cbs_h264.c
> index 75759c7f25..cc52f68550 100644
> --- a/libavcodec/cbs_h264.c
> +++ b/libavcodec/cbs_h264.c
> @@ -16,6 +16,8 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>   */
>  
> +#include "libavutil/stereo3d.h"
> +
>  #include "cbs_h264.h"
>  
>  int ff_cbs_h264_add_sei_message(CodedBitstreamContext *ctx,
> @@ -104,3 +106,48 @@ void ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx,
>                  (sei->payload_count - position) * sizeof(*sei->payload));
>      }
>  }
> +
> +void ff_cbs_h264_fill_sei_frame_packing_arrangement(H264RawSEIFramePackingArrangement *fp,
> +                                                    const AVStereo3D *st)
> +{
> +    static const int type_map[] = {

Why not uint8_t instead of int? After all,
frame_packing_arrangement_type is an uint8_t.

> +        [AV_STEREO3D_2D]                  = 6,
> +        [AV_STEREO3D_SIDEBYSIDE]          = 3,
> +        [AV_STEREO3D_TOPBOTTOM]           = 4,
> +        [AV_STEREO3D_FRAMESEQUENCE]       = 5,
> +        [AV_STEREO3D_CHECKERBOARD]        = 0,
> +        [AV_STEREO3D_SIDEBYSIDE_QUINCUNX] = 3,
> +        [AV_STEREO3D_LINES]               = 2,
> +        [AV_STEREO3D_COLUMNS]             = 1,
> +    };
> +
> +    memset(fp, 0, sizeof(*fp));
> +
> +    if (st->type >= FF_ARRAY_ELEMS(type_map))
> +        return;
> +
> +    fp->frame_packing_arrangement_type = type_map[st->type];
> +
> +    fp->quincunx_sampling_flag =
> +        st->type == AV_STEREO3D_CHECKERBOARD ||
> +        st->type == AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
> +
> +    if (st->type == AV_STEREO3D_2D)
> +        fp->content_interpretation_type = 0;
> +    else if (st->flags & AV_STEREO3D_FLAG_INVERT)
> +        fp->content_interpretation_type = 2;
> +    else
> +        fp->content_interpretation_type = 1;
> +
> +    if (st->type == AV_STEREO3D_FRAMESEQUENCE) {
> +        if (st->flags & AV_STEREO3D_FLAG_INVERT)
> +            fp->current_frame_is_frame0_flag =
> +                st->view == AV_STEREO3D_VIEW_RIGHT;
> +        else
> +            fp->current_frame_is_frame0_flag =
> +                st->view == AV_STEREO3D_VIEW_LEFT;
> +    }
> +
> +    fp->frame_packing_arrangement_repetition_period =
> +        st->type != AV_STEREO3D_FRAMESEQUENCE;
> +}
> diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
> index 512674ec07..76211c976b 100644
> --- a/libavcodec/cbs_h264.h
> +++ b/libavcodec/cbs_h264.h
> @@ -525,4 +525,12 @@ void ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx,
>                                      CodedBitstreamUnit *nal_unit,
>                                      int position);
>  
> +struct AVStereo3D;
> +/**
> + * Fill an SEI Frame Packing Arrangement structure with values derived from
> + * the AVStereo3D side-data structure.
> + */
> +void ff_cbs_h264_fill_sei_frame_packing_arrangement(H264RawSEIFramePackingArrangement *fp,
> +                                                    const struct AVStereo3D *st);
> +
>  #endif /* AVCODEC_CBS_H264_H */
> 



More information about the ffmpeg-devel mailing list