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.
Unified · Split
| @@ -15,6 +15,9 @@ libavutil: 2017-10-21 · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | API changes, most recent first: |
| 17 | 17 | |
| 18 | +2020-xx-xx - xxxxxxxxxx - lavu 56.63.100 - video_enc_params.h | |
| 19 | + Add AV_VIDEO_ENC_PARAMS_MPEG2 | |
| 20 | + | |
| 18 | 21 | 2020-12-03 - xxxxxxxxxx - lavu 56.62.100 - timecode.h |
| 19 | 22 | Add av_timecode_init_from_components. |
| 20 | 23 | |
| @@ -28,6 +28,8 @@ · 27 unmodified lines | ||
| 28 | 28 | #define UNCHECKED_BITSTREAM_READER 1 |
| 29 | 29 | |
| 30 | 30 | #include "libavutil/cpu.h" |
| 31 | +#include "libavutil/video_enc_params.h" | |
| 32 | + | |
| 31 | 33 | #include "avcodec.h" |
| 32 | 34 | #include "error_resilience.h" |
| 33 | 35 | #include "flv.h" |
| @@ -33,6 +33,7 @@ · 32 unmodified lines | ||
| 33 | 33 | #include "libavutil/internal.h" |
| 34 | 34 | #include "libavutil/mem_internal.h" |
| 35 | 35 | #include "libavutil/stereo3d.h" |
| 36 | +#include "libavutil/video_enc_params.h" | |
| 36 | 37 | |
| 37 | 38 | #include "avcodec.h" |
| 38 | 39 | #include "bytestream.h" |
| @@ -220,6 +220,7 @@ static int alloc_picture_tables(AVCodecContext *avctx, Picture *pic, int encodin · 219 unmodified lines | ||
| 220 | 220 | |
| 221 | 221 | pic->alloc_mb_width = mb_width; |
| 222 | 222 | pic->alloc_mb_height = mb_height; |
| 223 | + pic->alloc_mb_stride = mb_stride; | |
| 223 | 224 | |
| 224 | 225 | return 0; |
| 225 | 226 | } |
| @@ -346,6 +347,7 @@ int ff_update_picture_tables(Picture *dst, Picture *src) · 120 unmodified lines | ||
| 346 | 347 | |
| 347 | 348 | dst->alloc_mb_width = src->alloc_mb_width; |
| 348 | 349 | dst->alloc_mb_height = src->alloc_mb_height; |
| 350 | + dst->alloc_mb_stride = src->alloc_mb_stride; | |
| 349 | 351 | |
| 350 | 352 | return 0; |
| 351 | 353 | } |
| @@ -69,6 +69,7 @@ typedef struct Picture { · 68 unmodified lines | ||
| 69 | 69 | |
| 70 | 70 | int alloc_mb_width; ///< mb_width used to allocate tables |
| 71 | 71 | int alloc_mb_height; ///< mb_height used to allocate tables |
| 72 | + int alloc_mb_stride; ///< mb_stride used to allocate tables | |
| 72 | 73 | |
| 73 | 74 | AVBufferRef *mb_mean_buf; |
| 74 | 75 | uint8_t *mb_mean; ///< Table for MB luminance |
| @@ -32,6 +32,8 @@ · 31 unmodified lines | ||
| 32 | 32 | #include "libavutil/imgutils.h" |
| 33 | 33 | #include "libavutil/internal.h" |
| 34 | 34 | #include "libavutil/motion_vector.h" |
| 35 | +#include "libavutil/video_enc_params.h" | |
| 36 | + | |
| 35 | 37 | #include "avcodec.h" |
| 36 | 38 | #include "blockdsp.h" |
| 37 | 39 | #include "h264chroma.h" |
| @@ -1422,14 +1424,33 @@ void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict) · 1384 unmodified lines | ||
| 1422 | 1424 | |
| 1423 | 1425 | int 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); | |
| 1426 | − int offset = 2*s->mb_stride + 1; | |
| 1427 | − if(!ref) | |
| 1427 | + AVVideoEncParams *par; | |
| 1428 | + int mult = (qp_type == FF_QSCALE_TYPE_MPEG1) ? 2 : 1; | |
| 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 | 1437 | return AVERROR(ENOMEM); |
| 1429 | − av_assert0(ref->size >= offset + s->mb_stride * ((f->height+15)/16)); | |
| 1430 | − ref->size -= offset; | |
| 1431 | − ref->data += offset; | |
| 1432 | − return av_frame_set_qp_table(f, ref, s->mb_stride, qp_type); | |
| 1438 | + | |
| 1439 | + for (y = 0; y < p->alloc_mb_height; y++) | |
| 1440 | + for (x = 0; x < p->alloc_mb_width; x++) { | |
| 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 | |
| 1435 | 1456 | static inline int hpel_motion_lowres(MpegEncContext *s, |
| @@ -29,6 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | #include "libavutil/internal.h" |
| 30 | 30 | #include "libavutil/mem_internal.h" |
| 31 | 31 | #include "libavutil/thread.h" |
| 32 | +#include "libavutil/video_enc_params.h" | |
| 32 | 33 | |
| 33 | 34 | #include "avcodec.h" |
| 34 | 35 | #include "error_resilience.h" |
| @@ -79,7 +79,7 @@ · 78 unmodified lines | ||
| 79 | 79 | */ |
| 80 | 80 | |
| 81 | 81 | #define LIBAVUTIL_VERSION_MAJOR 56 |
| 82 | −#define LIBAVUTIL_VERSION_MINOR 62 | |
| 82 | +#define LIBAVUTIL_VERSION_MINOR 63 | |
| 83 | 83 | #define LIBAVUTIL_VERSION_MICRO 100 |
| 84 | 84 | |
| 85 | 85 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |
| @@ -55,6 +55,14 @@ enum AVVideoEncParamsType { · 54 unmodified lines | ||
| 55 | 55 | * as AVVideoBlockParams.qp_delta. |
| 56 | 56 | */ |
| 57 | 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 | /** |
| @@ -561,7 +561,7 @@ fate-filter-idet: CMD = framecrc -flags bitexact -idct simple -i $(SRC) -vf idet · 560 unmodified lines | ||
| 561 | 561 | FATE_FILTER_VSYNTH-$(CONFIG_PAD_FILTER) += fate-filter-pad |
| 562 | 562 | fate-filter-pad: CMD = video_filter "pad=iw*1.5:ih*1.5:iw*0.3:ih*0.2" |
| 563 | 563 | |
| 564 | −FATE_FILTER_PP = fate-filter-pp fate-filter-pp1 fate-filter-pp2 fate-filter-pp3 fate-filter-pp4 fate-filter-pp5 fate-filter-pp6 | |
| 564 | +#FATE_FILTER_PP = fate-filter-pp fate-filter-pp1 fate-filter-pp2 fate-filter-pp3 fate-filter-pp4 fate-filter-pp5 fate-filter-pp6 | |
| 565 | 565 | FATE_FILTER_VSYNTH-$(CONFIG_PP_FILTER) += $(FATE_FILTER_PP) |
| 566 | 566 | $(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 | ||
| 573 | 573 | fate-filter-pp5: CMD = video_filter "pp=md" |
| 574 | 574 | fate-filter-pp6: CMD = video_filter "pp=be/fd" |
| 575 | 575 | |
| 576 | −FATE_FILTER_VSYNTH-$(CONFIG_PP7_FILTER) += fate-filter-pp7 | |
| 576 | +#FATE_FILTER_VSYNTH-$(CONFIG_PP7_FILTER) += fate-filter-pp7 | |
| 577 | 577 | fate-filter-pp7: fate-vsynth1-mpeg4-qprd |
| 578 | 578 | fate-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 | |
| 580 | −FATE_FILTER_VSYNTH-$(CONFIG_SPP_FILTER) += fate-filter-spp | |
| 580 | +#FATE_FILTER_VSYNTH-$(CONFIG_SPP_FILTER) += fate-filter-spp | |
| 581 | 581 | fate-filter-spp: fate-vsynth1-mpeg4-qprd |
| 582 | 582 | fate-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 | |