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 d437a10977..1c2a5ce747 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 @@ -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 858633e8c73b..41555d998257 100644 +index 858633e8c73..41555d99825 100644 --- a/libavutil/buffer.c +++ b/libavutil/buffer.c @@ -305,6 +305,19 @@ static void buffer_pool_free(AVBufferPool *pool) @@ -36,7 +36,7 @@ index 858633e8c73b..41555d998257 100644 { AVBufferPool *pool; diff --git a/libavutil/buffer.h b/libavutil/buffer.h -index 241a80ed6709..f41363faf1dc 100644 +index 241a80ed670..f41363faf1d 100644 --- a/libavutil/buffer.h +++ b/libavutil/buffer.h @@ -315,6 +315,11 @@ AVBufferPool *av_buffer_pool_init2(size_t size, void *opaque, @@ -69,7 +69,7 @@ Signed-off-by: Jonas Karlman create mode 100644 libavcodec/v4l2_request.h diff --git a/configure b/configure -index d7a3f507e834..f2e203d13463 100755 +index d7a3f507e83..f2e203d1346 100755 --- a/configure +++ b/configure @@ -279,6 +279,7 @@ External library support: @@ -141,7 +141,7 @@ index d7a3f507e834..f2e203d13463 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 33a280cf6953..90dfffcb2004 100644 +index 33a280cf695..90dfffcb200 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -155,6 +155,7 @@ OBJS-$(CONFIG_VP3DSP) += vp3dsp.o @@ -153,7 +153,7 @@ index 33a280cf6953..90dfffcb2004 100644 OBJS-$(CONFIG_WMV2DSP) += wmv2dsp.o diff --git a/libavcodec/hwconfig.h b/libavcodec/hwconfig.h -index f421dc909f44..ee78d8ab8e89 100644 +index f421dc909f4..ee78d8ab8e8 100644 --- a/libavcodec/hwconfig.h +++ b/libavcodec/hwconfig.h @@ -80,6 +80,8 @@ typedef struct AVCodecHWConfigInternal { @@ -167,7 +167,7 @@ index f421dc909f44..ee78d8ab8e89 100644 &(const AVCodecHWConfigInternal) { \ diff --git a/libavcodec/v4l2_request.c b/libavcodec/v4l2_request.c new file mode 100644 -index 000000000000..5234b5049b0d +index 00000000000..5234b5049b0 --- /dev/null +++ b/libavcodec/v4l2_request.c @@ -0,0 +1,984 @@ @@ -1157,7 +1157,7 @@ index 000000000000..5234b5049b0d +} diff --git a/libavcodec/v4l2_request.h b/libavcodec/v4l2_request.h new file mode 100644 -index 000000000000..58d2aa70af80 +index 00000000000..58d2aa70af8 --- /dev/null +++ b/libavcodec/v4l2_request.h @@ -0,0 +1,77 @@ @@ -1254,7 +1254,7 @@ Signed-off-by: Jonas Karlman 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c -index 2d0605c7f4f6..c3a7338a7043 100644 +index 2d0605c7f4f..c3a7338a704 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1830,7 +1830,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, @@ -1267,7 +1267,7 @@ index 2d0605c7f4f6..c3a7338a7043 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 b7b19ba4f162..0698ab95ba51 100644 +index b7b19ba4f16..0698ab95ba5 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -336,6 +336,7 @@ typedef struct H264SliceContext { @@ -1295,7 +1295,7 @@ 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 c3a7338a7043..c28b58cd5d95 100644 +index c3a7338a704..c28b58cd5d9 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1748,7 +1748,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, @@ -1336,7 +1336,7 @@ index c3a7338a7043..c28b58cd5d95 100644 if (sl->slice_type_nos != AV_PICTURE_TYPE_I && pps->cabac) { diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h -index 0698ab95ba51..2b39e82c3b03 100644 +index 0698ab95ba5..2b39e82c3b0 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -329,6 +329,7 @@ typedef struct H264SliceContext { @@ -1374,7 +1374,7 @@ Signed-off-by: Jonas Karlman create mode 100644 libavcodec/v4l2_request_h264.c diff --git a/configure b/configure -index f2e203d13463..b17e4108c1b6 100755 +index f2e203d1346..b17e4108c1b 100755 --- a/configure +++ b/configure @@ -2951,6 +2951,8 @@ h264_dxva2_hwaccel_deps="dxva2" @@ -1395,7 +1395,7 @@ index f2e203d13463..b17e4108c1b6 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 90dfffcb2004..426c7528e904 100644 +index 90dfffcb200..426c7528e90 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -935,6 +935,7 @@ OBJS-$(CONFIG_H264_D3D11VA_HWACCEL) += dxva2_h264.o @@ -1407,7 +1407,7 @@ index 90dfffcb2004..426c7528e904 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 c28b58cd5d95..0a10d00aad9e 100644 +index c28b58cd5d9..0a10d00aad9 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -768,6 +768,7 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) @@ -1429,7 +1429,7 @@ index c28b58cd5d95..0a10d00aad9e 100644 if (h->avctx->codec->pix_fmts) choices = h->avctx->codec->pix_fmts; diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c -index 0a999bef43d9..d78e3eaee3a8 100644 +index 0a999bef43d..d78e3eaee3a 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -1076,6 +1076,9 @@ AVCodec ff_h264_decoder = { @@ -1443,7 +1443,7 @@ index 0a999bef43d9..d78e3eaee3a8 100644 NULL }, diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h -index 8e54cf73f90f..969a1da0f4bc 100644 +index 8e54cf73f90..969a1da0f4b 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -32,6 +32,7 @@ extern const AVHWAccel ff_h264_d3d11va_hwaccel; @@ -1456,7 +1456,7 @@ index 8e54cf73f90f..969a1da0f4bc 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 000000000000..88da8f0a2db0 +index 00000000000..88da8f0a2db --- /dev/null +++ b/libavcodec/v4l2_request_h264.c @@ -0,0 +1,456 @@ @@ -1933,7 +1933,7 @@ Signed-off-by: Jonas Karlman create mode 100644 libavcodec/v4l2_request_mpeg2.c diff --git a/configure b/configure -index b17e4108c1b6..ec141fabbdc1 100755 +index b17e4108c1b..ec141fabbdc 100755 --- a/configure +++ b/configure @@ -2995,6 +2995,8 @@ mpeg2_dxva2_hwaccel_deps="dxva2" @@ -1954,7 +1954,7 @@ index b17e4108c1b6..ec141fabbdc1 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 426c7528e904..02c023a44772 100644 +index 426c7528e90..02c023a4477 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -955,6 +955,7 @@ OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL) += dxva2_mpeg2.o @@ -1966,7 +1966,7 @@ index 426c7528e904..02c023a44772 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 969a1da0f4bc..a8ae1483d8e1 100644 +index 969a1da0f4b..a8ae1483d8e 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -53,6 +53,7 @@ extern const AVHWAccel ff_mpeg2_d3d11va_hwaccel; @@ -1978,7 +1978,7 @@ index 969a1da0f4bc..a8ae1483d8e1 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 94221da2c158..4b0176f6cb19 100644 +index 94221da2c15..4b0176f6cb1 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -1147,6 +1147,9 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = { @@ -2003,7 +2003,7 @@ index 94221da2c158..4b0176f6cb19 100644 }, diff --git a/libavcodec/v4l2_request_mpeg2.c b/libavcodec/v4l2_request_mpeg2.c new file mode 100644 -index 000000000000..84d53209c79d +index 00000000000..84d53209c79 --- /dev/null +++ b/libavcodec/v4l2_request_mpeg2.c @@ -0,0 +1,159 @@ @@ -2185,7 +2185,7 @@ Signed-off-by: Jonas Karlman create mode 100644 libavcodec/v4l2_request_vp8.c diff --git a/configure b/configure -index ec141fabbdc1..f16bed65a3a3 100755 +index ec141fabbdc..f16bed65a3a 100755 --- a/configure +++ b/configure @@ -3027,6 +3027,8 @@ vc1_vdpau_hwaccel_deps="vdpau" @@ -2206,7 +2206,7 @@ index ec141fabbdc1..f16bed65a3a3 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 02c023a44772..c79d678eb3ee 100644 +index 02c023a4477..c79d678eb3e 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -971,6 +971,7 @@ OBJS-$(CONFIG_VC1_QSV_HWACCEL) += qsvdec.o @@ -2218,7 +2218,7 @@ index 02c023a44772..c79d678eb3ee 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 a8ae1483d8e1..9f8d41e367ed 100644 +index a8ae1483d8e..9f8d41e367e 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -69,6 +69,7 @@ extern const AVHWAccel ff_vc1_nvdec_hwaccel; @@ -2231,7 +2231,7 @@ index a8ae1483d8e1..9f8d41e367ed 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 000000000000..bc0fc400727a +index 00000000000..bc0fc400727 --- /dev/null +++ b/libavcodec/v4l2_request_vp8.c @@ -0,0 +1,180 @@ @@ -2416,7 +2416,7 @@ index 000000000000..bc0fc400727a + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c -index d16e7b6aa34e..8ee768d875ad 100644 +index d16e7b6aa34..8ee768d875a 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -176,6 +176,9 @@ static enum AVPixelFormat get_pixel_format(VP8Context *s) @@ -2440,7 +2440,7 @@ index d16e7b6aa34e..8ee768d875ad 100644 NULL }, -From 3c09465f9dee3355b0ef68140b86e9e66797b5fc Mon Sep 17 00:00:00 2001 +From 41c38b001277f252c052ba0493546184760a0a8e Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sat, 15 Dec 2018 22:32:16 +0100 Subject: [PATCH 08/17] Add V4L2 request API hevc hwaccel @@ -2452,12 +2452,12 @@ Signed-off-by: Jonas Karlman libavcodec/Makefile | 1 + libavcodec/hevcdec.c | 10 + libavcodec/hwaccels.h | 1 + - libavcodec/v4l2_request_hevc.c | 604 +++++++++++++++++++++++++++++++++ - 5 files changed, 619 insertions(+) + libavcodec/v4l2_request_hevc.c | 580 +++++++++++++++++++++++++++++++++ + 5 files changed, 595 insertions(+) create mode 100644 libavcodec/v4l2_request_hevc.c diff --git a/configure b/configure -index f16bed65a3a3..02a80cf27fd7 100755 +index f16bed65a3a..02a80cf27fd 100755 --- a/configure +++ b/configure @@ -2967,6 +2967,8 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" @@ -2478,7 +2478,7 @@ index f16bed65a3a3..02a80cf27fd7 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 c79d678eb3ee..0059074530c5 100644 +index c79d678eb3e..0059074530c 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -943,6 +943,7 @@ OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL) += dxva2_hevc.o @@ -2490,7 +2490,7 @@ index c79d678eb3ee..0059074530c5 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 2231aed2599b..7507966d7160 100644 +index 2231aed2599..7507966d716 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -392,6 +392,7 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) @@ -2532,7 +2532,7 @@ index 2231aed2599b..7507966d7160 100644 NULL }, diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h -index 9f8d41e367ed..ffb9fa5087d9 100644 +index 9f8d41e367e..ffb9fa5087d 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -40,6 +40,7 @@ extern const AVHWAccel ff_hevc_d3d11va_hwaccel; @@ -2545,10 +2545,10 @@ index 9f8d41e367ed..ffb9fa5087d9 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 000000000000..3a9d564ce20b +index 00000000000..fd253661086 --- /dev/null +++ b/libavcodec/v4l2_request_hevc.c -@@ -0,0 +1,604 @@ +@@ -0,0 +1,580 @@ +/* + * This file is part of FFmpeg. + * @@ -2632,32 +2632,6 @@ index 000000000000..3a9d564ce20b + } +} + -+static int find_frame_rps_type(const HEVCContext *h, uint64_t timestamp) -+{ -+ const HEVCFrame *frame; -+ int i; -+ -+ for (i = 0; i < h->rps[ST_CURR_BEF].nb_refs; i++) { -+ frame = h->rps[ST_CURR_BEF].ref[i]; -+ if (frame && timestamp == ff_v4l2_request_get_capture_timestamp(frame->frame)) -+ return V4L2_HEVC_DPB_ENTRY_RPS_ST_CURR_BEFORE; -+ } -+ -+ for (i = 0; i < h->rps[ST_CURR_AFT].nb_refs; i++) { -+ frame = h->rps[ST_CURR_AFT].ref[i]; -+ if (frame && timestamp == ff_v4l2_request_get_capture_timestamp(frame->frame)) -+ return V4L2_HEVC_DPB_ENTRY_RPS_ST_CURR_AFTER; -+ } -+ -+ for (i = 0; i < h->rps[LT_CURR].nb_refs; i++) { -+ frame = h->rps[LT_CURR].ref[i]; -+ if (frame && timestamp == ff_v4l2_request_get_capture_timestamp(frame->frame)) -+ return V4L2_HEVC_DPB_ENTRY_RPS_LT_CURR; -+ } -+ -+ return 0; -+} -+ +static void fill_dec_params(struct v4l2_ctrl_hevc_decode_params *dec_params, const HEVCContext *h) +{ + const HEVCFrame *pic = h->ref; @@ -2677,8 +2651,10 @@ index 000000000000..3a9d564ce20b + struct v4l2_hevc_dpb_entry *entry = &dec_params->dpb[entries++]; + + entry->timestamp = ff_v4l2_request_get_capture_timestamp(frame->frame); -+ entry->rps = find_frame_rps_type(h, entry->timestamp); + entry->field_pic = frame->frame->interlaced_frame; ++ entry->flags = 0; ++ if (frame->flags & HEVC_FRAME_FLAG_LONG_REF) ++ entry->flags |= V4L2_HEVC_DPB_ENTRY_LONG_TERM_REFERENCE; + + /* TODO: Interleaved: Get the POC for each field. */ + entry->pic_order_cnt[0] = frame->poc; @@ -3154,7 +3130,7 @@ index 000000000000..3a9d564ce20b + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; -From 140874637c7d3d99b69e6b30f0ad32b07d4e43e8 Mon Sep 17 00:00:00 2001 +From 3c9c4c99eccdda102064ea67a04c8cbf8083ad1a Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 12 Dec 2019 16:13:55 +0100 Subject: [PATCH 09/17] Add V4L2 request API VP9 hwaccel @@ -3173,7 +3149,7 @@ Signed-off-by: Jernej Skrabec create mode 100644 libavcodec/v4l2_request_vp9.c diff --git a/configure b/configure -index 02a80cf27fd7..0b238c051dff 100755 +index 02a80cf27fd..0b238c051df 100755 --- a/configure +++ b/configure @@ -3041,6 +3041,8 @@ vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9" @@ -3194,7 +3170,7 @@ index 02a80cf27fd7..0b238c051dff 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 0059074530c5..38edf1cfe5e5 100644 +index 0059074530c..38edf1cfe5e 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -977,6 +977,7 @@ OBJS-$(CONFIG_VP8_VAAPI_HWACCEL) += vaapi_vp8.o @@ -3206,7 +3182,7 @@ index 0059074530c5..38edf1cfe5e5 100644 OBJS-$(CONFIG_VP9_VDPAU_HWACCEL) += vdpau_vp9.o OBJS-$(CONFIG_VP8_QSV_HWACCEL) += qsvdec.o diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h -index ffb9fa5087d9..fc5d0b0479be 100644 +index ffb9fa5087d..fc5d0b0479b 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -76,6 +76,7 @@ extern const AVHWAccel ff_vp9_d3d11va_hwaccel; @@ -3219,7 +3195,7 @@ index ffb9fa5087d9..fc5d0b0479be 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 000000000000..9b95c76cdb82 +index 00000000000..9b95c76cdb8 --- /dev/null +++ b/libavcodec/v4l2_request_vp9.c @@ -0,0 +1,268 @@ @@ -3492,7 +3468,7 @@ index 000000000000..9b95c76cdb82 + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c -index 4659f94ee8b6..1b2f1eeaf69c 100644 +index 4659f94ee8b..1b2f1eeaf69 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -191,6 +191,7 @@ static int update_size(AVCodecContext *avctx, int w, int h) @@ -3761,40 +3737,40 @@ index 4659f94ee8b6..1b2f1eeaf69c 100644 for (i = 0; i < 2; i++) { - if (vp56_rac_get_prob_branchy(&s->c, 252)) +- s->prob.p.mv_comp[i].sign = + if (vp56_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.mv_comp[i].sign = -+ (vp8_rac_get_uint(&s->c, 7) << 1) | 1; - s->prob.p.mv_comp[i].sign = -- (vp8_rac_get_uint(&s->c, 7) << 1) | 1; + (vp8_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)) +- s->prob.p.mv_comp[i].classes[j] = + if (vp56_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; - s->prob.p.mv_comp[i].classes[j] = -- (vp8_rac_get_uint(&s->c, 7) << 1) | 1; + (vp8_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)) +- s->prob.p.mv_comp[i].class0 = + if (vp56_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.mv_comp[i].class0 = -+ (vp8_rac_get_uint(&s->c, 7) << 1) | 1; - s->prob.p.mv_comp[i].class0 = -- (vp8_rac_get_uint(&s->c, 7) << 1) | 1; + (vp8_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)) +- s->prob.p.mv_comp[i].bits[j] = + if (vp56_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; - s->prob.p.mv_comp[i].bits[j] = -- (vp8_rac_get_uint(&s->c, 7) << 1) | 1; + (vp8_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]; + } } @@ -3813,11 +3789,11 @@ index 4659f94ee8b6..1b2f1eeaf69c 100644 for (j = 0; j < 3; j++) - if (vp56_rac_get_prob_branchy(&s->c, 252)) +- s->prob.p.mv_comp[i].fp[j] = + if (vp56_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; - s->prob.p.mv_comp[i].fp[j] = -- (vp8_rac_get_uint(&s->c, 7) << 1) | 1; + (vp8_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]; + } } @@ -3825,20 +3801,20 @@ index 4659f94ee8b6..1b2f1eeaf69c 100644 if (s->s.h.highprecisionmvs) { for (i = 0; i < 2; i++) { - if (vp56_rac_get_prob_branchy(&s->c, 252)) +- s->prob.p.mv_comp[i].class0_hp = + if (vp56_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; - s->prob.p.mv_comp[i].class0_hp = -- (vp8_rac_get_uint(&s->c, 7) << 1) | 1; + (vp8_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)) +- s->prob.p.mv_comp[i].hp = + if (vp56_rac_get_prob_branchy(&s->c, 252)) { + s->prob_raw.p.mv_comp[i].hp = -+ (vp8_rac_get_uint(&s->c, 7) << 1) | 1; - s->prob.p.mv_comp[i].hp = -- (vp8_rac_get_uint(&s->c, 7) << 1) | 1; + (vp8_rac_get_uint(&s->c, 7) << 1) | 1; ++ s->prob.p.mv_comp[i].hp = + s->prob_raw.p.mv_comp[i].hp; + } } @@ -3855,7 +3831,7 @@ index 4659f94ee8b6..1b2f1eeaf69c 100644 NULL }, diff --git a/libavcodec/vp9dec.h b/libavcodec/vp9dec.h -index d82b258a3d81..8d2c341e0b97 100644 +index d82b258a3d8..8d2c341e0b9 100644 --- a/libavcodec/vp9dec.h +++ b/libavcodec/vp9dec.h @@ -131,6 +131,10 @@ typedef struct VP9Context { @@ -3870,7 +3846,7 @@ index d82b258a3d81..8d2c341e0b97 100644 // contextual (above) cache uint8_t *above_partition_ctx; diff --git a/libavcodec/vp9shared.h b/libavcodec/vp9shared.h -index 54726df742f9..fee3568736f7 100644 +index 54726df742f..fee3568736f 100644 --- a/libavcodec/vp9shared.h +++ b/libavcodec/vp9shared.h @@ -131,6 +131,7 @@ typedef struct VP9BitstreamHeader { @@ -3882,23 +3858,23 @@ index 54726df742f9..fee3568736f7 100644 uint8_t pred_prob[3]; struct { -From ae118fbbef1e287c5101d7ceaa164727d825c4c2 Mon Sep 17 00:00:00 2001 +From 3d23a6cb94067e5c2529955551d6a8fcc8e48acd Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Thu, 14 Feb 2019 23:20:05 +0100 -Subject: [PATCH 10/17] Add and use private linux v5.16 headers for V4L2 +Subject: [PATCH 10/17] Add and use private linux v5.18 headers for V4L2 request API ctrls Signed-off-by: Jernej Skrabec Signed-off-by: Jonas Karlman --- configure | 2 +- - libavcodec/hevc-ctrls.h | 252 +++++++++++++++++++++++++++++++++ + libavcodec/hevc-ctrls.h | 250 +++++++++++++++++++++++++++++++++ libavcodec/v4l2_request_hevc.c | 1 + - 3 files changed, 254 insertions(+), 1 deletion(-) + 3 files changed, 252 insertions(+), 1 deletion(-) create mode 100644 libavcodec/hevc-ctrls.h diff --git a/configure b/configure -index 0b238c051dff..1c1929d2c28f 100755 +index 0b238c051df..1c1929d2c28 100755 --- a/configure +++ b/configure @@ -2967,7 +2967,7 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" @@ -3912,10 +3888,10 @@ index 0b238c051dff..1c1929d2c28f 100755 hevc_vaapi_hwaccel_select="hevc_decoder" diff --git a/libavcodec/hevc-ctrls.h b/libavcodec/hevc-ctrls.h new file mode 100644 -index 000000000000..ef63bc205756 +index 00000000000..01ccda48d8c --- /dev/null +++ b/libavcodec/hevc-ctrls.h -@@ -0,0 +1,252 @@ +@@ -0,0 +1,250 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * These are the HEVC state controls for use with stateless HEVC @@ -4045,15 +4021,13 @@ index 000000000000..ef63bc205756 + __u64 flags; +}; + -+#define V4L2_HEVC_DPB_ENTRY_RPS_ST_CURR_BEFORE 0x01 -+#define V4L2_HEVC_DPB_ENTRY_RPS_ST_CURR_AFTER 0x02 -+#define V4L2_HEVC_DPB_ENTRY_RPS_LT_CURR 0x03 ++#define V4L2_HEVC_DPB_ENTRY_LONG_TERM_REFERENCE 0x01 + +#define V4L2_HEVC_DPB_ENTRIES_NUM_MAX 16 + +struct v4l2_hevc_dpb_entry { + __u64 timestamp; -+ __u8 rps; ++ __u8 flags; + __u8 field_pic; + __u16 pic_order_cnt[2]; + __u8 padding[2]; @@ -4169,7 +4143,7 @@ index 000000000000..ef63bc205756 + +#endif diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c -index 3a9d564ce20b..f645c538c25c 100644 +index fd253661086..949df3811ac 100644 --- a/libavcodec/v4l2_request_hevc.c +++ b/libavcodec/v4l2_request_hevc.c @@ -19,6 +19,7 @@ @@ -4181,7 +4155,7 @@ index 3a9d564ce20b..f645c538c25c 100644 #define MAX_SLICES 16 -From afe6727d8c300c77a72549b4e094910f09242a42 Mon Sep 17 00:00:00 2001 +From bb3cf90c0533a0096dff74b416f55832814293e0 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Mon, 29 Apr 2019 22:08:59 +0000 Subject: [PATCH 11/17] HACK: hwcontext_drm: do not require drm device @@ -4192,7 +4166,7 @@ Signed-off-by: Jonas Karlman 1 file changed, 5 insertions(+) diff --git a/libavutil/hwcontext_drm.c b/libavutil/hwcontext_drm.c -index 7a9fdbd263d4..6297d1f9b613 100644 +index 7a9fdbd263d..6297d1f9b61 100644 --- a/libavutil/hwcontext_drm.c +++ b/libavutil/hwcontext_drm.c @@ -53,6 +53,11 @@ static int drm_device_create(AVHWDeviceContext *hwdev, const char *device, @@ -4208,7 +4182,7 @@ index 7a9fdbd263d4..6297d1f9b613 100644 if (hwctx->fd < 0) return AVERROR(errno); -From bcad5ac25923b3d2395edceca821129c00b57b9e Mon Sep 17 00:00:00 2001 +From 0a9c478c1e826eb1ecff27da1206542614449de5 Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sat, 15 Dec 2018 22:32:16 +0100 Subject: [PATCH 12/17] WIP: hevc entry point offsets @@ -4220,10 +4194,10 @@ Signed-off-by: Jernej Skrabec 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libavcodec/hevc-ctrls.h b/libavcodec/hevc-ctrls.h -index ef63bc205756..a24916603017 100644 +index 01ccda48d8c..00bae349d34 100644 --- a/libavcodec/hevc-ctrls.h +++ b/libavcodec/hevc-ctrls.h -@@ -202,7 +202,9 @@ struct v4l2_ctrl_hevc_slice_params { +@@ -200,7 +200,9 @@ struct v4l2_ctrl_hevc_slice_params { __u8 ref_idx_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; __u8 ref_idx_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; @@ -4235,10 +4209,10 @@ index ef63bc205756..a24916603017 100644 /* ISO/IEC 23008-2, ITU-T Rec. H.265: Weighted prediction parameter */ struct v4l2_hevc_pred_weight_table pred_weight_table; diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c -index f645c538c25c..601202a77d7a 100644 +index 949df3811ac..b74244f3be6 100644 --- a/libavcodec/v4l2_request_hevc.c +++ b/libavcodec/v4l2_request_hevc.c -@@ -256,6 +256,15 @@ static void v4l2_request_hevc_fill_slice_params(const HEVCContext *h, +@@ -232,6 +232,15 @@ static void v4l2_request_hevc_fill_slice_params(const HEVCContext *h, } v4l2_request_hevc_fill_pred_table(h, &slice_params->pred_weight_table); @@ -4255,7 +4229,7 @@ index f645c538c25c..601202a77d7a 100644 static void fill_sps(struct v4l2_ctrl_hevc_sps *ctrl, const HEVCContext *h) -From 694b79d528295ae4d073c5972d35173116ff2b69 Mon Sep 17 00:00:00 2001 +From 154405d2d8987c741e722f59430fda9326c8cdef Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Fri, 15 May 2020 16:54:05 +0000 Subject: [PATCH 13/17] WIP: add NV15 and NV20 support @@ -4267,7 +4241,7 @@ 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 0a10d00aad9e..45057fd049bd 100644 +index 0a10d00aad9..45057fd049b 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -794,10 +794,17 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) @@ -4301,7 +4275,7 @@ index 0a10d00aad9e..45057fd049bd 100644 *fmt++ = AV_PIX_FMT_YUVJ422P; else diff --git a/libavcodec/v4l2_request.c b/libavcodec/v4l2_request.c -index 5234b5049b0d..0b294feff2eb 100644 +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[] = { @@ -4342,7 +4316,7 @@ index 5234b5049b0d..0b294feff2eb 100644 default: return -1; -From dd29c8e4b504f12be27db8e188ba5bbaade7559f Mon Sep 17 00:00:00 2001 +From d7933e19a712a59af418f6b029c0984d5b29afe9 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Mon, 27 Jul 2020 23:15:45 +0000 Subject: [PATCH 14/17] HACK: define drm NV15 and NV20 format @@ -4352,7 +4326,7 @@ Subject: [PATCH 14/17] HACK: define drm NV15 and NV20 format 1 file changed, 8 insertions(+) diff --git a/libavcodec/v4l2_request.c b/libavcodec/v4l2_request.c -index 0b294feff2eb..a8f0ee79eeef 100644 +index 0b294feff2e..a8f0ee79eee 100644 --- a/libavcodec/v4l2_request.c +++ b/libavcodec/v4l2_request.c @@ -30,6 +30,14 @@ @@ -4371,7 +4345,7 @@ index 0b294feff2eb..a8f0ee79eeef 100644 { V4L2RequestDescriptor *req = (V4L2RequestDescriptor*)frame->data[0]; -From 0d56f3e7b04a5d574d38dd885000a6eb19eff903 Mon Sep 17 00:00:00 2001 +From 7ebf970204f1aaabc3d0ca0c81d8d4dd99916c56 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Wed, 13 May 2020 22:51:21 +0000 Subject: [PATCH 15/17] WIP: hevc rkvdec fields @@ -4383,7 +4357,7 @@ Signed-off-by: Jonas Karlman 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/libavcodec/hevc-ctrls.h b/libavcodec/hevc-ctrls.h -index a24916603017..cd143526685f 100644 +index 00bae349d34..2ecec618669 100644 --- a/libavcodec/hevc-ctrls.h +++ b/libavcodec/hevc-ctrls.h @@ -58,6 +58,8 @@ enum v4l2_mpeg_video_hevc_start_code { @@ -4422,7 +4396,7 @@ index a24916603017..cd143526685f 100644 __u64 flags; }; -@@ -202,6 +208,9 @@ struct v4l2_ctrl_hevc_slice_params { +@@ -200,6 +206,9 @@ struct v4l2_ctrl_hevc_slice_params { __u8 ref_idx_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; __u8 ref_idx_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; @@ -4433,10 +4407,10 @@ index a24916603017..cd143526685f 100644 __u32 entry_point_offset_minus1[256]; __u8 padding[8]; diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c -index 601202a77d7a..be7838244447 100644 +index b74244f3be6..093700c4063 100644 --- a/libavcodec/v4l2_request_hevc.c +++ b/libavcodec/v4l2_request_hevc.c -@@ -214,6 +214,9 @@ static void v4l2_request_hevc_fill_slice_params(const HEVCContext *h, +@@ -190,6 +190,9 @@ static void v4l2_request_hevc_fill_slice_params(const HEVCContext *h, /* ISO/IEC 23008-2, ITU-T Rec. H.265: Picture timing SEI message */ .pic_struct = h->sei.picture_timing.picture_struct, @@ -4446,7 +4420,7 @@ index 601202a77d7a..be7838244447 100644 }; if (sh->slice_sample_adaptive_offset_flag[0]) -@@ -270,9 +273,12 @@ static void v4l2_request_hevc_fill_slice_params(const HEVCContext *h, +@@ -246,9 +249,12 @@ static void v4l2_request_hevc_fill_slice_params(const HEVCContext *h, static void fill_sps(struct v4l2_ctrl_hevc_sps *ctrl, const HEVCContext *h) { const HEVCSPS *sps = h->ps.sps; @@ -4459,7 +4433,7 @@ index 601202a77d7a..be7838244447 100644 .pic_width_in_luma_samples = sps->width, .pic_height_in_luma_samples = sps->height, .bit_depth_luma_minus8 = sps->bit_depth - 8, -@@ -336,6 +342,7 @@ static int v4l2_request_hevc_start_frame(AVCodecContext *avctx, +@@ -312,6 +318,7 @@ static int v4l2_request_hevc_start_frame(AVCodecContext *avctx, &pps->scaling_list : sps->scaling_list_enable_flag ? &sps->scaling_list : NULL; @@ -4467,7 +4441,7 @@ index 601202a77d7a..be7838244447 100644 V4L2RequestControlsHEVC *controls = h->ref->hwaccel_picture_private; fill_sps(&controls->sps, h); -@@ -359,6 +366,9 @@ static int v4l2_request_hevc_start_frame(AVCodecContext *avctx, +@@ -335,6 +342,9 @@ static int v4l2_request_hevc_start_frame(AVCodecContext *avctx, /* ISO/IEC 23008-2, ITU-T Rec. H.265: Picture parameter set */ controls->pps = (struct v4l2_ctrl_hevc_pps) { @@ -4477,7 +4451,7 @@ index 601202a77d7a..be7838244447 100644 .num_extra_slice_header_bits = pps->num_extra_slice_header_bits, .num_ref_idx_l0_default_active_minus1 = pps->num_ref_idx_l0_default_active - 1, .num_ref_idx_l1_default_active_minus1 = pps->num_ref_idx_l1_default_active - 1, -@@ -488,6 +498,8 @@ static int v4l2_request_hevc_queue_decode(AVCodecContext *avctx, int last_slice) +@@ -464,6 +474,8 @@ static int v4l2_request_hevc_queue_decode(AVCodecContext *avctx, int last_slice) if (ctx->decode_mode == V4L2_MPEG_VIDEO_HEVC_DECODE_MODE_SLICE_BASED) return ff_v4l2_request_decode_slice(avctx, h->ref->frame, control, FF_ARRAY_ELEMS(control), controls->first_slice, last_slice); @@ -4487,7 +4461,7 @@ index 601202a77d7a..be7838244447 100644 } -From eb9a3213d56d9f6a177f16e907f57e0063b23244 Mon Sep 17 00:00:00 2001 +From c9ae9a29ef84096bb2e4d37fbdea6c3b3d20fff7 Mon Sep 17 00:00:00 2001 From: Alex Bee Date: Sun, 19 Sep 2021 13:10:55 +0200 Subject: [PATCH 16/17] v4l2_request: validate supported framesizes @@ -4498,7 +4472,7 @@ Signed-off-by: Alex Bee 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/libavcodec/v4l2_request.c b/libavcodec/v4l2_request.c -index a8f0ee79eeef..2fbe16634160 100644 +index a8f0ee79eee..2fbe1663416 100644 --- a/libavcodec/v4l2_request.c +++ b/libavcodec/v4l2_request.c @@ -376,6 +376,42 @@ int ff_v4l2_request_decode_frame(AVCodecContext *avctx, AVFrame *frame, struct v @@ -4554,7 +4528,7 @@ index a8f0ee79eeef..2fbe16634160 100644 fmtdesc.index++; } -From 5607e918e68f9eb3280914b04e93ebff766e9e02 Mon Sep 17 00:00:00 2001 +From c415926540fe04141bb1e8cabd24049b61752d4f Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sun, 27 Feb 2022 18:54:21 +0100 Subject: [PATCH 17/17] Improve VP9 decoding @@ -4564,7 +4538,7 @@ Subject: [PATCH 17/17] Improve VP9 decoding 1 file changed, 62 insertions(+), 48 deletions(-) diff --git a/libavcodec/v4l2_request_vp9.c b/libavcodec/v4l2_request_vp9.c -index 9b95c76cdb82..ec0300f66dbe 100644 +index 9b95c76cdb8..ec0300f66db 100644 --- a/libavcodec/v4l2_request_vp9.c +++ b/libavcodec/v4l2_request_vp9.c @@ -22,78 +22,62 @@