avcodec: add AVCodecContext.frame_num as 64 bit variant to frame_number

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.

Also deprecate the old 32 bit frame_number attribute.

Signed-off-by: Marton Balint <cus@passwd.hu>
release/6.0
Marton Balint 2 years ago
parent e506ea3ce1
commit 6b6f7db819
  1. 4
      doc/APIchanges
  2. 4
      doc/examples/decode_video.c
  3. 2
      fftools/ffmpeg.c
  4. 8
      libavcodec/4xm.c
  5. 2
      libavcodec/8svx.c
  6. 4
      libavcodec/aacenc.c
  7. 2
      libavcodec/ansi.c
  8. 4
      libavcodec/atrac3plus.c
  9. 7
      libavcodec/avcodec.c
  10. 15
      libavcodec/avcodec.h
  11. 2
      libavcodec/bfi.c
  12. 2
      libavcodec/cdgraphics.c
  13. 2
      libavcodec/cljrenc.c
  14. 22
      libavcodec/decode.c
  15. 2
      libavcodec/dvenc.c
  16. 2
      libavcodec/eac3enc.c
  17. 14
      libavcodec/encode.c
  18. 4
      libavcodec/evrcdec.c
  19. 16
      libavcodec/flashsv2enc.c
  20. 8
      libavcodec/flashsvenc.c
  21. 4
      libavcodec/g2meet.c
  22. 4
      libavcodec/gif.c
  23. 2
      libavcodec/h261dec.c
  24. 2
      libavcodec/h264_slice.c
  25. 8
      libavcodec/interplayvideo.c
  26. 2
      libavcodec/ituh263dec.c
  27. 2
      libavcodec/libwebpenc_animencoder.c
  28. 2
      libavcodec/mjpegdec.c
  29. 6
      libavcodec/mlpenc.c
  30. 2
      libavcodec/mpegutils.c
  31. 2
      libavcodec/nuv.c
  32. 2
      libavcodec/options_table.h
  33. 2
      libavcodec/opusenc.c
  34. 8
      libavcodec/pngenc.c
  35. 5
      libavcodec/pthread_frame.c
  36. 4
      libavcodec/qcelpdec.c
  37. 2
      libavcodec/qtrleenc.c
  38. 2
      libavcodec/rv10.c
  39. 2
      libavcodec/smcenc.c
  40. 12
      libavcodec/snowenc.c
  41. 6
      libavcodec/svq1enc.c
  42. 4
      libavcodec/svq3.c
  43. 2
      libavcodec/version.h
  44. 1
      libavcodec/version_major.h
  45. 6
      libavcodec/vp3.c
  46. 2
      libavcodec/wcmv.c
  47. 6
      libavcodec/wmaprodec.c
  48. 2
      libavcodec/yop.c
  49. 6
      tools/decode_simple.c
  50. 4
      tools/scale_slice_test.c
  51. 2
      tools/venc_data_dump.c

@ -2,6 +2,10 @@ The last version increases of all libraries were on 2023-02-09
API changes, most recent first:
2023-02-13 - xxxxxxxxxx - lavc 60.2.100 - avcodec.h
Add AVCodecContext.frame_num as a 64bit version of frame_number.
Deprecate AVCodecContext.frame_number.
2023-02-12 - xxxxxxxxxx - lavfi 9.1.100 - avfilter.h
Add filtergraph segment parsing API.
New structs:

@ -70,12 +70,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_num);
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_num);
pgm_save(frame->data[0], frame->linesize[0],
frame->width, frame->height, buf);
}

@ -2115,7 +2115,7 @@ static int decode(InputStream *ist, AVCodecContext *avctx,
fd = (FrameData*)frame->opaque_ref->data;
fd->pts = frame->pts;
fd->tb = avctx->pkt_timebase;
fd->idx = avctx->frame_number - 1;
fd->idx = avctx->frame_num - 1;
}
*got_frame = 1;

@ -875,7 +875,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
}
for (i = 0; i < CFRAME_BUFFER_COUNT; i++)
if (f->cfrm[i].id && f->cfrm[i].id < avctx->frame_number)
if (f->cfrm[i].id && f->cfrm[i].id < avctx->frame_num)
av_log(f->avctx, AV_LOG_ERROR, "lost c frame %d\n",
f->cfrm[i].id);
@ -910,9 +910,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
buf = cfrm->data;
frame_size = cfrm->size;
if (id != avctx->frame_number)
av_log(f->avctx, AV_LOG_ERROR, "cframe id mismatch %d %d\n",
id, avctx->frame_number);
if (id != avctx->frame_num)
av_log(f->avctx, AV_LOG_ERROR, "cframe id mismatch %d %"PRId64"\n",
id, avctx->frame_num);
if (f->version <= 1)
return AVERROR_INVALIDDATA;

