History

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.

Anton Khirnov committed 6 years ago

Commit baecaa11 parent e15371010 files · +50 −11Browse files

Unified · Split

10 files
  1. doc/APIchanges +3 −0
  2. libavcodec/h263dec.c +2 −0
  3. libavcodec/mpeg12dec.c +1 −0
  4. libavcodec/mpegpicture.c +2 −0
  5. libavcodec/mpegpicture.h +1 −0
  6. libavcodec/mpegvideo.c +28 −7
  7. libavcodec/rv34.c +1 −0
  8. libavutil/version.h +1 −1
  9. libavutil/video_enc_params.h +8 −0
  10. tests/fate/filter-video.mak +3 −3
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2017-10-21 · 14 unmodified lines
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182020-xx-xx - xxxxxxxxxx - lavu 56.63.100 - video_enc_params.h
19 Add AV_VIDEO_ENC_PARAMS_MPEG2
20
182020-12-03 - xxxxxxxxxx - lavu 56.62.100 - timecode.h212020-12-03 - xxxxxxxxxx - lavu 56.62.100 - timecode.h
19 Add av_timecode_init_from_components.22 Add av_timecode_init_from_components.
20 23
libavcodec/h263dec.c+2−0
@@ -28,6 +28,8 @@ · 27 unmodified lines
28#define UNCHECKED_BITSTREAM_READER 128#define UNCHECKED_BITSTREAM_READER 1
29 29
30#include "libavutil/cpu.h"30#include "libavutil/cpu.h"
31#include "libavutil/video_enc_params.h"
32
31#include "avcodec.h"33#include "avcodec.h"
32#include "error_resilience.h"34#include "error_resilience.h"
33#include "flv.h"35#include "flv.h"
libavcodec/mpeg12dec.c+1−0
@@ -33,6 +33,7 @@ · 32 unmodified lines
33#include "libavutil/internal.h"33#include "libavutil/internal.h"
34#include "libavutil/mem_internal.h"34#include "libavutil/mem_internal.h"
35#include "libavutil/stereo3d.h"35#include "libavutil/stereo3d.h"
36#include "libavutil/video_enc_params.h"
36 37
37#include "avcodec.h"38#include "avcodec.h"
38#include "bytestream.h"39#include "bytestream.h"
libavcodec/mpegpicture.c+2−0
@@ -220,6 +220,7 @@ static int alloc_picture_tables(AVCodecContext *avctx, Picture *pic, int encodin · 219 unmodified lines
220 220
221 pic->alloc_mb_width = mb_width;221 pic->alloc_mb_width = mb_width;
222 pic->alloc_mb_height = mb_height;222 pic->alloc_mb_height = mb_height;
223 pic->alloc_mb_stride = mb_stride;
223 224
224 return 0;225 return 0;
225}226}
@@ -346,6 +347,7 @@ int ff_update_picture_tables(Picture *dst, Picture *src) · 120 unmodified lines
346 347
347 dst->alloc_mb_width = src->alloc_mb_width;348 dst->alloc_mb_width = src->alloc_mb_width;
348 dst->alloc_mb_height = src->alloc_mb_height;349 dst->alloc_mb_height = src->alloc_mb_height;
350 dst->alloc_mb_stride = src->alloc_mb_stride;
349 351
350 return 0;352 return 0;
351}353}
libavcodec/mpegpicture.h+1−0
@@ -69,6 +69,7 @@ typedef struct Picture { · 68 unmodified lines
69 69
70 int alloc_mb_width; ///< mb_width used to allocate tables70 int alloc_mb_width; ///< mb_width used to allocate tables
71 int alloc_mb_height; ///< mb_height used to allocate tables71 int alloc_mb_height; ///< mb_height used to allocate tables
72 int alloc_mb_stride; ///< mb_stride used to allocate tables
72 73
73 AVBufferRef *mb_mean_buf;74 AVBufferRef *mb_mean_buf;
74 uint8_t *mb_mean; ///< Table for MB luminance75 uint8_t *mb_mean; ///< Table for MB luminance
libavcodec/mpegvideo.c+28−7
@@ -32,6 +32,8 @@ · 31 unmodified lines
32#include "libavutil/imgutils.h"32#include "libavutil/imgutils.h"
33#include "libavutil/internal.h"33#include "libavutil/internal.h"
34#include "libavutil/motion_vector.h"34#include "libavutil/motion_vector.h"
35#include "libavutil/video_enc_params.h"
36
35#include "avcodec.h"37#include "avcodec.h"
36#include "blockdsp.h"38#include "blockdsp.h"
37#include "h264chroma.h"39#include "h264chroma.h"
@@ -1422,14 +1424,33 @@ void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict) · 1384 unmodified lines
1422 1424
1423int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type)1425int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type)
1424{1426{
1425 AVBufferRef *ref = av_buffer_ref(p->qscale_table_buf);1427 AVVideoEncParams *par;
1426 int offset = 2*s->mb_stride + 1;1428 int mult = (qp_type == FF_QSCALE_TYPE_MPEG1) ? 2 : 1;
1427 if(!ref)1429 unsigned int nb_mb = p->alloc_mb_height * p->alloc_mb_width;
1430 unsigned int x, y;
1431
1432 if (!(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS))
1433 return 0;
1434
1435 par = av_video_enc_params_create_side_data(f, AV_VIDEO_ENC_PARAMS_MPEG2, nb_mb);
1436 if (!par)
1428 return AVERROR(ENOMEM);1437 return AVERROR(ENOMEM);
1429 av_assert0(ref->size >= offset + s->mb_stride * ((f->height+15)/16));1438
1430 ref->size -= offset;1439 for (y = 0; y < p->alloc_mb_height; y++)
1431 ref->data += offset;1440 for (x = 0; x < p->alloc_mb_width; x++) {
1432 return av_frame_set_qp_table(f, ref, s->mb_stride, qp_type);1441 const unsigned int block_idx = y * p->alloc_mb_width + x;
1442 const unsigned int mb_xy = y * p->alloc_mb_stride + x;
1443 AVVideoBlockParams *b = av_video_enc_params_block(par, block_idx);
1444
1445 b->src_x = x * 16;
1446 b->src_y = y * 16;
1447 b->w = 16;
1448 b->h = 16;
1449
1450 b->delta_qp = p->qscale_table[mb_xy] * mult;
1451 }
1452
1453 return 0;
1433}1454}
1434 1455
1435static inline int hpel_motion_lowres(MpegEncContext *s,1456static inline int hpel_motion_lowres(MpegEncContext *s,
libavcodec/rv34.c+1−0
@@ -29,6 +29,7 @@ · 28 unmodified lines
29#include "libavutil/internal.h"29#include "libavutil/internal.h"
30#include "libavutil/mem_internal.h"30#include "libavutil/mem_internal.h"
31#include "libavutil/thread.h"31#include "libavutil/thread.h"
32#include "libavutil/video_enc_params.h"
32 33
33#include "avcodec.h"34#include "avcodec.h"
34#include "error_resilience.h"35#include "error_resilience.h"
libavutil/version.h+1−1
@@ -79,7 +79,7 @@ · 78 unmodified lines
79 */79 */
80 80
81#define LIBAVUTIL_VERSION_MAJOR 5681#define LIBAVUTIL_VERSION_MAJOR 56
82#define LIBAVUTIL_VERSION_MINOR 6282#define LIBAVUTIL_VERSION_MINOR 63
83#define LIBAVUTIL_VERSION_MICRO 10083#define LIBAVUTIL_VERSION_MICRO 100
84 84
85#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \85#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
libavutil/video_enc_params.h+8−0
@@ -55,6 +55,14 @@ enum AVVideoEncParamsType { · 54 unmodified lines
55 * as AVVideoBlockParams.qp_delta.55 * as AVVideoBlockParams.qp_delta.
56 */56 */
57 AV_VIDEO_ENC_PARAMS_H264,57 AV_VIDEO_ENC_PARAMS_H264,
58
59 /*
60 * MPEG-2-compatible quantizer.
61 *
62 * Summing the frame-level qp with the per-block delta_qp gives the
63 * resulting quantizer for the block.
64 */
65 AV_VIDEO_ENC_PARAMS_MPEG2,
58};66};
59 67
60/**68/**
tests/fate/filter-video.mak+3−3
@@ -561,7 +561,7 @@ fate-filter-idet: CMD = framecrc -flags bitexact -idct simple -i $(SRC) -vf idet · 560 unmodified lines
561FATE_FILTER_VSYNTH-$(CONFIG_PAD_FILTER) += fate-filter-pad561FATE_FILTER_VSYNTH-$(CONFIG_PAD_FILTER) += fate-filter-pad
562fate-filter-pad: CMD = video_filter "pad=iw*1.5:ih*1.5:iw*0.3:ih*0.2"562fate-filter-pad: CMD = video_filter "pad=iw*1.5:ih*1.5:iw*0.3:ih*0.2"
563 563
564FATE_FILTER_PP = fate-filter-pp fate-filter-pp1 fate-filter-pp2 fate-filter-pp3 fate-filter-pp4 fate-filter-pp5 fate-filter-pp6564#FATE_FILTER_PP = fate-filter-pp fate-filter-pp1 fate-filter-pp2 fate-filter-pp3 fate-filter-pp4 fate-filter-pp5 fate-filter-pp6
565FATE_FILTER_VSYNTH-$(CONFIG_PP_FILTER) += $(FATE_FILTER_PP)565FATE_FILTER_VSYNTH-$(CONFIG_PP_FILTER) += $(FATE_FILTER_PP)
566$(FATE_FILTER_PP): fate-vsynth1-mpeg4-qprd566$(FATE_FILTER_PP): fate-vsynth1-mpeg4-qprd
567 567
@@ -573,11 +573,11 @@ fate-filter-pp4: CMD = video_filter "pp=be/ci" · 5 unmodified lines
573fate-filter-pp5: CMD = video_filter "pp=md"573fate-filter-pp5: CMD = video_filter "pp=md"
574fate-filter-pp6: CMD = video_filter "pp=be/fd"574fate-filter-pp6: CMD = video_filter "pp=be/fd"
575 575
576FATE_FILTER_VSYNTH-$(CONFIG_PP7_FILTER) += fate-filter-pp7576#FATE_FILTER_VSYNTH-$(CONFIG_PP7_FILTER) += fate-filter-pp7
577fate-filter-pp7: fate-vsynth1-mpeg4-qprd577fate-filter-pp7: fate-vsynth1-mpeg4-qprd
578fate-filter-pp7: CMD = framecrc -flags bitexact -idct simple -i $(TARGET_PATH)/tests/data/fate/vsynth1-mpeg4-qprd.avi -frames:v 5 -flags +bitexact -vf "pp7"578fate-filter-pp7: CMD = framecrc -flags bitexact -idct simple -i $(TARGET_PATH)/tests/data/fate/vsynth1-mpeg4-qprd.avi -frames:v 5 -flags +bitexact -vf "pp7"
579 579
580FATE_FILTER_VSYNTH-$(CONFIG_SPP_FILTER) += fate-filter-spp580#FATE_FILTER_VSYNTH-$(CONFIG_SPP_FILTER) += fate-filter-spp
581fate-filter-spp: fate-vsynth1-mpeg4-qprd581fate-filter-spp: fate-vsynth1-mpeg4-qprd
582fate-filter-spp: CMD = framecrc -flags bitexact -idct simple -i $(TARGET_PATH)/tests/data/fate/vsynth1-mpeg4-qprd.avi -frames:v 5 -flags +bitexact -vf "spp=idct=simple:dct=int"582fate-filter-spp: CMD = framecrc -flags bitexact -idct simple -i $(TARGET_PATH)/tests/data/fate/vsynth1-mpeg4-qprd.avi -frames:v 5 -flags +bitexact -vf "spp=idct=simple:dct=int"
583 583

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t