-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vlc-3.0.20-ffmpeg7.patch
360 lines (330 loc) · 16.9 KB
/
vlc-3.0.20-ffmpeg7.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
--- vlc-3.0.20/modules/codec/avcodec/audio.c.orig 2024-04-11 22:04:48.840481336 +0100
+++ vlc-3.0.20/modules/codec/avcodec/audio.c 2024-04-11 22:56:54.658799280 +0100
@@ -65,7 +65,7 @@
bool b_extract;
int pi_extraction[AOUT_CHAN_MAX];
int i_previous_channels;
- uint64_t i_previous_layout;
+ AVChannelLayout i_previous_layout;
};
#define BLOCK_FLAG_PRIVATE_REALLOCATED (1 << BLOCK_FLAG_PRIVATE_SHIFT)
@@ -139,7 +139,7 @@
}
ctx->sample_rate = p_dec->fmt_in.audio.i_rate;
- ctx->channels = p_dec->fmt_in.audio.i_channels;
+ ctx->ch_layout.nb_channels = p_dec->fmt_in.audio.i_channels;
ctx->block_align = p_dec->fmt_in.audio.i_blockalign;
ctx->bit_rate = p_dec->fmt_in.i_bitrate;
ctx->bits_per_coded_sample = p_dec->fmt_in.audio.i_bitspersample;
@@ -245,7 +245,7 @@
p_sys->i_reject_count = 0;
p_sys->b_extract = false;
p_sys->i_previous_channels = 0;
- p_sys->i_previous_layout = 0;
+ p_sys->i_previous_layout = (AVChannelLayout){0};
/* */
/* Try to set as much information as possible but do not trust it */
@@ -396,11 +396,11 @@
if( ret == 0 )
{
/* checks and init from first decoded frame */
- if( ctx->channels <= 0 || ctx->channels > INPUT_CHAN_MAX
+ if( ctx->ch_layout.nb_channels <= 0 || ctx->ch_layout.nb_channels > INPUT_CHAN_MAX
|| ctx->sample_rate <= 0 )
{
msg_Warn( p_dec, "invalid audio properties channels count %d, sample rate %d",
- ctx->channels, ctx->sample_rate );
+ ctx->ch_layout.nb_channels, ctx->sample_rate );
goto drop;
}
else if( p_dec->fmt_out.audio.i_rate != (unsigned int)ctx->sample_rate )
@@ -484,15 +484,15 @@
/* Interleave audio if required */
if( av_sample_fmt_is_planar( ctx->sample_fmt ) )
{
- p_block = block_Alloc(frame->linesize[0] * ctx->channels);
+ p_block = block_Alloc(frame->linesize[0] * ctx->ch_layout.nb_channels);
if ( likely(p_block) )
{
- const void *planes[ctx->channels];
- for (int i = 0; i < ctx->channels; i++)
+ const void *planes[ctx->ch_layout.nb_channels];
+ for (int i = 0; i < ctx->ch_layout.nb_channels; i++)
planes[i] = frame->extended_data[i];
aout_Interleave(p_block->p_buffer, planes, frame->nb_samples,
- ctx->channels, p_dec->fmt_out.audio.i_format);
+ ctx->ch_layout.nb_channels, p_dec->fmt_out.audio.i_format);
p_block->i_nb_samples = frame->nb_samples;
}
av_frame_free(&frame);
@@ -511,7 +511,7 @@
{
aout_ChannelExtract( p_buffer->p_buffer,
p_dec->fmt_out.audio.i_channels,
- p_block->p_buffer, ctx->channels,
+ p_block->p_buffer, ctx->ch_layout.nb_channels,
p_block->i_nb_samples, p_sys->pi_extraction,
p_dec->fmt_out.audio.i_bitspersample );
p_buffer->i_nb_samples = p_block->i_nb_samples;
@@ -580,33 +580,36 @@
p_dec->fmt_out.audio.i_rate = p_sys->p_context->sample_rate;
/* */
- if( p_sys->i_previous_channels == p_sys->p_context->channels &&
- p_sys->i_previous_layout == p_sys->p_context->channel_layout )
+ if( p_sys->i_previous_channels == p_sys->p_context->ch_layout.nb_channels &&
+ av_channel_layout_compare(&p_sys->i_previous_layout,&p_sys->p_context->ch_layout) == 0 )
return;
if( b_trust )
{
- p_sys->i_previous_channels = p_sys->p_context->channels;
- p_sys->i_previous_layout = p_sys->p_context->channel_layout;
+ p_sys->i_previous_channels = p_sys->p_context->ch_layout.nb_channels;
+ av_channel_layout_copy(&p_sys->i_previous_layout, &p_sys->p_context->ch_layout);
}
const unsigned i_order_max = sizeof(pi_channels_map)/sizeof(*pi_channels_map);
uint32_t pi_order_src[i_order_max];
int i_channels_src = 0;
- int64_t channel_layout =
- p_sys->p_context->channel_layout ? p_sys->p_context->channel_layout :
- av_get_default_channel_layout( p_sys->p_context->channels );
+ AVChannelLayout channel_layout;
+ if(p_sys->p_context->ch_layout.u.mask) {
+ av_channel_layout_copy(&channel_layout, &p_sys->p_context->ch_layout);
+ } else {
+ av_channel_layout_default(&channel_layout, p_sys->p_context->ch_layout.nb_channels );
+ }
- if( channel_layout )
+ if(av_channel_layout_check(&channel_layout))
{
for( unsigned i = 0; i < i_order_max
- && i_channels_src < p_sys->p_context->channels; i++ )
+ && i_channels_src < p_sys->p_context->ch_layout.nb_channels; i++ )
{
- if( channel_layout & pi_channels_map[i][0] )
+ if( channel_layout.u.mask & pi_channels_map[i][0] )
pi_order_src[i_channels_src++] = pi_channels_map[i][1];
}
- if( i_channels_src != p_sys->p_context->channels && b_trust )
+ if( i_channels_src != p_sys->p_context->ch_layout.nb_channels && b_trust )
msg_Err( p_dec, "Channel layout not understood" );
/* Detect special dual mono case */
@@ -638,7 +641,7 @@
{
msg_Warn( p_dec, "no channel layout found");
p_dec->fmt_out.audio.i_physical_channels = 0;
- p_dec->fmt_out.audio.i_channels = p_sys->p_context->channels;
+ p_dec->fmt_out.audio.i_channels = p_sys->p_context->ch_layout.nb_channels;
}
aout_FormatPrepare( &p_dec->fmt_out.audio );
--- vlc-3.0.20/modules/codec/avcodec/fourcc.c.orig 2024-04-11 23:18:24.472481862 +0100
+++ vlc-3.0.20/modules/codec/avcodec/fourcc.c 2024-04-11 23:17:13.105163354 +0100
@@ -182,7 +182,7 @@
/* AV_CODEC_ID_V210X */
{ VLC_CODEC_TMV, AV_CODEC_ID_TMV },
{ VLC_CODEC_V210, AV_CODEC_ID_V210 },
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 54, 50, 100 ) && LIBAVCODEC_VERSION_MICRO >= 100
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 54, 50, 100 ) && LIBAVCODEC_VERSION_MICRO >= 100 && LIBAVCODEC_VERSION_MAJOR < 61
{ VLC_CODEC_VUYA, AV_CODEC_ID_AYUV },
#endif
/* AV_CODEC_ID_DPX */
--- vlc-3.0.20/modules/codec/avcodec/encoder.c.orig 2024-04-11 23:16:32.476696552 +0100
+++ vlc-3.0.20/modules/codec/avcodec/encoder.c 2024-04-12 00:05:54.128425226 +0100
@@ -739,9 +739,10 @@
date_Set( &p_sys->buffer_date, AV_NOPTS_VALUE );
p_context->time_base.num = 1;
p_context->time_base.den = p_context->sample_rate;
- p_context->channels = p_enc->fmt_out.audio.i_channels;
+ p_context->ch_layout.order = AV_CHANNEL_ORDER_NATIVE;
+ p_context->ch_layout.nb_channels = p_enc->fmt_out.audio.i_channels;
#if LIBAVUTIL_VERSION_CHECK( 52, 2, 6, 0, 0)
- p_context->channel_layout = channel_mask[p_context->channels][1];
+ p_context->ch_layout.u.mask = channel_mask[p_context->ch_layout.nb_channels][1];
/* Setup Channel ordering for multichannel audio
* as VLC channel order isn't same as libavcodec expects
@@ -752,17 +753,17 @@
/* Specified order
* Copied from audio.c
*/
- const unsigned i_order_max = 8 * sizeof(p_context->channel_layout);
+ const unsigned i_order_max = 8 * sizeof(p_context->ch_layout.u.mask);
uint32_t pi_order_dst[AOUT_CHAN_MAX] = { };
uint32_t order_mask = 0;
int i_channels_src = 0;
- if( p_context->channel_layout )
+ if( p_context->ch_layout.u.mask )
{
msg_Dbg( p_enc, "Creating channel order for reordering");
for( unsigned i = 0; i < sizeof(pi_channels_map)/sizeof(*pi_channels_map); i++ )
{
- if( p_context->channel_layout & pi_channels_map[i][0] )
+ if( p_context->ch_layout.u.mask & pi_channels_map[i][0] )
{
msg_Dbg( p_enc, "%d %"PRIx64" mapped to %"PRIx64"", i_channels_src, pi_channels_map[i][0], pi_channels_map[i][1]);
pi_order_dst[i_channels_src++] = pi_channels_map[i][1];
@@ -774,7 +775,7 @@
{
msg_Dbg( p_enc, "Creating default channel order for reordering");
/* Create default order */
- for( unsigned int i = 0; i < __MIN( i_order_max, (unsigned)p_sys->p_context->channels ); i++ )
+ for( unsigned int i = 0; i < __MIN( i_order_max, (unsigned)p_sys->p_context->ch_layout.nb_channels ); i++ )
{
if( i < sizeof(pi_channels_map)/sizeof(*pi_channels_map) )
{
@@ -784,7 +785,7 @@
}
}
}
- if( i_channels_src != p_context->channels )
+ if( i_channels_src != p_context->ch_layout.nb_channels )
msg_Err( p_enc, "Channel layout not understood" );
p_sys->i_channels_to_reorder =
@@ -891,7 +892,7 @@
if( ret )
{
if( p_enc->fmt_in.i_cat != AUDIO_ES ||
- (p_context->channels <= 2 && i_codec_id != AV_CODEC_ID_MP2
+ (p_context->ch_layout.nb_channels <= 2 && i_codec_id != AV_CODEC_ID_MP2
&& i_codec_id != AV_CODEC_ID_MP3) )
errmsg:
{
@@ -916,10 +917,10 @@
goto error;
}
- if( p_context->channels > 2 )
+ if( p_context->ch_layout.nb_channels > 2 )
{
- p_context->channels = 2;
- p_context->channel_layout = channel_mask[p_context->channels][1];
+ p_context->ch_layout.nb_channels = 2;
+ p_context->ch_layout.u.mask = channel_mask[p_context->ch_layout.nb_channels][1];
/* Change fmt_in in order to ask for a channels conversion */
p_enc->fmt_in.audio.i_channels =
@@ -1022,7 +1023,7 @@
p_context->frame_size :
AV_INPUT_BUFFER_MIN_SIZE;
p_sys->i_buffer_out = av_samples_get_buffer_size(NULL,
- p_sys->p_context->channels, p_sys->i_frame_size,
+ p_sys->p_context->ch_layout.nb_channels, p_sys->i_frame_size,
p_sys->p_context->sample_fmt, DEFAULT_ALIGN);
p_sys->p_buffer = av_malloc( p_sys->i_buffer_out );
if ( unlikely( p_sys->p_buffer == NULL ) )
@@ -1272,13 +1273,12 @@
{
block_t *p_block = NULL;
//How much we need to copy from new packet
- const size_t leftover = leftover_samples * p_sys->p_context->channels * p_sys->i_sample_bytes;
+ const size_t leftover = leftover_samples * p_sys->p_context->ch_layout.nb_channels * p_sys->i_sample_bytes;
av_frame_unref( p_sys->frame );
p_sys->frame->format = p_sys->p_context->sample_fmt;
p_sys->frame->nb_samples = leftover_samples + p_sys->i_samples_delay;
- p_sys->frame->channel_layout = p_sys->p_context->channel_layout;
- p_sys->frame->channels = p_sys->p_context->channels;
+ av_channel_layout_copy(&p_sys->frame->ch_layout, &p_sys->p_context->ch_layout);
p_sys->frame->pts = date_Get( &p_sys->buffer_date ) * p_sys->p_context->time_base.den /
CLOCK_FREQ / p_sys->p_context->time_base.num;
@@ -1295,7 +1295,7 @@
// We need to deinterleave from p_aout_buf to p_buffer the leftover bytes
if( p_sys->b_planar )
aout_Deinterleave( p_sys->p_interleave_buf, p_sys->p_buffer,
- p_sys->i_frame_size, p_sys->p_context->channels, p_enc->fmt_in.i_codec );
+ p_sys->i_frame_size, p_sys->p_context->ch_layout.nb_channels, p_enc->fmt_in.i_codec );
else
memcpy( p_sys->p_buffer + buffer_delay, p_aout_buf->p_buffer, leftover);
@@ -1313,7 +1313,7 @@
memset( p_sys->p_buffer + (leftover+buffer_delay), 0, padding_size );
buffer_delay += padding_size;
}
- if( avcodec_fill_audio_frame( p_sys->frame, p_sys->p_context->channels,
+ if( avcodec_fill_audio_frame( p_sys->frame, p_sys->p_context->ch_layout.nb_channels,
p_sys->p_context->sample_fmt, p_sys->b_planar ? p_sys->p_interleave_buf : p_sys->p_buffer,
p_sys->i_buffer_out,
DEFAULT_ALIGN) < 0 )
@@ -1343,7 +1343,7 @@
//i_bytes_left is amount of bytes we get
i_samples_left = p_aout_buf ? p_aout_buf->i_nb_samples : 0;
- buffer_delay = p_sys->i_samples_delay * p_sys->i_sample_bytes * p_sys->p_context->channels;
+ buffer_delay = p_sys->i_samples_delay * p_sys->i_sample_bytes * p_sys->p_context->ch_layout.nb_channels;
//p_sys->i_buffer_out = p_sys->i_frame_size * chan * p_sys->i_sample_bytes
//Calculate how many bytes we would need from current buffer to fill frame
@@ -1408,16 +1408,15 @@
p_sys->frame->pts = date_Get( &p_sys->buffer_date ) * p_sys->p_context->time_base.den /
CLOCK_FREQ / p_sys->p_context->time_base.num;
- p_sys->frame->channel_layout = p_sys->p_context->channel_layout;
- p_sys->frame->channels = p_sys->p_context->channels;
+ av_channel_layout_copy(&p_sys->frame->ch_layout, &p_sys->p_context->ch_layout);
const int in_bytes = p_sys->frame->nb_samples *
- p_sys->p_context->channels * p_sys->i_sample_bytes;
+ p_sys->p_context->ch_layout.nb_channels * p_sys->i_sample_bytes;
if( p_sys->b_planar )
{
aout_Deinterleave( p_sys->p_buffer, p_aout_buf->p_buffer,
- p_sys->frame->nb_samples, p_sys->p_context->channels, p_enc->fmt_in.i_codec );
+ p_sys->frame->nb_samples, p_sys->p_context->ch_layout.nb_channels, p_enc->fmt_in.i_codec );
}
else
@@ -1425,7 +1424,7 @@
memcpy(p_sys->p_buffer, p_aout_buf->p_buffer, in_bytes);
}
- if( avcodec_fill_audio_frame( p_sys->frame, p_sys->p_context->channels,
+ if( avcodec_fill_audio_frame( p_sys->frame, p_sys->p_context->ch_layout.nb_channels,
p_sys->p_context->sample_fmt,
p_sys->p_buffer,
p_sys->i_buffer_out,
@@ -1451,7 +1450,7 @@
if( p_aout_buf->i_nb_samples > 0 )
{
memcpy( p_sys->p_buffer + buffer_delay, p_aout_buf->p_buffer,
- p_aout_buf->i_nb_samples * p_sys->i_sample_bytes * p_sys->p_context->channels);
+ p_aout_buf->i_nb_samples * p_sys->i_sample_bytes * p_sys->p_context->ch_layout.nb_channels);
p_sys->i_samples_delay += p_aout_buf->i_nb_samples;
}
--- vlc-3.0.20/modules/demux/avformat/mux.c.orig 2024-04-12 09:43:14.176674968 +0100
+++ vlc-3.0.20/modules/demux/avformat/mux.c 2024-04-12 09:46:15.032487553 +0100
@@ -74,10 +74,10 @@
static void DelStream( sout_mux_t *, sout_input_t * );
static int Mux ( sout_mux_t * );
-static int IOWrite( void *opaque, uint8_t *buf, int buf_size );
+static int IOWrite( void *opaque, const uint8_t *buf, int buf_size );
static int64_t IOSeek( void *opaque, int64_t offset, int whence );
#if LIBAVFORMAT_VERSION_CHECK( 57, 7, 0, 40, 100 )
-static int IOWriteTyped(void *opaque, uint8_t *buf, int buf_size,
+static int IOWriteTyped(void *opaque, const uint8_t *buf, int buf_size,
enum AVIODataMarkerType type, int64_t time);
#endif
@@ -267,7 +267,7 @@
{
case AUDIO_ES:
codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
- codecpar->channels = fmt->audio.i_channels;
+ codecpar->ch_layout.nb_channels = fmt->audio.i_channels;
codecpar->sample_rate = fmt->audio.i_rate;
stream->time_base = (AVRational){1, codecpar->sample_rate};
if (fmt->i_bitrate == 0) {
@@ -407,7 +407,7 @@
}
#if LIBAVFORMAT_VERSION_CHECK( 57, 7, 0, 40, 100 )
-int IOWriteTyped(void *opaque, uint8_t *buf, int buf_size,
+int IOWriteTyped(void *opaque, const uint8_t *buf, int buf_size,
enum AVIODataMarkerType type, int64_t time)
{
VLC_UNUSED(time);
@@ -508,7 +508,7 @@
/*****************************************************************************
* I/O wrappers for libavformat
*****************************************************************************/
-static int IOWrite( void *opaque, uint8_t *buf, int buf_size )
+static int IOWrite( void *opaque, const uint8_t *buf, int buf_size )
{
sout_mux_t *p_mux = opaque;
sout_mux_sys_t *p_sys = p_mux->p_sys;
--- vlc-3.0.20/modules/demux/avformat/demux.c.orig 2024-04-12 09:43:02.724067453 +0100
+++ vlc-3.0.20/modules/demux/avformat/demux.c 2024-04-12 09:46:46.224422142 +0100
@@ -401,7 +401,7 @@
es_format_Init( &es_fmt, AUDIO_ES, fcc );
es_fmt.i_original_fourcc = CodecTagToFourcc( cp->codec_tag );
es_fmt.i_bitrate = cp->bit_rate;
- es_fmt.audio.i_channels = cp->channels;
+ es_fmt.audio.i_channels = cp->ch_layout.nb_channels;
es_fmt.audio.i_rate = cp->sample_rate;
es_fmt.audio.i_bitspersample = cp->bits_per_coded_sample;
es_fmt.audio.i_blockalign = cp->block_align;