@ -151,7 +151,7 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, AVFrame *frame,
*got_frame_ptr = 1;
return ((avctx->frame_number == 0) * hdr_size + buf_size) * channels;
return ((avctx->frame_num == 0) * hdr_size + buf_size) * channels;
}
static av_cold int eightsvx_decode_init(AVCodecContext *avctx)

@ -854,7 +854,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
if (s->psypp)
ff_psy_preprocess(s->psypp, s->planar_samples, s->channels);
if (!avctx->frame_number)
if (!avctx->frame_num)
return 0;
start_ch = 0;
@ -958,7 +958,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
do {
init_put_bits(&s->pb, avpkt->data, avpkt->size);
if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & AV_CODEC_FLAG_BITEXACT))
if ((avctx->frame_num & 0xFF)==1 && !(avctx->flags & AV_CODEC_FLAG_BITEXACT))
put_bitstream_info(s, LIBAVCODEC_IDENT);
start_ch = 0;
target_bits = 0;

@ -364,7 +364,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0)
return ret;
if (!avctx->frame_number) {
if (!avctx->frame_num) {
for (i=0; i<avctx->height; i++)
memset(s->frame->data[0]+ i*s->frame->linesize[0], 0, avctx->width);
memset(s->frame->data[1], 0, AVPALETTE_SIZE);

@ -1391,9 +1391,9 @@ 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);
avctx->frame_num);
return AVERROR_INVALIDDATA;
}
dst[sb].start_index = ctx->waves_info->tones_index;

