From 5c23848068e1f7866e86eda319430fd717d9ebf5 Mon Sep 17 00:00:00 2001 From: Matthias Reichl Date: Sat, 1 Apr 2023 17:46:49 +0200 Subject: [PATCH] ffmpeg: update v4l2-request patch Patch created using revisions ea3d24b..fe61bbb from branch v4l2-request-n6.0 of https://github.com/jernejsk/FFmpeg --- .../ffmpeg-001-v4l2-request.patch | 356 +++++++++--------- 1 file changed, 178 insertions(+), 178 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 4e2bff5f77..fa9c9cad20 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,4 +1,4 @@ -From baea39c4a1898a8eb89548196722ae56b1e27515 Mon Sep 17 00:00:00 2001 +From 61a3cdcb354186f574bf3220de0472370fa53ccd Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Mon, 3 Dec 2018 23:48:04 +0100 Subject: [PATCH 01/13] avutil: add av_buffer_pool_flush() @@ -12,7 +12,7 @@ Signed-off-by: Jonas Karlman 2 files changed, 18 insertions(+) diff --git a/libavutil/buffer.c b/libavutil/buffer.c -index 54590be566..1af892b348 100644 +index e4562a79b1..09da632c00 100644 --- a/libavutil/buffer.c +++ b/libavutil/buffer.c @@ -319,6 +319,19 @@ static void buffer_pool_free(AVBufferPool *pool) @@ -52,7 +52,7 @@ index e1ef5b7f07..fde9bae4f6 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 91c471c226611f23d0eb07a7c5975470a01be985 Mon Sep 17 00:00:00 2001 +From 3fe3baf21ef5c934699bfc0aefb4b2b4180c2c72 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Sat, 15 Dec 2018 22:32:16 +0100 Subject: [PATCH 02/13] Add common V4L2 request API code @@ -70,7 +70,7 @@ Signed-off-by: Alex Bee create mode 100644 libavcodec/v4l2_request.h diff --git a/configure b/configure -index ba5793b2ff..0ccfd0ac36 100755 +index b6616f00b6..6167b122e0 100755 --- a/configure +++ b/configure @@ -281,6 +281,7 @@ External library support: @@ -81,7 +81,7 @@ index ba5793b2ff..0ccfd0ac36 100755 --enable-libv4l2 enable libv4l2/v4l-utils [no] --enable-libvidstab enable video stabilization using vid.stab [no] --enable-libvmaf enable vmaf filter via libvmaf [no] -@@ -349,6 +350,7 @@ External library support: +@@ -350,6 +351,7 @@ External library support: --enable-omx-rpi enable OpenMAX IL code for Raspberry Pi [no] --enable-rkmpp enable Rockchip Media Process Platform code [no] --disable-v4l2-m2m disable V4L2 mem2mem code [autodetect] @@ -89,7 +89,7 @@ index ba5793b2ff..0ccfd0ac36 100755 --disable-vaapi disable Video Acceleration API (mainly Unix/Intel) code [autodetect] --disable-vdpau disable Nvidia Video Decode and Presentation API for Unix code [autodetect] --disable-videotoolbox disable VideoToolbox code [autodetect] -@@ -1869,6 +1871,7 @@ EXTERNAL_LIBRARY_LIST=" +@@ -1857,6 +1859,7 @@ EXTERNAL_LIBRARY_LIST=" libtheora libtwolame libuavs3d @@ -97,7 +97,7 @@ index ba5793b2ff..0ccfd0ac36 100755 libv4l2 libvmaf libvorbis -@@ -1924,6 +1927,7 @@ HWACCEL_LIBRARY_LIST=" +@@ -1913,6 +1916,7 @@ HWACCEL_LIBRARY_LIST=" mmal omx opencl @@ -105,7 +105,7 @@ index ba5793b2ff..0ccfd0ac36 100755 " DOCUMENT_LIST=" -@@ -3011,6 +3015,7 @@ d3d11va_deps="dxva_h ID3D11VideoDecoder ID3D11VideoContext" +@@ -2999,6 +3003,7 @@ d3d11va_deps="dxva_h ID3D11VideoDecoder ID3D11VideoContext" dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32 user32" ffnvcodec_deps_any="libdl LoadLibrary" nvdec_deps="ffnvcodec" @@ -113,7 +113,7 @@ index ba5793b2ff..0ccfd0ac36 100755 vaapi_x11_deps="xlib_x11" videotoolbox_hwaccel_deps="videotoolbox pthreads" videotoolbox_hwaccel_extralibs="-framework QuartzCore" -@@ -6634,6 +6639,7 @@ enabled libtwolame && require libtwolame twolame.h twolame_init -ltwolame +@@ -6692,6 +6697,7 @@ enabled libtwolame && require libtwolame twolame.h twolame_init -ltwolame { check_lib libtwolame twolame.h twolame_encode_buffer_float32_interleaved -ltwolame || die "ERROR: libtwolame must be installed and version must be >= 0.3.10"; } enabled libuavs3d && require_pkg_config libuavs3d "uavs3d >= 1.1.41" uavs3d.h uavs3d_decode @@ -121,7 +121,7 @@ index ba5793b2ff..0ccfd0ac36 100755 enabled libv4l2 && require_pkg_config libv4l2 libv4l2 libv4l2.h v4l2_ioctl enabled libvidstab && require_pkg_config libvidstab "vidstab >= 0.98" vid.stab/libvidstab.h vsMotionDetectInit enabled libvmaf && require_pkg_config libvmaf "libvmaf >= 2.0.0" libvmaf.h vmaf_init -@@ -6735,6 +6741,10 @@ enabled rkmpp && { require_pkg_config rkmpp rockchip_mpp rockchip/r +@@ -6794,6 +6800,10 @@ enabled rkmpp && { require_pkg_config rkmpp rockchip_mpp rockchip/r { enabled libdrm || die "ERROR: rkmpp requires --enable-libdrm"; } } @@ -132,7 +132,7 @@ index ba5793b2ff..0ccfd0ac36 100755 enabled vapoursynth && require_pkg_config vapoursynth "vapoursynth-script >= 42" VSScript.h vsscript_init -@@ -6817,6 +6827,8 @@ if enabled v4l2_m2m; then +@@ -6876,6 +6886,8 @@ if enabled v4l2_m2m; then check_cc vp9_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;" fi @@ -142,10 +142,10 @@ index ba5793b2ff..0ccfd0ac36 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 457ec58377..3cb7dede11 100644 +index 389253f5d0..0148242ed0 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile -@@ -162,6 +162,7 @@ OBJS-$(CONFIG_VP3DSP) += vp3dsp.o +@@ -170,6 +170,7 @@ OBJS-$(CONFIG_VP3DSP) += vp3dsp.o OBJS-$(CONFIG_VP56DSP) += vp56dsp.o OBJS-$(CONFIG_VP8DSP) += vp8dsp.o OBJS-$(CONFIG_V4L2_M2M) += v4l2_m2m.o v4l2_context.o v4l2_buffers.o v4l2_fmt.o @@ -1279,7 +1279,7 @@ index 0000000000..58d2aa70af + +#endif /* AVCODEC_V4L2_REQUEST_H */ -From 1aa288b7f95876298e88eff71af50c350a51f30a Mon Sep 17 00:00:00 2001 +From 04ba66bab9951753498cb21080b53826dcec7a26 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 22 May 2019 14:44:22 +0200 Subject: [PATCH 03/13] h264dec: add ref_pic_marking and pic_order_cnt bit_size @@ -1295,10 +1295,10 @@ Signed-off-by: Jonas Karlman 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c -index d56722a5c2..3e239ae6f0 100644 +index 7767e16cf1..e782a69200 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c -@@ -1838,7 +1838,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, +@@ -1670,7 +1670,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, unsigned int slice_type, tmp, i; int field_pic_flag, bottom_field_flag; int first_slice = sl == h->slice_ctx && !h->current_slice; @@ -1307,7 +1307,7 @@ index d56722a5c2..3e239ae6f0 100644 if (first_slice) av_assert0(!h->setup_finished); -@@ -1929,6 +1929,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, +@@ -1761,6 +1761,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, sl->poc_lsb = 0; sl->delta_poc_bottom = 0; @@ -1315,7 +1315,7 @@ index d56722a5c2..3e239ae6f0 100644 if (sps->poc_type == 0) { sl->poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb); -@@ -1943,6 +1944,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, +@@ -1775,6 +1776,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME) sl->delta_poc[1] = get_se_golomb(&sl->gb); } @@ -1323,7 +1323,7 @@ index d56722a5c2..3e239ae6f0 100644 sl->redundant_pic_count = 0; if (pps->redundant_pic_cnt_present) -@@ -1982,9 +1984,11 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, +@@ -1814,9 +1816,11 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, sl->explicit_ref_marking = 0; if (nal->ref_idc) { @@ -1356,7 +1356,7 @@ index 9a1ec1bace..a87415f822 100644 /** -From efdc653700b45efb64af73060330b95e26aa99c5 Mon Sep 17 00:00:00 2001 +From 08b9d91572ac849db0680eb5f172920f6a0bc961 Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sat, 15 Dec 2018 22:32:16 +0100 Subject: [PATCH 04/13] Add V4L2 request API h264 hwaccel @@ -1374,10 +1374,10 @@ Signed-off-by: Jonas Karlman create mode 100644 libavcodec/v4l2_request_h264.c diff --git a/configure b/configure -index 0ccfd0ac36..4f98dec7b1 100755 +index 6167b122e0..b3ca83bf2b 100755 --- a/configure +++ b/configure -@@ -3045,6 +3045,8 @@ h264_dxva2_hwaccel_deps="dxva2" +@@ -3033,6 +3033,8 @@ h264_dxva2_hwaccel_deps="dxva2" h264_dxva2_hwaccel_select="h264_decoder" h264_nvdec_hwaccel_deps="nvdec" h264_nvdec_hwaccel_select="h264_decoder" @@ -1386,7 +1386,7 @@ index 0ccfd0ac36..4f98dec7b1 100755 h264_vaapi_hwaccel_deps="vaapi" h264_vaapi_hwaccel_select="h264_decoder" h264_vdpau_hwaccel_deps="vdpau" -@@ -6828,6 +6830,7 @@ if enabled v4l2_m2m; then +@@ -6887,6 +6889,7 @@ if enabled v4l2_m2m; then fi check_func_headers "linux/media.h linux/videodev2.h" v4l2_timeval_to_ns @@ -1395,10 +1395,10 @@ index 0ccfd0ac36..4f98dec7b1 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 3cb7dede11..54f8ed670b 100644 +index 0148242ed0..26004171b3 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile -@@ -966,6 +966,7 @@ OBJS-$(CONFIG_H264_D3D11VA_HWACCEL) += dxva2_h264.o +@@ -990,6 +990,7 @@ OBJS-$(CONFIG_H264_D3D11VA_HWACCEL) += dxva2_h264.o OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o OBJS-$(CONFIG_H264_NVDEC_HWACCEL) += nvdec_h264.o OBJS-$(CONFIG_H264_QSV_HWACCEL) += qsvdec.o @@ -1407,10 +1407,10 @@ index 3cb7dede11..54f8ed670b 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 3e239ae6f0..335dc2cac1 100644 +index e782a69200..3d0d45b2a3 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c -@@ -792,6 +792,7 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) +@@ -778,6 +778,7 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) #define HWACCEL_MAX (CONFIG_H264_DXVA2_HWACCEL + \ (CONFIG_H264_D3D11VA_HWACCEL * 2) + \ CONFIG_H264_NVDEC_HWACCEL + \ @@ -1418,7 +1418,7 @@ index 3e239ae6f0..335dc2cac1 100644 CONFIG_H264_VAAPI_HWACCEL + \ CONFIG_H264_VIDEOTOOLBOX_HWACCEL + \ CONFIG_H264_VDPAU_HWACCEL) -@@ -881,6 +882,9 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) +@@ -867,6 +868,9 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) #endif #if CONFIG_H264_VAAPI_HWACCEL *fmt++ = AV_PIX_FMT_VAAPI; @@ -1429,10 +1429,10 @@ index 3e239ae6f0..335dc2cac1 100644 if (h->avctx->codec->pix_fmts) choices = h->avctx->codec->pix_fmts; diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c -index 2a5b53ea56..dcba237b4f 100644 +index 2d691731c5..33cc25e1d3 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c -@@ -1099,6 +1099,9 @@ const FFCodec ff_h264_decoder = { +@@ -1093,6 +1093,9 @@ const FFCodec ff_h264_decoder = { #endif #if CONFIG_H264_VIDEOTOOLBOX_HWACCEL HWACCEL_VIDEOTOOLBOX(h264), @@ -1917,7 +1917,7 @@ index 0000000000..c960c9c887 + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; -From a1e633c09c135ff68937f1d25bbffc18c8cb55d1 Mon Sep 17 00:00:00 2001 +From ef1f67b26f8fddd19b08864710f689f23f7fa68f Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Sat, 15 Dec 2018 22:32:16 +0100 Subject: [PATCH 05/13] Add V4L2 request API mpeg2 hwaccel @@ -1933,10 +1933,10 @@ Signed-off-by: Jonas Karlman create mode 100644 libavcodec/v4l2_request_mpeg2.c diff --git a/configure b/configure -index 4f98dec7b1..c173884edb 100755 +index b3ca83bf2b..4283447b2f 100755 --- a/configure +++ b/configure -@@ -3085,6 +3085,8 @@ mpeg2_dxva2_hwaccel_deps="dxva2" +@@ -3073,6 +3073,8 @@ mpeg2_dxva2_hwaccel_deps="dxva2" mpeg2_dxva2_hwaccel_select="mpeg2video_decoder" mpeg2_nvdec_hwaccel_deps="nvdec" mpeg2_nvdec_hwaccel_select="mpeg2video_decoder" @@ -1945,7 +1945,7 @@ index 4f98dec7b1..c173884edb 100755 mpeg2_vaapi_hwaccel_deps="vaapi" mpeg2_vaapi_hwaccel_select="mpeg2video_decoder" mpeg2_vdpau_hwaccel_deps="vdpau" -@@ -6831,6 +6833,7 @@ fi +@@ -6890,6 +6892,7 @@ fi check_func_headers "linux/media.h linux/videodev2.h" v4l2_timeval_to_ns check_cc h264_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_H264_SLICE;" @@ -1954,10 +1954,10 @@ index 4f98dec7b1..c173884edb 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 54f8ed670b..65ead12255 100644 +index 26004171b3..47cc14558c 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile -@@ -985,6 +985,7 @@ OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL) += dxva2_mpeg2.o +@@ -1009,6 +1009,7 @@ OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL) += dxva2_mpeg2.o OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL) += dxva2_mpeg2.o OBJS-$(CONFIG_MPEG2_NVDEC_HWACCEL) += nvdec_mpeg12.o OBJS-$(CONFIG_MPEG2_QSV_HWACCEL) += qsvdec.o @@ -1978,10 +1978,10 @@ index 014b95f0c0..3b675dd9f8 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 e9bde48f7a..8c007756b4 100644 +index 457d985265..4b90f07b54 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c -@@ -1137,6 +1137,9 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = { +@@ -1134,6 +1134,9 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = { #endif #if CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL AV_PIX_FMT_VIDEOTOOLBOX, @@ -1991,7 +1991,7 @@ index e9bde48f7a..8c007756b4 100644 #endif AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE -@@ -2935,6 +2938,9 @@ const FFCodec ff_mpeg2video_decoder = { +@@ -2919,6 +2922,9 @@ const FFCodec ff_mpeg2video_decoder = { #endif #if CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL HWACCEL_VIDEOTOOLBOX(mpeg2), @@ -2167,7 +2167,7 @@ index 0000000000..84d53209c7 + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; -From 6bccc47f7ee6267b0c99318ab4cc47978161cef9 Mon Sep 17 00:00:00 2001 +From 1e84c65220903fe21301c520e4490ab3c0db9c83 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 22 May 2019 14:46:58 +0200 Subject: [PATCH 06/13] Add V4L2 request API vp8 hwaccel @@ -2185,10 +2185,10 @@ Signed-off-by: Jonas Karlman create mode 100644 libavcodec/v4l2_request_vp8.c diff --git a/configure b/configure -index c173884edb..ec16d26391 100755 +index 4283447b2f..794bd7f4d6 100755 --- a/configure +++ b/configure -@@ -3117,6 +3117,8 @@ vc1_vdpau_hwaccel_deps="vdpau" +@@ -3105,6 +3105,8 @@ vc1_vdpau_hwaccel_deps="vdpau" vc1_vdpau_hwaccel_select="vc1_decoder" vp8_nvdec_hwaccel_deps="nvdec" vp8_nvdec_hwaccel_select="vp8_decoder" @@ -2197,7 +2197,7 @@ index c173884edb..ec16d26391 100755 vp8_vaapi_hwaccel_deps="vaapi" vp8_vaapi_hwaccel_select="vp8_decoder" vp9_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_VP9" -@@ -6834,6 +6836,7 @@ fi +@@ -6893,6 +6895,7 @@ fi check_func_headers "linux/media.h linux/videodev2.h" v4l2_timeval_to_ns check_cc h264_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_H264_SLICE;" check_cc mpeg2_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2_SLICE;" @@ -2206,10 +2206,10 @@ index c173884edb..ec16d26391 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 65ead12255..aed145ecb6 100644 +index 47cc14558c..7da4fd1a87 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile -@@ -1000,6 +1000,7 @@ OBJS-$(CONFIG_VC1_QSV_HWACCEL) += qsvdec.o +@@ -1024,6 +1024,7 @@ OBJS-$(CONFIG_VC1_QSV_HWACCEL) += qsvdec.o OBJS-$(CONFIG_VC1_VAAPI_HWACCEL) += vaapi_vc1.o OBJS-$(CONFIG_VC1_VDPAU_HWACCEL) += vdpau_vc1.o OBJS-$(CONFIG_VP8_NVDEC_HWACCEL) += nvdec_vp8.o @@ -2231,7 +2231,7 @@ index 3b675dd9f8..6f9f078001 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..bc0fc40072 +index 0000000000..e169030213 --- /dev/null +++ b/libavcodec/v4l2_request_vp8.c @@ -0,0 +1,180 @@ @@ -2266,16 +2266,16 @@ index 0000000000..bc0fc40072 + av_unused uint32_t size) +{ + const VP8Context *s = avctx->priv_data; -+ V4L2RequestControlsVP8 *controls = s->framep[VP56_FRAME_CURRENT]->hwaccel_picture_private; ++ V4L2RequestControlsVP8 *controls = s->framep[VP8_FRAME_CURRENT]->hwaccel_picture_private; + + memset(&controls->ctrl, 0, sizeof(controls->ctrl)); -+ return ff_v4l2_request_reset_frame(avctx, s->framep[VP56_FRAME_CURRENT]->tf.f); ++ return ff_v4l2_request_reset_frame(avctx, s->framep[VP8_FRAME_CURRENT]->tf.f); +} + +static int v4l2_request_vp8_end_frame(AVCodecContext *avctx) +{ + const VP8Context *s = avctx->priv_data; -+ V4L2RequestControlsVP8 *controls = s->framep[VP56_FRAME_CURRENT]->hwaccel_picture_private; ++ V4L2RequestControlsVP8 *controls = s->framep[VP8_FRAME_CURRENT]->hwaccel_picture_private; + struct v4l2_ext_control control[] = { + { + .id = V4L2_CID_STATELESS_VP8_FRAME, @@ -2284,7 +2284,7 @@ index 0000000000..bc0fc40072 + }, + }; + -+ return ff_v4l2_request_decode_frame(avctx, s->framep[VP56_FRAME_CURRENT]->tf.f, ++ return ff_v4l2_request_decode_frame(avctx, s->framep[VP8_FRAME_CURRENT]->tf.f, + control, FF_ARRAY_ELEMS(control)); +} + @@ -2293,7 +2293,7 @@ index 0000000000..bc0fc40072 + uint32_t size) +{ + const VP8Context *s = avctx->priv_data; -+ V4L2RequestControlsVP8 *controls = s->framep[VP56_FRAME_CURRENT]->hwaccel_picture_private; ++ V4L2RequestControlsVP8 *controls = s->framep[VP8_FRAME_CURRENT]->hwaccel_picture_private; + struct v4l2_ctrl_vp8_frame *frame = &controls->ctrl; + const uint8_t *data = buffer + 3 + 7 * s->keyframe; + unsigned int i, j, k; @@ -2316,18 +2316,18 @@ index 0000000000..bc0fc40072 + frame->coder_state.range = s->coder_state_at_header_end.range; + frame->coder_state.value = s->coder_state_at_header_end.value; + frame->coder_state.bit_count = s->coder_state_at_header_end.bit_count; -+ if (s->framep[VP56_FRAME_PREVIOUS]) -+ frame->last_frame_ts = ff_v4l2_request_get_capture_timestamp(s->framep[VP56_FRAME_PREVIOUS]->tf.f); -+ if (s->framep[VP56_FRAME_GOLDEN]) -+ frame->golden_frame_ts = ff_v4l2_request_get_capture_timestamp(s->framep[VP56_FRAME_GOLDEN]->tf.f); -+ if (s->framep[VP56_FRAME_GOLDEN2]) -+ frame->alt_frame_ts = ff_v4l2_request_get_capture_timestamp(s->framep[VP56_FRAME_GOLDEN2]->tf.f); ++ if (s->framep[VP8_FRAME_PREVIOUS]) ++ frame->last_frame_ts = ff_v4l2_request_get_capture_timestamp(s->framep[VP8_FRAME_PREVIOUS]->tf.f); ++ if (s->framep[VP8_FRAME_GOLDEN]) ++ frame->golden_frame_ts = ff_v4l2_request_get_capture_timestamp(s->framep[VP8_FRAME_GOLDEN]->tf.f); ++ if (s->framep[VP8_FRAME_ALTREF]) ++ frame->alt_frame_ts = ff_v4l2_request_get_capture_timestamp(s->framep[VP8_FRAME_ALTREF]->tf.f); + frame->flags |= s->invisible ? 0 : V4L2_VP8_FRAME_FLAG_SHOW_FRAME; + frame->flags |= s->mbskip_enabled ? V4L2_VP8_FRAME_FLAG_MB_NO_SKIP_COEFF : 0; + frame->flags |= (s->profile & 0x4) ? V4L2_VP8_FRAME_FLAG_EXPERIMENTAL : 0; + frame->flags |= s->keyframe ? V4L2_VP8_FRAME_FLAG_KEY_FRAME : 0; -+ frame->flags |= s->sign_bias[VP56_FRAME_GOLDEN] ? V4L2_VP8_FRAME_FLAG_SIGN_BIAS_GOLDEN : 0; -+ frame->flags |= s->sign_bias[VP56_FRAME_GOLDEN2] ? V4L2_VP8_FRAME_FLAG_SIGN_BIAS_ALT : 0; ++ frame->flags |= s->sign_bias[VP8_FRAME_GOLDEN] ? V4L2_VP8_FRAME_FLAG_SIGN_BIAS_GOLDEN : 0; ++ frame->flags |= s->sign_bias[VP8_FRAME_ALTREF] ? V4L2_VP8_FRAME_FLAG_SIGN_BIAS_ALT : 0; + frame->segment.flags |= s->segmentation.enabled ? V4L2_VP8_SEGMENT_FLAG_ENABLED : 0; + frame->segment.flags |= s->segmentation.update_map ? V4L2_VP8_SEGMENT_FLAG_UPDATE_MAP : 0; + frame->segment.flags |= s->segmentation.update_feature_data ? V4L2_VP8_SEGMENT_FLAG_UPDATE_FEATURE_DATA : 0; @@ -2392,7 +2392,7 @@ index 0000000000..bc0fc40072 + frame->quant.uv_dc_delta = s->quant.uvdc_delta; + frame->quant.uv_ac_delta = s->quant.uvac_delta; + -+ return ff_v4l2_request_append_output_buffer(avctx, s->framep[VP56_FRAME_CURRENT]->tf.f, buffer, size); ++ return ff_v4l2_request_append_output_buffer(avctx, s->framep[VP8_FRAME_CURRENT]->tf.f, buffer, size); +} + +static int v4l2_request_vp8_init(AVCodecContext *avctx) @@ -2416,10 +2416,10 @@ index 0000000000..bc0fc40072 + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c -index f521f2c9de..a4799fca09 100644 +index db2419deaf..ad5e6e8f2b 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c -@@ -180,6 +180,9 @@ static enum AVPixelFormat get_pixel_format(VP8Context *s) +@@ -206,6 +206,9 @@ static enum AVPixelFormat get_pixel_format(VP8Context *s) #endif #if CONFIG_VP8_NVDEC_HWACCEL AV_PIX_FMT_CUDA, @@ -2429,7 +2429,7 @@ index f521f2c9de..a4799fca09 100644 #endif AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE, -@@ -2976,6 +2979,9 @@ const FFCodec ff_vp8_decoder = { +@@ -3007,6 +3010,9 @@ const FFCodec ff_vp8_decoder = { #endif #if CONFIG_VP8_NVDEC_HWACCEL HWACCEL_NVDEC(vp8), @@ -2440,7 +2440,7 @@ index f521f2c9de..a4799fca09 100644 NULL }, -From 26e5e1407717e88c508abfb24ae329036bb1a99e Mon Sep 17 00:00:00 2001 +From e5df38921bf3a7f918c7e05b0207e3fde6c65017 Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sat, 15 Dec 2018 22:32:16 +0100 Subject: [PATCH 07/13] Add V4L2 request API hevc hwaccel @@ -2459,10 +2459,10 @@ Signed-off-by: Alex Bee create mode 100644 libavcodec/v4l2_request_hevc.c diff --git a/configure b/configure -index ec16d26391..d366652e51 100755 +index 794bd7f4d6..2565ce8d7c 100755 --- a/configure +++ b/configure -@@ -3061,6 +3061,8 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" +@@ -3049,6 +3049,8 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" hevc_dxva2_hwaccel_select="hevc_decoder" hevc_nvdec_hwaccel_deps="nvdec" hevc_nvdec_hwaccel_select="hevc_decoder" @@ -2471,7 +2471,7 @@ index ec16d26391..d366652e51 100755 hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC" hevc_vaapi_hwaccel_select="hevc_decoder" hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC" -@@ -6835,6 +6837,7 @@ fi +@@ -6894,6 +6896,7 @@ fi check_func_headers "linux/media.h linux/videodev2.h" v4l2_timeval_to_ns check_cc h264_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_H264_SLICE;" @@ -2480,10 +2480,10 @@ index ec16d26391..d366652e51 100755 check_cc vp8_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_VP8_FRAME;" diff --git a/libavcodec/Makefile b/libavcodec/Makefile -index aed145ecb6..33ce5fc359 100644 +index 7da4fd1a87..cd08740e75 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile -@@ -974,6 +974,7 @@ OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL) += dxva2_hevc.o +@@ -998,6 +998,7 @@ OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL) += dxva2_hevc.o OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o OBJS-$(CONFIG_HEVC_QSV_HWACCEL) += qsvdec.o @@ -2492,10 +2492,10 @@ index aed145ecb6..33ce5fc359 100644 OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o h265_profile_level.o OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL) += nvdec_mjpeg.o diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c -index f8f981e838..8db5649b55 100644 +index 567e8d81d4..79b821e7e5 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c -@@ -402,6 +402,7 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) +@@ -403,6 +403,7 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + \ CONFIG_HEVC_D3D11VA_HWACCEL * 2 + \ CONFIG_HEVC_NVDEC_HWACCEL + \ @@ -2503,7 +2503,7 @@ index f8f981e838..8db5649b55 100644 CONFIG_HEVC_VAAPI_HWACCEL + \ CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL + \ CONFIG_HEVC_VDPAU_HWACCEL) -@@ -428,6 +429,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) +@@ -429,6 +430,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #endif #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; @@ -2513,7 +2513,7 @@ index f8f981e838..8db5649b55 100644 #endif break; case AV_PIX_FMT_YUV420P10: -@@ -449,6 +453,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) +@@ -450,6 +454,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #endif #if CONFIG_HEVC_NVDEC_HWACCEL *fmt++ = AV_PIX_FMT_CUDA; @@ -2523,7 +2523,7 @@ index f8f981e838..8db5649b55 100644 #endif break; case AV_PIX_FMT_YUV444P: -@@ -3905,6 +3912,9 @@ const FFCodec ff_hevc_decoder = { +@@ -3739,6 +3746,9 @@ const FFCodec ff_hevc_decoder = { #endif #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL HWACCEL_VIDEOTOOLBOX(hevc), @@ -3231,7 +3231,7 @@ index 0000000000..3e2b9a575e + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; -From 24e1336751a0d7346ea149aa3cbe9445e12b885e Mon Sep 17 00:00:00 2001 +From 760b6f7d4662d5c5d3bc6292a53a40e8fc2fc18d Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 12 Dec 2019 16:13:55 +0100 Subject: [PATCH 08/13] Add V4L2 request API VP9 hwaccel @@ -3250,10 +3250,10 @@ Signed-off-by: Jernej Skrabec create mode 100644 libavcodec/v4l2_request_vp9.c diff --git a/configure b/configure -index d366652e51..78d0c5a420 100755 +index 2565ce8d7c..081174babb 100755 --- a/configure +++ b/configure -@@ -3131,6 +3131,8 @@ vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9" +@@ -3119,6 +3119,8 @@ vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9" vp9_dxva2_hwaccel_select="vp9_decoder" vp9_nvdec_hwaccel_deps="nvdec" vp9_nvdec_hwaccel_select="vp9_decoder" @@ -3262,7 +3262,7 @@ index d366652e51..78d0c5a420 100755 vp9_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferVP9_bit_depth" vp9_vaapi_hwaccel_select="vp9_decoder" vp9_vdpau_hwaccel_deps="vdpau VdpPictureInfoVP9" -@@ -6840,6 +6842,7 @@ check_cc h264_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_H264_SLICE;" +@@ -6899,6 +6901,7 @@ check_cc h264_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_H264_SLICE;" check_cc hevc_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_HEVC_SLICE;" check_cc mpeg2_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2_SLICE;" check_cc vp8_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_VP8_FRAME;" @@ -3271,10 +3271,10 @@ index d366652e51..78d0c5a420 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 33ce5fc359..6561518e0e 100644 +index cd08740e75..e2c957763a 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile -@@ -1006,6 +1006,7 @@ OBJS-$(CONFIG_VP8_VAAPI_HWACCEL) += vaapi_vp8.o +@@ -1030,6 +1030,7 @@ OBJS-$(CONFIG_VP8_VAAPI_HWACCEL) += vaapi_vp8.o OBJS-$(CONFIG_VP9_D3D11VA_HWACCEL) += dxva2_vp9.o OBJS-$(CONFIG_VP9_DXVA2_HWACCEL) += dxva2_vp9.o OBJS-$(CONFIG_VP9_NVDEC_HWACCEL) += nvdec_vp9.o @@ -3583,10 +3583,10 @@ index 0000000000..ec0300f66d + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c -index fee79fb45b..bd7dc4f53a 100644 +index 7c0a246446..9cc36960eb 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c -@@ -184,6 +184,7 @@ static int update_size(AVCodecContext *avctx, int w, int h) +@@ -185,6 +185,7 @@ static int update_size(AVCodecContext *avctx, int w, int h) #define HWACCEL_MAX (CONFIG_VP9_DXVA2_HWACCEL + \ CONFIG_VP9_D3D11VA_HWACCEL * 2 + \ CONFIG_VP9_NVDEC_HWACCEL + \ @@ -3594,7 +3594,7 @@ index fee79fb45b..bd7dc4f53a 100644 CONFIG_VP9_VAAPI_HWACCEL + \ CONFIG_VP9_VDPAU_HWACCEL + \ CONFIG_VP9_VIDEOTOOLBOX_HWACCEL) -@@ -212,6 +213,9 @@ static int update_size(AVCodecContext *avctx, int w, int h) +@@ -213,6 +214,9 @@ static int update_size(AVCodecContext *avctx, int w, int h) #if CONFIG_VP9_NVDEC_HWACCEL *fmtp++ = AV_PIX_FMT_CUDA; #endif @@ -3604,7 +3604,7 @@ index fee79fb45b..bd7dc4f53a 100644 #if CONFIG_VP9_VAAPI_HWACCEL *fmtp++ = AV_PIX_FMT_VAAPI; #endif -@@ -226,6 +230,9 @@ static int update_size(AVCodecContext *avctx, int w, int h) +@@ -227,6 +231,9 @@ static int update_size(AVCodecContext *avctx, int w, int h) #if CONFIG_VP9_NVDEC_HWACCEL *fmtp++ = AV_PIX_FMT_CUDA; #endif @@ -3614,16 +3614,16 @@ index fee79fb45b..bd7dc4f53a 100644 #if CONFIG_VP9_VAAPI_HWACCEL *fmtp++ = AV_PIX_FMT_VAAPI; #endif -@@ -379,7 +386,7 @@ static av_always_inline int inv_recenter_nonneg(int v, int m) +@@ -387,7 +394,7 @@ static av_always_inline int inv_recenter_nonneg(int v, int m) } // differential forward probability updates --static int update_prob(VP56RangeCoder *c, int p) -+static int read_prob_delta(VP56RangeCoder *c) +-static int update_prob(VPXRangeCoder *c, int p) ++static int read_prob_delta(VPXRangeCoder *c) { static const uint8_t inv_map_table[255] = { 7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176, -@@ -433,8 +440,13 @@ static int update_prob(VP56RangeCoder *c, int p) +@@ -441,8 +448,13 @@ static int update_prob(VPXRangeCoder *c, int p) av_assert2(d < FF_ARRAY_ELEMS(inv_map_table)); } @@ -3639,7 +3639,7 @@ index fee79fb45b..bd7dc4f53a 100644 } static int read_colorspace_details(AVCodecContext *avctx) -@@ -700,7 +712,8 @@ static int decode_frame_header(AVCodecContext *avctx, +@@ -708,7 +720,8 @@ static int decode_frame_header(AVCodecContext *avctx, get_bits(&s->gb, 8) : 255; } @@ -3649,7 +3649,7 @@ index fee79fb45b..bd7dc4f53a 100644 s->s.h.segmentation.absolute_vals = get_bits1(&s->gb); for (i = 0; i < 8; i++) { if ((s->s.h.segmentation.feat[i].q_enabled = get_bits1(&s->gb))) -@@ -900,6 +913,8 @@ static int decode_frame_header(AVCodecContext *avctx, +@@ -908,6 +921,8 @@ static int decode_frame_header(AVCodecContext *avctx, * as explicit copies if the fw update is missing (and skip the copy upon * fw update)? */ s->prob.p = s->prob_ctx[c].p; @@ -3658,33 +3658,33 @@ index fee79fb45b..bd7dc4f53a 100644 // txfm updates if (s->s.h.lossless) { -@@ -911,18 +926,25 @@ static int decode_frame_header(AVCodecContext *avctx, +@@ -919,18 +934,25 @@ static int decode_frame_header(AVCodecContext *avctx, if (s->s.h.txfmmode == TX_SWITCHABLE) { for (i = 0; i < 2; i++) -- if (vp56_rac_get_prob_branchy(&s->c, 252)) +- if (vpx_rac_get_prob_branchy(&s->c, 252)) - s->prob.p.tx8p[i] = update_prob(&s->c, s->prob.p.tx8p[i]); -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.tx8p[i] = read_prob_delta(&s->c); + s->prob.p.tx8p[i] = update_prob(s->prob.p.tx8p[i], + s->prob_raw.p.tx8p[i]); + } for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) -- if (vp56_rac_get_prob_branchy(&s->c, 252)) +- if (vpx_rac_get_prob_branchy(&s->c, 252)) - s->prob.p.tx16p[i][j] = - update_prob(&s->c, s->prob.p.tx16p[i][j]); -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.tx16p[i][j] = read_prob_delta(&s->c); + s->prob.p.tx16p[i][j] = update_prob(s->prob.p.tx16p[i][j], + s->prob_raw.p.tx16p[i][j]); + } for (i = 0; i < 2; i++) for (j = 0; j < 3; j++) -- if (vp56_rac_get_prob_branchy(&s->c, 252)) +- if (vpx_rac_get_prob_branchy(&s->c, 252)) - s->prob.p.tx32p[i][j] = - update_prob(&s->c, s->prob.p.tx32p[i][j]); -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.tx32p[i][j] = read_prob_delta(&s->c); + s->prob.p.tx32p[i][j] = update_prob(s->prob.p.tx32p[i][j], + s->prob_raw.p.tx32p[i][j]); @@ -3692,7 +3692,7 @@ index fee79fb45b..bd7dc4f53a 100644 } } -@@ -934,15 +956,18 @@ static int decode_frame_header(AVCodecContext *avctx, +@@ -942,15 +964,18 @@ static int decode_frame_header(AVCodecContext *avctx, for (k = 0; k < 2; k++) for (l = 0; l < 6; l++) for (m = 0; m < 6; m++) { @@ -3702,10 +3702,10 @@ index fee79fb45b..bd7dc4f53a 100644 if (m >= 3 && l == 0) // dc only has 3 pt break; for (n = 0; n < 3; n++) { -- if (vp56_rac_get_prob_branchy(&s->c, 252)) +- if (vpx_rac_get_prob_branchy(&s->c, 252)) - p[n] = update_prob(&s->c, r[n]); - else -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + pd[n] = read_prob_delta(&s->c); + p[n] = update_prob(r[n], pd[n]); + } else { @@ -3714,7 +3714,7 @@ index fee79fb45b..bd7dc4f53a 100644 } memcpy(&p[3], ff_vp9_model_pareto8[p[2]], 8); } -@@ -957,7 +982,7 @@ static int decode_frame_header(AVCodecContext *avctx, +@@ -965,7 +990,7 @@ static int decode_frame_header(AVCodecContext *avctx, break; memcpy(p, r, 3); memcpy(&p[3], ff_vp9_model_pareto8[p[2]], 8); @@ -3723,13 +3723,13 @@ index fee79fb45b..bd7dc4f53a 100644 } if (s->s.h.txfmmode == i) break; -@@ -965,25 +990,37 @@ static int decode_frame_header(AVCodecContext *avctx, +@@ -973,25 +998,37 @@ static int decode_frame_header(AVCodecContext *avctx, // mode updates for (i = 0; i < 3; i++) -- if (vp56_rac_get_prob_branchy(&s->c, 252)) +- if (vpx_rac_get_prob_branchy(&s->c, 252)) - s->prob.p.skip[i] = update_prob(&s->c, s->prob.p.skip[i]); -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.skip[i] = read_prob_delta(&s->c); + s->prob.p.skip[i] = update_prob(s->prob.p.skip[i], + s->prob_raw.p.skip[i]); @@ -3737,8 +3737,8 @@ index fee79fb45b..bd7dc4f53a 100644 if (!s->s.h.keyframe && !s->s.h.intraonly) { for (i = 0; i < 7; i++) for (j = 0; j < 3; j++) -- if (vp56_rac_get_prob_branchy(&s->c, 252)) -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { +- if (vpx_rac_get_prob_branchy(&s->c, 252)) ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.mv_mode[i][j] = read_prob_delta(&s->c); s->prob.p.mv_mode[i][j] = - update_prob(&s->c, s->prob.p.mv_mode[i][j]); @@ -3749,8 +3749,8 @@ index fee79fb45b..bd7dc4f53a 100644 if (s->s.h.filtermode == FILTER_SWITCHABLE) for (i = 0; i < 4; i++) for (j = 0; j < 2; j++) -- if (vp56_rac_get_prob_branchy(&s->c, 252)) -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { +- if (vpx_rac_get_prob_branchy(&s->c, 252)) ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.filter[i][j] = read_prob_delta(&s->c); s->prob.p.filter[i][j] = - update_prob(&s->c, s->prob.p.filter[i][j]); @@ -3759,22 +3759,22 @@ index fee79fb45b..bd7dc4f53a 100644 + } for (i = 0; i < 4; i++) -- if (vp56_rac_get_prob_branchy(&s->c, 252)) +- if (vpx_rac_get_prob_branchy(&s->c, 252)) - s->prob.p.intra[i] = update_prob(&s->c, s->prob.p.intra[i]); -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.intra[i] = read_prob_delta(&s->c); + s->prob.p.intra[i] = update_prob(s->prob.p.intra[i], + s->prob_raw.p.intra[i]); + } if (s->s.h.allowcompinter) { - s->s.h.comppredmode = vp8_rac_get(&s->c); -@@ -991,92 +1028,134 @@ static int decode_frame_header(AVCodecContext *avctx, - s->s.h.comppredmode += vp8_rac_get(&s->c); + s->s.h.comppredmode = vp89_rac_get(&s->c); +@@ -999,92 +1036,134 @@ static int decode_frame_header(AVCodecContext *avctx, + s->s.h.comppredmode += vp89_rac_get(&s->c); if (s->s.h.comppredmode == PRED_SWITCHABLE) for (i = 0; i < 5; i++) -- if (vp56_rac_get_prob_branchy(&s->c, 252)) -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { +- if (vpx_rac_get_prob_branchy(&s->c, 252)) ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.comp[i] = read_prob_delta(&s->c); s->prob.p.comp[i] = - update_prob(&s->c, s->prob.p.comp[i]); @@ -3786,16 +3786,16 @@ index fee79fb45b..bd7dc4f53a 100644 if (s->s.h.comppredmode != PRED_COMPREF) { for (i = 0; i < 5; i++) { -- if (vp56_rac_get_prob_branchy(&s->c, 252)) -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { +- if (vpx_rac_get_prob_branchy(&s->c, 252)) ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.single_ref[i][0] = read_prob_delta(&s->c); s->prob.p.single_ref[i][0] = - update_prob(&s->c, s->prob.p.single_ref[i][0]); -- if (vp56_rac_get_prob_branchy(&s->c, 252)) +- if (vpx_rac_get_prob_branchy(&s->c, 252)) + update_prob(s->prob.p.single_ref[i][0], + s->prob_raw.p.single_ref[i][0]); + } -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.single_ref[i][1] = read_prob_delta(&s->c); s->prob.p.single_ref[i][1] = - update_prob(&s->c, s->prob.p.single_ref[i][1]); @@ -3807,8 +3807,8 @@ index fee79fb45b..bd7dc4f53a 100644 if (s->s.h.comppredmode != PRED_SINGLEREF) { for (i = 0; i < 5; i++) -- if (vp56_rac_get_prob_branchy(&s->c, 252)) -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { +- if (vpx_rac_get_prob_branchy(&s->c, 252)) ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.comp_ref[i] = read_prob_delta(&s->c); s->prob.p.comp_ref[i] = - update_prob(&s->c, s->prob.p.comp_ref[i]); @@ -3819,8 +3819,8 @@ index fee79fb45b..bd7dc4f53a 100644 for (i = 0; i < 4; i++) for (j = 0; j < 9; j++) -- if (vp56_rac_get_prob_branchy(&s->c, 252)) -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { +- if (vpx_rac_get_prob_branchy(&s->c, 252)) ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.y_mode[i][j] = read_prob_delta(&s->c); s->prob.p.y_mode[i][j] = - update_prob(&s->c, s->prob.p.y_mode[i][j]); @@ -3831,8 +3831,8 @@ index fee79fb45b..bd7dc4f53a 100644 for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) for (k = 0; k < 3; k++) -- if (vp56_rac_get_prob_branchy(&s->c, 252)) -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { +- if (vpx_rac_get_prob_branchy(&s->c, 252)) ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.partition[i][j][k] = read_prob_delta(&s->c); s->prob.p.partition[3 - i][j][k] = - update_prob(&s->c, @@ -3843,48 +3843,48 @@ index fee79fb45b..bd7dc4f53a 100644 // mv fields don't use the update_prob subexp model for some reason for (i = 0; i < 3; i++) -- if (vp56_rac_get_prob_branchy(&s->c, 252)) -- s->prob.p.mv_joint[i] = (vp8_rac_get_uint(&s->c, 7) << 1) | 1; -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { -+ s->prob_raw.p.mv_joint[i] = (vp8_rac_get_uint(&s->c, 7) << 1) | 1; +- if (vpx_rac_get_prob_branchy(&s->c, 252)) +- s->prob.p.mv_joint[i] = (vp89_rac_get_uint(&s->c, 7) << 1) | 1; ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { ++ s->prob_raw.p.mv_joint[i] = (vp89_rac_get_uint(&s->c, 7) << 1) | 1; + s->prob.p.mv_joint[i] = s->prob_raw.p.mv_joint[i]; + } for (i = 0; i < 2; i++) { -- if (vp56_rac_get_prob_branchy(&s->c, 252)) +- if (vpx_rac_get_prob_branchy(&s->c, 252)) - s->prob.p.mv_comp[i].sign = -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.mv_comp[i].sign = - (vp8_rac_get_uint(&s->c, 7) << 1) | 1; + (vp89_rac_get_uint(&s->c, 7) << 1) | 1; + s->prob.p.mv_comp[i].sign = + s->prob_raw.p.mv_comp[i].sign; + } for (j = 0; j < 10; j++) -- if (vp56_rac_get_prob_branchy(&s->c, 252)) +- if (vpx_rac_get_prob_branchy(&s->c, 252)) - s->prob.p.mv_comp[i].classes[j] = -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.mv_comp[i].classes[j] = - (vp8_rac_get_uint(&s->c, 7) << 1) | 1; + (vp89_rac_get_uint(&s->c, 7) << 1) | 1; + s->prob.p.mv_comp[i].classes[j] = + s->prob_raw.p.mv_comp[i].classes[j]; + } -- if (vp56_rac_get_prob_branchy(&s->c, 252)) +- if (vpx_rac_get_prob_branchy(&s->c, 252)) - s->prob.p.mv_comp[i].class0 = -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.mv_comp[i].class0 = - (vp8_rac_get_uint(&s->c, 7) << 1) | 1; + (vp89_rac_get_uint(&s->c, 7) << 1) | 1; + s->prob.p.mv_comp[i].class0 = + s->prob_raw.p.mv_comp[i].class0; + } for (j = 0; j < 10; j++) -- if (vp56_rac_get_prob_branchy(&s->c, 252)) +- if (vpx_rac_get_prob_branchy(&s->c, 252)) - s->prob.p.mv_comp[i].bits[j] = -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.mv_comp[i].bits[j] = - (vp8_rac_get_uint(&s->c, 7) << 1) | 1; + (vp89_rac_get_uint(&s->c, 7) << 1) | 1; + s->prob.p.mv_comp[i].bits[j] = + s->prob_raw.p.mv_comp[i].bits[j]; + } @@ -3893,21 +3893,21 @@ index fee79fb45b..bd7dc4f53a 100644 for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) for (k = 0; k < 3; k++) -- if (vp56_rac_get_prob_branchy(&s->c, 252)) +- if (vpx_rac_get_prob_branchy(&s->c, 252)) - s->prob.p.mv_comp[i].class0_fp[j][k] = -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.mv_comp[i].class0_fp[j][k] = - (vp8_rac_get_uint(&s->c, 7) << 1) | 1; + (vp89_rac_get_uint(&s->c, 7) << 1) | 1; + s->prob.p.mv_comp[i].class0_fp[j][k] = + s->prob_raw.p.mv_comp[i].class0_fp[j][k]; + } for (j = 0; j < 3; j++) -- if (vp56_rac_get_prob_branchy(&s->c, 252)) +- if (vpx_rac_get_prob_branchy(&s->c, 252)) - s->prob.p.mv_comp[i].fp[j] = -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.mv_comp[i].fp[j] = - (vp8_rac_get_uint(&s->c, 7) << 1) | 1; + (vp89_rac_get_uint(&s->c, 7) << 1) | 1; + s->prob.p.mv_comp[i].fp[j] = + s->prob_raw.p.mv_comp[i].fp[j]; + } @@ -3915,27 +3915,27 @@ index fee79fb45b..bd7dc4f53a 100644 if (s->s.h.highprecisionmvs) { for (i = 0; i < 2; i++) { -- if (vp56_rac_get_prob_branchy(&s->c, 252)) +- if (vpx_rac_get_prob_branchy(&s->c, 252)) - s->prob.p.mv_comp[i].class0_hp = -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.mv_comp[i].class0_hp = - (vp8_rac_get_uint(&s->c, 7) << 1) | 1; + (vp89_rac_get_uint(&s->c, 7) << 1) | 1; + s->prob.p.mv_comp[i].class0_hp = + s->prob_raw.p.mv_comp[i].class0_hp; + } -- if (vp56_rac_get_prob_branchy(&s->c, 252)) +- if (vpx_rac_get_prob_branchy(&s->c, 252)) - s->prob.p.mv_comp[i].hp = -+ if (vp56_rac_get_prob_branchy(&s->c, 252)) { ++ if (vpx_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.mv_comp[i].hp = - (vp8_rac_get_uint(&s->c, 7) << 1) | 1; + (vp89_rac_get_uint(&s->c, 7) << 1) | 1; + s->prob.p.mv_comp[i].hp = + s->prob_raw.p.mv_comp[i].hp; + } } } } -@@ -1902,6 +1981,9 @@ const FFCodec ff_vp9_decoder = { +@@ -1906,6 +1985,9 @@ const FFCodec ff_vp9_decoder = { #if CONFIG_VP9_VDPAU_HWACCEL HWACCEL_VDPAU(vp9), #endif @@ -3946,10 +3946,10 @@ index fee79fb45b..bd7dc4f53a 100644 HWACCEL_VIDEOTOOLBOX(vp9), #endif diff --git a/libavcodec/vp9dec.h b/libavcodec/vp9dec.h -index 9cbd5839a8..74b854691e 100644 +index de7aba0458..5935ba6227 100644 --- a/libavcodec/vp9dec.h +++ b/libavcodec/vp9dec.h -@@ -132,6 +132,10 @@ typedef struct VP9Context { +@@ -135,6 +135,10 @@ typedef struct VP9Context { ProbContext p; uint8_t coef[4][2][2][6][6][11]; } prob; @@ -3961,10 +3961,10 @@ index 9cbd5839a8..74b854691e 100644 // contextual (above) cache uint8_t *above_partition_ctx; diff --git a/libavcodec/vp9shared.h b/libavcodec/vp9shared.h -index ebaa11d2c1..3469a7312d 100644 +index 543a496df8..a5028d4b39 100644 --- a/libavcodec/vp9shared.h +++ b/libavcodec/vp9shared.h -@@ -131,6 +131,7 @@ typedef struct VP9BitstreamHeader { +@@ -137,6 +137,7 @@ typedef struct VP9BitstreamHeader { uint8_t temporal; uint8_t absolute_vals; uint8_t update_map; @@ -3973,7 +3973,7 @@ index ebaa11d2c1..3469a7312d 100644 uint8_t pred_prob[3]; struct { -From 3da495ee6fe1d8cf4bebde0a089bcd14e7a7785e Mon Sep 17 00:00:00 2001 +From 5057eb96b2adbff022a1abd8d5b06f369f908d51 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Mon, 29 Apr 2019 22:08:59 +0000 Subject: [PATCH 09/13] HACK: hwcontext_drm: do not require drm device @@ -4000,7 +4000,7 @@ index 7a9fdbd263..6297d1f9b6 100644 if (hwctx->fd < 0) return AVERROR(errno); -From 735160c215246efb0b99014978cac558fb775488 Mon Sep 17 00:00:00 2001 +From fce915b2195b3c4d74b8b40e0d5aa9ba4dcecd33 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Fri, 15 May 2020 16:54:05 +0000 Subject: [PATCH 10/13] WIP: add NV15 and NV20 support @@ -4012,10 +4012,10 @@ Signed-off-by: Jonas Karlman 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c -index 335dc2cac1..23807756c5 100644 +index 3d0d45b2a3..f7af51b28e 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c -@@ -822,10 +822,17 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) +@@ -808,10 +808,17 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) *fmt++ = AV_PIX_FMT_GBRP10; } else *fmt++ = AV_PIX_FMT_YUV444P10; @@ -4035,7 +4035,7 @@ index 335dc2cac1..23807756c5 100644 break; case 12: if (CHROMA444(h)) { -@@ -868,6 +875,9 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) +@@ -854,6 +861,9 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) else *fmt++ = AV_PIX_FMT_YUV444P; } else if (CHROMA422(h)) { @@ -4087,7 +4087,7 @@ index e7faf100f0..c77d3a8cb1 100644 default: return -1; -From 94dd83848ec99174057dd9c9747dfeff0a416a3a Mon Sep 17 00:00:00 2001 +From 943156690cb35cdcb177538d9e795f5755b03b3e Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Mon, 27 Jul 2020 23:15:45 +0000 Subject: [PATCH 11/13] HACK: define drm NV15 and NV20 format @@ -4116,7 +4116,7 @@ index c77d3a8cb1..19c41f2b3f 100644 { V4L2RequestDescriptor *req = (V4L2RequestDescriptor*)frame->data[0]; -From bbedc169415db75791a60082ec80942e891ad5f3 Mon Sep 17 00:00:00 2001 +From 28e490b972e644113237d6a3f48b0c7fd6cb011e Mon Sep 17 00:00:00 2001 From: Alex Bee Date: Sat, 22 Oct 2022 22:23:22 +0200 Subject: [PATCH 12/13] HACK: Revert "lavc/pthread_frame: always transfer @@ -4128,10 +4128,10 @@ This reverts commit 96c78e50a66a3b443eb2f237e2554ab84b8a12ce. 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c -index 43d6cc8ff4..80c15b35be 100644 +index d9d5afaa82..800f7a2377 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c -@@ -458,13 +458,13 @@ static int submit_packet(PerThreadContext *p, AVCodecContext *user_avctx, +@@ -430,13 +430,13 @@ static int submit_packet(PerThreadContext *p, AVCodecContext *user_avctx, pthread_mutex_unlock(&p->mutex); return err; } @@ -4152,7 +4152,7 @@ index 43d6cc8ff4..80c15b35be 100644 av_packet_unref(p->avpkt); ret = av_packet_ref(p->avpkt, avpkt); -From 1d0bcfaf182c8b51b001485bc7e7e6db0ceabc4e Mon Sep 17 00:00:00 2001 +From fe61bbb249a3a9ae96447ded7ef538d7034783e5 Mon Sep 17 00:00:00 2001 From: Alex Bee Date: Sat, 22 Oct 2022 22:24:07 +0200 Subject: [PATCH 13/13] HACK: Revert "lavc/pthread_frame: avoid leaving stale @@ -4164,10 +4164,10 @@ This reverts commit 35aa7e70e7ec350319e7634a30d8d8aa1e6ecdda. 1 file changed, 12 insertions(+), 35 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c -index 80c15b35be..8faea75a49 100644 +index 800f7a2377..5acc261e60 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c -@@ -147,12 +147,6 @@ typedef struct FrameThreadContext { +@@ -132,12 +132,6 @@ typedef struct FrameThreadContext { * Set for the first N packets, where N is the number of threads. * While it is set, ff_thread_en/decode_frame won't return any results. */ @@ -4179,8 +4179,8 @@ index 80c15b35be..8faea75a49 100644 - void *stash_hwaccel_priv; } FrameThreadContext; - #if FF_API_THREAD_SAFE_CALLBACKS -@@ -233,17 +227,9 @@ FF_ENABLE_DEPRECATION_WARNINGS + static void async_lock(FrameThreadContext *fctx) +@@ -220,17 +214,9 @@ static attribute_align_arg void *frame_worker_thread(void *arg) ff_thread_finish_setup(avctx); if (p->hwaccel_serializing) { @@ -4198,7 +4198,7 @@ index 80c15b35be..8faea75a49 100644 if (p->async_serializing) { p->async_serializing = 0; -@@ -307,6 +293,9 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, +@@ -294,6 +280,9 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, dst->color_range = src->color_range; dst->chroma_sample_location = src->chroma_sample_location; @@ -4208,7 +4208,7 @@ index 80c15b35be..8faea75a49 100644 dst->sample_rate = src->sample_rate; dst->sample_fmt = src->sample_fmt; #if FF_API_OLD_CHANNEL_LAYOUT -@@ -319,6 +308,8 @@ FF_ENABLE_DEPRECATION_WARNINGS +@@ -306,6 +295,8 @@ FF_ENABLE_DEPRECATION_WARNINGS if (err < 0) return err; @@ -4217,7 +4217,7 @@ index 80c15b35be..8faea75a49 100644 if (!!dst->hw_frames_ctx != !!src->hw_frames_ctx || (dst->hw_frames_ctx && dst->hw_frames_ctx->data != src->hw_frames_ctx->data)) { av_buffer_unref(&dst->hw_frames_ctx); -@@ -458,12 +449,6 @@ static int submit_packet(PerThreadContext *p, AVCodecContext *user_avctx, +@@ -430,12 +421,6 @@ static int submit_packet(PerThreadContext *p, AVCodecContext *user_avctx, pthread_mutex_unlock(&p->mutex); return err; } @@ -4230,7 +4230,7 @@ index 80c15b35be..8faea75a49 100644 } av_packet_unref(p->avpkt); -@@ -669,14 +654,6 @@ void ff_thread_finish_setup(AVCodecContext *avctx) { +@@ -603,14 +588,6 @@ void ff_thread_finish_setup(AVCodecContext *avctx) { async_lock(p->parent); } @@ -4245,7 +4245,7 @@ index 80c15b35be..8faea75a49 100644 pthread_mutex_lock(&p->progress_mutex); if(atomic_load(&p->state) == STATE_SETUP_FINISHED){ av_log(avctx, AV_LOG_WARNING, "Multiple ff_thread_finish_setup() calls\n"); -@@ -730,6 +707,13 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) +@@ -664,6 +641,13 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) park_frame_worker_threads(fctx, thread_count); @@ -4259,7 +4259,7 @@ index 80c15b35be..8faea75a49 100644 for (i = 0; i < thread_count; i++) { PerThreadContext *p = &fctx->threads[i]; AVCodecContext *ctx = p->avctx; -@@ -776,13 +760,6 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) +@@ -705,13 +689,6 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) av_freep(&fctx->threads); ff_pthread_free(fctx, thread_ctx_offsets);