File: 0087-avcommon-use-a-specific-macro-to-check-the-FFmpeg-li.patch

package info (click to toggle)
vlc 3.0.21-10
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 212,728 kB
  • sloc: ansic: 441,379; cpp: 110,628; objc: 36,394; sh: 6,947; makefile: 6,592; javascript: 4,902; xml: 1,611; asm: 1,355; yacc: 640; python: 555; lex: 88; perl: 77; sed: 16
file content (269 lines) | stat: -rw-r--r-- 12,406 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Wed, 19 Jun 2024 13:59:15 +0200
Subject: avcommon: use a specific macro to check the FFmpeg libavcodec
 version

This macro doesn't check for libav which is assumed to not have to relevant
code. This is the same macro name used in VLC 4.0.
---
 modules/codec/avcodec/audio.c           |  8 ++++----
 modules/codec/avcodec/avcommon.h        |  2 +-
 modules/codec/avcodec/avcommon_compat.h |  4 ++++
 modules/codec/avcodec/directx_va.c      |  4 ++--
 modules/codec/avcodec/encoder.c         | 13 ++++++-------
 modules/codec/avcodec/fourcc.c          | 18 ++++++++----------
 modules/codec/avcodec/video.c           |  3 +--
 modules/demux/avformat/demux.c          |  2 +-
 modules/demux/avformat/mux.c            |  2 +-
 9 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index 7a979e9..a3f67f7 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -142,7 +142,7 @@ static int OpenAudioCodec( decoder_t *p_dec )
     }
 
     ctx->sample_rate = p_dec->fmt_in.audio.i_rate;
-#if LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100)
+#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
     av_channel_layout_default( &ctx->ch_layout, p_dec->fmt_in.audio.i_channels );
 #else
     ctx->channels = p_dec->fmt_in.audio.i_channels;
@@ -402,7 +402,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         ret = avcodec_receive_frame( ctx, frame );
         if( ret == 0 )
         {
-#if LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100)
+#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
             int channels = frame->ch_layout.nb_channels;
 #else
             int channels = ctx->channels;
@@ -592,7 +592,7 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
     p_dec->fmt_out.audio.i_rate = p_sys->p_context->sample_rate;
 
     /* */
-#if LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100)
+#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
     if( p_sys->i_previous_channels == p_sys->p_context->ch_layout.nb_channels &&
         p_sys->i_previous_layout == p_sys->p_context->ch_layout.u.mask )
         return;
@@ -617,7 +617,7 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
 
     int i_channels_src = 0, channel_count;
     uint64_t channel_layout_mask;
-#if LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100)
+#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
     channel_layout_mask = p_sys->p_context->ch_layout.u.mask;
     channel_count = p_sys->p_context->ch_layout.nb_channels;
 #elif API_CHANNEL_LAYOUT
diff --git a/modules/codec/avcodec/avcommon.h b/modules/codec/avcodec/avcommon.h
index aa0c0b8..10ad13d 100644
--- a/modules/codec/avcodec/avcommon.h
+++ b/modules/codec/avcodec/avcommon.h
@@ -123,7 +123,7 @@ static inline void vlc_init_avcodec(vlc_object_t *obj)
 
     vlc_init_avutil(obj);
 
-#if (LIBAVFORMAT_VERSION_MICRO < 100) || (LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 10, 100))
+#if (LIBAVFORMAT_VERSION_MICRO < 100) || !(LIBAVCODEC_VERSION_CHECK(58, 10, 100))
     avcodec_register_all();
 #endif
 
diff --git a/modules/codec/avcodec/avcommon_compat.h b/modules/codec/avcodec/avcommon_compat.h
index b504fcd..ac02c06 100644
--- a/modules/codec/avcodec/avcommon_compat.h
+++ b/modules/codec/avcodec/avcommon_compat.h
@@ -30,6 +30,10 @@
 #ifdef HAVE_LIBAVCODEC_AVCODEC_H
 #include <libavcodec/avcodec.h>
 
+/* check the FFmpeg libavutil version */
+#define LIBAVCODEC_VERSION_CHECK( a, d, e ) \
+    (LIBAVCODEC_VERSION_MICRO >= 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( a, d, e ) )
+
 /* LIBAV_CODEC_VERSION_CHECK checks for the right version of libav and FFmpeg
  * a is the major version
  * b and c the minor and micro versions of libav
diff --git a/modules/codec/avcodec/directx_va.c b/modules/codec/avcodec/directx_va.c
index 607a1bc..890473e 100644
--- a/modules/codec/avcodec/directx_va.c
+++ b/modules/codec/avcodec/directx_va.c
@@ -274,7 +274,7 @@ static const directx_va_mode_t DXVA_MODES[] = {
 
     /* VPx */
     { "VP8",                                                                          &DXVA_ModeVP8_VLD,                      8, 0, NULL },
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 57, 17, 100 ) && LIBAVCODEC_VERSION_MICRO >= 100
+#if LIBAVCODEC_VERSION_CHECK( 57, 17, 100 )
     { "VP9 profile 0",                                                                &DXVA_ModeVP9_VLD_Profile0,             8, AV_CODEC_ID_VP9, PROF_VP9_MAIN },
     { "VP9 profile 2",                                                                &DXVA_ModeVP9_VLD_10bit_Profile2,       10, AV_CODEC_ID_VP9, PROF_VP9_10 },
 #else
