2 # User Torsten Jager <t.jager@gmx.de>
3 # Date 1674929040 -3600
4 # Sat Jan 28 19:04:00 2023 +0100
5 # Node ID 771f4ae27e582123ff3500444718fc8f96186d74
6 # Parent 250f1c09f4244c3e7ca7d414410c57bd387792c3
7 ffmpeg compatibility update.
9 diff -r 250f1c09f424 -r 771f4ae27e58 src/combined/ffmpeg/demux_avformat.c
10 --- a/src/combined/ffmpeg/demux_avformat.c Wed Jan 25 17:03:55 2023 +0100
11 +++ b/src/combined/ffmpeg/demux_avformat.c Sat Jan 28 19:04:00 2023 +0100
14 - * Copyright (C) 2013-2022 the xine project
15 + * Copyright (C) 2013-2023 the xine project
16 * Copyright (C) 2013-2020 Petri Hintukainen <phintuka@users.sourceforge.net>
18 * This file is part of xine, a free video player.
23 +# if XFF_AUDIO_CHANNEL_LAYOUT < 2
24 if (st->codecpar && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
25 st->codecpar->sample_rate != 0 && st->codecpar->channels != 0)
27 + if (st->codecpar && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
28 + st->codecpar->sample_rate != 0 && st->codecpar->ch_layout.nb_channels != 0)
31 if (st->codec && st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
32 st->codec->sample_rate != 0 && st->codec->channels != 0)
34 buf->size = extradata_size + sizeof(xine_waveformatex);
35 buf->decoder_info[1] = ctx->sample_rate;
36 buf->decoder_info[2] = ctx->bits_per_coded_sample;
37 +#if XFF_AUDIO_CHANNEL_LAYOUT < 2
38 buf->decoder_info[3] = ctx->channels;
40 + buf->decoder_info[3] = ctx->ch_layout.nb_channels;
42 buf->decoder_flags = BUF_FLAG_HEADER | BUF_FLAG_STDHEADER | BUF_FLAG_FRAME_END;
44 this->stream->audio_fifo->put (this->stream->audio_fifo, buf);
45 diff -r 250f1c09f424 -r 771f4ae27e58 src/combined/ffmpeg/ff_audio_decoder.c
46 --- a/src/combined/ffmpeg/ff_audio_decoder.c Wed Jan 25 17:03:55 2023 +0100
47 +++ b/src/combined/ffmpeg/ff_audio_decoder.c Sat Jan 28 19:04:00 2023 +0100
50 - * Copyright (C) 2001-2022 the xine project
51 + * Copyright (C) 2001-2023 the xine project
53 * This file is part of xine, a free video player.
57 this->context->bits_per_sample = this->ff_bits;
58 this->context->sample_rate = this->ff_sample_rate;
59 +#if XFF_AUDIO_CHANNEL_LAYOUT < 2
60 this->context->channels = this->ff_channels;
62 + this->context->ch_layout.nb_channels = this->ff_channels;
64 this->context->codec_id = this->codec->id;
65 this->context->codec_type = this->codec->type;
66 this->context->codec_tag = _x_stream_info_get(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC);
71 +static unsigned int ff_list_channels (uint8_t *list, uint64_t map) {
72 + unsigned int n, bit;
74 + for (n = bit = 0; map; map >>= 1, bit++) {
75 + uint32_t b = map & 1;
83 static void ff_map_channels (ff_audio_decoder_t *this) {
85 + uint8_t ff_list[64];
86 + unsigned int ff_num;
87 + const char *type = "native";
88 int caps = this->stream->audio_out->get_capabilities (this->stream->audio_out);
90 +#if XFF_AUDIO_CHANNEL_LAYOUT < 2
92 /* safety kludge for very old libavcodec */
93 -#ifdef AV_CH_FRONT_LEFT
94 +# ifdef AV_CH_FRONT_LEFT
95 ff_map = this->context->channel_layout;
96 if (!ff_map) /* wma2 bug */
98 + ff_map = ((uint64_t)1 << this->context->channels) - 1;
99 + ff_num = ff_list_channels (ff_list, ff_map);
101 +#else /* XFF_AUDIO_CHANNEL_LAYOUT == 2 */
103 + ff_num = this->context->ch_layout.nb_channels;
104 + if (ff_num > (int)(sizeof (ff_list) / sizeof (ff_list[0])))
105 + ff_num = sizeof (ff_list) / sizeof (ff_list[0]);
106 + switch (this->context->ch_layout.order) {
107 + const AVChannelCustom *cmap;
110 + case AV_CHANNEL_ORDER_UNSPEC:
114 + case AV_CHANNEL_ORDER_NATIVE:
115 + ff_map = this->context->ch_layout.u.mask;
116 + if (!ff_map) /* wma2 bug */
117 + ff_map = ((uint64_t)1 << ff_num) - 1;
118 + ff_num = ff_list_channels (ff_list, ff_map);
121 + case AV_CHANNEL_ORDER_CUSTOM:
123 + if (!(cmap = this->context->ch_layout.u.map))
126 + for (i = 0; i < ff_num; i++) {
127 + ff_list[i] = cmap[i].id;
128 + ff_map |= (uint64_t)1 << ff_list[i];
133 + type = "unsupported";
136 + ff_map = ((uint64_t)1 << ff_num) - 1;
137 + ff_num = ff_list_channels (ff_list, ff_map);
141 - ff_map = ((uint64_t)1 << this->context->channels) - 1;
143 if ((caps != this->ao_caps) || (ff_map != this->ff_map)) {
147 this->ao_caps = caps;
148 this->ff_map = ff_map;
149 - this->ff_channels = this->context->channels;
150 + this->ff_channels = ff_num;
153 for (i = 0; i < MAX_CHANNELS; i++)
154 @@ -576,20 +639,23 @@
155 this->left[0] = this->right[0] = 0;
156 tries = wishlist + 0 * num_modes;
157 } else if (this->ff_channels == 2) { /* stereo */
158 + /* FIXME: libxine does not yet support audio selection _after_ decoding.
159 + * For now, treat the most common "dual mono" case as stereo. */
164 tries = wishlist + 1 * num_modes;
166 - for (i = j = 0; i < sizeof (base_map) / sizeof (base_map[0]); i++) {
167 - if ((ff_map >> i) & 1) {
168 - int8_t target = base_map[i];
169 - if ((target >= 0) && (this->map[target] < 0))
170 - this->map[target] = j;
171 - name_map[j] = i; /* for debug output below */
174 + for (i = 0; i < ff_num; i++) {
176 + uint32_t num = ff_list[i];
177 + if (num >= sizeof (base_map) / sizeof (base_map[0]))
179 + target = base_map[num];
180 + if ((target >= 0) && (this->map[target] < 0))
181 + this->map[target] = i;
182 + name_map[i] = num; /* for debug output below */
184 this->left[0] = this->map[0] < 0 ? 0 : this->map[0];
188 "side left", "side right"
191 - int p = sprintf (buf, "ff_audio_dec: channel layout: ");
193 + int p = sprintf (buf, "ff_audio_dec: %s channel layout: ", type);
194 int8_t *indx = this->left;
195 for (i = 0; i < 2; i++) {