diff mbox series

[FFmpeg-devel,BUMP,1/2] avcodec: change AVCodecContext.frame_number to int64_t

Message ID 20230126224649.1887-1-cus@passwd.hu
State New
Headers show
Series [FFmpeg-devel,BUMP,1/2] avcodec: change AVCodecContext.frame_number to int64_t | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Marton Balint Jan. 26, 2023, 10:46 p.m. UTC
Frame counters can overflow relatively easily (INT_MAX number of frames is
slightly more than 1 year for 60 fps content), so make sure we use 64 bit
values for them.

Most of the changes are printf() format string updates, which is kind of the
necessary evil of this change, because API users need to do this as well. The
alternative would be to introduce separate 64-bit counters for the int64 type,
and keep the two values in sync, but that would be also quite ugly.

So let's do what we already did for AVFormatContext.bit_rate some years ago and
simply change the type.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 doc/APIchanges              | 4 ++++
 doc/examples/decode_video.c | 4 ++--
 libavcodec/4xm.c            | 2 +-
 libavcodec/atrac3plus.c     | 2 +-
 libavcodec/avcodec.h        | 2 +-
 libavcodec/decode.c         | 2 +-
 libavcodec/evrcdec.c        | 2 +-
 libavcodec/flashsv2enc.c    | 6 +++---
 libavcodec/flashsvenc.c     | 4 ++--
 libavcodec/g2meet.c         | 2 +-
 libavcodec/h261dec.c        | 2 +-
 libavcodec/interplayvideo.c | 2 +-
 libavcodec/mpegutils.c      | 2 +-
 libavcodec/options_table.h  | 2 +-
 libavcodec/qcelpdec.c       | 2 +-
 libavcodec/rv10.c           | 2 +-
 libavcodec/svq3.c           | 4 ++--
 libavcodec/vp3.c            | 2 +-
 libavcodec/wmaprodec.c      | 6 +++---
 tools/scale_slice_test.c    | 2 +-
 tools/venc_data_dump.c      | 2 +-
 21 files changed, 31 insertions(+), 27 deletions(-)

Comments

Anton Khirnov Jan. 27, 2023, 10:07 a.m. UTC | #1
I still think we should do a deprecation+replacement like we do for
everything else.
Marton Balint Jan. 27, 2023, 5:59 p.m. UTC | #2
On Fri, 27 Jan 2023, Anton Khirnov wrote:

> I still think we should do a deprecation+replacement like we do for
> everything else.

You mean you want to introduce a new 64 bit member and deprecate the old 
32 bit field?

E.g.

int64_t frame_num;

attribute_deprcated
int frame_number

And during the transition you want to sync the value between the 64bit and 
the 32bit ?

Thanks,
Marton

>
> -- 
> Anton Khirnov
> _______________________________________________
> 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".
>
Anton Khirnov Jan. 27, 2023, 6:04 p.m. UTC | #3
Quoting Marton Balint (2023-01-27 18:59:39)
> 
> 
> On Fri, 27 Jan 2023, Anton Khirnov wrote:
> 
> > I still think we should do a deprecation+replacement like we do for
> > everything else.
> 
> You mean you want to introduce a new 64 bit member and deprecate the old 
> 32 bit field?
> 
> E.g.
> 
> int64_t frame_num;
> 
> attribute_deprcated
> int frame_number
> 
> And during the transition you want to sync the value between the 64bit and 
> the 32bit ?

yes
James Almer Jan. 27, 2023, 6:16 p.m. UTC | #4
On 1/27/2023 3:04 PM, Anton Khirnov wrote:
> Quoting Marton Balint (2023-01-27 18:59:39)
>>
>>
>> On Fri, 27 Jan 2023, Anton Khirnov wrote:
>>
>>> I still think we should do a deprecation+replacement like we do for
>>> everything else.
>>
>> You mean you want to introduce a new 64 bit member and deprecate the old
>> 32 bit field?
>>
>> E.g.
>>
>> int64_t frame_num;
>>
>> attribute_deprcated
>> int frame_number
>>
>> And during the transition you want to sync the value between the 64bit and
>> the 32bit ?
> 
> yes

We did make changes like int -> size_t without adding new fields in 
places like AVBufferRef. See 14040a1d91.
It does however probably need an FF_API_ dance, much like in that example.
Marton Balint Jan. 27, 2023, 6:41 p.m. UTC | #5
On Fri, 27 Jan 2023, James Almer wrote:

