[FFmpeg-devel] [PATCH] ALS decoder

Thilo Borgmann thilo.borgmann
Tue Aug 25 15:37:11 CEST 2009


>> +    int64_t *prev_raw_samples; ///< contains unshifted raw samples from the previous block
>> +    int64_t **raw_samples;     ///< decoded raw samples for each channel
>> +    int64_t *raw_buffer;       ///< contains all decoded raw samples including carryover samples
> 
> these do need 64bit?
I'm currently retracing the need for 64 at all. This might take some
time though...



>> +        av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
>> +        return AVERROR(ENOMEM);
>> +    }
>> +
>> +    // calculate total number of frames to decode if possible
>> +    if (samples != 0xFFFFFFFF) {
>> +        ctx->num_frames        = ((samples - 1) / sconf->frame_length) + 1;
> 
>> +        ctx->last_frame_length = samples % ctx->sconf.frame_length;
>> +        if (!ctx->last_frame_length) {
>> +            ctx->last_frame_length = sconf->frame_length;
>> +        }
> 
> thats the same as
> (L-1) % F + 1
> i think (unchecked though)
Missing lvalue and independent of samples?


> [...]
>> +
>> +/** Reads and decodes a Rice codeword.
>> + */
> 
>> +static int64_t decode_rice(GetBitContext *gb, unsigned int k)
> 
> is the 64 bit really needed here?
> 
> [...]
see above.



> [...]
>> +/** Decodes blocks independently.
>> + */
>> +static int decode_blocks_ind(ALSDecContext *ctx, unsigned int ra_frame,
>> +                             unsigned int c, unsigned int *div_blocks,
>> +                             unsigned int *js_blocks)
>> +{
>> +    int64_t *raw_sample;
>> +    unsigned int b;
>> +    raw_sample = ctx->raw_samples[c];
>> +
>> +    for (b = 0; b < ctx->num_blocks; b++) {
>> +        if (read_block_data(ctx, ra_frame, raw_sample,
>> +                            div_blocks[b], &js_blocks[0], NULL)) {
> 
>> +            // damaged block, write zero for the rest of the frame
>> +            while (b < ctx->num_blocks) {
>> +                memset(raw_sample, 0, div_blocks[b]);
>> +                raw_sample += div_blocks[b];
>> +                b++;
>> +            }
>> +            return -1;
> [...]
>> +            // damaged block, write zero for the rest of the frame
>> +            while (b < ctx->num_blocks) {
>> +                memset(raw_samples_L, 0, div_blocks[b]);
>> +                memset(raw_samples_R, 0, div_blocks[b]);
>> +                raw_samples_L += div_blocks[b];
>> +                raw_samples_R += div_blocks[b];
>> +                b++;
>> +            }
> [...]
>> +                // damaged block, write zero for the rest of the frame
>> +                while (b < ctx->num_blocks) {
>> +                    memset(raw_samples_L, 0, div_blocks[b]);
>> +                    raw_samples_L += div_blocks[b];
>> +                    b++;
>> +                }
> 
> cant these be factored/combined?
They could be factored into decode_frame() but several parameters would
have to be passed somehow to know wich samples of which channel could be
decoded correctly already.
Alternative 1) loose all samples of the current RA unit.
Alternative 2) infunction {while() memset;} but this would add a second
loop for the code block in the middle.
Which way to go?


All other changes are part of revision 8.

-Thilo



More information about the ffmpeg-devel mailing list