@@ -284,7 +284,7 @@ static const directx_va_mode_t DXVA_MODES[] = {
     { "VP9 profile Intel",                                                            &DXVA_ModeVP9_VLD_Intel,                8, 0, NULL },
 
     /* AV1 */
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 58, 112, 103 ) && LIBAVCODEC_VERSION_MICRO >= 100
+#if LIBAVCODEC_VERSION_CHECK( 58, 112, 103 )
     { "AV1 Main profile 8",                                                           &DXVA_ModeAV1_VLD_Profile0,             8, AV_CODEC_ID_AV1, PROF_AV1_MAIN },
     { "AV1 Main profile 10",                                                          &DXVA_ModeAV1_VLD_Profile0,             10, AV_CODEC_ID_AV1, PROF_AV1_MAIN },
     { "AV1 High profile 8",                                                           &DXVA_ModeAV1_VLD_Profile1,             8, AV_CODEC_ID_AV1, PROF_AV1_HIGH },
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 9cf9a7d..2014b8a 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -61,8 +61,7 @@
 
 #define RAW_AUDIO_FRAME_SIZE (2048)
 
-#if LIBAVCODEC_VERSION_MICRO >= 100 && \
-    LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59, 0, 100)
+#if LIBAVCODEC_VERSION_CHECK(59, 0, 100)
 # define AVC_MAYBE_CONST const
 #else
 # define AVC_MAYBE_CONST
@@ -183,7 +182,7 @@ static const uint64_t pi_channels_map[][2] =
     { AV_CH_STEREO_RIGHT,      0 },
 };
 