> On 1/27/2023 3:04 PM, Anton Khirnov wrote:
>>  Quoting Marton Balint (2023-01-27 18:59:39)
>>> 
>>>
>>>  On Fri, 27 Jan 2023, Anton Khirnov wrote:
>>>
>>>>  I still think we should do a deprecation+replacement like we do for
>>>>  everything else.
>>>
>>>  You mean you want to introduce a new 64 bit member and deprecate the old
>>>  32 bit field?
>>>
>>>  E.g.
>>>
>>>  int64_t frame_num;
>>>
>>>  attribute_deprcated
>>>  int frame_number
>>>
>>>  And during the transition you want to sync the value between the 64bit
>>>  and
>>>  the 32bit ?
>>
>>  yes
>
> We did make changes like int -> size_t without adding new fields in places 
> like AVBufferRef. See 14040a1d91.

Or AVFormatContext bit_rate sometime before.

> It does however probably need an FF_API_ dance, much like in that example.

If no new field is added, and no old field is deprecated, then if the type 
change is done directly before the bump, then the dance is not needed, 
beacuse you'd just remove the dance at the bump.

Regards,
Marton
Marton Balint Jan. 28, 2023, 6:14 p.m. UTC | #6
On Fri, 27 Jan 2023, Marton Balint wrote:

>
>
> On Fri, 27 Jan 2023, James Almer wrote:
>
>>  On 1/27/2023 3:04 PM, Anton Khirnov wrote:
>>>   Quoting Marton Balint (2023-01-27 18:59:39)
>>>> 
>>>>
>>>>   On Fri, 27 Jan 2023, Anton Khirnov wrote:
>>>>
>>>>>   I still think we should do a deprecation+replacement like we do for
>>>>>   everything else.
>>>>
>>>>   You mean you want to introduce a new 64 bit member and deprecate the
>>>>   old
>>>>   32 bit field?
>>>>
>>>>   E.g.
>>>>
>>>>   int64_t frame_num;
>>>>
>>>>   attribute_deprcated
>>>>   int frame_number
>>>>
>>>>   And during the transition you want to sync the value between the 64bit
>>>>   and
>>>>   the 32bit ?
>>>
>>>   yes
>>
>>  We did make changes like int -> size_t without adding new fields in places
>>  like AVBufferRef. See 14040a1d91.
>
> Or AVFormatContext bit_rate sometime before.
>
>>  It does however probably need an FF_API_ dance, much like in that example.
>
> If no new field is added, and no old field is deprecated, then if the type 
> change is done directly before the bump, then the dance is not needed, 
> beacuse you'd just remove the dance at the bump.

Anyhow, I will send and alternate patch series which is introducing a new 
field for the 64-bit variant. That series is not dependant of the API 
bump, can be applied before or after.

If people prefer that, fine with me.

Regards,
Marton
diff mbox series

Patch

diff --git a/doc/APIchanges b/doc/APIchanges
index a11acadecd..cdd407799a 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,10 @@  libavutil:     2021-04-27
 
 API changes, most recent first:
 
+2023-xx-xx - xxxxxxxxxx - lavc 60.0.100 - avcodec.h
+  AVCodecContext.frame_number was changed to 64bit, make sure you update any
+  printf() or other type sensitive code
+
 2023-01-13 - xxxxxxxxxx - lavu 57.44.100 - ambient_viewing_environment.h frame.h
   Adds a new structure for holding H.274 Ambient Viewing Environment metadata,
   AVAmbientViewingEnvironment.
diff --git a/doc/examples/decode_video.c b/doc/examples/decode_video.c
index 7238e38103..37199352dd 100644
--- a/doc/examples/decode_video.c
+++ b/doc/examples/decode_video.c
@@ -69,12 +69,12 @@  static void decode(AVCodecContext *dec_ctx, AVFrame *frame, AVPacket *pkt,
             exit(1);
         }
 
-        printf("saving frame %3d\n", dec_ctx->frame_number);
+        printf("saving frame %3"PRId64"\n", dec_ctx->frame_number);
         fflush(stdout);
 
         /* the picture is allocated by the decoder. no need to
            free it */
-        snprintf(buf, sizeof(buf), "%s-%d", filename, dec_ctx->frame_number);
+        snprintf(buf, sizeof(buf), "%s-%"PRId64, filename, dec_ctx->frame_number);
         pgm_save(frame->data[0], frame->linesize[0],
                  frame->width, frame->height, buf);
     }
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index 5636fdef2d..3027ce9e20 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -911,7 +911,7 @@  static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
             frame_size = cfrm->size;
 
             if (id != avctx->frame_number)
