Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avutil/hash: add 16-bit CRC type CCITT_AUG
@ 2025-03-25 14:59 Nuo Mi
  2025-03-28 22:20 ` Michael Niedermayer
  0 siblings, 1 reply; 3+ messages in thread
From: Nuo Mi @ 2025-03-25 14:59 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avutil/hash: add 16-bit CRC type CCITT_AUG
  2025-03-25 14:59 [FFmpeg-devel] [PATCH] avutil/hash: add 16-bit CRC type CCITT_AUG Nuo Mi
@ 2025-03-28 22:20 ` Michael Niedermayer
  2025-03-30  4:17   ` Nuo Mi
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Niedermayer @ 2025-03-28 22:20 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 586 bytes --]

Hi

On Tue, Mar 25, 2025 at 10:59:28PM +0800, Nuo Mi wrote:
> 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(-)

needs update to fate-hash

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avutil/hash: add 16-bit CRC type CCITT_AUG
  2025-03-28 22:20 ` Michael Niedermayer
@ 2025-03-30  4:17   ` Nuo Mi
  0 siblings, 0 replies; 3+ messages in thread
From: Nuo Mi @ 2025-03-30  4:17 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Sat, Mar 29, 2025 at 6:21 AM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> Hi
>
> On Tue, Mar 25, 2025 at 10:59:28PM +0800, Nuo Mi wrote:
> > 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(-)
>
> needs update to fate-hash
>
Hi Micheal,
Thank you for the review.
Reimar believes that the hash API may not be necessary
<https://github.com/ffvvc/FFmpeg/pull/283#issuecomment-2755799110> for h274.

We are still working on this and discussing the approach.
If we determine that the patch is still needed, I will update the fate-hash
accordingly.

>
> thx
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Many things microsoft did are stupid, but not doing something just because
> microsoft did it is even more stupid. If everything ms did were stupid they
> would be bankrupt already.
> _______________________________________________
> 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".
>
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-30  4:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-25 14:59 [FFmpeg-devel] [PATCH] avutil/hash: add 16-bit CRC type CCITT_AUG Nuo Mi
2025-03-28 22:20 ` Michael Niedermayer
2025-03-30  4:17   ` Nuo Mi

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