[FFmpeg-devel] [PATCH] lavc/flacdec: Add frame CRC calculation

James Almer jamrial at gmail.com
Sat Feb 23 01:08:33 CET 2013


On 21/02/13 8:26 AM, Paul B Mahol wrote:
> From: James Almer <jamrial at gmail.com>
> 
> Fixes ticket #2266
> 
> Signed-off-by: James Almer <jamrial at gmail.com>
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
>  libavcodec/flacdec.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
> index f264d20..1f6d9a8 100644
> --- a/libavcodec/flacdec.c
> +++ b/libavcodec/flacdec.c
> @@ -533,7 +533,13 @@ static int flac_decode_frame(AVCodecContext *avctx, void *data,
>          av_log(s->avctx, AV_LOG_ERROR, "decode_frame() failed\n");
>          return -1;
>      }
> -    bytes_read = (get_bits_count(&s->gb)+7)/8;
> +    bytes_read = get_bits_count(&s->gb)/8;
> +
> +    if ((s->avctx->err_recognition & AV_EF_CRCCHECK) &&
> +        av_crc(av_crc_get_table(AV_CRC_16_ANSI),
> +               0, buf, bytes_read)) {
> +        av_log(s->avctx, AV_LOG_ERROR, "CRC error\n");
> +    }
>  
>      /* get output buffer */
>      frame->nb_samples = s->blocksize;

The user that opened the ticket requested the error to report the PTS of the damaged
frame.
We could use either

av_log(s->avctx, AV_LOG_ERROR, "CRC error at PTS %"PRId64"\n", 
       avpkt->pts);

or

av_log(s->avctx, AV_LOG_ERROR, "CRC error at %f seconds\n", 
       avpkt->pts * av_q2d(s->avctx->pkt_timebase));

Looks good otherwise.

Regards.


More information about the ffmpeg-devel mailing list