This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 1a0ab27954b8bb780358a168ae5b6b9637412e14 Author: James Almer <[email protected]> AuthorDate: Tue May 26 13:31:37 2026 -0300 Commit: James Almer <[email protected]> CommitDate: Sat May 30 21:37:33 2026 -0300 avfilter/af_aresample: propagate the matrix encoding used for downmixing Signed-off-by: James Almer <[email protected]> --- libavfilter/af_aresample.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c index 6c8e8e96ce..15b14b27f7 100644 --- a/libavfilter/af_aresample.c +++ b/libavfilter/af_aresample.c @@ -135,6 +135,7 @@ static int config_output(AVFilterLink *outlink) int64_t out_rate; const AVFrameSideData *sd; enum AVSampleFormat out_format; + enum AVMatrixEncoding matrix_encoding = AV_MATRIX_ENCODING_NONE; char inchl_buf[128], outchl_buf[128]; ret = swr_alloc_set_opts2(&aresample->swr, @@ -148,7 +149,6 @@ static int config_output(AVFilterLink *outlink) AV_FRAME_DATA_DOWNMIX_INFO); if (sd) { const AVDownmixInfo *di = (AVDownmixInfo *)sd->data; - enum AVMatrixEncoding matrix_encoding = AV_MATRIX_ENCODING_NONE; double center_mix_level, surround_mix_level; switch (di->preferred_downmix_type) { @@ -168,6 +168,14 @@ static int config_output(AVFilterLink *outlink) break; } + // Don't use Dolby Surround compatible coeffs when not downmixing to stereo + if (av_channel_layout_compare(&outlink->ch_layout, + &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO)) { + matrix_encoding = AV_MATRIX_ENCODING_NONE; + center_mix_level = di->center_mix_level; + surround_mix_level = di->surround_mix_level; + } + av_log(ctx, AV_LOG_VERBOSE, "Mix levels: center %f - " "surround %f - lfe %f.\n", center_mix_level, surround_mix_level, di->lfe_mix_level); @@ -176,10 +184,22 @@ static int config_output(AVFilterLink *outlink) av_opt_set_double(aresample->swr, "slev", surround_mix_level, 0); av_opt_set_double(aresample->swr, "lfe_mix_level", di->lfe_mix_level, 0); av_opt_set_int(aresample->swr, "matrix_encoding", matrix_encoding, 0); + } - if (av_channel_layout_compare(&outlink->ch_layout, &inlink->ch_layout)) - av_frame_side_data_remove(&outlink->side_data, &outlink->nb_side_data, - AV_FRAME_DATA_DOWNMIX_INFO); + if (av_channel_layout_compare(&outlink->ch_layout, &inlink->ch_layout)) { + av_frame_side_data_remove_by_props(&outlink->side_data, &outlink->nb_side_data, + AV_SIDE_DATA_PROP_CHANNEL_DEPENDENT); + + if (matrix_encoding != AV_MATRIX_ENCODING_NONE) { + AVFrameSideData *side_data = av_frame_side_data_new(&outlink->side_data, &outlink->nb_side_data, + AV_FRAME_DATA_MATRIXENCODING, + sizeof(matrix_encoding), 0); + + if (!side_data) + return AVERROR(ENOMEM); + + *(enum AVMatrixEncoding *)side_data->data = matrix_encoding; + } } ret = swr_init(aresample->swr); _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
