Merge GPL --> LGPL conversion of AC-3 decoder from trunk.

Originally committed as revision 18915 to svn://svn.ffmpeg.org/ffmpeg/branches/0.5
This commit is contained in:
Diego Biurrun 2009-05-23 12:58:44 +00:00
parent 0ae7dcae2c
commit a4d8ebfaa1
4 changed files with 60 additions and 67 deletions

View File

@ -8,6 +8,8 @@ version 0.5.1:
- documentation updates - documentation updates
- fix for GPL code in libswscale that was erroneously activated - fix for GPL code in libswscale that was erroneously activated
- AltiVec code in libswscale is now LGPL - AltiVec code in libswscale is now LGPL
- remaining GPL parts in AC-3 decoder converted to LGPL
version 0.5: version 0.5:

View File

@ -16,7 +16,6 @@ Specifically, the GPL parts of FFmpeg are
libavcodec/x86/h264_deblock_sse2.asm libavcodec/x86/h264_deblock_sse2.asm
libavcodec/x86/h264_idct_sse2.asm libavcodec/x86/h264_idct_sse2.asm
libavcodec/x86/idct_mmx.c libavcodec/x86/idct_mmx.c
- the AC-3 decoder in libavcodec/ac3dec.c
- the X11 grabber in libavdevice/x11grab.c - the X11 grabber in libavdevice/x11grab.c
Some external libraries, e.g. libx264, are under GPL and can be used in Some external libraries, e.g. libx264, are under GPL and can be used in

2
configure vendored
View File

@ -990,7 +990,6 @@ oldscaler_deps="!swscale"
# decoders / encoders # decoders / encoders
aac_decoder_select="fft mdct" aac_decoder_select="fft mdct"
ac3_decoder_deps="gpl"
ac3_decoder_select="fft mdct" ac3_decoder_select="fft mdct"
atrac3_decoder_select="fft mdct" atrac3_decoder_select="fft mdct"
cavs_decoder_select="golomb" cavs_decoder_select="golomb"
@ -999,7 +998,6 @@ cscd_decoder_suggest="zlib"
dca_decoder_select="fft mdct" dca_decoder_select="fft mdct"
dnxhd_encoder_select="aandct" dnxhd_encoder_select="aandct"
dxa_decoder_select="zlib" dxa_decoder_select="zlib"
eac3_decoder_deps="gpl"
eac3_decoder_select="fft mdct" eac3_decoder_select="fft mdct"
eatgq_decoder_select="aandct" eatgq_decoder_select="aandct"
eatqi_decoder_select="aandct" eatqi_decoder_select="aandct"

View File

@ -7,24 +7,19 @@
* Copyright (c) 2007-2008 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> * Copyright (c) 2007-2008 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com>
* Copyright (c) 2007 Justin Ruggles <justin.ruggles@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. * This file is part of FFmpeg.
* *
* FFmpeg is free software; you can redistribute it and/or * 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 * 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, * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 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 * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 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 * Grouped mantissas for 3-level 5-level and 11-level quantization
*/ */
typedef struct { typedef struct {
int b1_mant[3]; int b1_mant[2];
int b2_mant[3]; int b2_mant[2];
int b4_mant[2]; int b4_mant;
int b1ptr; int b1;
int b2ptr; int b2;
int b4ptr; int b4;
} mant_groups; } mant_groups;
/** /**
@ -452,73 +447,72 @@ typedef struct {
*/ */
static void ac3_decode_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, mant_groups *m) 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; GetBitContext *gbc = &s->gbc;
int i, gcode, tbap, start, end; int freq;
uint8_t *exps;
uint8_t *bap;
int *coeffs;
exps = s->dexps[ch_index]; for(freq = start_freq; freq < end_freq; freq++){
bap = s->bap[ch_index]; int bap = baps[freq];
coeffs = s->fixed_coeffs[ch_index]; int mantissa;
start = s->start_freq[ch_index]; switch(bap){
end = s->end_freq[ch_index];
for (i = start; i < end; i++) {
tbap = bap[i];
switch (tbap) {
case 0: case 0:
coeffs[i] = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000; mantissa = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000;
break; break;
case 1: case 1:
if(m->b1ptr > 2) { if(m->b1){
gcode = get_bits(gbc, 5); m->b1--;
m->b1_mant[0] = b1_mantissas[gcode][0]; mantissa = m->b1_mant[m->b1];
m->b1_mant[1] = b1_mantissas[gcode][1]; }
m->b1_mant[2] = b1_mantissas[gcode][2]; else{
m->b1ptr = 0; 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; break;
case 2: case 2:
if(m->b2ptr > 2) { if(m->b2){
gcode = get_bits(gbc, 7); m->b2--;
m->b2_mant[0] = b2_mantissas[gcode][0]; mantissa = m->b2_mant[m->b2];
m->b2_mant[1] = b2_mantissas[gcode][1]; }
m->b2_mant[2] = b2_mantissas[gcode][2]; else{
m->b2ptr = 0; 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; break;
case 3: case 3:
coeffs[i] = b3_mantissas[get_bits(gbc, 3)]; mantissa = b3_mantissas[get_bits(gbc, 3)];
break; break;
case 4: case 4:
if(m->b4ptr > 1) { if(m->b4){
gcode = get_bits(gbc, 7); m->b4 = 0;
m->b4_mant[0] = b4_mantissas[gcode][0]; mantissa = m->b4_mant;
m->b4_mant[1] = b4_mantissas[gcode][1]; }
m->b4ptr = 0; 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; break;
case 5: case 5:
coeffs[i] = b5_mantissas[get_bits(gbc, 4)]; mantissa = b5_mantissas[get_bits(gbc, 4)];
break; break;
default: /* 6 to 15 */
default: { mantissa = get_bits(gbc, quantization_tab[bap]);
/* asymmetric dequantization */ /* Shift mantissa and sign-extend it. */
int qlevel = quantization_tab[tbap]; mantissa = (mantissa << (32-quantization_tab[bap]))>>8;
coeffs[i] = get_sbits(gbc, qlevel) << (24 - qlevel);
break; 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; int got_cplchan = 0;
mant_groups m; mant_groups m;
m.b1ptr = m.b2ptr = m.b4ptr = 3; m.b1 = m.b2 = m.b4 = 0;
for (ch = 1; ch <= s->channels; ch++) { for (ch = 1; ch <= s->channels; ch++) {
/* transform coefficients for full-bandwidth channel */ /* transform coefficients for full-bandwidth channel */