* qatar/master:
adpcmenc: cosmetics: pretty-printing
ac3dec: cosmetics: pretty-printing
yuv4mpeg: cosmetics: pretty-printing
shorten: remove dead initialization
roqvideodec: set AVFrame reference before reget_buffer.
bmp: fix some 1bit samples.
latmdec: add fate test for audio config change
oma: PCM support
oma: better format detection with small probe buffer
oma: clearify ambiguous if condition
wavpack: Properly clip samples during lossy decode
Code clean-up for crc.c, lfg.c, log.c, random_see.d, rational.c and tree.c.
Cleaned pixdesc.c file in libavutil
zmbv.c: coding style clean-up.
xan.c: coding style clean-up.
mpegvideo.c: code cleanup - first 500 lines.
Conflicts:
Changelog
libavcodec/adpcmenc.c
libavcodec/bmp.c
libavcodec/zmbv.c
libavutil/log.c
libavutil/pixdesc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
| ... | ... |
@@ -44,7 +44,6 @@ |
| 44 | 44 |
*/ |
| 45 | 45 |
static uint8_t ungroup_3_in_7_bits_tab[128][3]; |
| 46 | 46 |
|
| 47 |
- |
|
| 48 | 47 |
/** tables for ungrouping mantissas */ |
| 49 | 48 |
static int b1_mantissas[32][3]; |
| 50 | 49 |
static int b2_mantissas[128][3]; |
| ... | ... |
@@ -124,7 +123,7 @@ static av_cold void ac3_tables_init(void) |
| 124 | 124 |
|
| 125 | 125 |
/* generate table for ungrouping 3 values in 7 bits |
| 126 | 126 |
reference: Section 7.1.3 Exponent Decoding */ |
| 127 |
- for(i=0; i<128; i++) {
|
|
| 127 |
+ for (i = 0; i < 128; i++) {
|
|
| 128 | 128 |
ungroup_3_in_7_bits_tab[i][0] = i / 25; |
| 129 | 129 |
ungroup_3_in_7_bits_tab[i][1] = (i % 25) / 5; |
| 130 | 130 |
ungroup_3_in_7_bits_tab[i][2] = (i % 25) % 5; |
| ... | ... |
@@ -132,13 +131,13 @@ static av_cold void ac3_tables_init(void) |
| 132 | 132 |
|
| 133 | 133 |
/* generate grouped mantissa tables |
| 134 | 134 |
reference: Section 7.3.5 Ungrouping of Mantissas */ |
| 135 |
- for(i=0; i<32; i++) {
|
|
| 135 |
+ for (i = 0; i < 32; i++) {
|
|
| 136 | 136 |
/* bap=1 mantissas */ |
| 137 | 137 |
b1_mantissas[i][0] = symmetric_dequant(ff_ac3_ungroup_3_in_5_bits_tab[i][0], 3); |
| 138 | 138 |
b1_mantissas[i][1] = symmetric_dequant(ff_ac3_ungroup_3_in_5_bits_tab[i][1], 3); |
| 139 | 139 |
b1_mantissas[i][2] = symmetric_dequant(ff_ac3_ungroup_3_in_5_bits_tab[i][2], 3); |
| 140 | 140 |
} |
| 141 |
- for(i=0; i<128; i++) {
|
|
| 141 |
+ for (i = 0; i < 128; i++) {
|
|
| 142 | 142 |
/* bap=2 mantissas */ |
| 143 | 143 |
b2_mantissas[i][0] = symmetric_dequant(ungroup_3_in_7_bits_tab[i][0], 5); |
| 144 | 144 |
b2_mantissas[i][1] = symmetric_dequant(ungroup_3_in_7_bits_tab[i][1], 5); |
| ... | ... |
@@ -150,24 +149,23 @@ static av_cold void ac3_tables_init(void) |
| 150 | 150 |
} |
| 151 | 151 |
/* generate ungrouped mantissa tables |
| 152 | 152 |
reference: Tables 7.21 and 7.23 */ |
| 153 |
- for(i=0; i<7; i++) {
|
|
| 153 |
+ for (i = 0; i < 7; i++) {
|
|
| 154 | 154 |
/* bap=3 mantissas */ |
| 155 | 155 |
b3_mantissas[i] = symmetric_dequant(i, 7); |
| 156 | 156 |
} |
| 157 |
- for(i=0; i<15; i++) {
|
|
| 157 |
+ for (i = 0; i < 15; i++) {
|
|
| 158 | 158 |
/* bap=5 mantissas */ |
| 159 | 159 |
b5_mantissas[i] = symmetric_dequant(i, 15); |
| 160 | 160 |
} |
| 161 | 161 |
|
| 162 | 162 |
/* generate dynamic range table |
| 163 | 163 |
reference: Section 7.7.1 Dynamic Range Control */ |
| 164 |
- for(i=0; i<256; i++) {
|
|
| 164 |
+ for (i = 0; i < 256; i++) {
|
|
| 165 | 165 |
int v = (i >> 5) - ((i >> 7) << 3) - 5; |
| 166 | 166 |
dynamic_range_tab[i] = powf(2.0f, v) * ((i & 0x1F) | 0x20); |
| 167 | 167 |
} |
| 168 | 168 |
} |
| 169 | 169 |
|
| 170 |
- |
|
| 171 | 170 |
/** |
| 172 | 171 |
* AVCodec initialization |
| 173 | 172 |
*/ |
| ... | ... |
@@ -250,7 +248,7 @@ static int ac3_parse_header(AC3DecodeContext *s) |
| 250 | 250 |
i = get_bits(gbc, 6); |
| 251 | 251 |
do {
|
| 252 | 252 |
skip_bits(gbc, 8); |
| 253 |
- } while(i--); |
|
| 253 |
+ } while (i--); |
|
| 254 | 254 |
} |
| 255 | 255 |
|
| 256 | 256 |
return 0; |
| ... | ... |
@@ -265,7 +263,7 @@ static int parse_frame_header(AC3DecodeContext *s) |
| 265 | 265 |
int err; |
| 266 | 266 |
|
| 267 | 267 |
err = avpriv_ac3_parse_header(&s->gbc, &hdr); |
| 268 |
- if(err) |
|
| 268 |
+ if (err) |
|
| 269 | 269 |
return err; |
| 270 | 270 |
|
| 271 | 271 |
/* get decoding parameters from header info */ |
| ... | ... |
@@ -287,9 +285,9 @@ static int parse_frame_header(AC3DecodeContext *s) |
| 287 | 287 |
s->frame_type = hdr.frame_type; |
| 288 | 288 |
s->substreamid = hdr.substreamid; |
| 289 | 289 |
|
| 290 |
- if(s->lfe_on) {
|
|
| 291 |
- s->start_freq[s->lfe_ch] = 0; |
|
| 292 |
- s->end_freq[s->lfe_ch] = 7; |
|
| 290 |
+ if (s->lfe_on) {
|
|
| 291 |
+ s->start_freq[s->lfe_ch] = 0; |
|
| 292 |
+ s->end_freq[s->lfe_ch] = 7; |
|
| 293 | 293 |
s->num_exp_groups[s->lfe_ch] = 2; |
| 294 | 294 |
s->channel_in_cpl[s->lfe_ch] = 0; |
| 295 | 295 |
} |
| ... | ... |
@@ -326,38 +324,39 @@ static void set_downmix_coeffs(AC3DecodeContext *s) |
| 326 | 326 |
float smix = gain_levels[surround_levels[s->surround_mix_level]]; |
| 327 | 327 |
float norm0, norm1; |
| 328 | 328 |
|
| 329 |
- for(i=0; i<s->fbw_channels; i++) {
|
|
| 329 |
+ for (i = 0; i < s->fbw_channels; i++) {
|
|
| 330 | 330 |
s->downmix_coeffs[i][0] = gain_levels[ac3_default_coeffs[s->channel_mode][i][0]]; |
| 331 | 331 |
s->downmix_coeffs[i][1] = gain_levels[ac3_default_coeffs[s->channel_mode][i][1]]; |
| 332 | 332 |
} |
| 333 |
- if(s->channel_mode > 1 && s->channel_mode & 1) {
|
|
| 333 |
+ if (s->channel_mode > 1 && s->channel_mode & 1) {
|
|
| 334 | 334 |
s->downmix_coeffs[1][0] = s->downmix_coeffs[1][1] = cmix; |
| 335 | 335 |
} |
| 336 |
- if(s->channel_mode == AC3_CHMODE_2F1R || s->channel_mode == AC3_CHMODE_3F1R) {
|
|
| 336 |
+ if (s->channel_mode == AC3_CHMODE_2F1R || s->channel_mode == AC3_CHMODE_3F1R) {
|
|
| 337 | 337 |
int nf = s->channel_mode - 2; |
| 338 | 338 |
s->downmix_coeffs[nf][0] = s->downmix_coeffs[nf][1] = smix * LEVEL_MINUS_3DB; |
| 339 | 339 |
} |
| 340 |
- if(s->channel_mode == AC3_CHMODE_2F2R || s->channel_mode == AC3_CHMODE_3F2R) {
|
|
| 340 |
+ if (s->channel_mode == AC3_CHMODE_2F2R || s->channel_mode == AC3_CHMODE_3F2R) {
|
|
| 341 | 341 |
int nf = s->channel_mode - 4; |
| 342 | 342 |
s->downmix_coeffs[nf][0] = s->downmix_coeffs[nf+1][1] = smix; |
| 343 | 343 |
} |
| 344 | 344 |
|
| 345 | 345 |
/* renormalize */ |
| 346 | 346 |
norm0 = norm1 = 0.0; |
| 347 |
- for(i=0; i<s->fbw_channels; i++) {
|
|
| 347 |
+ for (i = 0; i < s->fbw_channels; i++) {
|
|
| 348 | 348 |
norm0 += s->downmix_coeffs[i][0]; |
| 349 | 349 |
norm1 += s->downmix_coeffs[i][1]; |
| 350 | 350 |
} |
| 351 | 351 |
norm0 = 1.0f / norm0; |
| 352 | 352 |
norm1 = 1.0f / norm1; |
| 353 |
- for(i=0; i<s->fbw_channels; i++) {
|
|
| 353 |
+ for (i = 0; i < s->fbw_channels; i++) {
|
|
| 354 | 354 |
s->downmix_coeffs[i][0] *= norm0; |
| 355 | 355 |
s->downmix_coeffs[i][1] *= norm1; |
| 356 | 356 |
} |
| 357 | 357 |
|
| 358 |
- if(s->output_mode == AC3_CHMODE_MONO) {
|
|
| 359 |
- for(i=0; i<s->fbw_channels; i++) |
|
| 360 |
- s->downmix_coeffs[i][0] = (s->downmix_coeffs[i][0] + s->downmix_coeffs[i][1]) * LEVEL_MINUS_3DB; |
|
| 358 |
+ if (s->output_mode == AC3_CHMODE_MONO) {
|
|
| 359 |
+ for (i = 0; i < s->fbw_channels; i++) |
|
| 360 |
+ s->downmix_coeffs[i][0] = (s->downmix_coeffs[i][0] + |
|
| 361 |
+ s->downmix_coeffs[i][1]) * LEVEL_MINUS_3DB; |
|
| 361 | 362 |
} |
| 362 | 363 |
} |
| 363 | 364 |
|
| ... | ... |
@@ -374,7 +373,7 @@ static int decode_exponents(GetBitContext *gbc, int exp_strategy, int ngrps, |
| 374 | 374 |
|
| 375 | 375 |
/* unpack groups */ |
| 376 | 376 |
group_size = exp_strategy + (exp_strategy == EXP_D45); |
| 377 |
- for(grp=0,i=0; grp<ngrps; grp++) {
|
|
| 377 |
+ for (grp = 0, i = 0; grp < ngrps; grp++) {
|
|
| 378 | 378 |
expacc = get_bits(gbc, 7); |
| 379 | 379 |
dexp[i++] = ungroup_3_in_7_bits_tab[expacc][0]; |
| 380 | 380 |
dexp[i++] = ungroup_3_in_7_bits_tab[expacc][1]; |
| ... | ... |
@@ -383,15 +382,15 @@ static int decode_exponents(GetBitContext *gbc, int exp_strategy, int ngrps, |
| 383 | 383 |
|
| 384 | 384 |
/* convert to absolute exps and expand groups */ |
| 385 | 385 |
prevexp = absexp; |
| 386 |
- for(i=0,j=0; i<ngrps*3; i++) {
|
|
| 386 |
+ for (i = 0, j = 0; i < ngrps * 3; i++) {
|
|
| 387 | 387 |
prevexp += dexp[i] - 2; |
| 388 | 388 |
if (prevexp > 24U) |
| 389 | 389 |
return -1; |
| 390 | 390 |
switch (group_size) {
|
| 391 |
- case 4: dexps[j++] = prevexp; |
|
| 392 |
- dexps[j++] = prevexp; |
|
| 393 |
- case 2: dexps[j++] = prevexp; |
|
| 394 |
- case 1: dexps[j++] = prevexp; |
|
| 391 |
+ case 4: dexps[j++] = prevexp; |
|
| 392 |
+ dexps[j++] = prevexp; |
|
| 393 |
+ case 2: dexps[j++] = prevexp; |
|
| 394 |
+ case 1: dexps[j++] = prevexp; |
|
| 395 | 395 |
} |
| 396 | 396 |
} |
| 397 | 397 |
return 0; |
| ... | ... |
@@ -414,7 +413,8 @@ static void calc_transform_coeffs_cpl(AC3DecodeContext *s) |
| 414 | 414 |
if (s->channel_in_cpl[ch]) {
|
| 415 | 415 |
int cpl_coord = s->cpl_coords[ch][band] << 5; |
| 416 | 416 |
for (bin = band_start; bin < band_end; bin++) {
|
| 417 |
- s->fixed_coeffs[ch][bin] = MULH(s->fixed_coeffs[CPL_CH][bin] << 4, cpl_coord); |
|
| 417 |
+ s->fixed_coeffs[ch][bin] = |
|
| 418 |
+ MULH(s->fixed_coeffs[CPL_CH][bin] << 4, cpl_coord); |
|
| 418 | 419 |
} |
| 419 | 420 |
if (ch == 2 && s->phase_flags[band]) {
|
| 420 | 421 |
for (bin = band_start; bin < band_end; bin++) |
| ... | ... |
@@ -445,73 +445,70 @@ typedef struct {
|
| 445 | 445 |
static void ac3_decode_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, mant_groups *m) |
| 446 | 446 |
{
|
| 447 | 447 |
int start_freq = s->start_freq[ch_index]; |
| 448 |
- int end_freq = s->end_freq[ch_index]; |
|
| 449 |
- uint8_t *baps = s->bap[ch_index]; |
|
| 450 |
- int8_t *exps = s->dexps[ch_index]; |
|
| 451 |
- int *coeffs = s->fixed_coeffs[ch_index]; |
|
| 452 |
- int dither = (ch_index == CPL_CH) || s->dither_flag[ch_index]; |
|
| 448 |
+ int end_freq = s->end_freq[ch_index]; |
|
| 449 |
+ uint8_t *baps = s->bap[ch_index]; |
|
| 450 |
+ int8_t *exps = s->dexps[ch_index]; |
|
| 451 |
+ int *coeffs = s->fixed_coeffs[ch_index]; |
|
| 452 |
+ int dither = (ch_index == CPL_CH) || s->dither_flag[ch_index]; |
|
| 453 | 453 |
GetBitContext *gbc = &s->gbc; |
| 454 | 454 |
int freq; |
| 455 | 455 |
|
| 456 |
- for(freq = start_freq; freq < end_freq; freq++){
|
|
| 456 |
+ for (freq = start_freq; freq < end_freq; freq++) {
|
|
| 457 | 457 |
int bap = baps[freq]; |
| 458 | 458 |
int mantissa; |
| 459 |
- switch(bap){
|
|
| 460 |
- case 0: |
|
| 461 |
- if (dither) |
|
| 462 |
- mantissa = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000; |
|
| 463 |
- else |
|
| 464 |
- mantissa = 0; |
|
| 465 |
- break; |
|
| 466 |
- case 1: |
|
| 467 |
- if(m->b1){
|
|
| 468 |
- m->b1--; |
|
| 469 |
- mantissa = m->b1_mant[m->b1]; |
|
| 470 |
- } |
|
| 471 |
- else{
|
|
| 472 |
- int bits = get_bits(gbc, 5); |
|
| 473 |
- mantissa = b1_mantissas[bits][0]; |
|
| 474 |
- m->b1_mant[1] = b1_mantissas[bits][1]; |
|
| 475 |
- m->b1_mant[0] = b1_mantissas[bits][2]; |
|
| 476 |
- m->b1 = 2; |
|
| 477 |
- } |
|
| 478 |
- break; |
|
| 479 |
- case 2: |
|
| 480 |
- if(m->b2){
|
|
| 481 |
- m->b2--; |
|
| 482 |
- mantissa = m->b2_mant[m->b2]; |
|
| 483 |
- } |
|
| 484 |
- else{
|
|
| 485 |
- int bits = get_bits(gbc, 7); |
|
| 486 |
- mantissa = b2_mantissas[bits][0]; |
|
| 487 |
- m->b2_mant[1] = b2_mantissas[bits][1]; |
|
| 488 |
- m->b2_mant[0] = b2_mantissas[bits][2]; |
|
| 489 |
- m->b2 = 2; |
|
| 490 |
- } |
|
| 491 |
- break; |
|
| 492 |
- case 3: |
|
| 493 |
- mantissa = b3_mantissas[get_bits(gbc, 3)]; |
|
| 494 |
- break; |
|
| 495 |
- case 4: |
|
| 496 |
- if(m->b4){
|
|
| 497 |
- m->b4 = 0; |
|
| 498 |
- mantissa = m->b4_mant; |
|
| 499 |
- } |
|
| 500 |
- else{
|
|
| 501 |
- int bits = get_bits(gbc, 7); |
|
| 502 |
- mantissa = b4_mantissas[bits][0]; |
|
| 503 |
- m->b4_mant = b4_mantissas[bits][1]; |
|
| 504 |
- m->b4 = 1; |
|
| 505 |
- } |
|
| 506 |
- break; |
|
| 507 |
- case 5: |
|
| 508 |
- mantissa = b5_mantissas[get_bits(gbc, 4)]; |
|
| 509 |
- break; |
|
| 510 |
- default: /* 6 to 15 */ |
|
| 511 |
- /* Shift mantissa and sign-extend it. */ |
|
| 512 |
- mantissa = get_sbits(gbc, quantization_tab[bap]); |
|
| 513 |
- mantissa <<= 24 - quantization_tab[bap]; |
|
| 514 |
- break; |
|
| 459 |
+ switch (bap) {
|
|
| 460 |
+ case 0: |
|
| 461 |
+ if (dither) |
|
| 462 |
+ mantissa = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000; |
|
| 463 |
+ else |
|
| 464 |
+ mantissa = 0; |
|
| 465 |
+ break; |
|
| 466 |
+ case 1: |
|
| 467 |
+ if (m->b1) {
|
|
| 468 |
+ m->b1--; |
|
| 469 |
+ mantissa = m->b1_mant[m->b1]; |
|
| 470 |
+ } else {
|
|
| 471 |
+ int bits = get_bits(gbc, 5); |
|
| 472 |
+ mantissa = b1_mantissas[bits][0]; |
|
| 473 |
+ m->b1_mant[1] = b1_mantissas[bits][1]; |
|
| 474 |
+ m->b1_mant[0] = b1_mantissas[bits][2]; |
|
| 475 |
+ m->b1 = 2; |
|
| 476 |
+ } |
|
| 477 |
+ break; |
|
| 478 |
+ case 2: |
|
| 479 |
+ if (m->b2) {
|
|
| 480 |
+ m->b2--; |
|
| 481 |
+ mantissa = m->b2_mant[m->b2]; |
|
| 482 |
+ } else {
|
|
| 483 |
+ int bits = get_bits(gbc, 7); |
|
| 484 |
+ mantissa = b2_mantissas[bits][0]; |
|
| 485 |
+ m->b2_mant[1] = b2_mantissas[bits][1]; |
|
| 486 |
+ m->b2_mant[0] = b2_mantissas[bits][2]; |
|
| 487 |
+ m->b2 = 2; |
|
| 488 |
+ } |
|
| 489 |
+ break; |
|
| 490 |
+ case 3: |
|
| 491 |
+ mantissa = b3_mantissas[get_bits(gbc, 3)]; |
|
| 492 |
+ break; |
|
| 493 |
+ case 4: |
|
| 494 |
+ if (m->b4) {
|
|
| 495 |
+ m->b4 = 0; |
|
| 496 |
+ mantissa = m->b4_mant; |
|
| 497 |
+ } else {
|
|
| 498 |
+ int bits = get_bits(gbc, 7); |
|
| 499 |
+ mantissa = b4_mantissas[bits][0]; |
|
| 500 |
+ m->b4_mant = b4_mantissas[bits][1]; |
|
| 501 |
+ m->b4 = 1; |
|
| 502 |
+ } |
|
| 503 |
+ break; |
|
| 504 |
+ case 5: |
|
| 505 |
+ mantissa = b5_mantissas[get_bits(gbc, 4)]; |
|
| 506 |
+ break; |
|
| 507 |
+ default: /* 6 to 15 */ |
|
| 508 |
+ /* Shift mantissa and sign-extend it. */ |
|
| 509 |
+ mantissa = get_sbits(gbc, quantization_tab[bap]); |
|
| 510 |
+ mantissa <<= 24 - quantization_tab[bap]; |
|
| 511 |
+ break; |
|
| 515 | 512 |
} |
| 516 | 513 |
coeffs[freq] = mantissa >> exps[freq]; |
| 517 | 514 |
} |
| ... | ... |
@@ -525,10 +522,10 @@ static void ac3_decode_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, ma |
| 525 | 525 |
static void remove_dithering(AC3DecodeContext *s) {
|
| 526 | 526 |
int ch, i; |
| 527 | 527 |
|
| 528 |
- for(ch=1; ch<=s->fbw_channels; ch++) {
|
|
| 529 |
- if(!s->dither_flag[ch] && s->channel_in_cpl[ch]) {
|
|
| 530 |
- for(i = s->start_freq[CPL_CH]; i<s->end_freq[CPL_CH]; i++) {
|
|
| 531 |
- if(!s->bap[CPL_CH][i]) |
|
| 528 |
+ for (ch = 1; ch <= s->fbw_channels; ch++) {
|
|
| 529 |
+ if (!s->dither_flag[ch] && s->channel_in_cpl[ch]) {
|
|
| 530 |
+ for (i = s->start_freq[CPL_CH]; i < s->end_freq[CPL_CH]; i++) {
|
|
| 531 |
+ if (!s->bap[CPL_CH][i]) |
|
| 532 | 532 |
s->fixed_coeffs[ch][i] = 0; |
| 533 | 533 |
} |
| 534 | 534 |
} |
| ... | ... |
@@ -536,7 +533,7 @@ static void remove_dithering(AC3DecodeContext *s) {
|
| 536 | 536 |
} |
| 537 | 537 |
|
| 538 | 538 |
static void decode_transform_coeffs_ch(AC3DecodeContext *s, int blk, int ch, |
| 539 |
- mant_groups *m) |
|
| 539 |
+ mant_groups *m) |
|
| 540 | 540 |
{
|
| 541 | 541 |
if (!s->channel_uses_aht[ch]) {
|
| 542 | 542 |
ac3_decode_transform_coeffs_ch(s, ch, m); |
| ... | ... |
@@ -580,7 +577,7 @@ static void decode_transform_coeffs(AC3DecodeContext *s, int blk) |
| 580 | 580 |
} |
| 581 | 581 |
do |
| 582 | 582 |
s->fixed_coeffs[ch][end] = 0; |
| 583 |
- while(++end < 256); |
|
| 583 |
+ while (++end < 256); |
|
| 584 | 584 |
} |
| 585 | 585 |
|
| 586 | 586 |
/* zero the dithered coefficients for appropriate channels */ |
| ... | ... |
@@ -598,10 +595,10 @@ static void do_rematrixing(AC3DecodeContext *s) |
| 598 | 598 |
|
| 599 | 599 |
end = FFMIN(s->end_freq[1], s->end_freq[2]); |
| 600 | 600 |
|
| 601 |
- for(bnd=0; bnd<s->num_rematrixing_bands; bnd++) {
|
|
| 602 |
- if(s->rematrixing_flags[bnd]) {
|
|
| 603 |
- bndend = FFMIN(end, ff_ac3_rematrix_band_tab[bnd+1]); |
|
| 604 |
- for(i=ff_ac3_rematrix_band_tab[bnd]; i<bndend; i++) {
|
|
| 601 |
+ for (bnd = 0; bnd < s->num_rematrixing_bands; bnd++) {
|
|
| 602 |
+ if (s->rematrixing_flags[bnd]) {
|
|
| 603 |
+ bndend = FFMIN(end, ff_ac3_rematrix_band_tab[bnd + 1]); |
|
| 604 |
+ for (i = ff_ac3_rematrix_band_tab[bnd]; i < bndend; i++) {
|
|
| 605 | 605 |
int tmp0 = s->fixed_coeffs[1][i]; |
| 606 | 606 |
s->fixed_coeffs[1][i] += s->fixed_coeffs[2][i]; |
| 607 | 607 |
s->fixed_coeffs[2][i] = tmp0 - s->fixed_coeffs[2][i]; |
| ... | ... |
@@ -619,21 +616,23 @@ static inline void do_imdct(AC3DecodeContext *s, int channels) |
| 619 | 619 |
{
|
| 620 | 620 |
int ch; |
| 621 | 621 |
|
| 622 |
- for (ch=1; ch<=channels; ch++) {
|
|
| 622 |
+ for (ch = 1; ch <= channels; ch++) {
|
|
| 623 | 623 |
if (s->block_switch[ch]) {
|
| 624 | 624 |
int i; |
| 625 |
- float *x = s->tmp_output+128; |
|
| 626 |
- for(i=0; i<128; i++) |
|
| 627 |
- x[i] = s->transform_coeffs[ch][2*i]; |
|
| 625 |
+ float *x = s->tmp_output + 128; |
|
| 626 |
+ for (i = 0; i < 128; i++) |
|
| 627 |
+ x[i] = s->transform_coeffs[ch][2 * i]; |
|
| 628 | 628 |
s->imdct_256.imdct_half(&s->imdct_256, s->tmp_output, x); |
| 629 |
- s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 128); |
|
| 630 |
- for(i=0; i<128; i++) |
|
| 631 |
- x[i] = s->transform_coeffs[ch][2*i+1]; |
|
| 632 |
- s->imdct_256.imdct_half(&s->imdct_256, s->delay[ch-1], x); |
|
| 629 |
+ s->dsp.vector_fmul_window(s->output[ch - 1], s->delay[ch - 1], |
|
| 630 |
+ s->tmp_output, s->window, 128); |
|
| 631 |
+ for (i = 0; i < 128; i++) |
|
| 632 |
+ x[i] = s->transform_coeffs[ch][2 * i + 1]; |
|
| 633 |
+ s->imdct_256.imdct_half(&s->imdct_256, s->delay[ch - 1], x); |
|
| 633 | 634 |
} else {
|
| 634 | 635 |
s->imdct_512.imdct_half(&s->imdct_512, s->tmp_output, s->transform_coeffs[ch]); |
| 635 |
- s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 128); |
|
| 636 |
- memcpy(s->delay[ch-1], s->tmp_output+128, 128*sizeof(float)); |
|
| 636 |
+ s->dsp.vector_fmul_window(s->output[ch - 1], s->delay[ch - 1], |
|
| 637 |
+ s->tmp_output, s->window, 128); |
|
| 638 |
+ memcpy(s->delay[ch - 1], s->tmp_output + 128, 128 * sizeof(float)); |
|
| 637 | 639 |
} |
| 638 | 640 |
} |
| 639 | 641 |
} |
| ... | ... |
@@ -641,24 +640,25 @@ static inline void do_imdct(AC3DecodeContext *s, int channels) |
| 641 | 641 |
/** |
| 642 | 642 |
* Downmix the output to mono or stereo. |
| 643 | 643 |
*/ |
| 644 |
-void ff_ac3_downmix_c(float (*samples)[256], float (*matrix)[2], int out_ch, int in_ch, int len) |
|
| 644 |
+void ff_ac3_downmix_c(float (*samples)[256], float (*matrix)[2], |
|
| 645 |
+ int out_ch, int in_ch, int len) |
|
| 645 | 646 |
{
|
| 646 | 647 |
int i, j; |
| 647 | 648 |
float v0, v1; |
| 648 |
- if(out_ch == 2) {
|
|
| 649 |
- for(i=0; i<len; i++) {
|
|
| 649 |
+ if (out_ch == 2) {
|
|
| 650 |
+ for (i = 0; i < len; i++) {
|
|
| 650 | 651 |
v0 = v1 = 0.0f; |
| 651 |
- for(j=0; j<in_ch; j++) {
|
|
| 652 |
+ for (j = 0; j < in_ch; j++) {
|
|
| 652 | 653 |
v0 += samples[j][i] * matrix[j][0]; |
| 653 | 654 |
v1 += samples[j][i] * matrix[j][1]; |
| 654 | 655 |
} |
| 655 | 656 |
samples[0][i] = v0; |
| 656 | 657 |
samples[1][i] = v1; |
| 657 | 658 |
} |
| 658 |
- } else if(out_ch == 1) {
|
|
| 659 |
- for(i=0; i<len; i++) {
|
|
| 659 |
+ } else if (out_ch == 1) {
|
|
| 660 |
+ for (i = 0; i < len; i++) {
|
|
| 660 | 661 |
v0 = 0.0f; |
| 661 |
- for(j=0; j<in_ch; j++) |
|
| 662 |
+ for (j = 0; j < in_ch; j++) |
|
| 662 | 663 |
v0 += samples[j][i] * matrix[j][0]; |
| 663 | 664 |
samples[0][i] = v0; |
| 664 | 665 |
} |
| ... | ... |
@@ -671,25 +671,25 @@ void ff_ac3_downmix_c(float (*samples)[256], float (*matrix)[2], int out_ch, int |
| 671 | 671 |
static void ac3_upmix_delay(AC3DecodeContext *s) |
| 672 | 672 |
{
|
| 673 | 673 |
int channel_data_size = sizeof(s->delay[0]); |
| 674 |
- switch(s->channel_mode) {
|
|
| 675 |
- case AC3_CHMODE_DUALMONO: |
|
| 676 |
- case AC3_CHMODE_STEREO: |
|
| 677 |
- /* upmix mono to stereo */ |
|
| 678 |
- memcpy(s->delay[1], s->delay[0], channel_data_size); |
|
| 679 |
- break; |
|
| 680 |
- case AC3_CHMODE_2F2R: |
|
| 681 |
- memset(s->delay[3], 0, channel_data_size); |
|
| 682 |
- case AC3_CHMODE_2F1R: |
|
| 683 |
- memset(s->delay[2], 0, channel_data_size); |
|
| 684 |
- break; |
|
| 685 |
- case AC3_CHMODE_3F2R: |
|
| 686 |
- memset(s->delay[4], 0, channel_data_size); |
|
| 687 |
- case AC3_CHMODE_3F1R: |
|
| 688 |
- memset(s->delay[3], 0, channel_data_size); |
|
| 689 |
- case AC3_CHMODE_3F: |
|
| 690 |
- memcpy(s->delay[2], s->delay[1], channel_data_size); |
|
| 691 |
- memset(s->delay[1], 0, channel_data_size); |
|
| 692 |
- break; |
|
| 674 |
+ switch (s->channel_mode) {
|
|
| 675 |
+ case AC3_CHMODE_DUALMONO: |
|
| 676 |
+ case AC3_CHMODE_STEREO: |
|
| 677 |
+ /* upmix mono to stereo */ |
|
| 678 |
+ memcpy(s->delay[1], s->delay[0], channel_data_size); |
|
| 679 |
+ break; |
|
| 680 |
+ case AC3_CHMODE_2F2R: |
|
| 681 |
+ memset(s->delay[3], 0, channel_data_size); |
|
| 682 |
+ case AC3_CHMODE_2F1R: |
|
| 683 |
+ memset(s->delay[2], 0, channel_data_size); |
|
| 684 |
+ break; |
|
| 685 |
+ case AC3_CHMODE_3F2R: |
|
| 686 |
+ memset(s->delay[4], 0, channel_data_size); |
|
| 687 |
+ case AC3_CHMODE_3F1R: |
|
| 688 |
+ memset(s->delay[3], 0, channel_data_size); |
|
| 689 |
+ case AC3_CHMODE_3F: |
|
| 690 |
+ memcpy(s->delay[2], s->delay[1], channel_data_size); |
|
| 691 |
+ memset(s->delay[1], 0, channel_data_size); |
|
| 692 |
+ break; |
|
| 693 | 693 |
} |
| 694 | 694 |
} |
| 695 | 695 |
|
| ... | ... |
@@ -742,7 +742,7 @@ static void decode_band_structure(GetBitContext *gbc, int blk, int eac3, |
| 742 | 742 |
bnd_sz[0] = ecpl ? 6 : 12; |
| 743 | 743 |
for (bnd = 0, subbnd = 1; subbnd < n_subbands; subbnd++) {
|
| 744 | 744 |
int subbnd_size = (ecpl && subbnd < 4) ? 6 : 12; |
| 745 |
- if (band_struct[subbnd-1]) {
|
|
| 745 |
+ if (band_struct[subbnd - 1]) {
|
|
| 746 | 746 |
n_bands--; |
| 747 | 747 |
bnd_sz[bnd] += subbnd_size; |
| 748 | 748 |
} else {
|
| ... | ... |
@@ -779,7 +779,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 779 | 779 |
if (s->block_switch_syntax) {
|
| 780 | 780 |
for (ch = 1; ch <= fbw_channels; ch++) {
|
| 781 | 781 |
s->block_switch[ch] = get_bits1(gbc); |
| 782 |
- if(ch > 1 && s->block_switch[ch] != s->block_switch[1]) |
|
| 782 |
+ if (ch > 1 && s->block_switch[ch] != s->block_switch[1]) |
|
| 783 | 783 |
different_transforms = 1; |
| 784 | 784 |
} |
| 785 | 785 |
} |
| ... | ... |
@@ -794,13 +794,13 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 794 | 794 |
/* dynamic range */ |
| 795 | 795 |
i = !(s->channel_mode); |
| 796 | 796 |
do {
|
| 797 |
- if(get_bits1(gbc)) {
|
|
| 798 |
- s->dynamic_range[i] = ((dynamic_range_tab[get_bits(gbc, 8)]-1.0) * |
|
| 799 |
- s->drc_scale)+1.0; |
|
| 800 |
- } else if(blk == 0) {
|
|
| 797 |
+ if (get_bits1(gbc)) {
|
|
| 798 |
+ s->dynamic_range[i] = ((dynamic_range_tab[get_bits(gbc, 8)] - 1.0) * |
|
| 799 |
+ s->drc_scale) + 1.0; |
|
| 800 |
+ } else if (blk == 0) {
|
|
| 801 | 801 |
s->dynamic_range[i] = 1.0f; |
| 802 | 802 |
} |
| 803 |
- } while(i--); |
|
| 803 |
+ } while (i--); |
|
| 804 | 804 |
|
| 805 | 805 |
/* spectral extension strategy */ |
| 806 | 806 |
if (s->eac3 && (!blk || get_bits1(gbc))) {
|
| ... | ... |
@@ -881,7 +881,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 881 | 881 |
bandsize = s->spx_band_sizes[bnd]; |
| 882 | 882 |
nratio = ((float)((bin + (bandsize >> 1))) / s->spx_dst_end_freq) - spx_blend; |
| 883 | 883 |
nratio = av_clipf(nratio, 0.0f, 1.0f); |
| 884 |
- nblend = sqrtf(3.0f * nratio); // noise is scaled by sqrt(3) to give unity variance |
|
| 884 |
+ nblend = sqrtf(3.0f * nratio); // noise is scaled by sqrt(3) |
|
| 885 |
+ // to give unity variance |
|
| 885 | 886 |
sblend = sqrtf(1.0f - nratio); |
| 886 | 887 |
bin += bandsize; |
| 887 | 888 |
|
| ... | ... |
@@ -891,7 +892,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 891 | 891 |
if (spx_coord_exp == 15) spx_coord_mant <<= 1; |
| 892 | 892 |
else spx_coord_mant += 4; |
| 893 | 893 |
spx_coord_mant <<= (25 - spx_coord_exp - master_spx_coord); |
| 894 |
- spx_coord = spx_coord_mant * (1.0f/(1<<23)); |
|
| 894 |
+ spx_coord = spx_coord_mant * (1.0f / (1 << 23)); |
|
| 895 | 895 |
|
| 896 | 896 |
/* multiply noise and signal blending factors by spx coordinate */ |
| 897 | 897 |
s->spx_noise_blend [ch][bnd] = nblend * spx_coord; |
| ... | ... |
@@ -964,8 +965,9 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 964 | 964 |
s->phase_flags_in_use = 0; |
| 965 | 965 |
} |
| 966 | 966 |
} else if (!s->eac3) {
|
| 967 |
- if(!blk) {
|
|
| 968 |
- av_log(s->avctx, AV_LOG_ERROR, "new coupling strategy must be present in block 0\n"); |
|
| 967 |
+ if (!blk) {
|
|
| 968 |
+ av_log(s->avctx, AV_LOG_ERROR, "new coupling strategy must " |
|
| 969 |
+ "be present in block 0\n"); |
|
| 969 | 970 |
return -1; |
| 970 | 971 |
} else {
|
| 971 | 972 |
s->cpl_in_use[blk] = s->cpl_in_use[blk-1]; |
| ... | ... |
@@ -994,7 +996,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 994 | 994 |
s->cpl_coords[ch][bnd] >>= (cpl_coord_exp + master_cpl_coord); |
| 995 | 995 |
} |
| 996 | 996 |
} else if (!blk) {
|
| 997 |
- av_log(s->avctx, AV_LOG_ERROR, "new coupling coordinates must be present in block 0\n"); |
|
| 997 |
+ av_log(s->avctx, AV_LOG_ERROR, "new coupling coordinates must " |
|
| 998 |
+ "be present in block 0\n"); |
|
| 998 | 999 |
return -1; |
| 999 | 1000 |
} |
| 1000 | 1001 |
} else {
|
| ... | ... |
@@ -1019,10 +1022,11 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 1019 | 1019 |
} else if (s->spx_in_use && s->spx_src_start_freq <= 61) {
|
| 1020 | 1020 |
s->num_rematrixing_bands--; |
| 1021 | 1021 |
} |
| 1022 |
- for(bnd=0; bnd<s->num_rematrixing_bands; bnd++) |
|
| 1022 |
+ for (bnd = 0; bnd < s->num_rematrixing_bands; bnd++) |
|
| 1023 | 1023 |
s->rematrixing_flags[bnd] = get_bits1(gbc); |
| 1024 | 1024 |
} else if (!blk) {
|
| 1025 |
- av_log(s->avctx, AV_LOG_WARNING, "Warning: new rematrixing strategy not present in block 0\n"); |
|
| 1025 |
+ av_log(s->avctx, AV_LOG_WARNING, "Warning: " |
|
| 1026 |
+ "new rematrixing strategy not present in block 0\n"); |
|
| 1026 | 1027 |
s->num_rematrixing_bands = 0; |
| 1027 | 1028 |
} |
| 1028 | 1029 |
} |
| ... | ... |
@@ -1031,7 +1035,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 1031 | 1031 |
for (ch = !cpl_in_use; ch <= s->channels; ch++) {
|
| 1032 | 1032 |
if (!s->eac3) |
| 1033 | 1033 |
s->exp_strategy[blk][ch] = get_bits(gbc, 2 - (ch == s->lfe_ch)); |
| 1034 |
- if(s->exp_strategy[blk][ch] != EXP_REUSE) |
|
| 1034 |
+ if (s->exp_strategy[blk][ch] != EXP_REUSE) |
|
| 1035 | 1035 |
bit_alloc_stages[ch] = 3; |
| 1036 | 1036 |
} |
| 1037 | 1037 |
|
| ... | ... |
@@ -1054,8 +1058,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 1054 | 1054 |
s->end_freq[ch] = bandwidth_code * 3 + 73; |
| 1055 | 1055 |
} |
| 1056 | 1056 |
group_size = 3 << (s->exp_strategy[blk][ch] - 1); |
| 1057 |
- s->num_exp_groups[ch] = (s->end_freq[ch]+group_size-4) / group_size; |
|
| 1058 |
- if(blk > 0 && s->end_freq[ch] != prev) |
|
| 1057 |
+ s->num_exp_groups[ch] = (s->end_freq[ch] + group_size-4) / group_size; |
|
| 1058 |
+ if (blk > 0 && s->end_freq[ch] != prev) |
|
| 1059 | 1059 |
memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS); |
| 1060 | 1060 |
} |
| 1061 | 1061 |
} |
| ... | ... |
@@ -1074,7 +1078,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 1074 | 1074 |
av_log(s->avctx, AV_LOG_ERROR, "exponent out-of-range\n"); |
| 1075 | 1075 |
return -1; |
| 1076 | 1076 |
} |
| 1077 |
- if(ch != CPL_CH && ch != s->lfe_ch) |
|
| 1077 |
+ if (ch != CPL_CH && ch != s->lfe_ch) |
|
| 1078 | 1078 |
skip_bits(gbc, 2); /* skip gainrng */ |
| 1079 | 1079 |
} |
| 1080 | 1080 |
} |
| ... | ... |
@@ -1087,17 +1091,18 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 1087 | 1087 |
s->bit_alloc_params.slow_gain = ff_ac3_slow_gain_tab[get_bits(gbc, 2)]; |
| 1088 | 1088 |
s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[get_bits(gbc, 2)]; |
| 1089 | 1089 |
s->bit_alloc_params.floor = ff_ac3_floor_tab[get_bits(gbc, 3)]; |
| 1090 |
- for(ch=!cpl_in_use; ch<=s->channels; ch++) |
|
| 1090 |
+ for (ch = !cpl_in_use; ch <= s->channels; ch++) |
|
| 1091 | 1091 |
bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); |
| 1092 | 1092 |
} else if (!blk) {
|
| 1093 |
- av_log(s->avctx, AV_LOG_ERROR, "new bit allocation info must be present in block 0\n"); |
|
| 1093 |
+ av_log(s->avctx, AV_LOG_ERROR, "new bit allocation info must " |
|
| 1094 |
+ "be present in block 0\n"); |
|
| 1094 | 1095 |
return -1; |
| 1095 | 1096 |
} |
| 1096 | 1097 |
} |
| 1097 | 1098 |
|
| 1098 | 1099 |
/* signal-to-noise ratio offsets and fast gains (signal-to-mask ratios) */ |
| 1099 |
- if(!s->eac3 || !blk){
|
|
| 1100 |
- if(s->snr_offset_strategy && get_bits1(gbc)) {
|
|
| 1100 |
+ if (!s->eac3 || !blk) {
|
|
| 1101 |
+ if (s->snr_offset_strategy && get_bits1(gbc)) {
|
|
| 1101 | 1102 |
int snr = 0; |
| 1102 | 1103 |
int csnr; |
| 1103 | 1104 |
csnr = (get_bits(gbc, 6) - 15) << 4; |
| ... | ... |
@@ -1106,7 +1111,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 1106 | 1106 |
if (ch == i || s->snr_offset_strategy == 2) |
| 1107 | 1107 |
snr = (csnr + get_bits(gbc, 4)) << 2; |
| 1108 | 1108 |
/* run at least last bit allocation stage if snr offset changes */ |
| 1109 |
- if(blk && s->snr_offset[ch] != snr) {
|
|
| 1109 |
+ if (blk && s->snr_offset[ch] != snr) {
|
|
| 1110 | 1110 |
bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 1); |
| 1111 | 1111 |
} |
| 1112 | 1112 |
s->snr_offset[ch] = snr; |
| ... | ... |
@@ -1116,7 +1121,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 1116 | 1116 |
int prev = s->fast_gain[ch]; |
| 1117 | 1117 |
s->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gbc, 3)]; |
| 1118 | 1118 |
/* run last 2 bit allocation stages if fast gain changes */ |
| 1119 |
- if(blk && prev != s->fast_gain[ch]) |
|
| 1119 |
+ if (blk && prev != s->fast_gain[ch]) |
|
| 1120 | 1120 |
bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); |
| 1121 | 1121 |
} |
| 1122 | 1122 |
} |
| ... | ... |
@@ -1132,7 +1137,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 1132 | 1132 |
int prev = s->fast_gain[ch]; |
| 1133 | 1133 |
s->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gbc, 3)]; |
| 1134 | 1134 |
/* run last 2 bit allocation stages if fast gain changes */ |
| 1135 |
- if(blk && prev != s->fast_gain[ch]) |
|
| 1135 |
+ if (blk && prev != s->fast_gain[ch]) |
|
| 1136 | 1136 |
bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); |
| 1137 | 1137 |
} |
| 1138 | 1138 |
} else if (s->eac3 && !blk) {
|
| ... | ... |
@@ -1152,14 +1157,15 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 1152 | 1152 |
int sl = get_bits(gbc, 3); |
| 1153 | 1153 |
/* run last 2 bit allocation stages for coupling channel if |
| 1154 | 1154 |
coupling leak changes */ |
| 1155 |
- if(blk && (fl != s->bit_alloc_params.cpl_fast_leak || |
|
| 1156 |
- sl != s->bit_alloc_params.cpl_slow_leak)) {
|
|
| 1155 |
+ if (blk && (fl != s->bit_alloc_params.cpl_fast_leak || |
|
| 1156 |
+ sl != s->bit_alloc_params.cpl_slow_leak)) {
|
|
| 1157 | 1157 |
bit_alloc_stages[CPL_CH] = FFMAX(bit_alloc_stages[CPL_CH], 2); |
| 1158 | 1158 |
} |
| 1159 | 1159 |
s->bit_alloc_params.cpl_fast_leak = fl; |
| 1160 | 1160 |
s->bit_alloc_params.cpl_slow_leak = sl; |
| 1161 | 1161 |
} else if (!s->eac3 && !blk) {
|
| 1162 |
- av_log(s->avctx, AV_LOG_ERROR, "new coupling leak info must be present in block 0\n"); |
|
| 1162 |
+ av_log(s->avctx, AV_LOG_ERROR, "new coupling leak info must " |
|
| 1163 |
+ "be present in block 0\n"); |
|
| 1163 | 1164 |
return -1; |
| 1164 | 1165 |
} |
| 1165 | 1166 |
s->first_cpl_leak = 0; |
| ... | ... |
@@ -1183,40 +1189,40 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 1183 | 1183 |
for (seg = 0; seg < s->dba_nsegs[ch]; seg++) {
|
| 1184 | 1184 |
s->dba_offsets[ch][seg] = get_bits(gbc, 5); |
| 1185 | 1185 |
s->dba_lengths[ch][seg] = get_bits(gbc, 4); |
| 1186 |
- s->dba_values[ch][seg] = get_bits(gbc, 3); |
|
| 1186 |
+ s->dba_values[ch][seg] = get_bits(gbc, 3); |
|
| 1187 | 1187 |
} |
| 1188 | 1188 |
/* run last 2 bit allocation stages if new dba values */ |
| 1189 | 1189 |
bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); |
| 1190 | 1190 |
} |
| 1191 | 1191 |
} |
| 1192 |
- } else if(blk == 0) {
|
|
| 1193 |
- for(ch=0; ch<=s->channels; ch++) {
|
|
| 1192 |
+ } else if (blk == 0) {
|
|
| 1193 |
+ for (ch = 0; ch <= s->channels; ch++) {
|
|
| 1194 | 1194 |
s->dba_mode[ch] = DBA_NONE; |
| 1195 | 1195 |
} |
| 1196 | 1196 |
} |
| 1197 | 1197 |
|
| 1198 | 1198 |
/* Bit allocation */ |
| 1199 |
- for(ch=!cpl_in_use; ch<=s->channels; ch++) {
|
|
| 1200 |
- if(bit_alloc_stages[ch] > 2) {
|
|
| 1199 |
+ for (ch = !cpl_in_use; ch <= s->channels; ch++) {
|
|
| 1200 |
+ if (bit_alloc_stages[ch] > 2) {
|
|
| 1201 | 1201 |
/* Exponent mapping into PSD and PSD integration */ |
| 1202 | 1202 |
ff_ac3_bit_alloc_calc_psd(s->dexps[ch], |
| 1203 | 1203 |
s->start_freq[ch], s->end_freq[ch], |
| 1204 | 1204 |
s->psd[ch], s->band_psd[ch]); |
| 1205 | 1205 |
} |
| 1206 |
- if(bit_alloc_stages[ch] > 1) {
|
|
| 1206 |
+ if (bit_alloc_stages[ch] > 1) {
|
|
| 1207 | 1207 |
/* Compute excitation function, Compute masking curve, and |
| 1208 | 1208 |
Apply delta bit allocation */ |
| 1209 | 1209 |
if (ff_ac3_bit_alloc_calc_mask(&s->bit_alloc_params, s->band_psd[ch], |
| 1210 |
- s->start_freq[ch], s->end_freq[ch], |
|
| 1211 |
- s->fast_gain[ch], (ch == s->lfe_ch), |
|
| 1212 |
- s->dba_mode[ch], s->dba_nsegs[ch], |
|
| 1210 |
+ s->start_freq[ch], s->end_freq[ch], |
|
| 1211 |
+ s->fast_gain[ch], (ch == s->lfe_ch), |
|
| 1212 |
+ s->dba_mode[ch], s->dba_nsegs[ch], |
|
| 1213 | 1213 |
s->dba_offsets[ch], s->dba_lengths[ch], |
| 1214 |
- s->dba_values[ch], s->mask[ch])) {
|
|
| 1214 |
+ s->dba_values[ch], s->mask[ch])) {
|
|
| 1215 | 1215 |
av_log(s->avctx, AV_LOG_ERROR, "error in bit allocation\n"); |
| 1216 | 1216 |
return -1; |
| 1217 | 1217 |
} |
| 1218 | 1218 |
} |
| 1219 |
- if(bit_alloc_stages[ch] > 0) {
|
|
| 1219 |
+ if (bit_alloc_stages[ch] > 0) {
|
|
| 1220 | 1220 |
/* Compute bit allocation */ |
| 1221 | 1221 |
const uint8_t *bap_tab = s->channel_uses_aht[ch] ? |
| 1222 | 1222 |
ff_eac3_hebap_tab : ff_ac3_bap_tab; |
| ... | ... |
@@ -1231,7 +1237,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 1231 | 1231 |
/* unused dummy data */ |
| 1232 | 1232 |
if (s->skip_syntax && get_bits1(gbc)) {
|
| 1233 | 1233 |
int skipl = get_bits(gbc, 9); |
| 1234 |
- while(skipl--) |
|
| 1234 |
+ while (skipl--) |
|
| 1235 | 1235 |
skip_bits(gbc, 8); |
| 1236 | 1236 |
} |
| 1237 | 1237 |
|
| ... | ... |
@@ -1242,18 +1248,19 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 1242 | 1242 |
/* TODO: generate enhanced coupling coordinates and uncouple */ |
| 1243 | 1243 |
|
| 1244 | 1244 |
/* recover coefficients if rematrixing is in use */ |
| 1245 |
- if(s->channel_mode == AC3_CHMODE_STEREO) |
|
| 1245 |
+ if (s->channel_mode == AC3_CHMODE_STEREO) |
|
| 1246 | 1246 |
do_rematrixing(s); |
| 1247 | 1247 |
|
| 1248 | 1248 |
/* apply scaling to coefficients (headroom, dynrng) */ |
| 1249 |
- for(ch=1; ch<=s->channels; ch++) {
|
|
| 1249 |
+ for (ch = 1; ch <= s->channels; ch++) {
|
|
| 1250 | 1250 |
float gain = s->mul_bias / 4194304.0f; |
| 1251 |
- if(s->channel_mode == AC3_CHMODE_DUALMONO) {
|
|
| 1252 |
- gain *= s->dynamic_range[2-ch]; |
|
| 1251 |
+ if (s->channel_mode == AC3_CHMODE_DUALMONO) {
|
|
| 1252 |
+ gain *= s->dynamic_range[2 - ch]; |
|
| 1253 | 1253 |
} else {
|
| 1254 | 1254 |
gain *= s->dynamic_range[0]; |
| 1255 | 1255 |
} |
| 1256 |
- s->fmt_conv.int32_to_float_fmul_scalar(s->transform_coeffs[ch], s->fixed_coeffs[ch], gain, 256); |
|
| 1256 |
+ s->fmt_conv.int32_to_float_fmul_scalar(s->transform_coeffs[ch], |
|
| 1257 |
+ s->fixed_coeffs[ch], gain, 256); |
|
| 1257 | 1258 |
} |
| 1258 | 1259 |
|
| 1259 | 1260 |
/* apply spectral extension to high frequency bins */ |
| ... | ... |
@@ -1267,27 +1274,30 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) |
| 1267 | 1267 |
downmix_output = s->channels != s->out_channels && |
| 1268 | 1268 |
!((s->output_mode & AC3_OUTPUT_LFEON) && |
| 1269 | 1269 |
s->fbw_channels == s->out_channels); |
| 1270 |
- if(different_transforms) {
|
|
| 1270 |
+ if (different_transforms) {
|
|
| 1271 | 1271 |
/* the delay samples have already been downmixed, so we upmix the delay |
| 1272 | 1272 |
samples in order to reconstruct all channels before downmixing. */ |
| 1273 |
- if(s->downmixed) {
|
|
| 1273 |
+ if (s->downmixed) {
|
|
| 1274 | 1274 |
s->downmixed = 0; |
| 1275 | 1275 |
ac3_upmix_delay(s); |
| 1276 | 1276 |
} |
| 1277 | 1277 |
|
| 1278 | 1278 |
do_imdct(s, s->channels); |
| 1279 | 1279 |
|
| 1280 |
- if(downmix_output) {
|
|
| 1281 |
- s->dsp.ac3_downmix(s->output, s->downmix_coeffs, s->out_channels, s->fbw_channels, 256); |
|
| 1280 |
+ if (downmix_output) {
|
|
| 1281 |
+ s->dsp.ac3_downmix(s->output, s->downmix_coeffs, |
|
| 1282 |
+ s->out_channels, s->fbw_channels, 256); |
|
| 1282 | 1283 |
} |
| 1283 | 1284 |
} else {
|
| 1284 |
- if(downmix_output) {
|
|
| 1285 |
- s->dsp.ac3_downmix(s->transform_coeffs+1, s->downmix_coeffs, s->out_channels, s->fbw_channels, 256); |
|
| 1285 |
+ if (downmix_output) {
|
|
| 1286 |
+ s->dsp.ac3_downmix(s->transform_coeffs + 1, s->downmix_coeffs, |
|
| 1287 |
+ s->out_channels, s->fbw_channels, 256); |
|
| 1286 | 1288 |
} |
| 1287 | 1289 |
|
| 1288 |
- if(downmix_output && !s->downmixed) {
|
|
| 1290 |
+ if (downmix_output && !s->downmixed) {
|
|
| 1289 | 1291 |
s->downmixed = 1; |
| 1290 |
- s->dsp.ac3_downmix(s->delay, s->downmix_coeffs, s->out_channels, s->fbw_channels, 128); |
|
| 1292 |
+ s->dsp.ac3_downmix(s->delay, s->downmix_coeffs, s->out_channels, |
|
| 1293 |
+ s->fbw_channels, 128); |
|
| 1291 | 1294 |
} |
| 1292 | 1295 |
|
| 1293 | 1296 |
do_imdct(s, s->out_channels); |
| ... | ... |
@@ -1327,33 +1337,34 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, |
| 1327 | 1327 |
err = parse_frame_header(s); |
| 1328 | 1328 |
|
| 1329 | 1329 |
if (err) {
|
| 1330 |
- switch(err) {
|
|
| 1331 |
- case AAC_AC3_PARSE_ERROR_SYNC: |
|
| 1332 |
- av_log(avctx, AV_LOG_ERROR, "frame sync error\n"); |
|
| 1333 |
- return -1; |
|
| 1334 |
- case AAC_AC3_PARSE_ERROR_BSID: |
|
| 1335 |
- av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n"); |
|
| 1336 |
- break; |
|
| 1337 |
- case AAC_AC3_PARSE_ERROR_SAMPLE_RATE: |
|
| 1338 |
- av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n"); |
|
| 1339 |
- break; |
|
| 1340 |
- case AAC_AC3_PARSE_ERROR_FRAME_SIZE: |
|
| 1341 |
- av_log(avctx, AV_LOG_ERROR, "invalid frame size\n"); |
|
| 1342 |
- break; |
|
| 1343 |
- case AAC_AC3_PARSE_ERROR_FRAME_TYPE: |
|
| 1344 |
- /* skip frame if CRC is ok. otherwise use error concealment. */ |
|
| 1345 |
- /* TODO: add support for substreams and dependent frames */ |
|
| 1346 |
- if(s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {
|
|
| 1347 |
- av_log(avctx, AV_LOG_ERROR, "unsupported frame type : skipping frame\n"); |
|
| 1348 |
- *got_frame_ptr = 0; |
|
| 1349 |
- return s->frame_size; |
|
| 1350 |
- } else {
|
|
| 1351 |
- av_log(avctx, AV_LOG_ERROR, "invalid frame type\n"); |
|
| 1352 |
- } |
|
| 1353 |
- break; |
|
| 1354 |
- default: |
|
| 1355 |
- av_log(avctx, AV_LOG_ERROR, "invalid header\n"); |
|
| 1356 |
- break; |
|
| 1330 |
+ switch (err) {
|
|
| 1331 |
+ case AAC_AC3_PARSE_ERROR_SYNC: |
|
| 1332 |
+ av_log(avctx, AV_LOG_ERROR, "frame sync error\n"); |
|
| 1333 |
+ return -1; |
|
| 1334 |
+ case AAC_AC3_PARSE_ERROR_BSID: |
|
| 1335 |
+ av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n"); |
|
| 1336 |
+ break; |
|
| 1337 |
+ case AAC_AC3_PARSE_ERROR_SAMPLE_RATE: |
|
| 1338 |
+ av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n"); |
|
| 1339 |
+ break; |
|
| 1340 |
+ case AAC_AC3_PARSE_ERROR_FRAME_SIZE: |
|
| 1341 |
+ av_log(avctx, AV_LOG_ERROR, "invalid frame size\n"); |
|
| 1342 |
+ break; |
|
| 1343 |
+ case AAC_AC3_PARSE_ERROR_FRAME_TYPE: |
|
| 1344 |
+ /* skip frame if CRC is ok. otherwise use error concealment. */ |
|
| 1345 |
+ /* TODO: add support for substreams and dependent frames */ |
|
| 1346 |
+ if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {
|
|
| 1347 |
+ av_log(avctx, AV_LOG_ERROR, "unsupported frame type : " |
|
| 1348 |
+ "skipping frame\n"); |
|
| 1349 |
+ *got_frame_ptr = 0; |
|
| 1350 |
+ return s->frame_size; |
|
| 1351 |
+ } else {
|
|
| 1352 |
+ av_log(avctx, AV_LOG_ERROR, "invalid frame type\n"); |
|
| 1353 |
+ } |
|
| 1354 |
+ break; |
|
| 1355 |
+ default: |
|
| 1356 |
+ av_log(avctx, AV_LOG_ERROR, "invalid header\n"); |
|
| 1357 |
+ break; |
|
| 1357 | 1358 |
} |
| 1358 | 1359 |
} else {
|
| 1359 | 1360 |
/* check that reported frame size fits in input buffer */ |
| ... | ... |
@@ -1362,7 +1373,8 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, |
| 1362 | 1362 |
err = AAC_AC3_PARSE_ERROR_FRAME_SIZE; |
| 1363 | 1363 |
} else if (avctx->err_recognition & AV_EF_CRCCHECK) {
|
| 1364 | 1364 |
/* check for crc mismatch */ |
| 1365 |
- if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) {
|
|
| 1365 |
+ if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], |
|
| 1366 |
+ s->frame_size - 2)) {
|
|
| 1366 | 1367 |
av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n"); |
| 1367 | 1368 |
err = AAC_AC3_PARSE_ERROR_CRC; |
| 1368 | 1369 |
} |
| ... | ... |
@@ -1372,12 +1384,12 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, |
| 1372 | 1372 |
/* if frame is ok, set audio parameters */ |
| 1373 | 1373 |
if (!err) {
|
| 1374 | 1374 |
avctx->sample_rate = s->sample_rate; |
| 1375 |
- avctx->bit_rate = s->bit_rate; |
|
| 1375 |
+ avctx->bit_rate = s->bit_rate; |
|
| 1376 | 1376 |
|
| 1377 | 1377 |
/* channel config */ |
| 1378 | 1378 |
s->out_channels = s->channels; |
| 1379 |
- s->output_mode = s->channel_mode; |
|
| 1380 |
- if(s->lfe_on) |
|
| 1379 |
+ s->output_mode = s->channel_mode; |
|
| 1380 |
+ if (s->lfe_on) |
|
| 1381 | 1381 |
s->output_mode |= AC3_OUTPUT_LFEON; |
| 1382 | 1382 |
if (avctx->request_channels > 0 && avctx->request_channels <= 2 && |
| 1383 | 1383 |
avctx->request_channels < s->channels) {
|
| ... | ... |
@@ -1385,7 +1397,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, |
| 1385 | 1385 |
s->output_mode = avctx->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO; |
| 1386 | 1386 |
s->channel_layout = ff_ac3_channel_layout_tab[s->output_mode]; |
| 1387 | 1387 |
} |
| 1388 |
- avctx->channels = s->out_channels; |
|
| 1388 |
+ avctx->channels = s->out_channels; |
|
| 1389 | 1389 |
avctx->channel_layout = s->channel_layout; |
| 1390 | 1390 |
|
| 1391 | 1391 |
s->loro_center_mix_level = gain_levels[ center_levels[s-> center_mix_level]]; |
| ... | ... |
@@ -1393,13 +1405,13 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, |
| 1393 | 1393 |
s->ltrt_center_mix_level = LEVEL_MINUS_3DB; |
| 1394 | 1394 |
s->ltrt_surround_mix_level = LEVEL_MINUS_3DB; |
| 1395 | 1395 |
/* set downmixing coefficients if needed */ |
| 1396 |
- if(s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) && |
|
| 1396 |
+ if (s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) && |
|
| 1397 | 1397 |
s->fbw_channels == s->out_channels)) {
|
| 1398 | 1398 |
set_downmix_coeffs(s); |
| 1399 | 1399 |
} |
| 1400 | 1400 |
} else if (!s->out_channels) {
|
| 1401 | 1401 |
s->out_channels = avctx->channels; |
| 1402 |
- if(s->out_channels < s->channels) |
|
| 1402 |
+ if (s->out_channels < s->channels) |
|
| 1403 | 1403 |
s->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO; |
| 1404 | 1404 |
} |
| 1405 | 1405 |
/* set audio service type based on bitstream mode for AC-3 */ |
| ... | ... |
@@ -1476,19 +1488,19 @@ static const AVClass ac3_decoder_class = {
|
| 1476 | 1476 |
}; |
| 1477 | 1477 |
|
| 1478 | 1478 |
AVCodec ff_ac3_decoder = {
|
| 1479 |
- .name = "ac3", |
|
| 1480 |
- .type = AVMEDIA_TYPE_AUDIO, |
|
| 1481 |
- .id = CODEC_ID_AC3, |
|
| 1479 |
+ .name = "ac3", |
|
| 1480 |
+ .type = AVMEDIA_TYPE_AUDIO, |
|
| 1481 |
+ .id = CODEC_ID_AC3, |
|
| 1482 | 1482 |
.priv_data_size = sizeof (AC3DecodeContext), |
| 1483 |
- .init = ac3_decode_init, |
|
| 1484 |
- .close = ac3_decode_end, |
|
| 1485 |
- .decode = ac3_decode_frame, |
|
| 1486 |
- .capabilities = CODEC_CAP_DR1, |
|
| 1487 |
- .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
|
|
| 1488 |
- .sample_fmts = (const enum AVSampleFormat[]) {
|
|
| 1489 |
- AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE |
|
| 1490 |
- }, |
|
| 1491 |
- .priv_class = &ac3_decoder_class, |
|
| 1483 |
+ .init = ac3_decode_init, |
|
| 1484 |
+ .close = ac3_decode_end, |
|
| 1485 |
+ .decode = ac3_decode_frame, |
|
| 1486 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 1487 |
+ .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
|
|
| 1488 |
+ .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
|
|
| 1489 |
+ AV_SAMPLE_FMT_S16, |
|
| 1490 |
+ AV_SAMPLE_FMT_NONE }, |
|
| 1491 |
+ .priv_class = &ac3_decoder_class, |
|
| 1492 | 1492 |
}; |
| 1493 | 1493 |
|
| 1494 | 1494 |
#if CONFIG_EAC3_DECODER |
| ... | ... |
@@ -1498,19 +1510,20 @@ static const AVClass eac3_decoder_class = {
|
| 1498 | 1498 |
.option = options, |
| 1499 | 1499 |
.version = LIBAVUTIL_VERSION_INT, |
| 1500 | 1500 |
}; |
| 1501 |
+ |
|
| 1501 | 1502 |
AVCodec ff_eac3_decoder = {
|
| 1502 |
- .name = "eac3", |
|
| 1503 |
- .type = AVMEDIA_TYPE_AUDIO, |
|
| 1504 |
- .id = CODEC_ID_EAC3, |
|
| 1503 |
+ .name = "eac3", |
|
| 1504 |
+ .type = AVMEDIA_TYPE_AUDIO, |
|
| 1505 |
+ .id = CODEC_ID_EAC3, |
|
| 1505 | 1506 |
.priv_data_size = sizeof (AC3DecodeContext), |
| 1506 |
- .init = ac3_decode_init, |
|
| 1507 |
- .close = ac3_decode_end, |
|
| 1508 |
- .decode = ac3_decode_frame, |
|
| 1509 |
- .capabilities = CODEC_CAP_DR1, |
|
| 1510 |
- .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
|
|
| 1511 |
- .sample_fmts = (const enum AVSampleFormat[]) {
|
|
| 1512 |
- AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE |
|
| 1513 |
- }, |
|
| 1514 |
- .priv_class = &eac3_decoder_class, |
|
| 1507 |
+ .init = ac3_decode_init, |
|
| 1508 |
+ .close = ac3_decode_end, |
|
| 1509 |
+ .decode = ac3_decode_frame, |
|
| 1510 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 1511 |
+ .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
|
|
| 1512 |
+ .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
|
|
| 1513 |
+ AV_SAMPLE_FMT_S16, |
|
| 1514 |
+ AV_SAMPLE_FMT_NONE }, |
|
| 1515 |
+ .priv_class = &eac3_decoder_class, |
|
| 1515 | 1516 |
}; |
| 1516 | 1517 |
#endif |
| ... | ... |
@@ -66,37 +66,45 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) |
| 66 | 66 |
if (avctx->channels > 2) |
| 67 | 67 |
return -1; /* only stereo or mono =) */ |
| 68 | 68 |
|
| 69 |
- if(avctx->trellis && (unsigned)avctx->trellis > 16U){
|
|
| 69 |
+ if (avctx->trellis && (unsigned)avctx->trellis > 16U) {
|
|
| 70 | 70 |
av_log(avctx, AV_LOG_ERROR, "invalid trellis size\n"); |
| 71 | 71 |
return -1; |
| 72 | 72 |
} |
| 73 | 73 |
|
| 74 | 74 |
if (avctx->trellis) {
|
| 75 |
- int frontier = 1 << avctx->trellis; |
|
| 75 |
+ int frontier = 1 << avctx->trellis; |
|
| 76 | 76 |
int max_paths = frontier * FREEZE_INTERVAL; |
| 77 |
- FF_ALLOC_OR_GOTO(avctx, s->paths, max_paths * sizeof(*s->paths), error); |
|
| 78 |
- FF_ALLOC_OR_GOTO(avctx, s->node_buf, 2 * frontier * sizeof(*s->node_buf), error); |
|
| 79 |
- FF_ALLOC_OR_GOTO(avctx, s->nodep_buf, 2 * frontier * sizeof(*s->nodep_buf), error); |
|
| 80 |
- FF_ALLOC_OR_GOTO(avctx, s->trellis_hash, 65536 * sizeof(*s->trellis_hash), error); |
|
| 77 |
+ FF_ALLOC_OR_GOTO(avctx, s->paths, |
|
| 78 |
+ max_paths * sizeof(*s->paths), error); |
|
| 79 |
+ FF_ALLOC_OR_GOTO(avctx, s->node_buf, |
|
| 80 |
+ 2 * frontier * sizeof(*s->node_buf), error); |
|
| 81 |
+ FF_ALLOC_OR_GOTO(avctx, s->nodep_buf, |
|
| 82 |
+ 2 * frontier * sizeof(*s->nodep_buf), error); |
|
| 83 |
+ FF_ALLOC_OR_GOTO(avctx, s->trellis_hash, |
|
| 84 |
+ 65536 * sizeof(*s->trellis_hash), error); |
|
| 81 | 85 |
} |
| 82 | 86 |
|
| 83 | 87 |
avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id); |
| 84 | 88 |
|
| 85 |
- switch(avctx->codec->id) {
|
|
| 89 |
+ switch (avctx->codec->id) {
|
|
| 86 | 90 |
case CODEC_ID_ADPCM_IMA_WAV: |
| 87 |
- avctx->frame_size = (BLKSIZE - 4 * avctx->channels) * 8 / (4 * avctx->channels) + 1; /* each 16 bits sample gives one nibble */ |
|
| 88 |
- /* and we have 4 bytes per channel overhead */ |
|
| 91 |
+ /* each 16 bits sample gives one nibble |
|
| 92 |
+ and we have 4 bytes per channel overhead */ |
|
| 93 |
+ avctx->frame_size = (BLKSIZE - 4 * avctx->channels) * 8 / |
|
| 94 |
+ (4 * avctx->channels) + 1; |
|
| 95 |
+ /* seems frame_size isn't taken into account... |
|
| 96 |
+ have to buffer the samples :-( */ |
|
| 89 | 97 |
avctx->block_align = BLKSIZE; |
| 90 | 98 |
avctx->bits_per_coded_sample = 4; |
| 91 |
- /* seems frame_size isn't taken into account... have to buffer the samples :-( */ |
|
| 92 | 99 |
break; |
| 93 | 100 |
case CODEC_ID_ADPCM_IMA_QT: |
| 94 |
- avctx->frame_size = 64; |
|
| 101 |
+ avctx->frame_size = 64; |
|
| 95 | 102 |
avctx->block_align = 34 * avctx->channels; |
| 96 | 103 |
break; |
| 97 | 104 |
case CODEC_ID_ADPCM_MS: |
| 98 |
- avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 / avctx->channels + 2; /* each 16 bits sample gives one nibble */ |
|
| 99 |
- /* and we have 7 bytes per channel overhead */ |
|
| 105 |
+ /* each 16 bits sample gives one nibble |
|
| 106 |
+ and we have 7 bytes per channel overhead */ |
|
| 107 |
+ avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 / avctx->channels + 2; |
|
| 100 | 108 |
avctx->block_align = BLKSIZE; |
| 101 | 109 |
avctx->bits_per_coded_sample = 4; |
| 102 | 110 |
avctx->extradata_size = 32; |
| ... | ... |
@@ -111,14 +119,15 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) |
| 111 | 111 |
} |
| 112 | 112 |
break; |
| 113 | 113 |
case CODEC_ID_ADPCM_YAMAHA: |
| 114 |
- avctx->frame_size = BLKSIZE * avctx->channels; |
|
| 114 |
+ avctx->frame_size = BLKSIZE * avctx->channels; |
|
| 115 | 115 |
avctx->block_align = BLKSIZE; |
| 116 | 116 |
break; |
| 117 | 117 |
case CODEC_ID_ADPCM_SWF: |
| 118 | 118 |
if (avctx->sample_rate != 11025 && |
| 119 | 119 |
avctx->sample_rate != 22050 && |
| 120 | 120 |
avctx->sample_rate != 44100) {
|
| 121 |
- av_log(avctx, AV_LOG_ERROR, "Sample rate must be 11025, 22050 or 44100\n"); |
|
| 121 |
+ av_log(avctx, AV_LOG_ERROR, "Sample rate must be 11025, " |
|
| 122 |
+ "22050 or 44100\n"); |
|
| 122 | 123 |
goto error; |
| 123 | 124 |
} |
| 124 | 125 |
avctx->frame_size = 512 * (avctx->sample_rate / 11025); |
| ... | ... |
@@ -127,7 +136,7 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) |
| 127 | 127 |
goto error; |
| 128 | 128 |
} |
| 129 | 129 |
|
| 130 |
- avctx->coded_frame= avcodec_alloc_frame(); |
|
| 130 |
+ avctx->coded_frame = avcodec_alloc_frame(); |
|
| 131 | 131 |
avctx->coded_frame->key_frame= 1; |
| 132 | 132 |
|
| 133 | 133 |
return 0; |
| ... | ... |
@@ -152,19 +161,23 @@ static av_cold int adpcm_encode_close(AVCodecContext *avctx) |
| 152 | 152 |
} |
| 153 | 153 |
|
| 154 | 154 |
|
| 155 |
-static inline unsigned char adpcm_ima_compress_sample(ADPCMChannelStatus *c, short sample) |
|
| 155 |
+static inline unsigned char adpcm_ima_compress_sample(ADPCMChannelStatus *c, |
|
| 156 |
+ short sample) |
|
| 156 | 157 |
{
|
| 157 |
- int delta = sample - c->prev_sample; |
|
| 158 |
- int nibble = FFMIN(7, abs(delta)*4/ff_adpcm_step_table[c->step_index]) + (delta<0)*8; |
|
| 159 |
- c->prev_sample += ((ff_adpcm_step_table[c->step_index] * ff_adpcm_yamaha_difflookup[nibble]) / 8); |
|
| 158 |
+ int delta = sample - c->prev_sample; |
|
| 159 |
+ int nibble = FFMIN(7, abs(delta) * 4 / |
|
| 160 |
+ ff_adpcm_step_table[c->step_index]) + (delta < 0) * 8; |
|
| 161 |
+ c->prev_sample += ((ff_adpcm_step_table[c->step_index] * |
|
| 162 |
+ ff_adpcm_yamaha_difflookup[nibble]) / 8); |
|
| 160 | 163 |
c->prev_sample = av_clip_int16(c->prev_sample); |
| 161 |
- c->step_index = av_clip(c->step_index + ff_adpcm_index_table[nibble], 0, 88); |
|
| 164 |
+ c->step_index = av_clip(c->step_index + ff_adpcm_index_table[nibble], 0, 88); |
|
| 162 | 165 |
return nibble; |
| 163 | 166 |
} |
| 164 | 167 |
|
| 165 |
-static inline unsigned char adpcm_ima_qt_compress_sample(ADPCMChannelStatus *c, short sample) |
|
| 168 |
+static inline unsigned char adpcm_ima_qt_compress_sample(ADPCMChannelStatus *c, |
|
| 169 |
+ short sample) |
|
| 166 | 170 |
{
|
| 167 |
- int delta = sample - c->prev_sample; |
|
| 171 |
+ int delta = sample - c->prev_sample; |
|
| 168 | 172 |
int diff, step = ff_adpcm_step_table[c->step_index]; |
| 169 | 173 |
int nibble = 8*(delta < 0); |
| 170 | 174 |
|
| ... | ... |
@@ -173,17 +186,17 @@ static inline unsigned char adpcm_ima_qt_compress_sample(ADPCMChannelStatus *c, |
| 173 | 173 |
|
| 174 | 174 |
if (delta >= step) {
|
| 175 | 175 |
nibble |= 4; |
| 176 |
- delta -= step; |
|
| 176 |
+ delta -= step; |
|
| 177 | 177 |
} |
| 178 | 178 |
step >>= 1; |
| 179 | 179 |
if (delta >= step) {
|
| 180 | 180 |
nibble |= 2; |
| 181 |
- delta -= step; |
|
| 181 |
+ delta -= step; |
|
| 182 | 182 |
} |
| 183 | 183 |
step >>= 1; |
| 184 | 184 |
if (delta >= step) {
|
| 185 | 185 |
nibble |= 1; |
| 186 |
- delta -= step; |
|
| 186 |
+ delta -= step; |
|
| 187 | 187 |
} |
| 188 | 188 |
diff -= delta; |
| 189 | 189 |
|
| ... | ... |
@@ -193,47 +206,53 @@ static inline unsigned char adpcm_ima_qt_compress_sample(ADPCMChannelStatus *c, |
| 193 | 193 |
c->prev_sample += diff; |
| 194 | 194 |
|
| 195 | 195 |
c->prev_sample = av_clip_int16(c->prev_sample); |
| 196 |
- c->step_index = av_clip(c->step_index + ff_adpcm_index_table[nibble], 0, 88); |
|
| 196 |
+ c->step_index = av_clip(c->step_index + ff_adpcm_index_table[nibble], 0, 88); |
|
| 197 | 197 |
|
| 198 | 198 |
return nibble; |
| 199 | 199 |
} |
| 200 | 200 |
|
| 201 |
-static inline unsigned char adpcm_ms_compress_sample(ADPCMChannelStatus *c, short sample) |
|
| 201 |
+static inline unsigned char adpcm_ms_compress_sample(ADPCMChannelStatus *c, |
|
| 202 |
+ short sample) |
|
| 202 | 203 |
{
|
| 203 | 204 |
int predictor, nibble, bias; |
| 204 | 205 |
|
| 205 |
- predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 64; |
|
| 206 |
+ predictor = (((c->sample1) * (c->coeff1)) + |
|
| 207 |
+ (( c->sample2) * (c->coeff2))) / 64; |
|
| 206 | 208 |
|
| 207 |
- nibble= sample - predictor; |
|
| 208 |
- if(nibble>=0) bias= c->idelta/2; |
|
| 209 |
- else bias=-c->idelta/2; |
|
| 209 |
+ nibble = sample - predictor; |
|
| 210 |
+ if (nibble >= 0) |
|
| 211 |
+ bias = c->idelta / 2; |
|
| 212 |
+ else |
|
| 213 |
+ bias = -c->idelta / 2; |
|
| 210 | 214 |
|
| 211 |
- nibble= (nibble + bias) / c->idelta; |
|
| 212 |
- nibble= av_clip(nibble, -8, 7)&0x0F; |
|
| 215 |
+ nibble = (nibble + bias) / c->idelta; |
|
| 216 |
+ nibble = av_clip(nibble, -8, 7) & 0x0F; |
|
| 213 | 217 |
|
| 214 |
- predictor += (signed)((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->idelta; |
|
| 218 |
+ predictor += (signed)((nibble & 0x08) ? (nibble - 0x10) : nibble) * c->idelta; |
|
| 215 | 219 |
|
| 216 | 220 |
c->sample2 = c->sample1; |
| 217 | 221 |
c->sample1 = av_clip_int16(predictor); |
| 218 | 222 |
|
| 219 | 223 |
c->idelta = (ff_adpcm_AdaptationTable[(int)nibble] * c->idelta) >> 8; |
| 220 |
- if (c->idelta < 16) c->idelta = 16; |
|
| 224 |
+ if (c->idelta < 16) |
|
| 225 |
+ c->idelta = 16; |
|
| 221 | 226 |
|
| 222 | 227 |
return nibble; |
| 223 | 228 |
} |
| 224 | 229 |
|
| 225 |
-static inline unsigned char adpcm_yamaha_compress_sample(ADPCMChannelStatus *c, short sample) |
|
| 230 |
+static inline unsigned char adpcm_yamaha_compress_sample(ADPCMChannelStatus *c, |
|
| 231 |
+ short sample) |
|
| 226 | 232 |
{
|
| 227 | 233 |
int nibble, delta; |
| 228 | 234 |
|
| 229 |
- if(!c->step) {
|
|
| 235 |
+ if (!c->step) {
|
|
| 230 | 236 |
c->predictor = 0; |
| 231 |
- c->step = 127; |
|
| 237 |
+ c->step = 127; |
|
| 232 | 238 |
} |
| 233 | 239 |
|
| 234 | 240 |
delta = sample - c->predictor; |
| 235 | 241 |
|
| 236 |
- nibble = FFMIN(7, abs(delta)*4/c->step) + (delta<0)*8; |
|
| 242 |
+ nibble = FFMIN(7, abs(delta) * 4 / c->step) + (delta < 0) * 8; |
|
| 237 | 243 |
|
| 238 | 244 |
c->predictor += ((c->step * ff_adpcm_yamaha_difflookup[nibble]) / 8); |
| 239 | 245 |
c->predictor = av_clip_int16(c->predictor); |
| ... | ... |
@@ -249,57 +268,61 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples, |
| 249 | 249 |
//FIXME 6% faster if frontier is a compile-time constant |
| 250 | 250 |
ADPCMEncodeContext *s = avctx->priv_data; |
| 251 | 251 |
const int frontier = 1 << avctx->trellis; |
| 252 |
- const int stride = avctx->channels; |
|
| 253 |
- const int version = avctx->codec->id; |
|
| 254 |
- TrellisPath *paths = s->paths, *p; |
|
| 255 |
- TrellisNode *node_buf = s->node_buf; |
|
| 256 |
- TrellisNode **nodep_buf = s->nodep_buf; |
|
| 257 |
- TrellisNode **nodes = nodep_buf; // nodes[] is always sorted by .ssd |
|
| 252 |
+ const int stride = avctx->channels; |
|
| 253 |
+ const int version = avctx->codec->id; |
|
| 254 |
+ TrellisPath *paths = s->paths, *p; |
|
| 255 |
+ TrellisNode *node_buf = s->node_buf; |
|
| 256 |
+ TrellisNode **nodep_buf = s->nodep_buf; |
|
| 257 |
+ TrellisNode **nodes = nodep_buf; // nodes[] is always sorted by .ssd |
|
| 258 | 258 |
TrellisNode **nodes_next = nodep_buf + frontier; |
| 259 | 259 |
int pathn = 0, froze = -1, i, j, k, generation = 0; |
| 260 | 260 |
uint8_t *hash = s->trellis_hash; |
| 261 | 261 |
memset(hash, 0xff, 65536 * sizeof(*hash)); |
| 262 | 262 |
|
| 263 | 263 |
memset(nodep_buf, 0, 2 * frontier * sizeof(*nodep_buf)); |
| 264 |
- nodes[0] = node_buf + frontier; |
|
| 265 |
- nodes[0]->ssd = 0; |
|
| 266 |
- nodes[0]->path = 0; |
|
| 267 |
- nodes[0]->step = c->step_index; |
|
| 264 |
+ nodes[0] = node_buf + frontier; |
|
| 265 |
+ nodes[0]->ssd = 0; |
|
| 266 |
+ nodes[0]->path = 0; |
|
| 267 |
+ nodes[0]->step = c->step_index; |
|
| 268 | 268 |
nodes[0]->sample1 = c->sample1; |
| 269 | 269 |
nodes[0]->sample2 = c->sample2; |
| 270 |
- if((version == CODEC_ID_ADPCM_IMA_WAV) || (version == CODEC_ID_ADPCM_IMA_QT) || (version == CODEC_ID_ADPCM_SWF)) |
|
| 270 |
+ if (version == CODEC_ID_ADPCM_IMA_WAV || |
|
| 271 |
+ version == CODEC_ID_ADPCM_IMA_QT || |
|
| 272 |
+ version == CODEC_ID_ADPCM_SWF) |
|
| 271 | 273 |
nodes[0]->sample1 = c->prev_sample; |
| 272 |
- if(version == CODEC_ID_ADPCM_MS) |
|
| 274 |
+ if (version == CODEC_ID_ADPCM_MS) |
|
| 273 | 275 |
nodes[0]->step = c->idelta; |
| 274 |
- if(version == CODEC_ID_ADPCM_YAMAHA) {
|
|
| 275 |
- if(c->step == 0) {
|
|
| 276 |
- nodes[0]->step = 127; |
|
| 276 |
+ if (version == CODEC_ID_ADPCM_YAMAHA) {
|
|
| 277 |
+ if (c->step == 0) {
|
|
| 278 |
+ nodes[0]->step = 127; |
|
| 277 | 279 |
nodes[0]->sample1 = 0; |
| 278 | 280 |
} else {
|
| 279 |
- nodes[0]->step = c->step; |
|
| 281 |
+ nodes[0]->step = c->step; |
|
| 280 | 282 |
nodes[0]->sample1 = c->predictor; |
| 281 | 283 |
} |
| 282 | 284 |
} |
| 283 | 285 |
|
| 284 |
- for(i=0; i<n; i++) {
|
|
| 286 |
+ for (i = 0; i < n; i++) {
|
|
| 285 | 287 |
TrellisNode *t = node_buf + frontier*(i&1); |
| 286 | 288 |
TrellisNode **u; |
| 287 |
- int sample = samples[i*stride]; |
|
| 289 |
+ int sample = samples[i * stride]; |
|
| 288 | 290 |
int heap_pos = 0; |
| 289 |
- memset(nodes_next, 0, frontier*sizeof(TrellisNode*)); |
|
| 290 |
- for(j=0; j<frontier && nodes[j]; j++) {
|
|
| 291 |
- // higher j have higher ssd already, so they're likely to yield a suboptimal next sample too |
|
| 292 |
- const int range = (j < frontier/2) ? 1 : 0; |
|
| 293 |
- const int step = nodes[j]->step; |
|
| 291 |
+ memset(nodes_next, 0, frontier * sizeof(TrellisNode*)); |
|
| 292 |
+ for (j = 0; j < frontier && nodes[j]; j++) {
|
|
| 293 |
+ // higher j have higher ssd already, so they're likely |
|
| 294 |
+ // to yield a suboptimal next sample too |
|
| 295 |
+ const int range = (j < frontier / 2) ? 1 : 0; |
|
| 296 |
+ const int step = nodes[j]->step; |
|
| 294 | 297 |
int nidx; |
| 295 |
- if(version == CODEC_ID_ADPCM_MS) {
|
|
| 296 |
- const int predictor = ((nodes[j]->sample1 * c->coeff1) + (nodes[j]->sample2 * c->coeff2)) / 64; |
|
| 297 |
- const int div = (sample - predictor) / step; |
|
| 298 |
+ if (version == CODEC_ID_ADPCM_MS) {
|
|
| 299 |
+ const int predictor = ((nodes[j]->sample1 * c->coeff1) + |
|
| 300 |
+ (nodes[j]->sample2 * c->coeff2)) / 64; |
|
| 301 |
+ const int div = (sample - predictor) / step; |
|
| 298 | 302 |
const int nmin = av_clip(div-range, -8, 6); |
| 299 | 303 |
const int nmax = av_clip(div+range, -7, 7); |
| 300 |
- for(nidx=nmin; nidx<=nmax; nidx++) {
|
|
| 304 |
+ for (nidx = nmin; nidx <= nmax; nidx++) {
|
|
| 301 | 305 |
const int nibble = nidx & 0xf; |
| 302 |
- int dec_sample = predictor + nidx * step; |
|
| 306 |
+ int dec_sample = predictor + nidx * step; |
|
| 303 | 307 |
#define STORE_NODE(NAME, STEP_INDEX)\ |
| 304 | 308 |
int d;\ |
| 305 | 309 |
uint32_t ssd;\ |
| ... | ... |
@@ -334,25 +357,26 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples, |
| 334 | 334 |
} else {\
|
| 335 | 335 |
/* Try to replace one of the leaf nodes with the new \ |
| 336 | 336 |
* one, but try a different slot each time. */\ |
| 337 |
- pos = (frontier >> 1) + (heap_pos & ((frontier >> 1) - 1));\ |
|
| 337 |
+ pos = (frontier >> 1) +\ |
|
| 338 |
+ (heap_pos & ((frontier >> 1) - 1));\ |
|
| 338 | 339 |
if (ssd > nodes_next[pos]->ssd)\ |
| 339 | 340 |
goto next_##NAME;\ |
| 340 | 341 |
heap_pos++;\ |
| 341 | 342 |
}\ |
| 342 | 343 |
*h = generation;\ |
| 343 |
- u = nodes_next[pos];\ |
|
| 344 |
- if(!u) {\
|
|
| 345 |
- assert(pathn < FREEZE_INTERVAL<<avctx->trellis);\ |
|
| 344 |
+ u = nodes_next[pos];\ |
|
| 345 |
+ if (!u) {\
|
|
| 346 |
+ assert(pathn < FREEZE_INTERVAL << avctx->trellis);\ |
|
| 346 | 347 |
u = t++;\ |
| 347 | 348 |
nodes_next[pos] = u;\ |
| 348 | 349 |
u->path = pathn++;\ |
| 349 | 350 |
}\ |
| 350 |
- u->ssd = ssd;\ |
|
| 351 |
+ u->ssd = ssd;\ |
|
| 351 | 352 |
u->step = STEP_INDEX;\ |
| 352 | 353 |
u->sample2 = nodes[j]->sample1;\ |
| 353 | 354 |
u->sample1 = dec_sample;\ |
| 354 | 355 |
paths[u->path].nibble = nibble;\ |
| 355 |
- paths[u->path].prev = nodes[j]->path;\ |
|
| 356 |
+ paths[u->path].prev = nodes[j]->path;\ |
|
| 356 | 357 |
/* Sift the newly inserted node up in the heap to \ |
| 357 | 358 |
* restore the heap property. */\ |
| 358 | 359 |
while (pos > 0) {\
|
| ... | ... |
@@ -363,24 +387,34 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples, |
| 363 | 363 |
pos = parent;\ |
| 364 | 364 |
}\ |
| 365 | 365 |
next_##NAME:; |
| 366 |
- STORE_NODE(ms, FFMAX(16, (ff_adpcm_AdaptationTable[nibble] * step) >> 8)); |
|
| 366 |
+ STORE_NODE(ms, FFMAX(16, |
|
| 367 |
+ (ff_adpcm_AdaptationTable[nibble] * step) >> 8)); |
|
| 367 | 368 |
} |
| 368 |
- } else if((version == CODEC_ID_ADPCM_IMA_WAV)|| (version == CODEC_ID_ADPCM_IMA_QT)|| (version == CODEC_ID_ADPCM_SWF)) {
|
|
| 369 |
+ } else if (version == CODEC_ID_ADPCM_IMA_WAV || |
|
| 370 |
+ version == CODEC_ID_ADPCM_IMA_QT || |
|
| 371 |
+ version == CODEC_ID_ADPCM_SWF) {
|
|
| 369 | 372 |
#define LOOP_NODES(NAME, STEP_TABLE, STEP_INDEX)\ |
| 370 | 373 |
const int predictor = nodes[j]->sample1;\ |
| 371 | 374 |
const int div = (sample - predictor) * 4 / STEP_TABLE;\ |
| 372 |
- int nmin = av_clip(div-range, -7, 6);\ |
|
| 373 |
- int nmax = av_clip(div+range, -6, 7);\ |
|
| 374 |
- if(nmin<=0) nmin--; /* distinguish -0 from +0 */\ |
|
| 375 |
- if(nmax<0) nmax--;\ |
|
| 376 |
- for(nidx=nmin; nidx<=nmax; nidx++) {\
|
|
| 377 |
- const int nibble = nidx<0 ? 7-nidx : nidx;\ |
|
| 378 |
- int dec_sample = predictor + (STEP_TABLE * ff_adpcm_yamaha_difflookup[nibble]) / 8;\ |
|
| 375 |
+ int nmin = av_clip(div - range, -7, 6);\ |
|
| 376 |
+ int nmax = av_clip(div + range, -6, 7);\ |
|
| 377 |
+ if (nmin <= 0)\ |
|
| 378 |
+ nmin--; /* distinguish -0 from +0 */\ |
|
| 379 |
+ if (nmax < 0)\ |
|
| 380 |
+ nmax--;\ |
|
| 381 |
+ for (nidx = nmin; nidx <= nmax; nidx++) {\
|
|
| 382 |
+ const int nibble = nidx < 0 ? 7 - nidx : nidx;\ |
|
| 383 |
+ int dec_sample = predictor +\ |
|
| 384 |
+ (STEP_TABLE *\ |
|
| 385 |
+ ff_adpcm_yamaha_difflookup[nibble]) / 8;\ |
|
| 379 | 386 |
STORE_NODE(NAME, STEP_INDEX);\ |
| 380 | 387 |
} |
| 381 |
- LOOP_NODES(ima, ff_adpcm_step_table[step], av_clip(step + ff_adpcm_index_table[nibble], 0, 88)); |
|
| 388 |
+ LOOP_NODES(ima, ff_adpcm_step_table[step], |
|
| 389 |
+ av_clip(step + ff_adpcm_index_table[nibble], 0, 88)); |
|
| 382 | 390 |
} else { //CODEC_ID_ADPCM_YAMAHA
|
| 383 |
- LOOP_NODES(yamaha, step, av_clip((step * ff_adpcm_yamaha_indexscale[nibble]) >> 8, 127, 24567)); |
|
| 391 |
+ LOOP_NODES(yamaha, step, |
|
| 392 |
+ av_clip((step * ff_adpcm_yamaha_indexscale[nibble]) >> 8, |
|
| 393 |
+ 127, 24567)); |
|
| 384 | 394 |
#undef LOOP_NODES |
| 385 | 395 |
#undef STORE_NODE |
| 386 | 396 |
} |
| ... | ... |
@@ -397,16 +431,16 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples, |
| 397 | 397 |
} |
| 398 | 398 |
|
| 399 | 399 |
// prevent overflow |
| 400 |
- if(nodes[0]->ssd > (1<<28)) {
|
|
| 401 |
- for(j=1; j<frontier && nodes[j]; j++) |
|
| 400 |
+ if (nodes[0]->ssd > (1 << 28)) {
|
|
| 401 |
+ for (j = 1; j < frontier && nodes[j]; j++) |
|
| 402 | 402 |
nodes[j]->ssd -= nodes[0]->ssd; |
| 403 | 403 |
nodes[0]->ssd = 0; |
| 404 | 404 |
} |
| 405 | 405 |
|
| 406 | 406 |
// merge old paths to save memory |
| 407 |
- if(i == froze + FREEZE_INTERVAL) {
|
|
| 407 |
+ if (i == froze + FREEZE_INTERVAL) {
|
|
| 408 | 408 |
p = &paths[nodes[0]->path]; |
| 409 |
- for(k=i; k>froze; k--) {
|
|
| 409 |
+ for (k = i; k > froze; k--) {
|
|
| 410 | 410 |
dst[k] = p->nibble; |
| 411 | 411 |
p = &paths[p->prev]; |
| 412 | 412 |
} |
| ... | ... |
@@ -415,26 +449,26 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples, |
| 415 | 415 |
// other nodes might use paths that don't coincide with the frozen one. |
| 416 | 416 |
// checking which nodes do so is too slow, so just kill them all. |
| 417 | 417 |
// this also slightly improves quality, but I don't know why. |
| 418 |
- memset(nodes+1, 0, (frontier-1)*sizeof(TrellisNode*)); |
|
| 418 |
+ memset(nodes + 1, 0, (frontier - 1) * sizeof(TrellisNode*)); |
|
| 419 | 419 |
} |
| 420 | 420 |
} |
| 421 | 421 |
|
| 422 | 422 |
p = &paths[nodes[0]->path]; |
| 423 |
- for(i=n-1; i>froze; i--) {
|
|
| 423 |
+ for (i = n - 1; i > froze; i--) {
|
|
| 424 | 424 |
dst[i] = p->nibble; |
| 425 | 425 |
p = &paths[p->prev]; |
| 426 | 426 |
} |
| 427 | 427 |
|
| 428 |
- c->predictor = nodes[0]->sample1; |
|
| 429 |
- c->sample1 = nodes[0]->sample1; |
|
| 430 |
- c->sample2 = nodes[0]->sample2; |
|
| 428 |
+ c->predictor = nodes[0]->sample1; |
|
| 429 |
+ c->sample1 = nodes[0]->sample1; |
|
| 430 |
+ c->sample2 = nodes[0]->sample2; |
|
| 431 | 431 |
c->step_index = nodes[0]->step; |
| 432 |
- c->step = nodes[0]->step; |
|
| 433 |
- c->idelta = nodes[0]->step; |
|
| 432 |
+ c->step = nodes[0]->step; |
|
| 433 |
+ c->idelta = nodes[0]->step; |
|
| 434 | 434 |
} |
| 435 | 435 |
|
| 436 | 436 |
static int adpcm_encode_frame(AVCodecContext *avctx, |
| 437 |
- unsigned char *frame, int buf_size, void *data) |
|
| 437 |
+ unsigned char *frame, int buf_size, void *data) |
|
| 438 | 438 |
{
|
| 439 | 439 |
int n, i, st; |
| 440 | 440 |
short *samples; |
| ... | ... |
@@ -444,98 +478,96 @@ static int adpcm_encode_frame(AVCodecContext *avctx, |
| 444 | 444 |
|
| 445 | 445 |
dst = frame; |
| 446 | 446 |
samples = (short *)data; |
| 447 |
- st= avctx->channels == 2; |
|
| 448 |
-/* n = (BLKSIZE - 4 * avctx->channels) / (2 * 8 * avctx->channels); */ |
|
| 447 |
+ st = avctx->channels == 2; |
|
| 448 |
+ /* n = (BLKSIZE - 4 * avctx->channels) / (2 * 8 * avctx->channels); */ |
|
| 449 | 449 |
|
| 450 | 450 |
switch(avctx->codec->id) {
|
| 451 | 451 |
case CODEC_ID_ADPCM_IMA_WAV: |
| 452 | 452 |
n = avctx->frame_size / 8; |
| 453 |
- c->status[0].prev_sample = (signed short)samples[0]; /* XXX */ |
|
| 454 |
-/* c->status[0].step_index = 0; *//* XXX: not sure how to init the state machine */ |
|
| 455 |
- bytestream_put_le16(&dst, c->status[0].prev_sample); |
|
| 456 |
- *dst++ = (unsigned char)c->status[0].step_index; |
|
| 457 |
- *dst++ = 0; /* unknown */ |
|
| 453 |
+ c->status[0].prev_sample = (signed short)samples[0]; /* XXX */ |
|
| 454 |
+ /* c->status[0].step_index = 0; |
|
| 455 |
+ XXX: not sure how to init the state machine */ |
|
| 456 |
+ bytestream_put_le16(&dst, c->status[0].prev_sample); |
|
| 457 |
+ *dst++ = (unsigned char)c->status[0].step_index; |
|
| 458 |
+ *dst++ = 0; /* unknown */ |
|
| 459 |
+ samples++; |
|
| 460 |
+ if (avctx->channels == 2) {
|
|
| 461 |
+ c->status[1].prev_sample = (signed short)samples[0]; |
|
| 462 |
+ /* c->status[1].step_index = 0; */ |
|
| 463 |
+ bytestream_put_le16(&dst, c->status[1].prev_sample); |
|
| 464 |
+ *dst++ = (unsigned char)c->status[1].step_index; |
|
| 465 |
+ *dst++ = 0; |
|
| 458 | 466 |
samples++; |
| 459 |
- if (avctx->channels == 2) {
|
|
| 460 |
- c->status[1].prev_sample = (signed short)samples[0]; |
|
| 461 |
-/* c->status[1].step_index = 0; */ |
|
| 462 |
- bytestream_put_le16(&dst, c->status[1].prev_sample); |
|
| 463 |
- *dst++ = (unsigned char)c->status[1].step_index; |
|
| 464 |
- *dst++ = 0; |
|
| 465 |
- samples++; |
|
| 466 |
- } |
|
| 467 |
+ } |
|
| 467 | 468 |
|
| 468 |
- /* stereo: 4 bytes (8 samples) for left, 4 bytes for right, 4 bytes left, ... */ |
|
| 469 |
- if(avctx->trellis > 0) {
|
|
| 470 |
- FF_ALLOC_OR_GOTO(avctx, buf, 2*n*8, error); |
|
| 471 |
- adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n*8); |
|
| 472 |
- if(avctx->channels == 2) |
|
| 473 |
- adpcm_compress_trellis(avctx, samples+1, buf + n*8, &c->status[1], n*8); |
|
| 474 |
- for(i=0; i<n; i++) {
|
|
| 475 |
- *dst++ = buf[8*i+0] | (buf[8*i+1] << 4); |
|
| 476 |
- *dst++ = buf[8*i+2] | (buf[8*i+3] << 4); |
|
| 477 |
- *dst++ = buf[8*i+4] | (buf[8*i+5] << 4); |
|
| 478 |
- *dst++ = buf[8*i+6] | (buf[8*i+7] << 4); |
|
| 479 |
- if (avctx->channels == 2) {
|
|
| 480 |
- uint8_t *buf1 = buf + n*8; |
|
| 481 |
- *dst++ = buf1[8*i+0] | (buf1[8*i+1] << 4); |
|
| 482 |
- *dst++ = buf1[8*i+2] | (buf1[8*i+3] << 4); |
|
| 483 |
- *dst++ = buf1[8*i+4] | (buf1[8*i+5] << 4); |
|
| 484 |
- *dst++ = buf1[8*i+6] | (buf1[8*i+7] << 4); |
|
| 485 |
- } |
|
| 469 |
+ /* stereo: 4 bytes (8 samples) for left, |
|
| 470 |
+ 4 bytes for right, 4 bytes left, ... */ |
|
| 471 |
+ if (avctx->trellis > 0) {
|
|
| 472 |
+ FF_ALLOC_OR_GOTO(avctx, buf, 2 * n * 8, error); |
|
| 473 |
+ adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n * 8); |
|
| 474 |
+ if (avctx->channels == 2) |
|
| 475 |
+ adpcm_compress_trellis(avctx, samples + 1, buf + n * 8, |
|
| 476 |
+ &c->status[1], n * 8); |
|
| 477 |
+ for (i = 0; i < n; i++) {
|
|
| 478 |
+ *dst++ = buf[8 * i + 0] | (buf[8 * i + 1] << 4); |
|
| 479 |
+ *dst++ = buf[8 * i + 2] | (buf[8 * i + 3] << 4); |
|
| 480 |
+ *dst++ = buf[8 * i + 4] | (buf[8 * i + 5] << 4); |
|
| 481 |
+ *dst++ = buf[8 * i + 6] | (buf[8 * i + 7] << 4); |
|
| 482 |
+ if (avctx->channels == 2) {
|
|
| 483 |
+ uint8_t *buf1 = buf + n * 8; |
|
| 484 |
+ *dst++ = buf1[8 * i + 0] | (buf1[8 * i + 1] << 4); |
|
| 485 |
+ *dst++ = buf1[8 * i + 2] | (buf1[8 * i + 3] << 4); |
|
| 486 |
+ *dst++ = buf1[8 * i + 4] | (buf1[8 * i + 5] << 4); |
|
| 487 |
+ *dst++ = buf1[8 * i + 6] | (buf1[8 * i + 7] << 4); |
|
| 486 | 488 |
} |
| 487 |
- av_free(buf); |
|
| 488 |
- } else |
|
| 489 |
- for (; n>0; n--) {
|
|
| 490 |
- *dst = adpcm_ima_compress_sample(&c->status[0], samples[0]); |
|
| 491 |
- *dst |= adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels]) << 4; |
|
| 492 |
- dst++; |
|
| 493 |
- *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 2]); |
|
| 494 |
- *dst |= adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 3]) << 4; |
|
| 495 |
- dst++; |
|
| 496 |
- *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 4]); |
|
| 497 |
- *dst |= adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 5]) << 4; |
|
| 498 |
- dst++; |
|
| 499 |
- *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 6]); |
|
| 500 |
- *dst |= adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 7]) << 4; |
|
| 501 |
- dst++; |
|
| 489 |
+ } |
|
| 490 |
+ av_free(buf); |
|
| 491 |
+ } else {
|
|
| 492 |
+ for (; n > 0; n--) {
|
|
| 493 |
+ *dst = adpcm_ima_compress_sample(&c->status[0], samples[0]); |
|
| 494 |
+ *dst++ |= adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels ]) << 4; |
|
| 495 |
+ *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 2]); |
|
| 496 |
+ *dst++ |= adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 3]) << 4; |
|
| 497 |
+ *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 4]); |
|
| 498 |
+ *dst++ |= adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 5]) << 4; |
|
| 499 |
+ *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 6]); |
|
| 500 |
+ *dst++ |= adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 7]) << 4; |
|
| 502 | 501 |
/* right channel */ |
| 503 | 502 |
if (avctx->channels == 2) {
|
| 504 |
- *dst = adpcm_ima_compress_sample(&c->status[1], samples[1]); |
|
| 505 |
- *dst |= adpcm_ima_compress_sample(&c->status[1], samples[3]) << 4; |
|
| 506 |
- dst++; |
|
| 507 |
- *dst = adpcm_ima_compress_sample(&c->status[1], samples[5]); |
|
| 508 |
- *dst |= adpcm_ima_compress_sample(&c->status[1], samples[7]) << 4; |
|
| 509 |
- dst++; |
|
| 510 |
- *dst = adpcm_ima_compress_sample(&c->status[1], samples[9]); |
|
| 511 |
- *dst |= adpcm_ima_compress_sample(&c->status[1], samples[11]) << 4; |
|
| 512 |
- dst++; |
|
| 513 |
- *dst = adpcm_ima_compress_sample(&c->status[1], samples[13]); |
|
| 514 |
- *dst |= adpcm_ima_compress_sample(&c->status[1], samples[15]) << 4; |
|
| 515 |
- dst++; |
|
| 503 |
+ *dst = adpcm_ima_compress_sample(&c->status[1], samples[1 ]); |
|
| 504 |
+ *dst++ |= adpcm_ima_compress_sample(&c->status[1], samples[3 ]) << 4; |
|
| 505 |
+ *dst = adpcm_ima_compress_sample(&c->status[1], samples[5 ]); |
|
| 506 |
+ *dst++ |= adpcm_ima_compress_sample(&c->status[1], samples[7 ]) << 4; |
|
| 507 |
+ *dst = adpcm_ima_compress_sample(&c->status[1], samples[9 ]); |
|
| 508 |
+ *dst++ |= adpcm_ima_compress_sample(&c->status[1], samples[11]) << 4; |
|
| 509 |
+ *dst = adpcm_ima_compress_sample(&c->status[1], samples[13]); |
|
| 510 |
+ *dst++ |= adpcm_ima_compress_sample(&c->status[1], samples[15]) << 4; |
|
| 516 | 511 |
} |
| 517 | 512 |
samples += 8 * avctx->channels; |
| 518 | 513 |
} |
| 514 |
+ } |
|
| 519 | 515 |
break; |
| 520 | 516 |
case CODEC_ID_ADPCM_IMA_QT: |
| 521 | 517 |
{
|
| 522 | 518 |
int ch, i; |
| 523 | 519 |
PutBitContext pb; |
| 524 |
- init_put_bits(&pb, dst, buf_size*8); |
|
| 520 |
+ init_put_bits(&pb, dst, buf_size * 8); |
|
| 525 | 521 |
|
| 526 |
- for(ch=0; ch<avctx->channels; ch++){
|
|
| 522 |
+ for (ch = 0; ch < avctx->channels; ch++) {
|
|
| 527 | 523 |
put_bits(&pb, 9, (c->status[ch].prev_sample + 0x10000) >> 7); |
| 528 |
- put_bits(&pb, 7, c->status[ch].step_index); |
|
| 529 |
- if(avctx->trellis > 0) {
|
|
| 524 |
+ put_bits(&pb, 7, c->status[ch].step_index); |
|
| 525 |
+ if (avctx->trellis > 0) {
|
|
| 530 | 526 |
uint8_t buf[64]; |
| 531 | 527 |
adpcm_compress_trellis(avctx, samples+ch, buf, &c->status[ch], 64); |
| 532 |
- for(i=0; i<64; i++) |
|
| 533 |
- put_bits(&pb, 4, buf[i^1]); |
|
| 528 |
+ for (i = 0; i < 64; i++) |
|
| 529 |
+ put_bits(&pb, 4, buf[i ^ 1]); |
|
| 534 | 530 |
} else {
|
| 535 |
- for (i=0; i<64; i+=2){
|
|
| 531 |
+ for (i = 0; i < 64; i += 2) {
|
|
| 536 | 532 |
int t1, t2; |
| 537 |
- t1 = adpcm_ima_qt_compress_sample(&c->status[ch], samples[avctx->channels*(i+0)+ch]); |
|
| 538 |
- t2 = adpcm_ima_qt_compress_sample(&c->status[ch], samples[avctx->channels*(i+1)+ch]); |
|
| 533 |
+ t1 = adpcm_ima_qt_compress_sample(&c->status[ch], |
|
| 534 |
+ samples[avctx->channels * (i + 0) + ch]); |
|
| 535 |
+ t2 = adpcm_ima_qt_compress_sample(&c->status[ch], |
|
| 536 |
+ samples[avctx->channels * (i + 1) + ch]); |
|
| 539 | 537 |
put_bits(&pb, 4, t2); |
| 540 | 538 |
put_bits(&pb, 4, t1); |
| 541 | 539 |
} |
| ... | ... |
@@ -543,119 +575,120 @@ static int adpcm_encode_frame(AVCodecContext *avctx, |
| 543 | 543 |
} |
| 544 | 544 |
|
| 545 | 545 |
flush_put_bits(&pb); |
| 546 |
- dst += put_bits_count(&pb)>>3; |
|
| 546 |
+ dst += put_bits_count(&pb) >> 3; |
|
| 547 | 547 |
break; |
| 548 | 548 |
} |
| 549 | 549 |
case CODEC_ID_ADPCM_SWF: |
| 550 | 550 |
{
|
| 551 | 551 |
int i; |
| 552 | 552 |
PutBitContext pb; |
| 553 |
- init_put_bits(&pb, dst, buf_size*8); |
|
| 553 |
+ init_put_bits(&pb, dst, buf_size * 8); |
|
| 554 | 554 |
|
| 555 |
- n = avctx->frame_size-1; |
|
| 555 |
+ n = avctx->frame_size - 1; |
|
| 556 | 556 |
|
| 557 |
- //Store AdpcmCodeSize |
|
| 558 |
- put_bits(&pb, 2, 2); //Set 4bits flash adpcm format |
|
| 557 |
+ // store AdpcmCodeSize |
|
| 558 |
+ put_bits(&pb, 2, 2); // set 4-bit flash adpcm format |
|
| 559 | 559 |
|
| 560 |
- //Init the encoder state |
|
| 561 |
- for(i=0; i<avctx->channels; i++){
|
|
| 562 |
- c->status[i].step_index = av_clip(c->status[i].step_index, 0, 63); // clip step so it fits 6 bits |
|
| 560 |
+ // init the encoder state |
|
| 561 |
+ for (i = 0; i < avctx->channels; i++) {
|
|
| 562 |
+ // clip step so it fits 6 bits |
|
| 563 |
+ c->status[i].step_index = av_clip(c->status[i].step_index, 0, 63); |
|
| 563 | 564 |
put_sbits(&pb, 16, samples[i]); |
| 564 | 565 |
put_bits(&pb, 6, c->status[i].step_index); |
| 565 | 566 |
c->status[i].prev_sample = (signed short)samples[i]; |
| 566 | 567 |
} |
| 567 | 568 |
|
| 568 |
- if(avctx->trellis > 0) {
|
|
| 569 |
- FF_ALLOC_OR_GOTO(avctx, buf, 2*n, error); |
|
| 570 |
- adpcm_compress_trellis(avctx, samples+2, buf, &c->status[0], n); |
|
| 569 |
+ if (avctx->trellis > 0) {
|
|
| 570 |
+ FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error); |
|
| 571 |
+ adpcm_compress_trellis(avctx, samples + 2, buf, &c->status[0], n); |
|
| 571 | 572 |
if (avctx->channels == 2) |
| 572 |
- adpcm_compress_trellis(avctx, samples+3, buf+n, &c->status[1], n); |
|
| 573 |
- for(i=0; i<n; i++) {
|
|
| 573 |
+ adpcm_compress_trellis(avctx, samples + 3, buf + n, |
|
| 574 |
+ &c->status[1], n); |
|
| 575 |
+ for (i = 0; i < n; i++) {
|
|
| 574 | 576 |
put_bits(&pb, 4, buf[i]); |
| 575 | 577 |
if (avctx->channels == 2) |
| 576 |
- put_bits(&pb, 4, buf[n+i]); |
|
| 578 |
+ put_bits(&pb, 4, buf[n + i]); |
|
| 577 | 579 |
} |
| 578 | 580 |
av_free(buf); |
| 579 | 581 |
} else {
|
| 580 |
- for (i=1; i<avctx->frame_size; i++) {
|
|
| 581 |
- put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels*i])); |
|
| 582 |
+ for (i = 1; i < avctx->frame_size; i++) {
|
|
| 583 |
+ put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[0], |
|
| 584 |
+ samples[avctx->channels * i])); |
|
| 582 | 585 |
if (avctx->channels == 2) |
| 583 |
- put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[1], samples[2*i+1])); |
|
| 586 |
+ put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[1], |
|
| 587 |
+ samples[2 * i + 1])); |
|
| 584 | 588 |
} |
| 585 | 589 |
} |
| 586 | 590 |
flush_put_bits(&pb); |
| 587 |
- dst += put_bits_count(&pb)>>3; |
|
| 591 |
+ dst += put_bits_count(&pb) >> 3; |
|
| 588 | 592 |
break; |
| 589 | 593 |
} |
| 590 | 594 |
case CODEC_ID_ADPCM_MS: |
| 591 |
- for(i=0; i<avctx->channels; i++){
|
|
| 592 |
- int predictor=0; |
|
| 593 |
- |
|
| 595 |
+ for (i = 0; i < avctx->channels; i++) {
|
|
| 596 |
+ int predictor = 0; |
|
| 594 | 597 |
*dst++ = predictor; |
| 595 | 598 |
c->status[i].coeff1 = ff_adpcm_AdaptCoeff1[predictor]; |
| 596 | 599 |
c->status[i].coeff2 = ff_adpcm_AdaptCoeff2[predictor]; |
| 597 | 600 |
} |
| 598 |
- for(i=0; i<avctx->channels; i++){
|
|
| 601 |
+ for (i = 0; i < avctx->channels; i++) {
|
|
| 599 | 602 |
if (c->status[i].idelta < 16) |
| 600 | 603 |
c->status[i].idelta = 16; |
| 601 |
- |
|
| 602 | 604 |
bytestream_put_le16(&dst, c->status[i].idelta); |
| 603 | 605 |
} |
| 604 |
- for(i=0; i<avctx->channels; i++){
|
|
| 606 |
+ for (i = 0; i < avctx->channels; i++) |
|
| 605 | 607 |
c->status[i].sample2= *samples++; |
| 606 |
- } |
|
| 607 |
- for(i=0; i<avctx->channels; i++){
|
|
| 608 |
- c->status[i].sample1= *samples++; |
|
| 609 |
- |
|
| 608 |
+ for (i = 0; i < avctx->channels; i++) {
|
|
| 609 |
+ c->status[i].sample1 = *samples++; |
|
| 610 | 610 |
bytestream_put_le16(&dst, c->status[i].sample1); |
| 611 | 611 |
} |
| 612 |
- for(i=0; i<avctx->channels; i++) |
|
| 612 |
+ for (i = 0; i < avctx->channels; i++) |
|
| 613 | 613 |
bytestream_put_le16(&dst, c->status[i].sample2); |
| 614 | 614 |
|
| 615 |
- if(avctx->trellis > 0) {
|
|
| 616 |
- int n = avctx->block_align - 7*avctx->channels; |
|
| 617 |
- FF_ALLOC_OR_GOTO(avctx, buf, 2*n, error); |
|
| 618 |
- if(avctx->channels == 1) {
|
|
| 615 |
+ if (avctx->trellis > 0) {
|
|
| 616 |
+ int n = avctx->block_align - 7 * avctx->channels; |
|
| 617 |
+ FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error); |
|
| 618 |
+ if (avctx->channels == 1) {
|
|
| 619 | 619 |
adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n); |
| 620 |
- for(i=0; i<n; i+=2) |
|
| 621 |
- *dst++ = (buf[i] << 4) | buf[i+1]; |
|
| 620 |
+ for (i = 0; i < n; i += 2) |
|
| 621 |
+ *dst++ = (buf[i] << 4) | buf[i + 1]; |
|
| 622 | 622 |
} else {
|
| 623 |
- adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n); |
|
| 624 |
- adpcm_compress_trellis(avctx, samples+1, buf+n, &c->status[1], n); |
|
| 625 |
- for(i=0; i<n; i++) |
|
| 626 |
- *dst++ = (buf[i] << 4) | buf[n+i]; |
|
| 623 |
+ adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n); |
|
| 624 |
+ adpcm_compress_trellis(avctx, samples + 1, buf + n, &c->status[1], n); |
|
| 625 |
+ for (i = 0; i < n; i++) |
|
| 626 |
+ *dst++ = (buf[i] << 4) | buf[n + i]; |
|
| 627 | 627 |
} |
| 628 | 628 |
av_free(buf); |
| 629 |
- } else |
|
| 630 |
- for(i=7*avctx->channels; i<avctx->block_align; i++) {
|
|
| 631 |
- int nibble; |
|
| 632 |
- nibble = adpcm_ms_compress_sample(&c->status[ 0], *samples++)<<4; |
|
| 633 |
- nibble|= adpcm_ms_compress_sample(&c->status[st], *samples++); |
|
| 634 |
- *dst++ = nibble; |
|
| 629 |
+ } else {
|
|
| 630 |
+ for (i = 7 * avctx->channels; i < avctx->block_align; i++) {
|
|
| 631 |
+ int nibble; |
|
| 632 |
+ nibble = adpcm_ms_compress_sample(&c->status[ 0], *samples++) << 4; |
|
| 633 |
+ nibble |= adpcm_ms_compress_sample(&c->status[st], *samples++); |
|
| 634 |
+ *dst++ = nibble; |
|
| 635 |
+ } |
|
| 635 | 636 |
} |
| 636 | 637 |
break; |
| 637 | 638 |
case CODEC_ID_ADPCM_YAMAHA: |
| 638 | 639 |
n = avctx->frame_size / 2; |
| 639 |
- if(avctx->trellis > 0) {
|
|
| 640 |
- FF_ALLOC_OR_GOTO(avctx, buf, 2*n*2, error); |
|
| 640 |
+ if (avctx->trellis > 0) {
|
|
| 641 |
+ FF_ALLOC_OR_GOTO(avctx, buf, 2 * n * 2, error); |
|
| 641 | 642 |
n *= 2; |
| 642 |
- if(avctx->channels == 1) {
|
|
| 643 |
+ if (avctx->channels == 1) {
|
|
| 643 | 644 |
adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n); |
| 644 |
- for(i=0; i<n; i+=2) |
|
| 645 |
- *dst++ = buf[i] | (buf[i+1] << 4); |
|
| 645 |
+ for (i = 0; i < n; i += 2) |
|
| 646 |
+ *dst++ = buf[i] | (buf[i + 1] << 4); |
|
| 646 | 647 |
} else {
|
| 647 |
- adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n); |
|
| 648 |
- adpcm_compress_trellis(avctx, samples+1, buf+n, &c->status[1], n); |
|
| 649 |
- for(i=0; i<n; i++) |
|
| 650 |
- *dst++ = buf[i] | (buf[n+i] << 4); |
|
| 648 |
+ adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n); |
|
| 649 |
+ adpcm_compress_trellis(avctx, samples + 1, buf + n, &c->status[1], n); |
|
| 650 |
+ for (i = 0; i < n; i++) |
|
| 651 |
+ *dst++ = buf[i] | (buf[n + i] << 4); |
|
| 651 | 652 |
} |
| 652 | 653 |
av_free(buf); |
| 653 | 654 |
} else |
| 654 |
- for (n *= avctx->channels; n>0; n--) {
|
|
| 655 |
+ for (n *= avctx->channels; n > 0; n--) {
|
|
| 655 | 656 |
int nibble; |
| 656 | 657 |
nibble = adpcm_yamaha_compress_sample(&c->status[ 0], *samples++); |
| 657 | 658 |
nibble |= adpcm_yamaha_compress_sample(&c->status[st], *samples++) << 4; |
| 658 |
- *dst++ = nibble; |
|
| 659 |
+ *dst++ = nibble; |
|
| 659 | 660 |
} |
| 660 | 661 |
break; |
| 661 | 662 |
default: |
| ... | ... |
@@ -675,12 +708,13 @@ AVCodec ff_ ## name_ ## _encoder = { \
|
| 675 | 675 |
.init = adpcm_encode_init, \ |
| 676 | 676 |
.encode = adpcm_encode_frame, \ |
| 677 | 677 |
.close = adpcm_encode_close, \ |
| 678 |
- .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, \
|
|
| 678 |
+ .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, \
|
|
| 679 |
+ AV_SAMPLE_FMT_NONE}, \ |
|
| 679 | 680 |
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \ |
| 680 | 681 |
} |
| 681 | 682 |
|
| 682 |
-ADPCM_ENCODER(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt, "ADPCM IMA QuickTime"); |
|
| 683 |
+ADPCM_ENCODER(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt, "ADPCM IMA QuickTime"); |
|
| 683 | 684 |
ADPCM_ENCODER(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav, "ADPCM IMA WAV"); |
| 684 |
-ADPCM_ENCODER(CODEC_ID_ADPCM_MS, adpcm_ms, "ADPCM Microsoft"); |
|
| 685 |
-ADPCM_ENCODER(CODEC_ID_ADPCM_SWF, adpcm_swf, "ADPCM Shockwave Flash"); |
|
| 686 |
-ADPCM_ENCODER(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha, "ADPCM Yamaha"); |
|
| 685 |
+ADPCM_ENCODER(CODEC_ID_ADPCM_MS, adpcm_ms, "ADPCM Microsoft"); |
|
| 686 |
+ADPCM_ENCODER(CODEC_ID_ADPCM_SWF, adpcm_swf, "ADPCM Shockwave Flash"); |
|
| 687 |
+ADPCM_ENCODER(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha, "ADPCM Yamaha"); |
| ... | ... |
@@ -263,9 +263,9 @@ static int bmp_decode_frame(AVCodecContext *avctx, |
| 263 | 263 |
}else{
|
| 264 | 264 |
switch(depth){
|
| 265 | 265 |
case 1: |
| 266 |
- for(i = 0; i < avctx->height; i++){
|
|
| 266 |
+ for (i = 0; i < avctx->height; i++) {
|
|
| 267 | 267 |
int j; |
| 268 |
- for(j = 0; j < n; j++){
|
|
| 268 |
+ for (j = 0; j < n; j++) {
|
|
| 269 | 269 |
ptr[j*8+0] = buf[j] >> 7; |
| 270 | 270 |
ptr[j*8+1] = (buf[j] >> 6) & 1; |
| 271 | 271 |
ptr[j*8+2] = (buf[j] >> 5) & 1; |
| ... | ... |
@@ -66,44 +66,61 @@ static void dct_unquantize_h263_inter_c(MpegEncContext *s, |
| 66 | 66 |
//#define DEBUG |
| 67 | 67 |
|
| 68 | 68 |
|
| 69 |
-static const uint8_t ff_default_chroma_qscale_table[32]={
|
|
| 70 |
-// 0 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 |
|
| 71 |
- 0, 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 |
|
| 69 |
+static const uint8_t ff_default_chroma_qscale_table[32] = {
|
|
| 70 |
+// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
| 71 |
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
|
| 72 |
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 |
|
| 72 | 73 |
}; |
| 73 | 74 |
|
| 74 |
-const uint8_t ff_mpeg1_dc_scale_table[128]={
|
|
| 75 |
-// 0 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 |
|
| 76 |
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
|
| 77 |
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
|
| 78 |
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
|
| 79 |
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
|
| 75 |
+const uint8_t ff_mpeg1_dc_scale_table[128] = {
|
|
| 76 |
+// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
| 77 |
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
|
| 78 |
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
|
| 79 |
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
|
| 80 |
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
|
| 81 |
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
|
| 82 |
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
|
| 83 |
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
|
| 84 |
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
|
| 80 | 85 |
}; |
| 81 | 86 |
|
| 82 |
-static const uint8_t mpeg2_dc_scale_table1[128]={
|
|
| 83 |
-// 0 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 |
|
| 84 |
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, |
|
| 85 |
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, |
|
| 86 |
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, |
|
| 87 |
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, |
|
| 87 |
+static const uint8_t mpeg2_dc_scale_table1[128] = {
|
|
| 88 |
+// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
| 89 |
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, |
|
| 90 |
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, |
|
| 91 |
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, |
|
| 92 |
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, |
|
| 93 |
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, |
|
| 94 |
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, |
|
| 95 |
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, |
|
| 96 |
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, |
|
| 88 | 97 |
}; |
| 89 | 98 |
|
| 90 |
-static const uint8_t mpeg2_dc_scale_table2[128]={
|
|
| 91 |
-// 0 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 |
|
| 92 |
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
|
| 93 |
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
|
| 94 |
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
|
| 95 |
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
|
| 99 |
+static const uint8_t mpeg2_dc_scale_table2[128] = {
|
|
| 100 |
+// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
| 101 |
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
|
| 102 |
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
|
| 103 |
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
|
| 104 |
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
|
| 105 |
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
|
| 106 |
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
|
| 107 |
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
|
| 108 |
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
|
| 96 | 109 |
}; |
| 97 | 110 |
|
| 98 |
-static const uint8_t mpeg2_dc_scale_table3[128]={
|
|
| 99 |
-// 0 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 |
|
| 100 |
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
|
| 101 |
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
|
| 102 |
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
|
| 103 |
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
|
| 111 |
+static const uint8_t mpeg2_dc_scale_table3[128] = {
|
|
| 112 |
+// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
| 113 |
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
|
| 114 |
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
|
| 115 |
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
|
| 116 |
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
|
| 117 |
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
|
| 118 |
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
|
| 119 |
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
|
| 120 |
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
|
| 104 | 121 |
}; |
| 105 | 122 |
|
| 106 |
-const uint8_t * const ff_mpeg2_dc_scale_table[4]={
|
|
| 123 |
+const uint8_t *const ff_mpeg2_dc_scale_table[4] = {
|
|
| 107 | 124 |
ff_mpeg1_dc_scale_table, |
| 108 | 125 |
mpeg2_dc_scale_table1, |
| 109 | 126 |
mpeg2_dc_scale_table2, |
| ... | ... |
@@ -123,34 +140,37 @@ const enum PixelFormat ff_hwaccel_pixfmt_list_420[] = {
|
| 123 | 123 |
PIX_FMT_NONE |
| 124 | 124 |
}; |
| 125 | 125 |
|
| 126 |
-const uint8_t *avpriv_mpv_find_start_code(const uint8_t * restrict p, const uint8_t *end, uint32_t * restrict state){
|
|
| 126 |
+const uint8_t *avpriv_mpv_find_start_code(const uint8_t *restrict p, |
|
| 127 |
+ const uint8_t *end, |
|
| 128 |
+ uint32_t * restrict state) |
|
| 129 |
+{
|
|
| 127 | 130 |
int i; |
| 128 | 131 |
|
| 129 |
- assert(p<=end); |
|
| 130 |
- if(p>=end) |
|
| 132 |
+ assert(p <= end); |
|
| 133 |
+ if (p >= end) |
|
| 131 | 134 |
return end; |
| 132 | 135 |
|
| 133 |
- for(i=0; i<3; i++){
|
|
| 134 |
- uint32_t tmp= *state << 8; |
|
| 135 |
- *state= tmp + *(p++); |
|
| 136 |
- if(tmp == 0x100 || p==end) |
|
| 136 |
+ for (i = 0; i < 3; i++) {
|
|
| 137 |
+ uint32_t tmp = *state << 8; |
|
| 138 |
+ *state = tmp + *(p++); |
|
| 139 |
+ if (tmp == 0x100 || p == end) |
|
| 137 | 140 |
return p; |
| 138 | 141 |
} |
| 139 | 142 |
|
| 140 |
- while(p<end){
|
|
| 141 |
- if (p[-1] > 1 ) p+= 3; |
|
| 142 |
- else if(p[-2] ) p+= 2; |
|
| 143 |
- else if(p[-3]|(p[-1]-1)) p++; |
|
| 144 |
- else{
|
|
| 143 |
+ while (p < end) {
|
|
| 144 |
+ if (p[-1] > 1 ) p += 3; |
|
| 145 |
+ else if (p[-2] ) p += 2; |
|
| 146 |
+ else if (p[-3]|(p[-1]-1)) p++; |
|
| 147 |
+ else {
|
|
| 145 | 148 |
p++; |
| 146 | 149 |
break; |
| 147 | 150 |
} |
| 148 | 151 |
} |
| 149 | 152 |
|
| 150 |
- p= FFMIN(p, end)-4; |
|
| 151 |
- *state= AV_RB32(p); |
|
| 153 |
+ p = FFMIN(p, end) - 4; |
|
| 154 |
+ *state = AV_RB32(p); |
|
| 152 | 155 |
|
| 153 |
- return p+4; |
|
| 156 |
+ return p + 4; |
|
| 154 | 157 |
} |
| 155 | 158 |
|
| 156 | 159 |
/* init common dct for both encoder and decoder */ |
| ... | ... |
@@ -163,11 +183,11 @@ av_cold int ff_dct_common_init(MpegEncContext *s) |
| 163 | 163 |
s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_c; |
| 164 | 164 |
s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_c; |
| 165 | 165 |
s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_c; |
| 166 |
- if(s->flags & CODEC_FLAG_BITEXACT) |
|
| 166 |
+ if (s->flags & CODEC_FLAG_BITEXACT) |
|
| 167 | 167 |
s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_bitexact; |
| 168 | 168 |
s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_c; |
| 169 | 169 |
|
| 170 |
-#if HAVE_MMX |
|
| 170 |
+#if HAVE_MMX |
|
| 171 | 171 |
MPV_common_init_mmx(s); |
| 172 | 172 |
#elif ARCH_ALPHA |
| 173 | 173 |
MPV_common_init_axp(s); |
| ... | ... |
@@ -184,12 +204,12 @@ av_cold int ff_dct_common_init(MpegEncContext *s) |
| 184 | 184 |
#endif |
| 185 | 185 |
|
| 186 | 186 |
/* load & permutate scantables |
| 187 |
- note: only wmv uses different ones |
|
| 188 |
- */ |
|
| 189 |
- if(s->alternate_scan){
|
|
| 187 |
+ * note: only wmv uses different ones |
|
| 188 |
+ */ |
|
| 189 |
+ if (s->alternate_scan) {
|
|
| 190 | 190 |
ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_alternate_vertical_scan); |
| 191 | 191 |
ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_alternate_vertical_scan); |
| 192 |
- }else{
|
|
| 192 |
+ } else {
|
|
| 193 | 193 |
ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_zigzag_direct); |
| 194 | 194 |
ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_zigzag_direct); |
| 195 | 195 |
} |
| ... | ... |
@@ -199,9 +219,10 @@ av_cold int ff_dct_common_init(MpegEncContext *s) |
| 199 | 199 |
return 0; |
| 200 | 200 |
} |
| 201 | 201 |
|
| 202 |
-void ff_copy_picture(Picture *dst, Picture *src){
|
|
| 202 |
+void ff_copy_picture(Picture *dst, Picture *src) |
|
| 203 |
+{
|
|
| 203 | 204 |
*dst = *src; |
| 204 |
- dst->f.type= FF_BUFFER_TYPE_COPY; |
|
| 205 |
+ dst->f.type = FF_BUFFER_TYPE_COPY; |
|
| 205 | 206 |
} |
| 206 | 207 |
|
| 207 | 208 |
/** |
| ... | ... |
@@ -210,11 +231,12 @@ void ff_copy_picture(Picture *dst, Picture *src){
|
| 210 | 210 |
static void free_frame_buffer(MpegEncContext *s, Picture *pic) |
| 211 | 211 |
{
|
| 212 | 212 |
/* Windows Media Image codecs allocate internal buffers with different |
| 213 |
- dimensions; ignore user defined callbacks for these */ |
|
| 213 |
+ * dimensions; ignore user defined callbacks for these |
|
| 214 |
+ */ |
|
| 214 | 215 |
if (s->codec_id != CODEC_ID_WMV3IMAGE && s->codec_id != CODEC_ID_VC1IMAGE) |
| 215 |
- ff_thread_release_buffer(s->avctx, (AVFrame*)pic); |
|
| 216 |
+ ff_thread_release_buffer(s->avctx, (AVFrame *) pic); |
|
| 216 | 217 |
else |
| 217 |
- avcodec_default_release_buffer(s->avctx, (AVFrame*)pic); |
|
| 218 |
+ avcodec_default_release_buffer(s->avctx, (AVFrame *) pic); |
|
| 218 | 219 |
av_freep(&pic->f.hwaccel_picture_private); |
| 219 | 220 |
} |
| 220 | 221 |
|
| ... | ... |
@@ -237,9 +259,9 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic) |
| 237 | 237 |
} |
| 238 | 238 |
|
| 239 | 239 |
if (s->codec_id != CODEC_ID_WMV3IMAGE && s->codec_id != CODEC_ID_VC1IMAGE) |
| 240 |
- r = ff_thread_get_buffer(s->avctx, (AVFrame*)pic); |
|
| 240 |
+ r = ff_thread_get_buffer(s->avctx, (AVFrame *) pic); |
|
| 241 | 241 |
else |
| 242 |
- r = avcodec_default_get_buffer(s->avctx, (AVFrame*)pic); |
|
| 242 |
+ r = avcodec_default_get_buffer(s->avctx, (AVFrame *) pic); |
|
| 243 | 243 |
|
| 244 | 244 |
if (r < 0 || !pic->f.age || !pic->f.type || !pic->f.data[0]) {
|
| 245 | 245 |
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", |
| ... | ... |
@@ -248,14 +270,17 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic) |
| 248 | 248 |
return -1; |
| 249 | 249 |
} |
| 250 | 250 |
|
| 251 |
- if (s->linesize && (s->linesize != pic->f.linesize[0] || s->uvlinesize != pic->f.linesize[1])) {
|
|
| 252 |
- av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n"); |
|
| 251 |
+ if (s->linesize && (s->linesize != pic->f.linesize[0] || |
|
| 252 |
+ s->uvlinesize != pic->f.linesize[1])) {
|
|
| 253 |
+ av_log(s->avctx, AV_LOG_ERROR, |
|
| 254 |
+ "get_buffer() failed (stride changed)\n"); |
|
| 253 | 255 |
free_frame_buffer(s, pic); |
| 254 | 256 |
return -1; |
| 255 | 257 |
} |
| 256 | 258 |
|
| 257 | 259 |
if (pic->f.linesize[1] != pic->f.linesize[2]) {
|
| 258 |
- av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (uv stride mismatch)\n"); |
|
| 260 |
+ av_log(s->avctx, AV_LOG_ERROR, |
|
| 261 |
+ "get_buffer() failed (uv stride mismatch)\n"); |
|
| 259 | 262 |
free_frame_buffer(s, pic); |
| 260 | 263 |
return -1; |
| 261 | 264 |
} |
| ... | ... |
@@ -265,21 +290,25 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic) |
| 265 | 265 |
|
| 266 | 266 |
/** |
| 267 | 267 |
* allocates a Picture |
| 268 |
- * The pixels are allocated/set by calling get_buffer() if shared=0 |
|
| 268 |
+ * The pixels are allocated/set by calling get_buffer() if shared = 0 |
|
| 269 | 269 |
*/ |
| 270 |
-int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared){
|
|
| 271 |
- const int big_mb_num= s->mb_stride*(s->mb_height+1) + 1; //the +1 is needed so memset(,,stride*height) does not sig11 |
|
| 272 |
- const int mb_array_size= s->mb_stride*s->mb_height; |
|
| 273 |
- const int b8_array_size= s->b8_stride*s->mb_height*2; |
|
| 274 |
- const int b4_array_size= s->b4_stride*s->mb_height*4; |
|
| 270 |
+int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared) |
|
| 271 |
+{
|
|
| 272 |
+ const int big_mb_num = s->mb_stride * (s->mb_height + 1) + 1; |
|
| 273 |
+ |
|
| 274 |
+ // the + 1 is needed so memset(,,stride*height) does not sig11 |
|
| 275 |
+ |
|
| 276 |
+ const int mb_array_size = s->mb_stride * s->mb_height; |
|
| 277 |
+ const int b8_array_size = s->b8_stride * s->mb_height * 2; |
|
| 278 |
+ const int b4_array_size = s->b4_stride * s->mb_height * 4; |
|
| 275 | 279 |
int i; |
| 276 |
- int r= -1; |
|
| 280 |
+ int r = -1; |
|
| 277 | 281 |
|
| 278 |
- if(shared){
|
|
| 282 |
+ if (shared) {
|
|
| 279 | 283 |
assert(pic->f.data[0]); |
| 280 | 284 |
assert(pic->f.type == 0 || pic->f.type == FF_BUFFER_TYPE_SHARED); |
| 281 | 285 |
pic->f.type = FF_BUFFER_TYPE_SHARED; |
| 282 |
- }else{
|
|
| 286 |
+ } else {
|
|
| 283 | 287 |
assert(!pic->f.data[0]); |
| 284 | 288 |
|
| 285 | 289 |
if (alloc_frame_buffer(s, pic) < 0) |
| ... | ... |
@@ -291,49 +320,69 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared){
|
| 291 | 291 |
|
| 292 | 292 |
if (pic->f.qscale_table == NULL) {
|
| 293 | 293 |
if (s->encoding) {
|
| 294 |
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_var , mb_array_size * sizeof(int16_t) , fail) |
|
| 295 |
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->mc_mb_var, mb_array_size * sizeof(int16_t) , fail) |
|
| 296 |
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_mean , mb_array_size * sizeof(int8_t ) , fail) |
|
| 294 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_var, |
|
| 295 |
+ mb_array_size * sizeof(int16_t), fail) |
|
| 296 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, pic->mc_mb_var, |
|
| 297 |
+ mb_array_size * sizeof(int16_t), fail) |
|
| 298 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_mean, |
|
| 299 |
+ mb_array_size * sizeof(int8_t ), fail) |
|
| 297 | 300 |
} |
| 298 | 301 |
|
| 299 |
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.mbskip_table, mb_array_size * sizeof(uint8_t) + 2, fail) //the +2 is for the slice end check |
|
| 300 |
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->qscale_table_base , (big_mb_num + s->mb_stride) * sizeof(uint8_t) , fail) |
|
| 301 |
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_type_base , (big_mb_num + s->mb_stride) * sizeof(uint32_t), fail) |
|
| 302 |
- pic->f.mb_type = pic->mb_type_base + 2*s->mb_stride + 1; |
|
| 303 |
- pic->f.qscale_table = pic->qscale_table_base + 2*s->mb_stride + 1; |
|
| 304 |
- if(s->out_format == FMT_H264){
|
|
| 305 |
- for(i=0; i<2; i++){
|
|
| 306 |
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i], 2 * (b4_array_size+4) * sizeof(int16_t), fail) |
|
| 302 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.mbskip_table, |
|
| 303 |
+ mb_array_size * sizeof(uint8_t) + 2, fail)// the + 2 is for the slice end check |
|
| 304 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, pic->qscale_table_base, |
|
| 305 |
+ (big_mb_num + s->mb_stride) * sizeof(uint8_t), |
|
| 306 |
+ fail) |
|
| 307 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_type_base, |
|
| 308 |
+ (big_mb_num + s->mb_stride) * sizeof(uint32_t), |
|
| 309 |
+ fail) |
|
| 310 |
+ pic->f.mb_type = pic->mb_type_base + 2 * s->mb_stride + 1; |
|
| 311 |
+ pic->f.qscale_table = pic->qscale_table_base + 2 * s->mb_stride + 1; |
|
| 312 |
+ if (s->out_format == FMT_H264) {
|
|
| 313 |
+ for (i = 0; i < 2; i++) {
|
|
| 314 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i], |
|
| 315 |
+ 2 * (b4_array_size + 4) * sizeof(int16_t), |
|
| 316 |
+ fail) |
|
| 307 | 317 |
pic->f.motion_val[i] = pic->motion_val_base[i] + 4; |
| 308 |
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.ref_index[i], 4*mb_array_size * sizeof(uint8_t), fail) |
|
| 318 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.ref_index[i], |
|
| 319 |
+ 4 * mb_array_size * sizeof(uint8_t), fail) |
|
| 309 | 320 |
} |
| 310 | 321 |
pic->f.motion_subsample_log2 = 2; |
| 311 |
- }else if(s->out_format == FMT_H263 || s->encoding || (s->avctx->debug&FF_DEBUG_MV) || (s->avctx->debug_mv)){
|
|
| 312 |
- for(i=0; i<2; i++){
|
|
| 313 |
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i], 2 * (b8_array_size+4) * sizeof(int16_t), fail) |
|
| 322 |
+ } else if (s->out_format == FMT_H263 || s->encoding || |
|
| 323 |
+ (s->avctx->debug & FF_DEBUG_MV) || s->avctx->debug_mv) {
|
|
| 324 |
+ for (i = 0; i < 2; i++) {
|
|
| 325 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i], |
|
| 326 |
+ 2 * (b8_array_size + 4) * sizeof(int16_t), |
|
| 327 |
+ fail) |
|
| 314 | 328 |
pic->f.motion_val[i] = pic->motion_val_base[i] + 4; |
| 315 |
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.ref_index[i], 4*mb_array_size * sizeof(uint8_t), fail) |
|
| 329 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.ref_index[i], |
|
| 330 |
+ 4 * mb_array_size * sizeof(uint8_t), fail) |
|
| 316 | 331 |
} |
| 317 | 332 |
pic->f.motion_subsample_log2 = 3; |
| 318 | 333 |
} |
| 319 |
- if(s->avctx->debug&FF_DEBUG_DCT_COEFF) {
|
|
| 320 |
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.dct_coeff, 64 * mb_array_size * sizeof(DCTELEM) * 6, fail) |
|
| 334 |
+ if (s->avctx->debug&FF_DEBUG_DCT_COEFF) {
|
|
| 335 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.dct_coeff, |
|
| 336 |
+ 64 * mb_array_size * sizeof(DCTELEM) * 6, fail) |
|
| 321 | 337 |
} |
| 322 | 338 |
pic->f.qstride = s->mb_stride; |
| 323 |
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.pan_scan , 1 * sizeof(AVPanScan), fail) |
|
| 339 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.pan_scan, |
|
| 340 |
+ 1 * sizeof(AVPanScan), fail) |
|
| 324 | 341 |
} |
| 325 | 342 |
|
| 326 | 343 |
/* It might be nicer if the application would keep track of these |
| 327 | 344 |
* but it would require an API change. */ |
| 328 |
- memmove(s->prev_pict_types+1, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE-1); |
|
| 329 |
- s->prev_pict_types[0]= s->dropable ? AV_PICTURE_TYPE_B : s->pict_type; |
|
| 330 |
- if (pic->f.age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->f.age] == AV_PICTURE_TYPE_B) |
|
| 331 |
- pic->f.age = INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2 and it is a bit tricky to skip them anyway. |
|
| 345 |
+ memmove(s->prev_pict_types + 1, s->prev_pict_types, |
|
| 346 |
+ PREV_PICT_TYPES_BUFFER_SIZE-1); |
|
| 347 |
+ s->prev_pict_types[0] = s->dropable ? AV_PICTURE_TYPE_B : s->pict_type; |
|
| 348 |
+ if (pic->f.age < PREV_PICT_TYPES_BUFFER_SIZE && |
|
| 349 |
+ s->prev_pict_types[pic->f.age] == AV_PICTURE_TYPE_B) |
|
| 350 |
+ pic->f.age = INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2 |
|
| 351 |
+ // and it is a bit tricky to skip them anyway. |
|
| 332 | 352 |
pic->owner2 = s; |
| 333 | 353 |
|
| 334 | 354 |
return 0; |
| 335 |
-fail: //for the FF_ALLOCZ_OR_GOTO macro |
|
| 336 |
- if(r>=0) |
|
| 355 |
+fail: // for the FF_ALLOCZ_OR_GOTO macro |
|
| 356 |
+ if (r >= 0) |
|
| 337 | 357 |
free_frame_buffer(s, pic); |
| 338 | 358 |
return -1; |
| 339 | 359 |
} |
| ... | ... |
@@ -341,7 +390,8 @@ fail: //for the FF_ALLOCZ_OR_GOTO macro |
| 341 | 341 |
/** |
| 342 | 342 |
* deallocates a picture |
| 343 | 343 |
*/ |
| 344 |
-static void free_picture(MpegEncContext *s, Picture *pic){
|
|
| 344 |
+static void free_picture(MpegEncContext *s, Picture *pic) |
|
| 345 |
+{
|
|
| 345 | 346 |
int i; |
| 346 | 347 |
|
| 347 | 348 |
if (pic->f.data[0] && pic->f.type != FF_BUFFER_TYPE_SHARED) {
|
| ... | ... |
@@ -357,13 +407,13 @@ static void free_picture(MpegEncContext *s, Picture *pic){
|
| 357 | 357 |
av_freep(&pic->f.dct_coeff); |
| 358 | 358 |
av_freep(&pic->f.pan_scan); |
| 359 | 359 |
pic->f.mb_type = NULL; |
| 360 |
- for(i=0; i<2; i++){
|
|
| 360 |
+ for (i = 0; i < 2; i++) {
|
|
| 361 | 361 |
av_freep(&pic->motion_val_base[i]); |
| 362 | 362 |
av_freep(&pic->f.ref_index[i]); |
| 363 | 363 |
} |
| 364 | 364 |
|
| 365 | 365 |
if (pic->f.type == FF_BUFFER_TYPE_SHARED) {
|
| 366 |
- for(i=0; i<4; i++){
|
|
| 366 |
+ for (i = 0; i < 4; i++) {
|
|
| 367 | 367 |
pic->f.base[i] = |
| 368 | 368 |
pic->f.data[i] = NULL; |
| 369 | 369 |
} |
| ... | ... |
@@ -371,38 +421,47 @@ static void free_picture(MpegEncContext *s, Picture *pic){
|
| 371 | 371 |
} |
| 372 | 372 |
} |
| 373 | 373 |
|
| 374 |
-static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base){
|
|
| 374 |
+static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base) |
|
| 375 |
+{
|
|
| 375 | 376 |
int y_size = s->b8_stride * (2 * s->mb_height + 1); |
| 376 | 377 |
int c_size = s->mb_stride * (s->mb_height + 1); |
| 377 | 378 |
int yc_size = y_size + 2 * c_size; |
| 378 | 379 |
int i; |
| 379 | 380 |
|
| 380 |
- // edge emu needs blocksize + filter length - 1 (=17x17 for halfpel / 21x21 for h264) |
|
| 381 |
- FF_ALLOCZ_OR_GOTO(s->avctx, s->edge_emu_buffer, (s->width+64)*2*21*2, fail); //(width + edge + align)*interlaced*MBsize*tolerance |
|
| 382 |
- |
|
| 383 |
- //FIXME should be linesize instead of s->width*2 but that is not known before get_buffer() |
|
| 384 |
- FF_ALLOCZ_OR_GOTO(s->avctx, s->me.scratchpad, (s->width+64)*4*16*2*sizeof(uint8_t), fail) |
|
| 385 |
- s->me.temp= s->me.scratchpad; |
|
| 386 |
- s->rd_scratchpad= s->me.scratchpad; |
|
| 387 |
- s->b_scratchpad= s->me.scratchpad; |
|
| 388 |
- s->obmc_scratchpad= s->me.scratchpad + 16; |
|
| 381 |
+ // edge emu needs blocksize + filter length - 1 |
|
| 382 |
+ // (= 17x17 for halfpel / 21x21 for h264) |
|
| 383 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->edge_emu_buffer, |
|
| 384 |
+ (s->width + 64) * 2 * 21 * 2, fail); // (width + edge + align)*interlaced*MBsize*tolerance |
|
| 385 |
+ |
|
| 386 |
+ // FIXME should be linesize instead of s->width * 2 |
|
| 387 |
+ // but that is not known before get_buffer() |
|
| 388 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->me.scratchpad, |
|
| 389 |
+ (s->width + 64) * 4 * 16 * 2 * sizeof(uint8_t), fail) |
|
| 390 |
+ s->me.temp = s->me.scratchpad; |
|
| 391 |
+ s->rd_scratchpad = s->me.scratchpad; |
|
| 392 |
+ s->b_scratchpad = s->me.scratchpad; |
|
| 393 |
+ s->obmc_scratchpad = s->me.scratchpad + 16; |
|
| 389 | 394 |
if (s->encoding) {
|
| 390 |
- FF_ALLOCZ_OR_GOTO(s->avctx, s->me.map , ME_MAP_SIZE*sizeof(uint32_t), fail) |
|
| 391 |
- FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map, ME_MAP_SIZE*sizeof(uint32_t), fail) |
|
| 392 |
- if(s->avctx->noise_reduction){
|
|
| 393 |
- FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_error_sum, 2 * 64 * sizeof(int), fail) |
|
| 395 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->me.map, |
|
| 396 |
+ ME_MAP_SIZE * sizeof(uint32_t), fail) |
|
| 397 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map, |
|
| 398 |
+ ME_MAP_SIZE * sizeof(uint32_t), fail) |
|
| 399 |
+ if (s->avctx->noise_reduction) {
|
|
| 400 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_error_sum, |
|
| 401 |
+ 2 * 64 * sizeof(int), fail) |
|
| 394 | 402 |
} |
| 395 | 403 |
} |
| 396 |
- FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64*12*2 * sizeof(DCTELEM), fail) |
|
| 397 |
- s->block= s->blocks[0]; |
|
| 404 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * sizeof(DCTELEM), fail) |
|
| 405 |
+ s->block = s->blocks[0]; |
|
| 398 | 406 |
|
| 399 |
- for(i=0;i<12;i++){
|
|
| 407 |
+ for (i = 0; i < 12; i++) {
|
|
| 400 | 408 |
s->pblocks[i] = &s->block[i]; |
| 401 | 409 |
} |
| 402 | 410 |
|
| 403 | 411 |
if (s->out_format == FMT_H263) {
|
| 404 | 412 |
/* ac values */ |
| 405 |
- FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, yc_size * sizeof(int16_t) * 16, fail); |
|
| 413 |
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, |
|
| 414 |
+ yc_size * sizeof(int16_t) * 16, fail); |
|
| 406 | 415 |
s->ac_val[0] = s->ac_val_base + s->b8_stride + 1; |
| 407 | 416 |
s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1; |
| 408 | 417 |
s->ac_val[2] = s->ac_val[1] + c_size; |
| ... | ... |
@@ -410,29 +469,32 @@ static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base){
|
| 410 | 410 |
|
| 411 | 411 |
return 0; |
| 412 | 412 |
fail: |
| 413 |
- return -1; //free() through MPV_common_end() |
|
| 413 |
+ return -1; // free() through MPV_common_end() |
|
| 414 | 414 |
} |
| 415 | 415 |
|
| 416 |
-static void free_duplicate_context(MpegEncContext *s){
|
|
| 417 |
- if(s==NULL) return; |
|
| 416 |
+static void free_duplicate_context(MpegEncContext *s) |
|
| 417 |
+{
|
|
| 418 |
+ if (s == NULL) |
|
| 419 |
+ return; |
|
| 418 | 420 |
|
| 419 | 421 |
av_freep(&s->edge_emu_buffer); |
| 420 | 422 |
av_freep(&s->me.scratchpad); |
| 421 |
- s->me.temp= |
|
| 422 |
- s->rd_scratchpad= |
|
| 423 |
- s->b_scratchpad= |
|
| 424 |
- s->obmc_scratchpad= NULL; |
|
| 423 |
+ s->me.temp = |
|
| 424 |
+ s->rd_scratchpad = |
|
| 425 |
+ s->b_scratchpad = |
|
| 426 |
+ s->obmc_scratchpad = NULL; |
|
| 425 | 427 |
|
| 426 | 428 |
av_freep(&s->dct_error_sum); |
| 427 | 429 |
av_freep(&s->me.map); |
| 428 | 430 |
av_freep(&s->me.score_map); |
| 429 | 431 |
av_freep(&s->blocks); |
| 430 | 432 |
av_freep(&s->ac_val_base); |
| 431 |
- s->block= NULL; |
|
| 433 |
+ s->block = NULL; |
|
| 432 | 434 |
} |
| 433 | 435 |
|
| 434 |
-static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src){
|
|
| 435 |
-#define COPY(a) bak->a= src->a |
|
| 436 |
+static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src) |
|
| 437 |
+{
|
|
| 438 |
+#define COPY(a) bak->a = src->a |
|
| 436 | 439 |
COPY(edge_emu_buffer); |
| 437 | 440 |
COPY(me.scratchpad); |
| 438 | 441 |
COPY(me.temp); |
| ... | ... |
@@ -457,28 +519,33 @@ static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src){
|
| 457 | 457 |
#undef COPY |
| 458 | 458 |
} |
| 459 | 459 |
|
| 460 |
-void ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src){
|
|
| 460 |
+void ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src) |
|
| 461 |
+{
|
|
| 461 | 462 |
MpegEncContext bak; |
| 462 | 463 |
int i; |
| 463 |
- //FIXME copy only needed parts |
|
| 464 |
-//START_TIMER |
|
| 464 |
+ // FIXME copy only needed parts |
|
| 465 |
+ // START_TIMER |
|
| 465 | 466 |
backup_duplicate_context(&bak, dst); |
| 466 | 467 |
memcpy(dst, src, sizeof(MpegEncContext)); |
| 467 | 468 |
backup_duplicate_context(dst, &bak); |
| 468 |
- for(i=0;i<12;i++){
|
|
| 469 |
+ for (i = 0; i < 12; i++) {
|
|
| 469 | 470 |
dst->pblocks[i] = &dst->block[i]; |
| 470 | 471 |
} |
| 471 |
-//STOP_TIMER("update_duplicate_context") //about 10k cycles / 0.01 sec for 1000frames on 1ghz with 2 threads
|
|
| 472 |
+ // STOP_TIMER("update_duplicate_context")
|
|
| 473 |
+ // about 10k cycles / 0.01 sec for 1000frames on 1ghz with 2 threads |
|
| 472 | 474 |
} |
| 473 | 475 |
|
| 474 |
-int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src) |
|
| 476 |
+int ff_mpeg_update_thread_context(AVCodecContext *dst, |
|
| 477 |
+ const AVCodecContext *src) |
|
| 475 | 478 |
{
|
| 476 | 479 |
MpegEncContext *s = dst->priv_data, *s1 = src->priv_data; |
| 477 | 480 |
|
| 478 |
- if(dst == src || !s1->context_initialized) return 0; |
|
| 481 |
+ if (dst == src || !s1->context_initialized) |
|
| 482 |
+ return 0; |
|
| 479 | 483 |
|
| 480 |
- //FIXME can parameters change on I-frames? in that case dst may need a reinit |
|
| 481 |
- if(!s->context_initialized){
|
|
| 484 |
+ // FIXME can parameters change on I-frames? |
|
| 485 |
+ // in that case dst may need a reinit |
|
| 486 |
+ if (!s->context_initialized) {
|
|
| 482 | 487 |
memcpy(s, s1, sizeof(MpegEncContext)); |
| 483 | 488 |
|
| 484 | 489 |
s->avctx = dst; |
| ... | ... |
@@ -110,7 +110,7 @@ typedef struct WavpackFrameContext {
|
| 110 | 110 |
int extra_bits; |
| 111 | 111 |
int and, or, shift; |
| 112 | 112 |
int post_shift; |
| 113 |
- int hybrid, hybrid_bitrate; |
|
| 113 |
+ int hybrid, hybrid_bitrate, hybrid_maxclip; |
|
| 114 | 114 |
int float_flag; |
| 115 | 115 |
int float_shift; |
| 116 | 116 |
int float_max_exp; |
| ... | ... |
@@ -403,8 +403,14 @@ static inline int wv_get_value_integer(WavpackFrameContext *s, uint32_t *crc, in |
| 403 | 403 |
*crc = *crc * 9 + (S&0xffff) * 3 + ((unsigned)S>>16); |
| 404 | 404 |
} |
| 405 | 405 |
} |
| 406 |
+ |
|
| 406 | 407 |
bit = (S & s->and) | s->or; |
| 407 |
- return (((S + bit) << s->shift) - bit) << s->post_shift; |
|
| 408 |
+ bit = (((S + bit) << s->shift) - bit); |
|
| 409 |
+ |
|
| 410 |
+ if(s->hybrid) |
|
| 411 |
+ bit = av_clip(bit, -s->hybrid_maxclip, s->hybrid_maxclip - 1); |
|
| 412 |
+ |
|
| 413 |
+ return bit << s->post_shift; |
|
| 408 | 414 |
} |
| 409 | 415 |
|
| 410 | 416 |
static float wv_get_value_float(WavpackFrameContext *s, uint32_t *crc, int S) |
| ... | ... |
@@ -792,6 +798,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, |
| 792 | 792 |
s->joint = s->frame_flags & WV_JOINT_STEREO; |
| 793 | 793 |
s->hybrid = s->frame_flags & WV_HYBRID_MODE; |
| 794 | 794 |
s->hybrid_bitrate = s->frame_flags & WV_HYBRID_BITRATE; |
| 795 |
+ s->hybrid_maxclip = 1 << ((((s->frame_flags & 0x03) + 1) << 3) - 1); |
|
| 795 | 796 |
s->post_shift = 8 * (bpp-1-(s->frame_flags&0x03)) + ((s->frame_flags >> 13) & 0x1f); |
| 796 | 797 |
s->CRC = AV_RL32(buf); buf += 4; |
| 797 | 798 |
if(wc->mkv_mode) |
| ... | ... |
@@ -113,13 +113,13 @@ static int xan_huffman_decode(unsigned char *dest, int dest_len, |
| 113 | 113 |
|
| 114 | 114 |
init_get_bits(&gb, ptr, ptr_len * 8); |
| 115 | 115 |
|
| 116 |
- while ( val != 0x16 ) {
|
|
| 116 |
+ while (val != 0x16) {
|
|
| 117 | 117 |
unsigned idx = val - 0x17 + get_bits1(&gb) * byte; |
| 118 | 118 |
if (idx >= 2 * byte) |
| 119 | 119 |
return -1; |
| 120 | 120 |
val = src[idx]; |
| 121 | 121 |
|
| 122 |
- if ( val < 0x16 ) {
|
|
| 122 |
+ if (val < 0x16) {
|
|
| 123 | 123 |
if (dest >= dest_end) |
| 124 | 124 |
return 0; |
| 125 | 125 |
*dest++ = val; |
| ... | ... |
@@ -149,27 +149,23 @@ static void xan_unpack(unsigned char *dest, int dest_len, |
| 149 | 149 |
|
| 150 | 150 |
if (opcode < 0xe0) {
|
| 151 | 151 |
int size2, back; |
| 152 |
- if ( (opcode & 0x80) == 0 ) {
|
|
| 153 |
- |
|
| 152 |
+ if ((opcode & 0x80) == 0) {
|
|
| 154 | 153 |
size = opcode & 3; |
| 155 | 154 |
|
| 156 | 155 |
back = ((opcode & 0x60) << 3) + *src++ + 1; |
| 157 | 156 |
size2 = ((opcode & 0x1c) >> 2) + 3; |
| 158 |
- |
|
| 159 |
- } else if ( (opcode & 0x40) == 0 ) {
|
|
| 160 |
- |
|
| 157 |
+ } else if ((opcode & 0x40) == 0) {
|
|
| 161 | 158 |
size = *src >> 6; |
| 162 | 159 |
|
| 163 | 160 |
back = (bytestream_get_be16(&src) & 0x3fff) + 1; |
| 164 | 161 |
size2 = (opcode & 0x3f) + 4; |
| 165 |
- |
|
| 166 | 162 |
} else {
|
| 167 |
- |
|
| 168 | 163 |
size = opcode & 3; |
| 169 | 164 |
|
| 170 | 165 |
back = ((opcode & 0x10) << 12) + bytestream_get_be16(&src) + 1; |
| 171 | 166 |
size2 = ((opcode & 0x0c) << 6) + *src++ + 5; |
| 172 | 167 |
} |
| 168 |
+ |
|
| 173 | 169 |
if (dest_end - dest < size + size2 || |
| 174 | 170 |
dest + size - dest_org < back || |
| 175 | 171 |
src_end - src < size) |
| ... | ... |
@@ -205,7 +201,7 @@ static inline void xan_wc3_output_pixel_run(XanContext *s, |
| 205 | 205 |
line_inc = stride - width; |
| 206 | 206 |
index = y * stride + x; |
| 207 | 207 |
current_x = x; |
| 208 |
- while(pixel_count && (index < s->frame_size)) {
|
|
| 208 |
+ while (pixel_count && index < s->frame_size) {
|
|
| 209 | 209 |
int count = FFMIN(pixel_count, width - current_x); |
| 210 | 210 |
memcpy(palette_plane + index, pixel_buffer, count); |
| 211 | 211 |
pixel_count -= count; |
| ... | ... |
@@ -220,8 +216,9 @@ static inline void xan_wc3_output_pixel_run(XanContext *s, |
| 220 | 220 |
} |
| 221 | 221 |
} |
| 222 | 222 |
|
| 223 |
-static inline void xan_wc3_copy_pixel_run(XanContext *s, |
|
| 224 |
- int x, int y, int pixel_count, int motion_x, int motion_y) |
|
| 223 |
+static inline void xan_wc3_copy_pixel_run(XanContext *s, int x, int y, |
|
| 224 |
+ int pixel_count, int motion_x, |
|
| 225 |
+ int motion_y) |
|
| 225 | 226 |
{
|
| 226 | 227 |
int stride; |
| 227 | 228 |
int line_inc; |
| ... | ... |
@@ -230,8 +227,8 @@ static inline void xan_wc3_copy_pixel_run(XanContext *s, |
| 230 | 230 |
int width = s->avctx->width; |
| 231 | 231 |
unsigned char *palette_plane, *prev_palette_plane; |
| 232 | 232 |
|
| 233 |
- if ( y + motion_y < 0 || y + motion_y >= s->avctx->height || |
|
| 234 |
- x + motion_x < 0 || x + motion_x >= s->avctx->width) |
|
| 233 |
+ if (y + motion_y < 0 || y + motion_y >= s->avctx->height || |
|
| 234 |
+ x + motion_x < 0 || x + motion_x >= s->avctx->width) |
|
| 235 | 235 |
return; |
| 236 | 236 |
|
| 237 | 237 |
palette_plane = s->current_frame.data[0]; |
| ... | ... |
@@ -244,12 +241,14 @@ static inline void xan_wc3_copy_pixel_run(XanContext *s, |
| 244 | 244 |
curframe_x = x; |
| 245 | 245 |
prevframe_index = (y + motion_y) * stride + x + motion_x; |
| 246 | 246 |
prevframe_x = x + motion_x; |
| 247 |
- while(pixel_count && |
|
| 248 |
- curframe_index < s->frame_size && |
|
| 249 |
- prevframe_index < s->frame_size) {
|
|
| 250 |
- int count = FFMIN3(pixel_count, width - curframe_x, width - prevframe_x); |
|
| 251 |
- |
|
| 252 |
- memcpy(palette_plane + curframe_index, prev_palette_plane + prevframe_index, count); |
|
| 247 |
+ while (pixel_count && |
|
| 248 |
+ curframe_index < s->frame_size && |
|
| 249 |
+ prevframe_index < s->frame_size) {
|
|
| 250 |
+ int count = FFMIN3(pixel_count, width - curframe_x, |
|
| 251 |
+ width - prevframe_x); |
|
| 252 |
+ |
|
| 253 |
+ memcpy(palette_plane + curframe_index, |
|
| 254 |
+ prev_palette_plane + prevframe_index, count); |
|
| 253 | 255 |
pixel_count -= count; |
| 254 | 256 |
curframe_index += count; |
| 255 | 257 |
prevframe_index += count; |
| ... | ... |
@@ -270,7 +269,7 @@ static inline void xan_wc3_copy_pixel_run(XanContext *s, |
| 270 | 270 |
|
| 271 | 271 |
static int xan_wc3_decode_frame(XanContext *s) {
|
| 272 | 272 |
|
| 273 |
- int width = s->avctx->width; |
|
| 273 |
+ int width = s->avctx->width; |
|
| 274 | 274 |
int height = s->avctx->height; |
| 275 | 275 |
int total_pixels = width * height; |
| 276 | 276 |
unsigned char opcode; |
| ... | ... |
@@ -289,7 +288,8 @@ static int xan_wc3_decode_frame(XanContext *s) {
|
| 289 | 289 |
const unsigned char *size_segment; |
| 290 | 290 |
const unsigned char *vector_segment; |
| 291 | 291 |
const unsigned char *imagedata_segment; |
| 292 |
- int huffman_offset, size_offset, vector_offset, imagedata_offset, imagedata_size; |
|
| 292 |
+ int huffman_offset, size_offset, vector_offset, imagedata_offset, |
|
| 293 |
+ imagedata_size; |
|
| 293 | 294 |
|
| 294 | 295 |
if (s->size < 8) |
| 295 | 296 |
return AVERROR_INVALIDDATA; |
| ... | ... |
@@ -374,6 +374,7 @@ static int xan_wc3_decode_frame(XanContext *s) {
|
| 374 | 374 |
size_segment += 3; |
| 375 | 375 |
break; |
| 376 | 376 |
} |
| 377 |
+ |
|
| 377 | 378 |
if (size > total_pixels) |
| 378 | 379 |
break; |
| 379 | 380 |
|
| ... | ... |
@@ -518,7 +519,8 @@ static int xan_decode_frame(AVCodecContext *avctx, |
| 518 | 518 |
return AVERROR_INVALIDDATA; |
| 519 | 519 |
if (s->palettes_count >= PALETTES_MAX) |
| 520 | 520 |
return AVERROR_INVALIDDATA; |
| 521 |
- tmpptr = av_realloc(s->palettes, (s->palettes_count + 1) * AVPALETTE_SIZE); |
|
| 521 |
+ tmpptr = av_realloc(s->palettes, |
|
| 522 |
+ (s->palettes_count + 1) * AVPALETTE_SIZE); |
|
| 522 | 523 |
if (!tmpptr) |
| 523 | 524 |
return AVERROR(ENOMEM); |
| 524 | 525 |
s->palettes = tmpptr; |
| ... | ... |
@@ -569,7 +571,8 @@ static int xan_decode_frame(AVCodecContext *avctx, |
| 569 | 569 |
if (!s->frame_size) |
| 570 | 570 |
s->frame_size = s->current_frame.linesize[0] * s->avctx->height; |
| 571 | 571 |
|
| 572 |
- memcpy(s->current_frame.data[1], s->palettes + s->cur_palette * AVPALETTE_COUNT, AVPALETTE_SIZE); |
|
| 572 |
+ memcpy(s->current_frame.data[1], |
|
| 573 |
+ s->palettes + s->cur_palette * AVPALETTE_COUNT, AVPALETTE_SIZE); |
|
| 573 | 574 |
|
| 574 | 575 |
s->buf = buf; |
| 575 | 576 |
s->size = buf_size; |
| ... | ... |
@@ -617,5 +620,5 @@ AVCodec ff_xan_wc3_decoder = {
|
| 617 | 617 |
.close = xan_decode_end, |
| 618 | 618 |
.decode = xan_decode_frame, |
| 619 | 619 |
.capabilities = CODEC_CAP_DR1, |
| 620 |
- .long_name = NULL_IF_CONFIG_SMALL("Wing Commander III / Xan"),
|
|
| 620 |
+ .long_name = NULL_IF_CONFIG_SMALL("Wing Commander III / Xan"),
|
|
| 621 | 621 |
}; |
| ... | ... |
@@ -88,8 +88,8 @@ static int zmbv_decode_xor_8(ZmbvContext *c) |
| 88 | 88 |
output = c->cur; |
| 89 | 89 |
prev = c->prev; |
| 90 | 90 |
|
| 91 |
- if(c->flags & ZMBV_DELTAPAL){
|
|
| 92 |
- for(i = 0; i < 768; i++) |
|
| 91 |
+ if (c->flags & ZMBV_DELTAPAL) {
|
|
| 92 |
+ for (i = 0; i < 768; i++) |
|
| 93 | 93 |
c->pal[i] ^= *src++; |
| 94 | 94 |
} |
| 95 | 95 |
|
| ... | ... |
@@ -97,9 +97,9 @@ static int zmbv_decode_xor_8(ZmbvContext *c) |
| 97 | 97 |
src += ((c->bx * c->by * 2 + 3) & ~3); |
| 98 | 98 |
|
| 99 | 99 |
block = 0; |
| 100 |
- for(y = 0; y < c->height; y += c->bh) {
|
|
| 100 |
+ for (y = 0; y < c->height; y += c->bh) {
|
|
| 101 | 101 |
bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y); |
| 102 |
- for(x = 0; x < c->width; x += c->bw) {
|
|
| 102 |
+ for (x = 0; x < c->width; x += c->bw) {
|
|
| 103 | 103 |
uint8_t *out, *tprev; |
| 104 | 104 |
|
| 105 | 105 |
d = mvec[block] & 1; |
| ... | ... |
@@ -114,12 +114,12 @@ static int zmbv_decode_xor_8(ZmbvContext *c) |
| 114 | 114 |
tprev = prev + x + dx + dy * c->width; |
| 115 | 115 |
mx = x + dx; |
| 116 | 116 |
my = y + dy; |
| 117 |
- for(j = 0; j < bh2; j++){
|
|
| 118 |
- if((my + j < 0) || (my + j >= c->height)) {
|
|
| 117 |
+ for (j = 0; j < bh2; j++) {
|
|
| 118 |
+ if (my + j < 0 || my + j >= c->height) {
|
|
| 119 | 119 |
memset(out, 0, bw2); |
| 120 | 120 |
} else {
|
| 121 |
- for(i = 0; i < bw2; i++){
|
|
| 122 |
- if((mx + i < 0) || (mx + i >= c->width)) |
|
| 121 |
+ for (i = 0; i < bw2; i++) {
|
|
| 122 |
+ if (mx + i < 0 || mx + i >= c->width) |
|
| 123 | 123 |
out[i] = 0; |
| 124 | 124 |
else |
| 125 | 125 |
out[i] = tprev[i]; |
| ... | ... |
@@ -129,10 +129,10 @@ static int zmbv_decode_xor_8(ZmbvContext *c) |
| 129 | 129 |
tprev += c->width; |
| 130 | 130 |
} |
| 131 | 131 |
|
| 132 |
- if(d) { /* apply XOR'ed difference */
|
|
| 132 |
+ if (d) { /* apply XOR'ed difference */
|
|
| 133 | 133 |
out = output + x; |
| 134 |
- for(j = 0; j < bh2; j++){
|
|
| 135 |
- for(i = 0; i < bw2; i++) |
|
| 134 |
+ for (j = 0; j < bh2; j++) {
|
|
| 135 |
+ for (i = 0; i < bw2; i++) |
|
| 136 | 136 |
out[i] ^= *src++; |
| 137 | 137 |
out += c->width; |
| 138 | 138 |
} |
| ... | ... |
@@ -141,8 +141,9 @@ static int zmbv_decode_xor_8(ZmbvContext *c) |
| 141 | 141 |
output += c->width * c->bh; |
| 142 | 142 |
prev += c->width * c->bh; |
| 143 | 143 |
} |
| 144 |
- if(src - c->decomp_buf != c->decomp_len) |
|
| 145 |
- av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n", src-c->decomp_buf, c->decomp_len); |
|
| 144 |
+ if (src - c->decomp_buf != c->decomp_len) |
|
| 145 |
+ av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n", |
|
| 146 |
+ src-c->decomp_buf, c->decomp_len); |
|
| 146 | 147 |
return 0; |
| 147 | 148 |
} |
| 148 | 149 |
|
| ... | ... |
@@ -168,9 +169,9 @@ static int zmbv_decode_xor_16(ZmbvContext *c) |
| 168 | 168 |
src += ((c->bx * c->by * 2 + 3) & ~3); |
| 169 | 169 |
|
| 170 | 170 |
block = 0; |
| 171 |
- for(y = 0; y < c->height; y += c->bh) {
|
|
| 171 |
+ for (y = 0; y < c->height; y += c->bh) {
|
|
| 172 | 172 |
bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y); |
| 173 |
- for(x = 0; x < c->width; x += c->bw) {
|
|
| 173 |
+ for (x = 0; x < c->width; x += c->bw) {
|
|
| 174 | 174 |
uint16_t *out, *tprev; |
| 175 | 175 |
|
| 176 | 176 |
d = mvec[block] & 1; |
| ... | ... |
@@ -185,12 +186,12 @@ static int zmbv_decode_xor_16(ZmbvContext *c) |
| 185 | 185 |
tprev = prev + x + dx + dy * c->width; |
| 186 | 186 |
mx = x + dx; |
| 187 | 187 |
my = y + dy; |
| 188 |
- for(j = 0; j < bh2; j++){
|
|
| 189 |
- if((my + j < 0) || (my + j >= c->height)) {
|
|
| 188 |
+ for (j = 0; j < bh2; j++) {
|
|
| 189 |
+ if (my + j < 0 || my + j >= c->height) {
|
|
| 190 | 190 |
memset(out, 0, bw2 * 2); |
| 191 | 191 |
} else {
|
| 192 |
- for(i = 0; i < bw2; i++){
|
|
| 193 |
- if((mx + i < 0) || (mx + i >= c->width)) |
|
| 192 |
+ for (i = 0; i < bw2; i++) {
|
|
| 193 |
+ if (mx + i < 0 || mx + i >= c->width) |
|
| 194 | 194 |
out[i] = 0; |
| 195 | 195 |
else |
| 196 | 196 |
out[i] = tprev[i]; |
| ... | ... |
@@ -200,10 +201,10 @@ static int zmbv_decode_xor_16(ZmbvContext *c) |
| 200 | 200 |
tprev += c->width; |
| 201 | 201 |
} |
| 202 | 202 |
|
| 203 |
- if(d) { /* apply XOR'ed difference */
|
|
| 203 |
+ if (d) { /* apply XOR'ed difference */
|
|
| 204 | 204 |
out = output + x; |
| 205 |
- for(j = 0; j < bh2; j++){
|
|
| 206 |
- for(i = 0; i < bw2; i++) {
|
|
| 205 |
+ for (j = 0; j < bh2; j++){
|
|
| 206 |
+ for (i = 0; i < bw2; i++) {
|
|
| 207 | 207 |
out[i] ^= *((uint16_t*)src); |
| 208 | 208 |
src += 2; |
| 209 | 209 |
} |
| ... | ... |
@@ -214,8 +215,9 @@ static int zmbv_decode_xor_16(ZmbvContext *c) |
| 214 | 214 |
output += c->width * c->bh; |
| 215 | 215 |
prev += c->width * c->bh; |
| 216 | 216 |
} |
| 217 |
- if(src - c->decomp_buf != c->decomp_len) |
|
| 218 |
- av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n", src-c->decomp_buf, c->decomp_len); |
|
| 217 |
+ if (src - c->decomp_buf != c->decomp_len) |
|
| 218 |
+ av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n", |
|
| 219 |
+ src-c->decomp_buf, c->decomp_len); |
|
| 219 | 220 |
return 0; |
| 220 | 221 |
} |
| 221 | 222 |
|
| ... | ... |
@@ -244,9 +246,9 @@ static int zmbv_decode_xor_24(ZmbvContext *c) |
| 244 | 244 |
src += ((c->bx * c->by * 2 + 3) & ~3); |
| 245 | 245 |
|
| 246 | 246 |
block = 0; |
| 247 |
- for(y = 0; y < c->height; y += c->bh) {
|
|
| 247 |
+ for (y = 0; y < c->height; y += c->bh) {
|
|
| 248 | 248 |
bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y); |
| 249 |
- for(x = 0; x < c->width; x += c->bw) {
|
|
| 249 |
+ for (x = 0; x < c->width; x += c->bw) {
|
|
| 250 | 250 |
uint8_t *out, *tprev; |
| 251 | 251 |
|
| 252 | 252 |
d = mvec[block] & 1; |
| ... | ... |
@@ -261,12 +263,12 @@ static int zmbv_decode_xor_24(ZmbvContext *c) |
| 261 | 261 |
tprev = prev + (x + dx) * 3 + dy * stride; |
| 262 | 262 |
mx = x + dx; |
| 263 | 263 |
my = y + dy; |
| 264 |
- for(j = 0; j < bh2; j++){
|
|
| 265 |
- if((my + j < 0) || (my + j >= c->height)) {
|
|
| 264 |
+ for (j = 0; j < bh2; j++) {
|
|
| 265 |
+ if (my + j < 0 || my + j >= c->height) {
|
|
| 266 | 266 |
memset(out, 0, bw2 * 3); |
| 267 | 267 |
} else {
|
| 268 |
- for(i = 0; i < bw2; i++){
|
|
| 269 |
- if((mx + i < 0) || (mx + i >= c->width)) {
|
|
| 268 |
+ for (i = 0; i < bw2; i++){
|
|
| 269 |
+ if (mx + i < 0 || mx + i >= c->width) {
|
|
| 270 | 270 |
out[i * 3 + 0] = 0; |
| 271 | 271 |
out[i * 3 + 1] = 0; |
| 272 | 272 |
out[i * 3 + 2] = 0; |
| ... | ... |
@@ -281,10 +283,10 @@ static int zmbv_decode_xor_24(ZmbvContext *c) |
| 281 | 281 |
tprev += stride; |
| 282 | 282 |
} |
| 283 | 283 |
|
| 284 |
- if(d) { /* apply XOR'ed difference */
|
|
| 284 |
+ if (d) { /* apply XOR'ed difference */
|
|
| 285 | 285 |
out = output + x * 3; |
| 286 |
- for(j = 0; j < bh2; j++){
|
|
| 287 |
- for(i = 0; i < bw2; i++) {
|
|
| 286 |
+ for (j = 0; j < bh2; j++) {
|
|
| 287 |
+ for (i = 0; i < bw2; i++) {
|
|
| 288 | 288 |
out[i * 3 + 0] ^= *src++; |
| 289 | 289 |
out[i * 3 + 1] ^= *src++; |
| 290 | 290 |
out[i * 3 + 2] ^= *src++; |
| ... | ... |
@@ -296,8 +298,9 @@ static int zmbv_decode_xor_24(ZmbvContext *c) |
| 296 | 296 |
output += stride * c->bh; |
| 297 | 297 |
prev += stride * c->bh; |
| 298 | 298 |
} |
| 299 |
- if(src - c->decomp_buf != c->decomp_len) |
|
| 300 |
- av_log(c->avctx, AV_LOG_ERROR, "Used %i of %i bytes\n", src-c->decomp_buf, c->decomp_len); |
|
| 299 |
+ if (src - c->decomp_buf != c->decomp_len) |
|
| 300 |
+ av_log(c->avctx, AV_LOG_ERROR, "Used %i of %i bytes\n", |
|
| 301 |
+ src-c->decomp_buf, c->decomp_len); |
|
| 301 | 302 |
return 0; |
| 302 | 303 |
} |
| 303 | 304 |
#endif //ZMBV_ENABLE_24BPP |
| ... | ... |
@@ -324,9 +327,9 @@ static int zmbv_decode_xor_32(ZmbvContext *c) |
| 324 | 324 |
src += ((c->bx * c->by * 2 + 3) & ~3); |
| 325 | 325 |
|
| 326 | 326 |
block = 0; |
| 327 |
- for(y = 0; y < c->height; y += c->bh) {
|
|
| 327 |
+ for (y = 0; y < c->height; y += c->bh) {
|
|
| 328 | 328 |
bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y); |
| 329 |
- for(x = 0; x < c->width; x += c->bw) {
|
|
| 329 |
+ for (x = 0; x < c->width; x += c->bw) {
|
|
| 330 | 330 |
uint32_t *out, *tprev; |
| 331 | 331 |
|
| 332 | 332 |
d = mvec[block] & 1; |
| ... | ... |
@@ -341,12 +344,12 @@ static int zmbv_decode_xor_32(ZmbvContext *c) |
| 341 | 341 |
tprev = prev + x + dx + dy * c->width; |
| 342 | 342 |
mx = x + dx; |
| 343 | 343 |
my = y + dy; |
| 344 |
- for(j = 0; j < bh2; j++){
|
|
| 345 |
- if((my + j < 0) || (my + j >= c->height)) {
|
|
| 344 |
+ for (j = 0; j < bh2; j++) {
|
|
| 345 |
+ if (my + j < 0 || my + j >= c->height) {
|
|
| 346 | 346 |
memset(out, 0, bw2 * 4); |
| 347 | 347 |
} else {
|
| 348 |
- for(i = 0; i < bw2; i++){
|
|
| 349 |
- if((mx + i < 0) || (mx + i >= c->width)) |
|
| 348 |
+ for (i = 0; i < bw2; i++){
|
|
| 349 |
+ if (mx + i < 0 || mx + i >= c->width) |
|
| 350 | 350 |
out[i] = 0; |
| 351 | 351 |
else |
| 352 | 352 |
out[i] = tprev[i]; |
| ... | ... |
@@ -356,11 +359,11 @@ static int zmbv_decode_xor_32(ZmbvContext *c) |
| 356 | 356 |
tprev += c->width; |
| 357 | 357 |
} |
| 358 | 358 |
|
| 359 |
- if(d) { /* apply XOR'ed difference */
|
|
| 359 |
+ if (d) { /* apply XOR'ed difference */
|
|
| 360 | 360 |
out = output + x; |
| 361 |
- for(j = 0; j < bh2; j++){
|
|
| 362 |
- for(i = 0; i < bw2; i++) {
|
|
| 363 |
- out[i] ^= *((uint32_t*)src); |
|
| 361 |
+ for (j = 0; j < bh2; j++){
|
|
| 362 |
+ for (i = 0; i < bw2; i++) {
|
|
| 363 |
+ out[i] ^= *((uint32_t *) src); |
|
| 364 | 364 |
src += 4; |
| 365 | 365 |
} |
| 366 | 366 |
out += c->width; |
| ... | ... |
@@ -368,10 +371,11 @@ static int zmbv_decode_xor_32(ZmbvContext *c) |
| 368 | 368 |
} |
| 369 | 369 |
} |
| 370 | 370 |
output += c->width * c->bh; |
| 371 |
- prev += c->width * c->bh; |
|
| 371 |
+ prev += c->width * c->bh; |
|
| 372 | 372 |
} |
| 373 |
- if(src - c->decomp_buf != c->decomp_len) |
|
| 374 |
- av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n", src-c->decomp_buf, c->decomp_len); |
|
| 373 |
+ if (src - c->decomp_buf != c->decomp_len) |
|
| 374 |
+ av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n", |
|
| 375 |
+ src-c->decomp_buf, c->decomp_len); |
|
| 375 | 376 |
return 0; |
| 376 | 377 |
} |
| 377 | 378 |
|
| ... | ... |
@@ -401,12 +405,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac |
| 401 | 401 |
int len = buf_size; |
| 402 | 402 |
int hi_ver, lo_ver; |
| 403 | 403 |
|
| 404 |
- if(c->pic.data[0]) |
|
| 404 |
+ if (c->pic.data[0]) |
|
| 405 | 405 |
avctx->release_buffer(avctx, &c->pic); |
| 406 | 406 |
|
| 407 | 407 |
c->pic.reference = 3; |
| 408 | 408 |
c->pic.buffer_hints = FF_BUFFER_HINTS_VALID; |
| 409 |
- if(avctx->get_buffer(avctx, &c->pic) < 0){
|
|
| 409 |
+ if (avctx->get_buffer(avctx, &c->pic) < 0) {
|
|
| 410 | 410 |
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
| 411 | 411 |
return -1; |
| 412 | 412 |
} |
| ... | ... |
@@ -414,7 +418,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac |
| 414 | 414 |
/* parse header */ |
| 415 | 415 |
c->flags = buf[0]; |
| 416 | 416 |
buf++; len--; |
| 417 |
- if(c->flags & ZMBV_KEYFRAME) {
|
|
| 417 |
+ if (c->flags & ZMBV_KEYFRAME) {
|
|
| 418 | 418 |
void *decode_intra = NULL; |
| 419 | 419 |
c->decode_intra= NULL; |
| 420 | 420 |
hi_ver = buf[0]; |
| ... | ... |
@@ -426,21 +430,26 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac |
| 426 | 426 |
|
| 427 | 427 |
buf += 6; |
| 428 | 428 |
len -= 6; |
| 429 |
- av_log(avctx, AV_LOG_DEBUG, "Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n",c->flags,hi_ver,lo_ver,c->comp,c->fmt,c->bw,c->bh); |
|
| 430 |
- if(hi_ver != 0 || lo_ver != 1) {
|
|
| 431 |
- av_log(avctx, AV_LOG_ERROR, "Unsupported version %i.%i\n", hi_ver, lo_ver); |
|
| 429 |
+ av_log(avctx, AV_LOG_DEBUG, |
|
| 430 |
+ "Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n", |
|
| 431 |
+ c->flags,hi_ver,lo_ver,c->comp,c->fmt,c->bw,c->bh); |
|
| 432 |
+ if (hi_ver != 0 || lo_ver != 1) {
|
|
| 433 |
+ av_log(avctx, AV_LOG_ERROR, "Unsupported version %i.%i\n", |
|
| 434 |
+ hi_ver, lo_ver); |
|
| 432 | 435 |
return -1; |
| 433 | 436 |
} |
| 434 |
- if(c->bw == 0 || c->bh == 0) {
|
|
| 435 |
- av_log(avctx, AV_LOG_ERROR, "Unsupported block size %ix%i\n", c->bw, c->bh); |
|
| 437 |
+ if (c->bw == 0 || c->bh == 0) {
|
|
| 438 |
+ av_log(avctx, AV_LOG_ERROR, "Unsupported block size %ix%i\n", |
|
| 439 |
+ c->bw, c->bh); |
|
| 436 | 440 |
return -1; |
| 437 | 441 |
} |
| 438 |
- if(c->comp != 0 && c->comp != 1) {
|
|
| 439 |
- av_log(avctx, AV_LOG_ERROR, "Unsupported compression type %i\n", c->comp); |
|
| 442 |
+ if (c->comp != 0 && c->comp != 1) {
|
|
| 443 |
+ av_log(avctx, AV_LOG_ERROR, "Unsupported compression type %i\n", |
|
| 444 |
+ c->comp); |
|
| 440 | 445 |
return -1; |
| 441 | 446 |
} |
| 442 | 447 |
|
| 443 |
- switch(c->fmt) {
|
|
| 448 |
+ switch (c->fmt) {
|
|
| 444 | 449 |
case ZMBV_FMT_8BPP: |
| 445 | 450 |
c->bpp = 8; |
| 446 | 451 |
decode_intra = zmbv_decode_intra; |
| ... | ... |
@@ -466,7 +475,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac |
| 466 | 466 |
break; |
| 467 | 467 |
default: |
| 468 | 468 |
c->decode_xor = NULL; |
| 469 |
- av_log(avctx, AV_LOG_ERROR, "Unsupported (for now) format %i\n", c->fmt); |
|
| 469 |
+ av_log(avctx, AV_LOG_ERROR, |
|
| 470 |
+ "Unsupported (for now) format %i\n", c->fmt); |
|
| 470 | 471 |
return -1; |
| 471 | 472 |
} |
| 472 | 473 |
|
| ... | ... |
@@ -476,21 +486,21 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac |
| 476 | 476 |
return -1; |
| 477 | 477 |
} |
| 478 | 478 |
|
| 479 |
- c->cur = av_realloc_f(c->cur, avctx->width * avctx->height, (c->bpp / 8)); |
|
| 479 |
+ c->cur = av_realloc_f(c->cur, avctx->width * avctx->height, (c->bpp / 8)); |
|
| 480 | 480 |
c->prev = av_realloc_f(c->prev, avctx->width * avctx->height, (c->bpp / 8)); |
| 481 | 481 |
c->bx = (c->width + c->bw - 1) / c->bw; |
| 482 | 482 |
c->by = (c->height+ c->bh - 1) / c->bh; |
| 483 |
- if(!c->cur || !c->prev) |
|
| 483 |
+ if (!c->cur || !c->prev) |
|
| 484 | 484 |
return -1; |
| 485 | 485 |
c->decode_intra= decode_intra; |
| 486 | 486 |
} |
| 487 | 487 |
|
| 488 |
- if(c->decode_intra == NULL) {
|
|
| 488 |
+ if (c->decode_intra == NULL) {
|
|
| 489 | 489 |
av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n"); |
| 490 | 490 |
return -1; |
| 491 | 491 |
} |
| 492 | 492 |
|
| 493 |
- if(c->comp == 0) { //Uncompressed data
|
|
| 493 |
+ if (c->comp == 0) { //Uncompressed data
|
|
| 494 | 494 |
memcpy(c->decomp_buf, buf, len); |
| 495 | 495 |
c->decomp_size = 1; |
| 496 | 496 |
} else { // ZLIB-compressed data
|
| ... | ... |
@@ -502,14 +512,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac |
| 502 | 502 |
inflate(&c->zstream, Z_FINISH); |
| 503 | 503 |
c->decomp_len = c->zstream.total_out; |
| 504 | 504 |
} |
| 505 |
- if(c->flags & ZMBV_KEYFRAME) {
|
|
| 505 |
+ if (c->flags & ZMBV_KEYFRAME) {
|
|
| 506 | 506 |
c->pic.key_frame = 1; |
| 507 | 507 |
c->pic.pict_type = AV_PICTURE_TYPE_I; |
| 508 | 508 |
c->decode_intra(c); |
| 509 | 509 |
} else {
|
| 510 | 510 |
c->pic.key_frame = 0; |
| 511 | 511 |
c->pic.pict_type = AV_PICTURE_TYPE_P; |
| 512 |
- if(c->decomp_len) |
|
| 512 |
+ if (c->decomp_len) |
|
| 513 | 513 |
c->decode_xor(c); |
| 514 | 514 |
} |
| 515 | 515 |
|
| ... | ... |
@@ -520,10 +530,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac |
| 520 | 520 |
|
| 521 | 521 |
out = c->pic.data[0]; |
| 522 | 522 |
src = c->cur; |
| 523 |
- switch(c->fmt) {
|
|
| 523 |
+ switch (c->fmt) {
|
|
| 524 | 524 |
case ZMBV_FMT_8BPP: |
| 525 |
- for(j = 0; j < c->height; j++) {
|
|
| 526 |
- for(i = 0; i < c->width; i++) {
|
|
| 525 |
+ for (j = 0; j < c->height; j++) {
|
|
| 526 |
+ for (i = 0; i < c->width; i++) {
|
|
| 527 | 527 |
out[i * 3 + 0] = c->pal[(*src) * 3 + 0]; |
| 528 | 528 |
out[i * 3 + 1] = c->pal[(*src) * 3 + 1]; |
| 529 | 529 |
out[i * 3 + 2] = c->pal[(*src) * 3 + 2]; |
| ... | ... |
@@ -533,8 +543,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac |
| 533 | 533 |
} |
| 534 | 534 |
break; |
| 535 | 535 |
case ZMBV_FMT_15BPP: |
| 536 |
- for(j = 0; j < c->height; j++) {
|
|
| 537 |
- for(i = 0; i < c->width; i++) {
|
|
| 536 |
+ for (j = 0; j < c->height; j++) {
|
|
| 537 |
+ for (i = 0; i < c->width; i++) {
|
|
| 538 | 538 |
uint16_t tmp = AV_RL16(src); |
| 539 | 539 |
src += 2; |
| 540 | 540 |
out[i * 3 + 0] = (tmp & 0x7C00) >> 7; |
| ... | ... |
@@ -545,8 +555,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac |
| 545 | 545 |
} |
| 546 | 546 |
break; |
| 547 | 547 |
case ZMBV_FMT_16BPP: |
| 548 |
- for(j = 0; j < c->height; j++) {
|
|
| 549 |
- for(i = 0; i < c->width; i++) {
|
|
| 548 |
+ for (j = 0; j < c->height; j++) {
|
|
| 549 |
+ for (i = 0; i < c->width; i++) {
|
|
| 550 | 550 |
uint16_t tmp = AV_RL16(src); |
| 551 | 551 |
src += 2; |
| 552 | 552 |
out[i * 3 + 0] = (tmp & 0xF800) >> 8; |
| ... | ... |
@@ -558,7 +568,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac |
| 558 | 558 |
break; |
| 559 | 559 |
#ifdef ZMBV_ENABLE_24BPP |
| 560 | 560 |
case ZMBV_FMT_24BPP: |
| 561 |
- for(j = 0; j < c->height; j++) {
|
|
| 561 |
+ for (j = 0; j < c->height; j++) {
|
|
| 562 | 562 |
memcpy(out, src, c->width * 3); |
| 563 | 563 |
src += c->width * 3; |
| 564 | 564 |
out += c->pic.linesize[0]; |
| ... | ... |
@@ -566,8 +576,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac |
| 566 | 566 |
break; |
| 567 | 567 |
#endif //ZMBV_ENABLE_24BPP |
| 568 | 568 |
case ZMBV_FMT_32BPP: |
| 569 |
- for(j = 0; j < c->height; j++) {
|
|
| 570 |
- for(i = 0; i < c->width; i++) {
|
|
| 569 |
+ for (j = 0; j < c->height; j++) {
|
|
| 570 |
+ for (i = 0; i < c->width; i++) {
|
|
| 571 | 571 |
uint32_t tmp = AV_RL32(src); |
| 572 | 572 |
src += 4; |
| 573 | 573 |
AV_WB24(out+(i*3), tmp); |
| ... | ... |
@@ -616,7 +626,8 @@ static av_cold int decode_init(AVCodecContext *avctx) |
| 616 | 616 |
/* Allocate decompression buffer */ |
| 617 | 617 |
if (c->decomp_size) {
|
| 618 | 618 |
if ((c->decomp_buf = av_malloc(c->decomp_size)) == NULL) {
|
| 619 |
- av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); |
|
| 619 |
+ av_log(avctx, AV_LOG_ERROR, |
|
| 620 |
+ "Can't allocate decompression buffer.\n"); |
|
| 620 | 621 |
return 1; |
| 621 | 622 |
} |
| 622 | 623 |
} |
| ... | ... |
@@ -61,9 +61,10 @@ enum {
|
| 61 | 61 |
}; |
| 62 | 62 |
|
| 63 | 63 |
static const AVCodecTag codec_oma_tags[] = {
|
| 64 |
- { CODEC_ID_ATRAC3, OMA_CODECID_ATRAC3 },
|
|
| 65 |
- { CODEC_ID_ATRAC3P, OMA_CODECID_ATRAC3P },
|
|
| 66 |
- { CODEC_ID_MP3, OMA_CODECID_MP3 },
|
|
| 64 |
+ { CODEC_ID_ATRAC3, OMA_CODECID_ATRAC3 },
|
|
| 65 |
+ { CODEC_ID_ATRAC3P, OMA_CODECID_ATRAC3P },
|
|
| 66 |
+ { CODEC_ID_MP3, OMA_CODECID_MP3 },
|
|
| 67 |
+ { CODEC_ID_PCM_S16BE, OMA_CODECID_LPCM },
|
|
| 67 | 68 |
}; |
| 68 | 69 |
|
| 69 | 70 |
static const uint64_t leaf_table[] = {
|
| ... | ... |
@@ -205,8 +206,8 @@ static int decrypt_init(AVFormatContext *s, ID3v2ExtraMeta *em, uint8_t *header) |
| 205 | 205 |
while (em) {
|
| 206 | 206 |
if (!strcmp(em->tag, "GEOB") && |
| 207 | 207 |
(geob = em->data) && |
| 208 |
- !strcmp(geob->description, "OMG_LSI") || |
|
| 209 |
- !strcmp(geob->description, "OMG_BKLSI")) {
|
|
| 208 |
+ (!strcmp(geob->description, "OMG_LSI") || |
|
| 209 |
+ !strcmp(geob->description, "OMG_BKLSI"))) {
|
|
| 210 | 210 |
break; |
| 211 | 211 |
} |
| 212 | 212 |
em = em->next; |
| ... | ... |
@@ -361,6 +362,16 @@ static int oma_read_header(AVFormatContext *s, |
| 361 | 361 |
st->need_parsing = AVSTREAM_PARSE_FULL; |
| 362 | 362 |
framesize = 1024; |
| 363 | 363 |
break; |
| 364 |
+ case OMA_CODECID_LPCM: |
|
| 365 |
+ /* PCM 44.1 kHz 16 bit stereo big-endian */ |
|
| 366 |
+ st->codec->channels = 2; |
|
| 367 |
+ st->codec->sample_rate = 44100; |
|
| 368 |
+ framesize = 1024; |
|
| 369 |
+ /* bit rate = sample rate x PCM block align (= 4) x 8 */ |
|
| 370 |
+ st->codec->bit_rate = st->codec->sample_rate * 32; |
|
| 371 |
+ st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id); |
|
| 372 |
+ avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); |
|
| 373 |
+ break; |
|
| 364 | 374 |
default: |
| 365 | 375 |
av_log(s, AV_LOG_ERROR, "Unsupported codec %d!\n",buf[32]); |
| 366 | 376 |
return -1; |
| ... | ... |
@@ -397,14 +408,20 @@ static int oma_read_probe(AVProbeData *p) |
| 397 | 397 |
unsigned tag_len = 0; |
| 398 | 398 |
|
| 399 | 399 |
buf = p->buf; |
| 400 |
- /* version must be 3 and flags byte zero */ |
|
| 401 |
- if (ff_id3v2_match(buf, ID3v2_EA3_MAGIC) && buf[3] == 3 && !buf[4]) |
|
| 402 |
- tag_len = ff_id3v2_tag_len(buf); |
|
| 403 | 400 |
|
| 404 |
- // This check cannot overflow as tag_len has at most 28 bits |
|
| 405 |
- if (p->buf_size < tag_len + 5) |
|
| 401 |
+ if (p->buf_size < ID3v2_HEADER_SIZE || |
|
| 402 |
+ !ff_id3v2_match(buf, ID3v2_EA3_MAGIC) || |
|
| 403 |
+ buf[3] != 3 || // version must be 3 |
|
| 404 |
+ buf[4]) // flags byte zero |
|
| 406 | 405 |
return 0; |
| 407 | 406 |
|
| 407 |
+ tag_len = ff_id3v2_tag_len(buf); |
|
| 408 |
+ |
|
| 409 |
+ /* This check cannot overflow as tag_len has at most 28 bits */ |
|
| 410 |
+ if (p->buf_size < tag_len + 5) |
|
| 411 |
+ /* EA3 header comes late, might be outside of the probe buffer */ |
|
| 412 |
+ return AVPROBE_SCORE_MAX / 2; |
|
| 413 |
+ |
|
| 408 | 414 |
buf += tag_len; |
| 409 | 415 |
|
| 410 | 416 |
if (!memcmp(buf, "EA3", 3) && !buf[4] && buf[5] == EA3_HEADER_SIZE) |
| ... | ... |
@@ -39,23 +39,24 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf) |
| 39 | 39 |
char inter; |
| 40 | 40 |
const char *colorspace = ""; |
| 41 | 41 |
|
| 42 |
- st = s->streams[0]; |
|
| 43 |
- width = st->codec->width; |
|
| 42 |
+ st = s->streams[0]; |
|
| 43 |
+ width = st->codec->width; |
|
| 44 | 44 |
height = st->codec->height; |
| 45 | 45 |
|
| 46 |
- av_reduce(&raten, &rated, st->codec->time_base.den, st->codec->time_base.num, (1UL<<31)-1); |
|
| 46 |
+ av_reduce(&raten, &rated, st->codec->time_base.den, |
|
| 47 |
+ st->codec->time_base.num, (1UL << 31) - 1); |
|
| 47 | 48 |
|
| 48 | 49 |
aspectn = st->sample_aspect_ratio.num; |
| 49 | 50 |
aspectd = st->sample_aspect_ratio.den; |
| 50 | 51 |
|
| 51 |
- if ( aspectn == 0 && aspectd == 1 ) aspectd = 0; // 0:0 means unknown |
|
| 52 |
+ if (aspectn == 0 && aspectd == 1) |
|
| 53 |
+ aspectd = 0; // 0:0 means unknown |
|
| 52 | 54 |
|
| 53 | 55 |
inter = 'p'; /* progressive is the default */ |
| 54 |
- if (st->codec->coded_frame && st->codec->coded_frame->interlaced_frame) {
|
|
| 56 |
+ if (st->codec->coded_frame && st->codec->coded_frame->interlaced_frame) |
|
| 55 | 57 |
inter = st->codec->coded_frame->top_field_first ? 't' : 'b'; |
| 56 |
- } |
|
| 57 | 58 |
|
| 58 |
- switch(st->codec->pix_fmt) {
|
|
| 59 |
+ switch (st->codec->pix_fmt) {
|
|
| 59 | 60 |
case PIX_FMT_GRAY8: |
| 60 | 61 |
colorspace = " Cmono"; |
| 61 | 62 |
break; |
| ... | ... |
@@ -63,9 +64,11 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf) |
| 63 | 63 |
colorspace = " C411 XYSCSS=411"; |
| 64 | 64 |
break; |
| 65 | 65 |
case PIX_FMT_YUV420P: |
| 66 |
- colorspace = (st->codec->chroma_sample_location == AVCHROMA_LOC_TOPLEFT)?" C420paldv XYSCSS=420PALDV": |
|
| 67 |
- (st->codec->chroma_sample_location == AVCHROMA_LOC_LEFT) ?" C420mpeg2 XYSCSS=420MPEG2": |
|
| 68 |
- " C420jpeg XYSCSS=420JPEG"; |
|
| 66 |
+ switch (st->codec->chroma_sample_location) {
|
|
| 67 |
+ case AVCHROMA_LOC_TOPLEFT: colorspace = " C420paldv XYSCSS=420PALDV"; break; |
|
| 68 |
+ case AVCHROMA_LOC_LEFT: colorspace = " C420mpeg2 XYSCSS=420MPEG2"; break; |
|
| 69 |
+ default: colorspace = " C420jpeg XYSCSS=420JPEG"; break; |
|
| 70 |
+ } |
|
| 69 | 71 |
break; |
| 70 | 72 |
case PIX_FMT_YUV422P: |
| 71 | 73 |
colorspace = " C422 XYSCSS=422"; |
| ... | ... |
@@ -77,13 +80,8 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf) |
| 77 | 77 |
|
| 78 | 78 |
/* construct stream header, if this is the first frame */ |
| 79 | 79 |
n = snprintf(buf, Y4M_LINE_MAX, "%s W%d H%d F%d:%d I%c A%d:%d%s\n", |
| 80 |
- Y4M_MAGIC, |
|
| 81 |
- width, |
|
| 82 |
- height, |
|
| 83 |
- raten, rated, |
|
| 84 |
- inter, |
|
| 85 |
- aspectn, aspectd, |
|
| 86 |
- colorspace); |
|
| 80 |
+ Y4M_MAGIC, width, height, raten, rated, inter, |
|
| 81 |
+ aspectn, aspectd, colorspace); |
|
| 87 | 82 |
|
| 88 | 83 |
return n; |
| 89 | 84 |
} |
| ... | ... |
@@ -96,7 +94,7 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) |
| 96 | 96 |
int* first_pkt = s->priv_data; |
| 97 | 97 |
int width, height, h_chroma_shift, v_chroma_shift; |
| 98 | 98 |
int i; |
| 99 |
- char buf2[Y4M_LINE_MAX+1]; |
|
| 99 |
+ char buf2[Y4M_LINE_MAX + 1]; |
|
| 100 | 100 |
char buf1[20]; |
| 101 | 101 |
uint8_t *ptr, *ptr1, *ptr2; |
| 102 | 102 |
|
| ... | ... |
@@ -106,7 +104,8 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) |
| 106 | 106 |
if (*first_pkt) {
|
| 107 | 107 |
*first_pkt = 0; |
| 108 | 108 |
if (yuv4_generate_header(s, buf2) < 0) {
|
| 109 |
- av_log(s, AV_LOG_ERROR, "Error. YUV4MPEG stream header write failed.\n"); |
|
| 109 |
+ av_log(s, AV_LOG_ERROR, |
|
| 110 |
+ "Error. YUV4MPEG stream header write failed.\n"); |
|
| 110 | 111 |
return AVERROR(EIO); |
| 111 | 112 |
} else {
|
| 112 | 113 |
avio_write(pb, buf2, strlen(buf2)); |
| ... | ... |
@@ -118,31 +117,32 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) |
| 118 | 118 |
snprintf(buf1, sizeof(buf1), "%s\n", Y4M_FRAME_MAGIC); |
| 119 | 119 |
avio_write(pb, buf1, strlen(buf1)); |
| 120 | 120 |
|
| 121 |
- width = st->codec->width; |
|
| 121 |
+ width = st->codec->width; |
|
| 122 | 122 |
height = st->codec->height; |
| 123 | 123 |
|
| 124 | 124 |
ptr = picture->data[0]; |
| 125 |
- for(i=0;i<height;i++) {
|
|
| 125 |
+ for (i = 0; i < height; i++) {
|
|
| 126 | 126 |
avio_write(pb, ptr, width); |
| 127 | 127 |
ptr += picture->linesize[0]; |
| 128 | 128 |
} |
| 129 | 129 |
|
| 130 |
- if (st->codec->pix_fmt != PIX_FMT_GRAY8){
|
|
| 131 |
- // Adjust for smaller Cb and Cr planes |
|
| 132 |
- avcodec_get_chroma_sub_sample(st->codec->pix_fmt, &h_chroma_shift, &v_chroma_shift); |
|
| 133 |
- width >>= h_chroma_shift; |
|
| 134 |
- height >>= v_chroma_shift; |
|
| 135 |
- |
|
| 136 |
- ptr1 = picture->data[1]; |
|
| 137 |
- ptr2 = picture->data[2]; |
|
| 138 |
- for(i=0;i<height;i++) { /* Cb */
|
|
| 139 |
- avio_write(pb, ptr1, width); |
|
| 140 |
- ptr1 += picture->linesize[1]; |
|
| 141 |
- } |
|
| 142 |
- for(i=0;i<height;i++) { /* Cr */
|
|
| 143 |
- avio_write(pb, ptr2, width); |
|
| 130 |
+ if (st->codec->pix_fmt != PIX_FMT_GRAY8) {
|
|
| 131 |
+ // Adjust for smaller Cb and Cr planes |
|
| 132 |
+ avcodec_get_chroma_sub_sample(st->codec->pix_fmt, &h_chroma_shift, |
|
| 133 |
+ &v_chroma_shift); |
|
| 134 |
+ width >>= h_chroma_shift; |
|
| 135 |
+ height >>= v_chroma_shift; |
|
| 136 |
+ |
|
| 137 |
+ ptr1 = picture->data[1]; |
|
| 138 |
+ ptr2 = picture->data[2]; |
|
| 139 |
+ for (i = 0; i < height; i++) { /* Cb */
|
|
| 140 |
+ avio_write(pb, ptr1, width); |
|
| 141 |
+ ptr1 += picture->linesize[1]; |
|
| 142 |
+ } |
|
| 143 |
+ for (i = 0; i < height; i++) { /* Cr */
|
|
| 144 |
+ avio_write(pb, ptr2, width); |
|
| 144 | 145 |
ptr2 += picture->linesize[2]; |
| 145 |
- } |
|
| 146 |
+ } |
|
| 146 | 147 |
} |
| 147 | 148 |
avio_flush(pb); |
| 148 | 149 |
return 0; |
| ... | ... |
@@ -150,7 +150,7 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) |
| 150 | 150 |
|
| 151 | 151 |
static int yuv4_write_header(AVFormatContext *s) |
| 152 | 152 |
{
|
| 153 |
- int* first_pkt = s->priv_data; |
|
| 153 |
+ int *first_pkt = s->priv_data; |
|
| 154 | 154 |
|
| 155 | 155 |
if (s->nb_streams != 1) |
| 156 | 156 |
return AVERROR(EIO); |
| ... | ... |
@@ -162,13 +162,15 @@ static int yuv4_write_header(AVFormatContext *s) |
| 162 | 162 |
} |
| 163 | 163 |
|
| 164 | 164 |
if (s->streams[0]->codec->pix_fmt == PIX_FMT_YUV411P) {
|
| 165 |
- av_log(s, AV_LOG_ERROR, "Warning: generating rarely used 4:1:1 YUV stream, some mjpegtools might not work.\n"); |
|
| 166 |
- } |
|
| 167 |
- else if ((s->streams[0]->codec->pix_fmt != PIX_FMT_YUV420P) && |
|
| 168 |
- (s->streams[0]->codec->pix_fmt != PIX_FMT_YUV422P) && |
|
| 169 |
- (s->streams[0]->codec->pix_fmt != PIX_FMT_GRAY8) && |
|
| 170 |
- (s->streams[0]->codec->pix_fmt != PIX_FMT_YUV444P)) {
|
|
| 171 |
- av_log(s, AV_LOG_ERROR, "ERROR: yuv4mpeg only handles yuv444p, yuv422p, yuv420p, yuv411p and gray pixel formats. Use -pix_fmt to select one.\n"); |
|
| 165 |
+ av_log(s, AV_LOG_ERROR, "Warning: generating rarely used 4:1:1 YUV " |
|
| 166 |
+ "stream, some mjpegtools might not work.\n"); |
|
| 167 |
+ } else if ((s->streams[0]->codec->pix_fmt != PIX_FMT_YUV420P) && |
|
| 168 |
+ (s->streams[0]->codec->pix_fmt != PIX_FMT_YUV422P) && |
|
| 169 |
+ (s->streams[0]->codec->pix_fmt != PIX_FMT_GRAY8) && |
|
| 170 |
+ (s->streams[0]->codec->pix_fmt != PIX_FMT_YUV444P)) {
|
|
| 171 |
+ av_log(s, AV_LOG_ERROR, "ERROR: yuv4mpeg only handles yuv444p, " |
|
| 172 |
+ "yuv422p, yuv420p, yuv411p and gray pixel formats. " |
|
| 173 |
+ "Use -pix_fmt to select one.\n"); |
|
| 172 | 174 |
return AVERROR(EIO); |
| 173 | 175 |
} |
| 174 | 176 |
|
| ... | ... |
@@ -186,7 +188,7 @@ AVOutputFormat ff_yuv4mpegpipe_muxer = {
|
| 186 | 186 |
.video_codec = CODEC_ID_RAWVIDEO, |
| 187 | 187 |
.write_header = yuv4_write_header, |
| 188 | 188 |
.write_packet = yuv4_write_packet, |
| 189 |
- .flags = AVFMT_RAWPICTURE, |
|
| 189 |
+ .flags = AVFMT_RAWPICTURE, |
|
| 190 | 190 |
}; |
| 191 | 191 |
#endif |
| 192 | 192 |
|
| ... | ... |
@@ -196,85 +198,96 @@ AVOutputFormat ff_yuv4mpegpipe_muxer = {
|
| 196 | 196 |
|
| 197 | 197 |
static int yuv4_read_header(AVFormatContext *s, AVFormatParameters *ap) |
| 198 | 198 |
{
|
| 199 |
- char header[MAX_YUV4_HEADER+10]; // Include headroom for the longest option |
|
| 200 |
- char *tokstart,*tokend,*header_end; |
|
| 199 |
+ char header[MAX_YUV4_HEADER + 10]; // Include headroom for |
|
| 200 |
+ // the longest option |
|
| 201 |
+ char *tokstart, *tokend, *header_end; |
|
| 201 | 202 |
int i; |
| 202 | 203 |
AVIOContext *pb = s->pb; |
| 203 |
- int width=-1, height=-1, raten=0, rated=0, aspectn=0, aspectd=0; |
|
| 204 |
- enum PixelFormat pix_fmt=PIX_FMT_NONE,alt_pix_fmt=PIX_FMT_NONE; |
|
| 204 |
+ int width = -1, height = -1, raten = 0, |
|
| 205 |
+ rated = 0, aspectn = 0, aspectd = 0; |
|
| 206 |
+ enum PixelFormat pix_fmt = PIX_FMT_NONE, alt_pix_fmt = PIX_FMT_NONE; |
|
| 205 | 207 |
enum AVChromaLocation chroma_sample_location = AVCHROMA_LOC_UNSPECIFIED; |
| 206 | 208 |
AVStream *st; |
| 207 | 209 |
struct frame_attributes *s1 = s->priv_data; |
| 208 | 210 |
|
| 209 |
- for (i=0; i<MAX_YUV4_HEADER; i++) {
|
|
| 211 |
+ for (i = 0; i < MAX_YUV4_HEADER; i++) {
|
|
| 210 | 212 |
header[i] = avio_r8(pb); |
| 211 | 213 |
if (header[i] == '\n') {
|
| 212 |
- header[i+1] = 0x20; // Add a space after last option. Makes parsing "444" vs "444alpha" easier. |
|
| 213 |
- header[i+2] = 0; |
|
| 214 |
+ header[i + 1] = 0x20; // Add a space after last option. |
|
| 215 |
+ // Makes parsing "444" vs "444alpha" easier. |
|
| 216 |
+ header[i + 2] = 0; |
|
| 214 | 217 |
break; |
| 215 | 218 |
} |
| 216 | 219 |
} |
| 217 |
- if (i == MAX_YUV4_HEADER) return -1; |
|
| 218 |
- if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC))) return -1; |
|
| 220 |
+ if (i == MAX_YUV4_HEADER) |
|
| 221 |
+ return -1; |
|
| 222 |
+ if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC))) |
|
| 223 |
+ return -1; |
|
| 219 | 224 |
|
| 220 | 225 |
s1->interlaced_frame = 0; |
| 221 | 226 |
s1->top_field_first = 0; |
| 222 |
- header_end = &header[i+1]; // Include space |
|
| 223 |
- for(tokstart = &header[strlen(Y4M_MAGIC) + 1]; tokstart < header_end; tokstart++) {
|
|
| 224 |
- if (*tokstart==0x20) continue; |
|
| 227 |
+ header_end = &header[i + 1]; // Include space |
|
| 228 |
+ for (tokstart = &header[strlen(Y4M_MAGIC) + 1]; |
|
| 229 |
+ tokstart < header_end; tokstart++) {
|
|
| 230 |
+ if (*tokstart == 0x20) |
|
| 231 |
+ continue; |
|
| 225 | 232 |
switch (*tokstart++) {
|
| 226 | 233 |
case 'W': // Width. Required. |
| 227 |
- width = strtol(tokstart, &tokend, 10); |
|
| 228 |
- tokstart=tokend; |
|
| 234 |
+ width = strtol(tokstart, &tokend, 10); |
|
| 235 |
+ tokstart = tokend; |
|
| 229 | 236 |
break; |
| 230 | 237 |
case 'H': // Height. Required. |
| 231 |
- height = strtol(tokstart, &tokend, 10); |
|
| 232 |
- tokstart=tokend; |
|
| 238 |
+ height = strtol(tokstart, &tokend, 10); |
|
| 239 |
+ tokstart = tokend; |
|
| 233 | 240 |
break; |
| 234 | 241 |
case 'C': // Color space |
| 235 |
- if (strncmp("420jpeg",tokstart,7)==0) {
|
|
| 242 |
+ if (strncmp("420jpeg", tokstart, 7) == 0) {
|
|
| 236 | 243 |
pix_fmt = PIX_FMT_YUV420P; |
| 237 | 244 |
chroma_sample_location = AVCHROMA_LOC_CENTER; |
| 238 |
- } else if (strncmp("420mpeg2",tokstart,8)==0) {
|
|
| 245 |
+ } else if (strncmp("420mpeg2", tokstart, 8) == 0) {
|
|
| 239 | 246 |
pix_fmt = PIX_FMT_YUV420P; |
| 240 | 247 |
chroma_sample_location = AVCHROMA_LOC_LEFT; |
| 241 |
- } else if (strncmp("420paldv", tokstart, 8)==0) {
|
|
| 248 |
+ } else if (strncmp("420paldv", tokstart, 8) == 0) {
|
|
| 242 | 249 |
pix_fmt = PIX_FMT_YUV420P; |
| 243 | 250 |
chroma_sample_location = AVCHROMA_LOC_TOPLEFT; |
| 244 |
- } else if (strncmp("411", tokstart, 3)==0)
|
|
| 251 |
+ } else if (strncmp("411", tokstart, 3) == 0)
|
|
| 245 | 252 |
pix_fmt = PIX_FMT_YUV411P; |
| 246 |
- else if (strncmp("422", tokstart, 3)==0)
|
|
| 253 |
+ else if (strncmp("422", tokstart, 3) == 0)
|
|
| 247 | 254 |
pix_fmt = PIX_FMT_YUV422P; |
| 248 |
- else if (strncmp("444alpha", tokstart, 8)==0) {
|
|
| 249 |
- av_log(s, AV_LOG_ERROR, "Cannot handle 4:4:4:4 YUV4MPEG stream.\n"); |
|
| 255 |
+ else if (strncmp("444alpha", tokstart, 8) == 0 ) {
|
|
| 256 |
+ av_log(s, AV_LOG_ERROR, "Cannot handle 4:4:4:4 " |
|
| 257 |
+ "YUV4MPEG stream.\n"); |
|
| 250 | 258 |
return -1; |
| 251 |
- } else if (strncmp("444", tokstart, 3)==0)
|
|
| 259 |
+ } else if (strncmp("444", tokstart, 3) == 0)
|
|
| 252 | 260 |
pix_fmt = PIX_FMT_YUV444P; |
| 253 |
- else if (strncmp("mono",tokstart, 4)==0) {
|
|
| 261 |
+ else if (strncmp("mono", tokstart, 4) == 0) {
|
|
| 254 | 262 |
pix_fmt = PIX_FMT_GRAY8; |
| 255 | 263 |
} else {
|
| 256 |
- av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains an unknown pixel format.\n"); |
|
| 264 |
+ av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains an unknown " |
|
| 265 |
+ "pixel format.\n"); |
|
| 257 | 266 |
return -1; |
| 258 | 267 |
} |
| 259 |
- while(tokstart<header_end&&*tokstart!=0x20) tokstart++; |
|
| 268 |
+ while (tokstart < header_end && *tokstart != 0x20) |
|
| 269 |
+ tokstart++; |
|
| 260 | 270 |
break; |
| 261 | 271 |
case 'I': // Interlace type |
| 262 | 272 |
switch (*tokstart++){
|
| 263 | 273 |
case '?': |
| 264 | 274 |
break; |
| 265 | 275 |
case 'p': |
| 266 |
- s1->interlaced_frame=0; |
|
| 276 |
+ s1->interlaced_frame = 0; |
|
| 267 | 277 |
break; |
| 268 | 278 |
case 't': |
| 269 |
- s1->interlaced_frame=1; |
|
| 270 |
- s1->top_field_first=1; |
|
| 279 |
+ s1->interlaced_frame = 1; |
|
| 280 |
+ s1->top_field_first = 1; |
|
| 271 | 281 |
break; |
| 272 | 282 |
case 'b': |
| 273 |
- s1->interlaced_frame=1; |
|
| 274 |
- s1->top_field_first=0; |
|
| 283 |
+ s1->interlaced_frame = 1; |
|
| 284 |
+ s1->top_field_first = 0; |
|
| 275 | 285 |
break; |
| 276 | 286 |
case 'm': |
| 277 |
- av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains mixed interlaced and non-interlaced frames.\n"); |
|
| 287 |
+ av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains mixed " |
|
| 288 |
+ "interlaced and non-interlaced frames.\n"); |
|
| 278 | 289 |
return -1; |
| 279 | 290 |
default: |
| 280 | 291 |
av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n"); |
| ... | ... |
@@ -282,36 +295,39 @@ static int yuv4_read_header(AVFormatContext *s, AVFormatParameters *ap) |
| 282 | 282 |
} |
| 283 | 283 |
break; |
| 284 | 284 |
case 'F': // Frame rate |
| 285 |
- sscanf(tokstart,"%d:%d",&raten,&rated); // 0:0 if unknown |
|
| 286 |
- while(tokstart<header_end&&*tokstart!=0x20) tokstart++; |
|
| 285 |
+ sscanf(tokstart, "%d:%d", &raten, &rated); // 0:0 if unknown |
|
| 286 |
+ while (tokstart < header_end && *tokstart != 0x20) |
|
| 287 |
+ tokstart++; |
|
| 287 | 288 |
break; |
| 288 | 289 |
case 'A': // Pixel aspect |
| 289 |
- sscanf(tokstart,"%d:%d",&aspectn,&aspectd); // 0:0 if unknown |
|
| 290 |
- while(tokstart<header_end&&*tokstart!=0x20) tokstart++; |
|
| 290 |
+ sscanf(tokstart, "%d:%d", &aspectn, &aspectd); // 0:0 if unknown |
|
| 291 |
+ while (tokstart < header_end && *tokstart != 0x20) |
|
| 292 |
+ tokstart++; |
|
| 291 | 293 |
break; |
| 292 | 294 |
case 'X': // Vendor extensions |
| 293 |
- if (strncmp("YSCSS=",tokstart,6)==0) {
|
|
| 295 |
+ if (strncmp("YSCSS=", tokstart, 6) == 0) {
|
|
| 294 | 296 |
// Older nonstandard pixel format representation |
| 295 |
- tokstart+=6; |
|
| 296 |
- if (strncmp("420JPEG",tokstart,7)==0)
|
|
| 297 |
- alt_pix_fmt=PIX_FMT_YUV420P; |
|
| 298 |
- else if (strncmp("420MPEG2",tokstart,8)==0)
|
|
| 299 |
- alt_pix_fmt=PIX_FMT_YUV420P; |
|
| 300 |
- else if (strncmp("420PALDV",tokstart,8)==0)
|
|
| 301 |
- alt_pix_fmt=PIX_FMT_YUV420P; |
|
| 302 |
- else if (strncmp("411",tokstart,3)==0)
|
|
| 303 |
- alt_pix_fmt=PIX_FMT_YUV411P; |
|
| 304 |
- else if (strncmp("422",tokstart,3)==0)
|
|
| 305 |
- alt_pix_fmt=PIX_FMT_YUV422P; |
|
| 306 |
- else if (strncmp("444",tokstart,3)==0)
|
|
| 307 |
- alt_pix_fmt=PIX_FMT_YUV444P; |
|
| 297 |
+ tokstart += 6; |
|
| 298 |
+ if (strncmp("420JPEG", tokstart, 7) == 0)
|
|
| 299 |
+ alt_pix_fmt = PIX_FMT_YUV420P; |
|
| 300 |
+ else if (strncmp("420MPEG2", tokstart, 8) == 0)
|
|
| 301 |
+ alt_pix_fmt = PIX_FMT_YUV420P; |
|
| 302 |
+ else if (strncmp("420PALDV", tokstart, 8) == 0)
|
|
| 303 |
+ alt_pix_fmt = PIX_FMT_YUV420P; |
|
| 304 |
+ else if (strncmp("411", tokstart, 3) == 0)
|
|
| 305 |
+ alt_pix_fmt = PIX_FMT_YUV411P; |
|
| 306 |
+ else if (strncmp("422", tokstart, 3) == 0)
|
|
| 307 |
+ alt_pix_fmt = PIX_FMT_YUV422P; |
|
| 308 |
+ else if (strncmp("444", tokstart, 3) == 0)
|
|
| 309 |
+ alt_pix_fmt = PIX_FMT_YUV444P; |
|
| 308 | 310 |
} |
| 309 |
- while(tokstart<header_end&&*tokstart!=0x20) tokstart++; |
|
| 311 |
+ while (tokstart < header_end && *tokstart != 0x20) |
|
| 312 |
+ tokstart++; |
|
| 310 | 313 |
break; |
| 311 | 314 |
} |
| 312 | 315 |
} |
| 313 | 316 |
|
| 314 |
- if ((width == -1) || (height == -1)) {
|
|
| 317 |
+ if (width == -1 || height == -1) {
|
|
| 315 | 318 |
av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n"); |
| 316 | 319 |
return -1; |
| 317 | 320 |
} |
| ... | ... |
@@ -335,16 +351,16 @@ static int yuv4_read_header(AVFormatContext *s, AVFormatParameters *ap) |
| 335 | 335 |
} |
| 336 | 336 |
|
| 337 | 337 |
st = avformat_new_stream(s, NULL); |
| 338 |
- if(!st) |
|
| 338 |
+ if (!st) |
|
| 339 | 339 |
return AVERROR(ENOMEM); |
| 340 |
- st->codec->width = width; |
|
| 340 |
+ st->codec->width = width; |
|
| 341 | 341 |
st->codec->height = height; |
| 342 |
- av_reduce(&raten, &rated, raten, rated, (1UL<<31)-1); |
|
| 342 |
+ av_reduce(&raten, &rated, raten, rated, (1UL << 31) - 1); |
|
| 343 | 343 |
avpriv_set_pts_info(st, 64, rated, raten); |
| 344 |
- st->codec->pix_fmt = pix_fmt; |
|
| 345 |
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO; |
|
| 346 |
- st->codec->codec_id = CODEC_ID_RAWVIDEO; |
|
| 347 |
- st->sample_aspect_ratio= (AVRational){aspectn, aspectd};
|
|
| 344 |
+ st->codec->pix_fmt = pix_fmt; |
|
| 345 |
+ st->codec->codec_type = AVMEDIA_TYPE_VIDEO; |
|
| 346 |
+ st->codec->codec_id = CODEC_ID_RAWVIDEO; |
|
| 347 |
+ st->sample_aspect_ratio = (AVRational){ aspectn, aspectd };
|
|
| 348 | 348 |
st->codec->chroma_sample_location = chroma_sample_location; |
| 349 | 349 |
|
| 350 | 350 |
return 0; |
| ... | ... |
@@ -358,17 +374,19 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt) |
| 358 | 358 |
AVStream *st = s->streams[0]; |
| 359 | 359 |
struct frame_attributes *s1 = s->priv_data; |
| 360 | 360 |
|
| 361 |
- for (i=0; i<MAX_FRAME_HEADER; i++) {
|
|
| 361 |
+ for (i = 0; i < MAX_FRAME_HEADER; i++) {
|
|
| 362 | 362 |
header[i] = avio_r8(s->pb); |
| 363 | 363 |
if (header[i] == '\n') {
|
| 364 |
- header[i+1] = 0; |
|
| 364 |
+ header[i + 1] = 0; |
|
| 365 | 365 |
break; |
| 366 | 366 |
} |
| 367 | 367 |
} |
| 368 |
- if (i == MAX_FRAME_HEADER) return -1; |
|
| 369 |
- if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC))) return -1; |
|
| 368 |
+ if (i == MAX_FRAME_HEADER) |
|
| 369 |
+ return -1; |
|
| 370 |
+ if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC))) |
|
| 371 |
+ return -1; |
|
| 370 | 372 |
|
| 371 |
- width = st->codec->width; |
|
| 373 |
+ width = st->codec->width; |
|
| 372 | 374 |
height = st->codec->height; |
| 373 | 375 |
|
| 374 | 376 |
packet_size = avpicture_get_size(st->codec->pix_fmt, width, height); |
| ... | ... |
@@ -378,9 +396,9 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt) |
| 378 | 378 |
if (av_get_packet(s->pb, pkt, packet_size) != packet_size) |
| 379 | 379 |
return AVERROR(EIO); |
| 380 | 380 |
|
| 381 |
- if (s->streams[0]->codec->coded_frame) {
|
|
| 382 |
- s->streams[0]->codec->coded_frame->interlaced_frame = s1->interlaced_frame; |
|
| 383 |
- s->streams[0]->codec->coded_frame->top_field_first = s1->top_field_first; |
|
| 381 |
+ if (st->codec->coded_frame) {
|
|
| 382 |
+ st->codec->coded_frame->interlaced_frame = s1->interlaced_frame; |
|
| 383 |
+ st->codec->coded_frame->top_field_first = s1->top_field_first; |
|
| 384 | 384 |
} |
| 385 | 385 |
|
| 386 | 386 |
pkt->stream_index = 0; |
| ... | ... |
@@ -390,7 +408,7 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt) |
| 390 | 390 |
static int yuv4_probe(AVProbeData *pd) |
| 391 | 391 |
{
|
| 392 | 392 |
/* check file header */ |
| 393 |
- if (strncmp(pd->buf, Y4M_MAGIC, sizeof(Y4M_MAGIC)-1)==0) |
|
| 393 |
+ if (strncmp(pd->buf, Y4M_MAGIC, sizeof(Y4M_MAGIC) - 1) == 0) |
|
| 394 | 394 |
return AVPROBE_SCORE_MAX; |
| 395 | 395 |
else |
| 396 | 396 |
return 0; |
| ... | ... |
@@ -404,6 +422,6 @@ AVInputFormat ff_yuv4mpegpipe_demuxer = {
|
| 404 | 404 |
.read_probe = yuv4_probe, |
| 405 | 405 |
.read_header = yuv4_read_header, |
| 406 | 406 |
.read_packet = yuv4_read_packet, |
| 407 |
- .extensions = "y4m" |
|
| 407 |
+ .extensions = "y4m" |
|
| 408 | 408 |
}; |
| 409 | 409 |
#endif |
| ... | ... |
@@ -56,32 +56,34 @@ static AVCRC av_crc_table[AV_CRC_MAX][257]; |
| 56 | 56 |
* @param ctx_size size of ctx in bytes |
| 57 | 57 |
* @return <0 on failure |
| 58 | 58 |
*/ |
| 59 |
-int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size){
|
|
| 59 |
+int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size) |
|
| 60 |
+{
|
|
| 60 | 61 |
unsigned i, j; |
| 61 | 62 |
uint32_t c; |
| 62 | 63 |
|
| 63 |
- if (bits < 8 || bits > 32 || poly >= (1LL<<bits)) |
|
| 64 |
+ if (bits < 8 || bits > 32 || poly >= (1LL << bits)) |
|
| 64 | 65 |
return -1; |
| 65 |
- if (ctx_size != sizeof(AVCRC)*257 && ctx_size != sizeof(AVCRC)*1024) |
|
| 66 |
+ if (ctx_size != sizeof(AVCRC) * 257 && ctx_size != sizeof(AVCRC) * 1024) |
|
| 66 | 67 |
return -1; |
| 67 | 68 |
|
| 68 | 69 |
for (i = 0; i < 256; i++) {
|
| 69 | 70 |
if (le) {
|
| 70 | 71 |
for (c = i, j = 0; j < 8; j++) |
| 71 |
- c = (c>>1)^(poly & (-(c&1))); |
|
| 72 |
+ c = (c >> 1) ^ (poly & (-(c & 1))); |
|
| 72 | 73 |
ctx[i] = c; |
| 73 | 74 |
} else {
|
| 74 | 75 |
for (c = i << 24, j = 0; j < 8; j++) |
| 75 |
- c = (c<<1) ^ ((poly<<(32-bits)) & (((int32_t)c)>>31) ); |
|
| 76 |
+ c = (c << 1) ^ ((poly << (32 - bits)) & (((int32_t) c) >> 31)); |
|
| 76 | 77 |
ctx[i] = av_bswap32(c); |
| 77 | 78 |
} |
| 78 | 79 |
} |
| 79 |
- ctx[256]=1; |
|
| 80 |
+ ctx[256] = 1; |
|
| 80 | 81 |
#if !CONFIG_SMALL |
| 81 |
- if(ctx_size >= sizeof(AVCRC)*1024) |
|
| 82 |
+ if (ctx_size >= sizeof(AVCRC) * 1024) |
|
| 82 | 83 |
for (i = 0; i < 256; i++) |
| 83 |
- for(j=0; j<3; j++) |
|
| 84 |
- ctx[256*(j+1) + i]= (ctx[256*j + i]>>8) ^ ctx[ ctx[256*j + i]&0xFF ]; |
|
| 84 |
+ for (j = 0; j < 3; j++) |
|
| 85 |
+ ctx[256 *(j + 1) + i] = |
|
| 86 |
+ (ctx[256 * j + i] >> 8) ^ ctx[ctx[256 * j + i] & 0xFF]; |
|
| 85 | 87 |
#endif |
| 86 | 88 |
|
| 87 | 89 |
return 0; |
| ... | ... |
@@ -92,9 +94,10 @@ int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size){
|
| 92 | 92 |
* @param crc_id ID of a standard CRC |
| 93 | 93 |
* @return a pointer to the CRC table or NULL on failure |
| 94 | 94 |
*/ |
| 95 |
-const AVCRC *av_crc_get_table(AVCRCId crc_id){
|
|
| 95 |
+const AVCRC *av_crc_get_table(AVCRCId crc_id) |
|
| 96 |
+{
|
|
| 96 | 97 |
#if !CONFIG_HARDCODED_TABLES |
| 97 |
- if (!av_crc_table[crc_id][FF_ARRAY_ELEMS(av_crc_table[crc_id])-1]) |
|
| 98 |
+ if (!av_crc_table[crc_id][FF_ARRAY_ELEMS(av_crc_table[crc_id]) - 1]) |
|
| 98 | 99 |
if (av_crc_init(av_crc_table[crc_id], |
| 99 | 100 |
av_crc_table_params[crc_id].le, |
| 100 | 101 |
av_crc_table_params[crc_id].bits, |
| ... | ... |
@@ -112,46 +115,50 @@ const AVCRC *av_crc_get_table(AVCRCId crc_id){
|
| 112 | 112 |
* |
| 113 | 113 |
* @see av_crc_init() "le" parameter |
| 114 | 114 |
*/ |
| 115 |
-uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length){
|
|
| 116 |
- const uint8_t *end= buffer+length; |
|
| 115 |
+uint32_t av_crc(const AVCRC *ctx, uint32_t crc, |
|
| 116 |
+ const uint8_t *buffer, size_t length) |
|
| 117 |
+{
|
|
| 118 |
+ const uint8_t *end = buffer + length; |
|
| 117 | 119 |
|
| 118 | 120 |
#if !CONFIG_SMALL |
| 119 |
- if(!ctx[256]) {
|
|
| 120 |
- while(((intptr_t) buffer & 3) && buffer < end) |
|
| 121 |
- crc = ctx[((uint8_t)crc) ^ *buffer++] ^ (crc >> 8); |
|
| 121 |
+ if (!ctx[256]) {
|
|
| 122 |
+ while (((intptr_t) buffer & 3) && buffer < end) |
|
| 123 |
+ crc = ctx[((uint8_t) crc) ^ *buffer++] ^ (crc >> 8); |
|
| 122 | 124 |
|
| 123 |
- while(buffer<end-3){
|
|
| 124 |
- crc ^= av_le2ne32(*(const uint32_t*)buffer); buffer+=4; |
|
| 125 |
- crc = ctx[3*256 + ( crc &0xFF)] |
|
| 126 |
- ^ctx[2*256 + ((crc>>8 )&0xFF)] |
|
| 127 |
- ^ctx[1*256 + ((crc>>16)&0xFF)] |
|
| 128 |
- ^ctx[0*256 + ((crc>>24) )]; |
|
| 125 |
+ while (buffer < end - 3) {
|
|
| 126 |
+ crc ^= av_le2ne32(*(const uint32_t *) buffer); buffer += 4; |
|
| 127 |
+ crc = ctx[3 * 256 + ( crc & 0xFF)] ^ |
|
| 128 |
+ ctx[2 * 256 + ((crc >> 8 ) & 0xFF)] ^ |
|
| 129 |
+ ctx[1 * 256 + ((crc >> 16) & 0xFF)] ^ |
|
| 130 |
+ ctx[0 * 256 + ((crc >> 24) )]; |
|
| 129 | 131 |
} |
| 130 | 132 |
} |
| 131 | 133 |
#endif |
| 132 |
- while(buffer<end) |
|
| 133 |
- crc = ctx[((uint8_t)crc) ^ *buffer++] ^ (crc >> 8); |
|
| 134 |
+ while (buffer < end) |
|
| 135 |
+ crc = ctx[((uint8_t) crc) ^ *buffer++] ^ (crc >> 8); |
|
| 134 | 136 |
|
| 135 | 137 |
return crc; |
| 136 | 138 |
} |
| 137 | 139 |
|
| 138 | 140 |
#ifdef TEST |
| 139 | 141 |
#undef printf |
| 140 |
-int main(void){
|
|
| 142 |
+int main(void) |
|
| 143 |
+{
|
|
| 141 | 144 |
uint8_t buf[1999]; |
| 142 | 145 |
int i; |
| 143 |
- int p[4][3]={{AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04},
|
|
| 144 |
- {AV_CRC_32_IEEE , 0x04C11DB7, 0xC0F5BAE0},
|
|
| 145 |
- {AV_CRC_16_ANSI , 0x8005, 0x1FBB },
|
|
| 146 |
- {AV_CRC_8_ATM , 0x07, 0xE3 },};
|
|
| 146 |
+ int p[4][3] = { { AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04 },
|
|
| 147 |
+ { AV_CRC_32_IEEE , 0x04C11DB7, 0xC0F5BAE0 },
|
|
| 148 |
+ { AV_CRC_16_ANSI , 0x8005 , 0x1FBB },
|
|
| 149 |
+ { AV_CRC_8_ATM , 0x07 , 0xE3 }
|
|
| 150 |
+ }; |
|
| 147 | 151 |
const AVCRC *ctx; |
| 148 | 152 |
|
| 149 |
- for(i=0; i<sizeof(buf); i++) |
|
| 150 |
- buf[i]= i+i*i; |
|
| 153 |
+ for (i = 0; i < sizeof(buf); i++) |
|
| 154 |
+ buf[i] = i + i * i; |
|
| 151 | 155 |
|
| 152 |
- for(i=0; i<4; i++){
|
|
| 156 |
+ for (i = 0; i < 4; i++) {
|
|
| 153 | 157 |
ctx = av_crc_get_table(p[i][0]); |
| 154 |
- printf("crc %08X =%X\n", p[i][1], av_crc(ctx, 0, buf, sizeof(buf)));
|
|
| 158 |
+ printf("crc %08X = %X\n", p[i][1], av_crc(ctx, 0, buf, sizeof(buf)));
|
|
| 155 | 159 |
} |
| 156 | 160 |
return 0; |
| 157 | 161 |
} |
| ... | ... |
@@ -27,19 +27,21 @@ |
| 27 | 27 |
#include "intreadwrite.h" |
| 28 | 28 |
#include "attributes.h" |
| 29 | 29 |
|
| 30 |
-void av_cold av_lfg_init(AVLFG *c, unsigned int seed){
|
|
| 31 |
- uint8_t tmp[16]={0};
|
|
| 30 |
+void av_cold av_lfg_init(AVLFG *c, unsigned int seed) |
|
| 31 |
+{
|
|
| 32 |
+ uint8_t tmp[16] = { 0 };
|
|
| 32 | 33 |
int i; |
| 33 | 34 |
|
| 34 |
- for(i=8; i<64; i+=4){
|
|
| 35 |
- AV_WL32(tmp, seed); tmp[4]=i; |
|
| 36 |
- av_md5_sum(tmp, tmp, 16); |
|
| 37 |
- c->state[i ]= AV_RL32(tmp); |
|
| 38 |
- c->state[i+1]= AV_RL32(tmp+4); |
|
| 39 |
- c->state[i+2]= AV_RL32(tmp+8); |
|
| 40 |
- c->state[i+3]= AV_RL32(tmp+12); |
|
| 35 |
+ for (i = 8; i < 64; i += 4) {
|
|
| 36 |
+ AV_WL32(tmp, seed); |
|
| 37 |
+ tmp[4] = i; |
|
| 38 |
+ av_md5_sum(tmp, tmp, 16); |
|
| 39 |
+ c->state[i ] = AV_RL32(tmp); |
|
| 40 |
+ c->state[i + 1] = AV_RL32(tmp + 4); |
|
| 41 |
+ c->state[i + 2] = AV_RL32(tmp + 8); |
|
| 42 |
+ c->state[i + 3] = AV_RL32(tmp + 12); |
|
| 41 | 43 |
} |
| 42 |
- c->index=0; |
|
| 44 |
+ c->index = 0; |
|
| 43 | 45 |
} |
| 44 | 46 |
|
| 45 | 47 |
void av_bmg_get(AVLFG *lfg, double out[2]) |
| ... | ... |
@@ -47,9 +49,9 @@ void av_bmg_get(AVLFG *lfg, double out[2]) |
| 47 | 47 |
double x1, x2, w; |
| 48 | 48 |
|
| 49 | 49 |
do {
|
| 50 |
- x1 = 2.0/UINT_MAX*av_lfg_get(lfg) - 1.0; |
|
| 51 |
- x2 = 2.0/UINT_MAX*av_lfg_get(lfg) - 1.0; |
|
| 52 |
- w = x1*x1 + x2*x2; |
|
| 50 |
+ x1 = 2.0 / UINT_MAX * av_lfg_get(lfg) - 1.0; |
|
| 51 |
+ x2 = 2.0 / UINT_MAX * av_lfg_get(lfg) - 1.0; |
|
| 52 |
+ w = x1 * x1 + x2 * x2; |
|
| 53 | 53 |
} while (w >= 1.0); |
| 54 | 54 |
|
| 55 | 55 |
w = sqrt((-2.0 * log(w)) / w); |
| ... | ... |
@@ -63,7 +65,7 @@ void av_bmg_get(AVLFG *lfg, double out[2]) |
| 63 | 63 |
|
| 64 | 64 |
int main(void) |
| 65 | 65 |
{
|
| 66 |
- int x=0; |
|
| 66 |
+ int x = 0; |
|
| 67 | 67 |
int i, j; |
| 68 | 68 |
AVLFG state; |
| 69 | 69 |
|
| ... | ... |
@@ -71,8 +73,8 @@ int main(void) |
| 71 | 71 |
for (j = 0; j < 10000; j++) {
|
| 72 | 72 |
START_TIMER |
| 73 | 73 |
for (i = 0; i < 624; i++) {
|
| 74 |
-// av_log(NULL,AV_LOG_ERROR, "%X\n", av_lfg_get(&state)); |
|
| 75 |
- x+=av_lfg_get(&state); |
|
| 74 |
+ //av_log(NULL, AV_LOG_ERROR, "%X\n", av_lfg_get(&state)); |
|
| 75 |
+ x += av_lfg_get(&state); |
|
| 76 | 76 |
} |
| 77 | 77 |
STOP_TIMER("624 calls of av_lfg_get");
|
| 78 | 78 |
} |
| ... | ... |
@@ -34,49 +34,54 @@ static int flags; |
| 34 | 34 |
|
| 35 | 35 |
#if defined(_WIN32) && !defined(__MINGW32CE__) |
| 36 | 36 |
#include <windows.h> |
| 37 |
-static const uint8_t color[] = {12,12,12,14,7,7,7};
|
|
| 37 |
+static const uint8_t color[] = { 12, 12, 12, 14, 7, 7, 7 };
|
|
| 38 | 38 |
static int16_t background, attr_orig; |
| 39 | 39 |
static HANDLE con; |
| 40 | 40 |
#define set_color(x) SetConsoleTextAttribute(con, background | color[x]) |
| 41 | 41 |
#define reset_color() SetConsoleTextAttribute(con, attr_orig) |
| 42 | 42 |
#else |
| 43 |
-static const uint8_t color[]={0x41,0x41,0x11,0x03,9,9,9};
|
|
| 44 |
-#define set_color(x) fprintf(stderr, "\033[%d;3%dm", color[x]>>4, color[x]&15) |
|
| 43 |
+static const uint8_t color[] = { 0x41, 0x41, 0x11, 0x03, 9, 9, 9 };
|
|
| 44 |
+#define set_color(x) fprintf(stderr, "\033[%d;3%dm", color[x] >> 4, color[x]&15) |
|
| 45 | 45 |
#define reset_color() fprintf(stderr, "\033[0m") |
| 46 | 46 |
#endif |
| 47 |
-static int use_color=-1; |
|
| 47 |
+static int use_color = -1; |
|
| 48 | 48 |
|
| 49 | 49 |
#undef fprintf |
| 50 |
-static void colored_fputs(int level, const char *str){
|
|
| 51 |
- if(use_color<0){
|
|
| 50 |
+static void colored_fputs(int level, const char *str) |
|
| 51 |
+{
|
|
| 52 |
+ if (use_color < 0) {
|
|
| 52 | 53 |
#if defined(_WIN32) && !defined(__MINGW32CE__) |
| 53 | 54 |
CONSOLE_SCREEN_BUFFER_INFO con_info; |
| 54 | 55 |
con = GetStdHandle(STD_ERROR_HANDLE); |
| 55 |
- use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR");
|
|
| 56 |
+ use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR") &&
|
|
| 57 |
+ !getenv("AV_LOG_FORCE_NOCOLOR");
|
|
| 56 | 58 |
if (use_color) {
|
| 57 | 59 |
GetConsoleScreenBufferInfo(con, &con_info); |
| 58 | 60 |
attr_orig = con_info.wAttributes; |
| 59 | 61 |
background = attr_orig & 0xF0; |
| 60 | 62 |
} |
| 61 | 63 |
#elif HAVE_ISATTY |
| 62 |
- use_color= !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR") &&
|
|
| 63 |
- (getenv("TERM") && isatty(2) || getenv("AV_LOG_FORCE_COLOR"));
|
|
| 64 |
+ use_color = !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR") &&
|
|
| 65 |
+ (getenv("TERM") && isatty(2) ||
|
|
| 66 |
+ getenv("AV_LOG_FORCE_COLOR"));
|
|
| 64 | 67 |
#else |
| 65 |
- use_color= getenv("AV_LOG_FORCE_COLOR") && !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR");
|
|
| 68 |
+ use_color = getenv("AV_LOG_FORCE_COLOR") && !getenv("NO_COLOR") &&
|
|
| 69 |
+ !getenv("AV_LOG_FORCE_NOCOLOR");
|
|
| 66 | 70 |
#endif |
| 67 | 71 |
} |
| 68 | 72 |
|
| 69 |
- if(use_color){
|
|
| 73 |
+ if (use_color) {
|
|
| 70 | 74 |
set_color(level); |
| 71 | 75 |
} |
| 72 | 76 |
fputs(str, stderr); |
| 73 |
- if(use_color){
|
|
| 77 |
+ if (use_color) {
|
|
| 74 | 78 |
reset_color(); |
| 75 | 79 |
} |
| 76 | 80 |
} |
| 77 | 81 |
|
| 78 |
-const char* av_default_item_name(void* ptr){
|
|
| 79 |
- return (*(AVClass**)ptr)->class_name; |
|
| 82 |
+const char *av_default_item_name(void *ptr) |
|
| 83 |
+{
|
|
| 84 |
+ return (*(AVClass **) ptr)->class_name; |
|
| 80 | 85 |
} |
| 81 | 86 |
|
| 82 | 87 |
static void sanitize(uint8_t *line){
|
| ... | ... |
@@ -89,58 +94,64 @@ static void sanitize(uint8_t *line){
|
| 89 | 89 |
|
| 90 | 90 |
void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) |
| 91 | 91 |
{
|
| 92 |
- static int print_prefix=1; |
|
| 92 |
+ static int print_prefix = 1; |
|
| 93 | 93 |
static int count; |
| 94 | 94 |
static char prev[1024]; |
| 95 | 95 |
char line[1024]; |
| 96 | 96 |
static int is_atty; |
| 97 |
- AVClass* avc= ptr ? *(AVClass**)ptr : NULL; |
|
| 98 |
- if(level>av_log_level) |
|
| 97 |
+ AVClass* avc = ptr ? *(AVClass **) ptr : NULL; |
|
| 98 |
+ if (level > av_log_level) |
|
| 99 | 99 |
return; |
| 100 |
- line[0]=0; |
|
| 100 |
+ line[0] = 0; |
|
| 101 | 101 |
#undef fprintf |
| 102 |
- if(print_prefix && avc) {
|
|
| 102 |
+ if (print_prefix && avc) {
|
|
| 103 | 103 |
if (avc->parent_log_context_offset) {
|
| 104 |
- AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset); |
|
| 105 |
- if(parent && *parent){
|
|
| 106 |
- snprintf(line, sizeof(line), "[%s @ %p] ", (*parent)->item_name(parent), parent); |
|
| 104 |
+ AVClass** parent = *(AVClass ***) (((uint8_t *) ptr) + |
|
| 105 |
+ avc->parent_log_context_offset); |
|
| 106 |
+ if (parent && *parent) {
|
|
| 107 |
+ snprintf(line, sizeof(line), "[%s @ %p] ", |
|
| 108 |
+ (*parent)->item_name(parent), parent); |
|
| 107 | 109 |
} |
| 108 | 110 |
} |
| 109 |
- snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p] ", avc->item_name(ptr), ptr); |
|
| 111 |
+ snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p] ", |
|
| 112 |
+ avc->item_name(ptr), ptr); |
|
| 110 | 113 |
} |
| 111 | 114 |
|
| 112 | 115 |
vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl); |
| 113 | 116 |
|
| 114 |
- print_prefix = strlen(line) && line[strlen(line)-1] == '\n'; |
|
| 117 |
+ print_prefix = strlen(line) && line[strlen(line) - 1] == '\n'; |
|
| 115 | 118 |
|
| 116 | 119 |
#if HAVE_ISATTY |
| 117 |
- if(!is_atty) is_atty= isatty(2) ? 1 : -1; |
|
| 120 |
+ if (!is_atty) |
|
| 121 |
+ is_atty = isatty(2) ? 1 : -1; |
|
| 118 | 122 |
#endif |
| 119 | 123 |
|
| 120 |
- if(print_prefix && (flags & AV_LOG_SKIP_REPEATED) && !strcmp(line, prev)){
|
|
| 124 |
+ if (print_prefix && (flags & AV_LOG_SKIP_REPEATED) && !strcmp(line, prev)){
|
|
| 121 | 125 |
count++; |
| 122 |
- if(is_atty==1) |
|
| 126 |
+ if (is_atty == 1) |
|
| 123 | 127 |
fprintf(stderr, " Last message repeated %d times\r", count); |
| 124 | 128 |
return; |
| 125 | 129 |
} |
| 126 |
- if(count>0){
|
|
| 130 |
+ if (count > 0) {
|
|
| 127 | 131 |
fprintf(stderr, " Last message repeated %d times\n", count); |
| 128 |
- count=0; |
|
| 132 |
+ count = 0; |
|
| 129 | 133 |
} |
| 130 | 134 |
strcpy(prev, line); |
| 131 | 135 |
sanitize(line); |
| 132 |
- colored_fputs(av_clip(level>>3, 0, 6), line); |
|
| 136 |
+ colored_fputs(av_clip(level >> 3, 0, 6), line); |
|
| 133 | 137 |
} |
| 134 | 138 |
|
| 135 |
-static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback; |
|
| 139 |
+static void (*av_log_callback)(void*, int, const char*, va_list) = |
|
| 140 |
+ av_log_default_callback; |
|
| 136 | 141 |
|
| 137 | 142 |
void av_log(void* avcl, int level, const char *fmt, ...) |
| 138 | 143 |
{
|
| 139 |
- AVClass* avc= avcl ? *(AVClass**)avcl : NULL; |
|
| 144 |
+ AVClass* avc = avcl ? *(AVClass **) avcl : NULL; |
|
| 140 | 145 |
va_list vl; |
| 141 | 146 |
va_start(vl, fmt); |
| 142 |
- if(avc && avc->version >= (50<<16 | 15<<8 | 2) && avc->log_level_offset_offset && level>=AV_LOG_FATAL) |
|
| 143 |
- level += *(int*)(((uint8_t*)avcl) + avc->log_level_offset_offset); |
|
| 147 |
+ if (avc && avc->version >= (50 << 16 | 15 << 8 | 2) && |
|
| 148 |
+ avc->log_level_offset_offset && level >= AV_LOG_FATAL) |
|
| 149 |
+ level += *(int *) (((uint8_t *) avcl) + avc->log_level_offset_offset); |
|
| 144 | 150 |
av_vlog(avcl, level, fmt, vl); |
| 145 | 151 |
va_end(vl); |
| 146 | 152 |
} |
| ... | ... |
@@ -162,7 +173,7 @@ void av_log_set_level(int level) |
| 162 | 162 |
|
| 163 | 163 |
void av_log_set_flags(int arg) |
| 164 | 164 |
{
|
| 165 |
- flags= arg; |
|
| 165 |
+ flags = arg; |
|
| 166 | 166 |
} |
| 167 | 167 |
|
| 168 | 168 |
void av_log_set_callback(void (*callback)(void*, int, const char*, va_list)) |
| ... | ... |
@@ -27,45 +27,46 @@ |
| 27 | 27 |
#include "intreadwrite.h" |
| 28 | 28 |
|
| 29 | 29 |
void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], |
| 30 |
- const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component) |
|
| 30 |
+ const AVPixFmtDescriptor *desc, int x, int y, int c, int w, |
|
| 31 |
+ int read_pal_component) |
|
| 31 | 32 |
{
|
| 32 |
- AVComponentDescriptor comp= desc->comp[c]; |
|
| 33 |
- int plane= comp.plane; |
|
| 34 |
- int depth= comp.depth_minus1+1; |
|
| 35 |
- int mask = (1<<depth)-1; |
|
| 36 |
- int shift= comp.shift; |
|
| 37 |
- int step = comp.step_minus1+1; |
|
| 38 |
- int flags= desc->flags; |
|
| 33 |
+ AVComponentDescriptor comp = desc->comp[c]; |
|
| 34 |
+ int plane = comp.plane; |
|
| 35 |
+ int depth = comp.depth_minus1 + 1; |
|
| 36 |
+ int mask = (1 << depth) - 1; |
|
| 37 |
+ int shift = comp.shift; |
|
| 38 |
+ int step = comp.step_minus1 + 1; |
|
| 39 |
+ int flags = desc->flags; |
|
| 39 | 40 |
|
| 40 |
- if (flags & PIX_FMT_BITSTREAM){
|
|
| 41 |
- int skip = x*step + comp.offset_plus1-1; |
|
| 42 |
- const uint8_t *p = data[plane] + y*linesize[plane] + (skip>>3); |
|
| 43 |
- int shift = 8 - depth - (skip&7); |
|
| 41 |
+ if (flags & PIX_FMT_BITSTREAM) {
|
|
| 42 |
+ int skip = x * step + comp.offset_plus1 - 1; |
|
| 43 |
+ const uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3); |
|
| 44 |
+ int shift = 8 - depth - (skip & 7); |
|
| 44 | 45 |
|
| 45 |
- while(w--){
|
|
| 46 |
+ while (w--) {
|
|
| 46 | 47 |
int val = (*p >> shift) & mask; |
| 47 |
- if(read_pal_component) |
|
| 48 |
- val= data[1][4*val + c]; |
|
| 48 |
+ if (read_pal_component) |
|
| 49 |
+ val = data[1][4*val + c]; |
|
| 49 | 50 |
shift -= step; |
| 50 |
- p -= shift>>3; |
|
| 51 |
+ p -= shift >> 3; |
|
| 51 | 52 |
shift &= 7; |
| 52 |
- *dst++= val; |
|
| 53 |
+ *dst++ = val; |
|
| 53 | 54 |
} |
| 54 | 55 |
} else {
|
| 55 |
- const uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1; |
|
| 56 |
+ const uint8_t *p = data[plane] + y * linesize[plane] + x * step + comp.offset_plus1 - 1; |
|
| 56 | 57 |
int is_8bit = shift + depth <= 8; |
| 57 | 58 |
|
| 58 | 59 |
if (is_8bit) |
| 59 | 60 |
p += !!(flags & PIX_FMT_BE); |
| 60 | 61 |
|
| 61 |
- while(w--){
|
|
| 62 |
+ while (w--) {
|
|
| 62 | 63 |
int val = is_8bit ? *p : |
| 63 | 64 |
flags & PIX_FMT_BE ? AV_RB16(p) : AV_RL16(p); |
| 64 |
- val = (val>>shift) & mask; |
|
| 65 |
- if(read_pal_component) |
|
| 66 |
- val= data[1][4*val + c]; |
|
| 67 |
- p+= step; |
|
| 68 |
- *dst++= val; |
|
| 65 |
+ val = (val >> shift) & mask; |
|
| 66 |
+ if (read_pal_component) |
|
| 67 |
+ val = data[1][4 * val + c]; |
|
| 68 |
+ p += step; |
|
| 69 |
+ *dst++ = val; |
|
| 69 | 70 |
} |
| 70 | 71 |
} |
| 71 | 72 |
} |
| ... | ... |
@@ -75,41 +76,41 @@ void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesi |
| 75 | 75 |
{
|
| 76 | 76 |
AVComponentDescriptor comp = desc->comp[c]; |
| 77 | 77 |
int plane = comp.plane; |
| 78 |
- int depth = comp.depth_minus1+1; |
|
| 79 |
- int step = comp.step_minus1+1; |
|
| 78 |
+ int depth = comp.depth_minus1 + 1; |
|
| 79 |
+ int step = comp.step_minus1 + 1; |
|
| 80 | 80 |
int flags = desc->flags; |
| 81 | 81 |
|
| 82 | 82 |
if (flags & PIX_FMT_BITSTREAM) {
|
| 83 |
- int skip = x*step + comp.offset_plus1-1; |
|
| 84 |
- uint8_t *p = data[plane] + y*linesize[plane] + (skip>>3); |
|
| 85 |
- int shift = 8 - depth - (skip&7); |
|
| 83 |
+ int skip = x * step + comp.offset_plus1 - 1; |
|
| 84 |
+ uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3); |
|
| 85 |
+ int shift = 8 - depth - (skip & 7); |
|
| 86 | 86 |
|
| 87 | 87 |
while (w--) {
|
| 88 | 88 |
*p |= *src++ << shift; |
| 89 | 89 |
shift -= step; |
| 90 |
- p -= shift>>3; |
|
| 90 |
+ p -= shift >> 3; |
|
| 91 | 91 |
shift &= 7; |
| 92 | 92 |
} |
| 93 | 93 |
} else {
|
| 94 | 94 |
int shift = comp.shift; |
| 95 |
- uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1; |
|
| 95 |
+ uint8_t *p = data[plane] + y * linesize[plane] + x * step + comp.offset_plus1 - 1; |
|
| 96 | 96 |
|
| 97 | 97 |
if (shift + depth <= 8) {
|
| 98 | 98 |
p += !!(flags & PIX_FMT_BE); |
| 99 | 99 |
while (w--) {
|
| 100 |
- *p |= (*src++<<shift); |
|
| 100 |
+ *p |= (*src++ << shift); |
|
| 101 | 101 |
p += step; |
| 102 | 102 |
} |
| 103 | 103 |
} else {
|
| 104 | 104 |
while (w--) {
|
| 105 | 105 |
if (flags & PIX_FMT_BE) {
|
| 106 |
- uint16_t val = AV_RB16(p) | (*src++<<shift); |
|
| 106 |
+ uint16_t val = AV_RB16(p) | (*src++ << shift); |
|
| 107 | 107 |
AV_WB16(p, val); |
| 108 | 108 |
} else {
|
| 109 |
- uint16_t val = AV_RL16(p) | (*src++<<shift); |
|
| 109 |
+ uint16_t val = AV_RL16(p) | (*src++ << shift); |
|
| 110 | 110 |
AV_WL16(p, val); |
| 111 | 111 |
} |
| 112 |
- p+= step; |
|
| 112 |
+ p += step; |
|
| 113 | 113 |
} |
| 114 | 114 |
} |
| 115 | 115 |
} |
| ... | ... |
@@ -118,171 +119,171 @@ void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesi |
| 118 | 118 |
const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
|
| 119 | 119 |
[PIX_FMT_YUV420P] = {
|
| 120 | 120 |
.name = "yuv420p", |
| 121 |
- .nb_components= 3, |
|
| 122 |
- .log2_chroma_w= 1, |
|
| 123 |
- .log2_chroma_h= 1, |
|
| 121 |
+ .nb_components = 3, |
|
| 122 |
+ .log2_chroma_w = 1, |
|
| 123 |
+ .log2_chroma_h = 1, |
|
| 124 | 124 |
.comp = {
|
| 125 |
- {0,0,1,0,7}, /* Y */
|
|
| 126 |
- {1,0,1,0,7}, /* U */
|
|
| 127 |
- {2,0,1,0,7}, /* V */
|
|
| 125 |
+ { 0, 0, 1, 0, 7 }, /* Y */
|
|
| 126 |
+ { 1, 0, 1, 0, 7 }, /* U */
|
|
| 127 |
+ { 2, 0, 1, 0, 7 }, /* V */
|
|
| 128 | 128 |
}, |
| 129 | 129 |
.flags = PIX_FMT_PLANAR, |
| 130 | 130 |
}, |
| 131 | 131 |
[PIX_FMT_YUYV422] = {
|
| 132 | 132 |
.name = "yuyv422", |
| 133 |
- .nb_components= 3, |
|
| 134 |
- .log2_chroma_w= 1, |
|
| 135 |
- .log2_chroma_h= 0, |
|
| 133 |
+ .nb_components = 3, |
|
| 134 |
+ .log2_chroma_w = 1, |
|
| 135 |
+ .log2_chroma_h = 0, |
|
| 136 | 136 |
.comp = {
|
| 137 |
- {0,1,1,0,7}, /* Y */
|
|
| 138 |
- {0,3,2,0,7}, /* U */
|
|
| 139 |
- {0,3,4,0,7}, /* V */
|
|
| 137 |
+ { 0, 1, 1, 0, 7 }, /* Y */
|
|
| 138 |
+ { 0, 3, 2, 0, 7 }, /* U */
|
|
| 139 |
+ { 0, 3, 4, 0, 7 }, /* V */
|
|
| 140 | 140 |
}, |
| 141 | 141 |
}, |
| 142 | 142 |
[PIX_FMT_RGB24] = {
|
| 143 | 143 |
.name = "rgb24", |
| 144 |
- .nb_components= 3, |
|
| 145 |
- .log2_chroma_w= 0, |
|
| 146 |
- .log2_chroma_h= 0, |
|
| 144 |
+ .nb_components = 3, |
|
| 145 |
+ .log2_chroma_w = 0, |
|
| 146 |
+ .log2_chroma_h = 0, |
|
| 147 | 147 |
.comp = {
|
| 148 |
- {0,2,1,0,7}, /* R */
|
|
| 149 |
- {0,2,2,0,7}, /* G */
|
|
| 150 |
- {0,2,3,0,7}, /* B */
|
|
| 148 |
+ { 0, 2, 1, 0, 7 }, /* R */
|
|
| 149 |
+ { 0, 2, 2, 0, 7 }, /* G */
|
|
| 150 |
+ { 0, 2, 3, 0, 7 }, /* B */
|
|
| 151 | 151 |
}, |
| 152 | 152 |
.flags = PIX_FMT_RGB, |
| 153 | 153 |
}, |
| 154 | 154 |
[PIX_FMT_BGR24] = {
|
| 155 | 155 |
.name = "bgr24", |
| 156 |
- .nb_components= 3, |
|
| 157 |
- .log2_chroma_w= 0, |
|
| 158 |
- .log2_chroma_h= 0, |
|
| 156 |
+ .nb_components = 3, |
|
| 157 |
+ .log2_chroma_w = 0, |
|
| 158 |
+ .log2_chroma_h = 0, |
|
| 159 | 159 |
.comp = {
|
| 160 |
- {0,2,1,0,7}, /* B */
|
|
| 161 |
- {0,2,2,0,7}, /* G */
|
|
| 162 |
- {0,2,3,0,7}, /* R */
|
|
| 160 |
+ { 0, 2, 1, 0, 7 }, /* B */
|
|
| 161 |
+ { 0, 2, 2, 0, 7 }, /* G */
|
|
| 162 |
+ { 0, 2, 3, 0, 7 }, /* R */
|
|
| 163 | 163 |
}, |
| 164 | 164 |
.flags = PIX_FMT_RGB, |
| 165 | 165 |
}, |
| 166 | 166 |
[PIX_FMT_YUV422P] = {
|
| 167 | 167 |
.name = "yuv422p", |
| 168 |
- .nb_components= 3, |
|
| 169 |
- .log2_chroma_w= 1, |
|
| 170 |
- .log2_chroma_h= 0, |
|
| 168 |
+ .nb_components = 3, |
|
| 169 |
+ .log2_chroma_w = 1, |
|
| 170 |
+ .log2_chroma_h = 0, |
|
| 171 | 171 |
.comp = {
|
| 172 |
- {0,0,1,0,7}, /* Y */
|
|
| 173 |
- {1,0,1,0,7}, /* U */
|
|
| 174 |
- {2,0,1,0,7}, /* V */
|
|
| 172 |
+ { 0, 0, 1, 0, 7 }, /* Y */
|
|
| 173 |
+ { 1, 0, 1, 0, 7 }, /* U */
|
|
| 174 |
+ { 2, 0, 1, 0, 7 }, /* V */
|
|
| 175 | 175 |
}, |
| 176 | 176 |
.flags = PIX_FMT_PLANAR, |
| 177 | 177 |
}, |
| 178 | 178 |
[PIX_FMT_YUV444P] = {
|
| 179 | 179 |
.name = "yuv444p", |
| 180 |
- .nb_components= 3, |
|
| 181 |
- .log2_chroma_w= 0, |
|
| 182 |
- .log2_chroma_h= 0, |
|
| 180 |
+ .nb_components = 3, |
|
| 181 |
+ .log2_chroma_w = 0, |
|
| 182 |
+ .log2_chroma_h = 0, |
|
| 183 | 183 |
.comp = {
|
| 184 |
- {0,0,1,0,7}, /* Y */
|
|
| 185 |
- {1,0,1,0,7}, /* U */
|
|
| 186 |
- {2,0,1,0,7}, /* V */
|
|
| 184 |
+ { 0, 0, 1, 0, 7 }, /* Y */
|
|
| 185 |
+ { 1, 0, 1, 0, 7 }, /* U */
|
|
| 186 |
+ { 2, 0, 1, 0, 7 }, /* V */
|
|
| 187 | 187 |
}, |
| 188 | 188 |
.flags = PIX_FMT_PLANAR, |
| 189 | 189 |
}, |
| 190 | 190 |
[PIX_FMT_YUV410P] = {
|
| 191 | 191 |
.name = "yuv410p", |
| 192 |
- .nb_components= 3, |
|
| 193 |
- .log2_chroma_w= 2, |
|
| 194 |
- .log2_chroma_h= 2, |
|
| 192 |
+ .nb_components = 3, |
|
| 193 |
+ .log2_chroma_w = 2, |
|
| 194 |
+ .log2_chroma_h = 2, |
|
| 195 | 195 |
.comp = {
|
| 196 |
- {0,0,1,0,7}, /* Y */
|
|
| 197 |
- {1,0,1,0,7}, /* U */
|
|
| 198 |
- {2,0,1,0,7}, /* V */
|
|
| 196 |
+ { 0, 0, 1, 0, 7 }, /* Y */
|
|
| 197 |
+ { 1, 0, 1, 0, 7 }, /* U */
|
|
| 198 |
+ { 2, 0, 1, 0, 7 }, /* V */
|
|
| 199 | 199 |
}, |
| 200 | 200 |
.flags = PIX_FMT_PLANAR, |
| 201 | 201 |
}, |
| 202 | 202 |
[PIX_FMT_YUV411P] = {
|
| 203 | 203 |
.name = "yuv411p", |
| 204 |
- .nb_components= 3, |
|
| 205 |
- .log2_chroma_w= 2, |
|
| 206 |
- .log2_chroma_h= 0, |
|
| 204 |
+ .nb_components = 3, |
|
| 205 |
+ .log2_chroma_w = 2, |
|
| 206 |
+ .log2_chroma_h = 0, |
|
| 207 | 207 |
.comp = {
|
| 208 |
- {0,0,1,0,7}, /* Y */
|
|
| 209 |
- {1,0,1,0,7}, /* U */
|
|
| 210 |
- {2,0,1,0,7}, /* V */
|
|
| 208 |
+ { 0, 0, 1, 0, 7 }, /* Y */
|
|
| 209 |
+ { 1, 0, 1, 0, 7 }, /* U */
|
|
| 210 |
+ { 2, 0, 1, 0, 7 }, /* V */
|
|
| 211 | 211 |
}, |
| 212 | 212 |
.flags = PIX_FMT_PLANAR, |
| 213 | 213 |
}, |
| 214 | 214 |
[PIX_FMT_GRAY8] = {
|
| 215 | 215 |
.name = "gray", |
| 216 |
- .nb_components= 1, |
|
| 217 |
- .log2_chroma_w= 0, |
|
| 218 |
- .log2_chroma_h= 0, |
|
| 216 |
+ .nb_components = 1, |
|
| 217 |
+ .log2_chroma_w = 0, |
|
| 218 |
+ .log2_chroma_h = 0, |
|
| 219 | 219 |
.comp = {
|
| 220 |
- {0,0,1,0,7}, /* Y */
|
|
| 220 |
+ { 0, 0, 1, 0, 7 }, /* Y */
|
|
| 221 | 221 |
}, |
| 222 | 222 |
}, |
| 223 | 223 |
[PIX_FMT_MONOWHITE] = {
|
| 224 | 224 |
.name = "monow", |
| 225 |
- .nb_components= 1, |
|
| 226 |
- .log2_chroma_w= 0, |
|
| 227 |
- .log2_chroma_h= 0, |
|
| 225 |
+ .nb_components = 1, |
|
| 226 |
+ .log2_chroma_w = 0, |
|
| 227 |
+ .log2_chroma_h = 0, |
|
| 228 | 228 |
.comp = {
|
| 229 |
- {0,0,1,0,0}, /* Y */
|
|
| 229 |
+ { 0, 0, 1, 0, 0 }, /* Y */
|
|
| 230 | 230 |
}, |
| 231 | 231 |
.flags = PIX_FMT_BITSTREAM, |
| 232 | 232 |
}, |
| 233 | 233 |
[PIX_FMT_MONOBLACK] = {
|
| 234 | 234 |
.name = "monob", |
| 235 |
- .nb_components= 1, |
|
| 236 |
- .log2_chroma_w= 0, |
|
| 237 |
- .log2_chroma_h= 0, |
|
| 235 |
+ .nb_components = 1, |
|
| 236 |
+ .log2_chroma_w = 0, |
|
| 237 |
+ .log2_chroma_h = 0, |
|
| 238 | 238 |
.comp = {
|
| 239 |
- {0,0,1,7,0}, /* Y */
|
|
| 239 |
+ { 0, 0, 1, 7, 0 }, /* Y */
|
|
| 240 | 240 |
}, |
| 241 | 241 |
.flags = PIX_FMT_BITSTREAM, |
| 242 | 242 |
}, |
| 243 | 243 |
[PIX_FMT_PAL8] = {
|
| 244 | 244 |
.name = "pal8", |
| 245 |
- .nb_components= 1, |
|
| 246 |
- .log2_chroma_w= 0, |
|
| 247 |
- .log2_chroma_h= 0, |
|
| 245 |
+ .nb_components = 1, |
|
| 246 |
+ .log2_chroma_w = 0, |
|
| 247 |
+ .log2_chroma_h = 0, |
|
| 248 | 248 |
.comp = {
|
| 249 |
- {0,0,1,0,7},
|
|
| 249 |
+ { 0, 0, 1, 0, 7 },
|
|
| 250 | 250 |
}, |
| 251 | 251 |
.flags = PIX_FMT_PAL, |
| 252 | 252 |
}, |
| 253 | 253 |
[PIX_FMT_YUVJ420P] = {
|
| 254 | 254 |
.name = "yuvj420p", |
| 255 |
- .nb_components= 3, |
|
| 256 |
- .log2_chroma_w= 1, |
|
| 257 |
- .log2_chroma_h= 1, |
|
| 255 |
+ .nb_components = 3, |
|
| 256 |
+ .log2_chroma_w = 1, |
|
| 257 |
+ .log2_chroma_h = 1, |
|
| 258 | 258 |
.comp = {
|
| 259 |
- {0,0,1,0,7}, /* Y */
|
|
| 260 |
- {1,0,1,0,7}, /* U */
|
|
| 261 |
- {2,0,1,0,7}, /* V */
|
|
| 259 |
+ { 0, 0, 1, 0, 7 }, /* Y */
|
|
| 260 |
+ { 1, 0, 1, 0, 7 }, /* U */
|
|
| 261 |
+ { 2, 0, 1, 0, 7 }, /* V */
|
|
| 262 | 262 |
}, |
| 263 | 263 |
.flags = PIX_FMT_PLANAR, |
| 264 | 264 |
}, |
| 265 | 265 |
[PIX_FMT_YUVJ422P] = {
|
| 266 | 266 |
.name = "yuvj422p", |
| 267 |
- .nb_components= 3, |
|
| 268 |
- .log2_chroma_w= 1, |
|
| 269 |
- .log2_chroma_h= 0, |
|
| 267 |
+ .nb_components = 3, |
|
| 268 |
+ .log2_chroma_w = 1, |
|
| 269 |
+ .log2_chroma_h = 0, |
|
| 270 | 270 |
.comp = {
|
| 271 |
- {0,0,1,0,7}, /* Y */
|
|
| 272 |
- {1,0,1,0,7}, /* U */
|
|
| 273 |
- {2,0,1,0,7}, /* V */
|
|
| 271 |
+ { 0, 0, 1, 0, 7 }, /* Y */
|
|
| 272 |
+ { 1, 0, 1, 0, 7 }, /* U */
|
|
| 273 |
+ { 2, 0, 1, 0, 7 }, /* V */
|
|
| 274 | 274 |
}, |
| 275 | 275 |
.flags = PIX_FMT_PLANAR, |
| 276 | 276 |
}, |
| 277 | 277 |
[PIX_FMT_YUVJ444P] = {
|
| 278 | 278 |
.name = "yuvj444p", |
| 279 |
- .nb_components= 3, |
|
| 280 |
- .log2_chroma_w= 0, |
|
| 281 |
- .log2_chroma_h= 0, |
|
| 279 |
+ .nb_components = 3, |
|
| 280 |
+ .log2_chroma_w = 0, |
|
| 281 |
+ .log2_chroma_h = 0, |
|
| 282 | 282 |
.comp = {
|
| 283 |
- {0,0,1,0,7}, /* Y */
|
|
| 284 |
- {1,0,1,0,7}, /* U */
|
|
| 285 |
- {2,0,1,0,7}, /* V */
|
|
| 283 |
+ {0, 0, 1, 0, 7}, /* Y */
|
|
| 284 |
+ {1, 0, 1, 0, 7}, /* U */
|
|
| 285 |
+ {2, 0, 1, 0, 7}, /* V */
|
|
| 286 | 286 |
}, |
| 287 | 287 |
.flags = PIX_FMT_PLANAR, |
| 288 | 288 |
}, |
| ... | ... |
@@ -296,171 +297,171 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
|
| 296 | 296 |
}, |
| 297 | 297 |
[PIX_FMT_UYVY422] = {
|
| 298 | 298 |
.name = "uyvy422", |
| 299 |
- .nb_components= 3, |
|
| 300 |
- .log2_chroma_w= 1, |
|
| 301 |
- .log2_chroma_h= 0, |
|
| 299 |
+ .nb_components = 3, |
|
| 300 |
+ .log2_chroma_w = 1, |
|
| 301 |
+ .log2_chroma_h = 0, |
|
| 302 | 302 |
.comp = {
|
| 303 |
- {0,1,2,0,7}, /* Y */
|
|
| 304 |
- {0,3,1,0,7}, /* U */
|
|
| 305 |
- {0,3,3,0,7}, /* V */
|
|
| 303 |
+ { 0, 1, 2, 0, 7 }, /* Y */
|
|
| 304 |
+ { 0, 3, 1, 0, 7 }, /* U */
|
|
| 305 |
+ { 0, 3, 3, 0, 7 }, /* V */
|
|
| 306 | 306 |
}, |
| 307 | 307 |
}, |
| 308 | 308 |
[PIX_FMT_UYYVYY411] = {
|
| 309 | 309 |
.name = "uyyvyy411", |
| 310 |
- .nb_components= 3, |
|
| 311 |
- .log2_chroma_w= 2, |
|
| 312 |
- .log2_chroma_h= 0, |
|
| 310 |
+ .nb_components = 3, |
|
| 311 |
+ .log2_chroma_w = 2, |
|
| 312 |
+ .log2_chroma_h = 0, |
|
| 313 | 313 |
.comp = {
|
| 314 |
- {0,3,2,0,7}, /* Y */
|
|
| 315 |
- {0,5,1,0,7}, /* U */
|
|
| 316 |
- {0,5,4,0,7}, /* V */
|
|
| 314 |
+ { 0, 3, 2, 0, 7 }, /* Y */
|
|
| 315 |
+ { 0, 5, 1, 0, 7 }, /* U */
|
|
| 316 |
+ { 0, 5, 4, 0, 7 }, /* V */
|
|
| 317 | 317 |
}, |
| 318 | 318 |
}, |
| 319 | 319 |
[PIX_FMT_BGR8] = {
|
| 320 | 320 |
.name = "bgr8", |
| 321 |
- .nb_components= 3, |
|
| 322 |
- .log2_chroma_w= 0, |
|
| 323 |
- .log2_chroma_h= 0, |
|
| 321 |
+ .nb_components = 3, |
|
| 322 |
+ .log2_chroma_w = 0, |
|
| 323 |
+ .log2_chroma_h = 0, |
|
| 324 | 324 |
.comp = {
|
| 325 |
- {0,0,1,6,1}, /* B */
|
|
| 326 |
- {0,0,1,3,2}, /* G */
|
|
| 327 |
- {0,0,1,0,2}, /* R */
|
|
| 325 |
+ { 0, 0, 1, 6, 1 }, /* B */
|
|
| 326 |
+ { 0, 0, 1, 3, 2 }, /* G */
|
|
| 327 |
+ { 0, 0, 1, 0, 2 }, /* R */
|
|
| 328 | 328 |
}, |
| 329 | 329 |
.flags = PIX_FMT_PAL | PIX_FMT_RGB, |
| 330 | 330 |
}, |
| 331 | 331 |
[PIX_FMT_BGR4] = {
|
| 332 | 332 |
.name = "bgr4", |
| 333 |
- .nb_components= 3, |
|
| 334 |
- .log2_chroma_w= 0, |
|
| 335 |
- .log2_chroma_h= 0, |
|
| 333 |
+ .nb_components = 3, |
|
| 334 |
+ .log2_chroma_w = 0, |
|
| 335 |
+ .log2_chroma_h = 0, |
|
| 336 | 336 |
.comp = {
|
| 337 |
- {0,3,1,0,0}, /* B */
|
|
| 338 |
- {0,3,2,0,1}, /* G */
|
|
| 339 |
- {0,3,4,0,0}, /* R */
|
|
| 337 |
+ { 0, 3, 1, 0, 0 }, /* B */
|
|
| 338 |
+ { 0, 3, 2, 0, 1 }, /* G */
|
|
| 339 |
+ { 0, 3, 4, 0, 0 }, /* R */
|
|
| 340 | 340 |
}, |
| 341 | 341 |
.flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB, |
| 342 | 342 |
}, |
| 343 | 343 |
[PIX_FMT_BGR4_BYTE] = {
|
| 344 | 344 |
.name = "bgr4_byte", |
| 345 |
- .nb_components= 3, |
|
| 346 |
- .log2_chroma_w= 0, |
|
| 347 |
- .log2_chroma_h= 0, |
|
| 345 |
+ .nb_components = 3, |
|
| 346 |
+ .log2_chroma_w = 0, |
|
| 347 |
+ .log2_chroma_h = 0, |
|
| 348 | 348 |
.comp = {
|
| 349 |
- {0,0,1,3,0}, /* B */
|
|
| 350 |
- {0,0,1,1,1}, /* G */
|
|
| 351 |
- {0,0,1,0,0}, /* R */
|
|
| 349 |
+ { 0, 0, 1, 3, 0 }, /* B */
|
|
| 350 |
+ { 0, 0, 1, 1, 1 }, /* G */
|
|
| 351 |
+ { 0, 0, 1, 0, 0 }, /* R */
|
|
| 352 | 352 |
}, |
| 353 | 353 |
.flags = PIX_FMT_PAL | PIX_FMT_RGB, |
| 354 | 354 |
}, |
| 355 | 355 |
[PIX_FMT_RGB8] = {
|
| 356 | 356 |
.name = "rgb8", |
| 357 |
- .nb_components= 3, |
|
| 358 |
- .log2_chroma_w= 0, |
|
| 359 |
- .log2_chroma_h= 0, |
|
| 357 |
+ .nb_components = 3, |
|
| 358 |
+ .log2_chroma_w = 0, |
|
| 359 |
+ .log2_chroma_h = 0, |
|
| 360 | 360 |
.comp = {
|
| 361 |
- {0,0,1,6,1}, /* R */
|
|
| 362 |
- {0,0,1,3,2}, /* G */
|
|
| 363 |
- {0,0,1,0,2}, /* B */
|
|
| 361 |
+ { 0, 0, 1, 6, 1 }, /* R */
|
|
| 362 |
+ { 0, 0, 1, 3, 2 }, /* G */
|
|
| 363 |
+ { 0, 0, 1, 0, 2 }, /* B */
|
|
| 364 | 364 |
}, |
| 365 | 365 |
.flags = PIX_FMT_PAL | PIX_FMT_RGB, |
| 366 | 366 |
}, |
| 367 | 367 |
[PIX_FMT_RGB4] = {
|
| 368 | 368 |
.name = "rgb4", |
| 369 |
- .nb_components= 3, |
|
| 370 |
- .log2_chroma_w= 0, |
|
| 371 |
- .log2_chroma_h= 0, |
|
| 369 |
+ .nb_components = 3, |
|
| 370 |
+ .log2_chroma_w = 0, |
|
| 371 |
+ .log2_chroma_h = 0, |
|
| 372 | 372 |
.comp = {
|
| 373 |
- {0,3,1,0,0}, /* R */
|
|
| 374 |
- {0,3,2,0,1}, /* G */
|
|
| 375 |
- {0,3,4,0,0}, /* B */
|
|
| 373 |
+ { 0, 3, 1, 0, 0 }, /* R */
|
|
| 374 |
+ { 0, 3, 2, 0, 1 }, /* G */
|
|
| 375 |
+ { 0, 3, 4, 0, 0 }, /* B */
|
|
| 376 | 376 |
}, |
| 377 | 377 |
.flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB, |
| 378 | 378 |
}, |
| 379 | 379 |
[PIX_FMT_RGB4_BYTE] = {
|
| 380 | 380 |
.name = "rgb4_byte", |
| 381 |
- .nb_components= 3, |
|
| 382 |
- .log2_chroma_w= 0, |
|
| 383 |
- .log2_chroma_h= 0, |
|
| 381 |
+ .nb_components = 3, |
|
| 382 |
+ .log2_chroma_w = 0, |
|
| 383 |
+ .log2_chroma_h = 0, |
|
| 384 | 384 |
.comp = {
|
| 385 |
- {0,0,1,3,0}, /* R */
|
|
| 386 |
- {0,0,1,1,1}, /* G */
|
|
| 387 |
- {0,0,1,0,0}, /* B */
|
|
| 385 |
+ { 0, 0, 1, 3, 0 }, /* R */
|
|
| 386 |
+ { 0, 0, 1, 1, 1 }, /* G */
|
|
| 387 |
+ { 0, 0, 1, 0, 0 }, /* B */
|
|
| 388 | 388 |
}, |
| 389 | 389 |
.flags = PIX_FMT_PAL | PIX_FMT_RGB, |
| 390 | 390 |
}, |
| 391 | 391 |
[PIX_FMT_NV12] = {
|
| 392 | 392 |
.name = "nv12", |
| 393 |
- .nb_components= 3, |
|
| 394 |
- .log2_chroma_w= 1, |
|
| 395 |
- .log2_chroma_h= 1, |
|
| 393 |
+ .nb_components = 3, |
|
| 394 |
+ .log2_chroma_w = 1, |
|
| 395 |
+ .log2_chroma_h = 1, |
|
| 396 | 396 |
.comp = {
|
| 397 |
- {0,0,1,0,7}, /* Y */
|
|
| 398 |
- {1,1,1,0,7}, /* U */
|
|
| 399 |
- {1,1,2,0,7}, /* V */
|
|
| 397 |
+ { 0,0,1,0,7 }, /* Y */
|
|
| 398 |
+ { 1,1,1,0,7 }, /* U */
|
|
| 399 |
+ { 1,1,2,0,7 }, /* V */
|
|
| 400 | 400 |
}, |
| 401 | 401 |
.flags = PIX_FMT_PLANAR, |
| 402 | 402 |
}, |
| 403 | 403 |
[PIX_FMT_NV21] = {
|
| 404 | 404 |
.name = "nv21", |
| 405 |
- .nb_components= 3, |
|
| 406 |
- .log2_chroma_w= 1, |
|
| 407 |
- .log2_chroma_h= 1, |
|
| 405 |
+ .nb_components = 3, |
|
| 406 |
+ .log2_chroma_w = 1, |
|
| 407 |
+ .log2_chroma_h = 1, |
|
| 408 | 408 |
.comp = {
|
| 409 |
- {0,0,1,0,7}, /* Y */
|
|
| 410 |
- {1,1,1,0,7}, /* V */
|
|
| 411 |
- {1,1,2,0,7}, /* U */
|
|
| 409 |
+ { 0, 0, 1, 0, 7 }, /* Y */
|
|
| 410 |
+ { 1, 1, 1, 0, 7 }, /* V */
|
|
| 411 |
+ { 1, 1, 2, 0, 7 }, /* U */
|
|
| 412 | 412 |
}, |
| 413 | 413 |
.flags = PIX_FMT_PLANAR, |
| 414 | 414 |
}, |
| 415 | 415 |
[PIX_FMT_ARGB] = {
|
| 416 | 416 |
.name = "argb", |
| 417 |
- .nb_components= 4, |
|
| 418 |
- .log2_chroma_w= 0, |
|
| 419 |
- .log2_chroma_h= 0, |
|
| 417 |
+ .nb_components = 4, |
|
| 418 |
+ .log2_chroma_w = 0, |
|
| 419 |
+ .log2_chroma_h = 0, |
|
| 420 | 420 |
.comp = {
|
| 421 |
- {0,3,1,0,7}, /* A */
|
|
| 422 |
- {0,3,2,0,7}, /* R */
|
|
| 423 |
- {0,3,3,0,7}, /* G */
|
|
| 424 |
- {0,3,4,0,7}, /* B */
|
|
| 421 |
+ { 0, 3, 1, 0, 7 }, /* A */
|
|
| 422 |
+ { 0, 3, 2, 0, 7 }, /* R */
|
|
| 423 |
+ { 0, 3, 3, 0, 7 }, /* G */
|
|
| 424 |
+ { 0, 3, 4, 0, 7 }, /* B */
|
|
| 425 | 425 |
}, |
| 426 | 426 |
.flags = PIX_FMT_RGB, |
| 427 | 427 |
}, |
| 428 | 428 |
[PIX_FMT_RGBA] = {
|
| 429 | 429 |
.name = "rgba", |
| 430 |
- .nb_components= 4, |
|
| 431 |
- .log2_chroma_w= 0, |
|
| 432 |
- .log2_chroma_h= 0, |
|
| 430 |
+ .nb_components = 4, |
|
| 431 |
+ .log2_chroma_w = 0, |
|
| 432 |
+ .log2_chroma_h = 0, |
|
| 433 | 433 |
.comp = {
|
| 434 |
- {0,3,1,0,7}, /* R */
|
|
| 435 |
- {0,3,2,0,7}, /* G */
|
|
| 436 |
- {0,3,3,0,7}, /* B */
|
|
| 437 |
- {0,3,4,0,7}, /* A */
|
|
| 434 |
+ { 0, 3, 1, 0, 7 }, /* R */
|
|
| 435 |
+ { 0, 3, 2, 0, 7 }, /* G */
|
|
| 436 |
+ { 0, 3, 3, 0, 7 }, /* B */
|
|
| 437 |
+ { 0, 3, 4, 0, 7 }, /* A */
|
|
| 438 | 438 |
}, |
| 439 | 439 |
.flags = PIX_FMT_RGB, |
| 440 | 440 |
}, |
| 441 | 441 |
[PIX_FMT_ABGR] = {
|
| 442 | 442 |
.name = "abgr", |
| 443 |
- .nb_components= 4, |
|
| 444 |
- .log2_chroma_w= 0, |
|
| 445 |
- .log2_chroma_h= 0, |
|
| 443 |
+ .nb_components = 4, |
|
| 444 |
+ .log2_chroma_w = 0, |
|
| 445 |
+ .log2_chroma_h = 0, |
|
| 446 | 446 |
.comp = {
|
| 447 |
- {0,3,1,0,7}, /* A */
|
|
| 448 |
- {0,3,2,0,7}, /* B */
|
|
| 449 |
- {0,3,3,0,7}, /* G */
|
|
| 450 |
- {0,3,4,0,7}, /* R */
|
|
| 447 |
+ { 0, 3, 1, 0, 7 }, /* A */
|
|
| 448 |
+ { 0, 3, 2, 0, 7 }, /* B */
|
|
| 449 |
+ { 0, 3, 3, 0, 7 }, /* G */
|
|
| 450 |
+ { 0, 3, 4, 0, 7 }, /* R */
|
|
| 451 | 451 |
}, |
| 452 | 452 |
.flags = PIX_FMT_RGB, |
| 453 | 453 |
}, |
| 454 | 454 |
[PIX_FMT_BGRA] = {
|
| 455 | 455 |
.name = "bgra", |
| 456 |
- .nb_components= 4, |
|
| 457 |
- .log2_chroma_w= 0, |
|
| 458 |
- .log2_chroma_h= 0, |
|
| 456 |
+ .nb_components = 4, |
|
| 457 |
+ .log2_chroma_w = 0, |
|
| 458 |
+ .log2_chroma_h = 0, |
|
| 459 | 459 |
.comp = {
|
| 460 |
- {0,3,1,0,7}, /* B */
|
|
| 461 |
- {0,3,2,0,7}, /* G */
|
|
| 462 |
- {0,3,3,0,7}, /* R */
|
|
| 463 |
- {0,3,4,0,7}, /* A */
|
|
| 460 |
+ { 0, 3, 1, 0, 7 }, /* B */
|
|
| 461 |
+ { 0, 3, 2, 0, 7 }, /* G */
|
|
| 462 |
+ { 0, 3, 3, 0, 7 }, /* R */
|
|
| 463 |
+ { 0, 3, 4, 0, 7 }, /* A */
|
|
| 464 | 464 |
}, |
| 465 | 465 |
.flags = PIX_FMT_RGB, |
| 466 | 466 |
}, |
| ... | ... |
@@ -516,57 +517,57 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
|
| 516 | 516 |
}, |
| 517 | 517 |
[PIX_FMT_GRAY16BE] = {
|
| 518 | 518 |
.name = "gray16be", |
| 519 |
- .nb_components= 1, |
|
| 520 |
- .log2_chroma_w= 0, |
|
| 521 |
- .log2_chroma_h= 0, |
|
| 519 |
+ .nb_components = 1, |
|
| 520 |
+ .log2_chroma_w = 0, |
|
| 521 |
+ .log2_chroma_h = 0, |
|
| 522 | 522 |
.comp = {
|
| 523 |
- {0,1,1,0,15}, /* Y */
|
|
| 523 |
+ { 0, 1, 1, 0, 15 }, /* Y */
|
|
| 524 | 524 |
}, |
| 525 | 525 |
.flags = PIX_FMT_BE, |
| 526 | 526 |
}, |
| 527 | 527 |
[PIX_FMT_GRAY16LE] = {
|
| 528 | 528 |
.name = "gray16le", |
| 529 |
- .nb_components= 1, |
|
| 530 |
- .log2_chroma_w= 0, |
|
| 531 |
- .log2_chroma_h= 0, |
|
| 529 |
+ .nb_components = 1, |
|
| 530 |
+ .log2_chroma_w = 0, |
|
| 531 |
+ .log2_chroma_h = 0, |
|
| 532 | 532 |
.comp = {
|
| 533 |
- {0,1,1,0,15}, /* Y */
|
|
| 533 |
+ { 0, 1, 1, 0, 15 }, /* Y */
|
|
| 534 | 534 |
}, |
| 535 | 535 |
}, |
| 536 | 536 |
[PIX_FMT_YUV440P] = {
|
| 537 | 537 |
.name = "yuv440p", |
| 538 |
- .nb_components= 3, |
|
| 539 |
- .log2_chroma_w= 0, |
|
| 540 |
- .log2_chroma_h= 1, |
|
| 538 |
+ .nb_components = 3, |
|
| 539 |
+ .log2_chroma_w = 0, |
|
| 540 |
+ .log2_chroma_h = 1, |
|
| 541 | 541 |
.comp = {
|
| 542 |
- {0,0,1,0,7}, /* Y */
|
|
| 543 |
- {1,0,1,0,7}, /* U */
|
|
| 544 |
- {2,0,1,0,7}, /* V */
|
|
| 542 |
+ { 0, 0, 1, 0, 7 }, /* Y */
|
|
| 543 |
+ { 1, 0, 1, 0, 7 }, /* U */
|
|
| 544 |
+ { 2, 0, 1, 0, 7 }, /* V */
|
|
| 545 | 545 |
}, |
| 546 | 546 |
.flags = PIX_FMT_PLANAR, |
| 547 | 547 |
}, |
| 548 | 548 |
[PIX_FMT_YUVJ440P] = {
|
| 549 | 549 |
.name = "yuvj440p", |
| 550 |
- .nb_components= 3, |
|
| 551 |
- .log2_chroma_w= 0, |
|
| 552 |
- .log2_chroma_h= 1, |
|
| 550 |
+ .nb_components = 3, |
|
| 551 |
+ .log2_chroma_w = 0, |
|
| 552 |
+ .log2_chroma_h = 1, |
|
| 553 | 553 |
.comp = {
|
| 554 |
- {0,0,1,0,7}, /* Y */
|
|
| 555 |
- {1,0,1,0,7}, /* U */
|
|
| 556 |
- {2,0,1,0,7}, /* V */
|
|
| 554 |
+ { 0, 0, 1, 0, 7 }, /* Y */
|
|
| 555 |
+ { 1, 0, 1, 0, 7 }, /* U */
|
|
| 556 |
+ { 2, 0, 1, 0, 7 }, /* V */
|
|
| 557 | 557 |
}, |
| 558 | 558 |
.flags = PIX_FMT_PLANAR, |
| 559 | 559 |
}, |
| 560 | 560 |
[PIX_FMT_YUVA420P] = {
|
| 561 | 561 |
.name = "yuva420p", |
| 562 |
- .nb_components= 4, |
|
| 563 |
- .log2_chroma_w= 1, |
|
| 564 |
- .log2_chroma_h= 1, |
|
| 562 |
+ .nb_components = 4, |
|
| 563 |
+ .log2_chroma_w = 1, |
|
| 564 |
+ .log2_chroma_h = 1, |
|
| 565 | 565 |
.comp = {
|
| 566 |
- {0,0,1,0,7}, /* Y */
|
|
| 567 |
- {1,0,1,0,7}, /* U */
|
|
| 568 |
- {2,0,1,0,7}, /* V */
|
|
| 569 |
- {3,0,1,0,7}, /* A */
|
|
| 566 |
+ { 0, 0, 1, 0, 7 }, /* Y */
|
|
| 567 |
+ { 1, 0, 1, 0, 7 }, /* U */
|
|
| 568 |
+ { 2, 0, 1, 0, 7 }, /* V */
|
|
| 569 |
+ { 3, 0, 1, 0, 7 }, /* A */
|
|
| 570 | 570 |
}, |
| 571 | 571 |
.flags = PIX_FMT_PLANAR, |
| 572 | 572 |
}, |
| ... | ... |
@@ -608,25 +609,25 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
|
| 608 | 608 |
}, |
| 609 | 609 |
[PIX_FMT_RGB48BE] = {
|
| 610 | 610 |
.name = "rgb48be", |
| 611 |
- .nb_components= 3, |
|
| 612 |
- .log2_chroma_w= 0, |
|
| 613 |
- .log2_chroma_h= 0, |
|
| 611 |
+ .nb_components = 3, |
|
| 612 |
+ .log2_chroma_w = 0, |
|
| 613 |
+ .log2_chroma_h = 0, |
|
| 614 | 614 |
.comp = {
|
| 615 |
- {0,5,1,0,15}, /* R */
|
|
| 616 |
- {0,5,3,0,15}, /* G */
|
|
| 617 |
- {0,5,5,0,15}, /* B */
|
|
| 615 |
+ { 0, 5, 1, 0, 15 }, /* R */
|
|
| 616 |
+ { 0, 5, 3, 0, 15 }, /* G */
|
|
| 617 |
+ { 0, 5, 5, 0, 15 }, /* B */
|
|
| 618 | 618 |
}, |
| 619 | 619 |
.flags = PIX_FMT_RGB | PIX_FMT_BE, |
| 620 | 620 |
}, |
| 621 | 621 |
[PIX_FMT_RGB48LE] = {
|
| 622 | 622 |
.name = "rgb48le", |
| 623 |
- .nb_components= 3, |
|
| 624 |
- .log2_chroma_w= 0, |
|
| 625 |
- .log2_chroma_h= 0, |
|
| 623 |
+ .nb_components = 3, |
|
| 624 |
+ .log2_chroma_w = 0, |
|
| 625 |
+ .log2_chroma_h = 0, |
|
| 626 | 626 |
.comp = {
|
| 627 |
- {0,5,1,0,15}, /* R */
|
|
| 628 |
- {0,5,3,0,15}, /* G */
|
|
| 629 |
- {0,5,5,0,15}, /* B */
|
|
| 627 |
+ { 0, 5, 1, 0, 15 }, /* R */
|
|
| 628 |
+ { 0, 5, 3, 0, 15 }, /* G */
|
|
| 629 |
+ { 0, 5, 5, 0, 15 }, /* B */
|
|
| 630 | 630 |
}, |
| 631 | 631 |
.flags = PIX_FMT_RGB, |
| 632 | 632 |
}, |
| ... | ... |
@@ -658,97 +659,97 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
|
| 658 | 658 |
}, |
| 659 | 659 |
[PIX_FMT_RGB565BE] = {
|
| 660 | 660 |
.name = "rgb565be", |
| 661 |
- .nb_components= 3, |
|
| 662 |
- .log2_chroma_w= 0, |
|
| 663 |
- .log2_chroma_h= 0, |
|
| 661 |
+ .nb_components = 3, |
|
| 662 |
+ .log2_chroma_w = 0, |
|
| 663 |
+ .log2_chroma_h = 0, |
|
| 664 | 664 |
.comp = {
|
| 665 |
- {0,1,0,3,4}, /* R */
|
|
| 666 |
- {0,1,1,5,5}, /* G */
|
|
| 667 |
- {0,1,1,0,4}, /* B */
|
|
| 665 |
+ { 0, 1, 0, 3, 4 }, /* R */
|
|
| 666 |
+ { 0, 1, 1, 5, 5 }, /* G */
|
|
| 667 |
+ { 0, 1, 1, 0, 4 }, /* B */
|
|
| 668 | 668 |
}, |
| 669 | 669 |
.flags = PIX_FMT_BE | PIX_FMT_RGB, |
| 670 | 670 |
}, |
| 671 | 671 |
[PIX_FMT_RGB565LE] = {
|
| 672 | 672 |
.name = "rgb565le", |
| 673 |
- .nb_components= 3, |
|
| 674 |
- .log2_chroma_w= 0, |
|
| 675 |
- .log2_chroma_h= 0, |
|
| 673 |
+ .nb_components = 3, |
|
| 674 |
+ .log2_chroma_w = 0, |
|
| 675 |
+ .log2_chroma_h = 0, |
|
| 676 | 676 |
.comp = {
|
| 677 |
- {0,1,2,3,4}, /* R */
|
|
| 678 |
- {0,1,1,5,5}, /* G */
|
|
| 679 |
- {0,1,1,0,4}, /* B */
|
|
| 677 |
+ { 0, 1, 2, 3, 4 }, /* R */
|
|
| 678 |
+ { 0, 1, 1, 5, 5 }, /* G */
|
|
| 679 |
+ { 0, 1, 1, 0, 4 }, /* B */
|
|
| 680 | 680 |
}, |
| 681 | 681 |
.flags = PIX_FMT_RGB, |
| 682 | 682 |
}, |
| 683 | 683 |
[PIX_FMT_RGB555BE] = {
|
| 684 | 684 |
.name = "rgb555be", |
| 685 |
- .nb_components= 3, |
|
| 686 |
- .log2_chroma_w= 0, |
|
| 687 |
- .log2_chroma_h= 0, |
|
| 685 |
+ .nb_components = 3, |
|
| 686 |
+ .log2_chroma_w = 0, |
|
| 687 |
+ .log2_chroma_h = 0, |
|
| 688 | 688 |
.comp = {
|
| 689 |
- {0,1,0,2,4}, /* R */
|
|
| 690 |
- {0,1,1,5,4}, /* G */
|
|
| 691 |
- {0,1,1,0,4}, /* B */
|
|
| 689 |
+ { 0, 1, 0, 2, 4 }, /* R */
|
|
| 690 |
+ { 0, 1, 1, 5, 4 }, /* G */
|
|
| 691 |
+ { 0, 1, 1, 0, 4 }, /* B */
|
|
| 692 | 692 |
}, |
| 693 | 693 |
.flags = PIX_FMT_BE | PIX_FMT_RGB, |
| 694 | 694 |
}, |
| 695 | 695 |
[PIX_FMT_RGB555LE] = {
|
| 696 | 696 |
.name = "rgb555le", |
| 697 |
- .nb_components= 3, |
|
| 698 |
- .log2_chroma_w= 0, |
|
| 699 |
- .log2_chroma_h= 0, |
|
| 697 |
+ .nb_components = 3, |
|
| 698 |
+ .log2_chroma_w = 0, |
|
| 699 |
+ .log2_chroma_h = 0, |
|
| 700 | 700 |
.comp = {
|
| 701 |
- {0,1,2,2,4}, /* R */
|
|
| 702 |
- {0,1,1,5,4}, /* G */
|
|
| 703 |
- {0,1,1,0,4}, /* B */
|
|
| 701 |
+ { 0, 1, 2, 2, 4 }, /* R */
|
|
| 702 |
+ { 0, 1, 1, 5, 4 }, /* G */
|
|
| 703 |
+ { 0, 1, 1, 0, 4 }, /* B */
|
|
| 704 | 704 |
}, |
| 705 | 705 |
.flags = PIX_FMT_RGB, |
| 706 | 706 |
}, |
| 707 | 707 |
[PIX_FMT_RGB444BE] = {
|
| 708 | 708 |
.name = "rgb444be", |
| 709 |
- .nb_components= 3, |
|
| 710 |
- .log2_chroma_w= 0, |
|
| 711 |
- .log2_chroma_h= 0, |
|
| 709 |
+ .nb_components = 3, |
|
| 710 |
+ .log2_chroma_w = 0, |
|
| 711 |
+ .log2_chroma_h = 0, |
|
| 712 | 712 |
.comp = {
|
| 713 |
- {0,1,0,0,3}, /* R */
|
|
| 714 |
- {0,1,1,4,3}, /* G */
|
|
| 715 |
- {0,1,1,0,3}, /* B */
|
|
| 713 |
+ { 0, 1, 0, 0, 3 }, /* R */
|
|
| 714 |
+ { 0, 1, 1, 4, 3 }, /* G */
|
|
| 715 |
+ { 0, 1, 1, 0, 3 }, /* B */
|
|
| 716 | 716 |
}, |
| 717 | 717 |
.flags = PIX_FMT_BE | PIX_FMT_RGB, |
| 718 | 718 |
}, |
| 719 | 719 |
[PIX_FMT_RGB444LE] = {
|
| 720 | 720 |
.name = "rgb444le", |
| 721 |
- .nb_components= 3, |
|
| 722 |
- .log2_chroma_w= 0, |
|
| 723 |
- .log2_chroma_h= 0, |
|
| 721 |
+ .nb_components = 3, |
|
| 722 |
+ .log2_chroma_w = 0, |
|
| 723 |
+ .log2_chroma_h = 0, |
|
| 724 | 724 |
.comp = {
|
| 725 |
- {0,1,2,0,3}, /* R */
|
|
| 726 |
- {0,1,1,4,3}, /* G */
|
|
| 727 |
- {0,1,1,0,3}, /* B */
|
|
| 725 |
+ { 0, 1, 2, 0, 3 }, /* R */
|
|
| 726 |
+ { 0, 1, 1, 4, 3 }, /* G */
|
|
| 727 |
+ { 0, 1, 1, 0, 3 }, /* B */
|
|
| 728 | 728 |
}, |
| 729 | 729 |
.flags = PIX_FMT_RGB, |
| 730 | 730 |
}, |
| 731 | 731 |
[PIX_FMT_BGR48BE] = {
|
| 732 | 732 |
.name = "bgr48be", |
| 733 |
- .nb_components= 3, |
|
| 734 |
- .log2_chroma_w= 0, |
|
| 735 |
- .log2_chroma_h= 0, |
|
| 733 |
+ .nb_components = 3, |
|
| 734 |
+ .log2_chroma_w = 0, |
|
| 735 |
+ .log2_chroma_h = 0, |
|
| 736 | 736 |
.comp = {
|
| 737 |
- {0,5,1,0,15}, /* B */
|
|
| 738 |
- {0,5,3,0,15}, /* G */
|
|
| 739 |
- {0,5,5,0,15}, /* R */
|
|
| 737 |
+ { 0, 5, 1, 0, 15 }, /* B */
|
|
| 738 |
+ { 0, 5, 3, 0, 15 }, /* G */
|
|
| 739 |
+ { 0, 5, 5, 0, 15 }, /* R */
|
|
| 740 | 740 |
}, |
| 741 | 741 |
.flags = PIX_FMT_BE | PIX_FMT_RGB, |
| 742 | 742 |
}, |
| 743 | 743 |
[PIX_FMT_BGR48LE] = {
|
| 744 | 744 |
.name = "bgr48le", |
| 745 |
- .nb_components= 3, |
|
| 746 |
- .log2_chroma_w= 0, |
|
| 747 |
- .log2_chroma_h= 0, |
|
| 745 |
+ .nb_components = 3, |
|
| 746 |
+ .log2_chroma_w = 0, |
|
| 747 |
+ .log2_chroma_h = 0, |
|
| 748 | 748 |
.comp = {
|
| 749 |
- {0,5,1,0,15}, /* B */
|
|
| 750 |
- {0,5,3,0,15}, /* G */
|
|
| 751 |
- {0,5,5,0,15}, /* R */
|
|
| 749 |
+ { 0, 5, 1, 0, 15 }, /* B */
|
|
| 750 |
+ { 0, 5, 3, 0, 15 }, /* G */
|
|
| 751 |
+ { 0, 5, 5, 0, 15 }, /* R */
|
|
| 752 | 752 |
}, |
| 753 | 753 |
.flags = PIX_FMT_RGB, |
| 754 | 754 |
}, |
| ... | ... |
@@ -779,73 +780,73 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
|
| 779 | 779 |
}, |
| 780 | 780 |
[PIX_FMT_BGR565BE] = {
|
| 781 | 781 |
.name = "bgr565be", |
| 782 |
- .nb_components= 3, |
|
| 783 |
- .log2_chroma_w= 0, |
|
| 784 |
- .log2_chroma_h= 0, |
|
| 782 |
+ .nb_components = 3, |
|
| 783 |
+ .log2_chroma_w = 0, |
|
| 784 |
+ .log2_chroma_h = 0, |
|
| 785 | 785 |
.comp = {
|
| 786 |
- {0,1,0,3,4}, /* B */
|
|
| 787 |
- {0,1,1,5,5}, /* G */
|
|
| 788 |
- {0,1,1,0,4}, /* R */
|
|
| 786 |
+ { 0, 1, 0, 3, 4 }, /* B */
|
|
| 787 |
+ { 0, 1, 1, 5, 5 }, /* G */
|
|
| 788 |
+ { 0, 1, 1, 0, 4 }, /* R */
|
|
| 789 | 789 |
}, |
| 790 | 790 |
.flags = PIX_FMT_BE | PIX_FMT_RGB, |
| 791 | 791 |
}, |
| 792 | 792 |
[PIX_FMT_BGR565LE] = {
|
| 793 | 793 |
.name = "bgr565le", |
| 794 |
- .nb_components= 3, |
|
| 795 |
- .log2_chroma_w= 0, |
|
| 796 |
- .log2_chroma_h= 0, |
|
| 794 |
+ .nb_components = 3, |
|
| 795 |
+ .log2_chroma_w = 0, |
|
| 796 |
+ .log2_chroma_h = 0, |
|
| 797 | 797 |
.comp = {
|
| 798 |
- {0,1,2,3,4}, /* B */
|
|
| 799 |
- {0,1,1,5,5}, /* G */
|
|
| 800 |
- {0,1,1,0,4}, /* R */
|
|
| 798 |
+ { 0, 1, 2, 3, 4 }, /* B */
|
|
| 799 |
+ { 0, 1, 1, 5, 5 }, /* G */
|
|
| 800 |
+ { 0, 1, 1, 0, 4 }, /* R */
|
|
| 801 | 801 |
}, |
| 802 | 802 |
.flags = PIX_FMT_RGB, |
| 803 | 803 |
}, |
| 804 | 804 |
[PIX_FMT_BGR555BE] = {
|
| 805 | 805 |
.name = "bgr555be", |
| 806 |
- .nb_components= 3, |
|
| 807 |
- .log2_chroma_w= 0, |
|
| 808 |
- .log2_chroma_h= 0, |
|
| 806 |
+ .nb_components = 3, |
|
| 807 |
+ .log2_chroma_w = 0, |
|
| 808 |
+ .log2_chroma_h = 0, |
|
| 809 | 809 |
.comp = {
|
| 810 |
- {0,1,0,2,4}, /* B */
|
|
| 811 |
- {0,1,1,5,4}, /* G */
|
|
| 812 |
- {0,1,1,0,4}, /* R */
|
|
| 810 |
+ { 0, 1, 0, 2, 4 }, /* B */
|
|
| 811 |
+ { 0, 1, 1, 5, 4 }, /* G */
|
|
| 812 |
+ { 0, 1, 1, 0, 4 }, /* R */
|
|
| 813 | 813 |
}, |
| 814 | 814 |
.flags = PIX_FMT_BE | PIX_FMT_RGB, |
| 815 | 815 |
}, |
| 816 | 816 |
[PIX_FMT_BGR555LE] = {
|
| 817 | 817 |
.name = "bgr555le", |
| 818 |
- .nb_components= 3, |
|
| 819 |
- .log2_chroma_w= 0, |
|
| 820 |
- .log2_chroma_h= 0, |
|
| 818 |
+ .nb_components = 3, |
|
| 819 |
+ .log2_chroma_w = 0, |
|
| 820 |
+ .log2_chroma_h = 0, |
|
| 821 | 821 |
.comp = {
|
| 822 |
- {0,1,2,2,4}, /* B */
|
|
| 823 |
- {0,1,1,5,4}, /* G */
|
|
| 824 |
- {0,1,1,0,4}, /* R */
|
|
| 822 |
+ { 0, 1, 2, 2, 4 }, /* B */
|
|
| 823 |
+ { 0, 1, 1, 5, 4 }, /* G */
|
|
| 824 |
+ { 0, 1, 1, 0, 4 }, /* R */
|
|
| 825 | 825 |
}, |
| 826 | 826 |
.flags = PIX_FMT_RGB, |
| 827 | 827 |
}, |
| 828 | 828 |
[PIX_FMT_BGR444BE] = {
|
| 829 | 829 |
.name = "bgr444be", |
| 830 |
- .nb_components= 3, |
|
| 831 |
- .log2_chroma_w= 0, |
|
| 832 |
- .log2_chroma_h= 0, |
|
| 830 |
+ .nb_components = 3, |
|
| 831 |
+ .log2_chroma_w = 0, |
|
| 832 |
+ .log2_chroma_h = 0, |
|
| 833 | 833 |
.comp = {
|
| 834 |
- {0,1,0,0,3}, /* B */
|
|
| 835 |
- {0,1,1,4,3}, /* G */
|
|
| 836 |
- {0,1,1,0,3}, /* R */
|
|
| 834 |
+ { 0, 1, 0, 0, 3 }, /* B */
|
|
| 835 |
+ { 0, 1, 1, 4, 3 }, /* G */
|
|
| 836 |
+ { 0, 1, 1, 0, 3 }, /* R */
|
|
| 837 | 837 |
}, |
| 838 | 838 |
.flags = PIX_FMT_BE | PIX_FMT_RGB, |
| 839 | 839 |
}, |
| 840 | 840 |
[PIX_FMT_BGR444LE] = {
|
| 841 | 841 |
.name = "bgr444le", |
| 842 |
- .nb_components= 3, |
|
| 843 |
- .log2_chroma_w= 0, |
|
| 844 |
- .log2_chroma_h= 0, |
|
| 842 |
+ .nb_components = 3, |
|
| 843 |
+ .log2_chroma_w = 0, |
|
| 844 |
+ .log2_chroma_h = 0, |
|
| 845 | 845 |
.comp = {
|
| 846 |
- {0,1,2,0,3}, /* B */
|
|
| 847 |
- {0,1,1,4,3}, /* G */
|
|
| 848 |
- {0,1,1,0,3}, /* R */
|
|
| 846 |
+ { 0, 1, 2, 0, 3 }, /* B */
|
|
| 847 |
+ { 0, 1, 1, 4, 3 }, /* G */
|
|
| 848 |
+ { 0, 1, 1, 0, 3 }, /* R */
|
|
| 849 | 849 |
}, |
| 850 | 850 |
.flags = PIX_FMT_RGB, |
| 851 | 851 |
}, |
| ... | ... |
@@ -875,93 +876,93 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
|
| 875 | 875 |
}, |
| 876 | 876 |
[PIX_FMT_YUV420P9LE] = {
|
| 877 | 877 |
.name = "yuv420p9le", |
| 878 |
- .nb_components= 3, |
|
| 879 |
- .log2_chroma_w= 1, |
|
| 880 |
- .log2_chroma_h= 1, |
|
| 878 |
+ .nb_components = 3, |
|
| 879 |
+ .log2_chroma_w = 1, |
|
| 880 |
+ .log2_chroma_h = 1, |
|
| 881 | 881 |
.comp = {
|
| 882 |
- {0,1,1,0,8}, /* Y */
|
|
| 883 |
- {1,1,1,0,8}, /* U */
|
|
| 884 |
- {2,1,1,0,8}, /* V */
|
|
| 882 |
+ { 0, 1, 1, 0, 8 }, /* Y */
|
|
| 883 |
+ { 1, 1, 1, 0, 8 }, /* U */
|
|
| 884 |
+ { 2, 1, 1, 0, 8 }, /* V */
|
|
| 885 | 885 |
}, |
| 886 | 886 |
.flags = PIX_FMT_PLANAR, |
| 887 | 887 |
}, |
| 888 | 888 |
[PIX_FMT_YUV420P9BE] = {
|
| 889 | 889 |
.name = "yuv420p9be", |
| 890 |
- .nb_components= 3, |
|
| 891 |
- .log2_chroma_w= 1, |
|
| 892 |
- .log2_chroma_h= 1, |
|
| 890 |
+ .nb_components = 3, |
|
| 891 |
+ .log2_chroma_w = 1, |
|
| 892 |
+ .log2_chroma_h = 1, |
|
| 893 | 893 |
.comp = {
|
| 894 |
- {0,1,1,0,8}, /* Y */
|
|
| 895 |
- {1,1,1,0,8}, /* U */
|
|
| 896 |
- {2,1,1,0,8}, /* V */
|
|
| 894 |
+ { 0, 1, 1, 0, 8 }, /* Y */
|
|
| 895 |
+ { 1, 1, 1, 0, 8 }, /* U */
|
|
| 896 |
+ { 2, 1, 1, 0, 8 }, /* V */
|
|
| 897 | 897 |
}, |
| 898 | 898 |
.flags = PIX_FMT_BE | PIX_FMT_PLANAR, |
| 899 | 899 |
}, |
| 900 | 900 |
[PIX_FMT_YUV420P10LE] = {
|
| 901 | 901 |
.name = "yuv420p10le", |
| 902 |
- .nb_components= 3, |
|
| 903 |
- .log2_chroma_w= 1, |
|
| 904 |
- .log2_chroma_h= 1, |
|
| 902 |
+ .nb_components = 3, |
|
| 903 |
+ .log2_chroma_w = 1, |
|
| 904 |
+ .log2_chroma_h = 1, |
|
| 905 | 905 |
.comp = {
|
| 906 |
- {0,1,1,0,9}, /* Y */
|
|
| 907 |
- {1,1,1,0,9}, /* U */
|
|
| 908 |
- {2,1,1,0,9}, /* V */
|
|
| 906 |
+ { 0, 1, 1, 0, 9 }, /* Y */
|
|
| 907 |
+ { 1, 1, 1, 0, 9 }, /* U */
|
|
| 908 |
+ { 2, 1, 1, 0, 9 }, /* V */
|
|
| 909 | 909 |
}, |
| 910 | 910 |
.flags = PIX_FMT_PLANAR, |
| 911 | 911 |
}, |
| 912 | 912 |
[PIX_FMT_YUV420P10BE] = {
|
| 913 | 913 |
.name = "yuv420p10be", |
| 914 |
- .nb_components= 3, |
|
| 915 |
- .log2_chroma_w= 1, |
|
| 916 |
- .log2_chroma_h= 1, |
|
| 914 |
+ .nb_components = 3, |
|
| 915 |
+ .log2_chroma_w = 1, |
|
| 916 |
+ .log2_chroma_h = 1, |
|
| 917 | 917 |
.comp = {
|
| 918 |
- {0,1,1,0,9}, /* Y */
|
|
| 919 |
- {1,1,1,0,9}, /* U */
|
|
| 920 |
- {2,1,1,0,9}, /* V */
|
|
| 918 |
+ { 0, 1, 1, 0, 9 }, /* Y */
|
|
| 919 |
+ { 1, 1, 1, 0, 9 }, /* U */
|
|
| 920 |
+ { 2, 1, 1, 0, 9 }, /* V */
|
|
| 921 | 921 |
}, |
| 922 | 922 |
.flags = PIX_FMT_BE | PIX_FMT_PLANAR, |
| 923 | 923 |
}, |
| 924 | 924 |
[PIX_FMT_YUV420P16LE] = {
|
| 925 | 925 |
.name = "yuv420p16le", |
| 926 |
- .nb_components= 3, |
|
| 927 |
- .log2_chroma_w= 1, |
|
| 928 |
- .log2_chroma_h= 1, |
|
| 926 |
+ .nb_components = 3, |
|
| 927 |
+ .log2_chroma_w = 1, |
|
| 928 |
+ .log2_chroma_h = 1, |
|
| 929 | 929 |
.comp = {
|
| 930 |
- {0,1,1,0,15}, /* Y */
|
|
| 931 |
- {1,1,1,0,15}, /* U */
|
|
| 932 |
- {2,1,1,0,15}, /* V */
|
|
| 930 |
+ { 0, 1, 1, 0, 15 }, /* Y */
|
|
| 931 |
+ { 1, 1, 1, 0, 15 }, /* U */
|
|
| 932 |
+ { 2, 1, 1, 0, 15 }, /* V */
|
|
| 933 | 933 |
}, |
| 934 | 934 |
.flags = PIX_FMT_PLANAR, |
| 935 | 935 |
}, |
| 936 | 936 |
[PIX_FMT_YUV420P16BE] = {
|
| 937 | 937 |
.name = "yuv420p16be", |
| 938 |
- .nb_components= 3, |
|
| 939 |
- .log2_chroma_w= 1, |
|
| 940 |
- .log2_chroma_h= 1, |
|
| 938 |
+ .nb_components = 3, |
|
| 939 |
+ .log2_chroma_w = 1, |
|
| 940 |
+ .log2_chroma_h = 1, |
|
| 941 | 941 |
.comp = {
|
| 942 |
- {0,1,1,0,15}, /* Y */
|
|
| 943 |
- {1,1,1,0,15}, /* U */
|
|
| 944 |
- {2,1,1,0,15}, /* V */
|
|
| 942 |
+ { 0, 1, 1, 0, 15 }, /* Y */
|
|
| 943 |
+ { 1, 1, 1, 0, 15 }, /* U */
|
|
| 944 |
+ { 2, 1, 1, 0, 15 }, /* V */
|
|
| 945 | 945 |
}, |
| 946 | 946 |
.flags = PIX_FMT_BE | PIX_FMT_PLANAR, |
| 947 | 947 |
}, |
| 948 | 948 |
[PIX_FMT_YUV422P9LE] = {
|
| 949 | 949 |
.name = "yuv422p9le", |
| 950 |
- .nb_components= 3, |
|
| 951 |
- .log2_chroma_w= 1, |
|
| 952 |
- .log2_chroma_h= 0, |
|
| 950 |
+ .nb_components = 3, |
|
| 951 |
+ .log2_chroma_w = 1, |
|
| 952 |
+ .log2_chroma_h = 0, |
|
| 953 | 953 |
.comp = {
|
| 954 |
- {0,1,1,0,8}, /* Y */
|
|
| 955 |
- {1,1,1,0,8}, /* U */
|
|
| 956 |
- {2,1,1,0,8}, /* V */
|
|
| 954 |
+ { 0, 1, 1, 0, 8 }, /* Y */
|
|
| 955 |
+ { 1, 1, 1, 0, 8 }, /* U */
|
|
| 956 |
+ { 2, 1, 1, 0, 8 }, /* V */
|
|
| 957 | 957 |
}, |
| 958 | 958 |
.flags = PIX_FMT_PLANAR, |
| 959 | 959 |
}, |
| 960 | 960 |
[PIX_FMT_YUV422P9BE] = {
|
| 961 | 961 |
.name = "yuv422p9be", |
| 962 |
- .nb_components= 3, |
|
| 963 |
- .log2_chroma_w= 1, |
|
| 964 |
- .log2_chroma_h= 0, |
|
| 962 |
+ .nb_components = 3, |
|
| 963 |
+ .log2_chroma_w = 1, |
|
| 964 |
+ .log2_chroma_h = 0, |
|
| 965 | 965 |
.comp = {
|
| 966 | 966 |
{0,1,1,0,8}, /* Y */
|
| 967 | 967 |
{1,1,1,0,8}, /* U */
|
| ... | ... |
@@ -971,121 +972,121 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
|
| 971 | 971 |
}, |
| 972 | 972 |
[PIX_FMT_YUV422P10LE] = {
|
| 973 | 973 |
.name = "yuv422p10le", |
| 974 |
- .nb_components= 3, |
|
| 975 |
- .log2_chroma_w= 1, |
|
| 976 |
- .log2_chroma_h= 0, |
|
| 974 |
+ .nb_components = 3, |
|
| 975 |
+ .log2_chroma_w = 1, |
|
| 976 |
+ .log2_chroma_h = 0, |
|
| 977 | 977 |
.comp = {
|
| 978 |
- {0,1,1,0,9}, /* Y */
|
|
| 979 |
- {1,1,1,0,9}, /* U */
|
|
| 980 |
- {2,1,1,0,9}, /* V */
|
|
| 978 |
+ { 0, 1, 1, 0, 9 }, /* Y */
|
|
| 979 |
+ { 1, 1, 1, 0, 9 }, /* U */
|
|
| 980 |
+ { 2, 1, 1, 0, 9 }, /* V */
|
|
| 981 | 981 |
}, |
| 982 | 982 |
.flags = PIX_FMT_PLANAR, |
| 983 | 983 |
}, |
| 984 | 984 |
[PIX_FMT_YUV422P10BE] = {
|
| 985 | 985 |
.name = "yuv422p10be", |
| 986 |
- .nb_components= 3, |
|
| 987 |
- .log2_chroma_w= 1, |
|
| 988 |
- .log2_chroma_h= 0, |
|
| 986 |
+ .nb_components = 3, |
|
| 987 |
+ .log2_chroma_w = 1, |
|
| 988 |
+ .log2_chroma_h = 0, |
|
| 989 | 989 |
.comp = {
|
| 990 |
- {0,1,1,0,9}, /* Y */
|
|
| 991 |
- {1,1,1,0,9}, /* U */
|
|
| 992 |
- {2,1,1,0,9}, /* V */
|
|
| 990 |
+ { 0, 1, 1, 0, 9 }, /* Y */
|
|
| 991 |
+ { 1, 1, 1, 0, 9 }, /* U */
|
|
| 992 |
+ { 2, 1, 1, 0, 9 }, /* V */
|
|
| 993 | 993 |
}, |
| 994 | 994 |
.flags = PIX_FMT_BE | PIX_FMT_PLANAR, |
| 995 | 995 |
}, |
| 996 | 996 |
[PIX_FMT_YUV422P16LE] = {
|
| 997 | 997 |
.name = "yuv422p16le", |
| 998 |
- .nb_components= 3, |
|
| 999 |
- .log2_chroma_w= 1, |
|
| 1000 |
- .log2_chroma_h= 0, |
|
| 998 |
+ .nb_components = 3, |
|
| 999 |
+ .log2_chroma_w = 1, |
|
| 1000 |
+ .log2_chroma_h = 0, |
|
| 1001 | 1001 |
.comp = {
|
| 1002 |
- {0,1,1,0,15}, /* Y */
|
|
| 1003 |
- {1,1,1,0,15}, /* U */
|
|
| 1004 |
- {2,1,1,0,15}, /* V */
|
|
| 1002 |
+ { 0, 1, 1, 0, 15 }, /* Y */
|
|
| 1003 |
+ { 1, 1, 1, 0, 15 }, /* U */
|
|
| 1004 |
+ { 2, 1, 1, 0, 15 }, /* V */
|
|
| 1005 | 1005 |
}, |
| 1006 | 1006 |
.flags = PIX_FMT_PLANAR, |
| 1007 | 1007 |
}, |
| 1008 | 1008 |
[PIX_FMT_YUV422P16BE] = {
|
| 1009 | 1009 |
.name = "yuv422p16be", |
| 1010 |
- .nb_components= 3, |
|
| 1011 |
- .log2_chroma_w= 1, |
|
| 1012 |
- .log2_chroma_h= 0, |
|
| 1010 |
+ .nb_components = 3, |
|
| 1011 |
+ .log2_chroma_w = 1, |
|
| 1012 |
+ .log2_chroma_h = 0, |
|
| 1013 | 1013 |
.comp = {
|
| 1014 |
- {0,1,1,0,15}, /* Y */
|
|
| 1015 |
- {1,1,1,0,15}, /* U */
|
|
| 1016 |
- {2,1,1,0,15}, /* V */
|
|
| 1014 |
+ { 0, 1, 1, 0, 15 }, /* Y */
|
|
| 1015 |
+ { 1, 1, 1, 0, 15 }, /* U */
|
|
| 1016 |
+ { 2, 1, 1, 0, 15 }, /* V */
|
|
| 1017 | 1017 |
}, |
| 1018 | 1018 |
.flags = PIX_FMT_BE | PIX_FMT_PLANAR, |
| 1019 | 1019 |
}, |
| 1020 | 1020 |
[PIX_FMT_YUV444P16LE] = {
|
| 1021 | 1021 |
.name = "yuv444p16le", |
| 1022 |
- .nb_components= 3, |
|
| 1023 |
- .log2_chroma_w= 0, |
|
| 1024 |
- .log2_chroma_h= 0, |
|
| 1022 |
+ .nb_components = 3, |
|
| 1023 |
+ .log2_chroma_w = 0, |
|
| 1024 |
+ .log2_chroma_h = 0, |
|
| 1025 | 1025 |
.comp = {
|
| 1026 |
- {0,1,1,0,15}, /* Y */
|
|
| 1027 |
- {1,1,1,0,15}, /* U */
|
|
| 1028 |
- {2,1,1,0,15}, /* V */
|
|
| 1026 |
+ { 0, 1, 1, 0, 15 }, /* Y */
|
|
| 1027 |
+ { 1, 1, 1, 0, 15 }, /* U */
|
|
| 1028 |
+ { 2, 1, 1, 0, 15 }, /* V */
|
|
| 1029 | 1029 |
}, |
| 1030 | 1030 |
.flags = PIX_FMT_PLANAR, |
| 1031 | 1031 |
}, |
| 1032 | 1032 |
[PIX_FMT_YUV444P16BE] = {
|
| 1033 | 1033 |
.name = "yuv444p16be", |
| 1034 |
- .nb_components= 3, |
|
| 1035 |
- .log2_chroma_w= 0, |
|
| 1036 |
- .log2_chroma_h= 0, |
|
| 1034 |
+ .nb_components = 3, |
|
| 1035 |
+ .log2_chroma_w = 0, |
|
| 1036 |
+ .log2_chroma_h = 0, |
|
| 1037 | 1037 |
.comp = {
|
| 1038 |
- {0,1,1,0,15}, /* Y */
|
|
| 1039 |
- {1,1,1,0,15}, /* U */
|
|
| 1040 |
- {2,1,1,0,15}, /* V */
|
|
| 1038 |
+ { 0, 1, 1, 0, 15 }, /* Y */
|
|
| 1039 |
+ { 1, 1, 1, 0, 15 }, /* U */
|
|
| 1040 |
+ { 2, 1, 1, 0, 15 }, /* V */
|
|
| 1041 | 1041 |
}, |
| 1042 | 1042 |
.flags = PIX_FMT_BE | PIX_FMT_PLANAR, |
| 1043 | 1043 |
}, |
| 1044 | 1044 |
[PIX_FMT_YUV444P10LE] = {
|
| 1045 | 1045 |
.name = "yuv444p10le", |
| 1046 |
- .nb_components= 3, |
|
| 1047 |
- .log2_chroma_w= 0, |
|
| 1048 |
- .log2_chroma_h= 0, |
|
| 1046 |
+ .nb_components = 3, |
|
| 1047 |
+ .log2_chroma_w = 0, |
|
| 1048 |
+ .log2_chroma_h = 0, |
|
| 1049 | 1049 |
.comp = {
|
| 1050 |
- {0,1,1,0,9}, /* Y */
|
|
| 1051 |
- {1,1,1,0,9}, /* U */
|
|
| 1052 |
- {2,1,1,0,9}, /* V */
|
|
| 1050 |
+ { 0, 1, 1, 0, 9 }, /* Y */
|
|
| 1051 |
+ { 1, 1, 1, 0, 9 }, /* U */
|
|
| 1052 |
+ { 2, 1, 1, 0, 9 }, /* V */
|
|
| 1053 | 1053 |
}, |
| 1054 | 1054 |
.flags = PIX_FMT_PLANAR, |
| 1055 | 1055 |
}, |
| 1056 | 1056 |
[PIX_FMT_YUV444P10BE] = {
|
| 1057 | 1057 |
.name = "yuv444p10be", |
| 1058 |
- .nb_components= 3, |
|
| 1059 |
- .log2_chroma_w= 0, |
|
| 1060 |
- .log2_chroma_h= 0, |
|
| 1058 |
+ .nb_components = 3, |
|
| 1059 |
+ .log2_chroma_w = 0, |
|
| 1060 |
+ .log2_chroma_h = 0, |
|
| 1061 | 1061 |
.comp = {
|
| 1062 |
- {0,1,1,0,9}, /* Y */
|
|
| 1063 |
- {1,1,1,0,9}, /* U */
|
|
| 1064 |
- {2,1,1,0,9}, /* V */
|
|
| 1062 |
+ { 0, 1, 1, 0, 9 }, /* Y */
|
|
| 1063 |
+ { 1, 1, 1, 0, 9 }, /* U */
|
|
| 1064 |
+ { 2, 1, 1, 0, 9 }, /* V */
|
|
| 1065 | 1065 |
}, |
| 1066 | 1066 |
.flags = PIX_FMT_BE | PIX_FMT_PLANAR, |
| 1067 | 1067 |
}, |
| 1068 | 1068 |
[PIX_FMT_YUV444P9LE] = {
|
| 1069 | 1069 |
.name = "yuv444p9le", |
| 1070 |
- .nb_components= 3, |
|
| 1071 |
- .log2_chroma_w= 0, |
|
| 1072 |
- .log2_chroma_h= 0, |
|
| 1070 |
+ .nb_components = 3, |
|
| 1071 |
+ .log2_chroma_w = 0, |
|
| 1072 |
+ .log2_chroma_h = 0, |
|
| 1073 | 1073 |
.comp = {
|
| 1074 |
- {0,1,1,0,8}, /* Y */
|
|
| 1075 |
- {1,1,1,0,8}, /* U */
|
|
| 1076 |
- {2,1,1,0,8}, /* V */
|
|
| 1074 |
+ { 0, 1, 1, 0, 8 }, /* Y */
|
|
| 1075 |
+ { 1, 1, 1, 0, 8 }, /* U */
|
|
| 1076 |
+ { 2, 1, 1, 0, 8 }, /* V */
|
|
| 1077 | 1077 |
}, |
| 1078 | 1078 |
.flags = PIX_FMT_PLANAR, |
| 1079 | 1079 |
}, |
| 1080 | 1080 |
[PIX_FMT_YUV444P9BE] = {
|
| 1081 | 1081 |
.name = "yuv444p9be", |
| 1082 |
- .nb_components= 3, |
|
| 1083 |
- .log2_chroma_w= 0, |
|
| 1084 |
- .log2_chroma_h= 0, |
|
| 1082 |
+ .nb_components = 3, |
|
| 1083 |
+ .log2_chroma_w = 0, |
|
| 1084 |
+ .log2_chroma_h = 0, |
|
| 1085 | 1085 |
.comp = {
|
| 1086 |
- {0,1,1,0,8}, /* Y */
|
|
| 1087 |
- {1,1,1,0,8}, /* U */
|
|
| 1088 |
- {2,1,1,0,8}, /* V */
|
|
| 1086 |
+ { 0, 1, 1, 0, 8 }, /* Y */
|
|
| 1087 |
+ { 1, 1, 1, 0, 8 }, /* U */
|
|
| 1088 |
+ { 2, 1, 1, 0, 8 }, /* V */
|
|
| 1089 | 1089 |
}, |
| 1090 | 1090 |
.flags = PIX_FMT_BE | PIX_FMT_PLANAR, |
| 1091 | 1091 |
}, |
| ... | ... |
@@ -1103,10 +1104,10 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
|
| 1103 | 1103 |
}, |
| 1104 | 1104 |
[PIX_FMT_GRAY8A] = {
|
| 1105 | 1105 |
.name = "gray8a", |
| 1106 |
- .nb_components= 2, |
|
| 1106 |
+ .nb_components = 2, |
|
| 1107 | 1107 |
.comp = {
|
| 1108 |
- {0,1,1,0,7}, /* Y */
|
|
| 1109 |
- {0,1,2,0,7}, /* A */
|
|
| 1108 |
+ { 0, 1, 1, 0, 7 }, /* Y */
|
|
| 1109 |
+ { 0, 1, 2, 0, 7 }, /* A */
|
|
| 1110 | 1110 |
}, |
| 1111 | 1111 |
}, |
| 1112 | 1112 |
[PIX_FMT_GBR24P] = {
|
| ... | ... |
@@ -1121,85 +1122,85 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
|
| 1121 | 1121 |
}, |
| 1122 | 1122 |
[PIX_FMT_GBRP] = {
|
| 1123 | 1123 |
.name = "gbrp", |
| 1124 |
- .nb_components= 3, |
|
| 1125 |
- .log2_chroma_w= 0, |
|
| 1126 |
- .log2_chroma_h= 0, |
|
| 1124 |
+ .nb_components = 3, |
|
| 1125 |
+ .log2_chroma_w = 0, |
|
| 1126 |
+ .log2_chroma_h = 0, |
|
| 1127 | 1127 |
.comp = {
|
| 1128 |
- {0,0,1,0,7}, /* G */
|
|
| 1129 |
- {1,0,1,0,7}, /* B */
|
|
| 1130 |
- {2,0,1,0,7}, /* R */
|
|
| 1128 |
+ { 0, 0, 1, 0, 7 }, /* G */
|
|
| 1129 |
+ { 1, 0, 1, 0, 7 }, /* B */
|
|
| 1130 |
+ { 2, 0, 1, 0, 7 }, /* R */
|
|
| 1131 | 1131 |
}, |
| 1132 | 1132 |
.flags = PIX_FMT_PLANAR | PIX_FMT_RGB, |
| 1133 | 1133 |
}, |
| 1134 | 1134 |
[PIX_FMT_GBRP9LE] = {
|
| 1135 | 1135 |
.name = "gbrp9le", |
| 1136 |
- .nb_components= 3, |
|
| 1137 |
- .log2_chroma_w= 0, |
|
| 1138 |
- .log2_chroma_h= 0, |
|
| 1136 |
+ .nb_components = 3, |
|
| 1137 |
+ .log2_chroma_w = 0, |
|
| 1138 |
+ .log2_chroma_h = 0, |
|
| 1139 | 1139 |
.comp = {
|
| 1140 |
- {0,1,1,0,8}, /* G */
|
|
| 1141 |
- {1,1,1,0,8}, /* B */
|
|
| 1142 |
- {2,1,1,0,8}, /* R */
|
|
| 1140 |
+ { 0, 1, 1, 0, 8 }, /* G */
|
|
| 1141 |
+ { 1, 1, 1, 0, 8 }, /* B */
|
|
| 1142 |
+ { 2, 1, 1, 0, 8 }, /* R */
|
|
| 1143 | 1143 |
}, |
| 1144 | 1144 |
.flags = PIX_FMT_PLANAR | PIX_FMT_RGB, |
| 1145 | 1145 |
}, |
| 1146 | 1146 |
[PIX_FMT_GBRP9BE] = {
|
| 1147 | 1147 |
.name = "gbrp9be", |
| 1148 |
- .nb_components= 3, |
|
| 1149 |
- .log2_chroma_w= 0, |
|
| 1150 |
- .log2_chroma_h= 0, |
|
| 1148 |
+ .nb_components = 3, |
|
| 1149 |
+ .log2_chroma_w = 0, |
|
| 1150 |
+ .log2_chroma_h = 0, |
|
| 1151 | 1151 |
.comp = {
|
| 1152 |
- {0,1,1,0,8}, /* G */
|
|
| 1153 |
- {1,1,1,0,8}, /* B */
|
|
| 1154 |
- {2,1,1,0,8}, /* R */
|
|
| 1152 |
+ { 0, 1, 1, 0, 8 }, /* G */
|
|
| 1153 |
+ { 1, 1, 1, 0, 8 }, /* B */
|
|
| 1154 |
+ { 2, 1, 1, 0, 8 }, /* R */
|
|
| 1155 | 1155 |
}, |
| 1156 | 1156 |
.flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB, |
| 1157 | 1157 |
}, |
| 1158 | 1158 |
[PIX_FMT_GBRP10LE] = {
|
| 1159 | 1159 |
.name = "gbrp10le", |
| 1160 |
- .nb_components= 3, |
|
| 1161 |
- .log2_chroma_w= 0, |
|
| 1162 |
- .log2_chroma_h= 0, |
|
| 1160 |
+ .nb_components = 3, |
|
| 1161 |
+ .log2_chroma_w = 0, |
|
| 1162 |
+ .log2_chroma_h = 0, |
|
| 1163 | 1163 |
.comp = {
|
| 1164 |
- {0,1,1,0,9}, /* G */
|
|
| 1165 |
- {1,1,1,0,9}, /* B */
|
|
| 1166 |
- {2,1,1,0,9}, /* R */
|
|
| 1164 |
+ { 0, 1, 1, 0, 9 }, /* G */
|
|
| 1165 |
+ { 1, 1, 1, 0, 9 }, /* B */
|
|
| 1166 |
+ { 2, 1, 1, 0, 9 }, /* R */
|
|
| 1167 | 1167 |
}, |
| 1168 | 1168 |
.flags = PIX_FMT_PLANAR | PIX_FMT_RGB, |
| 1169 | 1169 |
}, |
| 1170 | 1170 |
[PIX_FMT_GBRP10BE] = {
|
| 1171 | 1171 |
.name = "gbrp10be", |
| 1172 |
- .nb_components= 3, |
|
| 1173 |
- .log2_chroma_w= 0, |
|
| 1174 |
- .log2_chroma_h= 0, |
|
| 1172 |
+ .nb_components = 3, |
|
| 1173 |
+ .log2_chroma_w = 0, |
|
| 1174 |
+ .log2_chroma_h = 0, |
|
| 1175 | 1175 |
.comp = {
|
| 1176 |
- {0,1,1,0,9}, /* G */
|
|
| 1177 |
- {1,1,1,0,9}, /* B */
|
|
| 1178 |
- {2,1,1,0,9}, /* R */
|
|
| 1176 |
+ { 0, 1, 1, 0, 9 }, /* G */
|
|
| 1177 |
+ { 1, 1, 1, 0, 9 }, /* B */
|
|
| 1178 |
+ { 2, 1, 1, 0, 9 }, /* R */
|
|
| 1179 | 1179 |
}, |
| 1180 | 1180 |
.flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB, |
| 1181 | 1181 |
}, |
| 1182 | 1182 |
[PIX_FMT_GBRP16LE] = {
|
| 1183 | 1183 |
.name = "gbrp16le", |
| 1184 |
- .nb_components= 3, |
|
| 1185 |
- .log2_chroma_w= 0, |
|
| 1186 |
- .log2_chroma_h= 0, |
|
| 1184 |
+ .nb_components = 3, |
|
| 1185 |
+ .log2_chroma_w = 0, |
|
| 1186 |
+ .log2_chroma_h = 0, |
|
| 1187 | 1187 |
.comp = {
|
| 1188 |
- {0,1,1,0,15}, /* G */
|
|
| 1189 |
- {1,1,1,0,15}, /* B */
|
|
| 1190 |
- {2,1,1,0,15}, /* R */
|
|
| 1188 |
+ { 0, 1, 1, 0, 15 }, /* G */
|
|
| 1189 |
+ { 1, 1, 1, 0, 15 }, /* B */
|
|
| 1190 |
+ { 2, 1, 1, 0, 15 }, /* R */
|
|
| 1191 | 1191 |
}, |
| 1192 | 1192 |
.flags = PIX_FMT_PLANAR | PIX_FMT_RGB, |
| 1193 | 1193 |
}, |
| 1194 | 1194 |
[PIX_FMT_GBRP16BE] = {
|
| 1195 | 1195 |
.name = "gbrp16be", |
| 1196 |
- .nb_components= 3, |
|
| 1197 |
- .log2_chroma_w= 0, |
|
| 1198 |
- .log2_chroma_h= 0, |
|
| 1196 |
+ .nb_components = 3, |
|
| 1197 |
+ .log2_chroma_w = 0, |
|
| 1198 |
+ .log2_chroma_h = 0, |
|
| 1199 | 1199 |
.comp = {
|
| 1200 |
- {0,1,1,0,15}, /* G */
|
|
| 1201 |
- {1,1,1,0,15}, /* B */
|
|
| 1202 |
- {2,1,1,0,15}, /* R */
|
|
| 1200 |
+ { 0, 1, 1, 0, 15 }, /* G */
|
|
| 1201 |
+ { 1, 1, 1, 0, 15 }, /* B */
|
|
| 1202 |
+ { 2, 1, 1, 0, 15 }, /* R */
|
|
| 1203 | 1203 |
}, |
| 1204 | 1204 |
.flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB, |
| 1205 | 1205 |
}, |
| ... | ... |
@@ -1254,8 +1255,8 @@ int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc) |
| 1254 | 1254 |
int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h; |
| 1255 | 1255 |
|
| 1256 | 1256 |
for (c = 0; c < pixdesc->nb_components; c++) {
|
| 1257 |
- int s = c==1 || c==2 ? 0 : log2_pixels; |
|
| 1258 |
- bits += (pixdesc->comp[c].depth_minus1+1) << s; |
|
| 1257 |
+ int s = c == 1 || c == 2 ? 0 : log2_pixels; |
|
| 1258 |
+ bits += (pixdesc->comp[c].depth_minus1 + 1) << s; |
|
| 1259 | 1259 |
} |
| 1260 | 1260 |
|
| 1261 | 1261 |
return bits >> log2_pixels; |
| ... | ... |
@@ -1265,11 +1266,11 @@ char *av_get_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt) |
| 1265 | 1265 |
{
|
| 1266 | 1266 |
/* print header */ |
| 1267 | 1267 |
if (pix_fmt < 0) {
|
| 1268 |
- snprintf (buf, buf_size, "name " " nb_components" " nb_bits"); |
|
| 1268 |
+ snprintf (buf, buf_size, "name" " nb_components" " nb_bits"); |
|
| 1269 | 1269 |
} else {
|
| 1270 | 1270 |
const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt]; |
| 1271 |
- snprintf(buf, buf_size, "%-11s %7d %10d", |
|
| 1272 |
- pixdesc->name, pixdesc->nb_components, av_get_bits_per_pixel(pixdesc)); |
|
| 1271 |
+ snprintf(buf, buf_size, "%-11s %7d %10d", pixdesc->name, |
|
| 1272 |
+ pixdesc->nb_components, av_get_bits_per_pixel(pixdesc)); |
|
| 1273 | 1273 |
} |
| 1274 | 1274 |
|
| 1275 | 1275 |
return buf; |
| ... | ... |
@@ -40,24 +40,24 @@ static int read_random(uint32_t *dst, const char *file) |
| 40 | 40 |
|
| 41 | 41 |
static uint32_t get_generic_seed(void) |
| 42 | 42 |
{
|
| 43 |
- clock_t last_t=0; |
|
| 44 |
- int bits=0; |
|
| 45 |
- uint64_t random=0; |
|
| 43 |
+ clock_t last_t = 0; |
|
| 44 |
+ int bits = 0; |
|
| 45 |
+ uint64_t random = 0; |
|
| 46 | 46 |
unsigned i; |
| 47 |
- float s=0.000000000001; |
|
| 47 |
+ float s = 0.000000000001; |
|
| 48 | 48 |
|
| 49 |
- for(i=0;bits<64;i++){
|
|
| 50 |
- clock_t t= clock(); |
|
| 51 |
- if(last_t && fabs(t-last_t)>s || t==(clock_t)-1){
|
|
| 52 |
- if(i<10000 && s<(1<<24)){
|
|
| 53 |
- s+=s; |
|
| 54 |
- i=t=0; |
|
| 55 |
- }else{
|
|
| 56 |
- random= 2*random + (i&1); |
|
| 49 |
+ for (i = 0; bits < 64; i++) {
|
|
| 50 |
+ clock_t t = clock(); |
|
| 51 |
+ if (last_t && fabs(t - last_t) > s || t == (clock_t) -1) {
|
|
| 52 |
+ if (i < 10000 && s < (1 << 24)) {
|
|
| 53 |
+ s += s; |
|
| 54 |
+ i = t = 0; |
|
| 55 |
+ } else {
|
|
| 56 |
+ random = 2 * random + (i & 1); |
|
| 57 | 57 |
bits++; |
| 58 | 58 |
} |
| 59 | 59 |
} |
| 60 |
- last_t= t; |
|
| 60 |
+ last_t = t; |
|
| 61 | 61 |
} |
| 62 | 62 |
#ifdef AV_READ_TIME |
| 63 | 63 |
random ^= AV_READ_TIME(); |
| ... | ... |
@@ -65,7 +65,7 @@ static uint32_t get_generic_seed(void) |
| 65 | 65 |
random ^= clock(); |
| 66 | 66 |
#endif |
| 67 | 67 |
|
| 68 |
- random += random>>32; |
|
| 68 |
+ random += random >> 32; |
|
| 69 | 69 |
|
| 70 | 70 |
return random; |
| 71 | 71 |
} |
| ... | ... |
@@ -33,75 +33,86 @@ |
| 33 | 33 |
#include "mathematics.h" |
| 34 | 34 |
#include "rational.h" |
| 35 | 35 |
|
| 36 |
-int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max){
|
|
| 37 |
- AVRational a0={0,1}, a1={1,0};
|
|
| 38 |
- int sign= (num<0) ^ (den<0); |
|
| 39 |
- int64_t gcd= av_gcd(FFABS(num), FFABS(den)); |
|
| 40 |
- |
|
| 41 |
- if(gcd){
|
|
| 42 |
- num = FFABS(num)/gcd; |
|
| 43 |
- den = FFABS(den)/gcd; |
|
| 36 |
+int av_reduce(int *dst_num, int *dst_den, |
|
| 37 |
+ int64_t num, int64_t den, int64_t max) |
|
| 38 |
+{
|
|
| 39 |
+ AVRational a0 = { 0, 1 }, a1 = { 1, 0 };
|
|
| 40 |
+ int sign = (num < 0) ^ (den < 0); |
|
| 41 |
+ int64_t gcd = av_gcd(FFABS(num), FFABS(den)); |
|
| 42 |
+ |
|
| 43 |
+ if (gcd) {
|
|
| 44 |
+ num = FFABS(num) / gcd; |
|
| 45 |
+ den = FFABS(den) / gcd; |
|
| 44 | 46 |
} |
| 45 |
- if(num<=max && den<=max){
|
|
| 46 |
- a1= (AVRational){num, den};
|
|
| 47 |
- den=0; |
|
| 47 |
+ if (num <= max && den <= max) {
|
|
| 48 |
+ a1 = (AVRational) { num, den };
|
|
| 49 |
+ den = 0; |
|
| 48 | 50 |
} |
| 49 | 51 |
|
| 50 |
- while(den){
|
|
| 51 |
- uint64_t x = num / den; |
|
| 52 |
- int64_t next_den= num - den*x; |
|
| 53 |
- int64_t a2n= x*a1.num + a0.num; |
|
| 54 |
- int64_t a2d= x*a1.den + a0.den; |
|
| 52 |
+ while (den) {
|
|
| 53 |
+ uint64_t x = num / den; |
|
| 54 |
+ int64_t next_den = num - den * x; |
|
| 55 |
+ int64_t a2n = x * a1.num + a0.num; |
|
| 56 |
+ int64_t a2d = x * a1.den + a0.den; |
|
| 55 | 57 |
|
| 56 |
- if(a2n > max || a2d > max){
|
|
| 57 |
- if(a1.num) x= (max - a0.num) / a1.num; |
|
| 58 |
- if(a1.den) x= FFMIN(x, (max - a0.den) / a1.den); |
|
| 58 |
+ if (a2n > max || a2d > max) {
|
|
| 59 |
+ if (a1.num) x = (max - a0.num) / a1.num; |
|
| 60 |
+ if (a1.den) x = FFMIN(x, (max - a0.den) / a1.den); |
|
| 59 | 61 |
|
| 60 |
- if (den*(2*x*a1.den + a0.den) > num*a1.den) |
|
| 61 |
- a1 = (AVRational){x*a1.num + a0.num, x*a1.den + a0.den};
|
|
| 62 |
+ if (den * (2 * x * a1.den + a0.den) > num * a1.den) |
|
| 63 |
+ a1 = (AVRational) { x * a1.num + a0.num, x * a1.den + a0.den };
|
|
| 62 | 64 |
break; |
| 63 | 65 |
} |
| 64 | 66 |
|
| 65 |
- a0= a1; |
|
| 66 |
- a1= (AVRational){a2n, a2d};
|
|
| 67 |
- num= den; |
|
| 68 |
- den= next_den; |
|
| 67 |
+ a0 = a1; |
|
| 68 |
+ a1 = (AVRational) { a2n, a2d };
|
|
| 69 |
+ num = den; |
|
| 70 |
+ den = next_den; |
|
| 69 | 71 |
} |
| 70 | 72 |
av_assert2(av_gcd(a1.num, a1.den) <= 1U); |
| 71 | 73 |
|
| 72 | 74 |
*dst_num = sign ? -a1.num : a1.num; |
| 73 | 75 |
*dst_den = a1.den; |
| 74 | 76 |
|
| 75 |
- return den==0; |
|
| 77 |
+ return den == 0; |
|
| 76 | 78 |
} |
| 77 | 79 |
|
| 78 |
-AVRational av_mul_q(AVRational b, AVRational c){
|
|
| 79 |
- av_reduce(&b.num, &b.den, b.num * (int64_t)c.num, b.den * (int64_t)c.den, INT_MAX); |
|
| 80 |
+AVRational av_mul_q(AVRational b, AVRational c) |
|
| 81 |
+{
|
|
| 82 |
+ av_reduce(&b.num, &b.den, |
|
| 83 |
+ b.num * (int64_t) c.num, |
|
| 84 |
+ b.den * (int64_t) c.den, INT_MAX); |
|
| 80 | 85 |
return b; |
| 81 | 86 |
} |
| 82 | 87 |
|
| 83 |
-AVRational av_div_q(AVRational b, AVRational c){
|
|
| 84 |
- return av_mul_q(b, (AVRational){c.den, c.num});
|
|
| 88 |
+AVRational av_div_q(AVRational b, AVRational c) |
|
| 89 |
+{
|
|
| 90 |
+ return av_mul_q(b, (AVRational) { c.den, c.num });
|
|
| 85 | 91 |
} |
| 86 | 92 |
|
| 87 |
-AVRational av_add_q(AVRational b, AVRational c){
|
|
| 88 |
- av_reduce(&b.num, &b.den, b.num * (int64_t)c.den + c.num * (int64_t)b.den, b.den * (int64_t)c.den, INT_MAX); |
|
| 93 |
+AVRational av_add_q(AVRational b, AVRational c) {
|
|
| 94 |
+ av_reduce(&b.num, &b.den, |
|
| 95 |
+ b.num * (int64_t) c.den + |
|
| 96 |
+ c.num * (int64_t) b.den, |
|
| 97 |
+ b.den * (int64_t) c.den, INT_MAX); |
|
| 89 | 98 |
return b; |
| 90 | 99 |
} |
| 91 | 100 |
|
| 92 |
-AVRational av_sub_q(AVRational b, AVRational c){
|
|
| 93 |
- return av_add_q(b, (AVRational){-c.num, c.den});
|
|
| 101 |
+AVRational av_sub_q(AVRational b, AVRational c) |
|
| 102 |
+{
|
|
| 103 |
+ return av_add_q(b, (AVRational) { -c.num, c.den });
|
|
| 94 | 104 |
} |
| 95 | 105 |
|
| 96 |
-AVRational av_d2q(double d, int max){
|
|
| 106 |
+AVRational av_d2q(double d, int max) |
|
| 107 |
+{
|
|
| 97 | 108 |
AVRational a; |
| 98 | 109 |
#define LOG2 0.69314718055994530941723212145817656807550013436025 |
| 99 | 110 |
int exponent; |
| 100 | 111 |
int64_t den; |
| 101 | 112 |
if (isnan(d)) |
| 102 |
- return (AVRational){0,0};
|
|
| 113 |
+ return (AVRational) { 0,0 };
|
|
| 103 | 114 |
if (isinf(d)) |
| 104 |
- return (AVRational){ d<0 ? -1:1, 0 };
|
|
| 115 |
+ return (AVRational) { d < 0 ? -1 : 1, 0 };
|
|
| 105 | 116 |
exponent = FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0); |
| 106 | 117 |
den = 1LL << (61 - exponent); |
| 107 | 118 |
av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max); |
| ... | ... |
@@ -127,7 +138,7 @@ int av_nearer_q(AVRational q, AVRational q1, AVRational q2) |
| 127 | 127 |
int av_find_nearest_q_idx(AVRational q, const AVRational* q_list) |
| 128 | 128 |
{
|
| 129 | 129 |
int i, nearest_q_idx = 0; |
| 130 |
- for(i=0; q_list[i].den; i++) |
|
| 130 |
+ for (i = 0; q_list[i].den; i++) |
|
| 131 | 131 |
if (av_nearer_q(q, q_list[i], q_list[nearest_q_idx]) > 0) |
| 132 | 132 |
nearest_q_idx = i; |
| 133 | 133 |
|
| ... | ... |
@@ -138,16 +149,19 @@ int av_find_nearest_q_idx(AVRational q, const AVRational* q_list) |
| 138 | 138 |
int main(void) |
| 139 | 139 |
{
|
| 140 | 140 |
AVRational a,b; |
| 141 |
- for(a.num=-2; a.num<=2; a.num++){
|
|
| 142 |
- for(a.den=-2; a.den<=2; a.den++){
|
|
| 143 |
- for(b.num=-2; b.num<=2; b.num++){
|
|
| 144 |
- for(b.den=-2; b.den<=2; b.den++){
|
|
| 145 |
- int c= av_cmp_q(a,b); |
|
| 146 |
- double d= av_q2d(a) == av_q2d(b) ? 0 : (av_q2d(a) - av_q2d(b)); |
|
| 147 |
- if(d>0) d=1; |
|
| 148 |
- else if(d<0) d=-1; |
|
| 149 |
- else if(d != d) d= INT_MIN; |
|
| 150 |
- if(c!=d) av_log(0, AV_LOG_ERROR, "%d/%d %d/%d, %d %f\n", a.num, a.den, b.num, b.den, c,d); |
|
| 141 |
+ for (a.num = -2; a.num <= 2; a.num++) {
|
|
| 142 |
+ for (a.den = -2; a.den <= 2; a.den++) {
|
|
| 143 |
+ for (b.num = -2; b.num <= 2; b.num++) {
|
|
| 144 |
+ for (b.den = -2; b.den <= 2; b.den++) {
|
|
| 145 |
+ int c = av_cmp_q(a,b); |
|
| 146 |
+ double d = av_q2d(a) == av_q2d(b) ? |
|
| 147 |
+ 0 : (av_q2d(a) - av_q2d(b)); |
|
| 148 |
+ if (d > 0) d = 1; |
|
| 149 |
+ else if (d < 0) d = -1; |
|
| 150 |
+ else if (d != d) d = INT_MIN; |
|
| 151 |
+ if (c != d) |
|
| 152 |
+ av_log(0, AV_LOG_ERROR, "%d/%d %d/%d, %d %f\n", a.num, |
|
| 153 |
+ a.den, b.num, b.den, c,d); |
|
| 151 | 154 |
} |
| 152 | 155 |
} |
| 153 | 156 |
} |
| ... | ... |
@@ -21,22 +21,24 @@ |
| 21 | 21 |
#include "log.h" |
| 22 | 22 |
#include "tree.h" |
| 23 | 23 |
|
| 24 |
-typedef struct AVTreeNode{
|
|
| 24 |
+typedef struct AVTreeNode {
|
|
| 25 | 25 |
struct AVTreeNode *child[2]; |
| 26 | 26 |
void *elem; |
| 27 | 27 |
int state; |
| 28 |
-}AVTreeNode; |
|
| 28 |
+} AVTreeNode; |
|
| 29 | 29 |
|
| 30 | 30 |
const int av_tree_node_size = sizeof(AVTreeNode); |
| 31 | 31 |
|
| 32 |
-void *av_tree_find(const AVTreeNode *t, void *key, int (*cmp)(void *key, const void *b), void *next[2]){
|
|
| 33 |
- if(t){
|
|
| 34 |
- unsigned int v= cmp(key, t->elem); |
|
| 35 |
- if(v){
|
|
| 36 |
- if(next) next[v>>31]= t->elem; |
|
| 37 |
- return av_tree_find(t->child[(v>>31)^1], key, cmp, next); |
|
| 38 |
- }else{
|
|
| 39 |
- if(next){
|
|
| 32 |
+void *av_tree_find(const AVTreeNode *t, void *key, |
|
| 33 |
+ int (*cmp)(void *key, const void *b), void *next[2]) |
|
| 34 |
+{
|
|
| 35 |
+ if (t) {
|
|
| 36 |
+ unsigned int v = cmp(key, t->elem); |
|
| 37 |
+ if (v) {
|
|
| 38 |
+ if (next) next[v >> 31] = t->elem; |
|
| 39 |
+ return av_tree_find(t->child[(v >> 31) ^ 1], key, cmp, next); |
|
| 40 |
+ } else {
|
|
| 41 |
+ if (next) {
|
|
| 40 | 42 |
av_tree_find(t->child[0], key, cmp, next); |
| 41 | 43 |
av_tree_find(t->child[1], key, cmp, next); |
| 42 | 44 |
} |
| ... | ... |
@@ -46,41 +48,43 @@ void *av_tree_find(const AVTreeNode *t, void *key, int (*cmp)(void *key, const v |
| 46 | 46 |
return NULL; |
| 47 | 47 |
} |
| 48 | 48 |
|
| 49 |
-void *av_tree_insert(AVTreeNode **tp, void *key, int (*cmp)(void *key, const void *b), AVTreeNode **next){
|
|
| 50 |
- AVTreeNode *t= *tp; |
|
| 51 |
- if(t){
|
|
| 52 |
- unsigned int v= cmp(t->elem, key); |
|
| 49 |
+void *av_tree_insert(AVTreeNode **tp, void *key, |
|
| 50 |
+ int (*cmp)(void *key, const void *b), AVTreeNode **next) |
|
| 51 |
+{
|
|
| 52 |
+ AVTreeNode *t = *tp; |
|
| 53 |
+ if (t) {
|
|
| 54 |
+ unsigned int v = cmp(t->elem, key); |
|
| 53 | 55 |
void *ret; |
| 54 |
- if(!v){
|
|
| 55 |
- if(*next) |
|
| 56 |
+ if (!v) {
|
|
| 57 |
+ if (*next) |
|
| 56 | 58 |
return t->elem; |
| 57 |
- else if(t->child[0]||t->child[1]){
|
|
| 58 |
- int i= !t->child[0]; |
|
| 59 |
+ else if (t->child[0] || t->child[1]) {
|
|
| 60 |
+ int i = !t->child[0]; |
|
| 59 | 61 |
void *next_elem[2]; |
| 60 | 62 |
av_tree_find(t->child[i], key, cmp, next_elem); |
| 61 |
- key= t->elem= next_elem[i]; |
|
| 62 |
- v= -i; |
|
| 63 |
- }else{
|
|
| 64 |
- *next= t; |
|
| 65 |
- *tp=NULL; |
|
| 63 |
+ key = t->elem = next_elem[i]; |
|
| 64 |
+ v = -i; |
|
| 65 |
+ } else {
|
|
| 66 |
+ *next = t; |
|
| 67 |
+ *tp = NULL; |
|
| 66 | 68 |
return NULL; |
| 67 | 69 |
} |
| 68 | 70 |
} |
| 69 |
- ret= av_tree_insert(&t->child[v>>31], key, cmp, next); |
|
| 70 |
- if(!ret){
|
|
| 71 |
- int i= (v>>31) ^ !!*next; |
|
| 72 |
- AVTreeNode **child= &t->child[i]; |
|
| 73 |
- t->state += 2*i - 1; |
|
| 74 |
- |
|
| 75 |
- if(!(t->state&1)){
|
|
| 76 |
- if(t->state){
|
|
| 71 |
+ ret = av_tree_insert(&t->child[v >> 31], key, cmp, next); |
|
| 72 |
+ if (!ret) {
|
|
| 73 |
+ int i = (v >> 31) ^ !!*next; |
|
| 74 |
+ AVTreeNode **child = &t->child[i]; |
|
| 75 |
+ t->state += 2 * i - 1; |
|
| 76 |
+ |
|
| 77 |
+ if (!(t->state & 1)) {
|
|
| 78 |
+ if (t->state) {
|
|
| 77 | 79 |
/* The following code is equivalent to |
| 78 | 80 |
if((*child)->state*2 == -t->state) |
| 79 | 81 |
rotate(child, i^1); |
| 80 | 82 |
rotate(tp, i); |
| 81 | 83 |
|
| 82 | 84 |
with rotate(): |
| 83 |
- static void rotate(AVTreeNode **tp, int i){
|
|
| 85 |
+ static void rotate(AVTreeNode **tp, int i) {
|
|
| 84 | 86 |
AVTreeNode *t= *tp; |
| 85 | 87 |
|
| 86 | 88 |
*tp= t->child[i]; |
| ... | ... |
@@ -92,54 +96,62 @@ void *av_tree_insert(AVTreeNode **tp, void *key, int (*cmp)(void *key, const voi |
| 92 | 92 |
} |
| 93 | 93 |
but such a rotate function is both bigger and slower |
| 94 | 94 |
*/ |
| 95 |
- if((*child)->state*2 == -t->state){
|
|
| 96 |
- *tp= (*child)->child[i^1]; |
|
| 97 |
- (*child)->child[i^1]= (*tp)->child[i]; |
|
| 98 |
- (*tp)->child[i]= *child; |
|
| 99 |
- *child= (*tp)->child[i^1]; |
|
| 100 |
- (*tp)->child[i^1]= t; |
|
| 101 |
- |
|
| 102 |
- (*tp)->child[0]->state= -((*tp)->state>0); |
|
| 103 |
- (*tp)->child[1]->state= (*tp)->state<0 ; |
|
| 104 |
- (*tp)->state=0; |
|
| 105 |
- }else{
|
|
| 106 |
- *tp= *child; |
|
| 107 |
- *child= (*child)->child[i^1]; |
|
| 108 |
- (*tp)->child[i^1]= t; |
|
| 109 |
- if((*tp)->state) t->state = 0; |
|
| 110 |
- else t->state>>= 1; |
|
| 111 |
- (*tp)->state= -t->state; |
|
| 95 |
+ if (( *child )->state * 2 == -t->state) {
|
|
| 96 |
+ *tp = (*child)->child[i ^ 1]; |
|
| 97 |
+ (*child)->child[i ^ 1] = (*tp)->child[i]; |
|
| 98 |
+ (*tp)->child[i] = *child; |
|
| 99 |
+ *child = ( *tp )->child[i ^ 1]; |
|
| 100 |
+ (*tp)->child[i ^ 1] = t; |
|
| 101 |
+ |
|
| 102 |
+ (*tp)->child[0]->state = -((*tp)->state > 0); |
|
| 103 |
+ (*tp)->child[1]->state = (*tp)->state < 0; |
|
| 104 |
+ (*tp)->state = 0; |
|
| 105 |
+ } else {
|
|
| 106 |
+ *tp = *child; |
|
| 107 |
+ *child = (*child)->child[i ^ 1]; |
|
| 108 |
+ (*tp)->child[i ^ 1] = t; |
|
| 109 |
+ if ((*tp)->state) t->state = 0; |
|
| 110 |
+ else t->state >>= 1; |
|
| 111 |
+ (*tp)->state = -t->state; |
|
| 112 | 112 |
} |
| 113 | 113 |
} |
| 114 | 114 |
} |
| 115 |
- if(!(*tp)->state ^ !!*next) |
|
| 115 |
+ if (!(*tp)->state ^ !!*next) |
|
| 116 | 116 |
return key; |
| 117 | 117 |
} |
| 118 | 118 |
return ret; |
| 119 |
- }else{
|
|
| 120 |
- *tp= *next; *next= NULL; |
|
| 121 |
- if(*tp){
|
|
| 122 |
- (*tp)->elem= key; |
|
| 119 |
+ } else {
|
|
| 120 |
+ *tp = *next; |
|
| 121 |
+ *next = NULL; |
|
| 122 |
+ if (*tp) {
|
|
| 123 |
+ (*tp)->elem = key; |
|
| 123 | 124 |
return NULL; |
| 124 |
- }else |
|
| 125 |
+ } else |
|
| 125 | 126 |
return key; |
| 126 | 127 |
} |
| 127 | 128 |
} |
| 128 | 129 |
|
| 129 |
-void av_tree_destroy(AVTreeNode *t){
|
|
| 130 |
- if(t){
|
|
| 130 |
+void av_tree_destroy(AVTreeNode *t) |
|
| 131 |
+{
|
|
| 132 |
+ if (t) {
|
|
| 131 | 133 |
av_tree_destroy(t->child[0]); |
| 132 | 134 |
av_tree_destroy(t->child[1]); |
| 133 | 135 |
av_free(t); |
| 134 | 136 |
} |
| 135 | 137 |
} |
| 136 | 138 |
|
| 137 |
-void av_tree_enumerate(AVTreeNode *t, void *opaque, int (*cmp)(void *opaque, void *elem), int (*enu)(void *opaque, void *elem)){
|
|
| 138 |
- if(t){
|
|
| 139 |
- int v= cmp ? cmp(opaque, t->elem) : 0; |
|
| 140 |
- if(v>=0) av_tree_enumerate(t->child[0], opaque, cmp, enu); |
|
| 141 |
- if(v==0) enu(opaque, t->elem); |
|
| 142 |
- if(v<=0) av_tree_enumerate(t->child[1], opaque, cmp, enu); |
|
| 139 |
+void av_tree_enumerate(AVTreeNode *t, void *opaque, |
|
| 140 |
+ int (*cmp)(void *opaque, void *elem), |
|
| 141 |
+ int (*enu)(void *opaque, void *elem)) |
|
| 142 |
+{
|
|
| 143 |
+ if (t) {
|
|
| 144 |
+ int v = cmp ? cmp(opaque, t->elem) : 0; |
|
| 145 |
+ if (v >= 0) |
|
| 146 |
+ av_tree_enumerate(t->child[0], opaque, cmp, enu); |
|
| 147 |
+ if (v == 0) |
|
| 148 |
+ enu(opaque, t->elem); |
|
| 149 |
+ if (v <= 0) |
|
| 150 |
+ av_tree_enumerate(t->child[1], opaque, cmp, enu); |
|
| 143 | 151 |
} |
| 144 | 152 |
} |
| 145 | 153 |
|
| ... | ... |
@@ -147,64 +159,68 @@ void av_tree_enumerate(AVTreeNode *t, void *opaque, int (*cmp)(void *opaque, voi |
| 147 | 147 |
|
| 148 | 148 |
#include "lfg.h" |
| 149 | 149 |
|
| 150 |
-static int check(AVTreeNode *t){
|
|
| 151 |
- if(t){
|
|
| 152 |
- int left= check(t->child[0]); |
|
| 153 |
- int right= check(t->child[1]); |
|
| 150 |
+static int check(AVTreeNode *t) |
|
| 151 |
+{
|
|
| 152 |
+ if (t) {
|
|
| 153 |
+ int left = check(t->child[0]); |
|
| 154 |
+ int right = check(t->child[1]); |
|
| 154 | 155 |
|
| 155 |
- if(left>999 || right>999) |
|
| 156 |
+ if (left>999 || right>999) |
|
| 156 | 157 |
return 1000; |
| 157 |
- if(right - left != t->state) |
|
| 158 |
+ if (right - left != t->state) |
|
| 158 | 159 |
return 1000; |
| 159 |
- if(t->state>1 || t->state<-1) |
|
| 160 |
+ if (t->state>1 || t->state<-1) |
|
| 160 | 161 |
return 1000; |
| 161 |
- return FFMAX(left, right)+1; |
|
| 162 |
+ return FFMAX(left, right) + 1; |
|
| 162 | 163 |
} |
| 163 | 164 |
return 0; |
| 164 | 165 |
} |
| 165 | 166 |
|
| 166 |
-static void print(AVTreeNode *t, int depth){
|
|
| 167 |
+static void print(AVTreeNode *t, int depth) |
|
| 168 |
+{
|
|
| 167 | 169 |
int i; |
| 168 |
- for(i=0; i<depth*4; i++) av_log(NULL, AV_LOG_ERROR, " "); |
|
| 169 |
- if(t){
|
|
| 170 |
+ for (i = 0; i < depth * 4; i++) av_log(NULL, AV_LOG_ERROR, " "); |
|
| 171 |
+ if (t) {
|
|
| 170 | 172 |
av_log(NULL, AV_LOG_ERROR, "Node %p %2d %p\n", t, t->state, t->elem); |
| 171 |
- print(t->child[0], depth+1); |
|
| 172 |
- print(t->child[1], depth+1); |
|
| 173 |
- }else |
|
| 173 |
+ print(t->child[0], depth + 1); |
|
| 174 |
+ print(t->child[1], depth + 1); |
|
| 175 |
+ } else |
|
| 174 | 176 |
av_log(NULL, AV_LOG_ERROR, "NULL\n"); |
| 175 | 177 |
} |
| 176 | 178 |
|
| 177 |
-static int cmp(void *a, const void *b){
|
|
| 178 |
- return (uint8_t*)a-(const uint8_t*)b; |
|
| 179 |
+static int cmp(void *a, const void *b) |
|
| 180 |
+{
|
|
| 181 |
+ return (uint8_t *) a - (const uint8_t *) b; |
|
| 179 | 182 |
} |
| 180 | 183 |
|
| 181 |
-int main(void){
|
|
| 184 |
+int main (void) |
|
| 185 |
+{
|
|
| 182 | 186 |
int i; |
| 183 | 187 |
void *k; |
| 184 |
- AVTreeNode *root= NULL, *node=NULL; |
|
| 188 |
+ AVTreeNode *root = NULL, *node = NULL; |
|
| 185 | 189 |
AVLFG prng; |
| 186 | 190 |
|
| 187 | 191 |
av_lfg_init(&prng, 1); |
| 188 | 192 |
|
| 189 |
- for(i=0; i<10000; i++){
|
|
| 193 |
+ for (i = 0; i < 10000; i++) {
|
|
| 190 | 194 |
int j = av_lfg_get(&prng) % 86294; |
| 191 |
- if(check(root) > 999){
|
|
| 195 |
+ if (check(root) > 999) {
|
|
| 192 | 196 |
av_log(NULL, AV_LOG_ERROR, "FATAL error %d\n", i); |
| 193 | 197 |
print(root, 0); |
| 194 | 198 |
return -1; |
| 195 | 199 |
} |
| 196 | 200 |
av_log(NULL, AV_LOG_ERROR, "inserting %4d\n", j); |
| 197 |
- if(!node) |
|
| 198 |
- node= av_mallocz(av_tree_node_size); |
|
| 199 |
- av_tree_insert(&root, (void*)(j+1), cmp, &node); |
|
| 201 |
+ if (!node) |
|
| 202 |
+ node = av_mallocz(av_tree_node_size); |
|
| 203 |
+ av_tree_insert(&root, (void *) (j + 1), cmp, &node); |
|
| 200 | 204 |
|
| 201 | 205 |
j = av_lfg_get(&prng) % 86294; |
| 202 | 206 |
{
|
| 203 |
- AVTreeNode *node2=NULL; |
|
| 207 |
+ AVTreeNode *node2 = NULL; |
|
| 204 | 208 |
av_log(NULL, AV_LOG_ERROR, "removing %4d\n", j); |
| 205 |
- av_tree_insert(&root, (void*)(j+1), cmp, &node2); |
|
| 206 |
- k= av_tree_find(root, (void*)(j+1), cmp, NULL); |
|
| 207 |
- if(k) |
|
| 209 |
+ av_tree_insert(&root, (void *) (j + 1), cmp, &node2); |
|
| 210 |
+ k = av_tree_find(root, (void *) (j + 1), cmp, NULL); |
|
| 211 |
+ if (k) |
|
| 208 | 212 |
av_log(NULL, AV_LOG_ERROR, "removal failure %d\n", i); |
| 209 | 213 |
} |
| 210 | 214 |
} |
| ... | ... |
@@ -38,6 +38,10 @@ FATE_AAC += fate-aac-ap05_48 |
| 38 | 38 |
fate-aac-ap05_48: CMD = pcm -i $(SAMPLES)/aac/ap05_48.mp4 |
| 39 | 39 |
fate-aac-ap05_48: REF = $(SAMPLES)/aac/ap05_48.s16 |
| 40 | 40 |
|
| 41 |
+FATE_AAC += fate-aac-latm_stereo_to_51 |
|
| 42 |
+fate-aac-latm_stereo_to_51: CMD = pcm -i $(SAMPLES)/aac/latm_stereo_to_51.ts -ac 6 |
|
| 43 |
+fate-aac-latm_stereo_to_51: REF = $(SAMPLES)/aac/latm_stereo_to_51.s16 |
|
| 44 |
+ |
|
| 41 | 45 |
fate-aac-ct%: CMD = pcm -i $(SAMPLES)/aac/CT_DecoderCheck/$(@:fate-aac-ct-%=%) |
| 42 | 46 |
fate-aac-ct%: REF = $(SAMPLES)/aac/CT_DecoderCheck/aacPlusv2.wav |
| 43 | 47 |
|