From patchwork Thu Jan 26 22:46:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 40130 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp882735pzj; Thu, 26 Jan 2023 14:47:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXuifxgQT3H20kMLjW5tVKwnrXb//l6+CKg45KvacvN+Dk4Cy8WThrnnlbV46ehPyMjMdsJW X-Received: by 2002:a05:6402:1ccc:b0:49c:fdd2:a47d with SMTP id ds12-20020a0564021ccc00b0049cfdd2a47dmr48397495edb.37.1674773230479; Thu, 26 Jan 2023 14:47:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674773230; cv=none; d=google.com; s=arc-20160816; b=LpfIkNE3Gh16rFyMLPBqrGQoo9jlDCwlQb8Cv+qSbE/9CzWS9lyR+7v6LoZkMKMKbw 4thc3Ug0P4ulYoLW2fkkF7XeC7qrfd26VCRKIx3PQMdgciF3E04oHgMZOgmvJTFaeLYA nW4QTPyyrpDuonDKFKEoWnTGEnxpoLzmgdA0L5WVK/CBr2zERG608yAX29RG6bbGcFbB gHZcZhAJxXFEMafeUQPVfh7v8ee6nqGBa8dZzOf+BBOPrsai78O6y0Gfn1lJplQInL0v rfDnV7YS1PtyE2IDA7rMxQUXGKouwotqPq8cQnFxiwO0kTVko6pKBKlxFLM4BCuQdNZU hNkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=XbGVmvB4Qq4HdKRizHVSgKz5ADRDGNYiq0ELhGIGc1g=; b=Na6SjYI5bru/BME7yAiGSNRtAsY3E2HQgqMdQPWJKT8WTdeX10ui3UTh3DF8H4JTxt 2sC5Ed8gwk+FLSvg6Bpxb7HIpggVhJj+PVJ9gQaMAVo9/+/beTY5yNRDianU1Wmb0pHM 7Vf+TmaMcqUcZagyyEYfekf/mbTExJetgACTV7TAbQpm6q9WCLVEi9SQ0R8O1jcr4yah A5I6BSFHDW7t0sPxF8YOsyhi9GpPgQkGlyavNUDHik6/bUdXfMuJ1rHfFGP6cQBay49b Ix5KFIe6LWiuUxL0mfdZTIn4XFkk4nnBHqz543PaboIcaH8tb+DXsAIDIxLDkjBu1CJt W3Hg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s13-20020a056402520d00b004917c8c661csi198388edd.243.2023.01.26.14.47.09; Thu, 26 Jan 2023 14:47:10 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F2C3568BD51; Fri, 27 Jan 2023 00:47:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B7CFA68BB04 for ; Fri, 27 Jan 2023 00:46:59 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 53226E857B; Thu, 26 Jan 2023 23:46:58 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id V2vyeCMLT66P; Thu, 26 Jan 2023 23:46:55 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 03F81E856D; Thu, 26 Jan 2023 23:46:54 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 26 Jan 2023 23:46:48 +0100 Message-Id: <20230126224649.1887-1-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Subject: [FFmpeg-devel] [BUMP PATCH 1/2] avcodec: change AVCodecContext.frame_number to int64_t X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: cVCTN7+ZHHr9 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 --- 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(-) 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) { From patchwork Thu Jan 26 22:46:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 40131 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp883006pzj; Thu, 26 Jan 2023 14:47:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXvGNyC3EYtMx4MZyYjQ6zD7jc65mAgWeEOzkhgK539BCqhoFocPJadOlzSbHg6Ma8gMPSpG X-Received: by 2002:aa7:d559:0:b0:492:bf3d:1a16 with SMTP id u25-20020aa7d559000000b00492bf3d1a16mr37481517edr.4.1674773268688; Thu, 26 Jan 2023 14:47:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674773268; cv=none; d=google.com; s=arc-20160816; b=Bl9c4uyZJj4fCy18yumlyVEreVojELBF+QV+spNYnr2XpE3TNzp1Nchyp2SpRxV8lu CMCNyzShfFDQbrn3nEZt3heMFphJwgegwmXap9zCQSbFnJdJMKfmj/ZtQ1HiGE3oicHm op5CeoyM62IKz23ua23gYE7vSOPvXTHDgVohEW2DlZRCXhwmxQrQjXml6kMw+1xbScrD LRRgtyEUJIRhZZwKRBVIAWRVRiXveX0+qnp2E+X82zdUQfRkCyYvkfcL5qchaGDxFIST eeuniqxkcfKDdTuZ8E4F0jI4iqJhp61ofqdZ/l9AYVILJt2FQ4XUm7MKSPRallkFHZGn SUZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=2N9v6JMHMWMX92WUTUFqOltHp1TARfLxbou5VgNZMEk=; b=s8wjt9Somyd+SF+HkobjS+vsmd1juV2+UdkuOxf8Xm/Qwe57ArACJbQJj34MPtQmTt LhXHKixoPaiH7hEEaLoQp13ItFKd/tgmTSmW9nOGBDdFb2HzuP2p0a+MtL3P7dc6DrHx QhNhdW16kypr+J2TUAif0mWkoUMxKhCDzqW9btT9ut4n7arhGdGkn5g/QB3vkhIBe/Ll U40yTPmLEe2uFimb6ZhepmAOLksWp25j2sC4C9kgNme2i2JxOE6v5v0+0WDrJf40F7Z0 8b7Oaoj6OqkbGC9Hp7dFOGzzo14uXt61jBF/kh4QmmjrgCDXZazB3RnIO3QHodiWKWIv ev1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y12-20020a056402270c00b00493969bd008si3906188edd.121.2023.01.26.14.47.48; Thu, 26 Jan 2023 14:47:48 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F0AD268BD67; Fri, 27 Jan 2023 00:47:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3F5A668A2BD for ; Fri, 27 Jan 2023 00:47:39 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id DCD3CE857B; Thu, 26 Jan 2023 23:47:37 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lVBJNIMdKvRv; Thu, 26 Jan 2023 23:47:35 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 71349E856D; Thu, 26 Jan 2023 23:47:35 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 26 Jan 2023 23:46:49 +0100 Message-Id: <20230126224649.1887-2-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230126224649.1887-1-cus@passwd.hu> References: <20230126224649.1887-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [BUMP PATCH 2/2] avutil/frame: change AVFrame.*_picture_number to int64_t X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: W9xKrymlVUOF 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. We also change MpegEncContext picture number members to 64 bit in this change, because mpeg(ish) decoding/encoding usually use and set AVFrame attributes based on the MpegEncContext picture number members, so it makes sense to use the same type. Same is true for H264Context.coded_picture_number. There are also a couple of printf() format string updates, which is 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 --- doc/APIchanges | 4 ++++ doc/examples/demuxing_decoding.c | 2 +- libavcodec/flvdec.c | 2 +- libavcodec/h264dec.h | 2 +- libavcodec/mpeg12enc.c | 2 +- libavcodec/mpegvideo.h | 6 +++--- libavcodec/mpegvideo_enc.c | 6 +++--- libavcodec/ratecontrol.c | 6 +++--- libavutil/frame.h | 4 ++-- 9 files changed, 19 insertions(+), 15 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index cdd407799a..b8dd6fc6ec 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,10 @@ libavutil: 2021-04-27 API changes, most recent first: +2023-xx-xx - xxxxxxxxxx - lavu 58.0.100 - frame.h + AVFrame.coded_picture_number and AVFrame.display_picture_number was changed + to 64bit, make sure you update any printf() or other type sensitive code + 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 diff --git a/doc/examples/demuxing_decoding.c b/doc/examples/demuxing_decoding.c index 999a78db0d..b16436b55b 100644 --- a/doc/examples/demuxing_decoding.c +++ b/doc/examples/demuxing_decoding.c @@ -73,7 +73,7 @@ static int output_video_frame(AVFrame *frame) return -1; } - printf("video_frame n:%d coded_n:%d\n", + printf("video_frame n:%d coded_n:%"PRId64"\n", video_frame_count++, frame->coded_picture_number); /* copy decoded frame to destination buffer: diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c index 09fefd3d1c..19fb23563d 100644 --- a/libavcodec/flvdec.c +++ b/libavcodec/flvdec.c @@ -103,7 +103,7 @@ int ff_flv_decode_picture_header(MpegEncContext *s) s->avctx->sample_aspect_ratio= (AVRational){1,2}; if (s->avctx->debug & FF_DEBUG_PICT_INFO) { - av_log(s->avctx, AV_LOG_DEBUG, "%c esc_type:%d, qp:%d num:%d\n", + av_log(s->avctx, AV_LOG_DEBUG, "%c esc_type:%d, qp:%d num:%"PRId64"\n", s->droppable ? 'D' : av_get_picture_type_char(s->pict_type), s->h263_flv - 1, s->qscale, s->picture_number); } diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h index 9a1ec1bace..dd3f06a03b 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -354,7 +354,7 @@ typedef struct H264Context { int chroma_x_shift, chroma_y_shift; int droppable; - int coded_picture_number; + int64_t coded_picture_number; int context_initialized; int flags; diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index a6663a158b..690c401432 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -76,7 +76,7 @@ typedef struct MPEG12EncContext { AVRational frame_rate_ext; unsigned frame_rate_index; - int gop_picture_number; ///< index of the first picture of a GOP based on fake_pic_num + int64_t gop_picture_number; ///< index of the first picture of a GOP based on fake_pic_num int64_t timecode_frame_start; ///< GOP timecode frame start number, in non drop frame format AVTimecode tc; ///< timecode context diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 42275953b9..3e932d3ab5 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -114,9 +114,9 @@ typedef struct MpegEncContext { /* sequence parameters */ int context_initialized; - int input_picture_number; ///< used to set pic->display_picture_number, should not be used for/by anything else - int coded_picture_number; ///< used to set pic->coded_picture_number, should not be used for/by anything else - int picture_number; //FIXME remove, unclear definition + int64_t input_picture_number; ///< used to set pic->display_picture_number, should not be used for/by anything else + int64_t coded_picture_number; ///< used to set pic->coded_picture_number, should not be used for/by anything else + int64_t picture_number; //FIXME remove, unclear definition int extradata_parsed; int picture_in_gop_number; ///< 0-> first pic in gop, ... int mb_width, mb_height; ///< number of MBs horizontally & vertically diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index bb101612e5..d2becc7003 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1095,8 +1095,8 @@ static int alloc_picture(MpegEncContext *s, Picture *pic, int shared) static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg) { Picture *pic = NULL; - int64_t pts; - int i, display_picture_number = 0, ret; + int64_t pts, display_picture_number = 0; + int i, ret; int encoding_delay = s->max_b_frames ? s->max_b_frames : (s->low_delay ? 0 : 1); int flush_offset = 1; @@ -1484,7 +1484,7 @@ static int select_input_picture(MpegEncContext *s) if (s->avctx->flags & AV_CODEC_FLAG_PASS2) { for (i = 0; i < s->max_b_frames + 1; i++) { - int pict_num = s->input_picture[0]->f->display_picture_number + i; + int64_t pict_num = s->input_picture[0]->f->display_picture_number + i; if (pict_num >= s->rc_context.num_entries) break; diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index 4829172c2c..299d82223c 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -37,7 +37,7 @@ void ff_write_pass1_stats(MpegEncContext *s) { snprintf(s->avctx->stats_out, 256, - "in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d " + "in:%"PRId64" out:%"PRId64" type:%d q:%d itex:%d ptex:%d mv:%d misc:%d " "fcode:%d bcode:%d mc-var:%"PRId64" var:%"PRId64" icount:%d skipcount:%d hbits:%d;\n", s->current_picture_ptr->f->display_picture_number, s->current_picture_ptr->f->coded_picture_number, @@ -571,7 +571,7 @@ av_cold int ff_rate_control_init(MpegEncContext *s) p = s->avctx->stats_in; for (i = 0; i < rcc->num_entries - s->max_b_frames; i++) { RateControlEntry *rce; - int picture_number; + int64_t picture_number; int e; char *next; @@ -580,7 +580,7 @@ av_cold int ff_rate_control_init(MpegEncContext *s) (*next) = 0; // sscanf is unbelievably slow on looong strings // FIXME copy / do not write next++; } - e = sscanf(p, " in:%d ", &picture_number); + e = sscanf(p, " in:%"PRId64" ", &picture_number); av_assert0(picture_number >= 0); av_assert0(picture_number < rcc->num_entries); diff --git a/libavutil/frame.h b/libavutil/frame.h index bbe909ee2d..da06a2f868 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -454,11 +454,11 @@ typedef struct AVFrame { /** * picture number in bitstream order */ - int coded_picture_number; + int64_t coded_picture_number; /** * picture number in display order */ - int display_picture_number; + int64_t display_picture_number; /** * quality (between 1 (good) and FF_LAMBDA_MAX (bad))