Now that FFmpeg 6 is in. Remove patches to revert newer FFmpeg API utilization to be able to build with FFmpeg 4.
Index: Makefile =================================================================== RCS file: /cvs/ports/multimedia/handbrake/Makefile,v retrieving revision 1.23 diff -u -p -u -p -r1.23 Makefile --- Makefile 29 May 2024 08:47:49 -0000 1.23 +++ Makefile 25 Sep 2024 06:37:25 -0000 @@ -3,6 +3,7 @@ COMMENT = open source video transcoder V = 1.6.1 DISTNAME = HandBrake-${V}-source PKGNAME = handbrake-${V} +REVISION = 0 EXTRACT_SUFX = .tar.bz2 CATEGORIES = multimedia x11 @@ -51,7 +52,7 @@ LIB_DEPENDS = archivers/bzip2 \ devel/harfbuzz \ devel/jansson \ devel/libdvdread \ - graphics/ffmpeg \ + graphics/ffmpeg>=6.1.2 \ graphics/jpeg \ graphics/zimg \ multimedia/aom \ Index: patches/patch-libhb_audio_remap_c =================================================================== RCS file: patches/patch-libhb_audio_remap_c diff -N patches/patch-libhb_audio_remap_c --- patches/patch-libhb_audio_remap_c 29 May 2024 08:47:50 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,24 +0,0 @@ -Revert "libhb: use mask part the new FFmpeg channel layout api." -c5012478cba356b8f8f222d6acff9fe3cc74e67e - -Index: libhb/audio_remap.c ---- libhb/audio_remap.c.orig -+++ libhb/audio_remap.c -@@ -258,7 +258,7 @@ void hb_audio_remap_set_channel_layout(hb_audio_remap_ - { - channel_layout = AV_CH_LAYOUT_STEREO; - } -- remap->nchannels = hb_layout_get_discrete_channel_count(channel_layout); -+ remap->nchannels = av_get_channel_layout_nb_channels(channel_layout); - - // in some cases, remapping is not necessary and/or supported - if (remap->nchannels > HB_AUDIO_REMAP_MAX_CHANNELS) -@@ -317,7 +317,7 @@ void hb_audio_remap_build_table(hb_chan_map_t *channel - // Dolby Surround is Stereo when it comes to remapping - channel_layout = AV_CH_LAYOUT_STEREO; - } -- nchannels = hb_layout_get_discrete_channel_count(channel_layout); -+ nchannels = av_get_channel_layout_nb_channels(channel_layout); - - // clear remap table before (re-)building it - memset(remap_table, 0, nchannels * sizeof(int)); Index: patches/patch-libhb_audio_resample_c =================================================================== RCS file: patches/patch-libhb_audio_resample_c diff -N patches/patch-libhb_audio_resample_c --- patches/patch-libhb_audio_resample_c 29 May 2024 08:47:50 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,25 +0,0 @@ -Revert "libhb: use mask part the new FFmpeg channel layout api." -c5012478cba356b8f8f222d6acff9fe3cc74e67e - -Index: libhb/audio_resample.c ---- libhb/audio_resample.c.orig -+++ libhb/audio_resample.c -@@ -53,7 +53,7 @@ hb_audio_resample_t* hb_audio_resample_init(enum AVSam - } - - // requested output channel_layout, sample_fmt -- resample->out.channels = hb_layout_get_discrete_channel_count(channel_layout); -+ resample->out.channels = av_get_channel_layout_nb_channels(channel_layout); - resample->out.channel_layout = channel_layout; - resample->out.matrix_encoding = matrix_encoding; - resample->out.sample_fmt = sample_fmt; -@@ -232,7 +232,8 @@ int hb_audio_resample_update(hb_audio_resample_t *resa - resample->resample.sample_fmt = resample->in.sample_fmt; - resample->resample.sample_rate = resample->in.sample_rate; - resample->resample.channel_layout = resample->in.channel_layout; -- resample->resample.channels = hb_layout_get_discrete_channel_count(resample->in.channel_layout); -+ resample->resample.channels = -+ av_get_channel_layout_nb_channels(resample->in.channel_layout); - resample->resample.lfe_mix_level = resample->in.lfe_mix_level; - resample->resample.center_mix_level = resample->in.center_mix_level; - resample->resample.surround_mix_level = resample->in.surround_mix_level; Index: patches/patch-libhb_common_c =================================================================== RCS file: patches/patch-libhb_common_c diff -N patches/patch-libhb_common_c --- patches/patch-libhb_common_c 29 May 2024 08:47:50 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,41 +0,0 @@ -Revert "libhb: use mask part the new FFmpeg channel layout api." -c5012478cba356b8f8f222d6acff9fe3cc74e67e - -Index: libhb/common.c ---- libhb/common.c.orig -+++ libhb/common.c -@@ -2283,7 +2283,7 @@ int hb_mixdown_has_remix_support(int mixdown, uint64_t - - // more than 1 channel - case HB_AMIXDOWN_STEREO: -- return (hb_layout_get_discrete_channel_count(layout) > 1); -+ return (av_get_channel_layout_nb_channels(layout) > 1); - - // regular stereo (not Dolby) - case HB_AMIXDOWN_LEFT: -@@ -2483,22 +2483,14 @@ const hb_mixdown_t* hb_mixdown_get_next(const hb_mixdo - return ((hb_mixdown_internal_t*)last)->next; - } - --void hb_layout_get_name(char *name, int size, int64_t layout) -+void hb_layout_get_name(char * name, int size, int64_t layout) - { -- AVChannelLayout ch_layout = {0}; -- av_channel_layout_from_mask(&ch_layout, layout); -- av_channel_layout_describe(&ch_layout, name, size); -- av_channel_layout_uninit(&ch_layout); -+ av_get_channel_layout_string(name, size, 0, layout); - } - - int hb_layout_get_discrete_channel_count(int64_t layout) - { -- int nb_channels = 0; -- AVChannelLayout ch_layout = {0}; -- av_channel_layout_from_mask(&ch_layout, layout); -- nb_channels = ch_layout.nb_channels; -- av_channel_layout_uninit(&ch_layout); -- return nb_channels; -+ return av_get_channel_layout_nb_channels(layout); - } - - int hb_layout_get_low_freq_channel_count(int64_t layout) Index: patches/patch-libhb_decavcodec_c =================================================================== RCS file: patches/patch-libhb_decavcodec_c diff -N patches/patch-libhb_decavcodec_c --- patches/patch-libhb_decavcodec_c 29 May 2024 08:47:50 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,167 +0,0 @@ -Revert "libhb: use mask part the new FFmpeg channel layout api." -c5012478cba356b8f8f222d6acff9fe3cc74e67e - -Index: libhb/decavcodec.c ---- libhb/decavcodec.c.orig -+++ libhb/decavcodec.c -@@ -207,9 +207,6 @@ static int decavcodecaInit( hb_work_object_t * w, hb_j - } - hb_ff_set_sample_fmt(pv->context, codec, AV_SAMPLE_FMT_FLT); - -- // Set decoder opts... -- AVDictionary *av_opts = NULL; -- - /* Downmixing & sample_fmt conversion */ - if (!(w->audio->config.out.codec & HB_ACODEC_PASS_FLAG)) - { -@@ -239,7 +236,7 @@ static int decavcodecaInit( hb_work_object_t * w, hb_j - { - case AV_CODEC_ID_AC3: - case AV_CODEC_ID_EAC3: -- avcodec_downmix = w->audio->config.out.normalize_mix_level == 0; -+ avcodec_downmix = w->audio->config.out.normalize_mix_level != 0; - break; - case AV_CODEC_ID_DTS: - avcodec_downmix = w->audio->config.out.normalize_mix_level == 0; -@@ -260,21 +257,13 @@ static int decavcodecaInit( hb_work_object_t * w, hb_j - // request 5.1 before downmixing to dpl1/dpl2 - case HB_AMIXDOWN_DOLBY: - case HB_AMIXDOWN_DOLBYPLII: -- { -- av_dict_set(&av_opts, "downmix", "5.1(side)", 0); -+ pv->context->request_channel_layout = AV_CH_LAYOUT_5POINT1; - break; -- } - // request the layout corresponding to the selected mixdown - default: -- { -- char description[256]; -- AVChannelLayout ch_layout = {0}; -- av_channel_layout_from_mask(&ch_layout, hb_ff_mixdown_xlat(w->audio->config.out.mixdown, NULL)); -- av_channel_layout_describe(&ch_layout, description, sizeof(description)); -- av_channel_layout_uninit(&ch_layout); -- av_dict_set(&av_opts, "downmix", description, 0); -+ pv->context->request_channel_layout = -+ hb_ff_mixdown_xlat(w->audio->config.out.mixdown, NULL); - break; -- } - } - } - } -@@ -284,9 +273,12 @@ static int decavcodecaInit( hb_work_object_t * w, hb_j - if (w->codec_param == AV_CODEC_ID_TRUEHD && - w->audio->config.in.channel_layout == AV_CH_LAYOUT_MONO) - { -- av_dict_set(&av_opts, "downmix", "stereo", 0); -+ pv->context->request_channel_layout = AV_CH_LAYOUT_STEREO; - } - -+ // Set decoder opts... -+ AVDictionary * av_opts = NULL; -+ - // Dynamic Range Compression - if (w->audio->config.out.dynamic_range_compression >= 0.0f && - hb_audio_can_apply_drc(w->audio->config.in.codec, -@@ -332,14 +324,6 @@ static int decavcodecaInit( hb_work_object_t * w, hb_j - pv->context->pkt_timebase.num = pv->audio->config.in.timebase.num; - pv->context->pkt_timebase.den = pv->audio->config.in.timebase.den; - -- // libavcodec can't decode TrueHD Mono (bug #356) -- // work around it by requesting Stereo and downmixing -- if (w->codec_param == AV_CODEC_ID_TRUEHD && -- w->audio->config.in.channel_layout == AV_CH_LAYOUT_MONO) -- { -- pv->context->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; -- } -- - // avcodec_open populates av_opts with the things it didn't recognize. - AVDictionaryEntry *t = NULL; - while ((t = av_dict_get(av_opts, "", t, AV_DICT_IGNORE_SUFFIX)) != NULL) -@@ -752,13 +736,15 @@ static int decavcodecaBSInfo( hb_work_object_t *w, con - // libavcodec can't decode TrueHD Mono (bug #356) - // work around it by requesting Stereo before decoding - if (context->codec_id == AV_CODEC_ID_TRUEHD && -- context->ch_layout.u.mask == AV_CH_LAYOUT_MONO) -+ context->channel_layout == AV_CH_LAYOUT_MONO) - { - truehd_mono = 1; -- AVChannelLayout ch_layout = AV_CHANNEL_LAYOUT_STEREO; -- av_opt_set_chlayout(context, "downmix", &ch_layout, AV_OPT_SEARCH_CHILDREN); -- context->ch_layout = ch_layout; -+ context->request_channel_layout = AV_CH_LAYOUT_STEREO; - } -+ else -+ { -+ context->request_channel_layout = 0; -+ } - - AVPacket *avp = av_packet_alloc(); - avp->data = parse_buffer; -@@ -797,7 +783,16 @@ static int decavcodecaBSInfo( hb_work_object_t *w, con - info->sample_bit_depth = context->bits_per_raw_sample; - - int bps = av_get_bits_per_sample(context->codec_id); -- int channels = frame->ch_layout.nb_channels; -+ int channels; -+ if (frame->channel_layout != 0) -+ { -+ channels = av_get_channel_layout_nb_channels( -+ frame->channel_layout); -+ } -+ else -+ { -+ channels = frame->channels; -+ } - - info->bitrate = bps * channels * info->rate.num; - if (info->bitrate <= 0) -@@ -837,17 +832,15 @@ static int decavcodecaBSInfo( hb_work_object_t *w, con - } - else - { -- info->channel_layout = frame->ch_layout.u.mask; -+ info->channel_layout = frame->channel_layout; - } - } - if (info->channel_layout == 0) - { - // Channel layout was not set. Guess a layout based - // on number of channels. -- AVChannelLayout channel_layout; -- av_channel_layout_default(&channel_layout, frame->ch_layout.nb_channels); -- info->channel_layout = channel_layout.u.mask; -- av_channel_layout_uninit(&channel_layout); -+ info->channel_layout = av_get_default_channel_layout( -+ frame->channels); - } - if (context->codec_id == AV_CODEC_ID_AC3 || - context->codec_id == AV_CODEC_ID_EAC3) -@@ -2310,7 +2303,7 @@ static void decodeAudio(hb_work_private_t *pv, packet_ - else - { - AVFrameSideData *side_data; -- AVChannelLayout channel_layout; -+ uint64_t channel_layout; - if ((side_data = - av_frame_get_side_data(pv->frame, - AV_FRAME_DATA_DOWNMIX_INFO)) != NULL) -@@ -2335,14 +2328,13 @@ static void decodeAudio(hb_work_private_t *pv, packet_ - center_mix_level, - downmix_info->lfe_mix_level); - } -- channel_layout = pv->frame->ch_layout; -- if (channel_layout.order != AV_CHANNEL_ORDER_NATIVE || channel_layout.u.mask == 0) -+ channel_layout = pv->frame->channel_layout; -+ if (channel_layout == 0) - { -- AVChannelLayout default_ch_layout; -- av_channel_layout_default(&default_ch_layout, pv->frame->ch_layout.nb_channels); -- channel_layout = default_ch_layout; -+ channel_layout = av_get_default_channel_layout( -+ pv->frame->channels); - } -- hb_audio_resample_set_channel_layout(pv->resample, channel_layout.u.mask); -+ hb_audio_resample_set_channel_layout(pv->resample, channel_layout); - hb_audio_resample_set_sample_fmt(pv->resample, - pv->frame->format); - hb_audio_resample_set_sample_rate(pv->resample, Index: patches/patch-libhb_encavcodecaudio_c =================================================================== RCS file: patches/patch-libhb_encavcodecaudio_c diff -N patches/patch-libhb_encavcodecaudio_c --- patches/patch-libhb_encavcodecaudio_c 29 May 2024 08:47:50 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,64 +0,0 @@ -Revert "libhb: use mask part the new FFmpeg channel layout api." -c5012478cba356b8f8f222d6acff9fe3cc74e67e - -Index: libhb/encavcodecaudio.c ---- libhb/encavcodecaudio.c.orig -+++ libhb/encavcodecaudio.c -@@ -174,15 +174,13 @@ static int encavcodecaInit(hb_work_object_t *w, hb_job - } - } - -- AVChannelLayout ch_layout = {0}; -- av_channel_layout_from_mask(&ch_layout, channel_layout); -- - // allocate the context and apply the settings - context = avcodec_alloc_context3(codec); - hb_ff_set_sample_fmt(context, codec, sample_fmt); - context->bits_per_raw_sample = bits_per_raw_sample; - context->profile = profile; -- context->ch_layout = ch_layout; -+ context->channel_layout = channel_layout; -+ context->channels = pv->out_discrete_channels; - context->sample_rate = audio->config.out.samplerate; - context->time_base = (AVRational){1, 90000}; - -@@ -234,7 +232,7 @@ static int encavcodecaInit(hb_work_object_t *w, hb_job - pv->context = context; - audio->config.out.samples_per_frame = - pv->samples_per_frame = context->frame_size; -- pv->input_samples = context->frame_size * context->ch_layout.nb_channels; -+ pv->input_samples = context->frame_size * context->channels; - pv->input_buf = malloc(pv->input_samples * sizeof(float)); - // Some encoders in libav (e.g. fdk-aac) fail if the output buffer - // size is not some minimum value. 8K seems to be enough :( -@@ -257,9 +255,9 @@ static int encavcodecaInit(hb_work_object_t *w, hb_job - av_opt_set_int(pv->swresample, "out_sample_fmt", - context->sample_fmt, 0); - av_opt_set_int(pv->swresample, "in_channel_layout", -- context->ch_layout.u.mask, 0); -+ context->channel_layout, 0); - av_opt_set_int(pv->swresample, "out_channel_layout", -- context->ch_layout.u.mask, 0); -+ context->channel_layout, 0); - av_opt_set_int(pv->swresample, "in_sample_rate", - context->sample_rate, 0); - av_opt_set_int(pv->swresample, "out_sample_rate", -@@ -423,15 +421,15 @@ static void Encode(hb_work_object_t *w, hb_buffer_list - int out_size; - AVFrame frame = { .nb_samples = pv->samples_per_frame, - .format = pv->context->sample_fmt, -- .ch_layout = pv->context->ch_layout -+ .channels = pv->context->channels - }; - - out_size = av_samples_get_buffer_size(NULL, -- pv->context->ch_layout.nb_channels, -+ pv->context->channels, - pv->samples_per_frame, - pv->context->sample_fmt, 1); - avcodec_fill_audio_frame(&frame, -- pv->context->ch_layout.nb_channels, pv->context->sample_fmt, -+ pv->context->channels, pv->context->sample_fmt, - pv->output_buf, out_size, 1); - if (pv->swresample != NULL) - { Index: patches/patch-libhb_muxavformat_c =================================================================== RCS file: patches/patch-libhb_muxavformat_c diff -N patches/patch-libhb_muxavformat_c --- patches/patch-libhb_muxavformat_c 29 May 2024 08:47:50 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,33 +0,0 @@ -Revert "libhb: use mask part the new FFmpeg channel layout api." -c5012478cba356b8f8f222d6acff9fe3cc74e67e - -Index: libhb/muxavformat.c ---- libhb/muxavformat.c.orig -+++ libhb/muxavformat.c -@@ -804,21 +804,19 @@ static int avformatInit( hb_mux_object_t * m ) - track->st->codecpar->sample_rate = audio->config.out.samplerate; - if (audio->config.out.codec & HB_ACODEC_PASS_FLAG) - { -- AVChannelLayout ch_layout = {0}; -- av_channel_layout_from_mask(&ch_layout, audio->config.in.channel_layout); -- track->st->codecpar->ch_layout = ch_layout; -+ track->st->codecpar->channels = av_get_channel_layout_nb_channels(audio->config.in.channel_layout); -+ track->st->codecpar->channel_layout = audio->config.in.channel_layout; - } - else - { -- AVChannelLayout ch_layout = {0}; -- av_channel_layout_from_mask(&ch_layout, hb_ff_mixdown_xlat(audio->config.out.mixdown, NULL)); -- track->st->codecpar->ch_layout = ch_layout; -+ track->st->codecpar->channels = hb_mixdown_get_discrete_channel_count(audio->config.out.mixdown); -+ track->st->codecpar->channel_layout = hb_ff_mixdown_xlat(audio->config.out.mixdown, NULL); - } - - const char *name; - if (audio->config.out.name == NULL) - { -- switch (track->st->codecpar->ch_layout.nb_channels) -+ switch (track->st->codecpar->channels) - { - case 1: - name = "Mono"; Index: patches/patch-libhb_scan_c =================================================================== RCS file: patches/patch-libhb_scan_c diff -N patches/patch-libhb_scan_c --- patches/patch-libhb_scan_c 29 May 2024 08:47:50 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,15 +0,0 @@ -Revert "libhb: use mask part the new FFmpeg channel layout api." -c5012478cba356b8f8f222d6acff9fe3cc74e67e - -Index: libhb/scan.c ---- libhb/scan.c.orig -+++ libhb/scan.c -@@ -1611,7 +1611,7 @@ static void LookForAudio(hb_scan_t *scan, hb_title_t * - { - int lfes = (!!(audio->config.in.channel_layout & AV_CH_LOW_FREQUENCY) + - !!(audio->config.in.channel_layout & AV_CH_LOW_FREQUENCY_2)); -- int channels = hb_layout_get_discrete_channel_count(audio->config.in.channel_layout); -+ int channels = av_get_channel_layout_nb_channels(audio->config.in.channel_layout); - char *desc = audio->config.lang.description + - strlen(audio->config.lang.description); - size_t size = sizeof(audio->config.lang.description) - strlen(audio->config.lang.description);