diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-03-10 11:45:55 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2021-01-01 14:23:19 +0100 |
commit | baecaa16c16dc2bca7ca15ed3c379d7343955adb (patch) | |
tree | 1f6f2269e0c05c25857d7d72b27d1691ea9ec67d /libavcodec | |
parent | e15371061d23457554d241a80dc471515ac13ad4 (diff) |
mpegvideo: use the AVVideoEncParams API for exporting QP tables
Do it only when requested with the AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS
flag.
Drop previous code using the long-deprecated AV_FRAME_DATA_QP_TABLE*
API. Temporarily disable fate-filter-pp, fate-filter-pp7,
fate-filter-spp. They will be reenabled once these filters are converted
in following commits.
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/h263dec.c | 2 | ||||
-rw-r--r-- | libavcodec/mpeg12dec.c | 1 | ||||
-rw-r--r-- | libavcodec/mpegpicture.c | 2 | ||||
-rw-r--r-- | libavcodec/mpegpicture.h | 1 | ||||
-rw-r--r-- | libavcodec/mpegvideo.c | 35 | ||||
-rw-r--r-- | libavcodec/rv34.c | 1 |
6 files changed, 35 insertions, 7 deletions
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 8b441b2951..dafa54d8d4 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -28,6 +28,8 @@ #define UNCHECKED_BITSTREAM_READER 1 #include "libavutil/cpu.h" +#include "libavutil/video_enc_params.h" + #include "avcodec.h" #include "error_resilience.h" #include "flv.h" diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 7b98d488a2..b9bd7daa25 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -33,6 +33,7 @@ #include "libavutil/internal.h" #include "libavutil/mem_internal.h" #include "libavutil/stereo3d.h" +#include "libavutil/video_enc_params.h" #include "avcodec.h" #include "bytestream.h" diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c index 13c11ec492..e495e315e6 100644 --- a/libavcodec/mpegpicture.c +++ b/libavcodec/mpegpicture.c @@ -220,6 +220,7 @@ static int alloc_picture_tables(AVCodecContext *avctx, Picture *pic, int encodin pic->alloc_mb_width = mb_width; pic->alloc_mb_height = mb_height; + pic->alloc_mb_stride = mb_stride; return 0; } @@ -346,6 +347,7 @@ int ff_update_picture_tables(Picture *dst, Picture *src) dst->alloc_mb_width = src->alloc_mb_width; dst->alloc_mb_height = src->alloc_mb_height; + dst->alloc_mb_stride = src->alloc_mb_stride; return 0; } diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h index 2db3d6733a..4bcd666797 100644 --- a/libavcodec/mpegpicture.h +++ b/libavcodec/mpegpicture.h @@ -69,6 +69,7 @@ typedef struct Picture { int alloc_mb_width; ///< mb_width used to allocate tables int alloc_mb_height; ///< mb_height used to allocate tables + int alloc_mb_stride; ///< mb_stride used to allocate tables AVBufferRef *mb_mean_buf; uint8_t *mb_mean; ///< Table for MB luminance diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 60ed716865..988dd18a33 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -32,6 +32,8 @@ #include "libavutil/imgutils.h" #include "libavutil/internal.h" #include "libavutil/motion_vector.h" +#include "libavutil/video_enc_params.h" + #include "avcodec.h" #include "blockdsp.h" #include "h264chroma.h" @@ -1422,14 +1424,33 @@ void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict) int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type) { - AVBufferRef *ref = av_buffer_ref(p->qscale_table_buf); - int offset = 2*s->mb_stride + 1; - if(!ref) + AVVideoEncParams *par; + int mult = (qp_type == FF_QSCALE_TYPE_MPEG1) ? 2 : 1; + unsigned int nb_mb = p->alloc_mb_height * p->alloc_mb_width; + unsigned int x, y; + + if (!(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS)) + return 0; + + par = av_video_enc_params_create_side_data(f, AV_VIDEO_ENC_PARAMS_MPEG2, nb_mb); + if (!par) return AVERROR(ENOMEM); - av_assert0(ref->size >= offset + s->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); + + for (y = 0; y < p->alloc_mb_height; y++) + for (x = 0; x < p->alloc_mb_width; x++) { + const unsigned int block_idx = y * p->alloc_mb_width + x; + const unsigned int mb_xy = y * p->alloc_mb_stride + x; + AVVideoBlockParams *b = av_video_enc_params_block(par, block_idx); + + b->src_x = x * 16; + b->src_y = y * 16; + b->w = 16; + b->h = 16; + + b->delta_qp = p->qscale_table[mb_xy] * mult; + } + + return 0; } static inline int hpel_motion_lowres(MpegEncContext *s, diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 6434f784d6..7e5bfe0e22 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -29,6 +29,7 @@ #include "libavutil/internal.h" #include "libavutil/mem_internal.h" #include "libavutil/thread.h" +#include "libavutil/video_enc_params.h" #include "avcodec.h" #include "error_resilience.h" |