-# if !LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100)
+# if !LIBAVCODEC_VERSION_CHECK(59, 24, 100)
 static const uint32_t channel_mask[][2] = {
     {0,0},
     {AOUT_CHAN_CENTER, AV_CH_LAYOUT_MONO},
@@ -765,7 +764,7 @@ int InitVideoEnc( vlc_object_t *p_this )
         uint32_t order_mask = 0;
         int i_channels_src = 0;
         msg_Dbg( p_enc, "Creating channel order for reordering");
-# if LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100)
+# if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
         av_channel_layout_default( &p_context->ch_layout, p_enc->fmt_out.audio.i_channels );
         uint64_t channel_mask = p_context->ch_layout.u.mask;
 # else
@@ -918,7 +917,7 @@ errmsg:
 
         if( p_enc->fmt_out.audio.i_channels > 2 )
         {
-#if LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100)
+#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
             av_channel_layout_default( &p_context->ch_layout, 2 );
 #else
             p_context->channels = 2;
@@ -1282,7 +1281,7 @@ static block_t *handle_delay_buffer( encoder_t *p_enc, encoder_sys_t *p_sys, uns
     av_frame_unref( p_sys->frame );
     p_sys->frame->format     = p_sys->p_context->sample_fmt;
     p_sys->frame->nb_samples = leftover_samples + p_sys->i_samples_delay;
-#if LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100)
+#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
     av_channel_layout_copy(&p_sys->frame->ch_layout, &p_sys->p_context->ch_layout);
 #else
     p_sys->frame->channel_layout = p_sys->p_context->channel_layout;
@@ -1417,7 +1416,7 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
         p_sys->frame->pts        = date_Get( &p_sys->buffer_date ) * p_sys->p_context->time_base.den /
                                     CLOCK_FREQ / p_sys->p_context->time_base.num;
 
-#if LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100)
+#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
         av_channel_layout_copy(&p_sys->frame->ch_layout, &p_sys->p_context->ch_layout);
 #else
         p_sys->frame->channel_layout = p_sys->p_context->channel_layout;
diff --git a/modules/codec/avcodec/fourcc.c b/modules/codec/avcodec/fourcc.c
index 3aea6b5..d75c21f 100644
--- a/modules/codec/avcodec/fourcc.c
+++ b/modules/codec/avcodec/fourcc.c
@@ -182,12 +182,10 @@ static const struct vlc_avcodec_fourcc video_codecs[] =
     /* AV_CODEC_ID_V210X */
     { VLC_CODEC_TMV, AV_CODEC_ID_TMV },
     { VLC_CODEC_V210, AV_CODEC_ID_V210 },
-#if LIBAVCODEC_VERSION_MICRO >= 100
-# if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 59, 42, 102 )
+#if LIBAVCODEC_VERSION_CHECK( 59, 42, 102 )
     { VLC_CODEC_VUYA, AV_CODEC_ID_RAWVIDEO },
-# elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 54, 50, 100 )
+#elif LIBAVCODEC_VERSION_CHECK( 54, 50, 100 )
     { VLC_CODEC_VUYA, AV_CODEC_ID_AYUV },
-# endif
 #endif
     /* AV_CODEC_ID_DPX */
     { VLC_CODEC_MAD, AV_CODEC_ID_MAD },
@@ -285,19 +283,19 @@ static const struct vlc_avcodec_fourcc video_codecs[] =
     /* ffmpeg only: AV_CODEC_ID_SNOW */
     /* ffmpeg only: AV_CODEC_ID_SMVJPEG */
 
-#if LIBAV_CODEC_VERSION_CHECK( 57, 999, 999, 24, 102 )
+#if LIBAVCODEC_VERSION_CHECK( 57, 24, 102 )
     { VLC_CODEC_CINEFORM, AV_CODEC_ID_CFHD },
 #endif
 
-#if LIBAV_CODEC_VERSION_CHECK( 57, 999, 999, 70, 100 )
+#if LIBAVCODEC_VERSION_CHECK( 57, 70, 100 )
     { VLC_CODEC_PIXLET, AV_CODEC_ID_PIXLET },
 #endif
 
-#if LIBAV_CODEC_VERSION_CHECK( 57, 999, 999, 71, 101 )
+#if LIBAVCODEC_VERSION_CHECK( 57, 71, 101 )
     { VLC_CODEC_SPEEDHQ, AV_CODEC_ID_SPEEDHQ },
 #endif
 
-#if LIBAV_CODEC_VERSION_CHECK( 57, 999, 999, 79, 100 )
+#if LIBAVCODEC_VERSION_CHECK( 57, 79, 100 )
     { VLC_CODEC_FMVC, AV_CODEC_ID_FMVC },
 #endif
 };
@@ -414,7 +412,7 @@ static const struct vlc_avcodec_fourcc audio_codecs[] =
     /* AV_CODEC_ID_WESTWOOD_SND1 */
     { VLC_CODEC_GSM, AV_CODEC_ID_GSM },
     { VLC_CODEC_QDM2, AV_CODEC_ID_QDM2 },
-#if LIBAV_CODEC_VERSION_CHECK( 57, 999, 999, 71, 100 )
+#if LIBAVCODEC_VERSION_CHECK( 57, 71, 100 )
     { VLC_CODEC_QDMC, AV_CODEC_ID_QDMC },
 #endif
     { VLC_CODEC_COOK, AV_CODEC_ID_COOK },
@@ -482,7 +480,7 @@ static const struct vlc_avcodec_fourcc spu_codecs[] =
     { VLC_CODEC_SSA, AV_CODEC_ID_SSA },
     /* AV_CODEC_ID_MOV_TEXT */
     { VLC_CODEC_BD_PG, AV_CODEC_ID_HDMV_PGS_SUBTITLE },
-#if LIBAV_CODEC_VERSION_CHECK( 57, 999, 999, 71, 100 )
+#if LIBAVCODEC_VERSION_CHECK( 57, 71, 100 )
     { VLC_CODEC_BD_TEXT, AV_CODEC_ID_HDMV_TEXT_SUBTITLE },
 #endif
     { VLC_CODEC_TELETEXT, AV_CODEC_ID_DVB_TELETEXT },
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 552c602..c306e91 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1824,8 +1824,7 @@ no_reuse:
     if (!can_hwaccel)
         return swfmt;
 
-#if (LIBAVCODEC_VERSION_MICRO >= 100) \
-  && (LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 83, 101))
+#if (LIBAVCODEC_VERSION_MICRO >= 100) && !(LIBAVCODEC_VERSION_CHECK(57, 83, 101))
     if (p_context->active_thread_type)
     {
         msg_Warn(p_dec, "thread type %d: disabling hardware acceleration",
diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index 39d2366..9975b0f 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -400,7 +400,7 @@ int avformat_OpenDemux( vlc_object_t *p_this )
             es_format_Init( &es_fmt, AUDIO_ES, fcc );
             es_fmt.i_original_fourcc = CodecTagToFourcc( cp->codec_tag );
             es_fmt.i_bitrate = cp->bit_rate;
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 59, 24, 100 ) && LIBAVCODEC_VERSION_MICRO >= 100
+#if LIBAVCODEC_VERSION_CHECK( 59, 24, 100 )
             es_fmt.audio.i_channels = cp->ch_layout.nb_channels;
 #else
             es_fmt.audio.i_channels = cp->channels;
diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
index 664a646..a48190c 100644
--- a/modules/demux/avformat/mux.c
+++ b/modules/demux/avformat/mux.c
@@ -273,7 +273,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
     {
     case AUDIO_ES:
         codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 59, 24, 100 ) && LIBAVCODEC_VERSION_MICRO >= 100
+#if LIBAVCODEC_VERSION_CHECK( 59, 24, 100 )
         av_channel_layout_default( &codecpar->ch_layout, fmt->audio.i_channels );
 #else
         codecpar->channels = fmt->audio.i_channels;