]> git.pld-linux.org Git - packages/xine-lib.git/blame - ffmpeg6.patch
- up to 1.2.13
[packages/xine-lib.git] / ffmpeg6.patch
CommitLineData
a48f55b5
JR
1# HG changeset patch
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
7ffmpeg compatibility update.
8
9diff -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
12@@ -1,5 +1,5 @@
13 /*
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>
17 *
18 * This file is part of xine, a free video player.
19@@ -423,8 +423,13 @@
20 }
21
22 #ifdef XFF_CODECPAR
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)
26+# else
27+ if (st->codecpar && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
28+ st->codecpar->sample_rate != 0 && st->codecpar->ch_layout.nb_channels != 0)
29+# endif
30 #else
31 if (st->codec && st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
32 st->codec->sample_rate != 0 && st->codec->channels != 0)
33@@ -501,7 +506,11 @@
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;
39+#else
40+ buf->decoder_info[3] = ctx->ch_layout.nb_channels;
41+#endif
42 buf->decoder_flags = BUF_FLAG_HEADER | BUF_FLAG_STDHEADER | BUF_FLAG_FRAME_END;
43
44 this->stream->audio_fifo->put (this->stream->audio_fifo, buf);
45diff -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
48@@ -1,5 +1,5 @@
49 /*
50- * Copyright (C) 2001-2022 the xine project
51+ * Copyright (C) 2001-2023 the xine project
52 *
53 * This file is part of xine, a free video player.
54 *
55@@ -303,7 +303,11 @@
56
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;
61+#else
62+ this->context->ch_layout.nb_channels = this->ff_channels;
63+#endif
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);
67@@ -527,16 +531,75 @@
68 this->ao_mode = 0;
69 }
70
71+static unsigned int ff_list_channels (uint8_t *list, uint64_t map) {
72+ unsigned int n, bit;
73+
74+ for (n = bit = 0; map; map >>= 1, bit++) {
75+ uint32_t b = map & 1;
76+
77+ list[n] = bit;
78+ n += b;
79+ }
80+ return n;
81+}
82+
83 static void ff_map_channels (ff_audio_decoder_t *this) {
84 uint64_t ff_map;
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);
89
90+#if XFF_AUDIO_CHANNEL_LAYOUT < 2
91+
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 */
97+# endif
98+ ff_map = ((uint64_t)1 << this->context->channels) - 1;
99+ ff_num = ff_list_channels (ff_list, ff_map);
100+
101+#else /* XFF_AUDIO_CHANNEL_LAYOUT == 2 */
102+
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;
108+ unsigned int i;
109+
110+ case AV_CHANNEL_ORDER_UNSPEC:
111+ type = "unknown";
112+ goto _fallback;
113+
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);
119+ break;
120+
121+ case AV_CHANNEL_ORDER_CUSTOM:
122+ type = "custom";
123+ if (!(cmap = this->context->ch_layout.u.map))
124+ goto _fallback;
125+ ff_map = 0;
126+ for (i = 0; i < ff_num; i++) {
127+ ff_list[i] = cmap[i].id;
128+ ff_map |= (uint64_t)1 << ff_list[i];
129+ }
130+ break;
131+
132+ default:
133+ type = "unsupported";
134+ /* fall through */
135+ _fallback:
136+ ff_map = ((uint64_t)1 << ff_num) - 1;
137+ ff_num = ff_list_channels (ff_list, ff_map);
138+ }
139+
140 #endif
141- ff_map = ((uint64_t)1 << this->context->channels) - 1;
142
143 if ((caps != this->ao_caps) || (ff_map != this->ff_map)) {
144 unsigned int i, j;
145@@ -562,7 +625,7 @@
146
147 this->ao_caps = caps;
148 this->ff_map = ff_map;
149- this->ff_channels = this->context->channels;
150+ this->ff_channels = ff_num;
151
152 /* silence out */
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. */
160 name_map[0] = 0;
161 name_map[1] = 1;
162 this->left[0] = 0;
163 this->right[0] = 1;
164 tries = wishlist + 1 * num_modes;
165 } else {
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 */
172- j++;
173- }
174+ for (i = 0; i < ff_num; i++) {
175+ int8_t target;
176+ uint32_t num = ff_list[i];
177+ if (num >= sizeof (base_map) / sizeof (base_map[0]))
178+ continue;
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 */
183 }
184 this->left[0] = this->map[0] < 0 ? 0 : this->map[0];
185 this->map[0] = -1;
186@@ -641,8 +707,8 @@
187 "rear center",
188 "side left", "side right"
189 };
190- int8_t buf[200];
191- int p = sprintf (buf, "ff_audio_dec: channel layout: ");
192+ int8_t buf[256];
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++) {
196 buf[p++] = '[';
This page took 0.051154 seconds and 4 git commands to generate.