[FFmpeg-devel] [PATCH]Only run the tta crc checks if requested

Paul B Mahol onemda at gmail.com
Fri Feb 6 11:48:02 CET 2015


On 2/6/15, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
> Hi!
>
> I did not benchmark but attached should be both a little faster
> and a little cleaner.
>
> Please comment, Carl Eugen
>

> From 8bf4e1c82e818483a5bbf55147bb818e5cfacc70 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <cehoyos at ag.or.at>
> Date: Fri, 6 Feb 2015 10:13:31 +0100
> Subject: [PATCH] avformat/tta: only check for header and seek table crc if
>  requested
>
> ---
>  libavformat/tta.c |   20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/libavformat/tta.c b/libavformat/tta.c
> index a782bd7..e839bc2 100644
> --- a/libavformat/tta.c
> +++ b/libavformat/tta.c
> @@ -83,10 +83,12 @@ static int tta_read_header(AVFormatContext *s)
>          return AVERROR_INVALIDDATA;
>      }
>
> -    crc = ffio_get_checksum(s->pb) ^ UINT32_MAX;
> -    if (crc != avio_rl32(s->pb) && s->error_recognition & AV_EF_CRCCHECK) {
> -        av_log(s, AV_LOG_ERROR, "Header CRC error\n");
> -        return AVERROR_INVALIDDATA;
> +    if (s->error_recognition & AV_EF_CRCCHECK) {
> +        crc = ffio_get_checksum(s->pb) ^ UINT32_MAX;
> +        if (crc != avio_rl32(s->pb) && s->error_recognition & AV_EF_CRCCHECK) {

You are checking for AV_EF_CRCCHECK twice.

> +            av_log(s, AV_LOG_ERROR, "Header CRC error\n");
> +            return AVERROR_INVALIDDATA;
> +        }
>      }
>
>      c->frame_size      = samplerate * 256 / 245;
> @@ -129,10 +131,12 @@ static int tta_read_header(AVFormatContext *s)
>              return r;
>          framepos += size;
>      }
> -    crc = ffio_get_checksum(s->pb) ^ UINT32_MAX;
> -    if (crc != avio_rl32(s->pb) && s->error_recognition & AV_EF_CRCCHECK) {
> -        av_log(s, AV_LOG_ERROR, "Seek table CRC error\n");
> -        return AVERROR_INVALIDDATA;
> +    if (s->error_recognition & AV_EF_CRCCHECK) {
> +        crc = ffio_get_checksum(s->pb) ^ UINT32_MAX;
> +        if (crc != avio_rl32(s->pb)) {
> +            av_log(s, AV_LOG_ERROR, "Seek table CRC error\n");
> +            return AVERROR_INVALIDDATA;
> +        }
>      }
>
>      st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
> --
> 1.7.10.4
>


More information about the ffmpeg-devel mailing list