[FFmpeg-devel] [PATCH] alsdec: Introduce failsafe switch to keep ALSSpecificConfig consistent to the input.

Thilo Borgmann thilo.borgmann at googlemail.com
Sat Jan 5 15:52:08 CET 2013


To keep sconf->chan_sort consistent with the input stream and not reuse it in
the failsage case.

-Thilo
-------------- next part --------------
>From 7d3b5a2c3bf819c0dce89f06ea78807a86dead72 Mon Sep 17 00:00:00 2001
From: Thilo Borgmann <thilo.borgmann at googlemail.com>
Date: Sat, 5 Jan 2013 15:29:13 +0100
Subject: [PATCH] alsdec: Introduce failsafe switch to keep ALSSpecificConfig consistent to the input.

---
 libavcodec/alsdec.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 8b9c2ee..6136a25 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -202,6 +202,7 @@ typedef struct {
     unsigned int cur_frame_length;  ///< length of the current frame to decode
     unsigned int frame_id;          ///< the frame ID / number of the current frame
     unsigned int js_switch;         ///< if true, joint-stereo decoding is enforced
+    unsigned int cs_switch;         ///< if true, channel rearrangement is done
     unsigned int num_blocks;        ///< number of blocks used in the current frame
     unsigned int s_max;             ///< maximum Rice parameter allowed in entropy coding
     uint8_t *bgmc_lut;              ///< pointer at lookup tables used for BGMC
@@ -355,21 +356,21 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
         if (!(sconf->chan_pos = av_malloc(avctx->channels * sizeof(*sconf->chan_pos))))
             return AVERROR(ENOMEM);

+        ctx->cs_switch = 1;
+
         for (i = 0; i < avctx->channels; i++) {
             int idx;

             idx = get_bits(&gb, chan_pos_bits);
             if (idx >= avctx->channels) {
                 av_log(avctx, AV_LOG_WARNING, "Invalid channel reordering.\n");
-                sconf->chan_sort = 0;
+                ctx->cs_switch = 0;
                 break;
             }
             sconf->chan_pos[idx] = i;
         }

         align_get_bits(&gb);
-    } else {
-        sconf->chan_sort = 0;
     }


@@ -1487,7 +1488,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
     {                                                                                \
         int##bps##_t *dest = (int##bps##_t*)ctx->frame.data[0];                      \
         shift = bps - ctx->avctx->bits_per_raw_sample;                               \
-        if (!sconf->chan_sort) {                                                     \
+        if (!ctx->cs_switch) {                                                       \
             for (sample = 0; sample < ctx->cur_frame_length; sample++)               \
                 for (c = 0; c < avctx->channels; c++)                                \
                     *dest++ = ctx->raw_samples[c][sample] << shift;                  \
--
1.7.4.3



More information about the ffmpeg-devel mailing list