aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2009-05-23 12:58:44 +0000
committerDiego Biurrun <diego@biurrun.de>2009-05-23 12:58:44 +0000
commita4d8ebfaa1ff87a6c2460e4aceaeefb2182c67df (patch)
treec4ae01dadbf66a821bc4001b564af9e3d5cf4e84
parent0ae7dcae2ce885b42f3944584ca510252a3ce316 (diff)
downloadffmpeg-a4d8ebfaa1ff87a6c2460e4aceaeefb2182c67df.tar.gz
Merge GPL --> LGPL conversion of AC-3 decoder from trunk.
Originally committed as revision 18915 to svn://svn.ffmpeg.org/ffmpeg/branches/0.5
-rw-r--r--Changelog2
-rw-r--r--LICENSE1
-rwxr-xr-xconfigure2
-rw-r--r--libavcodec/ac3dec.c122
4 files changed, 60 insertions, 67 deletions
diff --git a/Changelog b/Changelog
index 53c3e66bb3..8dc20b45d1 100644
--- a/Changelog
+++ b/Changelog
@@ -8,6 +8,8 @@ version 0.5.1:
- documentation updates
- fix for GPL code in libswscale that was erroneously activated
- AltiVec code in libswscale is now LGPL
+- remaining GPL parts in AC-3 decoder converted to LGPL
+
version 0.5:
diff --git a/LICENSE b/LICENSE
index 7c0a3e71b6..929f65bebc 100644
--- a/LICENSE
+++ b/LICENSE
@@ -16,7 +16,6 @@ Specifically, the GPL parts of FFmpeg are
libavcodec/x86/h264_deblock_sse2.asm
libavcodec/x86/h264_idct_sse2.asm
libavcodec/x86/idct_mmx.c
-- the AC-3 decoder in libavcodec/ac3dec.c
- the X11 grabber in libavdevice/x11grab.c
Some external libraries, e.g. libx264, are under GPL and can be used in
diff --git a/configure b/configure
index 0dc58a8d39..6ffc2b019b 100755
--- a/configure
+++ b/configure
@@ -990,7 +990,6 @@ oldscaler_deps="!swscale"
# decoders / encoders
aac_decoder_select="fft mdct"
-ac3_decoder_deps="gpl"
ac3_decoder_select="fft mdct"
atrac3_decoder_select="fft mdct"
cavs_decoder_select="golomb"
@@ -999,7 +998,6 @@ cscd_decoder_suggest="zlib"
dca_decoder_select="fft mdct"
dnxhd_encoder_select="aandct"
dxa_decoder_select="zlib"
-eac3_decoder_deps="gpl"
eac3_decoder_select="fft mdct"
eatgq_decoder_select="aandct"
eatqi_decoder_select="aandct"
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 766b262e49..7a2042c059 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -7,24 +7,19 @@
* Copyright (c) 2007-2008 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com>
* Copyright (c) 2007 Justin Ruggles <justin.ruggles@gmail.com>
*
- * Portions of this code are derived from liba52
- * http://liba52.sourceforge.net
- * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- *
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
+ * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public
+ * You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -438,12 +433,12 @@ static void calc_transform_coeffs_cpl(AC3DecodeContext *s)
* Grouped mantissas for 3-level 5-level and 11-level quantization
*/
typedef struct {
- int b1_mant[3];
- int b2_mant[3];
- int b4_mant[2];
- int b1ptr;
- int b2ptr;
- int b4ptr;
+ int b1_mant[2];
+ int b2_mant[2];
+ int b4_mant;
+ int b1;
+ int b2;
+ int b4;
} mant_groups;
/**
@@ -452,73 +447,72 @@ typedef struct {
*/
static void ac3_decode_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, mant_groups *m)
{
+ int start_freq = s->start_freq[ch_index];
+ int end_freq = s->end_freq[ch_index];
+ uint8_t *baps = s->bap[ch_index];
+ int8_t *exps = s->dexps[ch_index];
+ int *coeffs = s->fixed_coeffs[ch_index];
GetBitContext *gbc = &s->gbc;
- int i, gcode, tbap, start, end;
- uint8_t *exps;
- uint8_t *bap;
- int *coeffs;
-
- exps = s->dexps[ch_index];
- bap = s->bap[ch_index];
- coeffs = s->fixed_coeffs[ch_index];
- start = s->start_freq[ch_index];
- end = s->end_freq[ch_index];
+ int freq;
- for (i = start; i < end; i++) {
- tbap = bap[i];
- switch (tbap) {
+ for(freq = start_freq; freq < end_freq; freq++){
+ int bap = baps[freq];
+ int mantissa;
+ switch(bap){
case 0:
- coeffs[i] = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000;
+ mantissa = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000;
break;
-
case 1:
- if(m->b1ptr > 2) {
- gcode = get_bits(gbc, 5);
- m->b1_mant[0] = b1_mantissas[gcode][0];
- m->b1_mant[1] = b1_mantissas[gcode][1];
- m->b1_mant[2] = b1_mantissas[gcode][2];
- m->b1ptr = 0;
+ if(m->b1){
+ m->b1--;
+ mantissa = m->b1_mant[m->b1];
+ }
+ else{
+ int bits = get_bits(gbc, 5);
+ mantissa = b1_mantissas[bits][0];
+ m->b1_mant[1] = b1_mantissas[bits][1];
+ m->b1_mant[0] = b1_mantissas[bits][2];
+ m->b1 = 2;
}
- coeffs[i] = m->b1_mant[m->b1ptr++];
break;
-
case 2:
- if(m->b2ptr > 2) {
- gcode = get_bits(gbc, 7);
- m->b2_mant[0] = b2_mantissas[gcode][0];
- m->b2_mant[1] = b2_mantissas[gcode][1];
- m->b2_mant[2] = b2_mantissas[gcode][2];
- m->b2ptr = 0;
+ if(m->b2){
+ m->b2--;
+ mantissa = m->b2_mant[m->b2];
+ }
+ else{
+ int bits = get_bits(gbc, 7);
+ mantissa = b2_mantissas[bits][0];
+ m->b2_mant[1] = b2_mantissas[bits][1];
+ m->b2_mant[0] = b2_mantissas[bits][2];
+ m->b2 = 2;
}
- coeffs[i] = m->b2_mant[m->b2ptr++];
break;
-
case 3:
- coeffs[i] = b3_mantissas[get_bits(gbc, 3)];
+ mantissa = b3_mantissas[get_bits(gbc, 3)];
break;
-
case 4:
- if(m->b4ptr > 1) {
- gcode = get_bits(gbc, 7);
- m->b4_mant[0] = b4_mantissas[gcode][0];
- m->b4_mant[1] = b4_mantissas[gcode][1];
- m->b4ptr = 0;
+ if(m->b4){
+ m->b4 = 0;
+ mantissa = m->b4_mant;
+ }
+ else{
+ int bits = get_bits(gbc, 7);
+ mantissa = b4_mantissas[bits][0];
+ m->b4_mant = b4_mantissas[bits][1];
+ m->b4 = 1;
}
- coeffs[i] = m->b4_mant[m->b4ptr++];
break;
-
case 5:
- coeffs[i] = b5_mantissas[get_bits(gbc, 4)];
+ mantissa = b5_mantissas[get_bits(gbc, 4)];
break;
-
- default: {
- /* asymmetric dequantization */
- int qlevel = quantization_tab[tbap];
- coeffs[i] = get_sbits(gbc, qlevel) << (24 - qlevel);
+ default: /* 6 to 15 */
+ mantissa = get_bits(gbc, quantization_tab[bap]);
+ /* Shift mantissa and sign-extend it. */
+ mantissa = (mantissa << (32-quantization_tab[bap]))>>8;
break;
- }
}
- coeffs[i] >>= exps[i];
+ coeffs[freq] = mantissa >> exps[freq];
}
}
@@ -581,7 +575,7 @@ static void decode_transform_coeffs(AC3DecodeContext *s, int blk)
int got_cplchan = 0;
mant_groups m;
- m.b1ptr = m.b2ptr = m.b4ptr = 3;
+ m.b1 = m.b2 = m.b4 = 0;
for (ch = 1; ch <= s->channels; ch++) {
/* transform coefficients for full-bandwidth channel */