[FFmpeg-devel] [PATCH] Rename ffadler to ffhash and expand it using the generic hash API

Reimar Döffinger Reimar.Doeffinger at gmx.de
Wed May 15 19:37:06 CEST 2013


On Wed, May 15, 2013 at 03:38:12PM +0200, Michael Niedermayer wrote:
> On Wed, May 15, 2013 at 04:35:40AM -0300, James Almer wrote:
> > Signed-off-by: James Almer <jamrial at gmail.com>
> > ---
> >  libavutil/Makefile            |  2 +-
> >  tools/{ffadler.c => ffhash.c} | 79 +++++++++++++++++++++++++++++++++++++------
> >  2 files changed, 70 insertions(+), 11 deletions(-)
> >  rename tools/{ffadler.c => ffhash.c} (49%)
> 
> [...]
> 
> > +static void finish(void)
> > +{
> > +    int i, len = av_hash_get_size(hash);
> > +
> > +    printf("%s=0x", av_hash_get_name(hash));
> > +    av_hash_final(hash, res);
> > +    for (i = 0; i < len; i++)
> > +        printf("%02"PRIx8, res[i]);
> 
> %02x
> 
> also, the values returned change
> 
> echo this | tools/ffhash adler32
> adler32=0xc2010f06
> 
> echo this | tools/ffadler
> A32=0x061401c3

As he mentioned earlier, this is because hash.c isn't really
behaving well for adler32/CRC.
If I understood right at the very least this should be done,
but I did not test:
--- a/libavutil/hash.c
+++ b/libavutil/hash.c
@@ -97,7 +97,7 @@ int av_hash_alloc(AVHashContext **ctx, const char *name)
     case SHA224:
     case SHA256:  res->ctx = av_sha_alloc(); break;
     case CRC32:   res->crctab = av_crc_get_table(AV_CRC_32_IEEE); break;
-    case ADLER32: break;
+    case ADLER32: res->crc = 1; break;
     }
     if (i != ADLER32 && i != CRC32 && !res->ctx) {
         av_free(res);


More information about the ffmpeg-devel mailing list