Commit 8400b126 authored by Mans Rullgard's avatar Mans Rullgard

avcodec: deprecate AVFrame.age

This was intended as an optimisation for skipped blocks in MPEG2
P-frames and never used elsewhere.  Removing this "optimisation"
speeds up MPEG2 decoding by 1-2% (ARM Cortex-A9).
Signed-off-by: 's avatarMans Rullgard <mans@mansr.com>
parent bc78ceec
...@@ -1564,7 +1564,6 @@ static int input_get_buffer(AVCodecContext *codec, AVFrame *pic) ...@@ -1564,7 +1564,6 @@ static int input_get_buffer(AVCodecContext *codec, AVFrame *pic)
pic->linesize[i] = ref->linesize[i]; pic->linesize[i] = ref->linesize[i];
} }
pic->opaque = ref; pic->opaque = ref;
pic->age = INT_MAX;
pic->type = FF_BUFFER_TYPE_USER; pic->type = FF_BUFFER_TYPE_USER;
pic->reordered_opaque = codec->reordered_opaque; pic->reordered_opaque = codec->reordered_opaque;
if(codec->pkt) pic->pkt_pts = codec->pkt->pts; if(codec->pkt) pic->pkt_pts = codec->pkt->pts;
......
...@@ -13,6 +13,9 @@ libavutil: 2011-04-18 ...@@ -13,6 +13,9 @@ libavutil: 2011-04-18
API changes, most recent first: API changes, most recent first:
2011-12-18 - xxxxxxx - lavc 53.28.1
Deprecate AVFrame.age. The field is unused.
2011-xx-xx - xxxxxxx - lavf 53.17.0 2011-xx-xx - xxxxxxx - lavf 53.17.0
Add avformat_open_input(). Add avformat_open_input().
Deprecate av_close_input_file() and av_close_input_stream(). Deprecate av_close_input_file() and av_close_input_stream().
......
...@@ -1004,13 +1004,12 @@ typedef struct AVFrame { ...@@ -1004,13 +1004,12 @@ typedef struct AVFrame {
*/ */
int quality; int quality;
#if FF_API_AVFRAME_AGE
/** /**
* buffer age (1->was last buffer and dint change, 2->..., ...). * @deprecated unused
* Set to INT_MAX if the buffer has not been used yet.
* - encoding: unused
* - decoding: MUST be set by get_buffer() for video.
*/ */
int age; attribute_deprecated int age;
#endif
/** /**
* is this picture used as reference * is this picture used as reference
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "avcodec.h" #include "avcodec.h"
typedef struct InternalBuffer { typedef struct InternalBuffer {
int last_pic_num;
uint8_t *base[AV_NUM_DATA_POINTERS]; uint8_t *base[AV_NUM_DATA_POINTERS];
uint8_t *data[AV_NUM_DATA_POINTERS]; uint8_t *data[AV_NUM_DATA_POINTERS];
int linesize[AV_NUM_DATA_POINTERS]; int linesize[AV_NUM_DATA_POINTERS];
......
...@@ -263,9 +263,9 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic) ...@@ -263,9 +263,9 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
else else
r = avcodec_default_get_buffer(s->avctx, (AVFrame *) pic); r = avcodec_default_get_buffer(s->avctx, (AVFrame *) pic);
if (r < 0 || !pic->f.age || !pic->f.type || !pic->f.data[0]) { if (r < 0 || !pic->f.type || !pic->f.data[0]) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %p)\n",
r, pic->f.age, pic->f.type, pic->f.data[0]); r, pic->f.type, pic->f.data[0]);
av_freep(&pic->f.hwaccel_picture_private); av_freep(&pic->f.hwaccel_picture_private);
return -1; return -1;
} }
...@@ -369,15 +369,6 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared) ...@@ -369,15 +369,6 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared)
1 * sizeof(AVPanScan), fail) 1 * sizeof(AVPanScan), fail)
} }
/* It might be nicer if the application would keep track of these
* but it would require an API change. */
memmove(s->prev_pict_types + 1, s->prev_pict_types,
PREV_PICT_TYPES_BUFFER_SIZE-1);
s->prev_pict_types[0] = s->dropable ? AV_PICTURE_TYPE_B : s->pict_type;
if (pic->f.age < PREV_PICT_TYPES_BUFFER_SIZE &&
s->prev_pict_types[pic->f.age] == AV_PICTURE_TYPE_B)
pic->f.age = INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2
// and it is a bit tricky to skip them anyway.
pic->owner2 = s; pic->owner2 = s;
return 0; return 0;
...@@ -574,9 +565,6 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, ...@@ -574,9 +565,6 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
s->current_picture_ptr = REBASE_PICTURE(s1->current_picture_ptr, s, s1); s->current_picture_ptr = REBASE_PICTURE(s1->current_picture_ptr, s, s1);
s->next_picture_ptr = REBASE_PICTURE(s1->next_picture_ptr, s, s1); s->next_picture_ptr = REBASE_PICTURE(s1->next_picture_ptr, s, s1);
memcpy(s->prev_pict_types, s1->prev_pict_types,
PREV_PICT_TYPES_BUFFER_SIZE);
// Error/bug resilience // Error/bug resilience
s->next_p_frame_damaged = s1->next_p_frame_damaged; s->next_p_frame_damaged = s1->next_p_frame_damaged;
s->workaround_bugs = s1->workaround_bugs; s->workaround_bugs = s1->workaround_bugs;
...@@ -880,8 +868,6 @@ av_cold int MPV_common_init(MpegEncContext *s) ...@@ -880,8 +868,6 @@ av_cold int MPV_common_init(MpegEncContext *s)
/* init macroblock skip table */ /* init macroblock skip table */
FF_ALLOCZ_OR_GOTO(s->avctx, s->mbskip_table, mb_array_size + 2, fail); FF_ALLOCZ_OR_GOTO(s->avctx, s->mbskip_table, mb_array_size + 2, fail);
// Note the + 1 is for a quicker mpeg4 slice_end detection // Note the + 1 is for a quicker mpeg4 slice_end detection
FF_ALLOCZ_OR_GOTO(s->avctx, s->prev_pict_types,
PREV_PICT_TYPES_BUFFER_SIZE, fail);
s->parse_context.state = -1; s->parse_context.state = -1;
if ((s->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) || if ((s->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) ||
...@@ -981,7 +967,6 @@ void MPV_common_end(MpegEncContext *s) ...@@ -981,7 +967,6 @@ void MPV_common_end(MpegEncContext *s)
av_freep(&s->pred_dir_table); av_freep(&s->pred_dir_table);
av_freep(&s->mbskip_table); av_freep(&s->mbskip_table);
av_freep(&s->prev_pict_types);
av_freep(&s->bitstream_buffer); av_freep(&s->bitstream_buffer);
s->allocated_bitstream_buffer_size = 0; s->allocated_bitstream_buffer_size = 0;
...@@ -2215,24 +2200,13 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64], ...@@ -2215,24 +2200,13 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64],
/* skip only during decoding as we might trash the buffers during encoding a bit */ /* skip only during decoding as we might trash the buffers during encoding a bit */
if(!s->encoding){ if(!s->encoding){
uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy]; uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
const int age = s->current_picture.f.age;
assert(age);
if (s->mb_skipped) { if (s->mb_skipped) {
s->mb_skipped= 0; s->mb_skipped= 0;
assert(s->pict_type!=AV_PICTURE_TYPE_I); assert(s->pict_type!=AV_PICTURE_TYPE_I);
*mbskip_ptr = 1;
(*mbskip_ptr) ++; /* indicate that this time we skipped it */
if(*mbskip_ptr >99) *mbskip_ptr= 99;
/* if previous was skipped too, then nothing to do ! */
if (*mbskip_ptr >= age && s->current_picture.f.reference){
return;
}
} else if(!s->current_picture.f.reference) { } else if(!s->current_picture.f.reference) {
(*mbskip_ptr) ++; /* increase counter so the age can be compared cleanly */ *mbskip_ptr = 1;
if(*mbskip_ptr >99) *mbskip_ptr= 99;
} else{ } else{
*mbskip_ptr = 0; /* not skipped */ *mbskip_ptr = 0; /* not skipped */
} }
......
...@@ -309,8 +309,6 @@ typedef struct MpegEncContext { ...@@ -309,8 +309,6 @@ typedef struct MpegEncContext {
uint8_t *coded_block; ///< used for coded block pattern prediction (msmpeg4v3, wmv1) uint8_t *coded_block; ///< used for coded block pattern prediction (msmpeg4v3, wmv1)
int16_t (*ac_val_base)[16]; int16_t (*ac_val_base)[16];
int16_t (*ac_val[3])[16]; ///< used for for mpeg4 AC prediction, all 3 arrays must be continuous int16_t (*ac_val[3])[16]; ///< used for for mpeg4 AC prediction, all 3 arrays must be continuous
uint8_t *prev_pict_types; ///< previous picture types in bitstream order, used for mb skip
#define PREV_PICT_TYPES_BUFFER_SIZE 256
int mb_skipped; ///< MUST BE SET only during DECODING int mb_skipped; ///< MUST BE SET only during DECODING
uint8_t *mbskip_table; /**< used to avoid copy if macroblock skipped (for black regions for example) uint8_t *mbskip_table; /**< used to avoid copy if macroblock skipped (for black regions for example)
and used for b-frame encoding & decoding (contains skip table of next P Frame) */ and used for b-frame encoding & decoding (contains skip table of next P Frame) */
......
...@@ -855,13 +855,6 @@ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f) ...@@ -855,13 +855,6 @@ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
pthread_mutex_unlock(&p->parent->buffer_mutex); pthread_mutex_unlock(&p->parent->buffer_mutex);
/*
* Buffer age is difficult to keep track of between
* multiple threads, and the optimizations it allows
* are not worth the effort. It is disabled for now.
*/
f->age = INT_MAX;
return err; return err;
} }
......
...@@ -346,7 +346,6 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic) ...@@ -346,7 +346,6 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
int w= s->width; int w= s->width;
int h= s->height; int h= s->height;
InternalBuffer *buf; InternalBuffer *buf;
int *picture_number;
AVCodecInternal *avci = s->internal; AVCodecInternal *avci = s->internal;
if(pic->data[0]!=NULL) { if(pic->data[0]!=NULL) {
...@@ -367,8 +366,6 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic) ...@@ -367,8 +366,6 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
} }
buf = &avci->buffer[avci->buffer_count]; buf = &avci->buffer[avci->buffer_count];
picture_number = &(avci->buffer[INTERNAL_BUFFER_SIZE]).last_pic_num; //FIXME ugly hack
(*picture_number)++;
if(buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)){ if(buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)){
if(s->active_thread_type&FF_THREAD_FRAME) { if(s->active_thread_type&FF_THREAD_FRAME) {
...@@ -382,10 +379,7 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic) ...@@ -382,10 +379,7 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
} }
} }
if(buf->base[0]){ if (!buf->base[0]) {
pic->age= *picture_number - buf->last_pic_num;
buf->last_pic_num= *picture_number;
}else{
int h_chroma_shift, v_chroma_shift; int h_chroma_shift, v_chroma_shift;
int size[4] = {0}; int size[4] = {0};
int tmpsize; int tmpsize;
...@@ -424,7 +418,6 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic) ...@@ -424,7 +418,6 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
size[i] = picture.data[i+1] - picture.data[i]; size[i] = picture.data[i+1] - picture.data[i];
size[i] = tmpsize - (picture.data[i] - picture.data[0]); size[i] = tmpsize - (picture.data[i] - picture.data[0]);
buf->last_pic_num= -256*256*256*64;
memset(buf->base, 0, sizeof(buf->base)); memset(buf->base, 0, sizeof(buf->base));
memset(buf->data, 0, sizeof(buf->data)); memset(buf->data, 0, sizeof(buf->data));
...@@ -453,7 +446,6 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic) ...@@ -453,7 +446,6 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
buf->width = s->width; buf->width = s->width;
buf->height = s->height; buf->height = s->height;
buf->pix_fmt= s->pix_fmt; buf->pix_fmt= s->pix_fmt;
pic->age= 256*256*256*64;
} }
pic->type= FF_BUFFER_TYPE_INTERNAL; pic->type= FF_BUFFER_TYPE_INTERNAL;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#define LIBAVCODEC_VERSION_MAJOR 53 #define LIBAVCODEC_VERSION_MAJOR 53
#define LIBAVCODEC_VERSION_MINOR 28 #define LIBAVCODEC_VERSION_MINOR 28
#define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_MICRO 1
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \ LIBAVCODEC_VERSION_MINOR, \
...@@ -116,5 +116,8 @@ ...@@ -116,5 +116,8 @@
#ifndef FF_API_OLD_DECODE_AUDIO #ifndef FF_API_OLD_DECODE_AUDIO
#define FF_API_OLD_DECODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 54) #define FF_API_OLD_DECODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 54)
#endif #endif
#ifndef FF_API_AVFRAME_AGE
#define FF_API_AVFRAME_AGE (LIBAVCODEC_VERSION_MAJOR < 54)
#endif
#endif /* AVCODEC_VERSION_H */ #endif /* AVCODEC_VERSION_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment