[vlc-commits] [Git][videolan/vlc][master] 3 commits: avcodec: use enum AVCodecID where a codec ID is expected

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Jun 29 12:47:12 UTC 2021



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
c663b44b by Steve Lhomme at 2021-06-29T09:56:47+00:00
avcodec: use enum AVCodecID where a codec ID is expected

- - - - -
b6f3628f by Steve Lhomme at 2021-06-29T09:56:47+00:00
avcodec: use enum AVPixelFormat where a pixel format is expected

- - - - -
c78f7ac9 by Steve Lhomme at 2021-06-29T09:56:47+00:00
avcodec: always use AVPixelFormat instead of PixelFormat

AVPixelFormat was introduced in libavutil 51.42.0 we require 55.9.0.

- - - - -


18 changed files:

- modules/codec/avcodec/avcodec.c
- modules/codec/avcodec/avcodec.h
- modules/codec/avcodec/avcommon_compat.h
- modules/codec/avcodec/chroma.c
- modules/codec/avcodec/chroma.h
- modules/codec/avcodec/d3d11va.c
- modules/codec/avcodec/dxva2.c
- modules/codec/avcodec/encoder.c
- modules/codec/avcodec/fourcc.c
- modules/codec/avcodec/va.c
- modules/codec/avcodec/va.h
- modules/codec/avcodec/vaapi.c
- modules/codec/avcodec/video.c
- modules/demux/avformat/demux.c
- modules/demux/avformat/mux.c
- modules/hw/vdpau/avcodec.c
- modules/packetizer/avparser.c
- modules/video_chroma/swscale.c


Changes:

=====================================
modules/codec/avcodec/avcodec.c
=====================================
@@ -202,7 +202,7 @@ vlc_module_end ()
 AVCodecContext *ffmpeg_AllocContext( decoder_t *p_dec,
                                      const AVCodec **restrict codecp )
 {
-    unsigned i_codec_id;
+    enum AVCodecID i_codec_id;
     const char *psz_namecodec;
     const AVCodec *p_codec = NULL;
 


=====================================
modules/codec/avcodec/avcodec.h
=====================================
@@ -25,8 +25,8 @@
 
 /* VLC <-> avcodec tables */
 bool GetFfmpegCodec( enum es_format_category_e cat, vlc_fourcc_t i_fourcc,
-                     unsigned *pi_ffmpeg_codec, const char **ppsz_name );
-vlc_fourcc_t GetVlcFourcc( unsigned i_ffmpeg_codec );
+                     enum AVCodecID *pi_ffmpeg_codec, const char **ppsz_name );
+vlc_fourcc_t GetVlcFourcc( enum AVCodecID i_ffmpeg_codec );
 vlc_fourcc_t GetVlcAudioFormat( int i_sample_fmt );
 
 /* Video encoder module */


=====================================
modules/codec/avcodec/avcommon_compat.h
=====================================
@@ -96,11 +96,6 @@
 # define FF_API_AUDIOCONVERT 1
 #endif
 
-/* libavutil/pixfmt.h */
-#ifndef PixelFormat
-# define PixelFormat AVPixelFormat
-#endif
-
 #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
 # include <libavformat/avformat.h>
 


=====================================
modules/codec/avcodec/chroma.c
=====================================
@@ -53,7 +53,7 @@
 static const struct
 {
     vlc_fourcc_t  i_chroma;
-    int           i_chroma_id;
+    enum AVPixelFormat i_chroma_id;
     uint32_t      i_rmask;
     uint32_t      i_gmask;
     uint32_t      i_bmask;
@@ -206,7 +206,7 @@ static const struct
 };
 
 /* FIXME special case the RGB formats */
