From 69fae8524b9ef02cd2e3415ece1ae01dfc2b5426 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Tue, 13 Oct 2020 06:05:09 +0000 Subject: [PATCH] ffmpeg: update v4l2-request patch Patch created using revisions 922f5ee..fa7165e from branch v4l2-request-hwaccel-4.3.1 of https://github.com/Kwiboo/FFmpeg --- .../ffmpeg-001-v4l2-request.patch | 893 +++++++++++++++--- tools/ffmpeg/gen-patches.sh | 4 +- 2 files changed, 769 insertions(+), 128 deletions(-) diff --git a/packages/multimedia/ffmpeg/patches/v4l2-request/ffmpeg-001-v4l2-request.patch b/packages/multimedia/ffmpeg/patches/v4l2-request/ffmpeg-001-v4l2-request.patch index 7ef133994f..344fa1112e 100644 --- a/packages/multimedia/ffmpeg/patches/v4l2-request/ffmpeg-001-v4l2-request.patch +++ b/packages/multimedia/ffmpeg/patches/v4l2-request/ffmpeg-001-v4l2-request.patch @@ -1,7 +1,7 @@ -From df0e167bdb7db4cc2340ab831e6961a1108a753c Mon Sep 17 00:00:00 2001 +From 785728e72dbd513b58d97af2590fafba0f8a24bb Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Mon, 3 Dec 2018 23:48:04 +0100 -Subject: [PATCH 01/18] avutil: add av_buffer_pool_flush() +Subject: [PATCH 01/20] avutil: add av_buffer_pool_flush() Signed-off-by: Jonas Karlman --- @@ -10,7 +10,7 @@ Signed-off-by: Jonas Karlman 2 files changed, 18 insertions(+) diff --git a/libavutil/buffer.c b/libavutil/buffer.c -index 38a554208a..b0fedabc3e 100644 +index 38a554208a9..b0fedabc3e7 100644 --- a/libavutil/buffer.c +++ b/libavutil/buffer.c @@ -273,6 +273,19 @@ static void buffer_pool_free(AVBufferPool *pool) @@ -34,7 +34,7 @@ index 38a554208a..b0fedabc3e 100644 { AVBufferPool *pool; diff --git a/libavutil/buffer.h b/libavutil/buffer.h -index c0f3f6cc9a..998beec9ac 100644 +index c0f3f6cc9ab..998beec9ac5 100644 --- a/libavutil/buffer.h +++ b/libavutil/buffer.h @@ -267,6 +267,11 @@ AVBufferPool *av_buffer_pool_init2(int size, void *opaque, @@ -50,10 +50,10 @@ index c0f3f6cc9a..998beec9ac 100644 * Mark the pool as being available for freeing. It will actually be freed only * once all the allocated buffers associated with the pool are released. Thus it -From cdb4dbed4b223b9a21287cfcc594af99e7aa3990 Mon Sep 17 00:00:00 2001 +From abd5308771a71ba582155a1665a1c40878232040 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Sat, 15 Dec 2018 22:32:16 +0100 -Subject: [PATCH 02/18] Add common V4L2 request API code +Subject: [PATCH 02/20] Add common V4L2 request API code Signed-off-by: Jonas Karlman --- @@ -67,7 +67,7 @@ Signed-off-by: Jonas Karlman create mode 100644 libavcodec/v4l2_request.h diff --git a/configure b/configure -index 8569a60bf8..9f9909a236 100755 +index 8569a60bf82..9f9909a2369 100755 --- a/configure +++ b/configure @@ -274,6 +274,7 @@ External library support: @@ -139,7 +139,7 @@ index 8569a60bf8..9f9909a236 100755 test_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete diff --git a/libavcodec/Makefile b/libavcodec/Makefile -index 5a6ea59715..d742205168 100644 +index 5a6ea59715a..d7422051682 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -153,6 +153,7 @@ OBJS-$(CONFIG_VP3DSP) += vp3dsp.o @@ -151,7 +151,7 @@ index 5a6ea59715..d742205168 100644 OBJS-$(CONFIG_WMV2DSP) += wmv2dsp.o diff --git a/libavcodec/hwconfig.h b/libavcodec/hwconfig.h -index f421dc909f..ee78d8ab8e 100644 +index f421dc909f4..ee78d8ab8e8 100644 --- a/libavcodec/hwconfig.h +++ b/libavcodec/hwconfig.h @@ -80,6 +80,8 @@ typedef struct AVCodecHWConfigInternal { @@ -165,7 +165,7 @@ index f421dc909f..ee78d8ab8e 100644 &(const AVCodecHWConfigInternal) { \ diff --git a/libavcodec/v4l2_request.c b/libavcodec/v4l2_request.c new file mode 100644 -index 0000000000..7d97468153 +index 00000000000..5234b5049b0 --- /dev/null +++ b/libavcodec/v4l2_request.c @@ -0,0 +1,984 @@ @@ -683,16 +683,16 @@ index 0000000000..7d97468153 + goto fail; + } + -+ ret = v4l2_request_set_controls(ctx, -1, control, count); ++ ret = v4l2_request_set_format(avctx, ctx->output_type, pixelformat, buffersize); + if (ret < 0) { -+ av_log(avctx, AV_LOG_ERROR, "%s: set controls failed, %s (%d)\n", __func__, strerror(errno), errno); ++ av_log(avctx, AV_LOG_ERROR, "%s: set output format failed, %s (%d)\n", __func__, strerror(errno), errno); + ret = AVERROR(EINVAL); + goto fail; + } + -+ ret = v4l2_request_set_format(avctx, ctx->output_type, pixelformat, buffersize); ++ ret = v4l2_request_set_controls(ctx, -1, control, count); + if (ret < 0) { -+ av_log(avctx, AV_LOG_ERROR, "%s: set output format failed, %s (%d)\n", __func__, strerror(errno), errno); ++ av_log(avctx, AV_LOG_ERROR, "%s: set controls failed, %s (%d)\n", __func__, strerror(errno), errno); + ret = AVERROR(EINVAL); + goto fail; + } @@ -1155,7 +1155,7 @@ index 0000000000..7d97468153 +} diff --git a/libavcodec/v4l2_request.h b/libavcodec/v4l2_request.h new file mode 100644 -index 0000000000..58d2aa70af +index 00000000000..58d2aa70af8 --- /dev/null +++ b/libavcodec/v4l2_request.h @@ -0,0 +1,77 @@ @@ -1237,10 +1237,10 @@ index 0000000000..58d2aa70af + +#endif /* AVCODEC_V4L2_REQUEST_H */ -From ac7d0ac7775219d769deca3fb34c92b25411c947 Mon Sep 17 00:00:00 2001 +From e1ae7e32ce4798f3032a04ccb20a1f76834c3bea Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Sat, 15 Dec 2018 22:32:16 +0100 -Subject: [PATCH 03/18] Add V4L2 request API mpeg2 hwaccel +Subject: [PATCH 03/20] Add V4L2 request API mpeg2 hwaccel Signed-off-by: Jonas Karlman --- @@ -1253,7 +1253,7 @@ Signed-off-by: Jonas Karlman create mode 100644 libavcodec/v4l2_request_mpeg2.c diff --git a/configure b/configure -index 9f9909a236..6b157d6d3e 100755 +index 9f9909a2369..6b157d6d3ef 100755 --- a/configure +++ b/configure @@ -2967,6 +2967,8 @@ mpeg2_dxva2_hwaccel_deps="dxva2" @@ -1274,7 +1274,7 @@ index 9f9909a236..6b157d6d3e 100755 check_headers sys/videoio.h test_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete diff --git a/libavcodec/Makefile b/libavcodec/Makefile -index d742205168..8963bd3e91 100644 +index d7422051682..8963bd3e91c 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -922,6 +922,7 @@ OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL) += dxva2_mpeg2.o @@ -1286,7 +1286,7 @@ index d742205168..8963bd3e91 100644 OBJS-$(CONFIG_MPEG2_VDPAU_HWACCEL) += vdpau_mpeg12.o OBJS-$(CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h -index 6109c89bd6..172a546bb2 100644 +index 6109c89bd63..172a546bb28 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -47,6 +47,7 @@ extern const AVHWAccel ff_mpeg2_d3d11va_hwaccel; @@ -1298,7 +1298,7 @@ index 6109c89bd6..172a546bb2 100644 extern const AVHWAccel ff_mpeg2_vdpau_hwaccel; extern const AVHWAccel ff_mpeg2_videotoolbox_hwaccel; diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c -index 99e56532a5..15aaf97a34 100644 +index 99e56532a59..15aaf97a34c 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -1154,6 +1154,9 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = { @@ -1323,7 +1323,7 @@ index 99e56532a5..15aaf97a34 100644 }, diff --git a/libavcodec/v4l2_request_mpeg2.c b/libavcodec/v4l2_request_mpeg2.c new file mode 100644 -index 0000000000..88d86cc4c2 +index 00000000000..88d86cc4c23 --- /dev/null +++ b/libavcodec/v4l2_request_mpeg2.c @@ -0,0 +1,154 @@ @@ -1482,10 +1482,10 @@ index 0000000000..88d86cc4c2 + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; -From b22e02f5933366677620bac2583e2edec5c3007c Mon Sep 17 00:00:00 2001 +From 8a728ea300aee2fab7a181cab06c2c3cfdd0b705 Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sat, 15 Dec 2018 22:32:16 +0100 -Subject: [PATCH 04/18] Add V4L2 request API h264 hwaccel +Subject: [PATCH 04/20] Add V4L2 request API h264 hwaccel Signed-off-by: Jernej Skrabec Signed-off-by: Jonas Karlman @@ -1500,7 +1500,7 @@ Signed-off-by: Jonas Karlman create mode 100644 libavcodec/v4l2_request_h264.c diff --git a/configure b/configure -index 6b157d6d3e..1a7720ebe3 100755 +index 6b157d6d3ef..1a7720ebe3b 100755 --- a/configure +++ b/configure @@ -2925,6 +2925,8 @@ h264_dxva2_hwaccel_deps="dxva2" @@ -1521,7 +1521,7 @@ index 6b157d6d3e..1a7720ebe3 100755 check_headers sys/videoio.h diff --git a/libavcodec/Makefile b/libavcodec/Makefile -index 8963bd3e91..9a10a292e3 100644 +index 8963bd3e91c..9a10a292e37 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -903,6 +903,7 @@ OBJS-$(CONFIG_H264_D3D11VA_HWACCEL) += dxva2_h264.o @@ -1533,7 +1533,7 @@ index 8963bd3e91..9a10a292e3 100644 OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o OBJS-$(CONFIG_H264_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c -index db8363e4cc..3ae11ac8a7 100644 +index db8363e4cc9..3ae11ac8a71 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -759,6 +759,7 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) @@ -1555,7 +1555,7 @@ index db8363e4cc..3ae11ac8a7 100644 if (h->avctx->codec->pix_fmts) choices = h->avctx->codec->pix_fmts; diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c -index 5eedeb3c27..a504c89565 100644 +index 5eedeb3c275..a504c89565c 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -1102,6 +1102,9 @@ AVCodec ff_h264_decoder = { @@ -1569,7 +1569,7 @@ index 5eedeb3c27..a504c89565 100644 NULL }, diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h -index 172a546bb2..44e00e79b5 100644 +index 172a546bb28..44e00e79b51 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -27,6 +27,7 @@ extern const AVHWAccel ff_h264_d3d11va_hwaccel; @@ -1582,7 +1582,7 @@ index 172a546bb2..44e00e79b5 100644 extern const AVHWAccel ff_h264_videotoolbox_hwaccel; diff --git a/libavcodec/v4l2_request_h264.c b/libavcodec/v4l2_request_h264.c new file mode 100644 -index 0000000000..94b9aca8ad +index 00000000000..94b9aca8ad4 --- /dev/null +++ b/libavcodec/v4l2_request_h264.c @@ -0,0 +1,460 @@ @@ -2047,10 +2047,10 @@ index 0000000000..94b9aca8ad + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; -From c804445e166d743ce41831556c968ed9e3a414f5 Mon Sep 17 00:00:00 2001 +From 72758190a3d062b64db756c60761187a2b9ce1c9 Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sat, 15 Dec 2018 22:32:16 +0100 -Subject: [PATCH 05/18] Add V4L2 request API hevc hwaccel +Subject: [PATCH 05/20] Add V4L2 request API hevc hwaccel Signed-off-by: Jernej Skrabec Signed-off-by: Jonas Karlman @@ -2064,7 +2064,7 @@ Signed-off-by: Jonas Karlman create mode 100644 libavcodec/v4l2_request_hevc.c diff --git a/configure b/configure -index 1a7720ebe3..58abd99335 100755 +index 1a7720ebe3b..58abd99335b 100755 --- a/configure +++ b/configure @@ -2941,6 +2941,8 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" @@ -2085,7 +2085,7 @@ index 1a7720ebe3..58abd99335 100755 check_headers sys/videoio.h diff --git a/libavcodec/Makefile b/libavcodec/Makefile -index 9a10a292e3..5d0e1d7dae 100644 +index 9a10a292e37..5d0e1d7dae7 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -911,6 +911,7 @@ OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL) += dxva2_hevc.o @@ -2097,7 +2097,7 @@ index 9a10a292e3..5d0e1d7dae 100644 OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL) += nvdec_mjpeg.o diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c -index 0772608a30..d01b7b34bc 100644 +index 0772608a30e..d01b7b34bce 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -372,6 +372,7 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) @@ -2139,7 +2139,7 @@ index 0772608a30..d01b7b34bc 100644 NULL }, diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h -index 44e00e79b5..e2f90a5fdd 100644 +index 44e00e79b51..e2f90a5fdd5 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -35,6 +35,7 @@ extern const AVHWAccel ff_hevc_d3d11va_hwaccel; @@ -2152,7 +2152,7 @@ index 44e00e79b5..e2f90a5fdd 100644 extern const AVHWAccel ff_hevc_videotoolbox_hwaccel; diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c new file mode 100644 -index 0000000000..f724909546 +index 00000000000..f7249095465 --- /dev/null +++ b/libavcodec/v4l2_request_hevc.c @@ -0,0 +1,533 @@ @@ -2690,10 +2690,10 @@ index 0000000000..f724909546 + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; -From 11f2c3d30ce6085ef1510f51481852bab1380ecd Mon Sep 17 00:00:00 2001 +From ebc06b180bfc3c4c6e02cfe2f559e140ce0020e8 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 22 May 2019 14:46:58 +0200 -Subject: [PATCH 06/18] Add V4L2 request API vp8 hwaccel +Subject: [PATCH 06/20] Add V4L2 request API vp8 hwaccel Need to fix the STREAMOFF/STREAMON issue in a proper way. @@ -2709,7 +2709,7 @@ Signed-off-by: Ezequiel Garcia create mode 100644 libavcodec/v4l2_request_vp8.c diff --git a/configure b/configure -index 58abd99335..cbb91c2bca 100755 +index 58abd99335b..cbb91c2bca4 100755 --- a/configure +++ b/configure @@ -3003,6 +3003,8 @@ vc1_vdpau_hwaccel_deps="vdpau" @@ -2730,7 +2730,7 @@ index 58abd99335..cbb91c2bca 100755 check_headers sys/videoio.h test_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete diff --git a/libavcodec/Makefile b/libavcodec/Makefile -index 5d0e1d7dae..d6af854daa 100644 +index 5d0e1d7dae7..d6af854daaa 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -940,6 +940,7 @@ OBJS-$(CONFIG_VC1_QSV_HWACCEL) += qsvdec_other.o @@ -2742,7 +2742,7 @@ index 5d0e1d7dae..d6af854daa 100644 OBJS-$(CONFIG_VP9_D3D11VA_HWACCEL) += dxva2_vp9.o OBJS-$(CONFIG_VP9_DXVA2_HWACCEL) += dxva2_vp9.o diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h -index e2f90a5fdd..bd75e94f4c 100644 +index e2f90a5fdd5..bd75e94f4ca 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -65,6 +65,7 @@ extern const AVHWAccel ff_vc1_nvdec_hwaccel; @@ -2755,7 +2755,7 @@ index e2f90a5fdd..bd75e94f4c 100644 extern const AVHWAccel ff_vp9_d3d11va2_hwaccel; diff --git a/libavcodec/v4l2_request_vp8.c b/libavcodec/v4l2_request_vp8.c new file mode 100644 -index 0000000000..7e75ee398a +index 00000000000..7e75ee398a2 --- /dev/null +++ b/libavcodec/v4l2_request_vp8.c @@ -0,0 +1,180 @@ @@ -2940,7 +2940,7 @@ index 0000000000..7e75ee398a + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c -index bab4223aca..0e1edb46fb 100644 +index bab4223aca1..0e1edb46fb2 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -175,6 +175,9 @@ static enum AVPixelFormat get_pixel_format(VP8Context *s) @@ -2973,10 +2973,10 @@ index bab4223aca..0e1edb46fb 100644 NULL }, -From d1cbb6de7dd7462fb696160612ae45623c61265c Mon Sep 17 00:00:00 2001 +From cf21ba63945bf6a0a60616ceb0a000e42d02f044 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Wed, 20 Feb 2019 11:18:00 -0300 -Subject: [PATCH 07/18] avcodec/h264: parse idr_pic_id +Subject: [PATCH 07/20] avcodec/h264: parse idr_pic_id Signed-off-by: Ezequiel Garcia --- @@ -2986,7 +2986,7 @@ Signed-off-by: Ezequiel Garcia 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c -index 3ae11ac8a7..96e8edd102 100644 +index 3ae11ac8a71..96e8edd1028 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1822,7 +1822,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, @@ -2999,7 +2999,7 @@ index 3ae11ac8a7..96e8edd102 100644 if (sps->poc_type == 0) { sl->poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb); diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h -index a419615124..aebc5ed2f6 100644 +index a419615124b..aebc5ed2f61 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -190,6 +190,8 @@ typedef struct H264SliceContext { @@ -3012,7 +3012,7 @@ index a419615124..aebc5ed2f6 100644 int chroma_qp[2]; // QPc int qp_thresh; ///< QP threshold to skip loopfilter diff --git a/libavcodec/v4l2_request_h264.c b/libavcodec/v4l2_request_h264.c -index 94b9aca8ad..9382e573b4 100644 +index 94b9aca8ad4..9382e573b40 100644 --- a/libavcodec/v4l2_request_h264.c +++ b/libavcodec/v4l2_request_h264.c @@ -303,7 +303,7 @@ static int v4l2_request_h264_decode_slice(AVCodecContext *avctx, const uint8_t * @@ -3025,10 +3025,10 @@ index 94b9aca8ad..9382e573b4 100644 .delta_pic_order_cnt_bottom = sl->delta_poc_bottom, .delta_pic_order_cnt0 = sl->delta_poc[0], -From 88da95ec126bdf5ffbc4399c7e453a2248e79119 Mon Sep 17 00:00:00 2001 +From 13d2f3430db4d83ce30c921bf2b3ee44e1d6ec55 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 22 May 2019 14:44:22 +0200 -Subject: [PATCH 08/18] avcodec/h264: parse ref_pic_marking_size_in_bits and +Subject: [PATCH 08/20] avcodec/h264: parse ref_pic_marking_size_in_bits and pic_order_cnt_bit_size Signed-off-by: Boris Brezillon @@ -3039,7 +3039,7 @@ Signed-off-by: Boris Brezillon 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c -index 96e8edd102..c3896cfd90 100644 +index 96e8edd1028..c3896cfd90a 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1740,7 +1740,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, @@ -3080,7 +3080,7 @@ index 96e8edd102..c3896cfd90 100644 if (sl->slice_type_nos != AV_PICTURE_TYPE_I && pps->cabac) { diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h -index aebc5ed2f6..b3dcd6e7da 100644 +index aebc5ed2f61..b3dcd6e7da3 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -330,11 +330,13 @@ typedef struct H264SliceContext { @@ -3098,7 +3098,7 @@ index aebc5ed2f6..b3dcd6e7da 100644 int max_pic_num; } H264SliceContext; diff --git a/libavcodec/v4l2_request_h264.c b/libavcodec/v4l2_request_h264.c -index 9382e573b4..bdaeb67d26 100644 +index 9382e573b40..bdaeb67d261 100644 --- a/libavcodec/v4l2_request_h264.c +++ b/libavcodec/v4l2_request_h264.c @@ -311,9 +311,9 @@ static int v4l2_request_h264_decode_slice(AVCodecContext *avctx, const uint8_t * @@ -3114,10 +3114,10 @@ index 9382e573b4..bdaeb67d26 100644 .cabac_init_idc = sl->cabac_init_idc, .slice_qp_delta = sl->qscale - pps->init_qp, -From afd9b1ffb7a2805423d888c49ea13ee5ffc95994 Mon Sep 17 00:00:00 2001 +From 5ba945f011277dee7b4fb36af60810fd9b401f79 Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Thu, 14 Feb 2019 23:20:05 +0100 -Subject: [PATCH 09/18] Add and use private linux headers for V4L2 request API +Subject: [PATCH 09/20] Add and use private linux headers for V4L2 request API ctrls Signed-off-by: Jernej Skrabec @@ -3138,7 +3138,7 @@ Signed-off-by: Jernej Skrabec create mode 100644 libavcodec/vp8-ctrls.h diff --git a/configure b/configure -index cbb91c2bca..623012757c 100755 +index cbb91c2bca4..623012757c6 100755 --- a/configure +++ b/configure @@ -2925,7 +2925,7 @@ h264_dxva2_hwaccel_deps="dxva2" @@ -3170,7 +3170,7 @@ index cbb91c2bca..623012757c 100755 vp8_vaapi_hwaccel_select="vp8_decoder" diff --git a/libavcodec/h264-ctrls.h b/libavcodec/h264-ctrls.h new file mode 100644 -index 0000000000..e877bf1d53 +index 00000000000..e877bf1d537 --- /dev/null +++ b/libavcodec/h264-ctrls.h @@ -0,0 +1,210 @@ @@ -3386,7 +3386,7 @@ index 0000000000..e877bf1d53 +#endif diff --git a/libavcodec/hevc-ctrls.h b/libavcodec/hevc-ctrls.h new file mode 100644 -index 0000000000..1009cf0891 +index 00000000000..1009cf0891c --- /dev/null +++ b/libavcodec/hevc-ctrls.h @@ -0,0 +1,212 @@ @@ -3604,7 +3604,7 @@ index 0000000000..1009cf0891 +#endif diff --git a/libavcodec/mpeg2-ctrls.h b/libavcodec/mpeg2-ctrls.h new file mode 100644 -index 0000000000..6601455b3d +index 00000000000..6601455b3d5 --- /dev/null +++ b/libavcodec/mpeg2-ctrls.h @@ -0,0 +1,82 @@ @@ -3691,7 +3691,7 @@ index 0000000000..6601455b3d + +#endif diff --git a/libavcodec/v4l2_request_h264.c b/libavcodec/v4l2_request_h264.c -index bdaeb67d26..0254716e52 100644 +index bdaeb67d261..0254716e523 100644 --- a/libavcodec/v4l2_request_h264.c +++ b/libavcodec/v4l2_request_h264.c @@ -19,6 +19,7 @@ @@ -3703,7 +3703,7 @@ index bdaeb67d26..0254716e52 100644 typedef struct V4L2RequestControlsH264 { struct v4l2_ctrl_h264_sps sps; diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c -index f724909546..c16f8a868e 100644 +index f7249095465..c16f8a868e3 100644 --- a/libavcodec/v4l2_request_hevc.c +++ b/libavcodec/v4l2_request_hevc.c @@ -19,6 +19,7 @@ @@ -3715,7 +3715,7 @@ index f724909546..c16f8a868e 100644 #define MAX_SLICES 16 diff --git a/libavcodec/v4l2_request_mpeg2.c b/libavcodec/v4l2_request_mpeg2.c -index 88d86cc4c2..bc251a6fd2 100644 +index 88d86cc4c23..bc251a6fd2c 100644 --- a/libavcodec/v4l2_request_mpeg2.c +++ b/libavcodec/v4l2_request_mpeg2.c @@ -19,6 +19,7 @@ @@ -3727,7 +3727,7 @@ index 88d86cc4c2..bc251a6fd2 100644 typedef struct V4L2RequestControlsMPEG2 { struct v4l2_ctrl_mpeg2_slice_params slice_params; diff --git a/libavcodec/v4l2_request_vp8.c b/libavcodec/v4l2_request_vp8.c -index 7e75ee398a..ea2c55fa2f 100644 +index 7e75ee398a2..ea2c55fa2f5 100644 --- a/libavcodec/v4l2_request_vp8.c +++ b/libavcodec/v4l2_request_vp8.c @@ -19,6 +19,7 @@ @@ -3740,7 +3740,7 @@ index 7e75ee398a..ea2c55fa2f 100644 struct v4l2_ctrl_vp8_frame_header ctrl; diff --git a/libavcodec/vp8-ctrls.h b/libavcodec/vp8-ctrls.h new file mode 100644 -index 0000000000..53cba826e4 +index 00000000000..53cba826e48 --- /dev/null +++ b/libavcodec/vp8-ctrls.h @@ -0,0 +1,112 @@ @@ -3857,10 +3857,10 @@ index 0000000000..53cba826e4 + +#endif -From 4b5474250e1adb4931afb6418403def0d914aaea Mon Sep 17 00:00:00 2001 +From 77c91a97c87424c1d6bff888bc8562a9b6697aa2 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Sat, 2 May 2020 11:00:26 +0000 -Subject: [PATCH 10/18] Update to v5.7 private linux headers +Subject: [PATCH 10/20] Update to v5.7 private linux headers --- libavcodec/h264-ctrls.h | 2 ++ @@ -3868,7 +3868,7 @@ Subject: [PATCH 10/18] Update to v5.7 private linux headers 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264-ctrls.h b/libavcodec/h264-ctrls.h -index e877bf1d53..1c6ff7d63b 100644 +index e877bf1d537..1c6ff7d63bc 100644 --- a/libavcodec/h264-ctrls.h +++ b/libavcodec/h264-ctrls.h @@ -185,6 +185,8 @@ struct v4l2_ctrl_h264_slice_params { @@ -3881,7 +3881,7 @@ index e877bf1d53..1c6ff7d63b 100644 struct v4l2_h264_dpb_entry { __u64 reference_ts; diff --git a/libavcodec/v4l2_request_h264.c b/libavcodec/v4l2_request_h264.c -index 0254716e52..d28ed07da3 100644 +index 0254716e523..d28ed07da3b 100644 --- a/libavcodec/v4l2_request_h264.c +++ b/libavcodec/v4l2_request_h264.c @@ -67,8 +67,14 @@ static void fill_dpb_entry(struct v4l2_h264_dpb_entry *entry, const H264Picture @@ -3901,17 +3901,17 @@ index 0254716e52..d28ed07da3 100644 entry->flags |= V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM; if (pic->field_poc[0] != INT_MAX) -From 5044b279b44f20c58cb92600d751984de6c8111c Mon Sep 17 00:00:00 2001 +From 40407184ac1cd48d35acc6b0d8bdec48a98c74fb Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Sat, 2 May 2020 22:03:42 +0000 -Subject: [PATCH 11/18] Update to v5.8 private linux headers +Subject: [PATCH 11/20] Update to v5.8 private linux headers --- libavcodec/h264-ctrls.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264-ctrls.h b/libavcodec/h264-ctrls.h -index 1c6ff7d63b..080fd1293c 100644 +index 1c6ff7d63bc..080fd1293c4 100644 --- a/libavcodec/h264-ctrls.h +++ b/libavcodec/h264-ctrls.h @@ -13,6 +13,12 @@ @@ -3937,10 +3937,561 @@ index 1c6ff7d63b..080fd1293c 100644 __u16 nal_ref_idc; __s32 top_field_order_cnt; -From 3503a60af592944589b2beae7ce004884dfe04e2 Mon Sep 17 00:00:00 2001 +From 6a151e35d99c430030709b49a6abd36349a65887 Mon Sep 17 00:00:00 2001 +From: Jonas Karlman +Date: Sun, 6 Sep 2020 16:07:13 +0000 +Subject: [PATCH 12/20] Update to v5.10 private linux headers + +--- + libavcodec/h264-ctrls.h | 87 +++++++++------- + libavcodec/v4l2_request_h264.c | 182 ++++++++++++++++----------------- + 2 files changed, 136 insertions(+), 133 deletions(-) + +diff --git a/libavcodec/h264-ctrls.h b/libavcodec/h264-ctrls.h +index 080fd1293c4..ec479915443 100644 +--- a/libavcodec/h264-ctrls.h ++++ b/libavcodec/h264-ctrls.h +@@ -19,6 +19,8 @@ + */ + #define V4L2_H264_NUM_DPB_ENTRIES 16 + ++#define V4L2_H264_REF_LIST_LEN (2 * V4L2_H264_NUM_DPB_ENTRIES) ++ + /* Our pixel format isn't stable at the moment */ + #define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4') /* H264 parsed slices */ + +@@ -34,6 +36,7 @@ + #define V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS (V4L2_CID_MPEG_BASE+1004) + #define V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE (V4L2_CID_MPEG_BASE+1005) + #define V4L2_CID_MPEG_VIDEO_H264_START_CODE (V4L2_CID_MPEG_BASE+1006) ++#define V4L2_CID_MPEG_VIDEO_H264_PRED_WEIGHTS (V4L2_CID_MPEG_BASE+1007) + + /* enum v4l2_ctrl_type type values */ + #define V4L2_CTRL_TYPE_H264_SPS 0x0110 +@@ -41,6 +44,7 @@ + #define V4L2_CTRL_TYPE_H264_SCALING_MATRIX 0x0112 + #define V4L2_CTRL_TYPE_H264_SLICE_PARAMS 0x0113 + #define V4L2_CTRL_TYPE_H264_DECODE_PARAMS 0x0114 ++#define V4L2_CTRL_TYPE_H264_PRED_WEIGHTS 0x0115 + + enum v4l2_mpeg_video_h264_decode_mode { + V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED, +@@ -95,7 +99,7 @@ struct v4l2_ctrl_h264_sps { + #define V4L2_H264_PPS_FLAG_CONSTRAINED_INTRA_PRED 0x0010 + #define V4L2_H264_PPS_FLAG_REDUNDANT_PIC_CNT_PRESENT 0x0020 + #define V4L2_H264_PPS_FLAG_TRANSFORM_8X8_MODE 0x0040 +-#define V4L2_H264_PPS_FLAG_PIC_SCALING_MATRIX_PRESENT 0x0080 ++#define V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT 0x0080 + + struct v4l2_ctrl_h264_pps { + __u8 pic_parameter_set_id; +@@ -123,7 +127,14 @@ struct v4l2_h264_weight_factors { + __s16 chroma_offset[32][2]; + }; + +-struct v4l2_h264_pred_weight_table { ++#define V4L2_H264_CTRL_PRED_WEIGHTS_REQUIRED(pps, slice) \ ++ ((((pps)->flags & V4L2_H264_PPS_FLAG_WEIGHTED_PRED) && \ ++ ((slice)->slice_type == V4L2_H264_SLICE_TYPE_P || \ ++ (slice)->slice_type == V4L2_H264_SLICE_TYPE_SP)) || \ ++ ((pps)->weighted_bipred_idc == 1 && \ ++ (slice)->slice_type == V4L2_H264_SLICE_TYPE_B)) ++ ++struct v4l2_ctrl_h264_pred_weights { + __u16 luma_log2_weight_denom; + __u16 chroma_log2_weight_denom; + struct v4l2_h264_weight_factors weight_factors[2]; +@@ -135,39 +146,29 @@ struct v4l2_h264_pred_weight_table { + #define V4L2_H264_SLICE_TYPE_SP 3 + #define V4L2_H264_SLICE_TYPE_SI 4 + +-#define V4L2_H264_SLICE_FLAG_FIELD_PIC 0x01 +-#define V4L2_H264_SLICE_FLAG_BOTTOM_FIELD 0x02 +-#define V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED 0x04 +-#define V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH 0x08 ++#define V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED 0x01 ++#define V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH 0x02 + +-struct v4l2_ctrl_h264_slice_params { +- /* Size in bytes, including header */ +- __u32 size; ++#define V4L2_H264_TOP_FIELD_REF 0x1 ++#define V4L2_H264_BOTTOM_FIELD_REF 0x2 ++#define V4L2_H264_FRAME_REF 0x3 + +- /* Offset in bytes to the start of slice in the OUTPUT buffer. */ +- __u32 start_byte_offset; ++struct v4l2_h264_reference { ++ __u8 fields; ++ ++ /* Index into v4l2_ctrl_h264_decode_params.dpb[] */ ++ __u8 index; ++}; + ++struct v4l2_ctrl_h264_slice_params { + /* Offset in bits to slice_data() from the beginning of this slice. */ + __u32 header_bit_size; + +- __u16 first_mb_in_slice; ++ __u32 first_mb_in_slice; ++ + __u8 slice_type; +- __u8 pic_parameter_set_id; + __u8 colour_plane_id; + __u8 redundant_pic_cnt; +- __u16 frame_num; +- __u16 idr_pic_id; +- __u16 pic_order_cnt_lsb; +- __s32 delta_pic_order_cnt_bottom; +- __s32 delta_pic_order_cnt0; +- __s32 delta_pic_order_cnt1; +- +- struct v4l2_h264_pred_weight_table pred_weight_table; +- /* Size in bits of dec_ref_pic_marking() syntax element. */ +- __u32 dec_ref_pic_marking_bit_size; +- /* Size in bits of pic order count syntax. */ +- __u32 pic_order_cnt_bit_size; +- + __u8 cabac_init_idc; + __s8 slice_qp_delta; + __s8 slice_qs_delta; +@@ -176,14 +177,11 @@ struct v4l2_ctrl_h264_slice_params { + __s8 slice_beta_offset_div2; + __u8 num_ref_idx_l0_active_minus1; + __u8 num_ref_idx_l1_active_minus1; +- __u32 slice_group_change_cycle; + +- /* +- * Entries on each list are indices into +- * v4l2_ctrl_h264_decode_params.dpb[]. +- */ +- __u8 ref_pic_list0[32]; +- __u8 ref_pic_list1[32]; ++ __u8 reserved; ++ ++ struct v4l2_h264_reference ref_pic_list0[V4L2_H264_REF_LIST_LEN]; ++ struct v4l2_h264_reference ref_pic_list1[V4L2_H264_REF_LIST_LEN]; + + __u32 flags; + }; +@@ -192,26 +190,41 @@ struct v4l2_ctrl_h264_slice_params { + #define V4L2_H264_DPB_ENTRY_FLAG_ACTIVE 0x02 + #define V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM 0x04 + #define V4L2_H264_DPB_ENTRY_FLAG_FIELD 0x08 +-#define V4L2_H264_DPB_ENTRY_FLAG_BOTTOM_FIELD 0x10 + + struct v4l2_h264_dpb_entry { + __u64 reference_ts; ++ __u32 pic_num; + __u16 frame_num; +- __u16 pic_num; ++ __u8 fields; ++ __u8 reserved[5]; + /* Note that field is indicated by v4l2_buffer.field */ + __s32 top_field_order_cnt; + __s32 bottom_field_order_cnt; + __u32 flags; /* V4L2_H264_DPB_ENTRY_FLAG_* */ + }; + +-#define V4L2_H264_DECODE_PARAM_FLAG_IDR_PIC 0x01 ++#define V4L2_H264_DECODE_PARAM_FLAG_IDR_PIC 0x01 ++#define V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC 0x02 ++#define V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD 0x04 + + struct v4l2_ctrl_h264_decode_params { + struct v4l2_h264_dpb_entry dpb[V4L2_H264_NUM_DPB_ENTRIES]; +- __u16 num_slices; + __u16 nal_ref_idc; ++ __u16 frame_num; + __s32 top_field_order_cnt; + __s32 bottom_field_order_cnt; ++ __u16 idr_pic_id; ++ __u16 pic_order_cnt_lsb; ++ __s32 delta_pic_order_cnt_bottom; ++ __s32 delta_pic_order_cnt0; ++ __s32 delta_pic_order_cnt1; ++ /* Size in bits of dec_ref_pic_marking() syntax element. */ ++ __u32 dec_ref_pic_marking_bit_size; ++ /* Size in bits of pic order count syntax. */ ++ __u32 pic_order_cnt_bit_size; ++ __u32 slice_group_change_cycle; ++ ++ __u32 reserved; + __u32 flags; /* V4L2_H264_DECODE_PARAM_FLAG_* */ + }; + +diff --git a/libavcodec/v4l2_request_h264.c b/libavcodec/v4l2_request_h264.c +index d28ed07da3b..c9dbaf8c3e3 100644 +--- a/libavcodec/v4l2_request_h264.c ++++ b/libavcodec/v4l2_request_h264.c +@@ -26,15 +26,17 @@ typedef struct V4L2RequestControlsH264 { + struct v4l2_ctrl_h264_pps pps; + struct v4l2_ctrl_h264_scaling_matrix scaling_matrix; + struct v4l2_ctrl_h264_decode_params decode_params; +- struct v4l2_ctrl_h264_slice_params slice_params[MAX_SLICES]; ++ struct v4l2_ctrl_h264_slice_params slice_params; ++ struct v4l2_ctrl_h264_pred_weights pred_weights; ++ int pred_weights_required; + int first_slice; ++ int num_slices; + } V4L2RequestControlsH264; + + typedef struct V4L2RequestContextH264 { + V4L2RequestContext base; + int decode_mode; + int start_code; +- int max_slices; + } V4L2RequestContextH264; + + static uint8_t nalu_slice_start_code[] = { 0x00, 0x00, 0x01 }; +@@ -64,19 +66,16 @@ static void fill_weight_factors(struct v4l2_h264_weight_factors *factors, int li + static void fill_dpb_entry(struct v4l2_h264_dpb_entry *entry, const H264Picture *pic) + { + entry->reference_ts = ff_v4l2_request_get_capture_timestamp(pic->f); +- entry->frame_num = pic->frame_num; + entry->pic_num = pic->pic_id; ++ entry->frame_num = pic->frame_num; ++ entry->fields = pic->reference & V4L2_H264_FRAME_REF; + entry->flags = V4L2_H264_DPB_ENTRY_FLAG_VALID; +- if (pic->reference) { ++ if (entry->fields) + entry->flags |= V4L2_H264_DPB_ENTRY_FLAG_ACTIVE; +- if (pic->reference != PICT_FRAME) { +- entry->flags |= V4L2_H264_DPB_ENTRY_FLAG_FIELD; +- if (pic->reference == PICT_BOTTOM_FIELD) +- entry->flags |= V4L2_H264_DPB_ENTRY_FLAG_BOTTOM_FIELD; +- } +- } + if (pic->long_ref) + entry->flags |= V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM; ++ if (pic->field_picture) ++ entry->flags |= V4L2_H264_DPB_ENTRY_FLAG_FIELD; + if (pic->field_poc[0] != INT_MAX) + entry->top_field_order_cnt = pic->field_poc[0]; + if (pic->field_poc[1] != INT_MAX) +@@ -103,23 +102,24 @@ static void fill_dpb(struct v4l2_ctrl_h264_decode_params *decode, const H264Cont + } + } + +-static uint8_t get_dpb_index(struct v4l2_ctrl_h264_decode_params *decode, const H264Ref *ref) ++static void fill_ref_list(struct v4l2_h264_reference *reference, struct v4l2_ctrl_h264_decode_params *decode, const H264Ref *ref) + { + uint64_t timestamp; + + if (!ref->parent) +- return 0; ++ return; + + timestamp = ff_v4l2_request_get_capture_timestamp(ref->parent->f); + + for (uint8_t i = 0; i < FF_ARRAY_ELEMS(decode->dpb); i++) { + struct v4l2_h264_dpb_entry *entry = &decode->dpb[i]; + if ((entry->flags & V4L2_H264_DPB_ENTRY_FLAG_VALID) && +- entry->reference_ts == timestamp) +- return i; ++ entry->reference_ts == timestamp) { ++ reference->fields = ref->reference & V4L2_H264_FRAME_REF; ++ reference->index = i; ++ return; ++ } + } +- +- return 0; + } + + static void fill_sps(struct v4l2_ctrl_h264_sps *ctrl, const H264Context *h) +@@ -139,13 +139,15 @@ static void fill_sps(struct v4l2_ctrl_h264_sps *ctrl, const H264Context *h) + .log2_max_pic_order_cnt_lsb_minus4 = sps->log2_max_poc_lsb - 4, + .max_num_ref_frames = sps->ref_frame_count, + .num_ref_frames_in_pic_order_cnt_cycle = sps->poc_cycle_length, +- //.offset_for_ref_frame[255] - not required? not set by libva-v4l2-request - copy sps->offset_for_ref_frame + .offset_for_non_ref_pic = sps->offset_for_non_ref_pic, + .offset_for_top_to_bottom_field = sps->offset_for_top_to_bottom_field, + .pic_width_in_mbs_minus1 = h->mb_width - 1, + .pic_height_in_map_units_minus1 = sps->frame_mbs_only_flag ? h->mb_height - 1 : h->mb_height / 2 - 1, + }; + ++ if (sps->poc_cycle_length > 0 && sps->poc_cycle_length <= 255) ++ memcpy(ctrl->offset_for_ref_frame, sps->offset_for_ref_frame, sps->poc_cycle_length * sizeof(ctrl->offset_for_ref_frame[0])); ++ + if (sps->residual_color_transform_flag) + ctrl->flags |= V4L2_H264_SPS_FLAG_SEPARATE_COLOUR_PLANE; + if (sps->transform_bypass) +@@ -196,6 +198,9 @@ static void fill_pps(struct v4l2_ctrl_h264_pps *ctrl, const H264Context *h) + ctrl->flags |= V4L2_H264_PPS_FLAG_REDUNDANT_PIC_CNT_PRESENT; + if (pps->transform_8x8_mode) + ctrl->flags |= V4L2_H264_PPS_FLAG_TRANSFORM_8X8_MODE; ++ ++ /* FFmpeg always provide a scaling matrix */ ++ ctrl->flags |= V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT; + } + + static int v4l2_request_h264_start_frame(AVCodecContext *avctx, +@@ -205,6 +210,7 @@ static int v4l2_request_h264_start_frame(AVCodecContext *avctx, + const H264Context *h = avctx->priv_data; + const PPS *pps = h->ps.pps; + const SPS *sps = h->ps.sps; ++ const H264SliceContext *sl = &h->slice_ctx[0]; + V4L2RequestControlsH264 *controls = h->cur_pic_ptr->hwaccel_picture_private; + + fill_sps(&controls->sps, h); +@@ -222,18 +228,33 @@ static int v4l2_request_h264_start_frame(AVCodecContext *avctx, + } + + controls->decode_params = (struct v4l2_ctrl_h264_decode_params) { +- .num_slices = 0, + .nal_ref_idc = h->nal_ref_idc, ++ .frame_num = h->poc.frame_num, + .top_field_order_cnt = h->cur_pic_ptr->field_poc[0] != INT_MAX ? h->cur_pic_ptr->field_poc[0] : 0, + .bottom_field_order_cnt = h->cur_pic_ptr->field_poc[1] != INT_MAX ? h->cur_pic_ptr->field_poc[1] : 0, ++ .idr_pic_id = sl->idr_pic_id, ++ .pic_order_cnt_lsb = sl->poc_lsb, ++ .delta_pic_order_cnt_bottom = sl->delta_poc_bottom, ++ .delta_pic_order_cnt0 = sl->delta_poc[0], ++ .delta_pic_order_cnt1 = sl->delta_poc[1], ++ /* Size in bits of dec_ref_pic_marking() syntax element. */ ++ .dec_ref_pic_marking_bit_size = sl->ref_pic_marking_size_in_bits, ++ /* Size in bits of pic order count syntax. */ ++ .pic_order_cnt_bit_size = sl->pic_order_cnt_bit_size, ++ .slice_group_change_cycle = 0, /* slice group not supported by FFmpeg */ + }; + + if (h->picture_idr) + controls->decode_params.flags |= V4L2_H264_DECODE_PARAM_FLAG_IDR_PIC; ++ if (FIELD_PICTURE(h)) ++ controls->decode_params.flags |= V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC; ++ if (h->picture_structure == PICT_BOTTOM_FIELD) ++ controls->decode_params.flags |= V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD; + + fill_dpb(&controls->decode_params, h); + + controls->first_slice = !FIELD_PICTURE(h) || h->first_field; ++ controls->num_slices = 0; + + return ff_v4l2_request_reset_frame(avctx, h->cur_pic_ptr->f); + } +@@ -260,22 +281,29 @@ static int v4l2_request_h264_queue_decode(AVCodecContext *avctx, int last_slice) + .ptr = &controls->scaling_matrix, + .size = sizeof(controls->scaling_matrix), + }, ++ { ++ .id = V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS, ++ .ptr = &controls->decode_params, ++ .size = sizeof(controls->decode_params), ++ }, + { + .id = V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS, + .ptr = &controls->slice_params, +- .size = sizeof(controls->slice_params[0]) * FFMAX(FFMIN(controls->decode_params.num_slices, MAX_SLICES), ctx->max_slices), ++ .size = sizeof(controls->slice_params), + }, + { +- .id = V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS, +- .ptr = &controls->decode_params, +- .size = sizeof(controls->decode_params), ++ .id = V4L2_CID_MPEG_VIDEO_H264_PRED_WEIGHTS, ++ .ptr = &controls->pred_weights, ++ .size = sizeof(controls->pred_weights), + }, + }; + +- if (ctx->decode_mode == V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED) +- return ff_v4l2_request_decode_slice(avctx, h->cur_pic_ptr->f, control, FF_ARRAY_ELEMS(control), controls->first_slice, last_slice); ++ if (ctx->decode_mode == V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED) { ++ int count = FF_ARRAY_ELEMS(control) - (controls->pred_weights_required ? 0 : 1); ++ return ff_v4l2_request_decode_slice(avctx, h->cur_pic_ptr->f, control, count, controls->first_slice, last_slice); ++ } + +- return ff_v4l2_request_decode_frame(avctx, h->cur_pic_ptr->f, control, FF_ARRAY_ELEMS(control)); ++ return ff_v4l2_request_decode_frame(avctx, h->cur_pic_ptr->f, control, FF_ARRAY_ELEMS(control) - 2); + } + + static int v4l2_request_h264_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) +@@ -285,89 +313,72 @@ static int v4l2_request_h264_decode_slice(AVCodecContext *avctx, const uint8_t * + const H264SliceContext *sl = &h->slice_ctx[0]; + V4L2RequestControlsH264 *controls = h->cur_pic_ptr->hwaccel_picture_private; + V4L2RequestContextH264 *ctx = avctx->internal->hwaccel_priv_data; +- V4L2RequestDescriptor *req = (V4L2RequestDescriptor*)h->cur_pic_ptr->f->data[0]; +- int i, ret, count, slice = FFMIN(controls->decode_params.num_slices, MAX_SLICES - 1); ++ int i, ret, count; + +- if (ctx->decode_mode == V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED && slice) { ++ if (ctx->decode_mode == V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED && controls->num_slices) { + ret = v4l2_request_h264_queue_decode(avctx, 0); + if (ret) + return ret; + + ff_v4l2_request_reset_frame(avctx, h->cur_pic_ptr->f); +- slice = controls->decode_params.num_slices = 0; + controls->first_slice = 0; + } + +- controls->slice_params[slice] = (struct v4l2_ctrl_h264_slice_params) { +- /* Size in bytes, including header */ +- .size = 0, +- .start_byte_offset = req->output.used, ++ if (ctx->start_code == V4L2_MPEG_VIDEO_H264_START_CODE_ANNEX_B) { ++ ret = ff_v4l2_request_append_output_buffer(avctx, h->cur_pic_ptr->f, nalu_slice_start_code, 3); ++ if (ret) ++ return ret; ++ } ++ ++ ret = ff_v4l2_request_append_output_buffer(avctx, h->cur_pic_ptr->f, buffer, size); ++ if (ret) ++ return ret; ++ ++ if (ctx->decode_mode != V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED) ++ return 0; ++ ++ controls->slice_params = (struct v4l2_ctrl_h264_slice_params) { + /* Offset in bits to slice_data() from the beginning of this slice. */ + .header_bit_size = get_bits_count(&sl->gb), + + .first_mb_in_slice = sl->first_mb_addr, ++ + .slice_type = ff_h264_get_slice_type(sl), +- .pic_parameter_set_id = sl->pps_id, +- .colour_plane_id = 0, /* what is this? */ +- .frame_num = h->poc.frame_num, +- .idr_pic_id = sl->idr_pic_id, +- .pic_order_cnt_lsb = sl->poc_lsb, +- .delta_pic_order_cnt_bottom = sl->delta_poc_bottom, +- .delta_pic_order_cnt0 = sl->delta_poc[0], +- .delta_pic_order_cnt1 = sl->delta_poc[1], ++ .colour_plane_id = 0, /* separate colour plane not supported by FFmpeg */ + .redundant_pic_cnt = sl->redundant_pic_count, +- +- /* Size in bits of dec_ref_pic_marking() syntax element. */ +- .dec_ref_pic_marking_bit_size = sl->ref_pic_marking_size_in_bits, +- /* Size in bits of pic order count syntax. */ +- .pic_order_cnt_bit_size = sl->pic_order_cnt_bit_size, +- + .cabac_init_idc = sl->cabac_init_idc, + .slice_qp_delta = sl->qscale - pps->init_qp, +- .slice_qs_delta = 0, /* XXX not implemented by FFmpeg */ ++ .slice_qs_delta = 0, /* not implemented by FFmpeg */ + .disable_deblocking_filter_idc = sl->deblocking_filter < 2 ? !sl->deblocking_filter : sl->deblocking_filter, + .slice_alpha_c0_offset_div2 = sl->slice_alpha_c0_offset / 2, + .slice_beta_offset_div2 = sl->slice_beta_offset / 2, +- .slice_group_change_cycle = 0, /* what is this? */ +- + .num_ref_idx_l0_active_minus1 = sl->list_count > 0 ? sl->ref_count[0] - 1 : 0, + .num_ref_idx_l1_active_minus1 = sl->list_count > 1 ? sl->ref_count[1] - 1 : 0, + }; + +- if (FIELD_PICTURE(h)) +- controls->slice_params[slice].flags |= V4L2_H264_SLICE_FLAG_FIELD_PIC; +- if (h->picture_structure == PICT_BOTTOM_FIELD) +- controls->slice_params[slice].flags |= V4L2_H264_SLICE_FLAG_BOTTOM_FIELD; + if (sl->slice_type == AV_PICTURE_TYPE_B && sl->direct_spatial_mv_pred) +- controls->slice_params[slice].flags |= V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED; ++ controls->slice_params.flags |= V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED; ++ /* V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH: not implemented by FFmpeg */ + +- controls->slice_params[slice].pred_weight_table.chroma_log2_weight_denom = sl->pwt.chroma_log2_weight_denom; +- controls->slice_params[slice].pred_weight_table.luma_log2_weight_denom = sl->pwt.luma_log2_weight_denom; ++ controls->pred_weights_required = V4L2_H264_CTRL_PRED_WEIGHTS_REQUIRED(&controls->pps, &controls->slice_params); ++ if (controls->pred_weights_required) { ++ controls->pred_weights.chroma_log2_weight_denom = sl->pwt.chroma_log2_weight_denom; ++ controls->pred_weights.luma_log2_weight_denom = sl->pwt.luma_log2_weight_denom; ++ } + + count = sl->list_count > 0 ? sl->ref_count[0] : 0; + for (i = 0; i < count; i++) +- controls->slice_params[slice].ref_pic_list0[i] = get_dpb_index(&controls->decode_params, &sl->ref_list[0][i]); +- if (count) +- fill_weight_factors(&controls->slice_params[slice].pred_weight_table.weight_factors[0], 0, sl); ++ fill_ref_list(&controls->slice_params.ref_pic_list0[i], &controls->decode_params, &sl->ref_list[0][i]); ++ if (count && controls->pred_weights_required) ++ fill_weight_factors(&controls->pred_weights.weight_factors[0], 0, sl); + + count = sl->list_count > 1 ? sl->ref_count[1] : 0; + for (i = 0; i < count; i++) +- controls->slice_params[slice].ref_pic_list1[i] = get_dpb_index(&controls->decode_params, &sl->ref_list[1][i]); +- if (count) +- fill_weight_factors(&controls->slice_params[slice].pred_weight_table.weight_factors[1], 1, sl); +- +- if (ctx->start_code == V4L2_MPEG_VIDEO_H264_START_CODE_ANNEX_B) { +- ret = ff_v4l2_request_append_output_buffer(avctx, h->cur_pic_ptr->f, nalu_slice_start_code, 3); +- if (ret) +- return ret; +- } ++ fill_ref_list(&controls->slice_params.ref_pic_list1[i], &controls->decode_params, &sl->ref_list[1][i]); ++ if (count && controls->pred_weights_required) ++ fill_weight_factors(&controls->pred_weights.weight_factors[1], 1, sl); + +- ret = ff_v4l2_request_append_output_buffer(avctx, h->cur_pic_ptr->f, buffer, size); +- if (ret) +- return ret; +- +- controls->slice_params[slice].size = req->output.used - controls->slice_params[slice].start_byte_offset; +- controls->decode_params.num_slices++; ++ controls->num_slices++; + return 0; + } + +@@ -380,15 +391,11 @@ static int v4l2_request_h264_end_frame(AVCodecContext *avctx) + static int v4l2_request_h264_set_controls(AVCodecContext *avctx) + { + V4L2RequestContextH264 *ctx = avctx->internal->hwaccel_priv_data; +- int ret; + + struct v4l2_ext_control control[] = { + { .id = V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE, }, + { .id = V4L2_CID_MPEG_VIDEO_H264_START_CODE, }, + }; +- struct v4l2_query_ext_ctrl slice_params = { +- .id = V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS, +- }; + + ctx->decode_mode = ff_v4l2_request_query_control_default_value(avctx, V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE); + if (ctx->decode_mode != V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED && +@@ -404,16 +411,6 @@ static int v4l2_request_h264_set_controls(AVCodecContext *avctx) + return AVERROR(EINVAL); + } + +- ret = ff_v4l2_request_query_control(avctx, &slice_params); +- if (ret) +- return ret; +- +- ctx->max_slices = slice_params.elems; +- if (ctx->max_slices > MAX_SLICES) { +- av_log(avctx, AV_LOG_ERROR, "%s: unsupported max slices, %d\n", __func__, ctx->max_slices); +- return AVERROR(EINVAL); +- } +- + control[0].value = ctx->decode_mode; + control[1].value = ctx->start_code; + +@@ -424,7 +421,6 @@ static int v4l2_request_h264_init(AVCodecContext *avctx) + { + const H264Context *h = avctx->priv_data; + struct v4l2_ctrl_h264_sps sps; +- struct v4l2_ctrl_h264_pps pps; + int ret; + + struct v4l2_ext_control control[] = { +@@ -433,15 +429,9 @@ static int v4l2_request_h264_init(AVCodecContext *avctx) + .ptr = &sps, + .size = sizeof(sps), + }, +- { +- .id = V4L2_CID_MPEG_VIDEO_H264_PPS, +- .ptr = &pps, +- .size = sizeof(pps), +- }, + }; + + fill_sps(&sps, h); +- fill_pps(&pps, h); + + ret = ff_v4l2_request_init(avctx, V4L2_PIX_FMT_H264_SLICE, 4 * 1024 * 1024, control, FF_ARRAY_ELEMS(control)); + if (ret) + +From f9f4a89058a6fac25712cc385eab72f70e9ac4c8 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Mon, 29 Apr 2019 22:08:59 +0000 -Subject: [PATCH 12/18] HACK: hwcontext_drm: do not require drm device +Subject: [PATCH 13/20] HACK: hwcontext_drm: do not require drm device Signed-off-by: Jonas Karlman --- @@ -3948,7 +4499,7 @@ Signed-off-by: Jonas Karlman 1 file changed, 5 insertions(+) diff --git a/libavutil/hwcontext_drm.c b/libavutil/hwcontext_drm.c -index 32cbde82eb..aa4794c5e6 100644 +index 32cbde82ebf..aa4794c5e66 100644 --- a/libavutil/hwcontext_drm.c +++ b/libavutil/hwcontext_drm.c @@ -43,6 +43,11 @@ static int drm_device_create(AVHWDeviceContext *hwdev, const char *device, @@ -3964,36 +4515,10 @@ index 32cbde82eb..aa4794c5e6 100644 if (hwctx->fd < 0) return AVERROR(errno); -From 9e5907d59c23f5ccd4c48cfe37775411ce308107 Mon Sep 17 00:00:00 2001 +From 027f8c90ec25c42899b24d96b434e6ed1a1a8c40 Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sat, 15 Dec 2018 22:32:16 +0100 -Subject: [PATCH 13/18] WIP: h264 field reference - -Signed-off-by: Jernej Skrabec -Signed-off-by: Jonas Karlman ---- - libavcodec/v4l2_request_h264.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/libavcodec/v4l2_request_h264.c b/libavcodec/v4l2_request_h264.c -index d28ed07da3..5b0f21a60d 100644 ---- a/libavcodec/v4l2_request_h264.c -+++ b/libavcodec/v4l2_request_h264.c -@@ -116,7 +116,8 @@ static uint8_t get_dpb_index(struct v4l2_ctrl_h264_decode_params *decode, const - struct v4l2_h264_dpb_entry *entry = &decode->dpb[i]; - if ((entry->flags & V4L2_H264_DPB_ENTRY_FLAG_VALID) && - entry->reference_ts == timestamp) -- return i; -+ // TODO: signal reference type, possible using top 2 bits -+ return i | ((ref->reference & 3) << 6); - } - - return 0; - -From 9cf9b825c33690656331a9693b3132d1d82b75a8 Mon Sep 17 00:00:00 2001 -From: Jernej Skrabec -Date: Sat, 15 Dec 2018 22:32:16 +0100 -Subject: [PATCH 14/18] WIP: hevc scaling matrix +Subject: [PATCH 14/20] WIP: hevc scaling matrix Signed-off-by: Jernej Skrabec --- @@ -4002,7 +4527,7 @@ Signed-off-by: Jernej Skrabec 2 files changed, 33 insertions(+) diff --git a/libavcodec/hevc-ctrls.h b/libavcodec/hevc-ctrls.h -index 1009cf0891..1592e52c36 100644 +index 1009cf0891c..1592e52c361 100644 --- a/libavcodec/hevc-ctrls.h +++ b/libavcodec/hevc-ctrls.h @@ -19,6 +19,7 @@ @@ -4036,7 +4561,7 @@ index 1009cf0891..1592e52c36 100644 + #endif diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c -index c16f8a868e..f400bf4f3c 100644 +index c16f8a868e3..f400bf4f3c8 100644 --- a/libavcodec/v4l2_request_hevc.c +++ b/libavcodec/v4l2_request_hevc.c @@ -26,6 +26,7 @@ @@ -4083,10 +4608,10 @@ index c16f8a868e..f400bf4f3c 100644 .id = V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS, .ptr = &controls->slice_params, -From 572a336f459070be3ac0ecc15a11057c6be6cb61 Mon Sep 17 00:00:00 2001 +From 9c4a66cca0df6fd0976f907f1e315a715e5ffd87 Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sat, 15 Dec 2018 22:32:16 +0100 -Subject: [PATCH 15/18] WIP: hevc segment address +Subject: [PATCH 15/20] WIP: hevc segment address Signed-off-by: Jernej Skrabec --- @@ -4095,7 +4620,7 @@ Signed-off-by: Jernej Skrabec 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/hevc-ctrls.h b/libavcodec/hevc-ctrls.h -index 1592e52c36..3e2e320983 100644 +index 1592e52c361..3e2e3209831 100644 --- a/libavcodec/hevc-ctrls.h +++ b/libavcodec/hevc-ctrls.h @@ -167,6 +167,9 @@ struct v4l2_ctrl_hevc_slice_params { @@ -4118,7 +4643,7 @@ index 1592e52c36..3e2e320983 100644 /* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */ struct v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c -index f400bf4f3c..98222fc74c 100644 +index f400bf4f3c8..98222fc74c3 100644 --- a/libavcodec/v4l2_request_hevc.c +++ b/libavcodec/v4l2_request_hevc.c @@ -138,6 +138,9 @@ static void v4l2_request_hevc_fill_slice_params(const HEVCContext *h, @@ -4132,10 +4657,10 @@ index f400bf4f3c..98222fc74c 100644 .nal_unit_type = h->nal_unit_type, .nuh_temporal_id_plus1 = h->temporal_id + 1, -From 8777f29fef8e41f305ecf54dbc9908fca2e5d98a Mon Sep 17 00:00:00 2001 +From 62795e555cfcccfc29c144f0ed5acae5336479c7 Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sat, 15 Dec 2018 22:32:16 +0100 -Subject: [PATCH 16/18] WIP: hevc entry point offsets +Subject: [PATCH 16/20] WIP: hevc entry point offsets Signed-off-by: Jernej Skrabec --- @@ -4144,7 +4669,7 @@ Signed-off-by: Jernej Skrabec 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libavcodec/hevc-ctrls.h b/libavcodec/hevc-ctrls.h -index 3e2e320983..d1b094c8aa 100644 +index 3e2e3209831..d1b094c8aae 100644 --- a/libavcodec/hevc-ctrls.h +++ b/libavcodec/hevc-ctrls.h @@ -169,6 +169,7 @@ struct v4l2_ctrl_hevc_slice_params { @@ -4167,7 +4692,7 @@ index 3e2e320983..d1b094c8aa 100644 /* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */ struct v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c -index 98222fc74c..7e77c83e4e 100644 +index 98222fc74c3..7e77c83e4e4 100644 --- a/libavcodec/v4l2_request_hevc.c +++ b/libavcodec/v4l2_request_hevc.c @@ -225,6 +225,15 @@ static void v4l2_request_hevc_fill_slice_params(const HEVCContext *h, @@ -4187,10 +4712,10 @@ index 98222fc74c..7e77c83e4e 100644 static void fill_sps(struct v4l2_ctrl_hevc_sps *ctrl, const HEVCContext *h) -From 931d210b66a033eed21dab4be65ae93f2198d9b5 Mon Sep 17 00:00:00 2001 +From edaaede001e7fbae26a0a668ea1db2b642896322 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 12 Dec 2019 16:13:55 +0100 -Subject: [PATCH 17/18] WIP: Add V4L2 request API vp9 hwaccel +Subject: [PATCH 17/20] WIP: Add V4L2 request API vp9 hwaccel Signed-off-by: Boris Brezillon --- @@ -4204,7 +4729,7 @@ Signed-off-by: Boris Brezillon create mode 100644 libavcodec/v4l2_request_vp9.c diff --git a/configure b/configure -index 623012757c..2b723df55a 100755 +index 623012757c6..2b723df55ae 100755 --- a/configure +++ b/configure @@ -3015,6 +3015,8 @@ vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9" @@ -4225,7 +4750,7 @@ index 623012757c..2b723df55a 100755 check_headers sys/videoio.h test_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete diff --git a/libavcodec/Makefile b/libavcodec/Makefile -index d6af854daa..2f0e0a0976 100644 +index d6af854daaa..2f0e0a0976f 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -945,6 +945,7 @@ OBJS-$(CONFIG_VP8_VAAPI_HWACCEL) += vaapi_vp8.o @@ -4237,7 +4762,7 @@ index d6af854daa..2f0e0a0976 100644 OBJS-$(CONFIG_VP9_VDPAU_HWACCEL) += vdpau_vp9.o OBJS-$(CONFIG_VP8_QSV_HWACCEL) += qsvdec_other.o diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h -index bd75e94f4c..03a1aefe09 100644 +index bd75e94f4ca..03a1aefe09b 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -71,6 +71,7 @@ extern const AVHWAccel ff_vp9_d3d11va_hwaccel; @@ -4250,7 +4775,7 @@ index bd75e94f4c..03a1aefe09 100644 extern const AVHWAccel ff_wmv3_d3d11va_hwaccel; diff --git a/libavcodec/v4l2_request_vp9.c b/libavcodec/v4l2_request_vp9.c new file mode 100644 -index 0000000000..4074c7fe4b +index 00000000000..4074c7fe4b8 --- /dev/null +++ b/libavcodec/v4l2_request_vp9.c @@ -0,0 +1,352 @@ @@ -4607,7 +5132,7 @@ index 0000000000..4074c7fe4b + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c -index fd0bab14a2..434f905c62 100644 +index fd0bab14a23..434f905c62c 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -191,6 +191,7 @@ static int update_size(AVCodecContext *avctx, int w, int h) @@ -4659,7 +5184,7 @@ index fd0bab14a2..434f905c62 100644 NULL }, diff --git a/libavcodec/vp9shared.h b/libavcodec/vp9shared.h -index 54726df742..fee3568736 100644 +index 54726df742f..fee3568736f 100644 --- a/libavcodec/vp9shared.h +++ b/libavcodec/vp9shared.h @@ -131,6 +131,7 @@ typedef struct VP9BitstreamHeader { @@ -4671,10 +5196,10 @@ index 54726df742..fee3568736 100644 uint8_t pred_prob[3]; struct { -From 3e956323f01b221d7a38ad0a3293d337cd106f3f Mon Sep 17 00:00:00 2001 +From ef82ae9fffba44e88d59a3fa4b958a38d1b5cd9e Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 12 Dec 2019 16:13:55 +0100 -Subject: [PATCH 18/18] WIP: Add and use vp9 private linux header +Subject: [PATCH 18/20] WIP: Add and use vp9 private linux header Signed-off-by: Boris Brezillon --- @@ -4685,7 +5210,7 @@ Signed-off-by: Boris Brezillon create mode 100644 libavcodec/vp9-ctrls.h diff --git a/configure b/configure -index 2b723df55a..87c6836af2 100755 +index 2b723df55ae..87c6836af27 100755 --- a/configure +++ b/configure @@ -3015,7 +3015,7 @@ vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9" @@ -4698,7 +5223,7 @@ index 2b723df55a..87c6836af2 100755 vp9_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferVP9_bit_depth" vp9_vaapi_hwaccel_select="vp9_decoder" diff --git a/libavcodec/v4l2_request_vp9.c b/libavcodec/v4l2_request_vp9.c -index 4074c7fe4b..2e10b7ad1a 100644 +index 4074c7fe4b8..2e10b7ad1ac 100644 --- a/libavcodec/v4l2_request_vp9.c +++ b/libavcodec/v4l2_request_vp9.c @@ -19,6 +19,7 @@ @@ -4711,7 +5236,7 @@ index 4074c7fe4b..2e10b7ad1a 100644 struct v4l2_ctrl_vp9_frame_decode_params decode_params; diff --git a/libavcodec/vp9-ctrls.h b/libavcodec/vp9-ctrls.h new file mode 100644 -index 0000000000..0cdea8a18b +index 00000000000..0cdea8a18b7 --- /dev/null +++ b/libavcodec/vp9-ctrls.h @@ -0,0 +1,485 @@ @@ -5200,3 +5725,119 @@ index 0000000000..0cdea8a18b +}; + +#endif /* _VP9_CTRLS_H_ */ + +From 4b268a93e5945dc7863a8dc953a12fa157b4f8e6 Mon Sep 17 00:00:00 2001 +From: Jonas Karlman +Date: Fri, 15 May 2020 16:54:05 +0000 +Subject: [PATCH 19/20] WIP: add NV15 and NV20 support + +Signed-off-by: Jonas Karlman +--- + libavcodec/h264_slice.c | 14 ++++++++++++-- + libavcodec/v4l2_request.c | 23 +++++++++++++++++++++++ + 2 files changed, 35 insertions(+), 2 deletions(-) + +diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c +index c3896cfd90a..39ae8fabfd3 100644 +--- a/libavcodec/h264_slice.c ++++ b/libavcodec/h264_slice.c +@@ -785,10 +785,17 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) + *fmt++ = AV_PIX_FMT_GBRP10; + } else + *fmt++ = AV_PIX_FMT_YUV444P10; +- } else if (CHROMA422(h)) ++ } else if (CHROMA422(h)) { ++#if CONFIG_H264_V4L2REQUEST_HWACCEL ++ *fmt++ = AV_PIX_FMT_DRM_PRIME; ++#endif + *fmt++ = AV_PIX_FMT_YUV422P10; +- else ++ } else { ++#if CONFIG_H264_V4L2REQUEST_HWACCEL ++ *fmt++ = AV_PIX_FMT_DRM_PRIME; ++#endif + *fmt++ = AV_PIX_FMT_YUV420P10; ++ } + break; + case 12: + if (CHROMA444(h)) { +@@ -827,6 +834,9 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) + else + *fmt++ = AV_PIX_FMT_YUV444P; + } else if (CHROMA422(h)) { ++#if CONFIG_H264_V4L2REQUEST_HWACCEL ++ *fmt++ = AV_PIX_FMT_DRM_PRIME; ++#endif + if (h->avctx->color_range == AVCOL_RANGE_JPEG) + *fmt++ = AV_PIX_FMT_YUVJ422P; + else +diff --git a/libavcodec/v4l2_request.c b/libavcodec/v4l2_request.c +index 5234b5049b0..0b294feff2e 100644 +--- a/libavcodec/v4l2_request.c ++++ b/libavcodec/v4l2_request.c +@@ -188,6 +188,13 @@ const uint32_t v4l2_request_capture_pixelformats[] = { + #ifdef DRM_FORMAT_MOD_ALLWINNER_TILED + V4L2_PIX_FMT_SUNXI_TILED_NV12, + #endif ++#if defined(V4L2_PIX_FMT_NV15) && defined(DRM_FORMAT_NV15) ++ V4L2_PIX_FMT_NV15, ++#endif ++ V4L2_PIX_FMT_NV16, ++#if defined(V4L2_PIX_FMT_NV20) && defined(DRM_FORMAT_NV20) ++ V4L2_PIX_FMT_NV20, ++#endif + }; + + static int v4l2_request_set_drm_descriptor(V4L2RequestDescriptor *req, struct v4l2_format *format) +@@ -206,6 +213,22 @@ static int v4l2_request_set_drm_descriptor(V4L2RequestDescriptor *req, struct v4 + layer->format = DRM_FORMAT_NV12; + desc->objects[0].format_modifier = DRM_FORMAT_MOD_ALLWINNER_TILED; + break; ++#endif ++#if defined(V4L2_PIX_FMT_NV15) && defined(DRM_FORMAT_NV15) ++ case V4L2_PIX_FMT_NV15: ++ layer->format = DRM_FORMAT_NV15; ++ desc->objects[0].format_modifier = DRM_FORMAT_MOD_LINEAR; ++ break; ++#endif ++ case V4L2_PIX_FMT_NV16: ++ layer->format = DRM_FORMAT_NV16; ++ desc->objects[0].format_modifier = DRM_FORMAT_MOD_LINEAR; ++ break; ++#if defined(V4L2_PIX_FMT_NV20) && defined(DRM_FORMAT_NV20) ++ case V4L2_PIX_FMT_NV20: ++ layer->format = DRM_FORMAT_NV20; ++ desc->objects[0].format_modifier = DRM_FORMAT_MOD_LINEAR; ++ break; + #endif + default: + return -1; + +From fa7165e391287bf970569e36b0b19bff947b084f Mon Sep 17 00:00:00 2001 +From: Jonas Karlman +Date: Mon, 27 Jul 2020 23:15:45 +0000 +Subject: [PATCH 20/20] HACK: define drm NV15 and NV20 format + +--- + libavcodec/v4l2_request.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/libavcodec/v4l2_request.c b/libavcodec/v4l2_request.c +index 0b294feff2e..a8f0ee79eee 100644 +--- a/libavcodec/v4l2_request.c ++++ b/libavcodec/v4l2_request.c +@@ -30,6 +30,14 @@ + #include "internal.h" + #include "v4l2_request.h" + ++#ifndef DRM_FORMAT_NV15 ++#define DRM_FORMAT_NV15 fourcc_code('N', 'V', '1', '5') ++#endif ++ ++#ifndef DRM_FORMAT_NV20 ++#define DRM_FORMAT_NV20 fourcc_code('N', 'V', '2', '0') ++#endif ++ + uint64_t ff_v4l2_request_get_capture_timestamp(AVFrame *frame) + { + V4L2RequestDescriptor *req = (V4L2RequestDescriptor*)frame->data[0]; diff --git a/tools/ffmpeg/gen-patches.sh b/tools/ffmpeg/gen-patches.sh index 48ace62349..082590de27 100755 --- a/tools/ffmpeg/gen-patches.sh +++ b/tools/ffmpeg/gen-patches.sh @@ -2,7 +2,7 @@ # base ffmpeg version KODI_FFMPEG_REPO="https://github.com/xbmc/FFmpeg" -KODI_FFMPEG_VERSION="4.3-Matrix-Alpha1" +KODI_FFMPEG_VERSION="4.3.1-Matrix-Alpha1-1" ALL_FEATURE_SETS="v4l2-drmprime v4l2-request libreelec rpi" @@ -29,7 +29,7 @@ create_patch() { ;; v4l2-request) REPO="https://github.com/Kwiboo/FFmpeg" - REFSPEC="v4l2-request-hwaccel-4.3" + REFSPEC="v4l2-request-hwaccel-4.3.1" ;; libreelec) REPO="https://github.com/LibreELEC/FFmpeg"