[FFmpeg-devel] [PATCH] avformat/utils: added av_get_frame_filename3() (changed parameter int -> int64_t)

Michael Niedermayer michael at niedermayer.cc
Thu Sep 19 18:46:00 EEST 2024


On Mon, Sep 16, 2024 at 10:32:00PM +0100, Filip Mašić wrote:
> fix for ticket 11194 (frame_pts codepath requires a larger integer capacity for normal workloads)
> 
> Signed-off-by: Filip Mašić <shoutplenty at gmail.com>
> ---
>  libavformat/avformat.h |  5 ++++-
>  libavformat/img2enc.c  |  6 ++----
>  libavformat/utils.c    | 12 +++++++++---
>  3 files changed, 15 insertions(+), 8 deletions(-)

Missing doc/APIchanges update

[...]

> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index e9ded627ad..36017805a0 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -19,6 +19,7 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>   */
>  
> +#include <inttypes.h>
>  #include <stdint.h>
>  
>  #include "config.h"
> @@ -280,7 +281,7 @@ uint64_t ff_parse_ntp_time(uint64_t ntp_ts)
>      return (sec * 1000000) + usec;
>  }
>  
> -int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags)
> +int av_get_frame_filename3(char *buf, int buf_size, const char *path, int64_t number, int flags)
>  {
>      const char *p;
>      char *q, buf1[20], c;
> @@ -313,7 +314,7 @@ int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number
>                  percentd_found = 1;
>                  if (number < 0)
>                      nd += 1;
> -                snprintf(buf1, sizeof(buf1), "%0*d", nd, number);
> +                snprintf(buf1, sizeof(buf1), "%0*"PRId64, nd, number);
>                  len = strlen(buf1);
>                  if ((q - buf + len) > buf_size - 1)
>                      goto fail;
> @@ -338,9 +339,14 @@ fail:
>      return -1;
>  }
>  
> +int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags)
> +{
> +    return av_get_frame_filename3(buf, buf_size, path, (int64_t)number, flags);
> +}
> +
>  int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
>  {
> -    return av_get_frame_filename2(buf, buf_size, path, number, 0);
> +    return av_get_frame_filename3(buf, buf_size, path, (int64_t)number, 0);
>  }

Teh cast is unneeded

thx

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

It is what and why we do it that matters, not just one of them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20240919/14087dca/attachment.sig>


More information about the ffmpeg-devel mailing list