[FFmpeg-devel] [PATCH] Multi-Channel Correlation in ALS

Michael Niedermayer michaelni
Mon Jan 4 12:48:08 CET 2010


On Mon, Dec 21, 2009 at 01:24:07PM +0100, Thilo Borgmann wrote:
[...]
> +/** Recursively reverts the inter-channel correlation for a block.
> + */
> +static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
> +                                       ALSChannelData **cd, int *reverted,
> +                                       unsigned int offset, int c)
> +{
> +    ALSChannelData *ch = cd[c];
> +    unsigned int   dep = 0;
> +    unsigned int channels = ctx->avctx->channels;
> +

> +    if (reverted[c])
> +        return 0;
> +    else

{}


> +        reverted[c] = 1;
> +
> +    while (dep < channels && !ch[dep].stop_flag) {
> +        if (!reverted[ch[dep].master_channel])
> +            revert_channel_correlation(ctx, bd, cd, reverted, offset,
> +                                       ch[dep].master_channel);
> +
> +        dep++;
> +    }
> +
> +    if (dep == channels) {
> +        av_log(ctx->avctx, AV_LOG_WARNING, "Invalid channel correlation!\n");
> +        return -1;
> +    }
> +
> +    bd->use_ltp     = ctx->use_ltp + c;
> +    bd->ltp_lag     = ctx->ltp_lag + c;
> +    bd->ltp_gain    = ctx->ltp_gain[c];
> +    bd->lpc_cof     = ctx->lpc_cof[c];
> +    bd->quant_cof   = ctx->quant_cof[c];
> +    bd->raw_samples = ctx->raw_samples[c] + offset;
> +
> +    dep = 0;
> +    while (!ch[dep].stop_flag) {
> +        unsigned int smp;
> +        unsigned int begin = 1;
> +        unsigned int end   = bd->block_length - 1;
> +        int64_t y;
> +        int32_t *master = ctx->raw_samples[ch[dep].master_channel] + offset;
> +
> +        if (ch[dep].time_diff_flag) {
> +            int t = ch[dep].time_diff_index;
> +
> +            if (ch[dep].time_diff_sign)
> +                begin -= t;
> +            else

{}


[...]
> @@ -%ld,%ld +%ld,%ld @@
>                      sizeof(*ctx->raw_samples[c]) * sconf->max_order);
>          }
>      } else { // multi-channel coding
> +        ALSBlockData   bd;
> +        int            b;

> +        int            reverted_channels[avctx->channels];

i think malloc() would be safer or check that channel is within a
reasonabe range. Or make double sure the common code checks it

iam ok with the rest of the patch i think

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100104/606e95e4/attachment.pgp>



More information about the ffmpeg-devel mailing list