History

avformat/pcmdec: deprecate channels option

And ensure ch_layout has priority if set over channels, until the latter is gone.

James Almer committed 4 years ago

Commit 5cd6cb91 parent 902ee9c1 file · +17 −7Browse files

Unified · Split

libavformat/pcmdec.c+17−7
@@ -33,7 +33,9 @@ · 32 unmodified lines
3333 typedef struct PCMAudioDemuxerContext {
3434 AVClass *class;
3535 int sample_rate;
36+#if FF_API_OLD_CHANNEL_LAYOUT
3637 int channels;
38+#endif
3739 AVChannelLayout ch_layout;
3840 } PCMAudioDemuxerContext;
3941
@@ -43,6 +45,7 @@ static int pcm_read_header(AVFormatContext *s) · 3 unmodified lines
4345 AVCodecParameters *par;
4446 AVStream *st;
4547 uint8_t *mime_type = NULL;
48+ int ret;
4649
4750 st = avformat_new_stream(s, NULL);
4851 if (!st)
@@ -52,13 +55,16 @@ static int pcm_read_header(AVFormatContext *s) · 3 unmodified lines
5255 par->codec_type = AVMEDIA_TYPE_AUDIO;
5356 par->codec_id = s->iformat->raw_codec_id;
5457 par->sample_rate = s1->sample_rate;
55− if (s1->channels)
58+#if FF_API_OLD_CHANNEL_LAYOUT
59+ if (s1->ch_layout.nb_channels) {
60+#endif
61+ ret = av_channel_layout_copy(&par->ch_layout, &s1->ch_layout);
62+ if (ret < 0)
63+ return ret;
64+#if FF_API_OLD_CHANNEL_LAYOUT
65+ } else
5666 par->ch_layout.nb_channels = s1->channels;
57− else {
58− int ret = av_channel_layout_copy(&par->ch_layout, &s1->ch_layout);
59− if (ret < 0)
60− return ret;
61− }
67+#endif
6268
6369 av_opt_get(s->pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type);
6470 if (mime_type && s->iformat->mime_type) {
@@ -108,8 +114,12 @@ static int pcm_read_header(AVFormatContext *s) · 43 unmodified lines
108114
109115 static const AVOption pcm_options[] = {
110116 { "sample_rate", "", offsetof(PCMAudioDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.i64 = 44100}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
111− { "channels", "", offsetof(PCMAudioDemuxerContext, channels), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
117+#if FF_API_OLD_CHANNEL_LAYOUT
118+ { "channels", "", offsetof(PCMAudioDemuxerContext, channels), AV_OPT_TYPE_INT, {.i64 = 1}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_DEPRECATED },
119+ { "ch_layout", "", offsetof(PCMAudioDemuxerContext, ch_layout), AV_OPT_TYPE_CHLAYOUT, {.str = NULL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
120+#else
112121 { "ch_layout", "", offsetof(PCMAudioDemuxerContext, ch_layout), AV_OPT_TYPE_CHLAYOUT, {.str = "mono"}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
122+#endif
113123 { NULL },
114124 };
115125 static const AVClass pcm_demuxer_class = {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t