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
33typedef struct PCMAudioDemuxerContext {33typedef struct PCMAudioDemuxerContext {
34 AVClass *class;34 AVClass *class;
35 int sample_rate;35 int sample_rate;
36#if FF_API_OLD_CHANNEL_LAYOUT
36 int channels;37 int channels;
38#endif
37 AVChannelLayout ch_layout;39 AVChannelLayout ch_layout;
38} PCMAudioDemuxerContext;40} PCMAudioDemuxerContext;
39 41
@@ -43,6 +45,7 @@ static int pcm_read_header(AVFormatContext *s) · 3 unmodified lines
43 AVCodecParameters *par;45 AVCodecParameters *par;
44 AVStream *st;46 AVStream *st;
45 uint8_t *mime_type = NULL;47 uint8_t *mime_type = NULL;
48 int ret;
46 49
47 st = avformat_new_stream(s, NULL);50 st = avformat_new_stream(s, NULL);
48 if (!st)51 if (!st)
@@ -52,13 +55,16 @@ static int pcm_read_header(AVFormatContext *s) · 3 unmodified lines
52 par->codec_type = AVMEDIA_TYPE_AUDIO;55 par->codec_type = AVMEDIA_TYPE_AUDIO;
53 par->codec_id = s->iformat->raw_codec_id;56 par->codec_id = s->iformat->raw_codec_id;
54 par->sample_rate = s1->sample_rate;57 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
56 par->ch_layout.nb_channels = s1->channels;66 par->ch_layout.nb_channels = s1->channels;
57 else {67#endif
58 int ret = av_channel_layout_copy(&par->ch_layout, &s1->ch_layout);
59 if (ret < 0)
60 return ret;
61 }
62 68
63 av_opt_get(s->pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type);69 av_opt_get(s->pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type);
64 if (mime_type && s->iformat->mime_type) {70 if (mime_type && s->iformat->mime_type) {
@@ -108,8 +114,12 @@ static int pcm_read_header(AVFormatContext *s) · 43 unmodified lines
108 114
109static const AVOption pcm_options[] = {115static const AVOption pcm_options[] = {
110 { "sample_rate", "", offsetof(PCMAudioDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.i64 = 44100}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },116 { "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
112 { "ch_layout", "", offsetof(PCMAudioDemuxerContext, ch_layout), AV_OPT_TYPE_CHLAYOUT, {.str = "mono"}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },121 { "ch_layout", "", offsetof(PCMAudioDemuxerContext, ch_layout), AV_OPT_TYPE_CHLAYOUT, {.str = "mono"}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
122#endif
113 { NULL },123 { NULL },
114};124};
115static const AVClass pcm_demuxer_class = {125static 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