From: Nuo Mi <nuomi2021@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Nuo Mi <nuomi2021@gmail.com> Subject: [FFmpeg-devel] [PATCH] avutil/hash: add 16-bit CRC type CCITT_AUG Date: Tue, 25 Mar 2025 22:59:28 +0800 Message-ID: <20250325145928.63536-1-nuomi2021@gmail.com> (raw) 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-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2025-03-25 14:59 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-03-25 14:59 Nuo Mi [this message] 2025-03-28 22:20 ` Michael Niedermayer 2025-03-30 4:17 ` Nuo Mi
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250325145928.63536-1-nuomi2021@gmail.com \ --to=nuomi2021@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git