[FFmpeg-devel] [PATCH] avcodec/ffv1: Implement CRC with -1 initial and final value

Michael Niedermayer michael at niedermayer.cc
Thu Sep 26 22:56:49 EEST 2024


On Thu, Sep 26, 2024 at 09:51:48PM +0200, Michael Niedermayer wrote:
> Hi Traneptora
> 
> On Wed, Sep 25, 2024 at 06:52:52PM -0400, Leo Izen wrote:
> > On 9/25/24 4:06 AM, Michael Niedermayer wrote:
> > > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
[...]
> > >           if (f->ec) {
> > > -            unsigned crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, buf_p, v);
> > > -            if (crc) {
> > > +            unsigned crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref, buf_p, v);
> > 
> > Do we require sizeof(unsigned int) == 4?
> 
> no
> 
> 
> > Whether or not, it may be more readable to declare crc as a uint32_t
> 
> maybe, but that belongs in a seperate patch

it seems to have the opposit effect see:
(especially the av_log())

diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index b4d719a7eec..9efc926092c 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -509,11 +509,11 @@ static int read_extra_header(FFV1Context *f)
     }

     if (f->version > 2) {
-        unsigned v;
+        uint32_t v;
         v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref,
                    f->avctx->extradata, f->avctx->extradata_size);
         if (v != f->crcref || f->avctx->extradata_size < 4) {
-            av_log(f->avctx, AV_LOG_ERROR, "CRC mismatch %X!\n", v);
+            av_log(f->avctx, AV_LOG_ERROR, "CRC mismatch %"PRIX32"!\n", v);
             return AVERROR_INVALIDDATA;
         }
         crc = AV_RB32(f->avctx->extradata + f->avctx->extradata_size - 4);
@@ -950,10 +950,10 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
         buf_p -= v;

         if (f->ec) {
-            unsigned crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref, buf_p, v);
+            uint32_t crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref, buf_p, v);
             if (crc != f->crcref) {
                 int64_t ts = avpkt->pts != AV_NOPTS_VALUE ? avpkt->pts : avpkt->dts;
-                av_log(f->avctx, AV_LOG_ERROR, "slice CRC mismatch %X!", crc);
+                av_log(f->avctx, AV_LOG_ERROR, "slice CRC mismatch %"PRIX32"!", crc);
                 if (ts != AV_NOPTS_VALUE && avctx->pkt_timebase.num) {
                     av_log(f->avctx, AV_LOG_ERROR, "at %f seconds\n", ts*av_q2d(avctx->pkt_timebase));
                 } else if (ts != AV_NOPTS_VALUE) {


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No snowflake in an avalanche ever feels responsible. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20240926/5d65f23f/attachment.sig>


More information about the ffmpeg-devel mailing list