---

Restore Diego's sanity, thansk to the magic of trailing zeroes.

 libavcodec/ac3dec.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index fcb52e1..c1b0e8c 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"
@@ -1308,6 +1309,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. */
@@ -1478,6 +1480,36 @@ static int ac3_decode_frame(AVCodecContext * avctx, void 
*data,
     if ((ret = ff_side_data_update_matrix_encoding(frame, matrix_encoding)) < 
0)
         return ret;
 
+    /*
+     * AVDownmixInfo
+     *
+     * Note: LFE mix level (dB) = 10 - LFE mix level code
+     */
+    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       = pow(10.0, (10 - 
s->lfe_mix_level) / 20.0);
+        else
+            downmix_info->lfe_mix_level       = 0.0; // -inf dB
+    }
+
     *got_frame_ptr = 1;
 
     return FFMIN(buf_size, s->frame_size);
-- 
1.8.3.4 (Apple Git-47)

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to