It is also referred to as:
    SPI-FUJITSU
    AUG-CCITT
    CRC-CCITT (0x1D0F)
This CRC type used by H.274
---
 libavutil/hash.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavutil/hash.c b/libavutil/hash.c
index fbc24194de..3659c71c7f 100644
--- a/libavutil/hash.c
+++ b/libavutil/hash.c
@@ -55,6 +55,7 @@
     ENTRY(SHA384,     "SHA384",     48) \
     ENTRY(SHA512,     "SHA512",     64) \
     ENTRY(CRC32,      "CRC32",       4) \
+    ENTRY(CCITT_AUG,  "CCITT_AUG",   2) \
     ENTRY(ADLER32,    "adler32",     4) \
 
 enum hashtype {
@@ -138,9 +139,10 @@ int av_hash_alloc(AVHashContext **ctx, const char *name)
     case SHA384:
     case SHA512:  res->ctx = av_sha512_alloc(); break;
     case CRC32:   res->crctab = av_crc_get_table(AV_CRC_32_IEEE_LE); break;
+    case CCITT_AUG:    res->crctab = av_crc_get_table(AV_CRC_16_CCITT); break;
     case ADLER32: break;
     }
-    if (i != ADLER32 && i != CRC32 && !res->ctx) {
+    if (i != ADLER32 && i != CRC32 && i != CCITT_AUG && !res->ctx) {
         av_free(res);
         return AVERROR(ENOMEM);
     }
@@ -165,6 +167,7 @@ void av_hash_init(AVHashContext *ctx)
     case SHA384:  av_sha512_init(ctx->ctx, 384); break;
     case SHA512:  av_sha512_init(ctx->ctx, 512); break;
     case CRC32:   ctx->crc = UINT32_MAX; break;
+    case CCITT_AUG:   ctx->crc = 0x0F1D; break; //Byte swapped value of 0x1D0F
     case ADLER32: ctx->crc = 1; break;
     }
 }
@@ -185,7 +188,8 @@ void av_hash_update(AVHashContext *ctx, const uint8_t *src, 
size_t len)
     case SHA512_256:
     case SHA384:
     case SHA512:  av_sha512_update(ctx->ctx, src, len); break;
-    case CRC32:   ctx->crc = av_crc(ctx->crctab, ctx->crc, src, len); break;
+    case CRC32:
+    case CCITT_AUG: ctx->crc = av_crc(ctx->crctab, ctx->crc, src, len); break;
     case ADLER32: ctx->crc = av_adler32_update(ctx->crc, src, len); break;
     }
 }
@@ -207,6 +211,7 @@ void av_hash_final(AVHashContext *ctx, uint8_t *dst)
     case SHA384:
     case SHA512:  av_sha512_final(ctx->ctx, dst); break;
     case CRC32:   AV_WB32(dst, ctx->crc ^ UINT32_MAX); break;
+    case CCITT_AUG: AV_WB16(dst, ctx->crc); break;
     case ADLER32: AV_WB32(dst, ctx->crc); break;
     }
 }
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to