]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
update audio abuffersink from deprecated channel_layouts to ch_layouts and deprecated...
authoruknunknown <alin_gherghescu@yahoo.com>
Sun, 6 Oct 2024 23:42:55 +0000 (16:42 -0700)
committerFlole <Flole998@users.noreply.github.com>
Sun, 18 May 2025 20:43:21 +0000 (22:43 +0200)
update audio abuffersink from deprecated channel_layouts to ch_layouts and deprecated FF_PROFILE_* --> AV_PROFILE_*

13 files changed:
src/transcoding/codec/codecs/aac.c
src/transcoding/codec/codecs/libs/libx26x.c
src/transcoding/codec/codecs/libs/nvenc.c
src/transcoding/codec/codecs/libs/vaapi.c
src/transcoding/codec/internals.h
src/transcoding/codec/profile_audio_class.c
src/transcoding/codec/profile_class.c
src/transcoding/transcode/audio.c
src/transcoding/transcode/context.c
src/transcoding/transcode/hwaccels/vaapi.c
src/transcoding/transcode/internals.h
src/transcoding/transcode/video.c
src/webui/static/app/codec.js

index 44477287c6d3a050b2a32f900bfca9f06d62ddf4..63239083aab03856b868113b80b9f9dc9c3dd67f 100644 (file)
 
 
 /* aac ====================================================================== */
-
+// see aacenc_profiles[] ffmpeg-7.0/libavcodec/aacenctab.h + AV_PROFILE_UNKNOWN
 static const AVProfile aac_profiles[] = {
-    { FF_PROFILE_AAC_MAIN, "Main" },
-    { FF_PROFILE_AAC_LOW,  "LC" },
-    { FF_PROFILE_AAC_LTP,  "LTP" },
-    { FF_PROFILE_UNKNOWN },
+    { FF_AV_PROFILE_AAC_MAIN,      "Main" },
+    { FF_AV_PROFILE_AAC_LOW,       "LC" },
+    { FF_AV_PROFILE_AAC_LTP,       "LTP" },
+    { FF_AV_PROFILE_MPEG2_AAC_LOW, "MPEG2_LC" },
+    { FF_AV_PROFILE_UNKNOWN },
 };
 
 #if LIBAVCODEC_VERSION_MAJOR > 59
