summaryrefslogtreecommitdiff
path: root/doc/examples/filter_audio.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2022-01-20 17:47:51 -0300
committerJames Almer <jamrial@gmail.com>2022-03-15 09:42:47 -0300
commitf5ef91e02080316f50d606f5b0b03333bb627ed7 (patch)
treed6338f72a9ee59dfbf29024ae5d5a5aa29d81ce9 /doc/examples/filter_audio.c
parent50e9e11316064ecdee889b18a0b6681a248edcf4 (diff)
doc/examples: convert to new channel layout-API
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'doc/examples/filter_audio.c')
-rw-r--r--doc/examples/filter_audio.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/doc/examples/filter_audio.c b/doc/examples/filter_audio.c
index 1611e3d952..f53e52562b 100644
--- a/doc/examples/filter_audio.c
+++ b/doc/examples/filter_audio.c
@@ -55,7 +55,7 @@
#define INPUT_SAMPLERATE 48000
#define INPUT_FORMAT AV_SAMPLE_FMT_FLTP
-#define INPUT_CHANNEL_LAYOUT AV_CH_LAYOUT_5POINT0
+#define INPUT_CHANNEL_LAYOUT (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0
#define VOLUME_VAL 0.90
@@ -100,7 +100,7 @@ static int init_filter_graph(AVFilterGraph **graph, AVFilterContext **src,
}
/* Set the filter options through the AVOptions API. */
- av_get_channel_layout_string(ch_layout, sizeof(ch_layout), 0, INPUT_CHANNEL_LAYOUT);
+ av_channel_layout_describe(&INPUT_CHANNEL_LAYOUT, ch_layout, sizeof(ch_layout));
av_opt_set (abuffer_ctx, "channel_layout", ch_layout, AV_OPT_SEARCH_CHILDREN);
av_opt_set (abuffer_ctx, "sample_fmt", av_get_sample_fmt_name(INPUT_FORMAT), AV_OPT_SEARCH_CHILDREN);
av_opt_set_q (abuffer_ctx, "time_base", (AVRational){ 1, INPUT_SAMPLERATE }, AV_OPT_SEARCH_CHILDREN);
@@ -154,9 +154,8 @@ static int init_filter_graph(AVFilterGraph **graph, AVFilterContext **src,
/* A third way of passing the options is in a string of the form
* key1=value1:key2=value2.... */
snprintf(options_str, sizeof(options_str),
- "sample_fmts=%s:sample_rates=%d:channel_layouts=0x%"PRIx64,
- av_get_sample_fmt_name(AV_SAMPLE_FMT_S16), 44100,
- (uint64_t)AV_CH_LAYOUT_STEREO);
+ "sample_fmts=%s:sample_rates=%d:channel_layouts=stereo",
+ av_get_sample_fmt_name(AV_SAMPLE_FMT_S16), 44100);
err = avfilter_init_str(aformat_ctx, options_str);
if (err < 0) {
av_log(NULL, AV_LOG_ERROR, "Could not initialize the aformat filter.\n");
@@ -215,7 +214,7 @@ static int init_filter_graph(AVFilterGraph **graph, AVFilterContext **src,
static int process_output(struct AVMD5 *md5, AVFrame *frame)
{
int planar = av_sample_fmt_is_planar(frame->format);
- int channels = av_get_channel_layout_nb_channels(frame->channel_layout);
+ int channels = frame->ch_layout.nb_channels;
int planes = planar ? channels : 1;
int bps = av_get_bytes_per_sample(frame->format);
int plane_size = bps * frame->nb_samples * (planar ? 1 : channels);
@@ -248,7 +247,7 @@ static int get_input(AVFrame *frame, int frame_num)
/* Set up the frame properties and allocate the buffer for the data. */
frame->sample_rate = INPUT_SAMPLERATE;
frame->format = INPUT_FORMAT;
- frame->channel_layout = INPUT_CHANNEL_LAYOUT;
+ av_channel_layout_copy(&frame->ch_layout, &INPUT_CHANNEL_LAYOUT);
frame->nb_samples = FRAME_SIZE;
frame->pts = frame_num * FRAME_SIZE;