@@ -127,12 +127,14 @@ class Decoder
127127 ctx->framerate = av_guess_frame_rate (nullptr , stream, nullptr );
128128 ctx->sample_aspect_ratio = av_guess_sample_aspect_ratio (nullptr , stream, nullptr );
129129 } else if (ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
130+ #if !(FFMPEG_NEW_CHANNEL_LAYOUT)
130131 if (!ctx->channel_layout && ctx->channels ) {
131132 ctx->channel_layout = av_get_default_channel_layout (ctx->channels );
132133 }
133134 if (!ctx->channels && ctx->channel_layout ) {
134135 ctx->channels = av_get_channel_layout_nb_channels (ctx->channel_layout );
135136 }
137+ #endif
136138 }
137139
138140 if (codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) {
@@ -178,7 +180,11 @@ class Decoder
178180 // TODO (fix) is this always best?
179181 av_frame->pts = av_frame->best_effort_timestamp ;
180182
183+ #if LIBAVUTIL_VERSION_MAJOR < 58
181184 auto duration_pts = av_frame->pkt_duration ;
185+ #else
186+ auto duration_pts = av_frame->duration ;
187+ #endif
182188 if (duration_pts <= 0 ) {
183189 if (ctx->codec_type == AVMEDIA_TYPE_VIDEO) {
184190 const auto ticks = av_stream_get_parser (st) ? av_stream_get_parser (st)->repeat_pict + 1
@@ -313,7 +319,12 @@ struct Filter
313319 AVRational tb = {1 , format_desc.audio_sample_rate };
314320 for (auto n = 0U ; n < input->nb_streams ; ++n) {
315321 const auto st = input->streams [n];
316- if (st->codecpar ->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar ->channels > 0 ) {
322+ #if FFMPEG_NEW_CHANNEL_LAYOUT
323+ const auto codec_channels = st->codecpar ->ch_layout .nb_channels ;
324+ #else
325+ const auto codec_channels = st->codecpar ->channels ;
326+ #endif
327+ if (st->codecpar ->codec_type == AVMEDIA_TYPE_AUDIO && codec_channels > 0 ) {
317328 tb = {1 , st->codecpar ->sample_rate };
318329 break ;
319330 }
@@ -364,7 +375,12 @@ struct Filter
364375 for (auto n = 0U ; n < input->nb_streams ; ++n) {
365376 const auto st = input->streams [n];
366377
367- if (st->codecpar ->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar ->channels == 0 ) {
378+ #if FFMPEG_NEW_CHANNEL_LAYOUT
379+ const auto codec_channels = st->codecpar ->ch_layout .nb_channels ;
380+ #else
381+ const auto codec_channels = st->codecpar ->channels ;
382+ #endif
383+ if (st->codecpar ->codec_type == AVMEDIA_TYPE_AUDIO && codec_channels == 0 ) {
368384 continue ;
369385 }
370386
@@ -468,9 +484,16 @@ struct Filter
468484 FF (avfilter_link (source, 0 , cur->filter_ctx , cur->pad_idx ));
469485 sources.emplace (index, source);
470486 } else if (st->codec_type == AVMEDIA_TYPE_AUDIO) {
487+ #if FFMPEG_NEW_CHANNEL_LAYOUT
488+ char channel_layout[128 ];
489+ FF (av_channel_layout_describe (&st->ch_layout , channel_layout, sizeof (channel_layout)));
490+ #else
491+ const auto channel_layout = st->channel_layout ;
492+ #endif
493+
471494 auto args = (boost::format (" time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=%#x" ) %
472495 st->pkt_timebase .num % st->pkt_timebase .den % st->sample_rate %
473- av_get_sample_fmt_name (st->sample_fmt ) % st-> channel_layout )
496+ av_get_sample_fmt_name (st->sample_fmt ) % channel_layout)
474497 .str ();
475498 auto name = (boost::format (" in_%d" ) % index).str ();
476499
@@ -523,8 +546,7 @@ struct Filter
523546 const AVSampleFormat sample_fmts[] = {AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE};
524547 FF (av_opt_set_int_list (sink, " sample_fmts" , sample_fmts, -1 , AV_OPT_SEARCH_CHILDREN));
525548
526- const int channel_counts[] = {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , -1 };
527- FF (av_opt_set_int_list (sink, " channel_counts" , channel_counts, -1 , AV_OPT_SEARCH_CHILDREN));
549+ FF (av_opt_set_int (sink, " all_channel_counts" , 1 , AV_OPT_SEARCH_CHILDREN));
528550
529551 const int sample_rates[] = {format_desc.audio_sample_rate , -1 };
530552 FF (av_opt_set_int_list (sink, " sample_rates" , sample_rates, -1 , AV_OPT_SEARCH_CHILDREN));
0 commit comments