-// see aac_chan_configs in ffmpeg-6.0/libavcodec/aacenctab.h
+// see aac_normal_chan_layouts[7] in ffmpeg-7.0/libavcodec/aacenctab.h + NULL termination
 static const AVChannelLayout aac_channel_layouts[] = {
     AV_CHANNEL_LAYOUT_MONO,
     AV_CHANNEL_LAYOUT_STEREO,
@@ -40,6 +41,7 @@ static const AVChannelLayout aac_channel_layouts[] = {
     AV_CHANNEL_LAYOUT_5POINT0_BACK,
     AV_CHANNEL_LAYOUT_5POINT1_BACK,
     AV_CHANNEL_LAYOUT_7POINT1,
+    { 0 },
 };
 #else
 // see aac_chan_configs in ffmpeg-3.0.2/libavcodec/aacenctab.h
index 088b11e70dc3fa10071f3e0318e77d8bdb6868b7..abe3ca443289f03fbba951328e693d73fa2b1c7e 100644 (file)
@@ -116,13 +116,13 @@ tvh_codec_profile_libx265_destroy(TVHCodecProfile *_self)
 #include <x264.h>
 
 static const AVProfile libx264_profiles[] = {
-    { FF_PROFILE_H264_BASELINE, "Baseline" },
-    { FF_PROFILE_H264_MAIN,     "Main" },
-    { FF_PROFILE_H264_HIGH,     "High" },
-    { FF_PROFILE_H264_HIGH_10,  "High 10" },
-    { FF_PROFILE_H264_HIGH_422, "High 4:2:2" },
-    { FF_PROFILE_H264_HIGH_444, "High 4:4:4" },
-    { FF_PROFILE_UNKNOWN },
+    { FF_AV_PROFILE_H264_BASELINE, "Baseline" },
+    { FF_AV_PROFILE_H264_MAIN,     "Main" },
+    { FF_AV_PROFILE_H264_HIGH,     "High" },
+    { FF_AV_PROFILE_H264_HIGH_10,  "High 10" },
+    { FF_AV_PROFILE_H264_HIGH_422, "High 4:2:2" },
+    { FF_AV_PROFILE_H264_HIGH_444, "High 4:4:4" },
+    { FF_AV_PROFILE_UNKNOWN },
 };
 
 
index 6defe7077de549c94885164a660c77c212b78f05..914fb5ac2b8ce7b09663808b882059f816f347bc 100644 (file)
@@ -52,8 +52,6 @@
 #define NV_ENC_HEVC_PROFILE_MAIN_10                        1
 #define NV_ENC_HEVC_PROFILE_REXT                               2
 
-#define NV_ENC_PROFILE_UNKNOWN                      FF_PROFILE_UNKNOWN
-
 #define NV_ENC_LEVEL_AUTOSELECT                     0
 
 #define NV_ENC_LEVEL_H264_1                         10
@@ -217,7 +215,7 @@ static const codec_profile_class_t codec_profile_nvenc_class = {
                 .get_opts = codec_profile_class_profile_get_opts,
                 .off      = offsetof(tvh_codec_profile_nvenc_t, nvenc_profile),
                 .list     = codec_profile_nvenc_class_profile_list,
-                .def.i    = NV_ENC_PROFILE_UNKNOWN,
+                .def.i    = FF_AV_PROFILE_UNKNOWN,
             },
             {
                 .type     = PT_INT,
@@ -279,7 +277,7 @@ static const AVProfile nvenc_h264_profiles[] = {
     { NV_ENC_H264_PROFILE_MAIN,                 "Main" },
     { NV_ENC_H264_PROFILE_HIGH,                 "High" },
     { NV_ENC_H264_PROFILE_HIGH_444P,            "High 444P" },
-    { NV_ENC_PROFILE_UNKNOWN },
+    { FF_AV_PROFILE_UNKNOWN },
 };
 
 static int
@@ -323,7 +321,7 @@ tvh_codec_profile_nvenc_h264_open(tvh_codec_profile_nvenc_t *self,
         AV_DICT_SET(opts, "level", s, 0);
     }
 
-    if (self->nvenc_profile != NV_ENC_PROFILE_UNKNOWN &&
+    if (self->nvenc_profile != FF_AV_PROFILE_UNKNOWN &&
         (s = val2str(self->nvenc_profile, profiletab)) != NULL) {
         AV_DICT_SET(opts, "profile", s, 0);
     }
@@ -406,7 +404,7 @@ static const AVProfile nvenc_hevc_profiles[] = {
     { NV_ENC_HEVC_PROFILE_MAIN,    "Main" },
     { NV_ENC_HEVC_PROFILE_MAIN_10, "Main 10" },
     { NV_ENC_HEVC_PROFILE_REXT, "Rext" },
-    { NV_ENC_PROFILE_UNKNOWN },
+    { FF_AV_PROFILE_UNKNOWN },
 };
 
 static int
@@ -443,7 +441,7 @@ tvh_codec_profile_nvenc_hevc_open(tvh_codec_profile_nvenc_t *self,
         AV_DICT_SET(opts, "level", s, 0);
         }
 
-    if (self->nvenc_profile != NV_ENC_PROFILE_UNKNOWN &&
+    if (self->nvenc_profile != FF_AV_PROFILE_UNKNOWN &&
         (s = val2str(self->nvenc_profile, profiletab)) != NULL) {
         AV_DICT_SET(opts, "profile", s, 0);
         }
index fa5024de4c3d90bb133c4c997dd59ac2e3cc1124..1f436aee8a7dfa41307d9dc2395dbc6345098eec 100644 (file)
@@ -590,10 +590,10 @@ static const codec_profile_class_t codec_profile_vaapi_class = {
 /* h264_vaapi =============================================================== */
 
 static const AVProfile vaapi_h264_profiles[] = {
-    { FF_PROFILE_H264_CONSTRAINED_BASELINE, "Constrained Baseline" },
-    { FF_PROFILE_H264_MAIN,                 "Main" },
-    { FF_PROFILE_H264_HIGH,                 "High" },
-    { FF_PROFILE_UNKNOWN },
+    { FF_AV_PROFILE_H264_CONSTRAINED_BASELINE, "Constrained Baseline" },
+    { FF_AV_PROFILE_H264_MAIN,                 "Main" },
+    { FF_AV_PROFILE_H264_HIGH,                 "High" },
+    { FF_AV_PROFILE_UNKNOWN },
 };
 
 static int
@@ -915,10 +915,10 @@ TVHVideoCodec tvh_codec_vaapi_h264 = {
 /* hevc_vaapi =============================================================== */
 
 static const AVProfile vaapi_hevc_profiles[] = {
-    { FF_PROFILE_HEVC_MAIN, "Main" },
-    { FF_PROFILE_HEVC_MAIN_10, "Main 10" },
-    { FF_PROFILE_HEVC_REXT, "Rext" },
-    { FF_PROFILE_UNKNOWN },
+    { FF_AV_PROFILE_HEVC_MAIN,     "Main" },
+    { FF_AV_PROFILE_HEVC_MAIN_10,  "Main 10" },
+    { FF_AV_PROFILE_HEVC_REXT,     "Rext" },
+    { FF_AV_PROFILE_UNKNOWN },
 };
 
 static int
@@ -1230,7 +1230,7 @@ TVHVideoCodec tvh_codec_vaapi_hevc = {
 /* vp8_vaapi =============================================================== */
 
 static const AVProfile vaapi_vp8_profiles[] = {
-    { FF_PROFILE_UNKNOWN },
+    { FF_AV_PROFILE_UNKNOWN },
 };
 
 static int
@@ -1538,7 +1538,7 @@ TVHVideoCodec tvh_codec_vaapi_vp8 = {
 /* vp9_vaapi =============================================================== */
 
 static const AVProfile vaapi_vp9_profiles[] = {
-    { FF_PROFILE_UNKNOWN },
+    { FF_AV_PROFILE_UNKNOWN },
 };
 
 static int
index 7b8799f123f38d06e35897d2817e64106f959f43..2a0aef986f10f99360049957b907aebde3ca7b0b 100644 (file)
@@ -172,6 +172,69 @@ tvh_codecs_register(void);
 void
 tvh_codecs_forget(void);
 
+/* ffmpeg constants */
+#if LIBAVCODEC_VERSION_MAJOR > 59
+// **** AUDIO ****
+// aac
+#define FF_AV_PROFILE_AAC_MAIN                  AV_PROFILE_AAC_MAIN
+#define FF_AV_PROFILE_AAC_LOW                   AV_PROFILE_AAC_LOW
+#define FF_AV_PROFILE_AAC_LTP                   AV_PROFILE_AAC_LTP
+#define FF_AV_PROFILE_MPEG2_AAC_LOW             AV_PROFILE_MPEG2_AAC_LOW
+// **** VIDEO ****
+// vp9
+#define FF_AV_PROFILE_VP9_0                     AV_PROFILE_VP9_0
+#define FF_AV_PROFILE_VP9_1                     AV_PROFILE_VP9_1
+#define FF_AV_PROFILE_VP9_2                     AV_PROFILE_VP9_2
+#define FF_AV_PROFILE_VP9_3                     AV_PROFILE_VP9_3
+// h265
+#define FF_AV_PROFILE_HEVC_MAIN                 AV_PROFILE_HEVC_MAIN
+#define FF_AV_PROFILE_HEVC_MAIN_10              AV_PROFILE_HEVC_MAIN_10
+#define FF_AV_PROFILE_HEVC_REXT                 AV_PROFILE_HEVC_REXT
+// h264
+#define FF_AV_PROFILE_H264_BASELINE             AV_PROFILE_H264_BASELINE
+#define FF_AV_PROFILE_H264_CONSTRAINED_BASELINE AV_PROFILE_H264_CONSTRAINED_BASELINE
+#define FF_AV_PROFILE_H264_MAIN                 AV_PROFILE_H264_MAIN
+#define FF_AV_PROFILE_H264_HIGH                 AV_PROFILE_H264_HIGH
+#define FF_AV_PROFILE_H264_HIGH_10              AV_PROFILE_H264_HIGH_10
+#define FF_AV_PROFILE_H264_HIGH_422             AV_PROFILE_H264_HIGH_422
+#define FF_AV_PROFILE_H264_HIGH_444             AV_PROFILE_H264_HIGH_444
+// mpeg2
+#define FF_AV_PROFILE_MPEG2_MAIN                AV_PROFILE_MPEG2_MAIN
+#define FF_AV_PROFILE_MPEG2_SIMPLE              AV_PROFILE_MPEG2_SIMPLE
+// common
+#define FF_AV_PROFILE_UNKNOWN                   AV_PROFILE_UNKNOWN
+#else
+// **** AUDIO ****
+// aac
+#define FF_AV_PROFILE_AAC_MAIN                  FF_PROFILE_AAC_MAIN
+#define FF_AV_PROFILE_AAC_LOW                   FF_PROFILE_AAC_LOW
+#define FF_AV_PROFILE_AAC_LTP                   FF_PROFILE_AAC_LTP
+#define FF_AV_PROFILE_MPEG2_AAC_LOW             FF_PROFILE_MPEG2_AAC_LOW
+// **** VIDEO ****
+// vp9
+#define FF_AV_PROFILE_VP9_0                     FF_PROFILE_VP9_0
+#define FF_AV_PROFILE_VP9_1                     FF_PROFILE_VP9_1
+#define FF_AV_PROFILE_VP9_2                     FF_PROFILE_VP9_2
+#define FF_AV_PROFILE_VP9_3                     FF_PROFILE_VP9_3
+// h265
+#define FF_AV_PROFILE_HEVC_MAIN                 FF_PROFILE_HEVC_MAIN
+#define FF_AV_PROFILE_HEVC_MAIN_10              FF_PROFILE_HEVC_MAIN_10
+#define FF_AV_PROFILE_HEVC_REXT                 FF_PROFILE_HEVC_REXT
+// h264
+#define FF_AV_PROFILE_H264_BASELINE             FF_PROFILE_H264_BASELINE
+#define FF_AV_PROFILE_H264_CONSTRAINED_BASELINE FF_PROFILE_H264_CONSTRAINED_BASELINE
+#define FF_AV_PROFILE_H264_MAIN                 FF_PROFILE_H264_MAIN
+#define FF_AV_PROFILE_H264_HIGH                 FF_PROFILE_H264_HIGH
+#define FF_AV_PROFILE_H264_HIGH_10              FF_PROFILE_H264_HIGH_10
+#define FF_AV_PROFILE_H264_HIGH_422             FF_PROFILE_H264_HIGH_422
+#define FF_AV_PROFILE_H264_HIGH_444             FF_PROFILE_H264_HIGH_444
+// mpeg2
+#define FF_AV_PROFILE_MPEG2_MAIN                FF_PROFILE_MPEG2_MAIN
+#define FF_AV_PROFILE_MPEG2_SIMPLE              FF_PROFILE_MPEG2_SIMPLE
+// common
+#define FF_AV_PROFILE_UNKNOWN                   FF_PROFILE_UNKNOWN
+#endif
+
 
 /* codec_profile_class */
 
@@ -250,11 +313,8 @@ typedef struct tvh_codec_profile_audio {
     char *language3;
     int sample_fmt;
     int sample_rate;
-#if LIBAVCODEC_VERSION_MAJOR > 59
-    AVChannelLayout channel_layout;
-#else
+    // this variable will be used also as ch_layout_u_mask when LIBAVCODEC_VERSION_MAJOR > 59
     int64_t channel_layout;
-#endif
 } TVHAudioCodecProfile;
 
 
index 61caab38ec8d266b8fdec040206c557653fd5b63..52c9219fc41e58c3cf645397155de64fc2698a72 100644 (file)
@@ -106,7 +106,7 @@ tvh_codec_audio_get_list_channel_layouts(TVHAudioCodec *self)
 #if LIBAVCODEC_VERSION_MAJOR > 59
             l = channel_layouts;
             ADD_ENTRY(list, map, s64, 0, str, AUTO_STR);
-            while (l->nb_channels < 32) {
+            while (l->nb_channels != 0) {
                 if (!(map = htsmsg_create_map())) {
                     htsmsg_destroy(list);
                     list = NULL;
@@ -149,11 +149,14 @@ tvh_codec_profile_audio_is_copy(TVHAudioCodecProfile *self, tvh_ssc_t *ssc)
     int ssc_channels = ssc->es_channels ? ssc->es_channels : 2;
     int ssc_sr = ssc->es_sri ? sri_to_rate(ssc->es_sri) : 48000;
 #if LIBAVCODEC_VERSION_MAJOR > 59
-    if ((self->channel_layout.order != AV_CHANNEL_ORDER_UNSPEC &&
-         ssc_channels != self->channel_layout.nb_channels) ||
-        (self->sample_rate && ssc_sr != self->sample_rate)) {
+    AVChannelLayout ch_layout = {0};
+    av_channel_layout_from_mask(&ch_layout, self->channel_layout);
+    if ((self->channel_layout && ssc_channels != ch_layout.nb_channels) ||
+        (self->sample_rate      && ssc_sr != self->sample_rate)) {
+        av_channel_layout_uninit(&ch_layout);
         return 0;
     }
+    av_channel_layout_uninit(&ch_layout);
 #else
     if ((self->channel_layout &&
          ssc_channels != av_get_channel_layout_nb_channels(self->channel_layout)) ||
@@ -176,17 +179,13 @@ tvh_codec_profile_audio_open(TVHAudioCodecProfile *self, AVDictionary **opts)
         AV_DICT_SET_INT(opts, "sample_rate", self->sample_rate,
                         AV_DICT_DONT_OVERWRITE);
     }
+    if (self->channel_layout) {
 #if LIBAVCODEC_VERSION_MAJOR > 59
-    if (self->channel_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
-        AV_DICT_SET_INT(opts, "channel_layout", self->channel_layout.u.mask,
-                        AV_DICT_DONT_OVERWRITE);
-    }
+        AV_DICT_SET_INT(opts, "ch_layout_u_mask", self->channel_layout, AV_DICT_DONT_OVERWRITE);
 #else
-    if (self->channel_layout) {
-        AV_DICT_SET_INT(opts, "channel_layout", self->channel_layout,
-                        AV_DICT_DONT_OVERWRITE);
-    }
+        AV_DICT_SET_INT(opts, "channel_layout", self->channel_layout, AV_DICT_DONT_OVERWRITE);
 #endif
+    }
     return 0;
 }
 
index fea65b17483b81c41bbc61038ae68fd1fc2f7c91..c093a43b64bad609e0f0b9f8f68715143eee50ad 100644 (file)
@@ -51,8 +51,8 @@ tvh_codec_get_list_profiles(TVHCodec *self)
             list = NULL;
         }
         else {
-            ADD_ENTRY(list, map, s32, FF_PROFILE_UNKNOWN, str, AUTO_STR);
-            for (p = (AVProfile *)profiles; p->profile != FF_PROFILE_UNKNOWN; p++) {
+            ADD_ENTRY(list, map, s32, FF_AV_PROFILE_UNKNOWN, str, AUTO_STR);
+            for (p = (AVProfile *)profiles; p->profile != FF_AV_PROFILE_UNKNOWN; p++) {
                 if (!(map = htsmsg_create_map())) {
                     htsmsg_destroy(list);
                     list = NULL;
@@ -80,7 +80,7 @@ tvh_codec_profile_base_open(TVHCodecProfile *self, AVDictionary **opts)
 {
     AV_DICT_SET_TVH_REQUIRE_META(opts, 1);
     // profile
-    if (self->profile != FF_PROFILE_UNKNOWN) {
+    if (self->profile != FF_AV_PROFILE_UNKNOWN) {
         AV_DICT_SET_INT(opts, "profile", self->profile, 0);
     }
     return 0;
@@ -281,7 +281,7 @@ const codec_profile_class_t codec_profile_class = {
                 .get_opts = codec_profile_class_profile_get_opts,
                 .off      = offsetof(TVHCodecProfile, profile),
                 .list     = codec_profile_class_profile_list,
-                .def.i    = FF_PROFILE_UNKNOWN,
+                .def.i    = FF_AV_PROFILE_UNKNOWN,
             },
             {}
         }
index 383caa6a0c4e01d96b882199f12e8f984523ab4f..b9ee7a432f368d6d40a5470d2395a858cc3ec21c 100644 (file)
@@ -91,21 +91,23 @@ _audio_context_channel_layout(TVHContext *self, AVDictionary **opts, AVChannelLa
     av_channel_layout_default(&olayout, 0);
     AVChannelLayout altlayout;
     av_channel_layout_default(&altlayout, 0);
-    int tmp = 0, ichannels = 0, i;
+    int ch_layout_u_mask = 0, i = 0;
     char obuf[64], abuf[64], ibuf[64];
 
-    if (!tvh_context_get_int_opt(opts, "ch_layout", &tmp) &&
-        !(av_channel_layout_from_mask(&olayout, tmp)) && channel_layouts) {
-        ichannels = ilayout.nb_channels;
-        for (i = 0; (av_channel_layout_from_mask(&olayout, channel_layouts[i].u.mask)); i++) {
-            if (av_channel_layout_compare(&olayout, &ilayout)) {
-                break;
-            }
-            if (olayout.nb_channels <= ichannels) {
-                altlayout = olayout;
+    if (!tvh_context_get_int_opt(opts, "ch_layout_u_mask", &ch_layout_u_mask) &&
+        !(av_channel_layout_from_mask(&olayout, ch_layout_u_mask)) && channel_layouts) {
+        if (olayout.nb_channels > ilayout.nb_channels) {
+            olayout = ilayout;
+        }
+        while (channel_layouts[i].nb_channels != 0) {
+            if (channel_layouts[i].nb_channels <= ilayout.nb_channels) {
+                altlayout = channel_layouts[i];
             }
+            i++;
         }
     }
+    else
+        olayout = ilayout;
     if (tvhtrace_enabled()) {
         strcpy(obuf, "none");
         av_channel_layout_describe(&olayout, obuf, sizeof(obuf));
@@ -113,8 +115,8 @@ _audio_context_channel_layout(TVHContext *self, AVDictionary **opts, AVChannelLa
         av_channel_layout_describe(&altlayout, abuf, sizeof(abuf));
         strcpy(ibuf, "none");
         av_channel_layout_describe(&ilayout, ibuf, sizeof(ibuf));
-        tvh_context_log(self, LOG_TRACE, "audio layout selection: old %s, alt %s, in %s",
-                        obuf, abuf, ibuf);
+        tvh_context_log(self, LOG_TRACE, "audio layout selection: in %s, alt %s, out %s",
+                                                                     ibuf,   abuf,   obuf);
     }
     if (olayout.order != AV_CHANNEL_ORDER_UNSPEC)
         return av_channel_layout_copy(dst, &olayout);
@@ -242,22 +244,37 @@ tvh_audio_context_open_filters(TVHContext *self, AVDictionary **opts)
         return -1;
     }
 
+#if LIBAVCODEC_VERSION_MAJOR > 59
+    char ch_layout[64];
+    av_channel_layout_describe(&self->oavctx->ch_layout, ch_layout, sizeof(ch_layout));
+    
     int ret = tvh_context_open_filters(self,
         "abuffer", source_args,                           // source
         filters,                                          // filters
         "abuffersink",                                    // sink
-#if LIBAVCODEC_VERSION_MAJOR > 59
-        "channel_layouts", &self->oavctx->ch_layout.u.mask, // sink option: channel_layout
-        sizeof(self->oavctx->ch_layout.u.mask),
+        "ch_layouts",   AV_OPT_SET_STRING,                // sink option: channel_layout
+        sizeof(ch_layout),
+        ch_layout,
+        "sample_fmts",  AV_OPT_SET_BIN,                   // sink option: sample_fmt
+        sizeof(self->oavctx->sample_fmt),
+        &self->oavctx->sample_fmt,
+        "sample_rates", AV_OPT_SET_BIN,                   // sink option: sample_rate
+        sizeof(self->oavctx->sample_rate),
+        &self->oavctx->sample_rate,
+        NULL);                                            // _IMPORTANT!_
 #else
+    int ret = tvh_context_open_filters(self,
+        "abuffer", source_args,                           // source
+        filters,                                          // filters
+        "abuffersink",                                    // sink
         "channel_layouts", &self->oavctx->channel_layout, // sink option: channel_layout
         sizeof(self->oavctx->channel_layout),
-#endif
         "sample_fmts", &self->oavctx->sample_fmt,         // sink option: sample_fmt
         sizeof(self->oavctx->sample_fmt),
         "sample_rates", &self->oavctx->sample_rate,       // sink option: sample_rate
         sizeof(self->oavctx->sample_rate),
         NULL);                                            // _IMPORTANT!_
+#endif
     if (!ret) {
         av_buffersink_set_frame_size(self->oavfltctx, self->oavctx->frame_size);
     }
index 0d993a076e45fc0d7343e8e5a5fccbb8822cd471..7480b6b698cdbb01d01125740ed73dc2a4480019 100644 (file)
@@ -107,10 +107,48 @@ _context_filters_apply_sink_options(TVHContext *self, va_list ap)
 {
     const char *opt_name = NULL;
     const uint8_t *opt_val = NULL;
+#if LIBAVCODEC_VERSION_MAJOR > 59
+    const char *opt_val_char = NULL;
+    av_opt_set_type opt_type = AV_OPT_SET_UNKNOWN;
+    char err_desciption[32];
+#endif
     int opt_size = 0;
     int ret = -1;
 
     while ((opt_name = va_arg(ap, const char *))) {
+#if LIBAVCODEC_VERSION_MAJOR > 59
+        opt_type = (av_opt_set_type) va_arg(ap, int);
+        opt_size = va_arg(ap, int);
+        if (opt_type == AV_OPT_SET_BIN) {
+            opt_val = va_arg(ap, const uint8_t *);
+            ret = av_opt_set_bin(self->oavfltctx, opt_name, opt_val, opt_size, AV_OPT_SEARCH_CHILDREN);}
+        else {
+            if (opt_type == AV_OPT_SET_STRING) {
+                opt_val_char = va_arg(ap, const char *);
+                ret = av_opt_set(self->oavfltctx, opt_name, opt_val_char, AV_OPT_SEARCH_CHILDREN);} 
+            else {
+                tvh_context_log(self, LOG_ERR, "filters: failed to set option: '%s' with error: 'AV_OPT_SET_UNKNOWN'", opt_name);
+                return ret;
+            }
+        }
+        if (ret) {
+            switch (ret) {
+                case AVERROR_OPTION_NOT_FOUND:
+                    str_snprintf(err_desciption, sizeof(err_desciption), "AVERROR_OPTION_NOT_FOUND");
+                    break;
+                case AVERROR(EINVAL):
+                    str_snprintf(err_desciption, sizeof(err_desciption), "AVERROR(EINVAL)");
+                    break;
+                case AVERROR(ENOMEM):
+                    str_snprintf(err_desciption, sizeof(err_desciption), "AVERROR(ENOMEM)");
+                    break;
+                default:
+                    str_snprintf(err_desciption, sizeof(err_desciption), "UNKNOWN ERROR");
+                    break;
+            }
+            tvh_context_log(self, LOG_ERR, "filters: failed to set option: '%s' with error: '%s'", opt_name, err_desciption);
+        }
+#else
         opt_val = va_arg(ap, const uint8_t *);
         opt_size = va_arg(ap, int);
         if ((ret = av_opt_set_bin(self->oavfltctx, opt_name, opt_val, opt_size,
@@ -119,6 +157,7 @@ _context_filters_apply_sink_options(TVHContext *self, va_list ap)
                             opt_name);
             break;
         }
+#endif
     }
     return ret;
 }
index f3971f3cde08ab60d7efdfa59e2da158f400a3f9..3e8dab19a1d6e09d5dfeebc0859bd05191172d1d 100644 (file)
@@ -17,7 +17,7 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-
+#include "../../codec/internals.h"
 #include "../internals.h"
 #include "vaapi.h"
 
@@ -154,11 +154,11 @@ tvhva_context_profile(TVHVAContext *self, AVCodecContext *avctx)
     switch (avctx->codec->id) {
         case AV_CODEC_ID_MPEG2VIDEO:
             switch (avctx->profile) {
-                case FF_PROFILE_UNKNOWN:
-                case FF_PROFILE_MPEG2_MAIN:
+                case FF_AV_PROFILE_UNKNOWN:
+                case FF_AV_PROFILE_MPEG2_MAIN:
                     check = VAProfileMPEG2Main;
                     break;
-                case FF_PROFILE_MPEG2_SIMPLE:
+                case FF_AV_PROFILE_MPEG2_SIMPLE:
                     check = VAProfileMPEG2Simple;
                     break;
                 default:
@@ -167,14 +167,14 @@ tvhva_context_profile(TVHVAContext *self, AVCodecContext *avctx)
             break;
         case AV_CODEC_ID_H264:
             switch (avctx->profile) {
-                case FF_PROFILE_UNKNOWN:
-                case FF_PROFILE_H264_HIGH:
+                case FF_AV_PROFILE_UNKNOWN:
+                case FF_AV_PROFILE_H264_HIGH:
                     check = VAProfileH264High;
                     break;
-                case FF_PROFILE_H264_CONSTRAINED_BASELINE:
+                case FF_AV_PROFILE_H264_CONSTRAINED_BASELINE:
                     check = VAProfileH264ConstrainedBaseline;
                     break;
-                case FF_PROFILE_H264_MAIN:
+                case FF_AV_PROFILE_H264_MAIN:
                     check = VAProfileH264Main;
                     break;
                 default:
@@ -183,12 +183,12 @@ tvhva_context_profile(TVHVAContext *self, AVCodecContext *avctx)
             break;
         case AV_CODEC_ID_HEVC:
             switch (avctx->profile) {
-                case FF_PROFILE_UNKNOWN:
-                case FF_PROFILE_HEVC_MAIN:
+                case FF_AV_PROFILE_UNKNOWN:
+                case FF_AV_PROFILE_HEVC_MAIN:
                     check = VAProfileHEVCMain;
                     break;
-                case FF_PROFILE_HEVC_MAIN_10:
-                case FF_PROFILE_HEVC_REXT:
+                case FF_AV_PROFILE_HEVC_MAIN_10:
+                case FF_AV_PROFILE_HEVC_REXT:
                     check = VAProfileHEVCMain10;
                     break;
                 default:
@@ -197,7 +197,7 @@ tvhva_context_profile(TVHVAContext *self, AVCodecContext *avctx)
             break;
         case AV_CODEC_ID_VP8:
             switch (avctx->profile) {
-                case FF_PROFILE_UNKNOWN:
+                case FF_AV_PROFILE_UNKNOWN:
                     check = VAProfileVP8Version0_3;
                     break;
                 default:
@@ -206,17 +206,17 @@ tvhva_context_profile(TVHVAContext *self, AVCodecContext *avctx)
             break;
         case AV_CODEC_ID_VP9:
             switch (avctx->profile) {
-                case FF_PROFILE_UNKNOWN:
-                case FF_PROFILE_VP9_0:
+                case FF_AV_PROFILE_UNKNOWN:
+                case FF_AV_PROFILE_VP9_0:
                     check = VAProfileVP9Profile0;
                     break;
-                case FF_PROFILE_VP9_1:
+                case FF_AV_PROFILE_VP9_1:
                     check = VAProfileVP9Profile1;
                     break;
-                case FF_PROFILE_VP9_2:
+                case FF_AV_PROFILE_VP9_2:
                     check = VAProfileVP9Profile2;
                     break;
-                case FF_PROFILE_VP9_3:
+                case FF_AV_PROFILE_VP9_3:
                     check = VAProfileVP9Profile3;
                     break;
                 default:
index e0776cec40b06a98e5dfd08fee0128ea4437d0c5..2bf58b002de40805831d9581f7adf4712689a69c 100644 (file)
@@ -56,6 +56,14 @@ typedef enum {
     OPEN_ENCODER_POST
 } TVHOpenPhase;
 
+#if LIBAVCODEC_VERSION_MAJOR > 59
+// this is needed to separate av_opt_set-s from _context_filters_apply_sink_options
+typedef enum {
+    AV_OPT_SET_UNKNOWN,
+    AV_OPT_SET_BIN,
+    AV_OPT_SET_STRING
+} av_opt_set_type;
+#endif
 
 /* TVHTranscoder ============================================================ */
 
@@ -177,7 +185,7 @@ void
 tvh_context_close(TVHContext *self, int flush);
 
 /* __VA_ARGS__ = NULL terminated list of sink options
-   sink option = (const char *name, const uint8_t *value, int size) */
+   sink option = (const char *name, av_opt_set_type opt_set_type, int size, const uint8_t *value) */
 int
 tvh_context_open_filters(TVHContext *self,
                          const char *source_name, const char *source_args,
index b75e71dc1c4b6ea5dc8f2450592a7d73b4b5dfa9..c838fd734a9d0a2deadd89e6d3ee40483fc8e50d 100644 (file)
@@ -274,6 +274,15 @@ tvh_video_context_open_filters(TVHContext *self, AVDictionary **opts)
         return -1;
     }
 
+#if LIBAVCODEC_VERSION_MAJOR > 59
+    int ret = tvh_context_open_filters(self,
+        "buffer", source_args,                                  // source
+        strlen(filters) ? filters : "null",                     // filters
+        "buffersink",                                           // sink
+        "pix_fmts", AV_OPT_SET_BIN,                             // sink option: pix_fmt
+        sizeof(self->oavctx->pix_fmt), &self->oavctx->pix_fmt,
+        NULL);                                                  // _IMPORTANT!_
+#else
     int ret = tvh_context_open_filters(self,
         "buffer", source_args,              // source
         strlen(filters) ? filters : "null", // filters
@@ -281,6 +290,7 @@ tvh_video_context_open_filters(TVHContext *self, AVDictionary **opts)
         "pix_fmts", &self->oavctx->pix_fmt, // sink option: pix_fmt
         sizeof(self->oavctx->pix_fmt),
         NULL);                              // _IMPORTANT!_
+#endif
     str_clear(filters);
     return ret;
 }
index 014494224ec152f52942d4349f6b2c975c93135a..78cb2ce0e1aea876fbebdddcb48150356ca02ed7 100644 (file)
@@ -310,9 +310,9 @@ var codec_profile_forms = {
             AV_CH_LAYOUT_4POINT0           | 263   | 4
             AV_CH_LAYOUT_5POINT0_BACK      | 55    | 5
             AV_CH_LAYOUT_5POINT1_BACK      | 63    | 6
-            AV_CH_LAYOUT_7POINT1_WIDE_BACK | 255   | 8
+            AV_CH_LAYOUT_7POINT1           | 1599  | 8
         */
-        var channels = [0, 4, 3, 7, 263, 55, 63, -1, 255]
+        var channels = [0, 4, 3, 7, 263, 55, 63, 1599]
 
         function updateBitrate(bitrate_f, quality_f, samplerate_f, layout_f) {
             if (quality_f.getValue() > 0) {
@@ -322,10 +322,12 @@ var codec_profile_forms = {
             else {
                 var samplerate = samplerate_f.getValue() || 48000;
                 var layout = layout_f.getValue() || 3; // AV_CH_LAYOUT_STEREO
-                var max_bitrate = (6 * samplerate * channels.indexOf(layout)) / 1000;
-                bitrate_f.setMaxValue(max_bitrate);
-                if (bitrate_f.getValue() > max_bitrate) {
-                    bitrate_f.setValue(max_bitrate);
+                if (channels.indexOf(layout) >= 0) {
+                    var max_bitrate = (6 * samplerate * channels.indexOf(layout)) / 1000;
+                    bitrate_f.setMaxValue(max_bitrate);
+                    if (bitrate_f.getValue() > max_bitrate) {
+                        bitrate_f.setValue(max_bitrate);
+                    }
                 }
                 bitrate_f.setReadOnly(false);
             }