Originally committed as revision 18915 to svn://svn.ffmpeg.org/ffmpeg/branches/0.5
Diego Biurrun authored on 2009/05/23 21:58:44... | ... |
@@ -16,7 +16,6 @@ Specifically, the GPL parts of FFmpeg are |
16 | 16 |
libavcodec/x86/h264_deblock_sse2.asm |
17 | 17 |
libavcodec/x86/h264_idct_sse2.asm |
18 | 18 |
libavcodec/x86/idct_mmx.c |
19 |
-- the AC-3 decoder in libavcodec/ac3dec.c |
|
20 | 19 |
- the X11 grabber in libavdevice/x11grab.c |
21 | 20 |
|
22 | 21 |
Some external libraries, e.g. libx264, are under GPL and can be used in |
... | ... |
@@ -990,7 +990,6 @@ oldscaler_deps="!swscale" |
990 | 990 |
|
991 | 991 |
# decoders / encoders |
992 | 992 |
aac_decoder_select="fft mdct" |
993 |
-ac3_decoder_deps="gpl" |
|
994 | 993 |
ac3_decoder_select="fft mdct" |
995 | 994 |
atrac3_decoder_select="fft mdct" |
996 | 995 |
cavs_decoder_select="golomb" |
... | ... |
@@ -999,7 +998,6 @@ cscd_decoder_suggest="zlib" |
999 | 999 |
dca_decoder_select="fft mdct" |
1000 | 1000 |
dnxhd_encoder_select="aandct" |
1001 | 1001 |
dxa_decoder_select="zlib" |
1002 |
-eac3_decoder_deps="gpl" |
|
1003 | 1002 |
eac3_decoder_select="fft mdct" |
1004 | 1003 |
eatgq_decoder_select="aandct" |
1005 | 1004 |
eatqi_decoder_select="aandct" |
... | ... |
@@ -7,24 +7,19 @@ |
7 | 7 |
* Copyright (c) 2007-2008 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> |
8 | 8 |
* Copyright (c) 2007 Justin Ruggles <justin.ruggles@gmail.com> |
9 | 9 |
* |
10 |
- * Portions of this code are derived from liba52 |
|
11 |
- * http://liba52.sourceforge.net |
|
12 |
- * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org> |
|
13 |
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> |
|
14 |
- * |
|
15 | 10 |
* This file is part of FFmpeg. |
16 | 11 |
* |
17 | 12 |
* FFmpeg is free software; you can redistribute it and/or |
18 |
- * modify it under the terms of the GNU General Public |
|
13 |
+ * modify it under the terms of the GNU Lesser General Public |
|
19 | 14 |
* License as published by the Free Software Foundation; either |
20 |
- * version 2 of the License, or (at your option) any later version. |
|
15 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
21 | 16 |
* |
22 | 17 |
* FFmpeg is distributed in the hope that it will be useful, |
23 | 18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | 19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
25 |
- * General Public License for more details. |
|
20 |
+ * Lesser General Public License for more details. |
|
26 | 21 |
* |
27 |
- * You should have received a copy of the GNU General Public |
|
22 |
+ * You should have received a copy of the GNU Lesser General Public |
|
28 | 23 |
* License along with FFmpeg; if not, write to the Free Software |
29 | 24 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
30 | 25 |
*/ |
... | ... |
@@ -438,12 +433,12 @@ static void calc_transform_coeffs_cpl(AC3DecodeContext *s) |
438 | 438 |
* Grouped mantissas for 3-level 5-level and 11-level quantization |
439 | 439 |
*/ |
440 | 440 |
typedef struct { |
441 |
- int b1_mant[3]; |
|
442 |
- int b2_mant[3]; |
|
443 |
- int b4_mant[2]; |
|
444 |
- int b1ptr; |
|
445 |
- int b2ptr; |
|
446 |
- int b4ptr; |
|
441 |
+ int b1_mant[2]; |
|
442 |
+ int b2_mant[2]; |
|
443 |
+ int b4_mant; |
|
444 |
+ int b1; |
|
445 |
+ int b2; |
|
446 |
+ int b4; |
|
447 | 447 |
} mant_groups; |
448 | 448 |
|
449 | 449 |
/** |
... | ... |
@@ -452,73 +447,72 @@ typedef struct { |
452 | 452 |
*/ |
453 | 453 |
static void ac3_decode_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, mant_groups *m) |
454 | 454 |
{ |
455 |
+ int start_freq = s->start_freq[ch_index]; |
|
456 |
+ int end_freq = s->end_freq[ch_index]; |
|
457 |
+ uint8_t *baps = s->bap[ch_index]; |
|
458 |
+ int8_t *exps = s->dexps[ch_index]; |
|
459 |
+ int *coeffs = s->fixed_coeffs[ch_index]; |
|
455 | 460 |
GetBitContext *gbc = &s->gbc; |
456 |
- int i, gcode, tbap, start, end; |
|
457 |
- uint8_t *exps; |
|
458 |
- uint8_t *bap; |
|
459 |
- int *coeffs; |
|
460 |
- |
|
461 |
- exps = s->dexps[ch_index]; |
|
462 |
- bap = s->bap[ch_index]; |
|
463 |
- coeffs = s->fixed_coeffs[ch_index]; |
|
464 |
- start = s->start_freq[ch_index]; |
|
465 |
- end = s->end_freq[ch_index]; |
|
461 |
+ int freq; |
|
466 | 462 |
|
467 |
- for (i = start; i < end; i++) { |
|
468 |
- tbap = bap[i]; |
|
469 |
- switch (tbap) { |
|
463 |
+ for(freq = start_freq; freq < end_freq; freq++){ |
|
464 |
+ int bap = baps[freq]; |
|
465 |
+ int mantissa; |
|
466 |
+ switch(bap){ |
|
470 | 467 |
case 0: |
471 |
- coeffs[i] = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000; |
|
468 |
+ mantissa = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000; |
|
472 | 469 |
break; |
473 |
- |
|
474 | 470 |
case 1: |
475 |
- if(m->b1ptr > 2) { |
|
476 |
- gcode = get_bits(gbc, 5); |
|
477 |
- m->b1_mant[0] = b1_mantissas[gcode][0]; |
|
478 |
- m->b1_mant[1] = b1_mantissas[gcode][1]; |
|
479 |
- m->b1_mant[2] = b1_mantissas[gcode][2]; |
|
480 |
- m->b1ptr = 0; |
|
471 |
+ if(m->b1){ |
|
472 |
+ m->b1--; |
|
473 |
+ mantissa = m->b1_mant[m->b1]; |
|
474 |
+ } |
|
475 |
+ else{ |
|
476 |
+ int bits = get_bits(gbc, 5); |
|
477 |
+ mantissa = b1_mantissas[bits][0]; |
|
478 |
+ m->b1_mant[1] = b1_mantissas[bits][1]; |
|
479 |
+ m->b1_mant[0] = b1_mantissas[bits][2]; |
|
480 |
+ m->b1 = 2; |
|
481 | 481 |
} |
482 |
- coeffs[i] = m->b1_mant[m->b1ptr++]; |
|
483 | 482 |
break; |
484 |
- |
|
485 | 483 |
case 2: |
486 |
- if(m->b2ptr > 2) { |
|
487 |
- gcode = get_bits(gbc, 7); |
|
488 |
- m->b2_mant[0] = b2_mantissas[gcode][0]; |
|
489 |
- m->b2_mant[1] = b2_mantissas[gcode][1]; |
|
490 |
- m->b2_mant[2] = b2_mantissas[gcode][2]; |
|
491 |
- m->b2ptr = 0; |
|
484 |
+ if(m->b2){ |
|
485 |
+ m->b2--; |
|
486 |
+ mantissa = m->b2_mant[m->b2]; |
|
487 |
+ } |
|
488 |
+ else{ |
|
489 |
+ int bits = get_bits(gbc, 7); |
|
490 |
+ mantissa = b2_mantissas[bits][0]; |
|
491 |
+ m->b2_mant[1] = b2_mantissas[bits][1]; |
|
492 |
+ m->b2_mant[0] = b2_mantissas[bits][2]; |
|
493 |
+ m->b2 = 2; |
|
492 | 494 |
} |
493 |
- coeffs[i] = m->b2_mant[m->b2ptr++]; |
|
494 | 495 |
break; |
495 |
- |
|
496 | 496 |
case 3: |
497 |
- coeffs[i] = b3_mantissas[get_bits(gbc, 3)]; |
|
497 |
+ mantissa = b3_mantissas[get_bits(gbc, 3)]; |
|
498 | 498 |
break; |
499 |
- |
|
500 | 499 |
case 4: |
501 |
- if(m->b4ptr > 1) { |
|
502 |
- gcode = get_bits(gbc, 7); |
|
503 |
- m->b4_mant[0] = b4_mantissas[gcode][0]; |
|
504 |
- m->b4_mant[1] = b4_mantissas[gcode][1]; |
|
505 |
- m->b4ptr = 0; |
|
500 |
+ if(m->b4){ |
|
501 |
+ m->b4 = 0; |
|
502 |
+ mantissa = m->b4_mant; |
|
503 |
+ } |
|
504 |
+ else{ |
|
505 |
+ int bits = get_bits(gbc, 7); |
|
506 |
+ mantissa = b4_mantissas[bits][0]; |
|
507 |
+ m->b4_mant = b4_mantissas[bits][1]; |
|
508 |
+ m->b4 = 1; |
|
506 | 509 |
} |
507 |
- coeffs[i] = m->b4_mant[m->b4ptr++]; |
|
508 | 510 |
break; |
509 |
- |
|
510 | 511 |
case 5: |
511 |
- coeffs[i] = b5_mantissas[get_bits(gbc, 4)]; |
|
512 |
+ mantissa = b5_mantissas[get_bits(gbc, 4)]; |
|
512 | 513 |
break; |
513 |
- |
|
514 |
- default: { |
|
515 |
- /* asymmetric dequantization */ |
|
516 |
- int qlevel = quantization_tab[tbap]; |
|
517 |
- coeffs[i] = get_sbits(gbc, qlevel) << (24 - qlevel); |
|
514 |
+ default: /* 6 to 15 */ |
|
515 |
+ mantissa = get_bits(gbc, quantization_tab[bap]); |
|
516 |
+ /* Shift mantissa and sign-extend it. */ |
|
517 |
+ mantissa = (mantissa << (32-quantization_tab[bap]))>>8; |
|
518 | 518 |
break; |
519 |
- } |
|
520 | 519 |
} |
521 |
- coeffs[i] >>= exps[i]; |
|
520 |
+ coeffs[freq] = mantissa >> exps[freq]; |
|
522 | 521 |
} |
523 | 522 |
} |
524 | 523 |
|
... | ... |
@@ -581,7 +575,7 @@ static void decode_transform_coeffs(AC3DecodeContext *s, int blk) |
581 | 581 |
int got_cplchan = 0; |
582 | 582 |
mant_groups m; |
583 | 583 |
|
584 |
- m.b1ptr = m.b2ptr = m.b4ptr = 3; |
|
584 |
+ m.b1 = m.b2 = m.b4 = 0; |
|
585 | 585 |
|
586 | 586 |
for (ch = 1; ch <= s->channels; ch++) { |
587 | 587 |
/* transform coefficients for full-bandwidth channel */ |