[FFmpeg-soc] [soc]: r1735 - in eac3: ac3_parser.c ac3dec.c ac3dec.h eac3dec.c ffmpeg.patch
jbr
subversion at mplayerhq.hu
Tue Jan 1 00:18:56 CET 2008
Author: jbr
Date: Tue Jan 1 00:18:56 2008
New Revision: 1735
Log:
Remove the E-AC3 AVCodec, AVCodecParser, and codec_id. Use AC3 for both types.
Modified:
eac3/ac3_parser.c
eac3/ac3dec.c
eac3/ac3dec.h
eac3/eac3dec.c
eac3/ffmpeg.patch
Modified: eac3/ac3_parser.c
==============================================================================
--- eac3/ac3_parser.c (original)
+++ eac3/ac3_parser.c Tue Jan 1 00:18:56 2008
@@ -127,12 +127,6 @@ static int ac3_sync(AVCodecContext *avct
if(err)
return err;
- if(hdr.bitstream_id <= 10) {
- avctx->codec_id = CODEC_ID_AC3;
- } else {
- avctx->codec_id = CODEC_ID_EAC3;
- }
-
*sample_rate = hdr.sample_rate;
*bit_rate = hdr.bit_rate;
*channels = hdr.channels;
@@ -157,11 +151,3 @@ AVCodecParser ac3_parser = {
ff_aac_ac3_parse,
NULL,
};
-
-AVCodecParser eac3_parser = {
- { CODEC_ID_EAC3 },
- sizeof(AACAC3ParseContext),
- ac3_parse_init,
- ff_aac_ac3_parse,
- NULL,
-};
Modified: eac3/ac3dec.c
==============================================================================
--- eac3/ac3dec.c (original)
+++ eac3/ac3dec.c Tue Jan 1 00:18:56 2008
@@ -212,6 +212,7 @@ static int ac3_decode_init(AVCodecContex
ac3_common_init();
ff_ac3_tables_init();
+ ff_eac3_tables_init();
ff_mdct_init(&s->imdct_256, 8, 1);
ff_mdct_init(&s->imdct_512, 9, 1);
ff_ac3_window_init(s->window);
@@ -967,6 +968,14 @@ static int ac3_parse_audio_block(AC3Deco
return 0;
}
+static int parse_audio_block(AC3DecodeContext *s, int blk)
+{
+ if(s->bitstream_id <= 10)
+ return ac3_parse_audio_block(s, blk);
+ else
+ return ff_eac3_parse_audio_block(s, blk);
+}
+
/**
* Decode a single AC-3 frame.
*/
@@ -1003,11 +1012,6 @@ static int ac3_decode_frame(AVCodecConte
return -1;
}
- if(s->bitstream_id > 10) {
- av_log(avctx, AV_LOG_ERROR, "E-AC3 misdetected as AC3\n");
- return -1;
- }
-
avctx->sample_rate = s->sample_rate;
avctx->bit_rate = s->bit_rate;
@@ -1027,8 +1031,8 @@ static int ac3_decode_frame(AVCodecConte
avctx->channels = s->out_channels;
/* parse the audio blocks */
- for (blk = 0; blk < NB_BLOCKS; blk++) {
- if (ac3_parse_audio_block(s, blk)) {
+ for (blk = 0; blk < s->num_blocks; blk++) {
+ if (parse_audio_block(s, blk)) {
av_log(avctx, AV_LOG_ERROR, "error parsing the audio block\n");
*data_size = 0;
return s->frame_size;
@@ -1073,7 +1077,7 @@ static int ac3_decode_frame(AVCodecConte
for (ch = 0; ch < s->out_channels; ch++)
*(out_samples++) = s->int_output[ch][i];
}
- *data_size = NB_BLOCKS * 256 * avctx->channels * sizeof (int16_t);
+ *data_size = s->num_blocks * 256 * avctx->channels * sizeof (int16_t);
return s->frame_size;
}
Modified: eac3/ac3dec.h
==============================================================================
--- eac3/ac3dec.h (original)
+++ eac3/ac3dec.h Tue Jan 1 00:18:56 2008
@@ -249,6 +249,8 @@ int ff_ac3_parse_frame_header(AC3DecodeC
/* TEMPORARY SOLUTION */
int ff_eac3_parse_header(AC3DecodeContext *s);
+int ff_eac3_parse_audio_block(AC3DecodeContext *s, int blk);
+void ff_eac3_tables_init(void);
int ff_ac3_get_transform_coeffs_ch(AC3DecodeContext *s, int ch, mant_groups *m);
Modified: eac3/eac3dec.c
==============================================================================
--- eac3/eac3dec.c (original)
+++ eac3/eac3dec.c Tue Jan 1 00:18:56 2008
@@ -626,7 +626,7 @@ int ff_eac3_parse_header(AC3DecodeContex
return err;
}
-static int parse_audblk(AC3DecodeContext *s, const int blk){
+int ff_eac3_parse_audio_block(AC3DecodeContext *s, const int blk){
//int grp, sbnd, n, bin;
int seg, bnd, ch, i, chbwcod, grpsize;
int got_cplchan;
@@ -1146,91 +1146,7 @@ static int parse_audblk(AC3DecodeContext
return 0;
}
-static int eac3_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
- uint8_t *buf, int buf_size){
- int16_t *out_samples = (int16_t *)data;
- AC3DecodeContext *s = (AC3DecodeContext *)avctx->priv_data;
- int k, i, blk, ch;
-
- *data_size = 0;
- init_get_bits(&s->gbc, buf, buf_size*8);
-
- if(ff_ac3_parse_frame_header(s)) {
- return -1;
- }
-
- if(s->bitstream_id <= 10) {
- av_log(avctx, AV_LOG_ERROR, "AC3 misdetected as E-AC3\n");
- return -1;
- }
-
- avctx->sample_rate = s->sample_rate;
- avctx->bit_rate = s->bit_rate;
-
- /* channel config */
- s->out_channels = s->channels;
- if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
- avctx->request_channels < s->channels) {
- s->out_channels = avctx->request_channels;
- s->output_mode = avctx->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;
- }
- avctx->channels = s->out_channels;
-
- for (blk = 0; blk < s->num_blocks; blk++) {
- if (parse_audblk(s, blk)) {
- av_log(avctx, AV_LOG_ERROR, "Error in parse_audblk\n");
- return -1;
- }
-
- /* recover coefficients if rematrixing is in use */
- if (s->channel_mode == AC3_CHMODE_STEREO)
- ff_ac3_do_rematrixing(s);
-
- /* apply scaling to coefficients (dialnorm, dynrng) */
- for (ch = 1; ch <= s->fbw_channels + s->lfe_on; ch++) {
- float gain=2.0f;
- if (s->channel_mode == AC3_CHMODE_DUALMONO) {
- gain *= s->dynamic_range[ch-1];
- } else {
- gain *= s->dynamic_range[0];
- }
- for (i = 0; i < s->end_freq[ch]; i++) {
- s->transform_coeffs[ch][i] *= gain;
- }
- }
-
- ff_ac3_do_imdct(s);
-
- // TODO: Transient Pre-Noise Cross-Fading
-
- if(s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) &&
- s->fbw_channels == s->out_channels)) {
- ff_ac3_set_downmix_coeffs(s);
- ff_ac3_downmix(s);
- }
-
- // convert float to 16-bit integer
- for (ch = 0; ch < avctx->channels; ch++) {
- for (i = 0; i < AC3_BLOCK_SIZE; i++) {
- s->output[ch][i] = s->output[ch][i] * s->mul_bias +
- s->add_bias;
- }
- s->dsp.float_to_int16(s->int_output[ch], s->output[ch],
- AC3_BLOCK_SIZE);
- }
- for (k = 0; k < AC3_BLOCK_SIZE; k++) {
- for (i = 0; i < avctx->channels; i++) {
- *(out_samples++) = s->int_output[i][k];
- }
- }
- }
-
- *data_size = s->num_blocks * 256 * avctx->channels * sizeof(int16_t);
-
- return s->frame_size;
-}
-
-static void eac3_tables_init(void) {
+void ff_eac3_tables_init(void) {
int blk, i;
// initialize IDCT cosine table for use with AHT
@@ -1247,44 +1163,3 @@ static void eac3_tables_init(void) {
gaq_ungroup_tab[i][2] = i % 3;
}
}
-
-static int eac3_decode_init(AVCodecContext *avctx){
- AC3DecodeContext *ctx = avctx->priv_data;
-
- ctx->avctx = avctx;
- ac3_common_init();
- ff_ac3_tables_init();
- eac3_tables_init();
- av_init_random(0, &ctx->dith_state);
- ff_mdct_init(&ctx->imdct_256, 8, 1);
- ff_mdct_init(&ctx->imdct_512, 9, 1);
- dsputil_init(&ctx->dsp, avctx);
- if (ctx->dsp.float_to_int16 == ff_float_to_int16_c) {
- ctx->add_bias = 385.0f;
- ctx->mul_bias = 1.0f;
- } else {
- ctx->add_bias = 0.0f;
- ctx->mul_bias = 32767.0f;
- }
- ff_ac3_window_init(ctx->window);
- return 0;
-}
-
-static int eac3_decode_end(AVCodecContext *avctx){
- AC3DecodeContext *ctx = avctx->priv_data;
- ff_mdct_end(&ctx->imdct_512);
- ff_mdct_end(&ctx->imdct_256);
-
- return 0;
-}
-
-AVCodec eac3_decoder = {
- .name = "E-AC3",
- .type = CODEC_TYPE_AUDIO,
- .id = CODEC_ID_EAC3,
- .priv_data_size = sizeof (AC3DecodeContext),
- .init = eac3_decode_init,
- .close = eac3_decode_end,
- .decode = eac3_decode_frame,
-
-};
Modified: eac3/ffmpeg.patch
==============================================================================
--- eac3/ffmpeg.patch (original)
+++ eac3/ffmpeg.patch Tue Jan 1 00:18:56 2008
@@ -11,15 +11,6 @@ Index: libavcodec/aac_ac3_parser.c
&samples);
if (len == 0) {
/* no sync found : move by one byte (inefficient, but simple!) */
-@@ -61,7 +61,7 @@
- /* update codec info */
- avctx->sample_rate = sample_rate;
- /* set channels,except if the user explicitly requests 1 or 2 channels, XXX/FIXME this is a bit ugly */
-- if(avctx->codec_id == CODEC_ID_AC3){
-+ if(avctx->codec_id == CODEC_ID_AC3 || avctx->codec_id == CODEC_ID_EAC3){
- if(avctx->channels!=1 && avctx->channels!=2){
- avctx->channels = channels;
- }
Index: libavcodec/aac_ac3_parser.h
===================================================================
--- libavcodec/aac_ac3_parser.h (revision 11360)
@@ -37,15 +28,16 @@ Index: libavcodec/Makefile
===================================================================
--- libavcodec/Makefile (revision 11360)
+++ libavcodec/Makefile (working copy)
-@@ -67,6 +67,7 @@
- OBJS-$(CONFIG_DVVIDEO_DECODER) += dv.o
- OBJS-$(CONFIG_DVVIDEO_ENCODER) += dv.o
- OBJS-$(CONFIG_DXA_DECODER) += dxa.o
-+OBJS-$(CONFIG_EAC3_DECODER) += eac3dec.o ac3dec.o ac3tab.o ac3.o mdct.o fft.o
- OBJS-$(CONFIG_EIGHTBPS_DECODER) += 8bps.o
- OBJS-$(CONFIG_FFV1_DECODER) += ffv1.o rangecoder.o golomb.o
- OBJS-$(CONFIG_FFV1_ENCODER) += ffv1.o rangecoder.o
-@@ -318,6 +319,7 @@
+@@ -33,7 +33,7 @@
+ HEADERS = avcodec.h opt.h
+
+ OBJS-$(CONFIG_AASC_DECODER) += aasc.o
+-OBJS-$(CONFIG_AC3_DECODER) += ac3dec.o ac3tab.o ac3.o mdct.o fft.o
++OBJS-$(CONFIG_AC3_DECODER) += eac3dec.o ac3dec.o ac3tab.o ac3.o mdct.o fft.o ac3_parser.o
+ OBJS-$(CONFIG_AC3_ENCODER) += ac3enc.o ac3tab.o ac3.o
+ OBJS-$(CONFIG_ALAC_DECODER) += alac.o
+ OBJS-$(CONFIG_AMV_DECODER) += sp5xdec.o mjpegdec.o mjpeg.o
+@@ -318,6 +318,7 @@
OBJS-$(CONFIG_DCA_PARSER) += dca_parser.o
OBJS-$(CONFIG_DVBSUB_PARSER) += dvbsub_parser.o
OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsub_parser.o
@@ -66,38 +58,6 @@ Index: libavcodec/aac_parser.c
int *bit_rate, int *samples)
{
GetBitContext bits;
-Index: libavcodec/allcodecs.c
-===================================================================
---- libavcodec/allcodecs.c (revision 11360)
-+++ libavcodec/allcodecs.c (working copy)
-@@ -180,6 +180,7 @@
- REGISTER_DECODER (COOK, cook);
- REGISTER_DECODER (DCA, dca);
- REGISTER_DECODER (DSICINAUDIO, dsicinaudio);
-+ REGISTER_DECODER (EAC3, eac3);
- REGISTER_ENCDEC (FLAC, flac);
- REGISTER_DECODER (IMC, imc);
- REGISTER_DECODER (MACE3, mace3);
-@@ -287,6 +288,7 @@
- REGISTER_PARSER (DCA, dca);
- REGISTER_PARSER (DVBSUB, dvbsub);
- REGISTER_PARSER (DVDSUB, dvdsub);
-+ REGISTER_PARSER (EAC3, eac3);
- REGISTER_PARSER (H261, h261);
- REGISTER_PARSER (H263, h263);
- REGISTER_PARSER (H264, h264);
-Index: libavcodec/avcodec.h
-===================================================================
---- libavcodec/avcodec.h (revision 11360)
-+++ libavcodec/avcodec.h (working copy)
-@@ -276,6 +276,7 @@
- CODEC_ID_APE,
- CODEC_ID_NELLYMOSER,
- CODEC_ID_MUSEPACK8,
-+ CODEC_ID_EAC3,
-
- /* subtitle codecs */
- CODEC_ID_DVD_SUBTITLE= 0x17000,
Index: libavcodec/ac3enc.c
===================================================================
--- libavcodec/ac3enc.c (revision 11360)
More information about the FFmpeg-soc
mailing list