@@ -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.
@@ -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);
}
@@ -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)
@@ -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;
@@ -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
@@ -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);
@@ -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);
}
@@ -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;
@@ -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)
@@ -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;
}
@@ -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;
@@ -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;
}
@@ -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);
@@ -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",
@@ -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);
}
@@ -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) {
@@ -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;
}
@@ -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]] ||
@@ -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 */
@@ -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);
}
@@ -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) {
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(-)