-int GetFfmpegChroma( int *restrict i_ffmpeg_chroma, const video_format_t *fmt )
+int GetFfmpegChroma( enum AVPixelFormat *restrict i_ffmpeg_chroma, const video_format_t *fmt )
 {
     for( int i = 0; chroma_table[i].i_chroma != 0; i++ )
     {
@@ -227,7 +227,7 @@ int GetFfmpegChroma( int *restrict i_ffmpeg_chroma, const video_format_t *fmt )
     return VLC_EGENERIC;
 }
 
-vlc_fourcc_t FindVlcChroma( int i_ffmpeg_id )
+vlc_fourcc_t FindVlcChroma( enum AVPixelFormat i_ffmpeg_id )
 {
     for( int i = 0; chroma_table[i].i_chroma != 0; i++ )
         if( chroma_table[i].i_chroma_id == i_ffmpeg_id )
@@ -235,7 +235,7 @@ vlc_fourcc_t FindVlcChroma( int i_ffmpeg_id )
     return 0;
 }
 
-int GetVlcChroma( video_format_t *fmt, int i_ffmpeg_chroma )
+int GetVlcChroma( video_format_t *fmt, enum AVPixelFormat i_ffmpeg_chroma )
 {
     for( int i = 0; chroma_table[i].i_chroma != 0; i++ )
     {
@@ -252,7 +252,7 @@ int GetVlcChroma( video_format_t *fmt, int i_ffmpeg_chroma )
     return VLC_EGENERIC;
 }
 
-int FindFfmpegChroma( vlc_fourcc_t fourcc )
+enum AVPixelFormat FindFfmpegChroma( vlc_fourcc_t fourcc )
 {
     for( int i = 0; chroma_table[i].i_chroma != 0; i++ )
         if( chroma_table[i].i_chroma == fourcc )


=====================================
modules/codec/avcodec/chroma.h
=====================================
@@ -25,10 +25,12 @@
 #ifndef VLC_AVUTIL_CHROMA_H_
 #define VLC_AVUTIL_CHROMA_H_
 
-int FindFfmpegChroma( vlc_fourcc_t );
-int GetFfmpegChroma( int *i_ffmpeg_chroma, const video_format_t *fmt );
+#include <libavutil/pixfmt.h>
 
-vlc_fourcc_t FindVlcChroma( int );
-int GetVlcChroma( video_format_t *fmt, int i_ffmpeg_chroma );
+enum AVPixelFormat FindFfmpegChroma( vlc_fourcc_t );
+int GetFfmpegChroma( enum AVPixelFormat *i_ffmpeg_chroma, const video_format_t *fmt );
+
+vlc_fourcc_t FindVlcChroma( enum AVPixelFormat );
+int GetVlcChroma( video_format_t *fmt, enum AVPixelFormat i_ffmpeg_chroma );
 
 #endif


=====================================
modules/codec/avcodec/d3d11va.c
=====================================
@@ -61,7 +61,7 @@ struct d3d11va_pic_context
 
 #include "directx_va.h"
 
-static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat hwfmt, const AVPixFmtDescriptor *,
+static int Open(vlc_va_t *, AVCodecContext *, enum AVPixelFormat hwfmt, const AVPixFmtDescriptor *,
                 const es_format_t *, vlc_decoder_device *, video_format_t *, vlc_video_context **);
 
 vlc_module_begin()
@@ -221,7 +221,7 @@ static void Close(vlc_va_t *va)
 
 static const struct vlc_va_operations ops = { Get, Close, };
 
-static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat hwfmt, const AVPixFmtDescriptor *desc,
+static int Open(vlc_va_t *va, AVCodecContext *ctx, enum AVPixelFormat hwfmt, const AVPixFmtDescriptor *desc,
                 const es_format_t *fmt_in, vlc_decoder_device *dec_device,
                 video_format_t *fmt_out, vlc_video_context **vtcx_out)
 {


=====================================
modules/codec/avcodec/dxva2.c
=====================================
@@ -49,7 +49,7 @@ struct dxva2_pic_context
 
 #include "directx_va.h"
 
-static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat hwfmt, const AVPixFmtDescriptor *,
+static int Open(vlc_va_t *, AVCodecContext *, enum AVPixelFormat hwfmt, const AVPixFmtDescriptor *,
                 const es_format_t *, vlc_decoder_device *, video_format_t *, vlc_video_context **);
 
 vlc_module_begin()
@@ -232,7 +232,7 @@ static void Close(vlc_va_t *va)
 
 static const struct vlc_va_operations ops = { Get, Close, };
 
-static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat hwfmt, const AVPixFmtDescriptor *desc,
+static int Open(vlc_va_t *va, AVCodecContext *ctx, enum AVPixelFormat hwfmt, const AVPixFmtDescriptor *desc,
                 const es_format_t *fmt_in, vlc_decoder_device *dec_device,
                 video_format_t *fmt_out, vlc_video_context **vtcx_out)
 {


=====================================
modules/codec/avcodec/encoder.c
=====================================
@@ -297,7 +297,7 @@ int InitVideoEnc( vlc_object_t *p_this )
     encoder_sys_t *p_sys;
     AVCodecContext *p_context;
     AVCodec *p_codec = NULL;
-    unsigned i_codec_id;
+    enum AVCodecID i_codec_id;
     const char *psz_namecodec;
     float f_val;
     char *psz_val;
@@ -557,7 +557,7 @@ int InitVideoEnc( vlc_object_t *p_this )
                 AV_PIX_FMT_RGB24,
             };
             bool found = false;
-            const enum PixelFormat *p = p_codec->pix_fmts;
+            const enum AVPixelFormat *p = p_codec->pix_fmts;
             for( ; !found && *p != -1; p++ )
             {
                 for( size_t i = 0; i < ARRAY_SIZE(vlc_pix_fmts); ++i )


=====================================
modules/codec/avcodec/fourcc.c
=====================================
@@ -38,7 +38,7 @@
 struct vlc_avcodec_fourcc
 {
     vlc_fourcc_t i_fourcc;
-    unsigned i_codec;
+    enum AVCodecID i_codec;
 };
 
 /*
@@ -535,7 +535,7 @@ static const struct vlc_avcodec_fourcc spu_codecs[] =
 };
 
 bool GetFfmpegCodec( enum es_format_category_e cat, vlc_fourcc_t i_fourcc,
-                     unsigned *pi_ffmpeg_codec, const char **ppsz_name )
+                     enum AVCodecID *pi_ffmpeg_codec, const char **ppsz_name )
 {
     const struct vlc_avcodec_fourcc *base;
     size_t count;
@@ -575,7 +575,7 @@ bool GetFfmpegCodec( enum es_format_category_e cat, vlc_fourcc_t i_fourcc,
     return false;
 }
 
-vlc_fourcc_t GetVlcFourcc( unsigned i_ffmpeg_codec )
+vlc_fourcc_t GetVlcFourcc( enum AVCodecID i_ffmpeg_codec )
 {
     for( size_t i = 0; i < ARRAY_SIZE(video_codecs); i++ )
     {


=====================================
modules/codec/avcodec/va.c
=====================================
@@ -30,7 +30,7 @@
 #include <libavcodec/avcodec.h>
 #include "va.h"
 
-bool vlc_va_MightDecode(enum PixelFormat hwfmt, enum PixelFormat swfmt)
+bool vlc_va_MightDecode(enum AVPixelFormat hwfmt, enum AVPixelFormat swfmt)
 {
     switch (hwfmt)
     {
@@ -100,7 +100,7 @@ bool vlc_va_MightDecode(enum PixelFormat hwfmt, enum PixelFormat swfmt)
 }
 
 vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
-                     enum PixelFormat hwfmt, const AVPixFmtDescriptor *src_desc,
+                     enum AVPixelFormat hwfmt, const AVPixFmtDescriptor *src_desc,
                      const es_format_t *fmt_in, vlc_decoder_device *device,
                      video_format_t *fmt_out, vlc_video_context **vtcx_out)
 {


=====================================
modules/codec/avcodec/va.h
=====================================
@@ -44,7 +44,7 @@ struct vlc_va_t {
 };
 
 typedef int (*vlc_va_open)(vlc_va_t *, AVCodecContext *,
-                           enum PixelFormat hwfmt, const AVPixFmtDescriptor *,
+                           enum AVPixelFormat hwfmt, const AVPixFmtDescriptor *,
                            const es_format_t *, vlc_decoder_device *,
                            video_format_t *, vlc_video_context **);
 
@@ -63,7 +63,7 @@ typedef int (*vlc_va_open)(vlc_va_t *, AVCodecContext *,
  * @param swfmt the software pixel format
  * @return true if the hardware acceleration should be supported
  */
-bool vlc_va_MightDecode(enum PixelFormat hwfmt, enum PixelFormat swfmt);
+bool vlc_va_MightDecode(enum AVPixelFormat hwfmt, enum AVPixelFormat swfmt);
 
 /**
  * Creates an accelerated video decoding back-end for libavcodec.
@@ -72,7 +72,7 @@ bool vlc_va_MightDecode(enum PixelFormat hwfmt, enum PixelFormat swfmt);
  * @return a new VLC object on success, NULL on error.
  */
 vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *,
-                     enum PixelFormat hwfmt, const AVPixFmtDescriptor *,
+                     enum AVPixelFormat hwfmt, const AVPixFmtDescriptor *,
                      const es_format_t *fmt, vlc_decoder_device *device,
                      video_format_t *, vlc_video_context **vtcx_out);
 


=====================================
modules/codec/avcodec/vaapi.c
=====================================
@@ -237,7 +237,7 @@ static void VAAPISetupAVCodecContext(void *opaque, AVCodecContext *avctx)
     avctx->hwaccel_context = &sys->hw_ctx;
 }
 
-static int Create(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat hwfmt, const AVPixFmtDescriptor *desc,
+static int Create(vlc_va_t *va, AVCodecContext *ctx, enum AVPixelFormat hwfmt, const AVPixFmtDescriptor *desc,
                   const es_format_t *fmt_in, vlc_decoder_device *dec_device,
                   video_format_t *fmt_out, vlc_video_context **vtcx_out)
 {


=====================================
modules/codec/avcodec/video.c
=====================================
@@ -103,7 +103,7 @@ typedef struct
 
     /* VA API */
     vlc_va_t *p_va; /* Protected by lock */
-    enum PixelFormat pix_fmt;
+    enum AVPixelFormat pix_fmt;
     int profile;
     int level;
     vlc_video_context *vctx_out;
@@ -122,8 +122,8 @@ typedef struct
  *****************************************************************************/
 static void ffmpeg_InitCodec      ( decoder_t * );
 static int lavc_GetFrame(struct AVCodecContext *, AVFrame *, int);
-static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *,
-                                          const enum PixelFormat * );
+static enum AVPixelFormat ffmpeg_GetFormat( AVCodecContext *,
+                                          const enum AVPixelFormat * );
 static int  DecodeVideo( decoder_t *, block_t * );
 static void Flush( decoder_t * );
 
@@ -1538,15 +1538,15 @@ static int lavc_GetFrame(struct AVCodecContext *ctx, AVFrame *frame, int flags)
     return ret;
 }
 
-static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context,
-                                          const enum PixelFormat *pi_fmt )
+static enum AVPixelFormat ffmpeg_GetFormat( AVCodecContext *p_context,
+                                          const enum AVPixelFormat *pi_fmt )
 {
     decoder_t *p_dec = p_context->opaque;
     decoder_sys_t *p_sys = p_dec->p_sys;
     video_format_t fmt;
 
     /* Enumerate available formats */
-    enum PixelFormat swfmt = avcodec_default_get_format(p_context, pi_fmt);
+    enum AVPixelFormat swfmt = avcodec_default_get_format(p_context, pi_fmt);
     bool can_hwaccel = false;
 
     for (size_t i = 0; pi_fmt[i] != AV_PIX_FMT_NONE; i++)
@@ -1624,7 +1624,7 @@ no_reuse:
 
     vlc_mutex_lock(&p_sys->lock);
 
-    static const enum PixelFormat hwfmts[] =
+    static const enum AVPixelFormat hwfmts[] =
     {
 #ifdef _WIN32
         AV_PIX_FMT_D3D11VA_VLD,
@@ -1639,7 +1639,7 @@ no_reuse:
 
     for( size_t i = 0; hwfmts[i] != AV_PIX_FMT_NONE; i++ )
     {
-        enum PixelFormat hwfmt = AV_PIX_FMT_NONE;
+        enum AVPixelFormat hwfmt = AV_PIX_FMT_NONE;
         for( size_t j = 0; hwfmt == AV_PIX_FMT_NONE && pi_fmt[j] != AV_PIX_FMT_NONE; j++ )
             if( hwfmts[i] == pi_fmt[j] )
                 hwfmt = hwfmts[i];


=====================================
modules/demux/avformat/demux.c
=====================================
@@ -462,7 +462,7 @@ int avformat_OpenDemux( vlc_object_t *p_this )
             if( cp->codec_id == AV_CODEC_ID_RAWVIDEO )
             {
                 msg_Dbg( p_demux, "raw video, pixel format: %i", cp->format );
-                if( GetVlcChroma( &es_fmt.video, cp->format ) != VLC_SUCCESS)
+                if( GetVlcChroma( &es_fmt.video, (enum AVPixelFormat)cp->format ) != VLC_SUCCESS)
                 {
                     msg_Err( p_demux, "was unable to find a FourCC match for raw video" );
                 }


=====================================
modules/demux/avformat/mux.c
=====================================
@@ -197,7 +197,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
 {
     sout_mux_sys_t *p_sys = p_mux->p_sys;
     const es_format_t *fmt = p_input->p_fmt;
-    unsigned i_codec_id;
+    enum AVCodecID i_codec_id;
 
     msg_Dbg( p_mux, "adding input" );
 


=====================================
modules/hw/vdpau/avcodec.c
=====================================
@@ -147,7 +147,7 @@ const struct vlc_video_context_operations vdpau_vctx_ops = {
     DestroyVDPAUVideoContext,
 };
 
-static int Open(vlc_va_t *va, AVCodecContext *avctx, enum PixelFormat hwfmt, const AVPixFmtDescriptor *desc,
+static int Open(vlc_va_t *va, AVCodecContext *avctx, enum AVPixelFormat hwfmt, const AVPixFmtDescriptor *desc,
                 const es_format_t *fmt_in, vlc_decoder_device *dec_device,
                 video_format_t *fmt_out, vlc_video_context **vtcx_out)
 {


=====================================
modules/packetizer/avparser.c
=====================================
@@ -89,7 +89,7 @@ int avparser_OpenPacketizer( vlc_object_t *p_this )
     if( p_dec->fmt_in.i_codec != VLC_CODEC_VP9 )
         return VLC_EGENERIC;
 
-    unsigned i_avcodec_id;
+    enum AVCodecID i_avcodec_id;
 
     if( !GetFfmpegCodec( p_dec->fmt_in.i_cat, p_dec->fmt_in.i_codec,
                          &i_avcodec_id, NULL ) )


=====================================
modules/video_chroma/swscale.c
=====================================
@@ -111,8 +111,8 @@ static void Clean( filter_t * );
 
 typedef struct
 {
-    int  i_fmti;
-    int  i_fmto;
+    enum AVPixelFormat i_fmti;
+    enum AVPixelFormat i_fmto;
     bool b_has_a;
     bool b_add_a;
     int  i_sws_flags;
@@ -244,7 +244,7 @@ static int GetSwsCpuMask(void)
     return i_sws_cpu;
 }
 
-static void FixParameters( int *pi_fmt, bool *pb_has_a, bool *pb_swap_uv, vlc_fourcc_t fmt )
+static void FixParameters( enum AVPixelFormat *pi_fmt, bool *pb_has_a, bool *pb_swap_uv, vlc_fourcc_t fmt )
 {
     switch( fmt )
     {
@@ -290,8 +290,8 @@ static int GetParameters( ScalerConfiguration *p_cfg,
                           const video_format_t *p_fmto,
                           int i_sws_flags_default )
 {
-    int i_fmti = -1;
-    int i_fmto = -1;
+    enum AVPixelFormat i_fmti = AV_PIX_FMT_NONE;
+    enum AVPixelFormat i_fmto = AV_PIX_FMT_NONE;
 
     bool b_has_ai = false;
     bool b_has_ao = false;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/50aeffdf10f99f5ef351d08a73e59449c994700c...c78f7ac90f35779a97f4ce8372ac9126433e7674

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/50aeffdf10f99f5ef351d08a73e59449c994700c...c78f7ac90f35779a97f4ce8372ac9126433e7674
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list