[FFmpeg-devel] [PATCH] Add CRC check to ALS decoder

Måns Rullgård mans
Sun Jun 13 19:51:05 CEST 2010


Thilo Borgmann <thilo.borgmann at googlemail.com> writes:

> Am 12.06.10 21:08, schrieb Justin Ruggles:
>> Thilo Borgmann wrote:
>> 
>>>>> CRC check for the ALS decoder.
>>>>>
>>>>> Works fine on my Intel-driven architecture. Any tests on other archs are
>>>>> of course appreciated.
>>>> I'm pretty sure the CRC for 24-bit source files are calculated based on
>>>> 3-byte samples, not 4-byte samples.  I don't think your patch would work
>>>> in this case.  Have you tested this with 24-bit source files?
>>>
>>> Sorry, indeed not. Revision 1 is tested against the 24 bit conformance
>>> files.
>>>
>>> Still, I would appreciate if someone can test it on a non-intel arch
>>> (before FATE does...).
>> 
>> Maybe the patch could be simplified and some macros avoided by doing
>> something like:
>> 
>> int swap = HAVE_BIGENDIAN != sconf->msb_first;
>> ...
>> if (swap)
>>     bswap_##bps##(...)
>> ...
>
> Good idea.
>
> +    // update CRC
> +    if (sconf->crc_enabled && avctx->error_recognition >= FF_ER_CAREFUL) {
> +        int swap = HAVE_BIGENDIAN != sconf->msb_first;
> +
> +        #define CONVERT_OUTPUT(bps)                                \
> +        {                                                          \
> +            int##bps##_t *src  = (int##bps##_t*) data;             \
> +            int##bps##_t *dest = (int##bps##_t*) ctx->crc_buffer;  \
> +            for (sample = 0;                                       \
> +                 sample < ctx->cur_frame_length * avctx->channels; \
> +                 sample++)                                         \
> +                    *dest++ = bswap_##bps (src[sample]);           \
> +        }

Use bswap_buf from dsputil after adding a 16-bit version.


> @@ -1606,6 +1674,29 @@
>      for (c = 1; c < avctx->channels; c++)
>          ctx->raw_samples[c] = ctx->raw_samples[c - 1] + channel_size;
>
> +    // allocate crc buffer
> +    #define COND_MALLOC(cond)                                       \
> +    {                                                               \
> +        if ((cond) &&  sconf->crc_enabled &&                        \
> +            avctx->error_recognition >= FF_ER_CAREFUL) {            \
> +            ctx->crc_buffer = av_malloc(sizeof(*ctx->crc_buffer) *  \
> +                                        ctx->cur_frame_length *     \
> +                                        avctx->channels *           \
> +                                        (av_get_bits_per_sample_format(avctx->sample_fmt) >> 3)); \
> +            if (!ctx->crc_buffer) {                                 \
> +                av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n"); \
> +                decode_end(avctx);                                  \
> +                return AVERROR(ENOMEM);                             \
> +            }                                                       \
> +        }                                                           \
> +    }
> +
> +#if HAVE_BIGENDIAN
> +    COND_MALLOC(!sconf->msb_first);
> +#else
> +    COND_MALLOC( sconf->msb_first);
> +#endif

sconf->msb_first != HAVE_BIGENDIAN

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list