@ -266,7 +266,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
goto free_and_end;
}
avctx->frame_number = 0;
avctx->frame_num = 0;
#if FF_API_AVCTX_FRAME_NUMBER
FF_DISABLE_DEPRECATION_WARNINGS
avctx->frame_number = avctx->frame_num;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
avctx->codec_descriptor = avcodec_descriptor_get(avctx->codec_id);
if ((avctx->codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) &&

@ -1061,6 +1061,7 @@ typedef struct AVCodecContext {
*/
int frame_size;
#if FF_API_AVCTX_FRAME_NUMBER
/**
* Frame counter, set by libavcodec.
*
@ -1069,8 +1070,11 @@ typedef struct AVCodecContext {
*
* @note the counter is not incremented if encoding/decoding resulted in
* an error.
* @deprecated use frame_num instead
*/
attribute_deprecated
int frame_number;
#endif
/**
* number of bytes per packet if constant and known or 0
@ -2048,6 +2052,17 @@ typedef struct AVCodecContext {
* The decoder can then override during decoding as needed.
*/
AVChannelLayout ch_layout;
/**
* Frame counter, set by libavcodec.
*
* - decoding: total number of frames returned from the decoder so far.
* - encoding: total number of frames passed to the encoder so far.
*
* @note the counter is not incremented if encoding/decoding resulted in
* an error.
*/
int64_t frame_num;
} AVCodecContext;
/**

@ -66,7 +66,7 @@ static int bfi_decode_frame(AVCodecContext *avctx, AVFrame *frame,
bytestream2_init(&g, avpkt->data, buf_size);
/* Set frame parameters and palette, if necessary */
if (!avctx->frame_number) {
if (!avctx->frame_num) {
frame->pict_type = AV_PICTURE_TYPE_I;
frame->key_frame = 1;
/* Setting the palette */

@ -374,7 +374,7 @@ static void cdg_decode_flush(AVCodecContext *avctx)
return;
memset(cc->frame->data[0], 0, cc->frame->linesize[0] * avctx->height);
if (!avctx->frame_number)
if (!avctx->frame_num)
memset(cc->frame->data[1], 0, AVPALETTE_SIZE);
}

@ -42,7 +42,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
CLJRContext *a = avctx->priv_data;
PutBitContext pb;
int x, y, ret;
uint32_t dither= avctx->frame_number;
uint32_t dither= avctx->frame_num;
static const uint32_t ordered_dither[2][2] =
{
{ 0x10400000, 0x104F0000 },

@ -711,11 +711,16 @@ int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame)
goto fail;
}
avctx->frame_number++;
avctx->frame_num++;
#if FF_API_AVCTX_FRAME_NUMBER
FF_DISABLE_DEPRECATION_WARNINGS
avctx->frame_number = avctx->frame_num;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (avctx->flags & AV_CODEC_FLAG_DROPCHANGED) {
if (avctx->frame_number == 1) {
if (avctx->frame_num == 1) {
avci->initial_format = frame->format;
switch(avctx->codec_type) {
case AVMEDIA_TYPE_VIDEO:
@ -732,7 +737,7 @@ int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame)
}
}
if (avctx->frame_number > 1) {
if (avctx->frame_num > 1) {
changed = avci->initial_format != frame->format;
switch(avctx->codec_type) {
@ -749,9 +754,9 @@ 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,
avctx->frame_num, frame->pts,
avci->changed_frames_dropped);
ret = AVERROR_INPUT_CHANGED;
goto fail;
@ -916,7 +921,12 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
}
if (*got_sub_ptr)
avctx->frame_number++;
avctx->frame_num++;
#if FF_API_AVCTX_FRAME_NUMBER
FF_DISABLE_DEPRECATION_WARNINGS
avctx->frame_number = avctx->frame_num;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
return ret;

@ -1144,7 +1144,7 @@ static void dv_format_frame(DVEncContext *c, uint8_t *buf)
{
int chan, i, j, k;
/* We work with 720p frames split in half. The odd half-frame is chan 2,3 */
int chan_offset = 2*(c->sys->height == 720 && c->avctx->frame_number & 1);
int chan_offset = 2*(c->sys->height == 720 && c->avctx->frame_num & 1);
for (chan = 0; chan < c->sys->n_difchan; chan++) {
for (i = 0; i < c->sys->difseg_size; i++) {

@ -189,7 +189,7 @@ void ff_eac3_output_frame_header(AC3EncodeContext *s)
put_bits(&s->pb, 1, 0);
}
if (s->num_blocks != 6)
put_bits(&s->pb, 1, !(s->avctx->frame_number % 6)); /* converter sync flag */
put_bits(&s->pb, 1, !(s->avctx->frame_num % 6)); /* converter sync flag */
put_bits(&s->pb, 1, 0); /* no additional bit stream info */
/* frame header */

@ -171,7 +171,12 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
}
ret = ffcodec(avctx->codec)->cb.encode_sub(avctx, buf, buf_size, sub);
avctx->frame_number++;
avctx->frame_num++;
#if FF_API_AVCTX_FRAME_NUMBER
FF_DISABLE_DEPRECATION_WARNINGS
avctx->frame_number = avctx->frame_num;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
return ret;
}
@ -503,7 +508,12 @@ int attribute_align_arg avcodec_send_frame(AVCodecContext *avctx, const AVFrame
return ret;
}
avctx->frame_number++;
avctx->frame_num++;
#if FF_API_AVCTX_FRAME_NUMBER
FF_DISABLE_DEPRECATION_WARNINGS
avctx->frame_number = avctx->frame_num;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
return 0;
}

@ -221,8 +221,8 @@ 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",
avctx->frame_number, message);
av_log(avctx, AV_LOG_WARNING, "Frame #%"PRId64", %s\n",
avctx->frame_num, 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;
@ -787,7 +787,7 @@ static int optimum_use15_7(FlashSV2Context * s)
{
#ifndef FLASHSV2_DUMB
double ideal = ((double)(s->avctx->bit_rate * s->avctx->time_base.den * s->avctx->ticks_per_frame)) /
((double) s->avctx->time_base.num) * s->avctx->frame_number;
((double) s->avctx->time_base.num) * s->avctx->frame_num;
if (ideal + use15_7_threshold < s->total_bits) {
return 1;
} else {
@ -861,20 +861,20 @@ static int flashsv2_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return res;
/* First frame needs to be a keyframe */
if (avctx->frame_number == 0)
if (avctx->frame_num == 0)
keyframe = 1;
/* Check the placement of keyframes */
if (avctx->gop_size > 0) {
if (avctx->frame_number >= s->last_key_frame + avctx->gop_size)
if (avctx->frame_num >= s->last_key_frame + avctx->gop_size)
keyframe = 1;
}
if (!keyframe
&& avctx->frame_number > s->last_key_frame + avctx->keyint_min) {
&& avctx->frame_num > 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_num);
}
if (keyframe) {
@ -890,9 +890,9 @@ static int flashsv2_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
if (keyframe) {
new_key_frame(s);
s->last_key_frame = avctx->frame_number;
s->last_key_frame = avctx->frame_num;
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_num);
}
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;
@ -215,7 +215,7 @@ static int flashsv_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
/* Check the placement of keyframes */
if (avctx->gop_size > 0 &&
avctx->frame_number >= s->last_key_frame + avctx->gop_size) {
avctx->frame_num >= s->last_key_frame + avctx->gop_size) {
I_frame = 1;
}
@ -229,8 +229,8 @@ 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);
s->last_key_frame = avctx->frame_num;
ff_dlog(avctx, "Inserting keyframe at frame %"PRId64"\n", avctx->frame_num);
}
if (I_frame)

@ -931,8 +931,8 @@ 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",
avctx->frame_number, tile_x, tile_y);
"ePIC: tile decoding failed, frame=%"PRId64", tile_x=%d, tile_y=%d\n",
avctx->frame_num, tile_x, tile_y);
return AVERROR_INVALIDDATA;
}

