And ensure ch_layout has priority if set over channels, until the latter is gone.
Unified · Split
| @@ -33,7 +33,9 @@ · 32 unmodified lines | ||
| 33 | 33 | typedef struct PCMAudioDemuxerContext { |
| 34 | 34 | AVClass *class; |
| 35 | 35 | int sample_rate; |
| 36 | +#if FF_API_OLD_CHANNEL_LAYOUT | |
| 36 | 37 | int channels; |
| 38 | +#endif | |
| 37 | 39 | AVChannelLayout ch_layout; |
| 38 | 40 | } PCMAudioDemuxerContext; |
| 39 | 41 | |
| @@ -43,6 +45,7 @@ static int pcm_read_header(AVFormatContext *s) · 3 unmodified lines | ||
| 43 | 45 | AVCodecParameters *par; |
| 44 | 46 | AVStream *st; |
| 45 | 47 | uint8_t *mime_type = NULL; |
| 48 | + int ret; | |
| 46 | 49 | |
| 47 | 50 | st = avformat_new_stream(s, NULL); |
| 48 | 51 | if (!st) |
| @@ -52,13 +55,16 @@ static int pcm_read_header(AVFormatContext *s) · 3 unmodified lines | ||
| 52 | 55 | par->codec_type = AVMEDIA_TYPE_AUDIO; |
| 53 | 56 | par->codec_id = s->iformat->raw_codec_id; |
| 54 | 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 | 66 | 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 | |
| 62 | 68 | |
| 63 | 69 | av_opt_get(s->pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type); |
| 64 | 70 | if (mime_type && s->iformat->mime_type) { |
| @@ -108,8 +114,12 @@ static int pcm_read_header(AVFormatContext *s) · 43 unmodified lines | ||
| 108 | 114 | |
| 109 | 115 | static const AVOption pcm_options[] = { |
| 110 | 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 | 121 | { "ch_layout", "", offsetof(PCMAudioDemuxerContext, ch_layout), AV_OPT_TYPE_CHLAYOUT, {.str = "mono"}, 0, 0, AV_OPT_FLAG_DECODING_PARAM }, |
| 122 | +#endif | |
| 113 | 123 | { NULL }, |
| 114 | 124 | }; |
| 115 | 125 | static const AVClass pcm_demuxer_class = { |