summaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-02-16 02:18:58 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-02-16 02:18:58 +0100
commit1db87da35141c34474644c677bad2cf3a408611d (patch)
treefe8223c22f7617eb782d2e31918164937d32fe33 /libavcodec
parenta2bc6c116ddc15af47e092af874a0647d114a9f6 (diff)
parent9cd4bc41760f8ad879e248920eacbe1e7757152c (diff)
downloadffmpeg-streaming-1db87da35141c34474644c677bad2cf3a408611d.zip
ffmpeg-streaming-1db87da35141c34474644c677bad2cf3a408611d.tar.gz
Merge commit '9cd4bc41760f8ad879e248920eacbe1e7757152c'
* commit '9cd4bc41760f8ad879e248920eacbe1e7757152c': ac3dec: set AV_FRAME_DATA_DOWNMIX_INFO side data. Conflicts: libavcodec/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/ac3dec.c38
-rw-r--r--libavcodec/eac3dec.c1
-rw-r--r--libavcodec/version.h2
3 files changed, 39 insertions, 2 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 87b7f18..ef9ab88 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -31,6 +31,7 @@
#include "libavutil/channel_layout.h"
#include "libavutil/crc.h"
+#include "libavutil/downmix_info.h"
#include "libavutil/opt.h"
#include "internal.h"
#include "aac_ac3_parser.h"
@@ -77,6 +78,15 @@ static const float gain_levels[9] = {
LEVEL_MINUS_9DB
};
+/** Adjustments in dB gain (LFE, +10 to -21 dB) */
+static const float gain_levels_lfe[32] = {
+ 3.162275, 2.818382, 2.511886, 2.238719, 1.995261, 1.778278, 1.584893,
+ 1.412536, 1.258924, 1.122018, 1.000000, 0.891251, 0.794328, 0.707946,
+ 0.630957, 0.562341, 0.501187, 0.446683, 0.398107, 0.354813, 0.316227,
+ 0.281838, 0.251188, 0.223872, 0.199526, 0.177828, 0.158489, 0.141253,
+ 0.125892, 0.112201, 0.100000, 0.089125
+};
+
/**
* Table for default stereo downmixing coefficients
* reference: Section 7.8.2 Downmixing Into Two Channels
@@ -1312,6 +1322,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
const uint8_t *channel_map;
const float *output[AC3_MAX_CHANNELS];
enum AVMatrixEncoding matrix_encoding;
+ AVDownmixInfo *downmix_info;
/* copy input buffer to decoder context to avoid reading past the end
of the buffer, which can be caused by a damaged input stream. */
@@ -1489,6 +1500,33 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
if ((ret = ff_side_data_update_matrix_encoding(frame, matrix_encoding)) < 0)
return ret;
+ /* AVDownmixInfo */
+ if ((downmix_info = av_downmix_info_update_side_data(frame))) {
+ switch (s->preferred_downmix) {
+ case AC3_DMIXMOD_LTRT:
+ downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_LTRT;
+ break;
+ case AC3_DMIXMOD_LORO:
+ downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_LORO;
+ break;
+ case AC3_DMIXMOD_DPLII:
+ downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_DPLII;
+ break;
+ default:
+ downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_UNKNOWN;
+ break;
+ }
+ downmix_info->center_mix_level = gain_levels[s-> center_mix_level];
+ downmix_info->center_mix_level_ltrt = gain_levels[s-> center_mix_level_ltrt];
+ downmix_info->surround_mix_level = gain_levels[s-> surround_mix_level];
+ downmix_info->surround_mix_level_ltrt = gain_levels[s->surround_mix_level_ltrt];
+ if (s->lfe_mix_level_exists)
+ downmix_info->lfe_mix_level = gain_levels_lfe[s->lfe_mix_level];
+ else
+ downmix_info->lfe_mix_level = 0.0; // -inf dB
+ } else
+ return AVERROR(ENOMEM);
+
*got_frame_ptr = 1;
return FFMIN(buf_size, s->frame_size);
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index e623f0d..8e931fd 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -360,7 +360,6 @@ int ff_eac3_parse_header(AC3DecodeContext *s)
/* lfe mix level */
if (s->lfe_on && (s->lfe_mix_level_exists = get_bits1(gbc))) {
- // TODO: use LFE mix level
s->lfe_mix_level = get_bits(gbc, 5);
}
diff --git a/libavcodec/version.h b/libavcodec/version.h
index f805a64..61a7968 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
#define LIBAVCODEC_VERSION_MAJOR 55
#define LIBAVCODEC_VERSION_MINOR 52
-#define LIBAVCODEC_VERSION_MICRO 101
+#define LIBAVCODEC_VERSION_MICRO 102
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
OpenPOWER on IntegriCloud