Skip to content

Commit 7da199b

Browse files
uknunknownFlole998
authored andcommitted
update audio abuffersink from deprecated channel_layouts to ch_layouts and deprecated FF_PROFILE_* --> AV_PROFILE_*
update audio abuffersink from deprecated channel_layouts to ch_layouts and deprecated FF_PROFILE_* --> AV_PROFILE_*
1 parent 221400c commit 7da199b

13 files changed

Lines changed: 226 additions & 91 deletions

File tree

src/transcoding/codec/codecs/aac.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@
2222

2323

2424
/* aac ====================================================================== */
25-
25+
// see aacenc_profiles[] ffmpeg-7.0/libavcodec/aacenctab.h + AV_PROFILE_UNKNOWN
2626
static const AVProfile aac_profiles[] = {
27-
{ FF_PROFILE_AAC_MAIN, "Main" },
28-
{ FF_PROFILE_AAC_LOW, "LC" },
29-
{ FF_PROFILE_AAC_LTP, "LTP" },
30-
{ FF_PROFILE_UNKNOWN },
27+
{ FF_AV_PROFILE_AAC_MAIN, "Main" },
28+
{ FF_AV_PROFILE_AAC_LOW, "LC" },
29+
{ FF_AV_PROFILE_AAC_LTP, "LTP" },
30+
{ FF_AV_PROFILE_MPEG2_AAC_LOW, "MPEG2_LC" },
31+
{ FF_AV_PROFILE_UNKNOWN },
3132
};
3233

