* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+/*
+ * There are several features of E-AC-3 that this decoder does not yet support.
+ *
+ * Spectral Extension
+ * There is a patch to get this working for the two samples we have that
+ * use it, but it needs some minor changes in order to be accepted.
+ *
+ * Enhanced Coupling
+ * No known samples exist. If any ever surface, this feature should not be
+ * too difficult to implement.
+ *
+ * Reduced Sample Rates
+ * No known samples exist. The spec also does not give clear information
+ * on how this is to be implemented.
+ *
+ * Dependent Streams
+ * Only the independent stream is currently decoded. Any dependent
+ * streams are skipped. We have only come across two examples of this, and
+ * they are both just test streams, one for HD-DVD and the other for
+ * Blu-ray.
+ *
+ * Transient Pre-noise Processing
+ * This is side information which a decoder should use to reduce artifacts
+ * caused by transients. There are samples which are known to have this
+ * information, but this decoder currently ignores it.
+ */
+
+
#include "avcodec.h"
+#include "internal.h"
+#include "aac_ac3_parser.h"
#include "ac3.h"
#include "ac3_parser.h"
#include "ac3dec.h"
#include "ac3dec_data.h"
+#include "eac3dec_data.h"
/** gain adaptive quantization mode */
typedef enum {
for (blk = 0; blk < 6; blk++) {
int mant = get_sbits(gbc, gbits);
- if (mant == -(1 << (gbits-1))) {
+ if (log_gain && mant == -(1 << (gbits-1))) {
/* large mantissa */
int b;
- mant = get_sbits(gbc, bits-2+log_gain) << (26-log_gain-bits);
+ int mbits = bits - (2 - log_gain);
+ mant = get_sbits(gbc, mbits);
+ mant <<= (23 - (mbits - 1));
/* remap mantissa value to correct for asymmetric quantization */
if (mant >= 0)
- b = 32768 >> (log_gain+8);
+ b = 1 << (23 - log_gain);
else
- b = ff_eac3_gaq_remap_2_4_b[hebap-8][log_gain-1];
- mant += (ff_eac3_gaq_remap_2_4_a[hebap-8][log_gain-1] * (mant>>8) + b) >> 7;
+ b = ff_eac3_gaq_remap_2_4_b[hebap-8][log_gain-1] << 8;
+ mant += ((ff_eac3_gaq_remap_2_4_a[hebap-8][log_gain-1] * (int64_t)mant) >> 15) + b;
} else {
/* small mantissa, no GAQ, or Gk=1 */
mant <<= 24 - bits;
if (!log_gain) {
/* remap mantissa value for no GAQ or Gk=1 */
- mant += (ff_eac3_gaq_remap_1[hebap-8] * (mant>>8)) >> 7;
+ mant += (ff_eac3_gaq_remap_1[hebap-8] * (int64_t)mant) >> 15;
}
}
s->pre_mantissa[ch][bin][blk] = mant;
dependent streams which are used to add or replace channels. */
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
av_log_missing_feature(s->avctx, "Dependent substream decoding", 1);
- return AC3_PARSE_ERROR_FRAME_TYPE;
+ return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
} else if (s->frame_type == EAC3_FRAME_TYPE_RESERVED) {
av_log(s->avctx, AV_LOG_ERROR, "Reserved frame type\n");
- return AC3_PARSE_ERROR_FRAME_TYPE;
+ return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
}
/* The substream id indicates which substream this frame belongs to. each
if (s->substreamid) {
/* only decode substream with id=0. skip any additional substreams. */
av_log_missing_feature(s->avctx, "Additional substreams", 1);
- return AC3_PARSE_ERROR_FRAME_TYPE;
+ return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
}
if (s->bit_alloc_params.sr_code == EAC3_SR_CODE_REDUCED) {