From 23df8b720c2da0a5624f1d325c348a5c8917390a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Mon, 31 Aug 2015 17:35:20 +0200 Subject: [PATCH 1/2] avcodec: reduce ff_mpv_export_qp_table() parameters scope --- libavcodec/h263dec.c | 4 ++-- libavcodec/mpeg12dec.c | 4 ++-- libavcodec/mpegvideo.c | 10 +++++----- libavcodec/mpegvideo.h | 2 +- libavcodec/rv10.c | 4 ++-- libavcodec/rv34.c | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index c85ea9d..c34e009 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -685,12 +685,12 @@ frame_end: if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->current_picture_ptr, pict); - ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1); + ff_mpv_export_qp_table(pict, s->current_picture_ptr->qscale_table_buf, s->mb_stride, FF_QSCALE_TYPE_MPEG1); } else if (s->last_picture_ptr) { if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->last_picture_ptr, pict); - ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1); + ff_mpv_export_qp_table(pict, s->last_picture_ptr->qscale_table_buf, s->mb_stride, FF_QSCALE_TYPE_MPEG1); } if (s->last_picture_ptr || s->low_delay) { diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 5f42e95..5e2f7f2 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -2124,7 +2124,7 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict) if (ret < 0) return ret; ff_print_debug_info(s, s->current_picture_ptr, pict); - ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG2); + ff_mpv_export_qp_table(pict, s->current_picture_ptr->qscale_table_buf, s->mb_stride, FF_QSCALE_TYPE_MPEG2); } else { if (avctx->active_thread_type & FF_THREAD_FRAME) s->picture_number++; @@ -2135,7 +2135,7 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict) if (ret < 0) return ret; ff_print_debug_info(s, s->last_picture_ptr, pict); - ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG2); + ff_mpv_export_qp_table(pict, s->last_picture_ptr->qscale_table_buf, s->mb_stride, FF_QSCALE_TYPE_MPEG2); } } diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index f28f7e8..e7ef94e 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -1954,16 +1954,16 @@ void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict) s->mb_width, s->mb_height, s->mb_stride, s->quarter_sample); } -int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type) +int ff_mpv_export_qp_table(AVFrame *f, AVBufferRef *qscale_table_buf, int mb_stride, int qp_type) { - AVBufferRef *ref = av_buffer_ref(p->qscale_table_buf); - int offset = 2*s->mb_stride + 1; + AVBufferRef *ref = av_buffer_ref(qscale_table_buf); + int offset = 2*mb_stride + 1; if(!ref) return AVERROR(ENOMEM); - av_assert0(ref->size >= offset + s->mb_stride * ((f->height+15)/16)); + av_assert0(ref->size >= offset + mb_stride * ((f->height+15)/16)); ref->size -= offset; ref->data += offset; - return av_frame_set_qp_table(f, ref, s->mb_stride, qp_type); + return av_frame_set_qp_table(f, ref, mb_stride, qp_type); } static inline int hpel_motion_lowres(MpegEncContext *s, diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 8492045..e2d537c 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -655,7 +655,7 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_ int *low_delay, int mb_width, int mb_height, int mb_stride, int quarter_sample); -int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type); +int ff_mpv_export_qp_table(AVFrame *f, AVBufferRef *qscale_table_buf, int mb_stride, int qp_type); void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix); diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index b56bb58..4accaf7 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -769,12 +769,12 @@ static int rv10_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->current_picture_ptr, pict); - ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1); + ff_mpv_export_qp_table(pict, s->current_picture_ptr->qscale_table_buf, s->mb_stride, FF_QSCALE_TYPE_MPEG1); } else if (s->last_picture_ptr) { if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->last_picture_ptr, pict); - ff_mpv_export_qp_table(s, pict,s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1); + ff_mpv_export_qp_table(pict, s->last_picture_ptr->qscale_table_buf, s->mb_stride, FF_QSCALE_TYPE_MPEG1); } if (s->last_picture_ptr || s->low_delay) { diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 51e0f40..6d6eeb4 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -1608,13 +1608,13 @@ static int finish_frame(AVCodecContext *avctx, AVFrame *pict) if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->current_picture_ptr, pict); - ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1); + ff_mpv_export_qp_table(pict, s->current_picture_ptr->qscale_table_buf, s->mb_stride, FF_QSCALE_TYPE_MPEG1); got_picture = 1; } else if (s->last_picture_ptr) { if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->last_picture_ptr, pict); - ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1); + ff_mpv_export_qp_table(pict, s->last_picture_ptr->qscale_table_buf, s->mb_stride, FF_QSCALE_TYPE_MPEG1); got_picture = 1; } -- 2.5.1