[FFmpeg-soc] [soc]: r1704 - in eac3: ac3.h ac3dec.c eac3.h eac3dec.c
jbr
subversion at mplayerhq.hu
Sun Dec 30 07:12:43 CET 2007
Author: jbr
Date: Sun Dec 30 07:12:43 2007
New Revision: 1704
Log:
change downmixing and channel handling in eac3 decoder to match ac3 decoder
Modified:
eac3/ac3.h
eac3/ac3dec.c
eac3/eac3.h
eac3/eac3dec.c
Modified: eac3/ac3.h
==============================================================================
--- eac3/ac3.h (original)
+++ eac3/ac3.h Sun Dec 30 07:12:43 2007
@@ -43,6 +43,8 @@
#define EXP_D25 2
#define EXP_D45 3
+#define AC3_OUTPUT_LFEON 8
+
/** Delta bit allocation strategy */
typedef enum {
DBA_REUSE = 0,
Modified: eac3/ac3dec.c
==============================================================================
--- eac3/ac3dec.c (original)
+++ eac3/ac3dec.c Sun Dec 30 07:12:43 2007
@@ -110,8 +110,6 @@ const uint8_t ff_ac3_default_coeffs[8][5
#undef AC3_MAX_CHANNELS
#define AC3_MAX_CHANNELS 7
-#define AC3_OUTPUT_LFEON 8
-
typedef struct {
int channel_mode; ///< channel mode (acmod)
int block_switch[AC3_MAX_CHANNELS]; ///< block switch flags
Modified: eac3/eac3.h
==============================================================================
--- eac3/eac3.h (original)
+++ eac3/eac3.h Sun Dec 30 07:12:43 2007
@@ -126,6 +126,8 @@ typedef struct EAC3Context{
int channels; ///< Total of all channels
int lfe_ch; ///< Index of LFE channel
float downmix_coeffs[AC3_MAX_CHANNELS][2]; ///< stereo downmix coefficients
+ int output_mode; ///< output channel configuration
+ int out_channels; ///< number of output channels
///@}
///@defgroup dynrng Dynamic Range
Modified: eac3/eac3dec.c
==============================================================================
--- eac3/eac3dec.c (original)
+++ eac3/eac3dec.c Sun Dec 30 07:12:43 2007
@@ -358,6 +358,12 @@ static int parse_bsi(EAC3Context *s){
s->channels++;
}
+ /* set default output to all source channels */
+ s->out_channels = s->channels;
+ s->output_mode = s->channel_mode;
+ if(s->lfe_on)
+ s->output_mode |= AC3_OUTPUT_LFEON;
+
s->bitstream_id = get_bits(gbc, 5);
if (s->bitstream_id < 11 || s->bitstream_id > 16) {
av_log(s->avctx, AV_LOG_ERROR, "bitstream id is not within 11 and 16\n");
@@ -1239,23 +1245,13 @@ static int eac3_decode_frame(AVCodecCont
avctx->bit_rate = c->bit_rate;
/* channel config */
- if (!avctx->request_channels && !avctx->channels) {
- avctx->channels = c->channels;
- } else {
- if (c->channels < avctx->request_channels) {
- av_log(avctx, AV_LOG_ERROR, "Cannot upmix EAC3 from %d to %d channels.\n",
- c->channels, avctx->request_channels);
- return -1;
- } else {
- if (avctx->request_channels > 2
- && avctx->request_channels != c->channels) {
- av_log(avctx, AV_LOG_ERROR, "Cannot downmix EAC3 from %d to %d channels.\n",
- c->channels, avctx->request_channels);
- return -1;
- }
- avctx->channels = avctx->request_channels;
- }
+ c->out_channels = c->channels;
+ if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
+ avctx->request_channels < c->channels) {
+ c->out_channels = avctx->request_channels;
+ c->output_mode = avctx->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;
}
+ avctx->channels = c->out_channels;
for (blk = 0; blk < c->num_blocks; blk++) {
if (parse_audblk(c, blk)) {
@@ -1286,8 +1282,9 @@ static int eac3_decode_frame(AVCodecCont
// TODO: Transient Pre-Noise Cross-Fading
- if (avctx->channels != c->channels) {
- ff_ac3_downmix(c->output, c->fbw_channels, avctx->channels, c->downmix_coeffs);
+ if(c->channels != c->out_channels && !((c->output_mode & AC3_OUTPUT_LFEON) &&
+ c->fbw_channels == c->out_channels)) {
+ ff_ac3_downmix(c->output, c->fbw_channels, c->output_mode, c->downmix_coeffs);
}
// convert float to 16-bit integer
More information about the FFmpeg-soc
mailing list