This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit e85c0e0ab1b5333c9d3c3bc6fbc1574fdd2d9d3d
Author:     Niklas Haas <[email protected]>
AuthorDate: Mon Jun 29 17:35:13 2026 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Thu Jul 2 14:29:42 2026 +0000

    avformat/shared: increase CRC size to 32-bits
    
    This increases the amount of corrupted data we can correctly detect
    as corrupted from (on average) 2 GiB to 128 TiB, at the default 32 KiB block
    size.
    
    Sponsored-by: nxtedition AB
    Signed-off-by: Niklas Haas <[email protected]>
---
 libavformat/shared.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavformat/shared.c b/libavformat/shared.c
index 7c8b17350c..f47ea3a805 100644
--- a/libavformat/shared.c
+++ b/libavformat/shared.c
@@ -79,7 +79,7 @@ static int hash_uri(uint8_t hash[HASH_SIZE], const char *uri)
 }
 
 #define HEADER_MAGIC   MKTAG(u'\xFF', 'S', 'h', '$')
-#define HEADER_VERSION 2
+#define HEADER_VERSION 3
 
 enum BlockState {
     /* Reserved block state values */
@@ -93,9 +93,9 @@ enum BlockState {
      */
 };
 
-static uint16_t get_block_crc(const uint8_t *block, size_t block_size)
+static uint32_t get_block_crc(const uint8_t *block, size_t block_size)
 {
-    uint16_t crc = av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, block, 
block_size);
+    uint32_t crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, block, 
block_size);
     switch (crc) {
     case BLOCK_NONE:
     case BLOCK_FAILED:
@@ -107,7 +107,7 @@ static uint16_t get_block_crc(const uint8_t *block, size_t 
block_size)
 }
 
 typedef struct Block {
-    atomic_ushort state; /* enum BlockState */
+    atomic_uint state; /* enum BlockState */
 } Block;
 
 typedef struct Spacemap {
@@ -601,7 +601,7 @@ static int shared_read(URLContext *h, unsigned char *buf, 
int size)
         return ret;
 
     Block *const block = &s->spacemap->blocks[block_id];
-    unsigned short state = atomic_load_explicit(&block->state, 
memory_order_acquire);
+    unsigned state = atomic_load_explicit(&block->state, memory_order_acquire);
     int64_t pending_since = 0;
     int verify_read = 0, is_race = 0;
 
@@ -622,10 +622,10 @@ retry:
             }
         }
 
-        uint16_t crc = get_block_crc(tmp, block_size);
+        uint32_t crc = get_block_crc(tmp, block_size);
         if (crc != state) {
             av_log(h, AV_LOG_ERROR, "Cache corruption detected for block 
0x%"PRIx64" at "
-                   "offset 0x%"PRIx64": expected CRC: 0x%04X, got: 0x%04X\n",
+                   "offset 0x%"PRIx64": expected CRC: 0x%08X, got: 0x%08X\n",
                    block_id, block_pos, state, crc);
             return AVERROR(EIO);
         }
@@ -786,9 +786,9 @@ retry:
                                                     memory_order_relaxed,
                                                     memory_order_relaxed);
         } else {
-            uint16_t crc = get_block_crc(tmp, bytes_read);
+            uint32_t crc = get_block_crc(tmp, bytes_read);
             av_log(h, AV_LOG_TRACE, "Cached %d bytes to block 0x%"PRIx64" at "
-                   "offset 0x%"PRIx64", CRC 0x%04X\n", bytes_read, block_id,
+                   "offset 0x%"PRIx64", CRC 0x%08X\n", bytes_read, block_id,
                    block_pos, crc);
             atomic_store_explicit(&block->state, crc, memory_order_release);
         }

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to