@@ -124,85 +124,28 @@ static int sane_layout(AVChannelLayout *ch_layout) {
124
124
return 1 ;
125
125
}
126
126
127
- av_cold int swr_build_matrix2 (const AVChannelLayout * in_layout , const AVChannelLayout * out_layout ,
128
- double center_mix_level , double surround_mix_level ,
129
- double lfe_mix_level , double maxval ,
130
- double rematrix_volume , double * matrix_param ,
131
- ptrdiff_t stride , enum AVMatrixEncoding matrix_encoding , void * log_context )
127
+ static void build_matrix (const AVChannelLayout * in_ch_layout , const AVChannelLayout * out_ch_layout ,
128
+ double center_mix_level , double surround_mix_level ,
129
+ double lfe_mix_level , double maxval , double rematrix_volume , double * matrix_param ,
130
+ ptrdiff_t stride , enum AVMatrixEncoding matrix_encoding )
132
131
{
133
- int i , j , out_i , ret ;
134
- AVChannelLayout in_ch_layout = { 0 }, out_ch_layout = { 0 };
135
132
double matrix [NUM_NAMED_CHANNELS ][NUM_NAMED_CHANNELS ]= {{0 }};
136
- int64_t unaccounted ;
133
+ uint64_t unaccounted = in_ch_layout -> u . mask & ~ out_ch_layout -> u . mask ;
137
134
double maxcoef = 0 ;
138
- char buf [128 ];
139
-
140
- ret = clean_layout (& in_ch_layout , in_layout , log_context );
141
- ret |= clean_layout (& out_ch_layout , out_layout , log_context );
142
- if (ret < 0 )
143
- goto fail ;
144
-
145
- if ( !av_channel_layout_compare (& out_ch_layout , & (AVChannelLayout )AV_CHANNEL_LAYOUT_STEREO_DOWNMIX )
146
- && !av_channel_layout_subset (& in_ch_layout , AV_CH_LAYOUT_STEREO_DOWNMIX )
147
- ) {
148
- av_channel_layout_uninit (& out_ch_layout );
149
- out_ch_layout = (AVChannelLayout )AV_CHANNEL_LAYOUT_STEREO ;
150
- }
151
- if ( !av_channel_layout_compare (& in_ch_layout , & (AVChannelLayout )AV_CHANNEL_LAYOUT_STEREO_DOWNMIX )
152
- && !av_channel_layout_subset (& out_ch_layout , AV_CH_LAYOUT_STEREO_DOWNMIX )
153
- ) {
154
- av_channel_layout_uninit (& in_ch_layout );
155
- in_ch_layout = (AVChannelLayout )AV_CHANNEL_LAYOUT_STEREO ;
156
- }
157
- if (!av_channel_layout_compare (& in_ch_layout , & (AVChannelLayout )AV_CHANNEL_LAYOUT_22POINT2 ) &&
158
- av_channel_layout_compare (& out_ch_layout , & (AVChannelLayout )AV_CHANNEL_LAYOUT_22POINT2 )) {
159
- av_channel_layout_from_mask (& in_ch_layout , (AV_CH_LAYOUT_7POINT1_WIDE_BACK |AV_CH_BACK_CENTER ));
160
- av_channel_layout_describe (& in_ch_layout , buf , sizeof (buf ));
161
- av_log (log_context , AV_LOG_WARNING ,
162
- "Full-on remixing from 22.2 has not yet been implemented! "
163
- "Processing the input as '%s'\n" ,
164
- buf );
165
- }
166
-
167
- if (!av_channel_layout_check (& in_ch_layout )) {
168
- av_log (log_context , AV_LOG_ERROR , "Input channel layout is invalid\n" );
169
- ret = AVERROR (EINVAL );
170
- goto fail ;
171
- }
172
- if (!sane_layout (& in_ch_layout )) {
173
- av_channel_layout_describe (& in_ch_layout , buf , sizeof (buf ));
174
- av_log (log_context , AV_LOG_ERROR , "Input channel layout '%s' is not supported\n" , buf );
175
- ret = AVERROR (EINVAL );
176
- goto fail ;
177
- }
178
-
179
- if (!av_channel_layout_check (& out_ch_layout )) {
180
- av_log (log_context , AV_LOG_ERROR , "Output channel layout is invalid\n" );
181
- ret = AVERROR (EINVAL );
182
- goto fail ;
183
- }
184
- if (!sane_layout (& out_ch_layout )) {
185
- av_channel_layout_describe (& out_ch_layout , buf , sizeof (buf ));
186
- av_log (log_context , AV_LOG_ERROR , "Output channel layout '%s' is not supported\n" , buf );
187
- ret = AVERROR (EINVAL );
188
- goto fail ;
189
- }
135
+ int i , j , out_i ;
190
136
191
137
for (i = 0 ; i < FF_ARRAY_ELEMS (matrix ); i ++ ){
192
- if ( av_channel_layout_index_from_channel (& in_ch_layout , i ) >= 0
193
- && av_channel_layout_index_from_channel (& out_ch_layout , i ) >= 0 )
138
+ if ( av_channel_layout_index_from_channel (in_ch_layout , i ) >= 0
139
+ && av_channel_layout_index_from_channel (out_ch_layout , i ) >= 0 )
194
140
matrix [i ][i ]= 1.0 ;
195
141
}
196
142
197
- unaccounted = in_ch_layout .u .mask & ~out_ch_layout .u .mask ;
198
-
199
143
//FIXME implement dolby surround
200
144
//FIXME implement full ac3
201
145
202
-
203
146
if (unaccounted & AV_CH_FRONT_CENTER ){
204
- if (av_channel_layout_subset (& out_ch_layout , AV_CH_LAYOUT_STEREO ) == AV_CH_LAYOUT_STEREO ) {
205
- if (av_channel_layout_subset (& in_ch_layout , AV_CH_LAYOUT_STEREO )) {
147
+ if (av_channel_layout_subset (out_ch_layout , AV_CH_LAYOUT_STEREO ) == AV_CH_LAYOUT_STEREO ) {
148
+ if (av_channel_layout_subset (in_ch_layout , AV_CH_LAYOUT_STEREO )) {
206
149
matrix [ FRONT_LEFT ][FRONT_CENTER ]+= center_mix_level ;
207
150
matrix [FRONT_RIGHT ][FRONT_CENTER ]+= center_mix_level ;
208
151
} else {
@@ -213,23 +156,23 @@ av_cold int swr_build_matrix2(const AVChannelLayout *in_layout, const AVChannelL
213
156
av_assert0 (0 );
214
157
}
215
158
if (unaccounted & AV_CH_LAYOUT_STEREO ){
216
- if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_FRONT_CENTER ) >= 0 ) {
159
+ if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_FRONT_CENTER ) >= 0 ) {
217
160
matrix [FRONT_CENTER ][ FRONT_LEFT ]+= M_SQRT1_2 ;
218
161
matrix [FRONT_CENTER ][FRONT_RIGHT ]+= M_SQRT1_2 ;
219
- if (av_channel_layout_index_from_channel (& in_ch_layout , AV_CHAN_FRONT_CENTER ) >= 0 )
162
+ if (av_channel_layout_index_from_channel (in_ch_layout , AV_CHAN_FRONT_CENTER ) >= 0 )
220
163
matrix [FRONT_CENTER ][ FRONT_CENTER ] = center_mix_level * sqrt (2 );
221
164
}else
222
165
av_assert0 (0 );
223
166
}
224
167
225
168
if (unaccounted & AV_CH_BACK_CENTER ){
226
- if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_BACK_LEFT ) >= 0 ) {
169
+ if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_BACK_LEFT ) >= 0 ) {
227
170
matrix [ BACK_LEFT ][BACK_CENTER ]+= M_SQRT1_2 ;
228
171
matrix [BACK_RIGHT ][BACK_CENTER ]+= M_SQRT1_2 ;
229
- } else if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_SIDE_LEFT ) >= 0 ) {
172
+ } else if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_SIDE_LEFT ) >= 0 ) {
230
173
matrix [ SIDE_LEFT ][BACK_CENTER ]+= M_SQRT1_2 ;
231
174
matrix [SIDE_RIGHT ][BACK_CENTER ]+= M_SQRT1_2 ;
232
- } else if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_FRONT_LEFT ) >= 0 ) {
175
+ } else if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_FRONT_LEFT ) >= 0 ) {
233
176
if (matrix_encoding == AV_MATRIX_ENCODING_DOLBY ||
234
177
matrix_encoding == AV_MATRIX_ENCODING_DPLII ) {
235
178
if (unaccounted & (AV_CH_BACK_LEFT | AV_CH_SIDE_LEFT )) {
@@ -243,24 +186,24 @@ av_cold int swr_build_matrix2(const AVChannelLayout *in_layout, const AVChannelL
243
186
matrix [ FRONT_LEFT ][BACK_CENTER ]+= surround_mix_level * M_SQRT1_2 ;
244
187
matrix [FRONT_RIGHT ][BACK_CENTER ]+= surround_mix_level * M_SQRT1_2 ;
245
188
}
246
- } else if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_FRONT_CENTER ) >= 0 ) {
189
+ } else if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_FRONT_CENTER ) >= 0 ) {
247
190
matrix [ FRONT_CENTER ][BACK_CENTER ]+= surround_mix_level * M_SQRT1_2 ;
248
191
}else
249
192
av_assert0 (0 );
250
193
}
251
194
if (unaccounted & AV_CH_BACK_LEFT ){
252
- if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_BACK_CENTER ) >= 0 ) {
195
+ if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_BACK_CENTER ) >= 0 ) {
253
196
matrix [BACK_CENTER ][ BACK_LEFT ]+= M_SQRT1_2 ;
254
197
matrix [BACK_CENTER ][BACK_RIGHT ]+= M_SQRT1_2 ;
255
- } else if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_SIDE_LEFT ) >= 0 ) {
256
- if (av_channel_layout_index_from_channel (& in_ch_layout , AV_CHAN_SIDE_LEFT ) >= 0 ) {
198
+ } else if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_SIDE_LEFT ) >= 0 ) {
199
+ if (av_channel_layout_index_from_channel (in_ch_layout , AV_CHAN_SIDE_LEFT ) >= 0 ) {
257
200
matrix [ SIDE_LEFT ][ BACK_LEFT ]+= M_SQRT1_2 ;
258
201
matrix [SIDE_RIGHT ][BACK_RIGHT ]+= M_SQRT1_2 ;
259
202
}else {
260
203
matrix [ SIDE_LEFT ][ BACK_LEFT ]+= 1.0 ;
261
204
matrix [SIDE_RIGHT ][BACK_RIGHT ]+= 1.0 ;
262
205
}
263
- } else if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_FRONT_LEFT ) >= 0 ) {
206
+ } else if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_FRONT_LEFT ) >= 0 ) {
264
207
if (matrix_encoding == AV_MATRIX_ENCODING_DOLBY ) {
265
208
matrix [FRONT_LEFT ][BACK_LEFT ] -= surround_mix_level * M_SQRT1_2 ;
266
209
matrix [FRONT_LEFT ][BACK_RIGHT ] -= surround_mix_level * M_SQRT1_2 ;
@@ -275,28 +218,28 @@ av_cold int swr_build_matrix2(const AVChannelLayout *in_layout, const AVChannelL
275
218
matrix [ FRONT_LEFT ][ BACK_LEFT ] += surround_mix_level ;
276
219
matrix [FRONT_RIGHT ][BACK_RIGHT ] += surround_mix_level ;
277
220
}
278
- } else if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_FRONT_CENTER ) >= 0 ) {
221
+ } else if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_FRONT_CENTER ) >= 0 ) {
279
222
matrix [ FRONT_CENTER ][BACK_LEFT ]+= surround_mix_level * M_SQRT1_2 ;
280
223
matrix [ FRONT_CENTER ][BACK_RIGHT ]+= surround_mix_level * M_SQRT1_2 ;
281
224
}else
282
225
av_assert0 (0 );
283
226
}
284
227
285
228
if (unaccounted & AV_CH_SIDE_LEFT ){
286
- if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_BACK_LEFT ) >= 0 ) {
229
+ if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_BACK_LEFT ) >= 0 ) {
287
230
/* if back channels do not exist in the input, just copy side
288
231
channels to back channels, otherwise mix side into back */
289
- if (av_channel_layout_index_from_channel (& in_ch_layout , AV_CHAN_BACK_LEFT ) >= 0 ) {
232
+ if (av_channel_layout_index_from_channel (in_ch_layout , AV_CHAN_BACK_LEFT ) >= 0 ) {
290
233
matrix [BACK_LEFT ][SIDE_LEFT ] += M_SQRT1_2 ;
291
234
matrix [BACK_RIGHT ][SIDE_RIGHT ] += M_SQRT1_2 ;
292
235
} else {
293
236
matrix [BACK_LEFT ][SIDE_LEFT ] += 1.0 ;
294
237
matrix [BACK_RIGHT ][SIDE_RIGHT ] += 1.0 ;
295
238
}
296
- } else if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_BACK_CENTER ) >= 0 ) {
239
+ } else if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_BACK_CENTER ) >= 0 ) {
297
240
matrix [BACK_CENTER ][ SIDE_LEFT ]+= M_SQRT1_2 ;
298
241
matrix [BACK_CENTER ][SIDE_RIGHT ]+= M_SQRT1_2 ;
299
- } else if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_FRONT_LEFT ) >= 0 ) {
242
+ } else if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_FRONT_LEFT ) >= 0 ) {
300
243
if (matrix_encoding == AV_MATRIX_ENCODING_DOLBY ) {
301
244
matrix [FRONT_LEFT ][SIDE_LEFT ] -= surround_mix_level * M_SQRT1_2 ;
302
245
matrix [FRONT_LEFT ][SIDE_RIGHT ] -= surround_mix_level * M_SQRT1_2 ;
@@ -311,39 +254,39 @@ av_cold int swr_build_matrix2(const AVChannelLayout *in_layout, const AVChannelL
311
254
matrix [ FRONT_LEFT ][ SIDE_LEFT ] += surround_mix_level ;
312
255
matrix [FRONT_RIGHT ][SIDE_RIGHT ] += surround_mix_level ;
313
256
}
314
- } else if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_FRONT_CENTER ) >= 0 ) {
257
+ } else if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_FRONT_CENTER ) >= 0 ) {
315
258
matrix [ FRONT_CENTER ][SIDE_LEFT ]+= surround_mix_level * M_SQRT1_2 ;
316
259
matrix [ FRONT_CENTER ][SIDE_RIGHT ]+= surround_mix_level * M_SQRT1_2 ;
317
260
}else
318
261
av_assert0 (0 );
319
262
}
320
263
321
264
if (unaccounted & AV_CH_FRONT_LEFT_OF_CENTER ){
322
- if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_FRONT_LEFT ) >= 0 ) {
265
+ if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_FRONT_LEFT ) >= 0 ) {
323
266
matrix [ FRONT_LEFT ][ FRONT_LEFT_OF_CENTER ]+= 1.0 ;
324
267
matrix [FRONT_RIGHT ][FRONT_RIGHT_OF_CENTER ]+= 1.0 ;
325
- } else if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_FRONT_CENTER ) >= 0 ) {
268
+ } else if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_FRONT_CENTER ) >= 0 ) {
326
269
matrix [ FRONT_CENTER ][ FRONT_LEFT_OF_CENTER ]+= M_SQRT1_2 ;
327
270
matrix [ FRONT_CENTER ][FRONT_RIGHT_OF_CENTER ]+= M_SQRT1_2 ;
328
271
}else
329
272
av_assert0 (0 );
330
273
}
331
274
332
275
if (unaccounted & AV_CH_TOP_FRONT_LEFT ) {
333
- if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_TOP_FRONT_CENTER ) >= 0 ) {
276
+ if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_TOP_FRONT_CENTER ) >= 0 ) {
334
277
matrix [TOP_FRONT_CENTER ][TOP_FRONT_LEFT ] += M_SQRT1_2 ;
335
278
matrix [TOP_FRONT_CENTER ][TOP_FRONT_RIGHT ] += M_SQRT1_2 ;
336
- if (av_channel_layout_index_from_channel (& in_ch_layout , AV_CHAN_TOP_FRONT_CENTER ) >= 0 )
279
+ if (av_channel_layout_index_from_channel (in_ch_layout , AV_CHAN_TOP_FRONT_CENTER ) >= 0 )
337
280
matrix [TOP_FRONT_CENTER ][TOP_FRONT_CENTER ] = center_mix_level * sqrt (2 );
338
- } else if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_FRONT_LEFT ) >= 0 ) {
339
- if (av_channel_layout_index_from_channel (& in_ch_layout , AV_CHAN_FRONT_LEFT ) >= 0 ) {
281
+ } else if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_FRONT_LEFT ) >= 0 ) {
282
+ if (av_channel_layout_index_from_channel (in_ch_layout , AV_CHAN_FRONT_LEFT ) >= 0 ) {
340
283
matrix [FRONT_LEFT ][TOP_FRONT_LEFT ] += M_SQRT1_2 ;
341
284
matrix [FRONT_RIGHT ][TOP_FRONT_RIGHT ] += M_SQRT1_2 ;
342
285
} else {
343
286
matrix [FRONT_LEFT ][TOP_FRONT_LEFT ] += 1.0 ;
344
287
matrix [FRONT_RIGHT ][TOP_FRONT_RIGHT ] += 1.0 ;
345
288
}
346
- } else if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_FRONT_CENTER ) >= 0 ) {
289
+ } else if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_FRONT_CENTER ) >= 0 ) {
347
290
matrix [FRONT_CENTER ][TOP_FRONT_LEFT ] += M_SQRT1_2 ;
348
291
matrix [FRONT_CENTER ][TOP_FRONT_RIGHT ] += M_SQRT1_2 ;
349
292
} else
@@ -352,29 +295,30 @@ av_cold int swr_build_matrix2(const AVChannelLayout *in_layout, const AVChannelL
352
295
353
296
/* mix LFE into front left/right or center */
354
297
if (unaccounted & AV_CH_LOW_FREQUENCY ) {
355
- if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_FRONT_CENTER ) >= 0 ) {
298
+ if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_FRONT_CENTER ) >= 0 ) {
356
299
matrix [FRONT_CENTER ][LOW_FREQUENCY ] += lfe_mix_level ;
357
- } else if (av_channel_layout_index_from_channel (& out_ch_layout , AV_CHAN_FRONT_LEFT ) >= 0 ) {
300
+ } else if (av_channel_layout_index_from_channel (out_ch_layout , AV_CHAN_FRONT_LEFT ) >= 0 ) {
358
301
matrix [FRONT_LEFT ][LOW_FREQUENCY ] += lfe_mix_level * M_SQRT1_2 ;
359
302
matrix [FRONT_RIGHT ][LOW_FREQUENCY ] += lfe_mix_level * M_SQRT1_2 ;
360
303
} else
361
304
av_assert0 (0 );
362
305
}
363
306
307
+
364
308
for (out_i = i = 0 ; i < 64 ; i ++ ){
365
309
double sum = 0 ;
366
310
int in_i = 0 ;
367
- if (av_channel_layout_index_from_channel (& out_ch_layout , i ) < 0 )
311
+ if (av_channel_layout_index_from_channel (out_ch_layout , i ) < 0 )
368
312
continue ;
369
313
for (j = 0 ; j < 64 ; j ++ ){
370
- if (av_channel_layout_index_from_channel (& in_ch_layout , j ) < 0 )
314
+ if (av_channel_layout_index_from_channel (in_ch_layout , j ) < 0 )
371
315
continue ;
372
316
if (i < FF_ARRAY_ELEMS (matrix ) && j < FF_ARRAY_ELEMS (matrix [0 ]))
373
317
matrix_param [stride * out_i + in_i ] = matrix [i ][j ];
374
318
else
375
319
matrix_param [stride * out_i + in_i ] = i == j &&
376
- ( av_channel_layout_index_from_channel (& in_ch_layout , i ) >= 0
377
- && av_channel_layout_index_from_channel (& out_ch_layout , i ) >= 0 );
320
+ ( av_channel_layout_index_from_channel (in_ch_layout , i ) >= 0
321
+ && av_channel_layout_index_from_channel (out_ch_layout , i ) >= 0 );
378
322
sum += fabs (matrix_param [stride * out_i + in_i ]);
379
323
in_i ++ ;
380
324
}
@@ -391,6 +335,72 @@ av_cold int swr_build_matrix2(const AVChannelLayout *in_layout, const AVChannelL
391
335
matrix_param [stride * i + j ] /= maxcoef ;
392
336
}
393
337
}
338
+ }
339
+
340
+ av_cold int swr_build_matrix2 (const AVChannelLayout * in_layout , const AVChannelLayout * out_layout ,
341
+ double center_mix_level , double surround_mix_level ,
342
+ double lfe_mix_level , double maxval ,
343
+ double rematrix_volume , double * matrix_param ,
344
+ ptrdiff_t stride , enum AVMatrixEncoding matrix_encoding , void * log_context )
345
+ {
346
+ int i , j , ret ;
347
+ AVChannelLayout in_ch_layout = { 0 }, out_ch_layout = { 0 };
348
+ char buf [128 ];
349
+
350
+ ret = clean_layout (& in_ch_layout , in_layout , log_context );
351
+ ret |= clean_layout (& out_ch_layout , out_layout , log_context );
352
+ if (ret < 0 )
353
+ goto fail ;
354
+
355
+ if ( !av_channel_layout_compare (& out_ch_layout , & (AVChannelLayout )AV_CHANNEL_LAYOUT_STEREO_DOWNMIX )
356
+ && !av_channel_layout_subset (& in_ch_layout , AV_CH_LAYOUT_STEREO_DOWNMIX )
357
+ ) {
358
+ av_channel_layout_uninit (& out_ch_layout );
359
+ out_ch_layout = (AVChannelLayout )AV_CHANNEL_LAYOUT_STEREO ;
360
+ }
361
+ if ( !av_channel_layout_compare (& in_ch_layout , & (AVChannelLayout )AV_CHANNEL_LAYOUT_STEREO_DOWNMIX )
362
+ && !av_channel_layout_subset (& out_ch_layout , AV_CH_LAYOUT_STEREO_DOWNMIX )
363
+ ) {
364
+ av_channel_layout_uninit (& in_ch_layout );
365
+ in_ch_layout = (AVChannelLayout )AV_CHANNEL_LAYOUT_STEREO ;
366
+ }
367
+ if (!av_channel_layout_compare (& in_ch_layout , & (AVChannelLayout )AV_CHANNEL_LAYOUT_22POINT2 ) &&
368
+ av_channel_layout_compare (& out_ch_layout , & (AVChannelLayout )AV_CHANNEL_LAYOUT_22POINT2 )) {
369
+ av_channel_layout_from_mask (& in_ch_layout , (AV_CH_LAYOUT_7POINT1_WIDE_BACK |AV_CH_BACK_CENTER ));
370
+ av_channel_layout_describe (& in_ch_layout , buf , sizeof (buf ));
371
+ av_log (log_context , AV_LOG_WARNING ,
372
+ "Full-on remixing from 22.2 has not yet been implemented! "
373
+ "Processing the input as '%s'\n" ,
374
+ buf );
375
+ }
376
+
377
+ if (!av_channel_layout_check (& in_ch_layout )) {
378
+ av_log (log_context , AV_LOG_ERROR , "Input channel layout is invalid\n" );
379
+ ret = AVERROR (EINVAL );
380
+ goto fail ;
381
+ }
382
+ if (!sane_layout (& in_ch_layout )) {
383
+ av_channel_layout_describe (& in_ch_layout , buf , sizeof (buf ));
384
+ av_log (log_context , AV_LOG_ERROR , "Input channel layout '%s' is not supported\n" , buf );
385
+ ret = AVERROR (EINVAL );
386
+ goto fail ;
387
+ }
388
+
389
+ if (!av_channel_layout_check (& out_ch_layout )) {
390
+ av_log (log_context , AV_LOG_ERROR , "Output channel layout is invalid\n" );
391
+ ret = AVERROR (EINVAL );
392
+ goto fail ;
393
+ }
394
+ if (!sane_layout (& out_ch_layout )) {
395
+ av_channel_layout_describe (& out_ch_layout , buf , sizeof (buf ));
396
+ av_log (log_context , AV_LOG_ERROR , "Output channel layout '%s' is not supported\n" , buf );
397
+ ret = AVERROR (EINVAL );
398
+ goto fail ;
399
+ }
400
+
401
+ build_matrix (& in_ch_layout , & out_ch_layout , center_mix_level ,
402
+ surround_mix_level , lfe_mix_level , maxval , rematrix_volume ,
403
+ matrix_param , stride , matrix_encoding );
394
404
395
405
if (rematrix_volume > 0 ){
396
406
for (i = 0 ; i < SWR_CH_MAX ; i ++ )
0 commit comments