lavfi: add qp_table_size

This avoid recalculating it and in case w/h changed avoids crashes.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-09-07 13:00:47 +02:00
parent 5891e454a6
commit 91141f2a13
3 changed files with 3 additions and 1 deletions

View File

@ -50,6 +50,7 @@ int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
if(!dst->video->qp_table)
return AVERROR(ENOMEM);
dst->video->qp_table_linesize = src->qstride;
dst->video->qp_table_size = qsize;
memcpy(dst->video->qp_table, src->qscale_table, qsize);
}
break;

View File

@ -132,6 +132,7 @@ typedef struct AVFilterBufferRefVideoProps {
enum AVPictureType pict_type; ///< picture type of the frame
int key_frame; ///< 1 -> keyframe, 0-> not
int qp_table_linesize; ///< qp_table stride
int qp_table_size; ///< qp_table size
int8_t *qp_table; ///< array of Quantization Parameters
} AVFilterBufferRefVideoProps;

View File

@ -42,7 +42,7 @@ void ff_avfilter_default_free_buffer(AVFilterBuffer *ptr)
static void copy_video_props(AVFilterBufferRefVideoProps *dst, AVFilterBufferRefVideoProps *src) {
*dst = *src;
if (src->qp_table) {
int qsize = src->qp_table_linesize ? src->qp_table_linesize * ((src->h+15)/16) : (src->w+15)/16;
int qsize = src->qp_table_size;
dst->qp_table = av_malloc(qsize);
memcpy(dst->qp_table, src->qp_table, qsize);
}