@ -318,7 +318,7 @@ static int gif_image_write_image(AVCodecContext *avctx,
disposal = GCE_DISPOSAL_INPLACE;
}
if (s->image || !avctx->frame_number) { /* GIF header */
if (s->image || !avctx->frame_num) { /* GIF header */
const uint32_t *global_palette = palette ? palette : s->palette;
const AVRational sar = avctx->sample_aspect_ratio;
int64_t aspect = 0;
@ -510,7 +510,7 @@ static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
pkt->size = outbuf_ptr - pkt->data;
if (s->image || !avctx->frame_number)
if (s->image || !avctx->frame_num)
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;

@ -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_num, 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;

@ -1297,7 +1297,7 @@ static int h264_select_output_frame(H264Context *h)
h->last_pocs[0] = cur->poc;
cur->mmco_reset = 1;
} else if(h->avctx->has_b_frames < out_of_order && !sps->bitstream_restriction_flag){
int loglevel = h->avctx->frame_number > 1 ? AV_LOG_WARNING : AV_LOG_VERBOSE;
int loglevel = h->avctx->frame_num > 1 ? AV_LOG_WARNING : AV_LOG_VERBOSE;
av_log(h->avctx, loglevel, "Increasing reorder buffer to %d\n", out_of_order);
h->avctx->has_b_frames = out_of_order;
}

@ -926,7 +926,7 @@ static void ipvideo_format_06_firstpass(IpvideoContext *s, AVFrame *frame, int16
}
} else {
/* Don't try to copy second_last_frame data on the first frames */
if (s->avctx->frame_number > 2)
if (s->avctx->frame_num > 2)
copy_from(s, s->second_last_frame, frame, 0, 0);
}
}
@ -1085,7 +1085,7 @@ static void ipvideo_decode_format_10_opcodes(IpvideoContext *s, AVFrame *frame)
copy_from(s, s->cur_decode_frame, frame, 0, 0);
} else {
/* Don't try to copy last_frame data on the first frame */
if (s->avctx->frame_number)
if (s->avctx->frame_num)
copy_from(s, s->last_frame, frame, 0, 0);
}
skip *= 2;
@ -1144,8 +1144,8 @@ 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",
s->avctx->frame_number, x, y);
av_log(s->avctx, AV_LOG_ERROR, "decode problem on frame %"PRId64", @ block (%d, %d)\n",
s->avctx->frame_num, x, y);
return;
}
}

@ -1093,7 +1093,7 @@ int ff_h263_decode_picture_header(MpegEncContext *s)
align_get_bits(&s->gb);
if (show_bits(&s->gb, 2) == 2 && s->avctx->frame_number == 0) {
if (show_bits(&s->gb, 2) == 2 && s->avctx->frame_num == 0) {
av_log(s->avctx, AV_LOG_WARNING, "Header looks like RTP instead of H.263\n");
}

@ -132,7 +132,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
goto end;
}
if (!avctx->frame_number) {
if (!avctx->frame_num) {
s->first_frame_pts = frame->pts;
#if FF_API_REORDERED_OPAQUE
FF_DISABLE_DEPRECATION_WARNINGS

@ -2884,7 +2884,7 @@ av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
MJpegDecodeContext *s = avctx->priv_data;
int i, j;
if (s->interlaced && s->bottom_field == !s->interlace_polarity && s->got_picture && !avctx->frame_number) {
if (s->interlaced && s->bottom_field == !s->interlace_polarity && s->got_picture && !avctx->frame_num) {
av_log(avctx, AV_LOG_INFO, "Single field\n");
}

@ -2118,7 +2118,7 @@ static int mlp_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
data = frame ? frame->data[0] : NULL;
ctx->frame_index = avctx->frame_number % ctx->max_restart_interval;
ctx->frame_index = avctx->frame_num % ctx->max_restart_interval;
ctx->inout_buffer = ctx->major_inout_buffer
+ ctx->frame_index * ctx->one_sample_buffer_size;
@ -2128,7 +2128,7 @@ static int mlp_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
ctx->write_buffer = ctx->inout_buffer;
if (avctx->frame_number < ctx->max_restart_interval) {
if (avctx->frame_num < ctx->max_restart_interval) {
if (data)
goto input_and_return;
}
@ -2199,7 +2199,7 @@ input_and_return:
}
if (!frame && ctx->last_frames < ctx->max_restart_interval - 1)
avctx->frame_number++;
avctx->frame_num++;
if (bytes_written > 0) {
ff_af_queue_remove(&ctx->afq,

@ -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_num);
sd = av_frame_new_side_data(pict, AV_FRAME_DATA_MOTION_VECTORS, mbcount * sizeof(AVMotionVector));
if (!sd) {
av_freep(&mvs);

@ -139,7 +139,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
int size_change = 0;
int minsize = 0;
int flags = 0;
int result, init_frame = !avctx->frame_number;
int result, init_frame = !avctx->frame_num;
enum {
NUV_UNCOMPRESSED = '0',
NUV_RTJPEG = '1',

@ -97,7 +97,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_num), 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",

@ -554,7 +554,7 @@ static int opus_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
ff_bufqueue_add(avctx, &s->bufqueue, av_frame_clone(frame));
} else {
ff_opus_psy_signal_eof(&s->psyctx);
if (!s->afq.remaining_samples || !avctx->frame_number)
if (!s->afq.remaining_samples || !avctx->frame_num)
return 0; /* We've been flushed and there's nothing left to encode */
}

@ -251,7 +251,7 @@ static void png_write_image_data(AVCodecContext *avctx,
const AVCRC *crc_table = av_crc_get_table(AV_CRC_32_IEEE_LE);
uint32_t crc = ~0U;
if (avctx->codec_id == AV_CODEC_ID_PNG || avctx->frame_number == 0) {
if (avctx->codec_id == AV_CODEC_ID_PNG || avctx->frame_num == 0) {
png_write_chunk(&s->bytestream, MKTAG('I', 'D', 'A', 'T'), buf, length);
return;
}
@ -799,7 +799,7 @@ static int apng_encode_frame(AVCodecContext *avctx, const AVFrame *pict,
APNGFctlChunk last_fctl_chunk = *best_last_fctl_chunk;
APNGFctlChunk fctl_chunk = *best_fctl_chunk;
if (avctx->frame_number == 0) {
if (avctx->frame_num == 0) {
best_fctl_chunk->width = pict->width;
best_fctl_chunk->height = pict->height;
best_fctl_chunk->x_offset = 0;
@ -924,7 +924,7 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt,
if (pict && s->color_type == PNG_COLOR_TYPE_PALETTE) {
uint32_t checksum = ~av_crc(av_crc_get_table(AV_CRC_32_IEEE_LE), ~0U, pict->data[1], 256 * sizeof(uint32_t));
if (avctx->frame_number == 0) {
if (avctx->frame_num == 0) {
s->palette_checksum = checksum;
} else if (checksum != s->palette_checksum) {
av_log(avctx, AV_LOG_ERROR,
@ -946,7 +946,7 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt,
if (max_packet_size > INT_MAX)
return AVERROR(ENOMEM);
if (avctx->frame_number == 0) {
if (avctx->frame_num == 0) {
if (!pict)
return AVERROR(EINVAL);

@ -362,7 +362,12 @@ static int update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
dst->skip_idct = src->skip_idct;
dst->skip_frame = src->skip_frame;
dst->frame_num = src->frame_num;
#if FF_API_AVCTX_FRAME_NUMBER
FF_DISABLE_DEPRECATION_WARNINGS
dst->frame_number = src->frame_number;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
#if FF_API_REORDERED_OPAQUE
FF_DISABLE_DEPRECATION_WARNINGS
dst->reordered_opaque = src->reordered_opaque;

@ -646,8 +646,8 @@ 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",
avctx->frame_number, message);
av_log(avctx, AV_LOG_WARNING, "Frame #%"PRId64", IFQ: %s\n",
avctx->frame_num, message);
}
static void postfilter(QCELPContext *q, float *samples, float *lpc)

@ -374,7 +374,7 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return ret;
if (avctx->gop_size == 0 || !s->previous_frame->data[0] ||
(s->avctx->frame_number % avctx->gop_size) == 0) {
(s->avctx->frame_num % avctx->gop_size) == 0) {
/* I-Frame */
s->key_frame = 1;
} else {

@ -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_num, buf_size);
/* no supplementary picture */
if (buf_size == 0) {

@ -542,7 +542,7 @@ static int smc_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return ret;
if (avctx->gop_size == 0 || !s->prev_frame->data[0] ||
(avctx->frame_number % avctx->gop_size) == 0) {
(avctx->frame_num % avctx->gop_size) == 0) {
s->key_frame = 1;
} else {
s->key_frame = 0;

@ -1607,9 +1607,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
pic->pict_type = pict->pict_type;
pic->quality = pict->quality;
s->m.picture_number= avctx->frame_number;
s->m.picture_number= avctx->frame_num;
if(avctx->flags&AV_CODEC_FLAG_PASS2){
s->m.pict_type = pic->pict_type = s->m.rc_context.entry[avctx->frame_number].new_pict_type;
s->m.pict_type = pic->pict_type = s->m.rc_context.entry[avctx->frame_num].new_pict_type;
s->keyframe = pic->pict_type == AV_PICTURE_TYPE_I;
if(!(avctx->flags&AV_CODEC_FLAG_QSCALE)) {
pic->quality = ff_rate_estimate_qscale(&s->m, 0);
@ -1617,11 +1617,11 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return -1;
}
}else{
s->keyframe= avctx->gop_size==0 || avctx->frame_number % avctx->gop_size == 0;
s->keyframe= avctx->gop_size==0 || avctx->frame_num % avctx->gop_size == 0;
s->m.pict_type = pic->pict_type = s->keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
}
if(s->pass1_rc && avctx->frame_number == 0)
if(s->pass1_rc && avctx->frame_num == 0)
pic->quality = 2*FF_QP2LAMBDA;
if (pic->quality) {
s->qlog = qscale2qlog(pic->quality);
@ -1856,13 +1856,13 @@ redo_frame:
ff_snow_release_buffer(avctx);
s->current_picture->coded_picture_number = avctx->frame_number;
s->current_picture->coded_picture_number = avctx->frame_num;
s->current_picture->pict_type = pic->pict_type;
s->current_picture->quality = pic->quality;
s->m.frame_bits = 8*(s->c.bytestream - s->c.bytestream_start);
s->m.p_tex_bits = s->m.frame_bits - s->m.misc_bits - s->m.mv_bits;
s->m.current_picture.f->display_picture_number =
s->m.current_picture.f->coded_picture_number = avctx->frame_number;
s->m.current_picture.f->coded_picture_number = avctx->frame_num;
s->m.current_picture.f->quality = pic->quality;
s->m.total_bits += 8*(s->c.bytestream - s->c.bytestream_start);
if(s->pass1_rc)

@ -548,10 +548,10 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx)
SVQ1EncContext *const s = avctx->priv_data;
int i;
if (avctx->frame_number)
if (avctx->frame_num)
av_log(avctx, AV_LOG_DEBUG, "RD: %f\n",
s->rd_total / (double)(avctx->width * avctx->height *
avctx->frame_number));
avctx->frame_num));
s->m.mb_type = NULL;
ff_mpv_common_end(&s->m);
@ -684,7 +684,7 @@ static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
FFSWAP(AVFrame*, s->current_picture, s->last_picture);
if (avctx->gop_size && (avctx->frame_number % avctx->gop_size))
if (avctx->gop_size && (avctx->frame_num % avctx->gop_size))
s->pict_type = AV_PICTURE_TYPE_P;
else
s->pict_type = AV_PICTURE_TYPE_I;

@ -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_num, 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_num, left);
return -1;
}

@ -29,7 +29,7 @@
#include "version_major.h"
#define LIBAVCODEC_VERSION_MINOR 1
#define LIBAVCODEC_VERSION_MINOR 2
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \

@ -44,6 +44,7 @@
#define FF_API_VT_OUTPUT_CALLBACK (LIBAVCODEC_VERSION_MAJOR < 61)
#define FF_API_AVCODEC_CHROMA_POS (LIBAVCODEC_VERSION_MAJOR < 61)
#define FF_API_VT_HWACCEL_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 61)
#define FF_API_AVCTX_FRAME_NUMBER (LIBAVCODEC_VERSION_MAJOR < 61)
// reminder to remove CrystalHD decoders on next major bump
#define FF_CODEC_CRYSTAL_HD (LIBAVCODEC_VERSION_MAJOR < 61)

@ -2654,8 +2654,8 @@ 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",
s->keyframe ? "key" : "", avctx->frame_number + 1, s->qps[0]);
av_log(s->avctx, AV_LOG_INFO, " VP3 %sframe #%"PRId64": Q index = %d\n",
s->keyframe ? "key" : "", avctx->frame_num + 1, s->qps[0]);
s->skip_loop_filter = !s->filter_limit_values[s->qps[0]] ||
avctx->skip_loop_filter >= (s->keyframe ? AVDISCARD_ALL
@ -2701,7 +2701,7 @@ static int vp3_decode_frame(AVCodecContext *avctx, AVFrame *frame,
}
#endif
s->version = version;
if (avctx->frame_number == 0)
if (avctx->frame_num == 0)
av_log(s->avctx, AV_LOG_DEBUG,
"VP version: %d\n", s->version);
}

@ -156,7 +156,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
if (bytestream2_get_bytes_left(&gb) < 8LL * blocks)
return AVERROR_INVALIDDATA;
if (!avctx->frame_number) {
if (!avctx->frame_num) {
ptrdiff_t linesize[4] = { s->prev_frame->linesize[0], 0, 0, 0 };
av_image_fill_black(s->prev_frame->data, linesize, avctx->pix_fmt, 0,
avctx->width, avctx->height);

@ -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_num, 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_num, s->skip_packets);
}
ff_dlog(avctx, "packet[%d]: nbpf %x\n", avctx->frame_number,
ff_dlog(avctx, "packet[%"PRId64"]: nbpf %x\n", avctx->frame_num,
num_bits_prev_frame);
/** check for packet loss */

@ -207,7 +207,7 @@ static int yop_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
if ((ret = ff_reget_buffer(avctx, frame, 0)) < 0)
return ret;
if (!avctx->frame_number)
if (!avctx->frame_num)
memset(frame->data[1], 0, AVPALETTE_SIZE);
s->dstbuf = frame->data[0];

@ -38,7 +38,7 @@ static int decode_read(DecodeContext *dc, int flush)
int ret = 0;
while (ret >= 0 &&
(dc->max_frames == 0 || dc->decoder->frame_number < dc->max_frames)) {
(dc->max_frames == 0 || dc->decoder->frame_num < dc->max_frames)) {
ret = avcodec_receive_frame(dc->decoder, dc->frame);
if (ret < 0) {
if (ret == AVERROR_EOF) {
@ -55,11 +55,11 @@ static int decode_read(DecodeContext *dc, int flush)
if (ret < 0)
return ret;
if (dc->max_frames && dc->decoder->frame_number == dc->max_frames)
if (dc->max_frames && dc->decoder->frame_num == dc->max_frames)
return 1;
}
return (dc->max_frames == 0 || dc->decoder->frame_number < dc->max_frames) ? 0 : 1;
return (dc->max_frames == 0 || dc->decoder->frame_num < dc->max_frames) ? 0 : 1;
}
int ds_run(DecodeContext *dc)

@ -100,8 +100,8 @@ 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",
dc->decoder->frame_number - 1, pd->random_seed);
fprintf(stderr, "mismatch frame %"PRId64" seed %u\n",
dc->decoder->frame_num - 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_num - 1);
sd = av_frame_get_side_data(frame, AV_FRAME_DATA_VIDEO_ENC_PARAMS);
if (sd) {

Loading…
Cancel
Save