Re: [FFmpeg-devel] [PATCH v2 67/90] avutil: Switch crypto APIs to size_t

2021-04-19 Thread Andreas Rheinhardt
On Mon, Apr 19, 2021 at 10:33 PM Carl Eugen Hoyos 
wrote:

> Am Mo., 19. Apr. 2021 um 21:22 Uhr schrieb Andreas Rheinhardt
> :
> >
> > From: Andreas Rheinhardt 
> >
> > Announced in e435beb1ea5380a90774dbf51fdc8c941e486551.
> >
> > Signed-off-by: Andreas Rheinhardt 
> > ---
> > I forgot a printf specifier in tests/api/api-h264-test.c.
>
> > diff --git a/libavutil/version.h b/libavutil/version.h
> > index dbeb7ffe23..54b09534a2 100644
> > --- a/libavutil/version.h
> > +++ b/libavutil/version.h
> > @@ -105,9 +105,6 @@
> >   * @{
> >   */
> >
> > -#ifndef FF_API_CRYPTO_SIZE_T
> > -#define FF_API_CRYPTO_SIZE_T(LIBAVUTIL_VERSION_MAJOR < 57)
> > -#endif
> >  #ifndef FF_API_FRAME_GET_SET
> >  #define FF_API_FRAME_GET_SET(LIBAVUTIL_VERSION_MAJOR < 57)
> >  #endif
> > diff --git a/tests/api/api-h264-test.c b/tests/api/api-h264-test.c
> > index 04bdfbc9d2..6f13e773f9 100644
> > --- a/tests/api/api-h264-test.c
> > +++ b/tests/api/api-h264-test.c
> > @@ -153,7 +153,7 @@ static int video_decode_example(const char
> *input_filename)
> >  av_frame_unref(fr);
> >  return number_of_written_bytes;
> >  }
>
> > -printf("%d, %s, %s, %8"PRId64", %8d, 0x%08lx\n",
> video_stream,
> > +printf("%d, %s, %s, %8"PRId64", %8d, 0x%08"PRIx32"\n",
> video_stream,
> > av_ts2str(fr->pts), av_ts2str(fr->pkt_dts),
> fr->pkt_duration,
> > number_of_written_bytes, av_adler32_update(0, (const
> uint8_t*)byte_buffer, number_of_written_bytes));
>
> Afaict, this change is either related to another patch or wrong.
>

For most hash APIs the size parameter has been switched to size_t;
for av_adler32_update(), the return value has been switched as well:
>From unsigned long to uint32_t. Therefore this printf specifier had to
be updated as well.
(Adler-32 checksums are 32bit, so uint32_t is the natural type for them.)

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


Re: [FFmpeg-devel] [PATCH v2 67/90] avutil: Switch crypto APIs to size_t

2021-04-19 Thread James Almer

On 4/19/2021 5:10 PM, Carl Eugen Hoyos wrote:

Am Mo., 19. Apr. 2021 um 21:22 Uhr schrieb Andreas Rheinhardt
:


From: Andreas Rheinhardt 

Announced in e435beb1ea5380a90774dbf51fdc8c941e486551.

Signed-off-by: Andreas Rheinhardt 
---
I forgot a printf specifier in tests/api/api-h264-test.c.



diff --git a/libavutil/version.h b/libavutil/version.h
index dbeb7ffe23..54b09534a2 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -105,9 +105,6 @@
   * @{
   */

-#ifndef FF_API_CRYPTO_SIZE_T
-#define FF_API_CRYPTO_SIZE_T(LIBAVUTIL_VERSION_MAJOR < 57)
-#endif
  #ifndef FF_API_FRAME_GET_SET
  #define FF_API_FRAME_GET_SET(LIBAVUTIL_VERSION_MAJOR < 57)
  #endif
diff --git a/tests/api/api-h264-test.c b/tests/api/api-h264-test.c
index 04bdfbc9d2..6f13e773f9 100644
--- a/tests/api/api-h264-test.c
+++ b/tests/api/api-h264-test.c
@@ -153,7 +153,7 @@ static int video_decode_example(const char *input_filename)
  av_frame_unref(fr);
  return number_of_written_bytes;
  }



-printf("%d, %s, %s, %8"PRId64", %8d, 0x%08lx\n", video_stream,
+printf("%d, %s, %s, %8"PRId64", %8d, 0x%08"PRIx32"\n", 
video_stream,
 av_ts2str(fr->pts), av_ts2str(fr->pkt_dts), 
fr->pkt_duration,
 number_of_written_bytes, av_adler32_update(0, (const 
uint8_t*)byte_buffer, number_of_written_bytes));


Afaict, this change is either related to another patch or wrong.


The patch changes av_adler32_update() from returning an unsigned long to 
returning an uint32_t, and this chunk here updates the printf specifier 
required for it.




Carl Eugen
___
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".



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


Re: [FFmpeg-devel] [PATCH v2 67/90] avutil: Switch crypto APIs to size_t

2021-04-19 Thread Carl Eugen Hoyos
Am Mo., 19. Apr. 2021 um 21:22 Uhr schrieb Andreas Rheinhardt
:
>
> From: Andreas Rheinhardt 
>
> Announced in e435beb1ea5380a90774dbf51fdc8c941e486551.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
> I forgot a printf specifier in tests/api/api-h264-test.c.

> diff --git a/libavutil/version.h b/libavutil/version.h
> index dbeb7ffe23..54b09534a2 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -105,9 +105,6 @@
>   * @{
>   */
>
> -#ifndef FF_API_CRYPTO_SIZE_T
> -#define FF_API_CRYPTO_SIZE_T(LIBAVUTIL_VERSION_MAJOR < 57)
> -#endif
>  #ifndef FF_API_FRAME_GET_SET
>  #define FF_API_FRAME_GET_SET(LIBAVUTIL_VERSION_MAJOR < 57)
>  #endif
> diff --git a/tests/api/api-h264-test.c b/tests/api/api-h264-test.c
> index 04bdfbc9d2..6f13e773f9 100644
> --- a/tests/api/api-h264-test.c
> +++ b/tests/api/api-h264-test.c
> @@ -153,7 +153,7 @@ static int video_decode_example(const char 
> *input_filename)
>  av_frame_unref(fr);
>  return number_of_written_bytes;
>  }

> -printf("%d, %s, %s, %8"PRId64", %8d, 0x%08lx\n", video_stream,
> +printf("%d, %s, %s, %8"PRId64", %8d, 0x%08"PRIx32"\n", 
> video_stream,
> av_ts2str(fr->pts), av_ts2str(fr->pkt_dts), 
> fr->pkt_duration,
> number_of_written_bytes, av_adler32_update(0, (const 
> uint8_t*)byte_buffer, number_of_written_bytes));

Afaict, this change is either related to another patch or wrong.

Carl Eugen
___
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".


[FFmpeg-devel] [PATCH v2 67/90] avutil: Switch crypto APIs to size_t

2021-04-19 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Announced in e435beb1ea5380a90774dbf51fdc8c941e486551.

Signed-off-by: Andreas Rheinhardt 
---
I forgot a printf specifier in tests/api/api-h264-test.c.

 libavutil/adler32.c   |  5 -
 libavutil/adler32.h   |  9 -
 libavutil/hash.c  |  4 
 libavutil/hash.h  |  4 
 libavutil/hmac.c  |  4 
 libavutil/md5.c   | 15 +++
 libavutil/md5.h   |  8 
 libavutil/murmur3.c   |  4 
 libavutil/murmur3.h   |  4 
 libavutil/ripemd.c| 23 ---
 libavutil/ripemd.h|  4 
 libavutil/sha.c   | 23 ---
 libavutil/sha.h   |  4 
 libavutil/sha512.c| 23 ---
 libavutil/sha512.h|  4 
 libavutil/version.h   |  3 ---
 tests/api/api-h264-test.c |  2 +-
 17 files changed, 40 insertions(+), 103 deletions(-)

diff --git a/libavutil/adler32.c b/libavutil/adler32.c
index 5ed5ff55a3..f7d3062265 100644
--- a/libavutil/adler32.c
+++ b/libavutil/adler32.c
@@ -41,12 +41,7 @@
 #define DO4(buf)  DO1(buf); DO1(buf); DO1(buf); DO1(buf);
 #define DO16(buf) DO4(buf); DO4(buf); DO4(buf); DO4(buf);
 
-#if FF_API_CRYPTO_SIZE_T
-unsigned long av_adler32_update(unsigned long adler, const uint8_t * buf,
-unsigned int len)
-#else
 AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf, size_t len)
-#endif
 {
 unsigned long s1 = adler & 0x;
 unsigned long s2 = adler >> 16;
diff --git a/libavutil/adler32.h b/libavutil/adler32.h
index e7a8f83729..232d07f5fe 100644
--- a/libavutil/adler32.h
+++ b/libavutil/adler32.h
@@ -30,7 +30,6 @@
 #include 
 #include 
 #include "attributes.h"
-#include "version.h"
 
 /**
  * @defgroup lavu_adler32 Adler-32
@@ -40,11 +39,7 @@
  * @{
  */
 
-#if FF_API_CRYPTO_SIZE_T
-typedef unsigned long AVAdler;
-#else
 typedef uint32_t AVAdler;
-#endif
 
 /**
  * Calculate the Adler32 checksum of a buffer.
@@ -59,11 +54,7 @@ typedef uint32_t AVAdler;
  * @return  updated checksum
  */
 AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf,
-#if FF_API_CRYPTO_SIZE_T
-  unsigned int len) av_pure;
-#else
   size_t len) av_pure;
-#endif
 
 /**
  * @}
diff --git a/libavutil/hash.c b/libavutil/hash.c
index d626c31181..9a49748189 100644
--- a/libavutil/hash.c
+++ b/libavutil/hash.c
@@ -157,11 +157,7 @@ void av_hash_init(AVHashContext *ctx)
 }
 }
 
-#if FF_API_CRYPTO_SIZE_T
-void av_hash_update(AVHashContext *ctx, const uint8_t *src, int len)
-#else
 void av_hash_update(AVHashContext *ctx, const uint8_t *src, size_t len)
-#endif
 {
 switch (ctx->type) {
 case MD5: av_md5_update(ctx->ctx, src, len); break;
diff --git a/libavutil/hash.h b/libavutil/hash.h
index af4719e423..930d2d6cde 100644
--- a/libavutil/hash.h
+++ b/libavutil/hash.h
@@ -182,11 +182,7 @@ void av_hash_init(struct AVHashContext *ctx);
  * @param[in] src Data to be added to the hash context
  * @param[in] len Size of the additional data
  */
-#if FF_API_CRYPTO_SIZE_T
-void av_hash_update(struct AVHashContext *ctx, const uint8_t *src, int len);
-#else
 void av_hash_update(struct AVHashContext *ctx, const uint8_t *src, size_t len);
-#endif
 
 /**
  * Finalize a hash context and compute the actual hash value.
diff --git a/libavutil/hmac.c b/libavutil/hmac.c
index d064a105f4..e277fd7701 100644
--- a/libavutil/hmac.c
+++ b/libavutil/hmac.c
@@ -34,11 +34,7 @@
 #define MAX_BLOCKLEN 128
 
 typedef void (*hmac_final)(void *ctx, uint8_t *dst);
-#if FF_API_CRYPTO_SIZE_T
-typedef void (*hmac_update)(void *ctx, const uint8_t *src, int len);
-#else
 typedef void (*hmac_update)(void *ctx, const uint8_t *src, size_t len);
-#endif
 typedef void (*hmac_init)(void *ctx);
 
 struct AVHMAC {
diff --git a/libavutil/md5.c b/libavutil/md5.c
index 31e69925ae..88596203c1 100644
--- a/libavutil/md5.c
+++ b/libavutil/md5.c
@@ -98,14 +98,13 @@ static const uint32_t T[64] = { // T[i]= fabs(sin(i+1)<<32)
 a = b + (a << t | a >> (32 - t));   \
 } while (0)
 
-static void body(uint32_t ABCD[4], const uint8_t *src, int nblocks)
+static void body(uint32_t ABCD[4], const uint8_t *src, size_t nblocks)
 {
 int i av_unused;
-int n;
 const uint32_t *X;
 uint32_t a, b, c, d, t;
 
-for (n = 0; n < nblocks; n++) {
+for (size_t n = 0; n < nblocks; n++) {
 a = ABCD[3];
 b = ABCD[2];
 c = ABCD[1];
@@ -150,11 +149,7 @@ void av_md5_init(AVMD5 *ctx)
 ctx->ABCD[3] = 0x67452301;
 }
 
-#if FF_API_CRYPTO_SIZE_T
-void av_md5_update(AVMD5 *ctx, const uint8_t *src, int len)
-#else
 void av_md5_update(AVMD5 *ctx, const uint8_t *src, size_t len)
-#endif
 {
 const uint8_t *end;
 int j;
@@ -180,7 +175,7 @@ void av_md5_update(AVMD5 *ctx, const uint8_t *src, size_t 
len)
src += 64;
 }
 } else {
-int nblocks = len / 64;
+size_t nbl