[FFmpeg-devel] [PATCH] ALS decoder

Diego Biurrun diego
Mon Aug 24 12:43:58 CEST 2009


On Sun, Aug 23, 2009 at 11:51:18PM +0200, Thilo Borgmann wrote:
> 
> --- libavcodec/alsdec.c	(revision 0)
> +++ libavcodec/alsdec.c	(revision 0)
> @@ -0,0 +1,1089 @@
> +typedef struct {
> +    int frame_length;         ///< frame Length

length

But this is a rather redundant comment.

> +    uint32_t trailer_size;    ///< Trailer size of original audio file in bytes, provided for debugging

trailer

> +    GetBitContext gb;          ///< a bit reader context

bitreader

> +    unsigned int frame_id;     ///< the frame id / number of the current frame

ID

> +        q = get_unary(gb, 0, max);
> +        if (k == 1) {

if (k) { ?

> +static void parcor_to_lpc(unsigned int k, int32_t *par, int32_t *cof)
> +{
> +    int i;
> +
> +    for (i = 0; i < (k+1) >> 1; i++) {

pointless ()

> +    if (get_bits1(gb)) {
> +        *shift_lsbs = get_bits(gb, 4) + 1;
> +    }

pointless {}

> +            int opt_order_length =
> +                    FFMIN(
> +                    av_ceil_log2(sconf->max_order+1),
> +                    FFMAX(av_ceil_log2((block_length >> 3) - 1), 1)
> +                    );

That looks ugly.

> +        for (sb = 0; sb < sub_blocks; sb++) {
> +            for (k = start; k < sb_length; k++) {
> +                current_res[k] = decode_rice(gb, s[sb]);
> +            }

pointless {}

> +static int read_block_data(ALSDecContext *ctx, unsigned int ra_block,
> +                            int64_t *raw_samples, unsigned int block_length,
> +                            unsigned int *js_blocks, int64_t *raw_other)

Indentation is off.

> +    if (!sconf->mc_coding || ctx->js_switch) {
> +        align_get_bits(gb);
> +    }
> +
> +    if (shift_lsbs) {
> +        for (k = 0; k < block_length; k++)
> +            raw_samples[k] <<= shift_lsbs;
> +    }

more pointless {}

> +    if (ctx->num_frames && ctx->num_frames - 1 == ctx->frame_id) {
> +        ctx->cur_frame_length = ctx->last_frame_length;
> +    }
> +
> +    // decode the frame data
> +    if ((invalid_frame = read_frame_data(ctx, ra_frame))) {
> +        av_log(ctx->avctx, AV_LOG_WARNING,
> +               "Reading frame data failed. Skipping RA unit.\n");
> +    }

more pointless {}

> +    #define INTERLEAVE_OUTPUT(bps)                                   \
> +    {                                                                \
> +        int##bps##_t *dest = (int##bps##_t*) data;                   \
> +        shift = bps - ctx->avctx->bits_per_raw_sample;               \
> +        for (sample = 0; sample < ctx->cur_frame_length; sample++) { \
> +            for (c = 0; c < avctx->channels; c++) {                  \
> +                *dest++ = ctx->raw_samples[c][sample] << shift;      \
> +            }                                                        \
> +        }                                                            \

again

> +    if (!(ctx->prev_raw_samples = av_malloc(sizeof(int64_t) * sconf->max_order)) ||
> +        !(ctx->raw_buffer = av_mallocz(sizeof(int64_t) * avctx->channels
> +                                                          * channel_size))) {

This looks weird.

> +    for (c = 1; c < avctx->channels; c++) {
> +        ctx->raw_samples[c] = ctx->raw_samples[c - 1] + channel_size;
> +    }

{}

Diego



More information about the ffmpeg-devel mailing list