3334
#if LIBAVCODEC_VERSION_MAJOR > 59
34-
// see aac_chan_configs in ffmpeg-6.0/libavcodec/aacenctab.h
35+
// see aac_normal_chan_layouts[7] in ffmpeg-7.0/libavcodec/aacenctab.h + NULL termination
3536
static const AVChannelLayout aac_channel_layouts[] = {
3637
AV_CHANNEL_LAYOUT_MONO,
3738
AV_CHANNEL_LAYOUT_STEREO,
@@ -40,6 +41,7 @@ static const AVChannelLayout aac_channel_layouts[] = {
4041
AV_CHANNEL_LAYOUT_5POINT0_BACK,
4142
AV_CHANNEL_LAYOUT_5POINT1_BACK,
4243
AV_CHANNEL_LAYOUT_7POINT1,
44+
{ 0 },
4345
};
4446
#else
4547
// see aac_chan_configs in ffmpeg-3.0.2/libavcodec/aacenctab.h

src/transcoding/codec/codecs/libs/libx26x.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ tvh_codec_profile_libx265_destroy(TVHCodecProfile *_self)
116116
#include <x264.h>
117117

118118
static const AVProfile libx264_profiles[] = {
119-
{ FF_PROFILE_H264_BASELINE, "Baseline" },
120-
{ FF_PROFILE_H264_MAIN, "Main" },
121-
{ FF_PROFILE_H264_HIGH, "High" },
122-
{ FF_PROFILE_H264_HIGH_10, "High 10" },
123-
{ FF_PROFILE_H264_HIGH_422, "High 4:2:2" },
124-
{ FF_PROFILE_H264_HIGH_444, "High 4:4:4" },
125-
{ FF_PROFILE_UNKNOWN },
119+
{ FF_AV_PROFILE_H264_BASELINE, "Baseline" },
120+
{ FF_AV_PROFILE_H264_MAIN, "Main" },
121+
{ FF_AV_PROFILE_H264_HIGH, "High" },
122+
{ FF_AV_PROFILE_H264_HIGH_10, "High 10" },
123+
{ FF_AV_PROFILE_H264_HIGH_422, "High 4:2:2" },
124+
{ FF_AV_PROFILE_H264_HIGH_444, "High 4:4:4" },
125+
{ FF_AV_PROFILE_UNKNOWN },
126126
};
127127

128128

src/transcoding/codec/codecs/libs/nvenc.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
#define NV_ENC_HEVC_PROFILE_MAIN_10 1
5353
#define NV_ENC_HEVC_PROFILE_REXT 2
5454

55-
#define NV_ENC_PROFILE_UNKNOWN FF_PROFILE_UNKNOWN
56-
5755
#define NV_ENC_LEVEL_AUTOSELECT 0
5856

5957
#define NV_ENC_LEVEL_H264_1 10
@@ -217,7 +215,7 @@ static const codec_profile_class_t codec_profile_nvenc_class = {
217215
.get_opts = codec_profile_class_profile_get_opts,
218216
.off = offsetof(tvh_codec_profile_nvenc_t, nvenc_profile),
219217
.list = codec_profile_nvenc_class_profile_list,
220-
.def.i = NV_ENC_PROFILE_UNKNOWN,
218+
.def.i = FF_AV_PROFILE_UNKNOWN,
221219
},
222220
{
223221
.type = PT_INT,
@@ -279,7 +277,7 @@ static const AVProfile nvenc_h264_profiles[] = {
279277
{ NV_ENC_H264_PROFILE_MAIN, "Main" },
280278
{ NV_ENC_H264_PROFILE_HIGH, "High" },
281279
{ NV_ENC_H264_PROFILE_HIGH_444P, "High 444P" },
282-
{ NV_ENC_PROFILE_UNKNOWN },
280+
{ FF_AV_PROFILE_UNKNOWN },
283281
};
284282

285283
static int
@@ -323,7 +321,7 @@ tvh_codec_profile_nvenc_h264_open(tvh_codec_profile_nvenc_t *self,
323321
AV_DICT_SET(opts, "level", s, 0);
324322
}
325323

326-
if (self->nvenc_profile != NV_ENC_PROFILE_UNKNOWN &&
324+
if (self->nvenc_profile != FF_AV_PROFILE_UNKNOWN &&
327325
(s = val2str(self->nvenc_profile, profiletab)) != NULL) {
328326
AV_DICT_SET(opts, "profile", s, 0);
329327
}
@@ -406,7 +404,7 @@ static const AVProfile nvenc_hevc_profiles[] = {
406404
{ NV_ENC_HEVC_PROFILE_MAIN, "Main" },
407405
{ NV_ENC_HEVC_PROFILE_MAIN_10, "Main 10" },
408406
{ NV_ENC_HEVC_PROFILE_REXT, "Rext" },
409-
{ NV_ENC_PROFILE_UNKNOWN },
407+
{ FF_AV_PROFILE_UNKNOWN },
410408
};
411409

412410
static int
@@ -443,7 +441,7 @@ tvh_codec_profile_nvenc_hevc_open(tvh_codec_profile_nvenc_t *self,
443441
AV_DICT_SET(opts, "level", s, 0);
444442
}
445443

446-
if (self->nvenc_profile != NV_ENC_PROFILE_UNKNOWN &&
444+
if (self->nvenc_profile != FF_AV_PROFILE_UNKNOWN &&
447445
(s = val2str(self->nvenc_profile, profiletab)) != NULL) {
448446
AV_DICT_SET(opts, "profile", s, 0);
449447
}

src/transcoding/codec/codecs/libs/vaapi.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,10 @@ static const codec_profile_class_t codec_profile_vaapi_class = {
590590
/* h264_vaapi =============================================================== */
591591

592592
static const AVProfile vaapi_h264_profiles[] = {
593-
{ FF_PROFILE_H264_CONSTRAINED_BASELINE, "Constrained Baseline" },
594-
{ FF_PROFILE_H264_MAIN, "Main" },
595-
{ FF_PROFILE_H264_HIGH, "High" },
596-
{ FF_PROFILE_UNKNOWN },
593+
{ FF_AV_PROFILE_H264_CONSTRAINED_BASELINE, "Constrained Baseline" },
594+
{ FF_AV_PROFILE_H264_MAIN, "Main" },
595+
{ FF_AV_PROFILE_H264_HIGH, "High" },
596+
{ FF_AV_PROFILE_UNKNOWN },
597597
};
598598

599599
static int
@@ -915,10 +915,10 @@ TVHVideoCodec tvh_codec_vaapi_h264 = {
915915
/* hevc_vaapi =============================================================== */
916916

917917
static const AVProfile vaapi_hevc_profiles[] = {
918-
{ FF_PROFILE_HEVC_MAIN, "Main" },
919-
{ FF_PROFILE_HEVC_MAIN_10, "Main 10" },
920-
{ FF_PROFILE_HEVC_REXT, "Rext" },
921-
{ FF_PROFILE_UNKNOWN },
918+
{ FF_AV_PROFILE_HEVC_MAIN, "Main" },
919+
{ FF_AV_PROFILE_HEVC_MAIN_10, "Main 10" },
920+
{ FF_AV_PROFILE_HEVC_REXT, "Rext" },
921+
{ FF_AV_PROFILE_UNKNOWN },
922922
};
923923

924924
static int
@@ -1230,7 +1230,7 @@ TVHVideoCodec tvh_codec_vaapi_hevc = {
12301230
/* vp8_vaapi =============================================================== */
12311231

12321232
static const AVProfile vaapi_vp8_profiles[] = {
1233-
{ FF_PROFILE_UNKNOWN },
1233+
{ FF_AV_PROFILE_UNKNOWN },
12341234
};
12351235

12361236
static int
@@ -1538,7 +1538,7 @@ TVHVideoCodec tvh_codec_vaapi_vp8 = {
15381538
/* vp9_vaapi =============================================================== */
15391539

15401540
static const AVProfile vaapi_vp9_profiles[] = {
1541-
{ FF_PROFILE_UNKNOWN },
1541+
{ FF_AV_PROFILE_UNKNOWN },
15421542
};
15431543

15441544
static int

src/transcoding/codec/internals.h

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,69 @@ tvh_codecs_register(void);
172172
void
173173
tvh_codecs_forget(void);
174174

175+
/* ffmpeg constants */
176+
#if LIBAVCODEC_VERSION_MAJOR > 59
177+
// **** AUDIO ****
178+
// aac
179+
#define FF_AV_PROFILE_AAC_MAIN AV_PROFILE_AAC_MAIN
180+
#define FF_AV_PROFILE_AAC_LOW AV_PROFILE_AAC_LOW
181+
#define FF_AV_PROFILE_AAC_LTP AV_PROFILE_AAC_LTP
182+
#define FF_AV_PROFILE_MPEG2_AAC_LOW AV_PROFILE_MPEG2_AAC_LOW
183+
// **** VIDEO ****
184+
// vp9
185+
#define FF_AV_PROFILE_VP9_0 AV_PROFILE_VP9_0
186+
#define FF_AV_PROFILE_VP9_1 AV_PROFILE_VP9_1
187+
#define FF_AV_PROFILE_VP9_2 AV_PROFILE_VP9_2
188+
#define FF_AV_PROFILE_VP9_3 AV_PROFILE_VP9_3
189+
// h265
190+
#define FF_AV_PROFILE_HEVC_MAIN AV_PROFILE_HEVC_MAIN
191+
#define FF_AV_PROFILE_HEVC_MAIN_10 AV_PROFILE_HEVC_MAIN_10
192+
#define FF_AV_PROFILE_HEVC_REXT AV_PROFILE_HEVC_REXT
193+
// h264
194+
#define FF_AV_PROFILE_H264_BASELINE AV_PROFILE_H264_BASELINE
195+
#define FF_AV_PROFILE_H264_CONSTRAINED_BASELINE AV_PROFILE_H264_CONSTRAINED_BASELINE
196+
#define FF_AV_PROFILE_H264_MAIN AV_PROFILE_H264_MAIN
197+
#define FF_AV_PROFILE_H264_HIGH AV_PROFILE_H264_HIGH
198+
#define FF_AV_PROFILE_H264_HIGH_10 AV_PROFILE_H264_HIGH_10
199+
#define FF_AV_PROFILE_H264_HIGH_422 AV_PROFILE_H264_HIGH_422
200+
#define FF_AV_PROFILE_H264_HIGH_444 AV_PROFILE_H264_HIGH_444
201+
// mpeg2
202+
#define FF_AV_PROFILE_MPEG2_MAIN AV_PROFILE_MPEG2_MAIN
203+
#define FF_AV_PROFILE_MPEG2_SIMPLE AV_PROFILE_MPEG2_SIMPLE
204+
// common
205+
#define FF_AV_PROFILE_UNKNOWN AV_PROFILE_UNKNOWN
206+
#else
207+
// **** AUDIO ****
208+
// aac
209+
#define FF_AV_PROFILE_AAC_MAIN FF_PROFILE_AAC_MAIN
210+
#define FF_AV_PROFILE_AAC_LOW FF_PROFILE_AAC_LOW
211+
#define FF_AV_PROFILE_AAC_LTP FF_PROFILE_AAC_LTP
212+
#define FF_AV_PROFILE_MPEG2_AAC_LOW FF_PROFILE_MPEG2_AAC_LOW
213+
// **** VIDEO ****
214+
// vp9
215+
#define FF_AV_PROFILE_VP9_0 FF_PROFILE_VP9_0
216+
#define FF_AV_PROFILE_VP9_1 FF_PROFILE_VP9_1
217+
#define FF_AV_PROFILE_VP9_2 FF_PROFILE_VP9_2
218+
#define FF_AV_PROFILE_VP9_3 FF_PROFILE_VP9_3
219+
// h265
220+
#define FF_AV_PROFILE_HEVC_MAIN FF_PROFILE_HEVC_MAIN
221+
#define FF_AV_PROFILE_HEVC_MAIN_10 FF_PROFILE_HEVC_MAIN_10
222+
#define FF_AV_PROFILE_HEVC_REXT FF_PROFILE_HEVC_REXT
223+
// h264
224+
#define FF_AV_PROFILE_H264_BASELINE FF_PROFILE_H264_BASELINE
225+
#define FF_AV_PROFILE_H264_CONSTRAINED_BASELINE FF_PROFILE_H264_CONSTRAINED_BASELINE
226+
#define FF_AV_PROFILE_H264_MAIN FF_PROFILE_H264_MAIN
227+
#define FF_AV_PROFILE_H264_HIGH FF_PROFILE_H264_HIGH
228+
#define FF_AV_PROFILE_H264_HIGH_10 FF_PROFILE_H264_HIGH_10
229+
#define FF_AV_PROFILE_H264_HIGH_422 FF_PROFILE_H264_HIGH_422
230+
#define FF_AV_PROFILE_H264_HIGH_444 FF_PROFILE_H264_HIGH_444
231+
// mpeg2
232+
#define FF_AV_PROFILE_MPEG2_MAIN FF_PROFILE_MPEG2_MAIN
233+
#define FF_AV_PROFILE_MPEG2_SIMPLE FF_PROFILE_MPEG2_SIMPLE
234+
// common
235+
#define FF_AV_PROFILE_UNKNOWN FF_PROFILE_UNKNOWN
236+
#endif
237+
175238

176239
/* codec_profile_class */
177240

@@ -250,11 +313,8 @@ typedef struct tvh_codec_profile_audio {
250313
char *language3;
251314
int sample_fmt;
252315
int sample_rate;
253-
#if LIBAVCODEC_VERSION_MAJOR > 59
254-
AVChannelLayout channel_layout;
255-
#else
316+
// this variable will be used also as ch_layout_u_mask when LIBAVCODEC_VERSION_MAJOR > 59
256317
int64_t channel_layout;
257-
#endif
258318
} TVHAudioCodecProfile;
259319

260320

src/transcoding/codec/profile_audio_class.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ tvh_codec_audio_get_list_channel_layouts(TVHAudioCodec *self)
106106
#if LIBAVCODEC_VERSION_MAJOR > 59
107107
l = channel_layouts;
108108
ADD_ENTRY(list, map, s64, 0, str, AUTO_STR);
109-
while (l->nb_channels < 32) {
109+
while (l->nb_channels != 0) {
110110
if (!(map = htsmsg_create_map())) {
111111
htsmsg_destroy(list);
112112
list = NULL;
@@ -149,11 +149,14 @@ tvh_codec_profile_audio_is_copy(TVHAudioCodecProfile *self, tvh_ssc_t *ssc)
149149
int ssc_channels = ssc->es_channels ? ssc->es_channels : 2;
150150
int ssc_sr = ssc->es_sri ? sri_to_rate(ssc->es_sri) : 48000;
151151
#if LIBAVCODEC_VERSION_MAJOR > 59
152-
if ((self->channel_layout.order != AV_CHANNEL_ORDER_UNSPEC &&
153-
ssc_channels != self->channel_layout.nb_channels) ||
154-
(self->sample_rate && ssc_sr != self->sample_rate)) {
152+
AVChannelLayout ch_layout = {0};
153+
av_channel_layout_from_mask(&ch_layout, self->channel_layout);
154+
if ((self->channel_layout && ssc_channels != ch_layout.nb_channels) ||
155+
(self->sample_rate && ssc_sr != self->sample_rate)) {
156+
av_channel_layout_uninit(&ch_layout);
155157
return 0;
156158
}
159+
av_channel_layout_uninit(&ch_layout);
157160
#else
158161
if ((self->channel_layout &&
159162
ssc_channels != av_get_channel_layout_nb_channels(self->channel_layout)) ||
@@ -176,17 +179,13 @@ tvh_codec_profile_audio_open(TVHAudioCodecProfile *self, AVDictionary **opts)
176179
AV_DICT_SET_INT(opts, "sample_rate", self->sample_rate,
177180
AV_DICT_DONT_OVERWRITE);
178181
}
182+
if (self->channel_layout) {
179183
#if LIBAVCODEC_VERSION_MAJOR > 59
180-
if (self->channel_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
181-
AV_DICT_SET_INT(opts, "channel_layout", self->channel_layout.u.mask,
182-
AV_DICT_DONT_OVERWRITE);
183-
}
184+
AV_DICT_SET_INT(opts, "ch_layout_u_mask", self->channel_layout, AV_DICT_DONT_OVERWRITE);
184185
#else
185-
if (self->channel_layout) {
186-
AV_DICT_SET_INT(opts, "channel_layout", self->channel_layout,
187-
AV_DICT_DONT_OVERWRITE);
188-
}
186+
AV_DICT_SET_INT(opts, "channel_layout", self->channel_layout, AV_DICT_DONT_OVERWRITE);
189187
#endif
188+
}
190189
return 0;
191190
}
192191

src/transcoding/codec/profile_class.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ tvh_codec_get_list_profiles(TVHCodec *self)
5151
list = NULL;
5252
}
5353
else {
54-
ADD_ENTRY(list, map, s32, FF_PROFILE_UNKNOWN, str, AUTO_STR);
55-
for (p = (AVProfile *)profiles; p->profile != FF_PROFILE_UNKNOWN; p++) {
54+
ADD_ENTRY(list, map, s32, FF_AV_PROFILE_UNKNOWN, str, AUTO_STR);
55+
for (p = (AVProfile *)profiles; p->profile != FF_AV_PROFILE_UNKNOWN; p++) {
5656
if (!(map = htsmsg_create_map())) {
5757
htsmsg_destroy(list);
5858
list = NULL;
@@ -80,7 +80,7 @@ tvh_codec_profile_base_open(TVHCodecProfile *self, AVDictionary **opts)
8080
{
8181
AV_DICT_SET_TVH_REQUIRE_META(opts, 1);
8282
// profile
83-
if (self->profile != FF_PROFILE_UNKNOWN) {
83+
if (self->profile != FF_AV_PROFILE_UNKNOWN) {
8484
AV_DICT_SET_INT(opts, "profile", self->profile, 0);
8585
}
8686
return 0;
@@ -281,7 +281,7 @@ const codec_profile_class_t codec_profile_class = {
281281
.get_opts = codec_profile_class_profile_get_opts,
282282
.off = offsetof(TVHCodecProfile, profile),
283283
.list = codec_profile_class_profile_list,
284-
.def.i = FF_PROFILE_UNKNOWN,
284+
.def.i = FF_AV_PROFILE_UNKNOWN,
285285
},
286286
{}
287287
}

0 commit comments

Comments
 (0)