-                av_log(f->avctx, AV_LOG_ERROR, "cframe id mismatch %d %d\n",
+                av_log(f->avctx, AV_LOG_ERROR, "cframe id mismatch %d %"PRId64"\n",
                        id, avctx->frame_number);
 
             if (f->version <= 1)
diff --git a/libavcodec/atrac3plus.c b/libavcodec/atrac3plus.c
index a0836f1178..0fcf3a386e 100644
--- a/libavcodec/atrac3plus.c
+++ b/libavcodec/atrac3plus.c
@@ -1391,7 +1391,7 @@  static int decode_band_numwavs(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
         if (band_has_tones[sb]) {
             if (ctx->waves_info->tones_index + dst[sb].num_wavs > 48) {
                 av_log(avctx, AV_LOG_ERROR,
-                       "Too many tones: %d (max. 48), frame: %d!\n",
+                       "Too many tones: %d (max. 48), frame: %"PRId64"!\n",
                        ctx->waves_info->tones_index + dst[sb].num_wavs,
                        avctx->frame_number);
                 return AVERROR_INVALIDDATA;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 0ac581d660..6236c7936a 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1043,7 +1043,7 @@  typedef struct AVCodecContext {
      *   @note the counter is not incremented if encoding/decoding resulted in
      *   an error.
      */
-    int frame_number;
+    int64_t frame_number;
 
     /**
      * number of bytes per packet if constant and known or 0
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 0abc88737b..7af8770a32 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -758,7 +758,7 @@  int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame)
 
             if (changed) {
                 avci->changed_frames_dropped++;
-                av_log(avctx, AV_LOG_INFO, "dropped changed frame #%d pts %"PRId64
+                av_log(avctx, AV_LOG_INFO, "dropped changed frame #%"PRId64" pts %"PRId64
                                             " drop count: %d \n",
                                             avctx->frame_number, frame->pts,
                                             avci->changed_frames_dropped);
diff --git a/libavcodec/evrcdec.c b/libavcodec/evrcdec.c
index c4b0ad2957..393cfe59a6 100644
--- a/libavcodec/evrcdec.c
+++ b/libavcodec/evrcdec.c
@@ -221,7 +221,7 @@  static evrc_packet_rate determine_bitrate(AVCodecContext *avctx,
 static void warn_insufficient_frame_quality(AVCodecContext *avctx,
                                             const char *message)
 {
-    av_log(avctx, AV_LOG_WARNING, "Frame #%d, %s\n",
+    av_log(avctx, AV_LOG_WARNING, "Frame #%"PRId64", %s\n",
            avctx->frame_number, message);
 }
 
diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c
index 668ca6a85f..0aa24efd68 100644
--- a/libavcodec/flashsv2enc.c
+++ b/libavcodec/flashsv2enc.c
@@ -105,7 +105,7 @@  typedef struct FlashSV2Context {
 
     int rows, cols;
 
-    int last_key_frame;
+    int64_t last_key_frame;
 
     int image_width, image_height;
     int block_width, block_height;
@@ -874,7 +874,7 @@  static int flashsv2_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         && avctx->frame_number > s->last_key_frame + avctx->keyint_min) {
         recommend_keyframe(s, &keyframe);
         if (keyframe)
-            av_log(avctx, AV_LOG_DEBUG, "Recommending key frame at frame %d\n", avctx->frame_number);
+            av_log(avctx, AV_LOG_DEBUG, "Recommending key frame at frame %"PRId64"\n", avctx->frame_number);
     }
 
     if (keyframe) {
@@ -892,7 +892,7 @@  static int flashsv2_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         new_key_frame(s);
         s->last_key_frame = avctx->frame_number;
         pkt->flags |= AV_PKT_FLAG_KEY;
-        av_log(avctx, AV_LOG_DEBUG, "Inserting key frame at frame %d\n", avctx->frame_number);
+        av_log(avctx, AV_LOG_DEBUG, "Inserting key frame at frame %"PRId64"\n", avctx->frame_number);
     }
 
     pkt->size = res;
diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c
index 3a35876d9c..b7cad8c970 100644
--- a/libavcodec/flashsvenc.c
+++ b/libavcodec/flashsvenc.c
@@ -65,7 +65,7 @@  typedef struct FlashSVContext {
     AVBufferRef    *prev_frame_buf;
     int             image_width, image_height;
     unsigned        packet_size;
-    int             last_key_frame;
+    int64_t         last_key_frame;
     uint8_t         tmpblock[3 * 256 * 256];
 } FlashSVContext;
 
@@ -230,7 +230,7 @@  static int flashsv_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     //mark the frame type so the muxer can mux it correctly
     if (I_frame) {
         s->last_key_frame = avctx->frame_number;
-        ff_dlog(avctx, "Inserting keyframe at frame %d\n", avctx->frame_number);
+        ff_dlog(avctx, "Inserting keyframe at frame %"PRId64"\n", avctx->frame_number);
     }
 
     if (I_frame)
diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
index 761fd22fc3..5b4c0a1f81 100644
--- a/libavcodec/g2meet.c
+++ b/libavcodec/g2meet.c
@@ -931,7 +931,7 @@  static int epic_jb_decode_tile(G2MContext *c, int tile_x, int tile_y,
 
         if (ret) {
             av_log(avctx, AV_LOG_ERROR,
-                   "ePIC: tile decoding failed, frame=%d, tile_x=%d, tile_y=%d\n",
+                   "ePIC: tile decoding failed, frame=%"PRId64", tile_x=%d, tile_y=%d\n",
                    avctx->frame_number, tile_x, tile_y);
             return AVERROR_INVALIDDATA;
         }
diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 57f7e8bf35..a35bf7426e 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -610,7 +610,7 @@  static int h261_decode_frame(AVCodecContext *avctx, AVFrame *pict,
     MpegEncContext *s  = &h->s;
     int ret;
 
-    ff_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
+    ff_dlog(avctx, "*****frame %"PRId64" size=%d\n", avctx->frame_number, buf_size);
     ff_dlog(avctx, "bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]);
 
     h->gob_start_code_skipped = 0;
diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c
index 655326a7f1..136b0635db 100644
--- a/libavcodec/interplayvideo.c
+++ b/libavcodec/interplayvideo.c
@@ -1144,7 +1144,7 @@  static void ipvideo_decode_format_11_opcodes(IpvideoContext *s, AVFrame *frame)
                 ret = ipvideo_decode_block16[opcode](s, frame);
             }
             if (ret != 0) {
-                av_log(s->avctx, AV_LOG_ERROR, "decode problem on frame %d, @ block (%d, %d)\n",
+                av_log(s->avctx, AV_LOG_ERROR, "decode problem on frame %"PRId64", @ block (%d, %d)\n",
                        s->avctx->frame_number, x, y);
                 return;
             }
diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
index 36d75b9633..814bd7817e 100644
--- a/libavcodec/mpegutils.c
+++ b/libavcodec/mpegutils.c
@@ -230,7 +230,7 @@  void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict,
         if (mbcount) {
             AVFrameSideData *sd;
 
-            av_log(avctx, AV_LOG_DEBUG, "Adding %d MVs info to frame %d\n", mbcount, avctx->frame_number);
+            av_log(avctx, AV_LOG_DEBUG, "Adding %d MVs info to frame %"PRId64"\n", mbcount, avctx->frame_number);
             sd = av_frame_new_side_data(pict, AV_FRAME_DATA_MOTION_VECTORS, mbcount * sizeof(AVMotionVector));
             if (!sd) {
                 av_freep(&mvs);
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 7924ca6144..d2aebbe9e4 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -98,7 +98,7 @@  static const AVOption avcodec_options[] = {
 #endif
 {"cutoff", "set cutoff bandwidth", OFFSET(cutoff), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|E},
 {"frame_size", NULL, OFFSET(frame_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|E},
-{"frame_number", NULL, OFFSET(frame_number), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
+{"frame_number", NULL, OFFSET(frame_number), AV_OPT_TYPE_INT64, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
 {"delay", NULL, OFFSET(delay), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
 {"qcomp", "video quantizer scale compression (VBR). Constant of ratecontrol equation. "
           "Recommended range for default rc_eq: 0.0-1.0",
diff --git a/libavcodec/qcelpdec.c b/libavcodec/qcelpdec.c
index 277c55100a..6c79c2d804 100644
--- a/libavcodec/qcelpdec.c
+++ b/libavcodec/qcelpdec.c
@@ -646,7 +646,7 @@  static qcelp_packet_rate determine_bitrate(AVCodecContext *avctx,
 static void warn_insufficient_frame_quality(AVCodecContext *avctx,
                                             const char *message)
 {
-    av_log(avctx, AV_LOG_WARNING, "Frame #%d, IFQ: %s\n",
+    av_log(avctx, AV_LOG_WARNING, "Frame #%"PRId64", IFQ: %s\n",
            avctx->frame_number, message);
 }
 
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index a45683228e..1980522c07 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -603,7 +603,7 @@  static int rv10_decode_frame(AVCodecContext *avctx, AVFrame *pict,
     int slice_count;
     const uint8_t *slices_hdr = NULL;
 
-    ff_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
+    ff_dlog(avctx, "*****frame %"PRId64" size=%d\n", avctx->frame_number, buf_size);
 
     /* no supplementary picture */
     if (buf_size == 0) {
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index b96c4f61f6..d9ce5091c2 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -1542,12 +1542,12 @@  static int svq3_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
     left = buf_size*8 - get_bits_count(&s->gb_slice);
 
     if (s->mb_y != s->mb_height || s->mb_x != s->mb_width) {
-        av_log(avctx, AV_LOG_INFO, "frame num %d incomplete pic x %d y %d left %d\n", avctx->frame_number, s->mb_y, s->mb_x, left);
+        av_log(avctx, AV_LOG_INFO, "frame num %"PRId64" incomplete pic x %d y %d left %d\n", avctx->frame_number, s->mb_y, s->mb_x, left);
         //av_hex_dump(stderr, buf+buf_size-8, 8);
     }
 
     if (left < 0) {
-        av_log(avctx, AV_LOG_ERROR, "frame num %d left %d\n", avctx->frame_number, left);
+        av_log(avctx, AV_LOG_ERROR, "frame num %"PRId64" left %d\n", avctx->frame_number, left);
         return -1;
     }
 
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index b731bc0669..8b879156ff 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -2654,7 +2654,7 @@  static int vp3_decode_frame(AVCodecContext *avctx, AVFrame *frame,
         s->qps[i] = -1;
 
     if (s->avctx->debug & FF_DEBUG_PICT_INFO)
-        av_log(s->avctx, AV_LOG_INFO, " VP3 %sframe #%d: Q index = %d\n",
+        av_log(s->avctx, AV_LOG_INFO, " VP3 %sframe #%"PRId64": Q index = %d\n",
                s->keyframe ? "key" : "", avctx->frame_number + 1, s->qps[0]);
 
     s->skip_loop_filter = !s->filter_limit_values[s->qps[0]] ||
diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index fbfe75ee33..0fcc099a3c 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -1678,7 +1678,7 @@  static int decode_packet(AVCodecContext *avctx, WMAProDecodeCtx *s,
             skip_bits(gb, 2);
         } else {
             int num_frames = get_bits(gb, 6);
-            ff_dlog(avctx, "packet[%d]: number of frames %d\n", avctx->frame_number, num_frames);
+            ff_dlog(avctx, "packet[%"PRId64"]: number of frames %d\n", avctx->frame_number, num_frames);
             packet_sequence_number = 0;
         }
 
@@ -1687,10 +1687,10 @@  static int decode_packet(AVCodecContext *avctx, WMAProDecodeCtx *s,
         if (avctx->codec_id != AV_CODEC_ID_WMAPRO) {
             skip_bits(gb, 3);
             s->skip_packets = get_bits(gb, 8);
-            ff_dlog(avctx, "packet[%d]: skip packets %d\n", avctx->frame_number, s->skip_packets);
+            ff_dlog(avctx, "packet[%"PRId64"]: skip packets %d\n", avctx->frame_number, s->skip_packets);
         }
 
-        ff_dlog(avctx, "packet[%d]: nbpf %x\n", avctx->frame_number,
+        ff_dlog(avctx, "packet[%"PRId64"]: nbpf %x\n", avctx->frame_number,
                 num_bits_prev_frame);
 
         /** check for packet loss */
diff --git a/tools/scale_slice_test.c b/tools/scale_slice_test.c
index d869eaae74..93cb6db7d1 100644
--- a/tools/scale_slice_test.c
+++ b/tools/scale_slice_test.c
@@ -100,7 +100,7 @@  static int process_frame(DecodeContext *dc, AVFrame *frame)
 
         if (memcmp(pd->frame_ref->data[i], pd->frame_dst->data[i],
                    pd->frame_ref->linesize[i] * (pd->frame_ref->height >> shift))) {
-            fprintf(stderr, "mismatch frame %d seed %u\n",
+            fprintf(stderr, "mismatch frame %"PRId64" seed %u\n",
                     dc->decoder->frame_number - 1, pd->random_seed);
             return AVERROR(EINVAL);
         }
diff --git a/tools/venc_data_dump.c b/tools/venc_data_dump.c
index 3a3543f80f..8e91aaa402 100644
--- a/tools/venc_data_dump.c
+++ b/tools/venc_data_dump.c
@@ -38,7 +38,7 @@  static int process_frame(DecodeContext *dc, AVFrame *frame)
     if (!frame)
         return 0;
 
-    fprintf(stdout, "frame %d\n", dc->decoder->frame_number - 1);
+    fprintf(stdout, "frame %"PRId64"\n", dc->decoder->frame_number - 1);
 
     sd = av_frame_get_side_data(frame, AV_FRAME_DATA_VIDEO_ENC_PARAMS);
     if (sd) {