diff --git a/packages/multimedia/ffmpeg/package.mk b/packages/multimedia/ffmpeg/package.mk index 290cfa7151..2f8114a535 100644 --- a/packages/multimedia/ffmpeg/package.mk +++ b/packages/multimedia/ffmpeg/package.mk @@ -27,12 +27,10 @@ case "${PROJECT}" in PKG_PATCH_DIRS+=" rpi" ;; L4T) - if [ ! "${DISTRO}" = "LibreELEC" ]; then PKG_DEPENDS_TARGET+=" tegra-bsp:host" PKG_PATCH_DIRS+=" L4T" PKG_FFMPEG_NVV4L2="--enable-nvv4l2" EXTRA_CFLAGS="-I${SYSROOT_PREFIX}/usr/src/jetson_multimedia_api/include" - fi ;; *) if [ "${DISPLAYSERVER}" = "x11" ]; then diff --git a/packages/multimedia/ffmpeg/patches/L4T/0001-codecs-add-nvv4l2-codec-for-Nvidia-Tegra-SOCs.patch b/packages/multimedia/ffmpeg/patches/L4T/0001-codecs-add-nvv4l2-codec-for-Nvidia-Tegra-SOCs.patch index 298d85517c..d8c0a9e742 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0001-codecs-add-nvv4l2-codec-for-Nvidia-Tegra-SOCs.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0001-codecs-add-nvv4l2-codec-for-Nvidia-Tegra-SOCs.patch @@ -1,7 +1,69 @@ -diff -Naur ffmpeg-6.0/configure ffmpeg-6.0-2/configure ---- ffmpeg-6.0/configure 2023-06-04 19:34:55.681571179 +0200 -+++ ffmpeg-6.0-2/configure 2023-06-04 19:40:31.395734934 +0200 -@@ -336,6 +336,7 @@ +From 7df787ecf3260cbb9f370290afc13b77de740c4c Mon Sep 17 00:00:00 2001 +From: CTCaer +Date: Sat, 5 Mar 2022 03:27:27 +0000 +Subject: [PATCH 01/39] codecs: add nvv4l2 codec for Nvidia Tegra SOCs + +Use `--enable-nvv4l2` to enable it. + +This Codec uses customized V4L2, called NVV4L2 that adds various features. +NVV4L2 uses the Tegra HW video engines NVDEC and NVENC. + +Decoder features: +- Codecs: MPEG2, MPEG4, H264, HEVC, VP8, VP9 +- Output: YUV420, NV12 +- Low latency mode for realtime streaming by using `AV_CODEC_FLAG_LOW_DELAY` +- Higher throughput than original Nvidia specs and provided software. + (Tegra X1: 4k@63, 1080p@265, 720p@439) + +Encoder features: +- Codecs: H264, HEVC +- Output: YUV420, YUV444, NV12, P010 +- Higher throughput than original Nvidia specs and provided software. + (Tegra X1: 4k@60, 1080p@202, 720p@414) + +- Options for H264: + profile: baseline, main (default), high, high444 + level: 1.0 to 5.1 (default). (5.1 is L4T kernel limitation. Max is 6.2.) + rc: cbr, vbr (default) + lossless: off (default), on. (Sets profile to high444 and constant QP to 0) + preset: default (medium), slow, medium (default), fast, ultrafast + num_capture_buffers: 1 to 32. (Default: 10) + AVCodec defaults: b: 5M, g: 50, all others unchanged. + +- Options for HEVC: + profile: main (default), main10 + tier: main (default), high + level: 1.0 to 6.2 (default) + rc: cbr, vbr (default) + lossless: off (default), on. (Sets constant QP to 0) + preset: default (medium), slow, medium (default), fast, ultrafast + num_capture_buffers: 1 to 32. (Default: 10) + AVCodec defaults: b: 5M, g: 50, all others unchanged. + +Decoder to Encoder speed: +FPS are halved. + +Some formats are supported from Tegra X1 and up. +For more, check the NVDEC/NVENC version support matrix. +--- + configure | 23 + + libavcodec/Makefile | 14 +- + libavcodec/allcodecs.c | 8 + + libavcodec/nvv4l2.c | 820 +++++++++++++++++++++++ + libavcodec/nvv4l2.h | 324 +++++++++ + libavcodec/nvv4l2_dec.c | 1101 +++++++++++++++++++++++++++++++ + libavcodec/nvv4l2_enc.c | 1389 +++++++++++++++++++++++++++++++++++++++ + 7 files changed, 3678 insertions(+), 1 deletion(-) + create mode 100644 libavcodec/nvv4l2.c + create mode 100644 libavcodec/nvv4l2.h + create mode 100644 libavcodec/nvv4l2_dec.c + create mode 100644 libavcodec/nvv4l2_enc.c + +diff --git a/configure b/configure +index 3cd3bdfb44..889b547071 100755 +--- a/configure ++++ b/configure +@@ -336,6 +336,7 @@ External library support: --enable-cuda-nvcc enable Nvidia CUDA compiler [no] --disable-cuda-llvm disable CUDA compilation using clang [autodetect] --disable-cuvid disable Nvidia CUVID support [autodetect] @@ -9,7 +71,7 @@ diff -Naur ffmpeg-6.0/configure ffmpeg-6.0-2/configure --disable-d3d11va disable Microsoft Direct3D 11 video acceleration code [autodetect] --disable-dxva2 disable Microsoft DirectX 9 video acceleration code [autodetect] --disable-ffnvcodec disable dynamically linked Nvidia code [autodetect] -@@ -1887,6 +1888,7 @@ +@@ -1887,6 +1888,7 @@ HWACCEL_AUTODETECT_LIBRARY_LIST=" ffnvcodec nvdec nvenc @@ -17,7 +79,7 @@ diff -Naur ffmpeg-6.0/configure ffmpeg-6.0-2/configure vaapi vdpau videotoolbox -@@ -3129,6 +3131,8 @@ +@@ -3129,6 +3131,8 @@ qsvenc_select="qsv" qsvvpp_select="qsv" vaapi_encode_deps="vaapi" v4l2_m2m_deps="linux_videodev2_h sem_timedwait" @@ -26,17 +88,18 @@ diff -Naur ffmpeg-6.0/configure ffmpeg-6.0-2/configure bilateral_cuda_filter_deps="ffnvcodec" bilateral_cuda_filter_deps_any="cuda_nvcc cuda_llvm" -@@ -3177,6 +3181,9 @@ - h264_mmal_decoder_deps="mmal" - h264_nvenc_encoder_deps="nvenc" - h264_nvenc_encoder_select="atsc_a53" +@@ -3153,6 +3157,10 @@ ddagrab_filter_deps="d3d11va IDXGIOutput1 DXGI_OUTDUPL_FRAME_INFO" + amf_deps_any="libdl LoadLibrary" + nvenc_deps="ffnvcodec" + nvenc_deps_any="libdl LoadLibrary" ++nvenc_encoder_deps="nvenc" +h264_nvv4l2_encoder_deps="nvv4l2" +h264_nvv4l2_decoder_deps="nvv4l2" +h264_nvv4l2_decoder_select="h264_mp4toannexb_bsf" - h264_omx_encoder_deps="omx" - h264_qsv_decoder_select="h264_mp4toannexb_bsf qsvdec" - h264_qsv_encoder_select="atsc_a53 qsvenc" -@@ -3197,6 +3204,9 @@ + + aac_mf_encoder_deps="mediafoundation" + ac3_mf_encoder_deps="mediafoundation" +@@ -3197,6 +3205,9 @@ hevc_mediacodec_encoder_extralibs="-landroid" hevc_mediacodec_encoder_select="hevc_metadata" hevc_mf_encoder_deps="mediafoundation" hevc_nvenc_encoder_deps="nvenc" @@ -46,7 +109,7 @@ diff -Naur ffmpeg-6.0/configure ffmpeg-6.0-2/configure hevc_nvenc_encoder_select="atsc_a53" hevc_qsv_decoder_select="hevc_mp4toannexb_bsf qsvdec" hevc_qsv_encoder_select="hevcparse qsvenc" -@@ -3220,6 +3230,7 @@ +@@ -3220,6 +3231,7 @@ mpeg2_crystalhd_decoder_select="crystalhd" mpeg2_cuvid_decoder_deps="cuvid" mpeg2_mmal_decoder_deps="mmal" mpeg2_mediacodec_decoder_deps="mediacodec" @@ -54,7 +117,7 @@ diff -Naur ffmpeg-6.0/configure ffmpeg-6.0-2/configure mpeg2_qsv_decoder_select="qsvdec" mpeg2_qsv_encoder_select="qsvenc" mpeg2_vaapi_encoder_select="cbs_mpeg2 vaapi_encode" -@@ -3228,6 +3239,7 @@ +@@ -3228,6 +3240,7 @@ mpeg4_crystalhd_decoder_select="crystalhd" mpeg4_cuvid_decoder_deps="cuvid" mpeg4_mediacodec_decoder_deps="mediacodec" mpeg4_mmal_decoder_deps="mmal" @@ -62,7 +125,7 @@ diff -Naur ffmpeg-6.0/configure ffmpeg-6.0-2/configure mpeg4_omx_encoder_deps="omx" mpeg4_v4l2m2m_decoder_deps="v4l2_m2m mpeg4_v4l2_m2m" mpeg4_v4l2m2m_encoder_deps="v4l2_m2m mpeg4_v4l2_m2m" -@@ -3239,6 +3251,7 @@ +@@ -3239,6 +3252,7 @@ vc1_qsv_decoder_select="qsvdec" vc1_v4l2m2m_decoder_deps="v4l2_m2m vc1_v4l2_m2m" vp8_cuvid_decoder_deps="cuvid" vp8_mediacodec_decoder_deps="mediacodec" @@ -70,7 +133,7 @@ diff -Naur ffmpeg-6.0/configure ffmpeg-6.0-2/configure vp8_qsv_decoder_select="qsvdec" vp8_rkmpp_decoder_deps="rkmpp" vp8_vaapi_encoder_deps="VAEncPictureParameterBufferVP8" -@@ -3247,6 +3260,7 @@ +@@ -3247,6 +3261,7 @@ vp8_v4l2m2m_decoder_deps="v4l2_m2m vp8_v4l2_m2m" vp8_v4l2m2m_encoder_deps="v4l2_m2m vp8_v4l2_m2m" vp9_cuvid_decoder_deps="cuvid" vp9_mediacodec_decoder_deps="mediacodec" @@ -78,7 +141,7 @@ diff -Naur ffmpeg-6.0/configure ffmpeg-6.0-2/configure vp9_qsv_decoder_select="qsvdec" vp9_rkmpp_decoder_deps="rkmpp" vp9_vaapi_encoder_deps="VAEncPictureParameterBufferVP9" -@@ -3537,6 +3551,7 @@ +@@ -3537,6 +3552,7 @@ kmsgrab_indev_deps="libdrm" lavfi_indev_deps="avfilter" libcdio_indev_deps="libcdio" libdc1394_indev_deps="libdc1394" @@ -86,7 +149,7 @@ diff -Naur ffmpeg-6.0/configure ffmpeg-6.0-2/configure openal_indev_deps="openal" opengl_outdev_deps="opengl" opengl_outdev_suggest="sdl2" -@@ -7054,6 +7069,13 @@ +@@ -7054,6 +7070,13 @@ if enabled_any nvdec cuvid; then check_type "ffnvcodec/dynlink_cuda.h ffnvcodec/dynlink_cuviddec.h" "CUVIDAV1PICPARAMS" fi @@ -100,70 +163,37 @@ diff -Naur ffmpeg-6.0/configure ffmpeg-6.0-2/configure enabled amf && check_cpp_condition amf "AMF/core/Version.h" \ "(AMF_VERSION_MAJOR << 48 | AMF_VERSION_MINOR << 32 | AMF_VERSION_RELEASE << 16 | AMF_VERSION_BUILD_NUM) >= 0x00010004001c0000" -diff -Naur ffmpeg-6.0/libavcodec/allcodecs.c ffmpeg-6.0-2/libavcodec/allcodecs.c ---- ffmpeg-6.0/libavcodec/allcodecs.c 2023-06-04 19:34:55.301564187 +0200 -+++ ffmpeg-6.0-2/libavcodec/allcodecs.c 2023-06-04 19:54:39.714797058 +0200 -@@ -150,6 +150,8 @@ - extern const FFCodec ff_h263p_encoder; - extern const FFCodec ff_h263p_decoder; - extern const FFCodec ff_h263_v4l2m2m_decoder; -+extern const FFCodec ff_h264_nvv4l2_encoder; -+extern const FFCodec ff_h264_nvv4l2_decoder; - extern const FFCodec ff_h264_decoder; - extern const FFCodec ff_h264_crystalhd_decoder; - extern const FFCodec ff_h264_v4l2m2m_decoder; -@@ -160,6 +162,8 @@ - extern const FFCodec ff_h264_rkmpp_decoder; - extern const FFCodec ff_hap_encoder; - extern const FFCodec ff_hap_decoder; -+extern const FFCodec ff_hevc_nvv4l2_encoder; -+extern const FFCodec ff_hevc_nvv4l2_decoder; - extern const FFCodec ff_hevc_decoder; - extern const FFCodec ff_hevc_qsv_decoder; - extern const FFCodec ff_hevc_rkmpp_decoder; -@@ -205,8 +209,10 @@ - extern const FFCodec ff_motionpixels_decoder; - extern const FFCodec ff_mpeg1video_encoder; - extern const FFCodec ff_mpeg1video_decoder; -+extern const FFCodec ff_mpeg2_nvv4l2_decoder; - extern const FFCodec ff_mpeg2video_encoder; - extern const FFCodec ff_mpeg2video_decoder; -+extern const FFCodec ff_mpeg4_nvv4l2_decoder; - extern const FFCodec ff_mpeg4_encoder; - extern const FFCodec ff_mpeg4_decoder; - extern const FFCodec ff_mpeg4_crystalhd_decoder; -@@ -376,9 +382,11 @@ - extern const FFCodec ff_vp6a_decoder; - extern const FFCodec ff_vp6f_decoder; - extern const FFCodec ff_vp7_decoder; -+extern const FFCodec ff_vp8_nvv4l2_decoder; - extern const FFCodec ff_vp8_decoder; - extern const FFCodec ff_vp8_rkmpp_decoder; - extern const FFCodec ff_vp8_v4l2m2m_decoder; -+extern const FFCodec ff_vp9_nvv4l2_decoder; - extern const FFCodec ff_vp9_decoder; - extern const FFCodec ff_vp9_rkmpp_decoder; - extern const FFCodec ff_vp9_v4l2m2m_decoder; -diff -Naur ffmpeg-6.0/libavcodec/Makefile ffmpeg-6.0-2/libavcodec/Makefile ---- ffmpeg-6.0/libavcodec/Makefile 2023-06-04 19:34:55.229562862 +0200 -+++ ffmpeg-6.0-2/libavcodec/Makefile 2023-06-04 19:45:38.465357287 +0200 -@@ -148,6 +148,7 @@ +diff --git a/libavcodec/Makefile b/libavcodec/Makefile +index 389253f5d0..78f43ca9a1 100644 +--- a/libavcodec/Makefile ++++ b/libavcodec/Makefile +@@ -148,6 +148,8 @@ OBJS-$(CONFIG_MSMPEG4DEC) += msmpeg4dec.o msmpeg4.o msmpeg4data.o \ OBJS-$(CONFIG_MSMPEG4ENC) += msmpeg4enc.o msmpeg4.o msmpeg4data.o \ msmpeg4_vc1_data.o OBJS-$(CONFIG_MSS34DSP) += mss34dsp.o jpegquanttables.o ++OBJS-$(CONFIG_NVENC) += nvenc.o +OBJS-$(CONFIG_NVV4L2) += nvv4l2.o OBJS-$(CONFIG_PIXBLOCKDSP) += pixblockdsp.o OBJS-$(CONFIG_QPELDSP) += qpeldsp.o OBJS-$(CONFIG_QSV) += qsv.o -@@ -409,6 +410,7 @@ +@@ -404,11 +406,15 @@ OBJS-$(CONFIG_H264_DECODER) += h264dec.o h264_cabac.o h264_cavlc.o \ + h264_slice.o h264data.o h274.o + OBJS-$(CONFIG_H264_AMF_ENCODER) += amfenc_h264.o + OBJS-$(CONFIG_H264_CUVID_DECODER) += cuviddec.o ++OBJS-$(CONFIG_H264_NVV4L2_DECODER) += nvv4l2_dec.o + OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec.o + OBJS-$(CONFIG_H264_MEDIACODEC_ENCODER) += mediacodecenc.o OBJS-$(CONFIG_H264_MF_ENCODER) += mfenc.o mf_utils.o OBJS-$(CONFIG_H264_MMAL_DECODER) += mmaldec.o - OBJS-$(CONFIG_H264_NVENC_ENCODER) += nvenc_h264.o nvenc.o +-OBJS-$(CONFIG_H264_NVENC_ENCODER) += nvenc_h264.o nvenc.o ++OBJS-$(CONFIG_H264_NVENC_ENCODER) += nvenc_h264.o ++OBJS-$(CONFIG_NVENC_ENCODER) += nvenc_h264.o ++OBJS-$(CONFIG_NVENC_H264_ENCODER) += nvenc_h264.o +OBJS-$(CONFIG_H264_NVV4L2_ENCODER) += nvv4l2_enc.o OBJS-$(CONFIG_H264_OMX_ENCODER) += omx.o OBJS-$(CONFIG_H264_QSV_DECODER) += qsvdec.o OBJS-$(CONFIG_H264_QSV_ENCODER) += qsvenc_h264.o -@@ -430,6 +432,7 @@ +@@ -430,6 +436,7 @@ OBJS-$(CONFIG_HEVC_DECODER) += hevcdec.o hevc_mvs.o \ h274.o OBJS-$(CONFIG_HEVC_AMF_ENCODER) += amfenc_hevc.o OBJS-$(CONFIG_HEVC_CUVID_DECODER) += cuviddec.o @@ -171,7 +201,7 @@ diff -Naur ffmpeg-6.0/libavcodec/Makefile ffmpeg-6.0-2/libavcodec/Makefile OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_HEVC_MEDIACODEC_ENCODER) += mediacodecenc.o OBJS-$(CONFIG_HEVC_MF_ENCODER) += mfenc.o mf_utils.o -@@ -441,6 +444,7 @@ +@@ -441,6 +448,7 @@ OBJS-$(CONFIG_HEVC_RKMPP_DECODER) += rkmppdec.o OBJS-$(CONFIG_HEVC_VAAPI_ENCODER) += vaapi_encode_h265.o h265_profile_level.o \ h2645data.o OBJS-$(CONFIG_HEVC_V4L2M2M_DECODER) += v4l2_m2m_dec.o @@ -179,7 +209,7 @@ diff -Naur ffmpeg-6.0/libavcodec/Makefile ffmpeg-6.0-2/libavcodec/Makefile OBJS-$(CONFIG_HEVC_V4L2M2M_ENCODER) += v4l2_m2m_enc.o OBJS-$(CONFIG_HEVC_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o OBJS-$(CONFIG_HNM4_VIDEO_DECODER) += hnm4video.o -@@ -535,12 +539,14 @@ +@@ -535,12 +543,14 @@ OBJS-$(CONFIG_MPEG2_QSV_ENCODER) += qsvenc_mpeg2.o OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o OBJS-$(CONFIG_MPEG2_CUVID_DECODER) += cuviddec.o @@ -194,7 +224,7 @@ diff -Naur ffmpeg-6.0/libavcodec/Makefile ffmpeg-6.0-2/libavcodec/Makefile OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_MPEG4_OMX_ENCODER) += omx.o OBJS-$(CONFIG_MPEG4_V4L2M2M_DECODER) += v4l2_m2m_dec.o -@@ -763,6 +769,7 @@ +@@ -763,6 +773,7 @@ OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o \ OBJS-$(CONFIG_VP7_DECODER) += vp8.o vpx_rac.o OBJS-$(CONFIG_VP8_DECODER) += vp8.o vpx_rac.o OBJS-$(CONFIG_VP8_CUVID_DECODER) += cuviddec.o @@ -202,7 +232,7 @@ diff -Naur ffmpeg-6.0/libavcodec/Makefile ffmpeg-6.0-2/libavcodec/Makefile OBJS-$(CONFIG_VP8_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_VP8_QSV_DECODER) += qsvdec.o OBJS-$(CONFIG_VP8_RKMPP_DECODER) += rkmppdec.o -@@ -773,6 +780,7 @@ +@@ -773,6 +784,7 @@ OBJS-$(CONFIG_VP9_DECODER) += vp9.o vp9data.o vp9dsp.o vp9lpf.o vp9r vp9block.o vp9prob.o vp9mvs.o vpx_rac.o \ vp9dsp_8bpp.o vp9dsp_10bpp.o vp9dsp_12bpp.o OBJS-$(CONFIG_VP9_CUVID_DECODER) += cuviddec.o @@ -210,9 +240,56 @@ diff -Naur ffmpeg-6.0/libavcodec/Makefile ffmpeg-6.0-2/libavcodec/Makefile OBJS-$(CONFIG_VP9_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_VP9_RKMPP_DECODER) += rkmppdec.o OBJS-$(CONFIG_VP9_VAAPI_ENCODER) += vaapi_encode_vp9.o -diff -Naur ffmpeg-6.0/libavcodec/nvv4l2.c ffmpeg-6.0-2/libavcodec/nvv4l2.c ---- ffmpeg-6.0/libavcodec/nvv4l2.c 1970-01-01 01:00:00.000000000 +0100 -+++ ffmpeg-6.0-2/libavcodec/nvv4l2.c 2023-06-04 19:38:13.741210367 +0200 +diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c +index e593ad19af..8eb911eec2 100644 +--- a/libavcodec/allcodecs.c ++++ b/libavcodec/allcodecs.c +@@ -150,6 +150,8 @@ extern const FFCodec ff_h263i_decoder; + extern const FFCodec ff_h263p_encoder; + extern const FFCodec ff_h263p_decoder; + extern const FFCodec ff_h263_v4l2m2m_decoder; ++extern const FFCodec ff_h264_nvv4l2_encoder; ++extern const FFCodec ff_h264_nvv4l2_decoder; + extern const FFCodec ff_h264_decoder; + extern const FFCodec ff_h264_crystalhd_decoder; + extern const FFCodec ff_h264_v4l2m2m_decoder; +@@ -160,6 +162,8 @@ extern const FFCodec ff_h264_qsv_decoder; + extern const FFCodec ff_h264_rkmpp_decoder; + extern const FFCodec ff_hap_encoder; + extern const FFCodec ff_hap_decoder; ++extern const FFCodec ff_hevc_nvv4l2_encoder; ++extern const FFCodec ff_hevc_nvv4l2_decoder; + extern const FFCodec ff_hevc_decoder; + extern const FFCodec ff_hevc_qsv_decoder; + extern const FFCodec ff_hevc_rkmpp_decoder; +@@ -205,8 +209,10 @@ extern const FFCodec ff_mobiclip_decoder; + extern const FFCodec ff_motionpixels_decoder; + extern const FFCodec ff_mpeg1video_encoder; + extern const FFCodec ff_mpeg1video_decoder; ++extern const FFCodec ff_mpeg2_nvv4l2_decoder; + extern const FFCodec ff_mpeg2video_encoder; + extern const FFCodec ff_mpeg2video_decoder; ++extern const FFCodec ff_mpeg4_nvv4l2_decoder; + extern const FFCodec ff_mpeg4_encoder; + extern const FFCodec ff_mpeg4_decoder; + extern const FFCodec ff_mpeg4_crystalhd_decoder; +@@ -376,9 +382,11 @@ extern const FFCodec ff_vp6_decoder; + extern const FFCodec ff_vp6a_decoder; + extern const FFCodec ff_vp6f_decoder; + extern const FFCodec ff_vp7_decoder; ++extern const FFCodec ff_vp8_nvv4l2_decoder; + extern const FFCodec ff_vp8_decoder; + extern const FFCodec ff_vp8_rkmpp_decoder; + extern const FFCodec ff_vp8_v4l2m2m_decoder; ++extern const FFCodec ff_vp9_nvv4l2_decoder; + extern const FFCodec ff_vp9_decoder; + extern const FFCodec ff_vp9_rkmpp_decoder; + extern const FFCodec ff_vp9_v4l2m2m_decoder; +diff --git a/libavcodec/nvv4l2.c b/libavcodec/nvv4l2.c +new file mode 100644 +index 0000000000..b3e4a27823 +--- /dev/null ++++ b/libavcodec/nvv4l2.c @@ -0,0 +1,820 @@ +/* + * Copyright (c) 2021-2022, CTCaer @@ -1034,9 +1111,341 @@ diff -Naur ffmpeg-6.0/libavcodec/nvv4l2.c ffmpeg-6.0-2/libavcodec/nvv4l2.c + fdesc.index++; + } +} -diff -Naur ffmpeg-6.0/libavcodec/nvv4l2_dec.c ffmpeg-6.0-2/libavcodec/nvv4l2_dec.c ---- ffmpeg-6.0/libavcodec/nvv4l2_dec.c 1970-01-01 01:00:00.000000000 +0100 -+++ ffmpeg-6.0-2/libavcodec/nvv4l2_dec.c 2023-06-04 19:38:13.741210367 +0200 +diff --git a/libavcodec/nvv4l2.h b/libavcodec/nvv4l2.h +new file mode 100644 +index 0000000000..5c65e2bec7 +--- /dev/null ++++ b/libavcodec/nvv4l2.h +@@ -0,0 +1,324 @@ ++/* ++ * Copyright (c) 2021-2022, CTCaer ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the "Software"), ++ * to deal in the Software without restriction, including without limitation ++ * the rights to use, copy, modify, merge, publish, distribute, sublicense, ++ * and/or sell copies of the Software, and to permit persons to whom the ++ * Software is furnished to do so, subject to the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be included in ++ * all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ++ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ++ * DEALINGS IN THE SOFTWARE. ++ */ ++ ++/** ++ * Specifies the decoder device node. ++ */ ++#ifndef __nvv4l2_H__ ++#define __nvv4l2_H__ ++ ++#include ++#include ++#include ++#include ++#include ++#include "avcodec.h" ++ ++#include "nvbuf_utils.h" ++#include "v4l2_nv_extensions.h" ++ ++#define NV_MAX_BUFFERS 32 ++ ++/** ++ * Specifies the maximum number of planes a buffer can contain. ++ */ ++#define NV_MAX_PLANES 3 ++#define NVMIN(a,b) (((a) < (b)) ? (a) : (b)) ++#define NVMAX(a, b) ((a) > (b) ? (a) : (b)) ++ ++/* Use app malloc/free implementation */ ++#define NVMALLOC(size) (av_malloc((size))) ++#define NVCALLOC(num, size) (av_mallocz((num) * (size))) ++#define NVFREE(ptr) (av_free((ptr))) ++ ++typedef struct _queue { ++ uint32_t capacity; ++ uint32_t front; ++ uint32_t back; ++} NvQueues; ++ ++typedef enum { ++ NV_PIX_NV12, ++ NV_PIX_YUV420 ++} NvPixFormat; ++ ++typedef struct _NVPACKET { ++ uint32_t flags; ++ uint32_t payload_size; ++ uint8_t *payload; ++ uint32_t width; ++ uint32_t height; ++ uint64_t pts; ++} NvPacket; ++ ++typedef struct _NVFRAME { ++ uint32_t flags; ++ uint32_t payload_size[3]; ++ uint8_t *payload[3]; ++ uint32_t width; ++ uint32_t height; ++ uint64_t pts; ++} NvFrame; ++ ++typedef enum { ++ NvVideoCodec_H264, /**< H.264 */ ++ NvVideoCodec_MPEG4, /**< MPEG-4 */ ++ NvVideoCodec_MPEG2, /**< MPEG-2 */ ++ NvVideoCodec_VP8, /**< VP8 */ ++ NvVideoCodec_VP9, /**< VP9 */ ++ NvVideoCodec_HEVC, /**< H.265/HEVC */ ++ NvVideoCodec_UNDEFINED, ++} NvCodingType; ++ ++typedef struct { ++ uint32_t width; /**< Holds the width of the plane in pixels. */ ++ uint32_t height; /**< Holds the height of the plane in pixels. */ ++ ++ uint32_t bytesperpixel; /**< Holds the bytes used to represent one ++ pixel in the plane. */ ++ uint32_t stride; /**< Holds the stride of the plane in bytes. */ ++ uint32_t sizeimage; /**< Holds the size of the plane in bytes. */ ++} NvBufferPlaneFormat; ++ ++ /** ++ * Holds the buffer plane parameters. ++ */ ++ ++typedef struct { ++ NvBufferPlaneFormat fmt; /**< Holds the format of the plane. */ ++ uint8_t *data; /**< Holds a pointer to the plane memory. */ ++ uint32_t bytesused; /**< Holds the number of valid bytes in the plane. */ ++ int fd; /**< Holds the file descriptor (FD) of the plane of the ++ exported buffer, in the case of V4L2 MMAP buffers. */ ++ uint32_t mem_offset; /**< Holds the offset of the first valid byte ++ from the data pointer. */ ++ uint32_t length; /**< Holds the size of the buffer in bytes. */ ++} NvBufferPlane; ++ ++typedef struct { ++ enum v4l2_buf_type buf_type; /**< Type of the buffer. */ ++ enum v4l2_memory memory_type; /**< Type of memory associated with the buffer. */ ++ uint32_t index; /**< Holds the buffer index. */ ++ uint32_t n_planes; /**< Holds the number of planes in the buffer. */ ++ NvBufferPlane planes[NV_MAX_PLANES]; ++ bool mapped; ++} NvBuffer; ++ ++typedef struct { ++ uint32_t width; ++ uint32_t height; ++ bool low_latency; ++ uint32_t profile; ++ uint32_t bitrate; ++ uint32_t level; ++ uint32_t tier; ++ uint32_t preset_type; ++ uint32_t lossless; ++ uint32_t iframe_interval; ++ uint32_t idr_interval; ++ uint32_t fps_n; ++ uint32_t fps_d; ++ int qmin; ++ int qmax; ++ int num_b_frames; ++ uint32_t num_ref; ++ bool sps_pps_at_idr; ++ uint32_t ratecontrol; ++} NvEncoder; ++ ++/** ++ * @brief Struct defining the decoder context. ++ * The video decoder device node is `/dev/nvhost-nvdec`. The category name ++ * for the decoder is \c "NVDEC". ++ * ++ * The context stores the information for decoding. ++ * Refer to [V4L2 Video Decoder](group__V4L2Dec.html) for more information on the decoder. ++ */ ++ ++typedef struct { ++ uint32_t codec_width; ++ uint32_t codec_height; ++ ++ uint32_t op_pixfmt; ++ uint32_t cp_pixfmt; ++ enum v4l2_memory op_mem_type; ++ enum v4l2_memory cp_mem_type; ++ enum v4l2_buf_type op_buf_type; ++ enum v4l2_buf_type cp_buf_type; ++ NvBufferPlaneFormat op_planefmts[NV_MAX_PLANES]; ++ NvBufferPlaneFormat cp_planefmts[NV_MAX_PLANES]; ++ uint32_t cp_num_planes; ++ uint32_t op_num_planes; ++ uint32_t cp_num_buffers; ++ uint32_t op_num_buffers; ++ NvQueues *export_pool; ++ NvBuffer **op_buffers; ++ NvBuffer **cp_buffers; ++ uint32_t num_active_op_buffers; ++ uint32_t num_queued_op_buffers; ++ uint32_t num_queued_cp_buffers; ++ ++ pthread_mutex_t queue_lock; ++ pthread_cond_t queue_cond; ++ pthread_mutex_t frame_lock; ++ pthread_cond_t frame_cond; ++ pthread_mutex_t pool_lock; ++ pthread_t capture_thread; ++ ++ bool in_error; ++ bool eos; ++ bool op_streamon; ++ bool cp_streamon; ++ bool draining_event; ++ bool low_latency; ++ ++ int fd; ++ int out_dma_fd; ++ int dmabuff_fd[NV_MAX_BUFFERS]; ++ ++ int plane_dma_fd[NV_MAX_BUFFERS]; ++ uint32_t plane_width[MAX_NUM_PLANES]; ++ uint32_t plane_height[MAX_NUM_PLANES]; ++ uint64_t frame_pts[NV_MAX_BUFFERS]; ++ ++ uint8_t *packet[NV_MAX_BUFFERS]; ++ uint32_t packet_buf_size[NV_MAX_BUFFERS]; ++ uint32_t packet_size[NV_MAX_BUFFERS]; ++ bool packet_keyflag[NV_MAX_BUFFERS]; ++ ++ NvEncoder *enc; ++ AVCodecContext *avctx; ++} nvv4l2_ctx_t; ++ ++/* NVV4L2 common functions */ ++uint32_t nvv4l2_map_nvcodec_type(NvCodingType nv_codec_type); ++int ++nvv4l2_pool_idx_next(nvv4l2_ctx_t *ctx, NvQueues *q); ++void ++nvv4l2_pool_push(nvv4l2_ctx_t *ctx, NvQueues *q); ++int ++nvv4l2_pool_pop(nvv4l2_ctx_t *ctx, NvQueues *q); ++int ++nvv4l2_create_bufferfmt(NvBuffer *buffer, enum v4l2_buf_type buf_type, ++ enum v4l2_memory memory_type, uint32_t n_planes, ++ NvBufferPlaneFormat *fmt, uint32_t index); ++int ++nvv4l2_map_out(nvv4l2_ctx_t *ctx, struct v4l2_buffer *v4l2_buf, ++ enum v4l2_buf_type buf_type, enum v4l2_memory mem_type, ++ int dma_fd); ++int ++nvv4l2_unmap_out(nvv4l2_ctx_t *ctx, int index, enum v4l2_buf_type buf_type, ++ enum v4l2_memory mem_type, int dma_fd); ++void ++nvv4l2_destroyBuffer(nvv4l2_ctx_t *ctx, NvBuffer *buffer); ++int ++nvv4l2_allocate_memory(nvv4l2_ctx_t *ctx, NvBuffer *buffer); ++int ++nvv4l2_map(nvv4l2_ctx_t *ctx, NvBuffer *buffer); ++void ++nvv4l2_unmap(nvv4l2_ctx_t *ctx, NvBuffer *buffer); ++int ++nvv4l2_query_buffer(nvv4l2_ctx_t *ctx, enum v4l2_buf_type buf_type, ++ enum v4l2_memory memory_type, uint32_t num_planes, ++ uint32_t index); ++int ++nvv4l2_export_buffer(nvv4l2_ctx_t *ctx, enum v4l2_buf_type buf_type, ++ uint32_t num_planes, uint32_t index); ++int ++nvv4l2_fill_buffer_plane_format(nvv4l2_ctx_t *ctx, ++ uint32_t *num_planes, ++ NvBufferPlaneFormat *planefmts, ++ uint32_t width, uint32_t height, ++ uint32_t pixfmt); ++int ++nvv4l2_dq_event(nvv4l2_ctx_t *ctx, struct v4l2_event *event, ++ uint32_t max_wait_ms); ++int ++nvv4l2_dq_buffer(nvv4l2_ctx_t *ctx, struct v4l2_buffer *v4l2_buf, ++ NvBuffer **buffer, enum v4l2_buf_type buf_type, ++ enum v4l2_memory memory_type, uint32_t num_retries); ++int ++nvv4l2_q_buffer(nvv4l2_ctx_t *ctx, struct v4l2_buffer *v4l2_buf, ++ NvBuffer *buffer, enum v4l2_buf_type buf_type, ++ enum v4l2_memory memory_type, int num_planes); ++int ++nvv4l2_req_buffers_on_capture_plane(nvv4l2_ctx_t *ctx, ++ enum v4l2_buf_type buf_type, ++ enum v4l2_memory mem_type, ++ int num_buffers); ++int ++nvv4l2_req_buffers_on_output_plane(nvv4l2_ctx_t *ctx, ++ enum v4l2_buf_type buf_type, ++ enum v4l2_memory mem_type, ++ int num_buffers); ++int ++nvv4l2_set_ext_controls(int fd, uint32_t id, ++ uint32_t class, uint32_t value); ++int ++nvv4l2_set_ext_control_qp_range(int fd, uint32_t qpmin, ++ uint32_t qpmax); ++int ++nvv4l2_set_ext_control_constant_qp(int fd, uint32_t qpval); ++int ++nvv4l2_get_ext_control_metadata(int fd, uint32_t buffer_index, ++ v4l2_ctrl_videoenc_outputbuf_metadata *enc_metadata); ++int ++nvv4l2_set_stream_control_framerate(int fd, uint32_t buf_type, ++ uint32_t framerate_num, ++ uint32_t framerate_den); ++int ++nvv4l2_subscribe_event(int fd, uint32_t type, uint32_t id, ++ uint32_t flags); ++ ++/* NVV4L2 debug functions */ ++void ++nvv4l2_dbg_plane_supported_formats(nvv4l2_ctx_t *ctx, ++ uint32_t buf_type); ++ ++/* NVV4L2 decoder functions */ ++nvv4l2_ctx_t *nvv4l2_create_decoder(AVCodecContext *avctx, ++ NvCodingType nv_codec_type, ++ int pix_fmt); ++int ++nvv4l2_decoder_put_packet(AVCodecContext *avctx, nvv4l2_ctx_t *ctx, ++ NvPacket *packet); ++int ++nvv4l2_decoder_get_frame(AVCodecContext *avctx, nvv4l2_ctx_t *ctx, ++ int *buf_index, NvFrame *frame); ++int nvv4l2_decoder_close(AVCodecContext *avctx, nvv4l2_ctx_t *ctx); ++ ++/* NVV4L2 encoder functions */ ++nvv4l2_ctx_t *nvv4l2_create_encoder(AVCodecContext *avctx, ++ NvEncoder *enc, ++ NvCodingType codingType, ++ int pix_fmt); ++int ++nvv4l2_encoder_put_frame(AVCodecContext *avctx, nvv4l2_ctx_t *ctx, ++ NvFrame *frame); ++int ++nvv4l2_encoder_get_packet(AVCodecContext *avctx, ++ nvv4l2_ctx_t *ctx, ++ NvPacket *packet); ++int ++nvv4l2_encoder_close(AVCodecContext *avctx, nvv4l2_ctx_t *ctx); ++ ++#endif +diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c +new file mode 100644 +index 0000000000..ab7f0ee45e +--- /dev/null ++++ b/libavcodec/nvv4l2_dec.c @@ -0,0 +1,1101 @@ +/* + * Copyright (c) 2021-2022, CTCaer @@ -2139,9 +2548,11 @@ diff -Naur ffmpeg-6.0/libavcodec/nvv4l2_dec.c ffmpeg-6.0-2/libavcodec/nvv4l2_dec +NVV4L2_DEC(mpeg4, AV_CODEC_ID_MPEG4, NULL); +NVV4L2_DEC(vp9, AV_CODEC_ID_VP9, NULL); +NVV4L2_DEC(vp8, AV_CODEC_ID_VP8, NULL); -diff -Naur ffmpeg-6.0/libavcodec/nvv4l2_enc.c ffmpeg-6.0-2/libavcodec/nvv4l2_enc.c ---- ffmpeg-6.0/libavcodec/nvv4l2_enc.c 1970-01-01 01:00:00.000000000 +0100 -+++ ffmpeg-6.0-2/libavcodec/nvv4l2_enc.c 2023-06-04 19:38:13.745210441 +0200 +diff --git a/libavcodec/nvv4l2_enc.c b/libavcodec/nvv4l2_enc.c +new file mode 100644 +index 0000000000..e85d20dfda +--- /dev/null ++++ b/libavcodec/nvv4l2_enc.c @@ -0,0 +1,1389 @@ +/* + * Copyright (c) 2021-2022, CTCaer @@ -3532,331 +3943,6 @@ diff -Naur ffmpeg-6.0/libavcodec/nvv4l2_enc.c ffmpeg-6.0-2/libavcodec/nvv4l2_enc + +NVV4L2_ENC(h264, AV_CODEC_ID_H264); +NVV4L2_ENC(hevc, AV_CODEC_ID_HEVC); -diff -Naur ffmpeg-6.0/libavcodec/nvv4l2.h ffmpeg-6.0-2/libavcodec/nvv4l2.h ---- ffmpeg-6.0/libavcodec/nvv4l2.h 1970-01-01 01:00:00.000000000 +0100 -+++ ffmpeg-6.0-2/libavcodec/nvv4l2.h 2023-06-04 19:38:13.741210367 +0200 -@@ -0,0 +1,324 @@ -+/* -+ * Copyright (c) 2021-2022, CTCaer -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a -+ * copy of this software and associated documentation files (the "Software"), -+ * to deal in the Software without restriction, including without limitation -+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, -+ * and/or sell copies of the Software, and to permit persons to whom the -+ * Software is furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice shall be included in -+ * all copies or substantial portions of the Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -+ * DEALINGS IN THE SOFTWARE. -+ */ -+ -+/** -+ * Specifies the decoder device node. -+ */ -+#ifndef __nvv4l2_H__ -+#define __nvv4l2_H__ -+ -+#include -+#include -+#include -+#include -+#include -+#include "avcodec.h" -+ -+#include "nvbuf_utils.h" -+#include "v4l2_nv_extensions.h" -+ -+#define NV_MAX_BUFFERS 32 -+ -+/** -+ * Specifies the maximum number of planes a buffer can contain. -+ */ -+#define NV_MAX_PLANES 3 -+#define NVMIN(a,b) (((a) < (b)) ? (a) : (b)) -+#define NVMAX(a, b) ((a) > (b) ? (a) : (b)) -+ -+/* Use app malloc/free implementation */ -+#define NVMALLOC(size) (av_malloc((size))) -+#define NVCALLOC(num, size) (av_mallocz((num) * (size))) -+#define NVFREE(ptr) (av_free((ptr))) -+ -+typedef struct _queue { -+ uint32_t capacity; -+ uint32_t front; -+ uint32_t back; -+} NvQueues; -+ -+typedef enum { -+ NV_PIX_NV12, -+ NV_PIX_YUV420 -+} NvPixFormat; -+ -+typedef struct _NVPACKET { -+ uint32_t flags; -+ uint32_t payload_size; -+ uint8_t *payload; -+ uint32_t width; -+ uint32_t height; -+ uint64_t pts; -+} NvPacket; -+ -+typedef struct _NVFRAME { -+ uint32_t flags; -+ uint32_t payload_size[3]; -+ uint8_t *payload[3]; -+ uint32_t width; -+ uint32_t height; -+ uint64_t pts; -+} NvFrame; -+ -+typedef enum { -+ NvVideoCodec_H264, /**< H.264 */ -+ NvVideoCodec_MPEG4, /**< MPEG-4 */ -+ NvVideoCodec_MPEG2, /**< MPEG-2 */ -+ NvVideoCodec_VP8, /**< VP8 */ -+ NvVideoCodec_VP9, /**< VP9 */ -+ NvVideoCodec_HEVC, /**< H.265/HEVC */ -+ NvVideoCodec_UNDEFINED, -+} NvCodingType; -+ -+typedef struct { -+ uint32_t width; /**< Holds the width of the plane in pixels. */ -+ uint32_t height; /**< Holds the height of the plane in pixels. */ -+ -+ uint32_t bytesperpixel; /**< Holds the bytes used to represent one -+ pixel in the plane. */ -+ uint32_t stride; /**< Holds the stride of the plane in bytes. */ -+ uint32_t sizeimage; /**< Holds the size of the plane in bytes. */ -+} NvBufferPlaneFormat; -+ -+ /** -+ * Holds the buffer plane parameters. -+ */ -+ -+typedef struct { -+ NvBufferPlaneFormat fmt; /**< Holds the format of the plane. */ -+ uint8_t *data; /**< Holds a pointer to the plane memory. */ -+ uint32_t bytesused; /**< Holds the number of valid bytes in the plane. */ -+ int fd; /**< Holds the file descriptor (FD) of the plane of the -+ exported buffer, in the case of V4L2 MMAP buffers. */ -+ uint32_t mem_offset; /**< Holds the offset of the first valid byte -+ from the data pointer. */ -+ uint32_t length; /**< Holds the size of the buffer in bytes. */ -+} NvBufferPlane; -+ -+typedef struct { -+ enum v4l2_buf_type buf_type; /**< Type of the buffer. */ -+ enum v4l2_memory memory_type; /**< Type of memory associated with the buffer. */ -+ uint32_t index; /**< Holds the buffer index. */ -+ uint32_t n_planes; /**< Holds the number of planes in the buffer. */ -+ NvBufferPlane planes[NV_MAX_PLANES]; -+ bool mapped; -+} NvBuffer; -+ -+typedef struct { -+ uint32_t width; -+ uint32_t height; -+ bool low_latency; -+ uint32_t profile; -+ uint32_t bitrate; -+ uint32_t level; -+ uint32_t tier; -+ uint32_t preset_type; -+ uint32_t lossless; -+ uint32_t iframe_interval; -+ uint32_t idr_interval; -+ uint32_t fps_n; -+ uint32_t fps_d; -+ int qmin; -+ int qmax; -+ int num_b_frames; -+ uint32_t num_ref; -+ bool sps_pps_at_idr; -+ uint32_t ratecontrol; -+} NvEncoder; -+ -+/** -+ * @brief Struct defining the decoder context. -+ * The video decoder device node is `/dev/nvhost-nvdec`. The category name -+ * for the decoder is \c "NVDEC". -+ * -+ * The context stores the information for decoding. -+ * Refer to [V4L2 Video Decoder](group__V4L2Dec.html) for more information on the decoder. -+ */ -+ -+typedef struct { -+ uint32_t codec_width; -+ uint32_t codec_height; -+ -+ uint32_t op_pixfmt; -+ uint32_t cp_pixfmt; -+ enum v4l2_memory op_mem_type; -+ enum v4l2_memory cp_mem_type; -+ enum v4l2_buf_type op_buf_type; -+ enum v4l2_buf_type cp_buf_type; -+ NvBufferPlaneFormat op_planefmts[NV_MAX_PLANES]; -+ NvBufferPlaneFormat cp_planefmts[NV_MAX_PLANES]; -+ uint32_t cp_num_planes; -+ uint32_t op_num_planes; -+ uint32_t cp_num_buffers; -+ uint32_t op_num_buffers; -+ NvQueues *export_pool; -+ NvBuffer **op_buffers; -+ NvBuffer **cp_buffers; -+ uint32_t num_active_op_buffers; -+ uint32_t num_queued_op_buffers; -+ uint32_t num_queued_cp_buffers; -+ -+ pthread_mutex_t queue_lock; -+ pthread_cond_t queue_cond; -+ pthread_mutex_t frame_lock; -+ pthread_cond_t frame_cond; -+ pthread_mutex_t pool_lock; -+ pthread_t capture_thread; -+ -+ bool in_error; -+ bool eos; -+ bool op_streamon; -+ bool cp_streamon; -+ bool draining_event; -+ bool low_latency; -+ -+ int fd; -+ int out_dma_fd; -+ int dmabuff_fd[NV_MAX_BUFFERS]; -+ -+ int plane_dma_fd[NV_MAX_BUFFERS]; -+ uint32_t plane_width[MAX_NUM_PLANES]; -+ uint32_t plane_height[MAX_NUM_PLANES]; -+ uint64_t frame_pts[NV_MAX_BUFFERS]; -+ -+ uint8_t *packet[NV_MAX_BUFFERS]; -+ uint32_t packet_buf_size[NV_MAX_BUFFERS]; -+ uint32_t packet_size[NV_MAX_BUFFERS]; -+ bool packet_keyflag[NV_MAX_BUFFERS]; -+ -+ NvEncoder *enc; -+ AVCodecContext *avctx; -+} nvv4l2_ctx_t; -+ -+/* NVV4L2 common functions */ -+uint32_t nvv4l2_map_nvcodec_type(NvCodingType nv_codec_type); -+int -+nvv4l2_pool_idx_next(nvv4l2_ctx_t *ctx, NvQueues *q); -+void -+nvv4l2_pool_push(nvv4l2_ctx_t *ctx, NvQueues *q); -+int -+nvv4l2_pool_pop(nvv4l2_ctx_t *ctx, NvQueues *q); -+int -+nvv4l2_create_bufferfmt(NvBuffer *buffer, enum v4l2_buf_type buf_type, -+ enum v4l2_memory memory_type, uint32_t n_planes, -+ NvBufferPlaneFormat *fmt, uint32_t index); -+int -+nvv4l2_map_out(nvv4l2_ctx_t *ctx, struct v4l2_buffer *v4l2_buf, -+ enum v4l2_buf_type buf_type, enum v4l2_memory mem_type, -+ int dma_fd); -+int -+nvv4l2_unmap_out(nvv4l2_ctx_t *ctx, int index, enum v4l2_buf_type buf_type, -+ enum v4l2_memory mem_type, int dma_fd); -+void -+nvv4l2_destroyBuffer(nvv4l2_ctx_t *ctx, NvBuffer *buffer); -+int -+nvv4l2_allocate_memory(nvv4l2_ctx_t *ctx, NvBuffer *buffer); -+int -+nvv4l2_map(nvv4l2_ctx_t *ctx, NvBuffer *buffer); -+void -+nvv4l2_unmap(nvv4l2_ctx_t *ctx, NvBuffer *buffer); -+int -+nvv4l2_query_buffer(nvv4l2_ctx_t *ctx, enum v4l2_buf_type buf_type, -+ enum v4l2_memory memory_type, uint32_t num_planes, -+ uint32_t index); -+int -+nvv4l2_export_buffer(nvv4l2_ctx_t *ctx, enum v4l2_buf_type buf_type, -+ uint32_t num_planes, uint32_t index); -+int -+nvv4l2_fill_buffer_plane_format(nvv4l2_ctx_t *ctx, -+ uint32_t *num_planes, -+ NvBufferPlaneFormat *planefmts, -+ uint32_t width, uint32_t height, -+ uint32_t pixfmt); -+int -+nvv4l2_dq_event(nvv4l2_ctx_t *ctx, struct v4l2_event *event, -+ uint32_t max_wait_ms); -+int -+nvv4l2_dq_buffer(nvv4l2_ctx_t *ctx, struct v4l2_buffer *v4l2_buf, -+ NvBuffer **buffer, enum v4l2_buf_type buf_type, -+ enum v4l2_memory memory_type, uint32_t num_retries); -+int -+nvv4l2_q_buffer(nvv4l2_ctx_t *ctx, struct v4l2_buffer *v4l2_buf, -+ NvBuffer *buffer, enum v4l2_buf_type buf_type, -+ enum v4l2_memory memory_type, int num_planes); -+int -+nvv4l2_req_buffers_on_capture_plane(nvv4l2_ctx_t *ctx, -+ enum v4l2_buf_type buf_type, -+ enum v4l2_memory mem_type, -+ int num_buffers); -+int -+nvv4l2_req_buffers_on_output_plane(nvv4l2_ctx_t *ctx, -+ enum v4l2_buf_type buf_type, -+ enum v4l2_memory mem_type, -+ int num_buffers); -+int -+nvv4l2_set_ext_controls(int fd, uint32_t id, -+ uint32_t class, uint32_t value); -+int -+nvv4l2_set_ext_control_qp_range(int fd, uint32_t qpmin, -+ uint32_t qpmax); -+int -+nvv4l2_set_ext_control_constant_qp(int fd, uint32_t qpval); -+int -+nvv4l2_get_ext_control_metadata(int fd, uint32_t buffer_index, -+ v4l2_ctrl_videoenc_outputbuf_metadata *enc_metadata); -+int -+nvv4l2_set_stream_control_framerate(int fd, uint32_t buf_type, -+ uint32_t framerate_num, -+ uint32_t framerate_den); -+int -+nvv4l2_subscribe_event(int fd, uint32_t type, uint32_t id, -+ uint32_t flags); -+ -+/* NVV4L2 debug functions */ -+void -+nvv4l2_dbg_plane_supported_formats(nvv4l2_ctx_t *ctx, -+ uint32_t buf_type); -+ -+/* NVV4L2 decoder functions */ -+nvv4l2_ctx_t *nvv4l2_create_decoder(AVCodecContext *avctx, -+ NvCodingType nv_codec_type, -+ int pix_fmt); -+int -+nvv4l2_decoder_put_packet(AVCodecContext *avctx, nvv4l2_ctx_t *ctx, -+ NvPacket *packet); -+int -+nvv4l2_decoder_get_frame(AVCodecContext *avctx, nvv4l2_ctx_t *ctx, -+ int *buf_index, NvFrame *frame); -+int nvv4l2_decoder_close(AVCodecContext *avctx, nvv4l2_ctx_t *ctx); -+ -+/* NVV4L2 encoder functions */ -+nvv4l2_ctx_t *nvv4l2_create_encoder(AVCodecContext *avctx, -+ NvEncoder *enc, -+ NvCodingType codingType, -+ int pix_fmt); -+int -+nvv4l2_encoder_put_frame(AVCodecContext *avctx, nvv4l2_ctx_t *ctx, -+ NvFrame *frame); -+int -+nvv4l2_encoder_get_packet(AVCodecContext *avctx, -+ nvv4l2_ctx_t *ctx, -+ NvPacket *packet); -+int -+nvv4l2_encoder_close(AVCodecContext *avctx, nvv4l2_ctx_t *ctx); -+ -+#endif +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0002-fftools-libavformat-Enforce-nvv4l2.patch b/packages/multimedia/ffmpeg/patches/L4T/0002-fftools-libavformat-Enforce-nvv4l2.patch new file mode 100644 index 0000000000..23f56db80f --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0002-fftools-libavformat-Enforce-nvv4l2.patch @@ -0,0 +1,75 @@ +From ffa9de21d7415d53f2f02b674438a41daaeee209 Mon Sep 17 00:00:00 2001 +From: CTCaer +Date: Sat, 5 Mar 2022 03:30:44 +0000 +Subject: [PATCH 02/39] fftools/libavformat: Enforce nvv4l2 + +This enforces NVV4L2 even if user requests another codec. +Additionally, it forces nvv4l2 to go through software codecs first to get context if needed. +--- + fftools/ffplay.c | 25 +++++++++++++++++++++++++ + libavformat/demux.c | 13 +++++++++++++ + 2 files changed, 38 insertions(+) + +diff --git a/fftools/ffplay.c b/fftools/ffplay.c +index d6479aef5f..86f8425a15 100644 +--- a/fftools/ffplay.c ++++ b/fftools/ffplay.c +@@ -2590,6 +2590,31 @@ static int stream_component_open(VideoState *is, int stream_index) + case AVMEDIA_TYPE_SUBTITLE: is->last_subtitle_stream = stream_index; forced_codec_name = subtitle_codec_name; break; + case AVMEDIA_TYPE_VIDEO : is->last_video_stream = stream_index; forced_codec_name = video_codec_name; break; + } ++ ++#if CONFIG_NVV4L2 ++ /* Reset requested decoder in order to enforce NVV4L2 if possible. */ ++ if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && forced_codec_name) { ++ if (strcmp(forced_codec_name, "h264") == 0) ++ forced_codec_name = NULL; ++ else if (strcmp(forced_codec_name, "hevc") == 0) ++ forced_codec_name = NULL; ++ else if (strcmp(forced_codec_name, "mpeg2video") == 0) ++ forced_codec_name = NULL; ++ else if (strcmp(forced_codec_name, "mpeg4") == 0) ++ forced_codec_name = NULL; ++ else if (strcmp(forced_codec_name, "vp8") == 0) ++ forced_codec_name = NULL; ++ else if (strcmp(forced_codec_name, "vp9") == 0 && ++ avctx->pix_fmt != AV_PIX_FMT_YUV420P10) { ++ forced_codec_name = NULL; ++ } ++ } ++ ++ /* NVV4L2 does not support VP9 with YUV420P10. */ ++ if (!forced_codec_name && avctx->pix_fmt == AV_PIX_FMT_YUV420P10) ++ forced_codec_name = "vp9"; ++#endif ++ + if (forced_codec_name) + codec = avcodec_find_decoder_by_name(forced_codec_name); + if (!codec) { +diff --git a/libavformat/demux.c b/libavformat/demux.c +index b19ab86d08..ae60a819d5 100644 +--- a/libavformat/demux.c ++++ b/libavformat/demux.c +@@ -77,6 +77,19 @@ static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st, + if (codec_id == AV_CODEC_ID_H264) + return avcodec_find_decoder_by_name("h264"); + #endif ++#if CONFIG_NVV4L2 ++ /* NVV4L2 decoders depend on context init from base decoders */ ++ if (codec_id == AV_CODEC_ID_HEVC) ++ return avcodec_find_decoder_by_name("hevc"); ++ else if (codec_id == AV_CODEC_ID_MPEG2VIDEO) ++ return avcodec_find_decoder_by_name("mpeg2video"); ++ else if (codec_id == AV_CODEC_ID_MPEG4) ++ return avcodec_find_decoder_by_name("mpeg4"); ++ else if (codec_id == AV_CODEC_ID_VP8) ++ return avcodec_find_decoder_by_name("vp8"); ++ else if (codec_id == AV_CODEC_ID_VP9) ++ return avcodec_find_decoder_by_name("vp9"); ++#endif + + codec = ff_find_decoder(s, st, codec_id); + if (!codec) +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0004-codecs-nvv4l2-avoid-probing.patch b/packages/multimedia/ffmpeg/patches/L4T/0003-codecs-nvv4l2-avoid-probing.patch similarity index 91% rename from packages/multimedia/ffmpeg/patches/L4T/0004-codecs-nvv4l2-avoid-probing.patch rename to packages/multimedia/ffmpeg/patches/L4T/0003-codecs-nvv4l2-avoid-probing.patch index 8295bc9383..259afcef23 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0004-codecs-nvv4l2-avoid-probing.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0003-codecs-nvv4l2-avoid-probing.patch @@ -1,7 +1,7 @@ -From 87622041abb1387bc8580721d23ec79a03e5249c Mon Sep 17 00:00:00 2001 +From c80256646ddae6d91a1ec9fe1a6cda53efaf923f Mon Sep 17 00:00:00 2001 From: CTCaer Date: Sun, 6 Mar 2022 04:26:06 +0000 -Subject: [PATCH 04/22] codecs: nvv4l2: avoid probing +Subject: [PATCH 03/39] codecs: nvv4l2: avoid probing NVV4L2 does not support probing for getting stream metadata. So disallow that. diff --git a/packages/multimedia/ffmpeg/patches/L4T/0003-fftools-libavformat-Enforce-nvv4l2.patch b/packages/multimedia/ffmpeg/patches/L4T/0003-fftools-libavformat-Enforce-nvv4l2.patch deleted file mode 100644 index a7e32e38d9..0000000000 --- a/packages/multimedia/ffmpeg/patches/L4T/0003-fftools-libavformat-Enforce-nvv4l2.patch +++ /dev/null @@ -1,87 +0,0 @@ -diff -Naur ffmpeg-6.0/fftools/ffmpeg_demux.c ffmpeg-6.0-2/fftools/ffmpeg_demux.c ---- ffmpeg-6.0/fftools/ffmpeg_demux.c 2023-06-04 21:39:14.447960833 +0200 -+++ ffmpeg-6.0-2/fftools/ffmpeg_demux.c 2023-06-04 21:43:39.492669262 +0200 -@@ -502,6 +502,25 @@ - char *codec_name = NULL; - - MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st); -+ -+#if CONFIG_NVV4L2 -+ /* Reset requested decoder in order to enforce NVV4L2 if possible. */ -+ if (codec_name) { -+ if (strcmp(codec_name, "h264") == 0) -+ return avcodec_find_decoder(st->codecpar->codec_id); -+ else if (strcmp(codec_name, "hevc") == 0) -+ return avcodec_find_decoder(st->codecpar->codec_id); -+ else if (strcmp(codec_name, "mpeg2video") == 0) -+ return avcodec_find_decoder(st->codecpar->codec_id); -+ else if (strcmp(codec_name, "mpeg4") == 0) -+ return avcodec_find_decoder(st->codecpar->codec_id); -+ else if (strcmp(codec_name, "vp8") == 0) -+ return avcodec_find_decoder(st->codecpar->codec_id); -+ else if (strcmp(codec_name, "vp9") == 0 && st->codecpar->format != AV_PIX_FMT_YUV420P10) -+ return avcodec_find_decoder(st->codecpar->codec_id); -+ } -+#endif -+ - if (codec_name) { - const AVCodec *codec = find_codec_or_die(NULL, codec_name, st->codecpar->codec_type, 0); - st->codecpar->codec_id = codec->id; -diff -Naur ffmpeg-6.0/fftools/ffplay.c ffmpeg-6.0-2/fftools/ffplay.c ---- ffmpeg-6.0/fftools/ffplay.c 2023-06-04 21:39:14.447960833 +0200 -+++ ffmpeg-6.0-2/fftools/ffplay.c 2023-06-04 21:41:40.550552101 +0200 -@@ -2590,6 +2590,31 @@ - case AVMEDIA_TYPE_SUBTITLE: is->last_subtitle_stream = stream_index; forced_codec_name = subtitle_codec_name; break; - case AVMEDIA_TYPE_VIDEO : is->last_video_stream = stream_index; forced_codec_name = video_codec_name; break; - } -+ -+#if CONFIG_NVV4L2 -+ /* Reset requested decoder in order to enforce NVV4L2 if possible. */ -+ if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && forced_codec_name) { -+ if (strcmp(forced_codec_name, "h264") == 0) -+ forced_codec_name = NULL; -+ else if (strcmp(forced_codec_name, "hevc") == 0) -+ forced_codec_name = NULL; -+ else if (strcmp(forced_codec_name, "mpeg2video") == 0) -+ forced_codec_name = NULL; -+ else if (strcmp(forced_codec_name, "mpeg4") == 0) -+ forced_codec_name = NULL; -+ else if (strcmp(forced_codec_name, "vp8") == 0) -+ forced_codec_name = NULL; -+ else if (strcmp(forced_codec_name, "vp9") == 0 && -+ avctx->pix_fmt != AV_PIX_FMT_YUV420P10) { -+ forced_codec_name = NULL; -+ } -+ } -+ -+ /* NVV4L2 does not support VP9 with YUV420P10. */ -+ if (!forced_codec_name && avctx->pix_fmt == AV_PIX_FMT_YUV420P10) -+ forced_codec_name = "vp9"; -+#endif -+ - if (forced_codec_name) - codec = avcodec_find_decoder_by_name(forced_codec_name); - if (!codec) { -diff -Naur ffmpeg-6.0/libavformat/utils.c ffmpeg-6.0-2/libavformat/utils.c ---- ffmpeg-6.0/libavformat/utils.c 2023-06-04 21:39:14.379959629 +0200 -+++ ffmpeg-6.0-2/libavformat/utils.c 2023-06-04 21:41:40.550552101 +0200 -@@ -37,6 +37,19 @@ - #if CONFIG_NETWORK - #include "network.h" - #endif -+#if CONFIG_NVV4L2 -+ /* NVV4L2 decoders depend on context init from base decoders */ -+ if (codec_id == AV_CODEC_ID_HEVC) -+ return avcodec_find_decoder_by_name("hevc"); -+ else if (codec_id == AV_CODEC_ID_MPEG2VIDEO) -+ return avcodec_find_decoder_by_name("mpeg2video"); -+ else if (codec_id == AV_CODEC_ID_MPEG4) -+ return avcodec_find_decoder_by_name("mpeg4"); -+ else if (codec_id == AV_CODEC_ID_VP8) -+ return avcodec_find_decoder_by_name("vp8"); -+ else if (codec_id == AV_CODEC_ID_VP9) -+ return avcodec_find_decoder_by_name("vp9"); -+#endif - - static AVMutex avformat_mutex = AV_MUTEX_INITIALIZER; - diff --git a/packages/multimedia/ffmpeg/patches/L4T/0005-libavformat-remove-nvv4l2-probing-mitigation.patch b/packages/multimedia/ffmpeg/patches/L4T/0004-libavformat-remove-nvv4l2-probing-mitigation.patch similarity index 62% rename from packages/multimedia/ffmpeg/patches/L4T/0005-libavformat-remove-nvv4l2-probing-mitigation.patch rename to packages/multimedia/ffmpeg/patches/L4T/0004-libavformat-remove-nvv4l2-probing-mitigation.patch index 47d850b4d1..ba3a252ad7 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0005-libavformat-remove-nvv4l2-probing-mitigation.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0004-libavformat-remove-nvv4l2-probing-mitigation.patch @@ -1,18 +1,18 @@ -From ecdbd9b4904b71bea7d3c373690d0e6283896730 Mon Sep 17 00:00:00 2001 +From 81aa7501ce56cf7df7ee7be3bf6e7e37d1952dc8 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Sun, 6 Mar 2022 04:27:54 +0000 -Subject: [PATCH 05/22] libavformat: remove nvv4l2 probing mitigation +Subject: [PATCH 04/39] libavformat: remove nvv4l2 probing mitigation It was fixed properly with AV_CODEC_CAP_AVOID_PROBING flag. --- - libavformat/utils.c | 13 ------------- + libavformat/demux.c | 13 ------------- 1 file changed, 13 deletions(-) -diff --git a/libavformat/utils.c b/libavformat/utils.c -index a960f8265d..1384b56771 100644 ---- a/libavformat/utils.c -+++ b/libavformat/utils.c -@@ -211,19 +211,6 @@ static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st, +diff --git a/libavformat/demux.c b/libavformat/demux.c +index ae60a819d5..b19ab86d08 100644 +--- a/libavformat/demux.c ++++ b/libavformat/demux.c +@@ -77,19 +77,6 @@ static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st, if (codec_id == AV_CODEC_ID_H264) return avcodec_find_decoder_by_name("h264"); #endif @@ -25,12 +25,12 @@ index a960f8265d..1384b56771 100644 - else if (codec_id == AV_CODEC_ID_MPEG4) - return avcodec_find_decoder_by_name("mpeg4"); - else if (codec_id == AV_CODEC_ID_VP8) -- return avcodec_find_decoder_by_name("vp8"); +- return avcodec_find_decoder_by_name("vp8"); - else if (codec_id == AV_CODEC_ID_VP9) - return avcodec_find_decoder_by_name("vp9"); -#endif - codec = find_decoder(s, st, codec_id); + codec = ff_find_decoder(s, st, codec_id); if (!codec) -- 2.25.1 diff --git a/packages/multimedia/ffmpeg/patches/L4T/0006-codecs-nvv4l2-do-not-use-external-headers.patch b/packages/multimedia/ffmpeg/patches/L4T/0005-codecs-nvv4l2-do-not-use-external-headers.patch similarity index 99% rename from packages/multimedia/ffmpeg/patches/L4T/0006-codecs-nvv4l2-do-not-use-external-headers.patch rename to packages/multimedia/ffmpeg/patches/L4T/0005-codecs-nvv4l2-do-not-use-external-headers.patch index 70ab712349..4dd4c0daba 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0006-codecs-nvv4l2-do-not-use-external-headers.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0005-codecs-nvv4l2-do-not-use-external-headers.patch @@ -1,7 +1,7 @@ -From 8e286f3ffc845709f6747d77982c60ad0ed0b37f Mon Sep 17 00:00:00 2001 +From 135ad87310784e7dfd49c95ba6f7ed45e9444cd8 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Fri, 18 Mar 2022 21:16:35 +0000 -Subject: [PATCH 06/22] codecs: nvv4l2: do not use external headers +Subject: [PATCH 05/39] codecs: nvv4l2: do not use external headers Make needed headers builtin as this will help to bring compatibility from r32.3.1 till r32.7.1 and newer with a single build. --- @@ -11,10 +11,10 @@ Make needed headers builtin as this will help to bring compatibility from r32.3. create mode 100644 libavcodec/nvv4l2_ext_utils.h diff --git a/configure b/configure -index 29a6d96575..ea84db929c 100755 +index 889b547071..ba28526b44 100755 --- a/configure +++ b/configure -@@ -3053,7 +3053,7 @@ qsvenc_select="qsv" +@@ -3131,7 +3131,7 @@ qsvenc_select="qsv" qsvvpp_select="qsv" vaapi_encode_deps="vaapi" v4l2_m2m_deps="linux_videodev2_h sem_timedwait" @@ -22,8 +22,8 @@ index 29a6d96575..ea84db929c 100755 +nvv4l2_deps="libv4l2 pthreads linux_videodev2_h" nvv4l2_extralibs="-lnvbuf_utils" - hwupload_cuda_filter_deps="ffnvcodec" -@@ -6798,11 +6798,8 @@ if enabled_any nvdec cuvid; then + bilateral_cuda_filter_deps="ffnvcodec" +@@ -7070,11 +7070,8 @@ if enabled_any nvdec cuvid; then check_type "ffnvcodec/dynlink_cuda.h ffnvcodec/dynlink_cuviddec.h" "CUVIDAV1PICPARAMS" fi diff --git a/packages/multimedia/ffmpeg/patches/L4T/0007-codecs-nvv4l2-use-atomics-for-pool.patch b/packages/multimedia/ffmpeg/patches/L4T/0006-codecs-nvv4l2-use-atomics-for-pool.patch similarity index 96% rename from packages/multimedia/ffmpeg/patches/L4T/0007-codecs-nvv4l2-use-atomics-for-pool.patch rename to packages/multimedia/ffmpeg/patches/L4T/0006-codecs-nvv4l2-use-atomics-for-pool.patch index 9ba78872df..99c1aade4a 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0007-codecs-nvv4l2-use-atomics-for-pool.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0006-codecs-nvv4l2-use-atomics-for-pool.patch @@ -1,7 +1,7 @@ -From fd622ef8d15cf208810f82a6a843b4db94fb28be Mon Sep 17 00:00:00 2001 +From 4896ff0afcdccbb5521dee948c233dccb6616d7a Mon Sep 17 00:00:00 2001 From: CTCaer Date: Fri, 18 Mar 2022 21:20:48 +0000 -Subject: [PATCH 07/22] codecs: nvv4l2: use atomics for pool +Subject: [PATCH 06/39] codecs: nvv4l2: use atomics for pool Do not lock with mutexes until we need to do more in pools. Use atomics for now to lower latency. --- diff --git a/packages/multimedia/ffmpeg/patches/L4T/0008-codecs-nvv4l2-add-new-functions-and-update-context-a.patch b/packages/multimedia/ffmpeg/patches/L4T/0007-codecs-nvv4l2-add-new-functions-and-update-context-a.patch similarity index 97% rename from packages/multimedia/ffmpeg/patches/L4T/0008-codecs-nvv4l2-add-new-functions-and-update-context-a.patch rename to packages/multimedia/ffmpeg/patches/L4T/0007-codecs-nvv4l2-add-new-functions-and-update-context-a.patch index 2b7eec4ba7..fd5e059ba6 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0008-codecs-nvv4l2-add-new-functions-and-update-context-a.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0007-codecs-nvv4l2-add-new-functions-and-update-context-a.patch @@ -1,7 +1,7 @@ -From 0fd5fb903861c42d40f84b0468496006966e1c5d Mon Sep 17 00:00:00 2001 +From 607f6a8e40b495ecb887fc046bf8cf6030036c3a Mon Sep 17 00:00:00 2001 From: CTCaer Date: Fri, 18 Mar 2022 21:23:33 +0000 -Subject: [PATCH 08/22] codecs: nvv4l2: add new functions and update context as +Subject: [PATCH 07/39] codecs: nvv4l2: add new functions and update context as prep --- diff --git a/packages/multimedia/ffmpeg/patches/L4T/0009-codecs-nvv4l2-support-multiple-L4T-versions-with-sin.patch b/packages/multimedia/ffmpeg/patches/L4T/0008-codecs-nvv4l2-support-multiple-L4T-versions-with-sin.patch similarity index 96% rename from packages/multimedia/ffmpeg/patches/L4T/0009-codecs-nvv4l2-support-multiple-L4T-versions-with-sin.patch rename to packages/multimedia/ffmpeg/patches/L4T/0008-codecs-nvv4l2-support-multiple-L4T-versions-with-sin.patch index 532bd73e03..ef3d118c33 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0009-codecs-nvv4l2-support-multiple-L4T-versions-with-sin.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0008-codecs-nvv4l2-support-multiple-L4T-versions-with-sin.patch @@ -1,7 +1,7 @@ -From 02d9583d32a9a8bd02dda9dd510519c04691d8d2 Mon Sep 17 00:00:00 2001 +From 72f992d69e5462c2da170f4259032b5f9ff6b250 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Fri, 18 Mar 2022 21:31:31 +0000 -Subject: [PATCH 09/22] codecs: nvv4l2: support multiple L4T versions with +Subject: [PATCH 08/39] codecs: nvv4l2: support multiple L4T versions with single build Nvidia has the tendency to break compatibility on documented apis for no reason. diff --git a/packages/multimedia/ffmpeg/patches/L4T/0010-codecs-nvv4l2-align-line-width-to-64B.patch b/packages/multimedia/ffmpeg/patches/L4T/0009-codecs-nvv4l2-align-line-width-to-64B.patch similarity index 95% rename from packages/multimedia/ffmpeg/patches/L4T/0010-codecs-nvv4l2-align-line-width-to-64B.patch rename to packages/multimedia/ffmpeg/patches/L4T/0009-codecs-nvv4l2-align-line-width-to-64B.patch index 86eb5099e2..ac49107773 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0010-codecs-nvv4l2-align-line-width-to-64B.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0009-codecs-nvv4l2-align-line-width-to-64B.patch @@ -1,7 +1,7 @@ -From 280522f4f351a045ae7288ce7f5110ae099ea8b7 Mon Sep 17 00:00:00 2001 +From ade9d9b54d172437be84797300b25a85c4164cd4 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Fri, 18 Mar 2022 21:39:48 +0000 -Subject: [PATCH 10/22] codecs: nvv4l2: align line width to 64B +Subject: [PATCH 09/39] codecs: nvv4l2: align line width to 64B Transformations of formats to formats of simply Block linear to Pitch are done in HW. diff --git a/packages/multimedia/ffmpeg/patches/L4T/0011-codecs-nvv4l2-add-two-pass-cbr-mode-support.patch b/packages/multimedia/ffmpeg/patches/L4T/0010-codecs-nvv4l2-add-two-pass-cbr-mode-support.patch similarity index 97% rename from packages/multimedia/ffmpeg/patches/L4T/0011-codecs-nvv4l2-add-two-pass-cbr-mode-support.patch rename to packages/multimedia/ffmpeg/patches/L4T/0010-codecs-nvv4l2-add-two-pass-cbr-mode-support.patch index e4d9bc485e..e3b9fb3063 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0011-codecs-nvv4l2-add-two-pass-cbr-mode-support.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0010-codecs-nvv4l2-add-two-pass-cbr-mode-support.patch @@ -1,7 +1,7 @@ -From 9d3282af10055fbbb81bd53654dd342682e2d09d Mon Sep 17 00:00:00 2001 +From b7a72216ca1ed53f6428a3fca5949618d2059538 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Fri, 18 Mar 2022 21:42:29 +0000 -Subject: [PATCH 11/22] codecs: nvv4l2: add two-pass cbr mode support +Subject: [PATCH 10/39] codecs: nvv4l2: add two-pass cbr mode support To enable, use `twopass=on` as encoder option. diff --git a/packages/multimedia/ffmpeg/patches/L4T/0012-codecs-nvv4l2-various-bugfixes.patch b/packages/multimedia/ffmpeg/patches/L4T/0011-codecs-nvv4l2-various-bugfixes.patch similarity index 98% rename from packages/multimedia/ffmpeg/patches/L4T/0012-codecs-nvv4l2-various-bugfixes.patch rename to packages/multimedia/ffmpeg/patches/L4T/0011-codecs-nvv4l2-various-bugfixes.patch index 2a6492bd99..0ff8f02783 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0012-codecs-nvv4l2-various-bugfixes.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0011-codecs-nvv4l2-various-bugfixes.patch @@ -1,7 +1,7 @@ -From 73aba81a154a3f25efb2326a6e59949660d6a5f5 Mon Sep 17 00:00:00 2001 +From 124b4a1c85f24a11de5710b8515648dae91000cf Mon Sep 17 00:00:00 2001 From: CTCaer Date: Fri, 18 Mar 2022 21:46:36 +0000 -Subject: [PATCH 12/22] codecs: nvv4l2: various bugfixes +Subject: [PATCH 11/39] codecs: nvv4l2: various bugfixes --- libavcodec/nvv4l2_dec.c | 105 ++++++++++++++++++++++------------------ diff --git a/packages/multimedia/ffmpeg/patches/L4T/0013-codecs-nvv4l2-fix-hanging-on-event-wait-if-no-full-f.patch b/packages/multimedia/ffmpeg/patches/L4T/0012-codecs-nvv4l2-fix-hanging-on-event-wait-if-no-full-f.patch similarity index 91% rename from packages/multimedia/ffmpeg/patches/L4T/0013-codecs-nvv4l2-fix-hanging-on-event-wait-if-no-full-f.patch rename to packages/multimedia/ffmpeg/patches/L4T/0012-codecs-nvv4l2-fix-hanging-on-event-wait-if-no-full-f.patch index 9de3ec3f96..2564838464 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0013-codecs-nvv4l2-fix-hanging-on-event-wait-if-no-full-f.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0012-codecs-nvv4l2-fix-hanging-on-event-wait-if-no-full-f.patch @@ -1,7 +1,7 @@ -From c0832ff40e14ff28c926e500525cdf839d58ff98 Mon Sep 17 00:00:00 2001 +From d78e4bc70ec1d97e22c5f0365c027574e740923f Mon Sep 17 00:00:00 2001 From: CTCaer Date: Fri, 18 Mar 2022 21:50:20 +0000 -Subject: [PATCH 13/22] codecs: nvv4l2: fix hanging on event wait if no full +Subject: [PATCH 12/39] codecs: nvv4l2: fix hanging on event wait if no full frame info Sometimes the decoder can be opened with no packet sent or not many for a frame to be decoded. diff --git a/packages/multimedia/ffmpeg/patches/L4T/0014-codecs-nvv4l2-use-sessions-for-transformations.patch b/packages/multimedia/ffmpeg/patches/L4T/0013-codecs-nvv4l2-use-sessions-for-transformations.patch similarity index 94% rename from packages/multimedia/ffmpeg/patches/L4T/0014-codecs-nvv4l2-use-sessions-for-transformations.patch rename to packages/multimedia/ffmpeg/patches/L4T/0013-codecs-nvv4l2-use-sessions-for-transformations.patch index ab9dd3b355..3f7e4e78df 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0014-codecs-nvv4l2-use-sessions-for-transformations.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0013-codecs-nvv4l2-use-sessions-for-transformations.patch @@ -1,7 +1,7 @@ -From eceaecff30fc8a1ca622de7506470d486e34695a Mon Sep 17 00:00:00 2001 +From ac123e70b68b22a99b483ba5b9406e60b35f1519 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Fri, 18 Mar 2022 21:53:34 +0000 -Subject: [PATCH 14/22] codecs: nvv4l2: use sessions for transformations +Subject: [PATCH 13/39] codecs: nvv4l2: use sessions for transformations Some apps use different processes for init and decoding. diff --git a/packages/multimedia/ffmpeg/patches/L4T/0015-codecs-nvv4l2-support-all-different-timestamps.patch b/packages/multimedia/ffmpeg/patches/L4T/0014-codecs-nvv4l2-support-all-different-timestamps.patch similarity index 97% rename from packages/multimedia/ffmpeg/patches/L4T/0015-codecs-nvv4l2-support-all-different-timestamps.patch rename to packages/multimedia/ffmpeg/patches/L4T/0014-codecs-nvv4l2-support-all-different-timestamps.patch index 49f6ede404..079a253c32 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0015-codecs-nvv4l2-support-all-different-timestamps.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0014-codecs-nvv4l2-support-all-different-timestamps.patch @@ -1,7 +1,7 @@ -From 1d0dbfb7243a12b2941a23584a2dbed7cfb7077f Mon Sep 17 00:00:00 2001 +From 95ed6f305a76c588f8264406e69123e3775e6c36 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Fri, 18 Mar 2022 21:57:58 +0000 -Subject: [PATCH 15/22] codecs: nvv4l2: support all different timestamps +Subject: [PATCH 14/39] codecs: nvv4l2: support all different timestamps Various packets and players have different timestamps defined. diff --git a/packages/multimedia/ffmpeg/patches/L4T/0016-codecs-nvv4l2-BSP-34.1.x-remarks.patch b/packages/multimedia/ffmpeg/patches/L4T/0015-codecs-nvv4l2-BSP-34.1.x-remarks.patch similarity index 91% rename from packages/multimedia/ffmpeg/patches/L4T/0016-codecs-nvv4l2-BSP-34.1.x-remarks.patch rename to packages/multimedia/ffmpeg/patches/L4T/0015-codecs-nvv4l2-BSP-34.1.x-remarks.patch index b6d1f3015e..0a1419b0a4 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0016-codecs-nvv4l2-BSP-34.1.x-remarks.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0015-codecs-nvv4l2-BSP-34.1.x-remarks.patch @@ -1,7 +1,7 @@ -From 04008befad133d97b7f956a21632592aaaede7ca Mon Sep 17 00:00:00 2001 +From 0cd74d94cdac5e3cd7ce3e014b3af2b276389074 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Sat, 11 Jun 2022 17:14:49 +0000 -Subject: [PATCH 16/22] codecs: nvv4l2: BSP 34.1.x remarks +Subject: [PATCH 15/39] codecs: nvv4l2: BSP 34.1.x remarks NVIDIA changed the enum again in r34 and broke compatibility for no reason. diff --git a/packages/multimedia/ffmpeg/patches/L4T/0017-codecs-nvv4l2-support-BT709-BT2020-colorspaces.patch b/packages/multimedia/ffmpeg/patches/L4T/0016-codecs-nvv4l2-support-BT709-BT2020-colorspaces.patch similarity index 98% rename from packages/multimedia/ffmpeg/patches/L4T/0017-codecs-nvv4l2-support-BT709-BT2020-colorspaces.patch rename to packages/multimedia/ffmpeg/patches/L4T/0016-codecs-nvv4l2-support-BT709-BT2020-colorspaces.patch index ce384fca14..c8ec383d6a 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0017-codecs-nvv4l2-support-BT709-BT2020-colorspaces.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0016-codecs-nvv4l2-support-BT709-BT2020-colorspaces.patch @@ -1,7 +1,7 @@ -From 3674076e6287c62dd39c73585521504908f25fb9 Mon Sep 17 00:00:00 2001 +From 628d01310250a97fc874f3acb9405460b57e679d Mon Sep 17 00:00:00 2001 From: CTCaer Date: Tue, 14 Jun 2022 19:21:20 +0000 -Subject: [PATCH 17/22] codecs: nvv4l2: support BT709/BT2020 colorspaces +Subject: [PATCH 16/39] codecs: nvv4l2: support BT709/BT2020 colorspaces --- libavcodec/nvv4l2_dec.c | 62 ++++++++++++++++++++++++----------- diff --git a/packages/multimedia/ffmpeg/patches/L4T/0018-codecs-nvv4l2-reorder-capture-buffer-queueing.patch b/packages/multimedia/ffmpeg/patches/L4T/0017-codecs-nvv4l2-reorder-capture-buffer-queueing.patch similarity index 98% rename from packages/multimedia/ffmpeg/patches/L4T/0018-codecs-nvv4l2-reorder-capture-buffer-queueing.patch rename to packages/multimedia/ffmpeg/patches/L4T/0017-codecs-nvv4l2-reorder-capture-buffer-queueing.patch index 3f3d1fce06..0917b8756d 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0018-codecs-nvv4l2-reorder-capture-buffer-queueing.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0017-codecs-nvv4l2-reorder-capture-buffer-queueing.patch @@ -1,7 +1,7 @@ -From 636c040931dff3d5febae00697a8502af396e01f Mon Sep 17 00:00:00 2001 +From 9ad8d41a2aa4dcb6b552d77e04f9ce4dc26e999a Mon Sep 17 00:00:00 2001 From: CTCaer Date: Wed, 15 Jun 2022 13:33:10 +0000 -Subject: [PATCH 18/22] codecs: nvv4l2: reorder capture buffer queueing +Subject: [PATCH 17/39] codecs: nvv4l2: reorder capture buffer queueing Move capture buffer queueing after capture plane stream on. diff --git a/packages/multimedia/ffmpeg/patches/L4T/0019-codecs-nvv4l2-align-encoder-plane-width-to-64B.patch b/packages/multimedia/ffmpeg/patches/L4T/0018-codecs-nvv4l2-align-encoder-plane-width-to-64B.patch similarity index 92% rename from packages/multimedia/ffmpeg/patches/L4T/0019-codecs-nvv4l2-align-encoder-plane-width-to-64B.patch rename to packages/multimedia/ffmpeg/patches/L4T/0018-codecs-nvv4l2-align-encoder-plane-width-to-64B.patch index 1b903f8e9e..cd1074dbbe 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0019-codecs-nvv4l2-align-encoder-plane-width-to-64B.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0018-codecs-nvv4l2-align-encoder-plane-width-to-64B.patch @@ -1,7 +1,7 @@ -From 7b67a0996bb80c38a923b215566c67ffc130d161 Mon Sep 17 00:00:00 2001 +From ef1bcd73fa1e37982dfc24f2319e83d5932848a8 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Tue, 28 Jun 2022 01:37:59 +0000 -Subject: [PATCH 19/22] codecs: nvv4l2: align encoder plane width to 64B +Subject: [PATCH 18/39] codecs: nvv4l2: align encoder plane width to 64B Transformations of Block linear formats to linear Pitch formats are done in HW. diff --git a/packages/multimedia/ffmpeg/patches/L4T/0020-codecs-nvv4l2-align-enc-plane-width-per-format-plane.patch b/packages/multimedia/ffmpeg/patches/L4T/0019-codecs-nvv4l2-align-enc-plane-width-per-format-plane.patch similarity index 95% rename from packages/multimedia/ffmpeg/patches/L4T/0020-codecs-nvv4l2-align-enc-plane-width-per-format-plane.patch rename to packages/multimedia/ffmpeg/patches/L4T/0019-codecs-nvv4l2-align-enc-plane-width-per-format-plane.patch index 910c406db3..46138b630a 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0020-codecs-nvv4l2-align-enc-plane-width-per-format-plane.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0019-codecs-nvv4l2-align-enc-plane-width-per-format-plane.patch @@ -1,7 +1,7 @@ -From b0aabaeebd73e4968654f384f44ce8a4d608ae8d Mon Sep 17 00:00:00 2001 +From c5751e2bb1faeb0fd8e4442461bbbcd9448c3960 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Wed, 29 Jun 2022 06:38:26 +0000 -Subject: [PATCH 20/22] codecs: nvv4l2: align enc plane width per format/plane +Subject: [PATCH 19/39] codecs: nvv4l2: align enc plane width per format/plane Take two on creating a heuristic of the needed alignment. diff --git a/packages/multimedia/ffmpeg/patches/L4T/0021-codecs-nvv4l2-fix-memleak.patch b/packages/multimedia/ffmpeg/patches/L4T/0020-codecs-nvv4l2-fix-memleak.patch similarity index 97% rename from packages/multimedia/ffmpeg/patches/L4T/0021-codecs-nvv4l2-fix-memleak.patch rename to packages/multimedia/ffmpeg/patches/L4T/0020-codecs-nvv4l2-fix-memleak.patch index 0d676f53cb..3d1bc7b56b 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0021-codecs-nvv4l2-fix-memleak.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0020-codecs-nvv4l2-fix-memleak.patch @@ -1,7 +1,7 @@ -From deac819ac20d2ccd1664c95e4d91c20a35d67cc5 Mon Sep 17 00:00:00 2001 +From 1fe17b61d4221fed766069a7742a7d09eaabedbf Mon Sep 17 00:00:00 2001 From: CTCaer Date: Wed, 3 Aug 2022 22:04:22 +0000 -Subject: [PATCH 21/22] codecs: nvv4l2: fix memleak +Subject: [PATCH 20/39] codecs: nvv4l2: fix memleak Fixes #2 diff --git a/packages/multimedia/ffmpeg/patches/L4T/0022-codecs-nvv4l2-fix-use-after-free.patch b/packages/multimedia/ffmpeg/patches/L4T/0021-codecs-nvv4l2-fix-use-after-free.patch similarity index 92% rename from packages/multimedia/ffmpeg/patches/L4T/0022-codecs-nvv4l2-fix-use-after-free.patch rename to packages/multimedia/ffmpeg/patches/L4T/0021-codecs-nvv4l2-fix-use-after-free.patch index fa454c9fd3..9473de1741 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0022-codecs-nvv4l2-fix-use-after-free.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0021-codecs-nvv4l2-fix-use-after-free.patch @@ -1,7 +1,7 @@ -From 95d5bcfdc444e7d19299be64311119582c0fbab9 Mon Sep 17 00:00:00 2001 +From 24b397a75e4a737c845b91771274ad1104edd54f Mon Sep 17 00:00:00 2001 From: CTCaer Date: Wed, 28 Dec 2022 14:22:13 +0000 -Subject: [PATCH 22/22] codecs: nvv4l2: fix use after free +Subject: [PATCH 21/39] codecs: nvv4l2: fix use after free --- libavcodec/nvv4l2_enc.c | 9 +++++++-- diff --git a/packages/multimedia/ffmpeg/patches/L4T/0024-nvv4l2_decode-fix-header.patch b/packages/multimedia/ffmpeg/patches/L4T/0022-codecs-nvv4l2-rename-AVCodec-to-fit-API-renames.patch similarity index 72% rename from packages/multimedia/ffmpeg/patches/L4T/0024-nvv4l2_decode-fix-header.patch rename to packages/multimedia/ffmpeg/patches/L4T/0022-codecs-nvv4l2-rename-AVCodec-to-fit-API-renames.patch index 3323c6baaa..9b25a1ce79 100644 --- a/packages/multimedia/ffmpeg/patches/L4T/0024-nvv4l2_decode-fix-header.patch +++ b/packages/multimedia/ffmpeg/patches/L4T/0022-codecs-nvv4l2-rename-AVCodec-to-fit-API-renames.patch @@ -1,16 +1,27 @@ -diff -Naur ffmpeg-6.0/libavcodec/nvv4l2_dec.c ffmpeg-6.0-2/libavcodec/nvv4l2_dec.c ---- ffmpeg-6.0/libavcodec/nvv4l2_dec.c 2023-06-04 21:56:37.526608261 +0200 -+++ ffmpeg-6.0-2/libavcodec/nvv4l2_dec.c 2023-06-04 23:04:03.479000528 +0200 -@@ -29,6 +29,8 @@ +From b2a7cfdcf77cfd5c3ca864670aa949ddef17cd9a Mon Sep 17 00:00:00 2001 +From: Azkali Manad +Date: Wed, 25 Jan 2023 02:02:57 +0100 +Subject: [PATCH 22/39] codecs: nvv4l2: rename AVCodec to fit API renames + +--- + libavcodec/nvv4l2_dec.c | 20 ++++++++++---------- + libavcodec/nvv4l2_enc.c | 20 ++++++++++---------- + 2 files changed, 20 insertions(+), 20 deletions(-) + +diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c +index 35784e0704..b56d35cf82 100644 +--- a/libavcodec/nvv4l2_dec.c ++++ b/libavcodec/nvv4l2_dec.c +@@ -29,7 +29,7 @@ #include #include #include -+#include "decode.h" +-#include "internal.h" +#include "codec_internal.h" - #include "internal.h" #include "libavutil/log.h" -@@ -1203,22 +1205,22 @@ + #include "nvv4l2.h" +@@ -1203,22 +1203,22 @@ nvv4l2dec_decode(AVCodecContext *avctx, void *data, int *got_frame, #define NVV4L2_DEC(NAME, ID, BSFS) \ NVV4L2_DEC_CLASS(NAME) \ @@ -19,16 +30,15 @@ diff -Naur ffmpeg-6.0/libavcodec/nvv4l2_dec.c ffmpeg-6.0-2/libavcodec/nvv4l2_dec - .long_name = NULL_IF_CONFIG_SMALL(#NAME " NVV4L2 HW decoder for Tegra"), \ - .type = AVMEDIA_TYPE_VIDEO, \ - .id = ID, \ -+ FFCodec ff_##NAME##_nvv4l2_decoder = { \ ++ const FFCodec ff_##NAME##_nvv4l2_decoder = { \ + .p.name = #NAME "_nvv4l2", \ -+ CODEC_LONG_NAME(NULL_IF_CONFIG_SMALL(#NAME " NVV4L2 HW decoder for Tegra")), \ ++ .p.long_name = NULL_IF_CONFIG_SMALL(#NAME " NVV4L2 HW decoder for Tegra"), \ + .p.type = AVMEDIA_TYPE_VIDEO, \ + .p.id = ID, \ .priv_data_size = sizeof(nvv4l2DecodeContext), \ .init = nvv4l2dec_init, \ .close = nvv4l2dec_close, \ -- .decode = nvv4l2dec_decode, \ -+ FF_CODEC_DECODE_CB(nvv4l2dec_decode), \ + .decode = nvv4l2dec_decode, \ .flush = nvv4l2dec_flush, \ - .priv_class = &nvv4l2_##NAME##_dec_class, \ - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE | \ @@ -43,37 +53,20 @@ diff -Naur ffmpeg-6.0/libavcodec/nvv4l2_dec.c ffmpeg-6.0-2/libavcodec/nvv4l2_dec AV_PIX_FMT_NV12, \ AV_PIX_FMT_NONE }, \ }; -diff -Naur ffmpeg-6.0/libavcodec/nvv4l2_enc.c ffmpeg-6.0-2/libavcodec/nvv4l2_enc.c ---- ffmpeg-6.0/libavcodec/nvv4l2_enc.c 2023-06-04 21:56:41.758684320 +0200 -+++ ffmpeg-6.0-2/libavcodec/nvv4l2_enc.c 2023-06-04 23:48:47.734896973 +0200 -@@ -28,6 +28,8 @@ +diff --git a/libavcodec/nvv4l2_enc.c b/libavcodec/nvv4l2_enc.c +index dc09236e0a..fad54868e3 100644 +--- a/libavcodec/nvv4l2_enc.c ++++ b/libavcodec/nvv4l2_enc.c +@@ -28,7 +28,7 @@ #include #include #include -+#include "encode.h" +-#include "internal.h" +#include "codec_internal.h" - #include "internal.h" #include "libavutil/imgutils.h" #include "libavutil/log.h" -@@ -1265,7 +1267,7 @@ - if (nvv4l2_encoder_get_packet(avctx, ctx, &packet)) - return 0; - -- ff_alloc_packet2(avctx, pkt, packet.payload_size, packet.payload_size); -+ ff_alloc_packet(avctx, pkt, packet.payload_size); - - memcpy(pkt->data, packet.payload, packet.payload_size); - pkt->dts = pkt->pts = packet.pts; -@@ -1286,7 +1288,7 @@ - return 0; - } - --static const AVCodecDefault defaults[] = { -+static const FFCodecDefault defaults[] = { - { "b", "5M" }, - { "qmin", "-1" }, - { "qmax", "-1" }, -@@ -1455,20 +1457,20 @@ + #include "libavutil/opt.h" +@@ -1455,20 +1455,20 @@ static const AVOption options_hevc[] = { #define NVV4L2_ENC(NAME, ID) \ NVV4L2_ENC_CLASS(NAME) \ @@ -82,18 +75,17 @@ diff -Naur ffmpeg-6.0/libavcodec/nvv4l2_enc.c ffmpeg-6.0-2/libavcodec/nvv4l2_enc - .long_name = NULL_IF_CONFIG_SMALL(#NAME " NVV4L2 HW encoder for Tegra"), \ - .type = AVMEDIA_TYPE_VIDEO, \ - .id = ID, \ -+ FFCodec ff_##NAME##_nvv4l2_encoder = { \ ++ const FFCodec ff_##NAME##_nvv4l2_encoder = { \ + .p.name = #NAME "_nvv4l2" , \ -+ CODEC_LONG_NAME(NULL_IF_CONFIG_SMALL(#NAME " NVV4L2 HW encoder for Tegra")), \ ++ .p.long_name = NULL_IF_CONFIG_SMALL(#NAME " NVV4L2 HW encoder for Tegra"), \ + .p.type = AVMEDIA_TYPE_VIDEO, \ + .p.id = ID, \ .priv_data_size = sizeof(nvv4l2EncodeContext), \ .init = nvv4l2enc_init, \ .close = nvv4l2enc_close, \ -- .encode2 = nvv4l2enc_encode, \ + .encode2 = nvv4l2enc_encode, \ - .priv_class = &nvv4l2_##NAME##_enc_class, \ - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, \ -+ FF_CODEC_ENCODE_CB(nvv4l2enc_encode), \ + .p.priv_class = &nvv4l2_##NAME##_enc_class, \ + .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, \ .defaults = defaults, \ @@ -104,3 +96,6 @@ diff -Naur ffmpeg-6.0/libavcodec/nvv4l2_enc.c ffmpeg-6.0-2/libavcodec/nvv4l2_enc AV_PIX_FMT_YUV444P, \ AV_PIX_FMT_NV12, \ AV_PIX_FMT_P010, \ +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0023-codecs-nvv4l2-comment-structs-redefined-in-nvv4l2.h.patch b/packages/multimedia/ffmpeg/patches/L4T/0023-codecs-nvv4l2-comment-structs-redefined-in-nvv4l2.h.patch new file mode 100644 index 0000000000..cd72a81f2d --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0023-codecs-nvv4l2-comment-structs-redefined-in-nvv4l2.h.patch @@ -0,0 +1,92 @@ +From 23ccbf1d6a5494c7d79e8df2c74f02358e8df7d4 Mon Sep 17 00:00:00 2001 +From: Azkali Manad +Date: Wed, 25 Jan 2023 03:08:02 +0100 +Subject: [PATCH 23/39] codecs: nvv4l2: comment structs redefined in nvv4l2.h + +--- + libavcodec/nvv4l2_ext_utils.h | 32 ++++++++++++++++---------------- + 1 file changed, 16 insertions(+), 16 deletions(-) + +diff --git a/libavcodec/nvv4l2_ext_utils.h b/libavcodec/nvv4l2_ext_utils.h +index 007306ccc5..04a2ee1c79 100644 +--- a/libavcodec/nvv4l2_ext_utils.h ++++ b/libavcodec/nvv4l2_ext_utils.h +@@ -178,7 +178,7 @@ enum v4l2_mpeg_video_h265_profile { + #define V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY 0x10 + #define V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD 0x20 + #define V4L2_H264_SPS_FLAG_DIRECT_8X8_INFERENCE 0x40 +-struct v4l2_ctrl_h264_sps { ++/* struct v4l2_ctrl_h264_sps { + __u8 profile_idc; + __u8 constraint_set_flags; + __u8 level_idc; +@@ -197,7 +197,7 @@ struct v4l2_ctrl_h264_sps { + __u16 pic_width_in_mbs_minus1; + __u16 pic_height_in_map_units_minus1; + __u8 flags; +-}; ++}; */ + + #define V4L2_H264_PPS_FLAG_ENTROPY_CODING_MODE 0x0001 + #define V4L2_H264_PPS_FLAG_BOTTOM_FIELD_PIC_ORDER_IN_FRAME_PRESENT 0x0002 +@@ -207,7 +207,7 @@ struct v4l2_ctrl_h264_sps { + #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 +-struct v4l2_ctrl_h264_pps { ++/* struct v4l2_ctrl_h264_pps { + __u8 pic_parameter_set_id; + __u8 seq_parameter_set_id; + __u8 num_slice_groups_minus1; +@@ -219,19 +219,19 @@ struct v4l2_ctrl_h264_pps { + __s8 chroma_qp_index_offset; + __s8 second_chroma_qp_index_offset; + __u8 flags; +-}; ++}; */ + +-struct v4l2_ctrl_h264_scaling_matrix { ++/* struct v4l2_ctrl_h264_scaling_matrix { + __u8 scaling_list_4x4[6][16]; + __u8 scaling_list_8x8[6][64]; +-}; ++}; */ + +-struct v4l2_h264_weight_factors { ++/* struct v4l2_h264_weight_factors { + __s8 luma_weight[32]; + __s8 luma_offset[32]; + __s8 chroma_weight[32][2]; + __s8 chroma_offset[32][2]; +-}; ++}; */ + + struct v4l2_h264_pred_weight_table { + __u8 luma_log2_weight_denom; +@@ -289,15 +289,15 @@ struct v4l2_ctrl_h264_slice_param { + If not set, this entry is unused for reference. */ + #define V4L2_H264_DPB_ENTRY_FLAG_ACTIVE 0x01 + #define V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM 0x02 +-struct v4l2_h264_dpb_entry { +- __u32 buf_index; /**< v4l2_buffer index. */ +- __u16 frame_num; +- __u16 pic_num; ++/* struct v4l2_h264_dpb_entry { */ ++/* __u32 buf_index; /**< v4l2_buffer index. */ ++/* __u16 frame_num; ++ __u16 pic_num; */ + /** @note `v4l2_buffer.field` specifies this field. */ +- __s32 top_field_order_cnt; +- __s32 bottom_field_order_cnt; +- __u8 flags; /* V4L2_H264_DPB_ENTRY_FLAG_* */ +-}; ++/* __s32 top_field_order_cnt; ++ __s32 bottom_field_order_cnt; */ ++/* __u8 flags; /* V4L2_H264_DPB_ENTRY_FLAG_* */ ++/* }; */ + + struct v4l2_ctrl_h264_decode_param { + __u32 num_slices; +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0024-codecs-nvv4l2-More-API-related-changes.patch b/packages/multimedia/ffmpeg/patches/L4T/0024-codecs-nvv4l2-More-API-related-changes.patch new file mode 100644 index 0000000000..102f645a08 --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0024-codecs-nvv4l2-More-API-related-changes.patch @@ -0,0 +1,68 @@ +From b2f78477cf1cca514a91a4a5ecd6f93fee289f2a Mon Sep 17 00:00:00 2001 +From: Azkali Manad +Date: Wed, 25 Jan 2023 03:32:12 +0100 +Subject: [PATCH 24/39] codecs: nvv4l2: More API related changes + + decoder: add internal.h header needed for ff_get_buffer + encoder: Rename AVCodecDefault to FFCodecDefault + *: use callback defines for encode/decode struct members +--- + libavcodec/nvv4l2_dec.c | 3 ++- + libavcodec/nvv4l2_enc.c | 6 +++--- + 2 files changed, 5 insertions(+), 4 deletions(-) + +diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c +index b56d35cf82..26e7363823 100644 +--- a/libavcodec/nvv4l2_dec.c ++++ b/libavcodec/nvv4l2_dec.c +@@ -30,6 +30,7 @@ + #include + #include + #include "codec_internal.h" ++#include "internal.h" + #include "libavutil/log.h" + + #include "nvv4l2.h" +@@ -1211,7 +1212,7 @@ nvv4l2dec_decode(AVCodecContext *avctx, void *data, int *got_frame, + .priv_data_size = sizeof(nvv4l2DecodeContext), \ + .init = nvv4l2dec_init, \ + .close = nvv4l2dec_close, \ +- .decode = nvv4l2dec_decode, \ ++ FF_CODEC_DECODE_CB(nvv4l2dec_decode) \ + .flush = nvv4l2dec_flush, \ + .p.priv_class = &nvv4l2_##NAME##_dec_class, \ + .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE | \ +diff --git a/libavcodec/nvv4l2_enc.c b/libavcodec/nvv4l2_enc.c +index fad54868e3..7f1aad1b32 100644 +--- a/libavcodec/nvv4l2_enc.c ++++ b/libavcodec/nvv4l2_enc.c +@@ -1265,7 +1265,7 @@ nvv4l2enc_encode(AVCodecContext *avctx, AVPacket *pkt, + if (nvv4l2_encoder_get_packet(avctx, ctx, &packet)) + return 0; + +- ff_alloc_packet2(avctx, pkt, packet.payload_size, packet.payload_size); ++ ff_alloc_packet(avctx, pkt, packet.payload_size, packet.payload_size); + + memcpy(pkt->data, packet.payload, packet.payload_size); + pkt->dts = pkt->pts = packet.pts; +@@ -1286,7 +1286,7 @@ static av_cold int nvv4l2enc_close(AVCodecContext *avctx) + return 0; + } + +-static const AVCodecDefault defaults[] = { ++static const FFCodecDefault defaults[] = { + { "b", "5M" }, + { "qmin", "-1" }, + { "qmax", "-1" }, +@@ -1463,7 +1463,7 @@ static const AVOption options_hevc[] = { + .priv_data_size = sizeof(nvv4l2EncodeContext), \ + .init = nvv4l2enc_init, \ + .close = nvv4l2enc_close, \ +- .encode2 = nvv4l2enc_encode, \ ++ FF_CODEC_ENCODE_CB(nvv4l2enc_encode), \ + .p.priv_class = &nvv4l2_##NAME##_enc_class, \ + .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, \ + .defaults = defaults, \ +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0025-codecs-nvv4l2-add-encode.h-header-needed-for-ff_allo.patch b/packages/multimedia/ffmpeg/patches/L4T/0025-codecs-nvv4l2-add-encode.h-header-needed-for-ff_allo.patch new file mode 100644 index 0000000000..4464519581 --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0025-codecs-nvv4l2-add-encode.h-header-needed-for-ff_allo.patch @@ -0,0 +1,25 @@ +From 157e6cffa1464b66809d32b5d511f62882068dcd Mon Sep 17 00:00:00 2001 +From: Azkali Manad +Date: Wed, 25 Jan 2023 03:42:59 +0100 +Subject: [PATCH 25/39] codecs: nvv4l2: add encode.h header needed for + ff_alloc_packet + +--- + libavcodec/nvv4l2_enc.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libavcodec/nvv4l2_enc.c b/libavcodec/nvv4l2_enc.c +index 7f1aad1b32..6c3d276f31 100644 +--- a/libavcodec/nvv4l2_enc.c ++++ b/libavcodec/nvv4l2_enc.c +@@ -29,6 +29,7 @@ + #include + #include + #include "codec_internal.h" ++#include "encode.h" + #include "libavutil/imgutils.h" + #include "libavutil/log.h" + #include "libavutil/opt.h" +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0026-codecs-nvv4l2-fix-missing-comma-in-FFCodec-struct.patch b/packages/multimedia/ffmpeg/patches/L4T/0026-codecs-nvv4l2-fix-missing-comma-in-FFCodec-struct.patch new file mode 100644 index 0000000000..bc43143229 --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0026-codecs-nvv4l2-fix-missing-comma-in-FFCodec-struct.patch @@ -0,0 +1,25 @@ +From c1447a426afa49ed23384f2b135ea9748c98d568 Mon Sep 17 00:00:00 2001 +From: Azkali Manad +Date: Wed, 25 Jan 2023 03:45:50 +0100 +Subject: [PATCH 26/39] codecs: nvv4l2: fix missing comma in FFCodec struct + +--- + libavcodec/nvv4l2_dec.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c +index 26e7363823..fe54883522 100644 +--- a/libavcodec/nvv4l2_dec.c ++++ b/libavcodec/nvv4l2_dec.c +@@ -1212,7 +1212,7 @@ nvv4l2dec_decode(AVCodecContext *avctx, void *data, int *got_frame, + .priv_data_size = sizeof(nvv4l2DecodeContext), \ + .init = nvv4l2dec_init, \ + .close = nvv4l2dec_close, \ +- FF_CODEC_DECODE_CB(nvv4l2dec_decode) \ ++ FF_CODEC_DECODE_CB(nvv4l2dec_decode), \ + .flush = nvv4l2dec_flush, \ + .p.priv_class = &nvv4l2_##NAME##_dec_class, \ + .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE | \ +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0027-codecs-nvv4l2-remove-second-size-argument-as-it-is-u.patch b/packages/multimedia/ffmpeg/patches/L4T/0027-codecs-nvv4l2-remove-second-size-argument-as-it-is-u.patch new file mode 100644 index 0000000000..270b5a6fa5 --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0027-codecs-nvv4l2-remove-second-size-argument-as-it-is-u.patch @@ -0,0 +1,26 @@ +From cd758dad831c7f7f115b0fcc8646e241d338c800 Mon Sep 17 00:00:00 2001 +From: Azkali Manad +Date: Wed, 25 Jan 2023 03:52:47 +0100 +Subject: [PATCH 27/39] codecs: nvv4l2: remove second size argument as it is + unneeded + +--- + libavcodec/nvv4l2_enc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libavcodec/nvv4l2_enc.c b/libavcodec/nvv4l2_enc.c +index 6c3d276f31..39a179b255 100644 +--- a/libavcodec/nvv4l2_enc.c ++++ b/libavcodec/nvv4l2_enc.c +@@ -1266,7 +1266,7 @@ nvv4l2enc_encode(AVCodecContext *avctx, AVPacket *pkt, + if (nvv4l2_encoder_get_packet(avctx, ctx, &packet)) + return 0; + +- ff_alloc_packet(avctx, pkt, packet.payload_size, packet.payload_size); ++ ff_alloc_packet(avctx, pkt, packet.payload_size); + + memcpy(pkt->data, packet.payload, packet.payload_size); + pkt->dts = pkt->pts = packet.pts; +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0028-codecs-nvv4l2-undo-struct-commenting-due-to-OpenBuil.patch b/packages/multimedia/ffmpeg/patches/L4T/0028-codecs-nvv4l2-undo-struct-commenting-due-to-OpenBuil.patch new file mode 100644 index 0000000000..f09f0a2639 --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0028-codecs-nvv4l2-undo-struct-commenting-due-to-OpenBuil.patch @@ -0,0 +1,56 @@ +From 1340217cbcc40418337225ca12d1d0f5dd82e682 Mon Sep 17 00:00:00 2001 +From: Azkali +Date: Thu, 26 Jan 2023 03:44:07 +0100 +Subject: [PATCH 28/39] codecs: nvv4l2: undo struct commenting due to + OpenBuildServic weirdness + +--- + libavcodec/nvv4l2_ext_utils.h | 20 ++++++++++---------- + 1 file changed, 10 insertions(+), 10 deletions(-) + +diff --git a/libavcodec/nvv4l2_ext_utils.h b/libavcodec/nvv4l2_ext_utils.h +index 04a2ee1c79..4fb66583de 100644 +--- a/libavcodec/nvv4l2_ext_utils.h ++++ b/libavcodec/nvv4l2_ext_utils.h +@@ -226,12 +226,12 @@ enum v4l2_mpeg_video_h265_profile { + __u8 scaling_list_8x8[6][64]; + }; */ + +-/* struct v4l2_h264_weight_factors { ++struct v4l2_h264_weight_factors { + __s8 luma_weight[32]; + __s8 luma_offset[32]; + __s8 chroma_weight[32][2]; + __s8 chroma_offset[32][2]; +-}; */ ++}; + + struct v4l2_h264_pred_weight_table { + __u8 luma_log2_weight_denom; +@@ -289,15 +289,15 @@ struct v4l2_ctrl_h264_slice_param { + If not set, this entry is unused for reference. */ + #define V4L2_H264_DPB_ENTRY_FLAG_ACTIVE 0x01 + #define V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM 0x02 +-/* struct v4l2_h264_dpb_entry { */ +-/* __u32 buf_index; /**< v4l2_buffer index. */ +-/* __u16 frame_num; +- __u16 pic_num; */ ++struct v4l2_h264_dpb_entry { ++ __u32 buf_index; /**< v4l2_buffer index. */ ++ __u16 frame_num; ++ __u16 pic_num; + /** @note `v4l2_buffer.field` specifies this field. */ +-/* __s32 top_field_order_cnt; +- __s32 bottom_field_order_cnt; */ +-/* __u8 flags; /* V4L2_H264_DPB_ENTRY_FLAG_* */ +-/* }; */ ++ __s32 top_field_order_cnt; ++ __s32 bottom_field_order_cnt; ++ __u8 flags; /* V4L2_H264_DPB_ENTRY_FLAG_* */ ++}; + + struct v4l2_ctrl_h264_decode_param { + __u32 num_slices; +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0029-fftools-improve-nvv4l2-enforcing-Now-non-supported-p.patch b/packages/multimedia/ffmpeg/patches/L4T/0029-fftools-improve-nvv4l2-enforcing-Now-non-supported-p.patch new file mode 100644 index 0000000000..f1f17ba94a --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0029-fftools-improve-nvv4l2-enforcing-Now-non-supported-p.patch @@ -0,0 +1,222 @@ +From a3ee3863be6268abaf331af6a12892feeb8797c6 Mon Sep 17 00:00:00 2001 +From: CTCaer +Date: Sun, 2 Jul 2023 03:18:28 +0000 +Subject: [PATCH 29/39] fftools: improve nvv4l2 enforcing Now non-supported + pixel formats are properly handled. Additionally, all edge cases are handled + even if the codec is forced by user. + +--- + fftools/ffmpeg_demux.c | 92 ++++++++++++++++++++++++++++++------------ + fftools/ffplay.c | 74 +++++++++++++++++++++++++-------- + 2 files changed, 124 insertions(+), 42 deletions(-) + +diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c +index 938ec09e3d..3b58c18f3d 100644 +--- a/fftools/ffmpeg_demux.c ++++ b/fftools/ffmpeg_demux.c +@@ -500,40 +500,80 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s + + { + char *codec_name = NULL; ++#if CONFIG_NVV4L2 ++ int nvv4l2_pix_fmt_ok; ++#endif + + MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st); +- if (codec_name) { +- const AVCodec *codec = find_codec_or_die(NULL, codec_name, st->codecpar->codec_type, 0); +- st->codecpar->codec_id = codec->id; +- if (recast_media && st->codecpar->codec_type != codec->type) +- st->codecpar->codec_type = codec->type; +- return codec; +- } else { +- if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && +- hwaccel_id == HWACCEL_GENERIC && +- hwaccel_device_type != AV_HWDEVICE_TYPE_NONE) { +- const AVCodec *c; +- void *i = NULL; +- +- while ((c = av_codec_iterate(&i))) { +- const AVCodecHWConfig *config; + +- if (c->id != st->codecpar->codec_id || +- !av_codec_is_decoder(c)) +- continue; ++#if CONFIG_NVV4L2 ++ nvv4l2_pix_fmt_ok = st->codecpar->format == AV_PIX_FMT_NONE || ++ st->codecpar->format == AV_PIX_FMT_NV12 || ++ st->codecpar->format == AV_PIX_FMT_YUV420P; + +- for (int j = 0; config = avcodec_get_hw_config(c, j); j++) { +- if (config->device_type == hwaccel_device_type) { +- av_log(NULL, AV_LOG_VERBOSE, "Selecting decoder '%s' because of requested hwaccel method %s\n", +- c->name, av_hwdevice_get_type_name(hwaccel_device_type)); +- return c; +- } +- } +- } ++ /* Force software decoding if codec name not defined and pixel format not supported. */ ++ if (!codec_name && !nvv4l2_pix_fmt_ok) { ++ switch (st->codecpar->codec_id) { ++ case AV_CODEC_ID_H264: ++ codec_name = (char *)"h264"; ++ break; ++ case AV_CODEC_ID_HEVC: ++ codec_name = (char *)"hevc"; ++ break; ++ case AV_CODEC_ID_MPEG2VIDEO: ++ codec_name = (char *)"mpeg2video"; ++ break; ++ case AV_CODEC_ID_MPEG4: ++ codec_name = (char *)"mpeg4"; ++ break; ++ case AV_CODEC_ID_VP8: ++ codec_name = (char *)"vp8"; ++ break; ++ case AV_CODEC_ID_VP9: ++ codec_name = (char *)"vp9"; ++ break; + } ++ } ++#endif + ++ if (!codec_name) + return avcodec_find_decoder(st->codecpar->codec_id); ++ ++#if CONFIG_NVV4L2 ++ if (nvv4l2_pix_fmt_ok) { ++ /* Force hardware decoding if pixel format supported. */ ++ if (strcmp(codec_name, "h264") == 0) ++ return avcodec_find_decoder(st->codecpar->codec_id); ++ else if (strcmp(codec_name, "hevc") == 0) ++ return avcodec_find_decoder(st->codecpar->codec_id); ++ else if (strcmp(codec_name, "mpeg2video") == 0) ++ return avcodec_find_decoder(st->codecpar->codec_id); ++ else if (strcmp(codec_name, "mpeg4") == 0) ++ return avcodec_find_decoder(st->codecpar->codec_id); ++ else if (strcmp(codec_name, "vp8") == 0) ++ return avcodec_find_decoder(st->codecpar->codec_id); ++ else if (strcmp(codec_name, "vp9") == 0) ++ return avcodec_find_decoder(st->codecpar->codec_id); ++ } else { ++ /* Force software decoding if pixel format not supported. */ ++ if (strcmp(codec_name, "h264_nvv4l2") == 0) ++ codec_name = (char *)"h264"; ++ else if (strcmp(codec_name, "hevc_nvv4l2") == 0) ++ codec_name = (char *)"hevc"; ++ else if (strcmp(codec_name, "mpeg2video_nvv4l2") == 0) ++ codec_name = (char *)"mpeg2video"; ++ else if (strcmp(codec_name, "mpeg4_nvv4l2") == 0) ++ codec_name = (char *)"mpeg4"; ++ else if (strcmp(codec_name, "vp8_nvv4l2") == 0) ++ codec_name = (char *)"vp8"; ++ else if (strcmp(codec_name, "vp9_nvv4l2") == 0) ++ codec_name = (char *)"vp9"; + } ++#endif ++ ++ const AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0); ++ st->codecpar->codec_id = codec->id; ++ return codec; + } + + static int guess_input_channel_layout(InputStream *ist) +diff --git a/fftools/ffplay.c b/fftools/ffplay.c +index 86f8425a15..a02f2a06a7 100644 +--- a/fftools/ffplay.c ++++ b/fftools/ffplay.c +@@ -2570,6 +2570,9 @@ static int stream_component_open(VideoState *is, int stream_index) + AVChannelLayout ch_layout = { 0 }; + int ret = 0; + int stream_lowres = lowres; ++#if CONFIG_NVV4L2 ++ int nvv4l2_pix_fmt_ok; ++#endif + + if (stream_index < 0 || stream_index >= ic->nb_streams) + return -1; +@@ -2593,26 +2596,65 @@ static int stream_component_open(VideoState *is, int stream_index) + + #if CONFIG_NVV4L2 + /* Reset requested decoder in order to enforce NVV4L2 if possible. */ ++ nvv4l2_pix_fmt_ok = avctx->pix_fmt == AV_PIX_FMT_NONE || ++ avctx->pix_fmt == AV_PIX_FMT_NV12 || ++ avctx->pix_fmt == AV_PIX_FMT_YUV420P; ++ + if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && forced_codec_name) { +- if (strcmp(forced_codec_name, "h264") == 0) +- forced_codec_name = NULL; +- else if (strcmp(forced_codec_name, "hevc") == 0) +- forced_codec_name = NULL; +- else if (strcmp(forced_codec_name, "mpeg2video") == 0) +- forced_codec_name = NULL; +- else if (strcmp(forced_codec_name, "mpeg4") == 0) +- forced_codec_name = NULL; +- else if (strcmp(forced_codec_name, "vp8") == 0) +- forced_codec_name = NULL; +- else if (strcmp(forced_codec_name, "vp9") == 0 && +- avctx->pix_fmt != AV_PIX_FMT_YUV420P10) { +- forced_codec_name = NULL; ++ if (nvv4l2_pix_fmt_ok) { ++ /* Force hardware decoding if pixel format supported. */ ++ if (strcmp(forced_codec_name, "h264") == 0) ++ forced_codec_name = NULL; ++ else if (strcmp(forced_codec_name, "hevc") == 0) ++ forced_codec_name = NULL; ++ else if (strcmp(forced_codec_name, "mpeg2video") == 0) ++ forced_codec_name = NULL; ++ else if (strcmp(forced_codec_name, "mpeg4") == 0) ++ forced_codec_name = NULL; ++ else if (strcmp(forced_codec_name, "vp8") == 0) ++ forced_codec_name = NULL; ++ else if (strcmp(forced_codec_name, "vp9") == 0) ++ forced_codec_name = NULL; ++ } else { ++ /* Force software decoding if pixel format not supported. */ ++ if (strcmp(forced_codec_name, "h264_nvv4l2") == 0) ++ forced_codec_name = (char *)"h264"; ++ else if (strcmp(forced_codec_name, "hevc_nvv4l2") == 0) ++ forced_codec_name = (char *)"hevc"; ++ else if (strcmp(forced_codec_name, "mpeg2video_nvv4l2") == 0) ++ forced_codec_name = (char *)"mpeg2video"; ++ else if (strcmp(forced_codec_name, "mpeg4_nvv4l2") == 0) ++ forced_codec_name = (char *)"mpeg4"; ++ else if (strcmp(forced_codec_name, "vp8_nvv4l2") == 0) ++ forced_codec_name = (char *)"vp8"; ++ else if (strcmp(forced_codec_name, "vp9_nvv4l2") == 0) ++ forced_codec_name = (char *)"vp9"; + } + } + +- /* NVV4L2 does not support VP9 with YUV420P10. */ +- if (!forced_codec_name && avctx->pix_fmt == AV_PIX_FMT_YUV420P10) +- forced_codec_name = "vp9"; ++ /* Force software decoding if codec name not defined and pixel format not supported. */ ++ if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !forced_codec_name && !nvv4l2_pix_fmt_ok) { ++ switch (avctx->codec_id) { ++ case AV_CODEC_ID_H264: ++ forced_codec_name = (char *)"h264"; ++ break; ++ case AV_CODEC_ID_HEVC: ++ forced_codec_name = (char *)"hevc"; ++ break; ++ case AV_CODEC_ID_MPEG2VIDEO: ++ forced_codec_name = (char *)"mpeg2video"; ++ break; ++ case AV_CODEC_ID_MPEG4: ++ forced_codec_name = (char *)"mpeg4"; ++ break; ++ case AV_CODEC_ID_VP8: ++ forced_codec_name = (char *)"vp8"; ++ break; ++ case AV_CODEC_ID_VP9: ++ forced_codec_name = (char *)"vp9"; ++ break; ++ } ++ } + #endif + + if (forced_codec_name) +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0030-nvv4l2-add-yuv420p10-support.patch b/packages/multimedia/ffmpeg/patches/L4T/0030-nvv4l2-add-yuv420p10-support.patch new file mode 100644 index 0000000000..2e4ac7475f --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0030-nvv4l2-add-yuv420p10-support.patch @@ -0,0 +1,41 @@ +From 8014b28095f1b3d2559387b7b8aca93b034561cf Mon Sep 17 00:00:00 2001 +From: CTCaer +Date: Sun, 2 Jul 2023 03:23:34 +0000 +Subject: [PATCH 30/39] nvv4l2: add yuv420p10 support NVENC supports yuv420p10 + as p010. + +--- + libavcodec/nvv4l2_enc.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/libavcodec/nvv4l2_enc.c b/libavcodec/nvv4l2_enc.c +index 39a179b255..b979c93051 100644 +--- a/libavcodec/nvv4l2_enc.c ++++ b/libavcodec/nvv4l2_enc.c +@@ -1,5 +1,5 @@ + /* +- * Copyright (c) 2021-2022, CTCaer ++ * Copyright (c) 2021-2023, CTCaer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), +@@ -1130,6 +1130,8 @@ static int nvv4l2enc_init(AVCodecContext *avctx) + case AV_PIX_FMT_NV12: + pix_fmt = V4L2_PIX_FMT_NV12M; + break; ++ case AV_PIX_FMT_YUV420P10: ++ avctx->pix_fmt = AV_PIX_FMT_P010; + case AV_PIX_FMT_P010: + pix_fmt = V4L2_PIX_FMT_P010M; + break; +@@ -1473,6 +1475,7 @@ static const AVOption options_hevc[] = { + AV_PIX_FMT_YUV444P, \ + AV_PIX_FMT_NV12, \ + AV_PIX_FMT_P010, \ ++ AV_PIX_FMT_YUV420P10, \ + AV_PIX_FMT_NONE }, \ + }; + +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0031-nvv4l2-handle-unsupported-pixel-formats-NVDEC-only-s.patch b/packages/multimedia/ffmpeg/patches/L4T/0031-nvv4l2-handle-unsupported-pixel-formats-NVDEC-only-s.patch new file mode 100644 index 0000000000..1bded6acb8 --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0031-nvv4l2-handle-unsupported-pixel-formats-NVDEC-only-s.patch @@ -0,0 +1,127 @@ +From ded4a192fa894768db5d1ab0e90256f28a87b834 Mon Sep 17 00:00:00 2001 +From: CTCaer +Date: Sun, 2 Jul 2023 03:49:48 +0000 +Subject: [PATCH 31/39] nvv4l2: handle unsupported pixel formats NVDEC only + supports YUV420 and NV12 formats. + +If a consumer starting nvv4l2 decoder with unsupported pixel format force +software decoding. + +If consumer does not probe info of the media, the pixel format will be empty. +If the actual pixel format is not supported it will result in no image. +Since the normal procedure of using libavcodec is to just open a codec via id, +without passing extra info or data, except if on purpose, there's no way to +mitigate that issue in a non-invasive way. +--- + libavcodec/avcodec.c | 2 -- + libavcodec/nvv4l2_dec.c | 58 ++++++++++++++++++++++++++++++++++++++--- + 2 files changed, 54 insertions(+), 6 deletions(-) + +diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c +index fb1362290f..773d0457b3 100644 +--- a/libavcodec/avcodec.c ++++ b/libavcodec/avcodec.c +@@ -355,8 +355,6 @@ FF_ENABLE_DEPRECATION_WARNINGS + goto free_and_end; + } + } +- if (codec->priv_class) +- av_assert0(*(const AVClass **)avctx->priv_data == codec->priv_class); + + end: + +diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c +index fe54883522..0b91cf0eba 100644 +--- a/libavcodec/nvv4l2_dec.c ++++ b/libavcodec/nvv4l2_dec.c +@@ -1,5 +1,5 @@ + /* +- * Copyright (c) 2021-2022, CTCaer ++ * Copyright (c) 2021-2023, CTCaer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), +@@ -31,10 +31,18 @@ + #include + #include "codec_internal.h" + #include "internal.h" ++#include "decode.h" ++#include "thread.h" + #include "libavutil/log.h" ++#include "libavutil/pixdesc.h" ++#include "libavutil/opt.h" + + #include "nvv4l2.h" + ++extern AVCodec ff_h264_decoder; ++extern AVCodec ff_hevc_decoder; ++extern AVCodec ff_vp9_decoder; ++ + /* + ** Output plane format support: + ** S264 (H264 Encoded Slice bitstream) +@@ -978,6 +986,48 @@ static NvCodingType map_avcodec_id(enum AVCodecID id) + return NvVideoCodec_UNDEFINED; + } + ++static int nvv4l2dec_codec_fallback(AVCodecContext *avctx) ++{ ++ av_log(avctx, AV_LOG_WARNING, "Falling back to software decoding.\n"); ++ ++ switch (avctx->codec_id) { ++ case AV_CODEC_ID_H264: ++ avctx->codec = &ff_h264_decoder; ++ break; ++ case AV_CODEC_ID_HEVC: ++ avctx->codec = &ff_hevc_decoder; ++ break; ++ case AV_CODEC_ID_VP9: ++ avctx->codec = &ff_vp9_decoder; ++ break; ++ default: ++ av_log(avctx, AV_LOG_ERROR, "Unsupported codec fallback!\n"); ++ return AVERROR_BUG; ++ } ++ ++ av_opt_free(avctx->priv_data); ++ ++ if (avctx->codec->priv_data_size > 0) { ++ avctx->priv_data = av_mallocz(avctx->codec->priv_data_size); ++ if (!avctx->priv_data) ++ return AVERROR(ENOMEM); ++ } ++ ++ if (HAVE_THREADS ++ && !(avctx->internal->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))) { ++ ff_thread_init(avctx); ++ } ++ if (!HAVE_THREADS && !(avctx->codec->caps_internal & FF_CODEC_CAP_AUTO_THREADS)) ++ avctx->thread_count = 1; ++ ++ if (avctx->codec->priv_class) { ++ *(const AVClass **)avctx->priv_data = avctx->codec->priv_class; ++ av_opt_set_defaults(avctx->priv_data); ++ } ++ ++ return avctx->codec->init(avctx); ++} ++ + static int nvv4l2dec_init(AVCodecContext *avctx) + { + nvv4l2DecodeContext *nvv4l2_ctx = avctx->priv_data; +@@ -1000,9 +1050,9 @@ static int nvv4l2dec_init(AVCodecContext *avctx) + pix_fmt = V4L2_PIX_FMT_NV12M; + break; + default: +- av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format %d!\n", +- avctx->pix_fmt); +- return AVERROR_BUG; ++ av_log(avctx, AV_LOG_WARNING, "Unsupported pixel format %s!\n", ++ av_get_pix_fmt_name(avctx->pix_fmt)); ++ return nvv4l2dec_codec_fallback(avctx); + } + + nvv4l2_ctx->ctx = nvv4l2_create_decoder(avctx, nv_codec_type, pix_fmt); +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0032-nvv4l2-allow-10-bit-HEVC-The-only-hw-support-for-10-.patch b/packages/multimedia/ffmpeg/patches/L4T/0032-nvv4l2-allow-10-bit-HEVC-The-only-hw-support-for-10-.patch new file mode 100644 index 0000000000..a1950c1ee1 --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0032-nvv4l2-allow-10-bit-HEVC-The-only-hw-support-for-10-.patch @@ -0,0 +1,92 @@ +From 9e860a0aeab0b955e627de763e9494457942222d Mon Sep 17 00:00:00 2001 +From: CTCaer +Date: Mon, 3 Jul 2023 14:19:46 +0000 +Subject: [PATCH 32/39] nvv4l2: allow 10-bit HEVC The only hw support for + 10-bit on NVDEC 2nd/3rd gen is on HEVC. H264 does not support it on main + spec, so as per previous changes it fallbacks to software decoding. VP8 codec + does not support it at all. The only out of spec non-support on hw decoding + is on VP9. + +--- + fftools/ffmpeg_demux.c | 4 ++++ + fftools/ffplay.c | 4 ++++ + libavcodec/nvv4l2_dec.c | 9 ++++++++- + libavcodec/nvv4l2_ext_utils.h | 6 ++++++ + 4 files changed, 22 insertions(+), 1 deletion(-) + +diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c +index 3b58c18f3d..f791c3a898 100644 +--- a/fftools/ffmpeg_demux.c ++++ b/fftools/ffmpeg_demux.c +@@ -510,6 +510,10 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s + nvv4l2_pix_fmt_ok = st->codecpar->format == AV_PIX_FMT_NONE || + st->codecpar->format == AV_PIX_FMT_NV12 || + st->codecpar->format == AV_PIX_FMT_YUV420P; ++ if (st->codecpar->codec_id == AV_CODEC_ID_HEVC) ++ nvv4l2_pix_fmt_ok = st->codecpar->format == AV_PIX_FMT_YUV420P10LE || ++ st->codecpar->format == AV_PIX_FMT_P010 || ++ nvv4l2_pix_fmt_ok; + + /* Force software decoding if codec name not defined and pixel format not supported. */ + if (!codec_name && !nvv4l2_pix_fmt_ok) { +diff --git a/fftools/ffplay.c b/fftools/ffplay.c +index a02f2a06a7..bbd5761115 100644 +--- a/fftools/ffplay.c ++++ b/fftools/ffplay.c +@@ -2599,6 +2599,10 @@ static int stream_component_open(VideoState *is, int stream_index) + nvv4l2_pix_fmt_ok = avctx->pix_fmt == AV_PIX_FMT_NONE || + avctx->pix_fmt == AV_PIX_FMT_NV12 || + avctx->pix_fmt == AV_PIX_FMT_YUV420P; ++ if (avctx->codec_id == AV_CODEC_ID_HEVC) ++ nvv4l2_pix_fmt_ok = avctx->pix_fmt == AV_PIX_FMT_YUV420P10LE || ++ avctx->pix_fmt == AV_PIX_FMT_P010 || ++ nvv4l2_pix_fmt_ok; + + if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && forced_codec_name) { + if (nvv4l2_pix_fmt_ok) { +diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c +index 0b91cf0eba..79116ec858 100644 +--- a/libavcodec/nvv4l2_dec.c ++++ b/libavcodec/nvv4l2_dec.c +@@ -1042,13 +1042,20 @@ static int nvv4l2dec_init(AVCodecContext *avctx) + + switch (avctx->pix_fmt) { + case AV_PIX_FMT_NONE: +- avctx->pix_fmt = AV_PIX_FMT_YUV420P; + case AV_PIX_FMT_YUV420P: ++ avctx->pix_fmt = AV_PIX_FMT_YUV420P; + pix_fmt = V4L2_PIX_FMT_YUV420M; + break; + case AV_PIX_FMT_NV12: + pix_fmt = V4L2_PIX_FMT_NV12M; + break; ++ case AV_PIX_FMT_YUV420P10LE: ++ case AV_PIX_FMT_P010: ++ if (avctx->codec_id == AV_CODEC_ID_HEVC) { ++ avctx->pix_fmt = AV_PIX_FMT_YUV420P; ++ pix_fmt = V4L2_PIX_FMT_YUV420M; ++ break; ++ } + default: + av_log(avctx, AV_LOG_WARNING, "Unsupported pixel format %s!\n", + av_get_pix_fmt_name(avctx->pix_fmt)); +diff --git a/libavcodec/nvv4l2_ext_utils.h b/libavcodec/nvv4l2_ext_utils.h +index 4fb66583de..142b429336 100644 +--- a/libavcodec/nvv4l2_ext_utils.h ++++ b/libavcodec/nvv4l2_ext_utils.h +@@ -2144,6 +2144,12 @@ typedef enum + NvBufferColorFormat_ARGB32 = 18, /* BSP 32.5.0 and up: 19 */ + /** BT.601 colorspace - Y/CbCr 4:2:0 10-bit multi-planar. */ + NvBufferColorFormat_NV12_10LE = 19, /* BSP 32.5.0 and up: 20 */ ++ /** BT.709 colorspace - Y/CbCr 4:2:0 10-bit multi-planar. */ ++ NvBufferColorFormat_NV12_10LE_709 = 20, /* BSP 32.5.0 and up: 21 */ ++ /** BT.709_ER colorspace - Y/CbCr 4:2:0 10-bit multi-planar. */ ++ NvBufferColorFormat_NV12_10LE_709_ER = 21, /* BSP 32.5.0 and up: 22 */ ++ /** BT.2020 colorspace - Y/CbCr 4:2:0 10-bit multi-planar. */ ++ NvBufferColorFormat_NV12_10LE_2020 = 22, /* BSP 32.5.0 and up: 23 */ + /** BT.709 colorspace - Y/CbCr 4:2:0 multi-planar. */ + NvBufferColorFormat_NV12_709 = 29, /* BSP 32.5.0 and up: 30 */ + /** BT.709 colorspace - Y/CbCr ER 4:2:0 multi-planar. */ +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0033-codecs-nvv4l2-more-rename-AVCodec-to-fit-API-renames.patch b/packages/multimedia/ffmpeg/patches/L4T/0033-codecs-nvv4l2-more-rename-AVCodec-to-fit-API-renames.patch new file mode 100644 index 0000000000..7bc820b716 --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0033-codecs-nvv4l2-more-rename-AVCodec-to-fit-API-renames.patch @@ -0,0 +1,29 @@ +From b4c1473d7a0db6efb31e5d5f5c7b483736ac593a Mon Sep 17 00:00:00 2001 +From: theofficialgman <28281419+theofficialgman@users.noreply.github.com> +Date: Thu, 18 Jan 2024 17:48:52 -0500 +Subject: [PATCH 33/39] codecs: nvv4l2: more rename AVCodec to fit API renames + +--- + libavcodec/nvv4l2_dec.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c +index 79116ec858..a92b191b24 100644 +--- a/libavcodec/nvv4l2_dec.c ++++ b/libavcodec/nvv4l2_dec.c +@@ -39,9 +39,9 @@ + + #include "nvv4l2.h" + +-extern AVCodec ff_h264_decoder; +-extern AVCodec ff_hevc_decoder; +-extern AVCodec ff_vp9_decoder; ++extern const FFCodec ff_h264_decoder; ++extern const FFCodec ff_hevc_decoder; ++extern const FFCodec ff_vp9_decoder; + + /* + ** Output plane format support: +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0034-codecs-nvv4l2-more-API-renames.patch b/packages/multimedia/ffmpeg/patches/L4T/0034-codecs-nvv4l2-more-API-renames.patch new file mode 100644 index 0000000000..5d9bac291b --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0034-codecs-nvv4l2-more-API-renames.patch @@ -0,0 +1,58 @@ +From 08ff68f2fb3175157a46a8dfb880f58870ac6b9e Mon Sep 17 00:00:00 2001 +From: theofficialgman <28281419+theofficialgman@users.noreply.github.com> +Date: Wed, 17 Jan 2024 22:17:55 -0500 +Subject: [PATCH 34/39] codecs: nvv4l2: more API renames + +--- + libavcodec/nvv4l2_dec.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c +index a92b191b24..5ccea0830b 100644 +--- a/libavcodec/nvv4l2_dec.c ++++ b/libavcodec/nvv4l2_dec.c +@@ -988,6 +988,8 @@ static NvCodingType map_avcodec_id(enum AVCodecID id) + + static int nvv4l2dec_codec_fallback(AVCodecContext *avctx) + { ++ const FFCodec *codec2; ++ + av_log(avctx, AV_LOG_WARNING, "Falling back to software decoding.\n"); + + switch (avctx->codec_id) { +@@ -1005,10 +1007,12 @@ static int nvv4l2dec_codec_fallback(AVCodecContext *avctx) + return AVERROR_BUG; + } + ++ codec2 = ffcodec(avctx->codec); ++ + av_opt_free(avctx->priv_data); + +- if (avctx->codec->priv_data_size > 0) { +- avctx->priv_data = av_mallocz(avctx->codec->priv_data_size); ++ if (codec2->priv_data_size > 0) { ++ avctx->priv_data = av_mallocz(codec2->priv_data_size); + if (!avctx->priv_data) + return AVERROR(ENOMEM); + } +@@ -1017,7 +1021,7 @@ static int nvv4l2dec_codec_fallback(AVCodecContext *avctx) + && !(avctx->internal->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))) { + ff_thread_init(avctx); + } +- if (!HAVE_THREADS && !(avctx->codec->caps_internal & FF_CODEC_CAP_AUTO_THREADS)) ++ if (!HAVE_THREADS && !(codec2->caps_internal & FF_CODEC_CAP_AUTO_THREADS)) + avctx->thread_count = 1; + + if (avctx->codec->priv_class) { +@@ -1025,7 +1029,7 @@ static int nvv4l2dec_codec_fallback(AVCodecContext *avctx) + av_opt_set_defaults(avctx->priv_data); + } + +- return avctx->codec->init(avctx); ++ return codec2->init(avctx); + } + + static int nvv4l2dec_init(AVCodecContext *avctx) +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0035-codecs-nvv4l2-find_codec_or_die-to-find_codec-API-re.patch b/packages/multimedia/ffmpeg/patches/L4T/0035-codecs-nvv4l2-find_codec_or_die-to-find_codec-API-re.patch new file mode 100644 index 0000000000..1b72655618 --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0035-codecs-nvv4l2-find_codec_or_die-to-find_codec-API-re.patch @@ -0,0 +1,82 @@ +From e508318655d72876d29df374c19c7edcf3134997 Mon Sep 17 00:00:00 2001 +From: theofficialgman <28281419+theofficialgman@users.noreply.github.com> +Date: Wed, 17 Jan 2024 23:45:11 -0500 +Subject: [PATCH 35/39] codecs: nvv4l2: find_codec_or_die to find_codec API + rename and rework + +--- + fftools/ffmpeg_demux.c | 47 +++++++++++++++++++++++++++--------------- + 1 file changed, 30 insertions(+), 17 deletions(-) + +diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c +index f791c3a898..17b5d63bf8 100644 +--- a/fftools/ffmpeg_demux.c ++++ b/fftools/ffmpeg_demux.c +@@ -540,24 +540,33 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s + } + #endif + +- if (!codec_name) +- return avcodec_find_decoder(st->codecpar->codec_id); ++ if (!codec_name) { ++ *pcodec = avcodec_find_decoder(st->codecpar->codec_id); ++ return 0; ++ } + + #if CONFIG_NVV4L2 + if (nvv4l2_pix_fmt_ok) { + /* Force hardware decoding if pixel format supported. */ +- if (strcmp(codec_name, "h264") == 0) +- return avcodec_find_decoder(st->codecpar->codec_id); +- else if (strcmp(codec_name, "hevc") == 0) +- return avcodec_find_decoder(st->codecpar->codec_id); +- else if (strcmp(codec_name, "mpeg2video") == 0) +- return avcodec_find_decoder(st->codecpar->codec_id); +- else if (strcmp(codec_name, "mpeg4") == 0) +- return avcodec_find_decoder(st->codecpar->codec_id); +- else if (strcmp(codec_name, "vp8") == 0) +- return avcodec_find_decoder(st->codecpar->codec_id); +- else if (strcmp(codec_name, "vp9") == 0) +- return avcodec_find_decoder(st->codecpar->codec_id); ++ if (strcmp(codec_name, "h264") == 0) { ++ *pcodec = avcodec_find_decoder(st->codecpar->codec_id); ++ return 0; ++ } else if (strcmp(codec_name, "hevc") == 0) { ++ *pcodec = avcodec_find_decoder(st->codecpar->codec_id); ++ return 0; ++ } else if (strcmp(codec_name, "mpeg2video") == 0) { ++ *pcodec = avcodec_find_decoder(st->codecpar->codec_id); ++ return 0; ++ } else if (strcmp(codec_name, "mpeg4") == 0) { ++ *pcodec = avcodec_find_decoder(st->codecpar->codec_id); ++ return 0; ++ } else if (strcmp(codec_name, "vp8") == 0) { ++ *pcodec = avcodec_find_decoder(st->codecpar->codec_id); ++ return 0; ++ } else if (strcmp(codec_name, "vp9") == 0) { ++ *pcodec = avcodec_find_decoder(st->codecpar->codec_id); ++ return 0; ++ } + } else { + /* Force software decoding if pixel format not supported. */ + if (strcmp(codec_name, "h264_nvv4l2") == 0) +@@ -575,9 +584,13 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s + } + #endif + +- const AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0); +- st->codecpar->codec_id = codec->id; +- return codec; ++ int ret = find_codec(NULL, codec_name, st->codecpar->codec_type, 0, pcodec); ++ if (ret < 0) ++ return ret; ++ st->codecpar->codec_id = (*pcodec)->id; ++ if (recast_media && st->codecpar->codec_type != (*pcodec)->type) ++ st->codecpar->codec_type = (*pcodec)->type; ++ return 0; + } + + static int guess_input_channel_layout(InputStream *ist) +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0036-codecs-nvv4l2-update-for-ABI-rework.patch b/packages/multimedia/ffmpeg/patches/L4T/0036-codecs-nvv4l2-update-for-ABI-rework.patch new file mode 100644 index 0000000000..083da07a9d --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0036-codecs-nvv4l2-update-for-ABI-rework.patch @@ -0,0 +1,30 @@ +From 8d78a510e496ea473ea7392b828e17165bb6b6ac Mon Sep 17 00:00:00 2001 +From: theofficialgman <28281419+theofficialgman@users.noreply.github.com> +Date: Sun, 21 Jan 2024 02:01:10 -0500 +Subject: [PATCH 36/39] codecs: nvv4l2: update for ABI rework + +--- + libavcodec/nvv4l2_dec.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c +index 5ccea0830b..27e06da1b5 100644 +--- a/libavcodec/nvv4l2_dec.c ++++ b/libavcodec/nvv4l2_dec.c +@@ -1175,12 +1175,11 @@ static int nvv4l2dec_close(AVCodecContext *avctx) + } + + static int +-nvv4l2dec_decode(AVCodecContext *avctx, void *data, int *got_frame, ++nvv4l2dec_decode(AVCodecContext *avctx, AVFrame *avframe, int *got_frame, + AVPacket *avpkt) + { + nvv4l2DecodeContext *nvv4l2_ctx = avctx->priv_data; + nvv4l2_ctx_t *ctx = nvv4l2_ctx->ctx; +- AVFrame *avframe = (AVFrame *)data; + NvFrame _nvframe = { 0 }; + int processed_size = 0; + int buf_index = -1; +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0037-Revert-codecs-nvv4l2-update-for-ABI-rework.patch b/packages/multimedia/ffmpeg/patches/L4T/0037-Revert-codecs-nvv4l2-update-for-ABI-rework.patch new file mode 100644 index 0000000000..5cc9084449 --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0037-Revert-codecs-nvv4l2-update-for-ABI-rework.patch @@ -0,0 +1,31 @@ +From a18c43b29c220fa020f9cac2522608b2b4cba954 Mon Sep 17 00:00:00 2001 +From: azkali +Date: Tue, 23 Jan 2024 18:28:29 +0100 +Subject: [PATCH 37/39] Revert "codecs: nvv4l2: update for ABI rework" + +This reverts commit 8d78a510e496ea473ea7392b828e17165bb6b6ac. +--- + libavcodec/nvv4l2_dec.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c +index 27e06da1b5..5ccea0830b 100644 +--- a/libavcodec/nvv4l2_dec.c ++++ b/libavcodec/nvv4l2_dec.c +@@ -1175,11 +1175,12 @@ static int nvv4l2dec_close(AVCodecContext *avctx) + } + + static int +-nvv4l2dec_decode(AVCodecContext *avctx, AVFrame *avframe, int *got_frame, ++nvv4l2dec_decode(AVCodecContext *avctx, void *data, int *got_frame, + AVPacket *avpkt) + { + nvv4l2DecodeContext *nvv4l2_ctx = avctx->priv_data; + nvv4l2_ctx_t *ctx = nvv4l2_ctx->ctx; ++ AVFrame *avframe = (AVFrame *)data; + NvFrame _nvframe = { 0 }; + int processed_size = 0; + int buf_index = -1; +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0038-Revert-codecs-nvv4l2-find_codec_or_die-to-find_codec.patch b/packages/multimedia/ffmpeg/patches/L4T/0038-Revert-codecs-nvv4l2-find_codec_or_die-to-find_codec.patch new file mode 100644 index 0000000000..9ff76c1bfe --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0038-Revert-codecs-nvv4l2-find_codec_or_die-to-find_codec.patch @@ -0,0 +1,83 @@ +From 4279fc32ea8b6da4a36aaf0b616408ad1fe4dcea Mon Sep 17 00:00:00 2001 +From: azkali +Date: Tue, 23 Jan 2024 18:35:39 +0100 +Subject: [PATCH 38/39] Revert "codecs: nvv4l2: find_codec_or_die to find_codec + API rename and rework" + +This reverts commit e508318655d72876d29df374c19c7edcf3134997. +--- + fftools/ffmpeg_demux.c | 47 +++++++++++++++--------------------------- + 1 file changed, 17 insertions(+), 30 deletions(-) + +diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c +index 17b5d63bf8..f791c3a898 100644 +--- a/fftools/ffmpeg_demux.c ++++ b/fftools/ffmpeg_demux.c +@@ -540,33 +540,24 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s + } + #endif + +- if (!codec_name) { +- *pcodec = avcodec_find_decoder(st->codecpar->codec_id); +- return 0; +- } ++ if (!codec_name) ++ return avcodec_find_decoder(st->codecpar->codec_id); + + #if CONFIG_NVV4L2 + if (nvv4l2_pix_fmt_ok) { + /* Force hardware decoding if pixel format supported. */ +- if (strcmp(codec_name, "h264") == 0) { +- *pcodec = avcodec_find_decoder(st->codecpar->codec_id); +- return 0; +- } else if (strcmp(codec_name, "hevc") == 0) { +- *pcodec = avcodec_find_decoder(st->codecpar->codec_id); +- return 0; +- } else if (strcmp(codec_name, "mpeg2video") == 0) { +- *pcodec = avcodec_find_decoder(st->codecpar->codec_id); +- return 0; +- } else if (strcmp(codec_name, "mpeg4") == 0) { +- *pcodec = avcodec_find_decoder(st->codecpar->codec_id); +- return 0; +- } else if (strcmp(codec_name, "vp8") == 0) { +- *pcodec = avcodec_find_decoder(st->codecpar->codec_id); +- return 0; +- } else if (strcmp(codec_name, "vp9") == 0) { +- *pcodec = avcodec_find_decoder(st->codecpar->codec_id); +- return 0; +- } ++ if (strcmp(codec_name, "h264") == 0) ++ return avcodec_find_decoder(st->codecpar->codec_id); ++ else if (strcmp(codec_name, "hevc") == 0) ++ return avcodec_find_decoder(st->codecpar->codec_id); ++ else if (strcmp(codec_name, "mpeg2video") == 0) ++ return avcodec_find_decoder(st->codecpar->codec_id); ++ else if (strcmp(codec_name, "mpeg4") == 0) ++ return avcodec_find_decoder(st->codecpar->codec_id); ++ else if (strcmp(codec_name, "vp8") == 0) ++ return avcodec_find_decoder(st->codecpar->codec_id); ++ else if (strcmp(codec_name, "vp9") == 0) ++ return avcodec_find_decoder(st->codecpar->codec_id); + } else { + /* Force software decoding if pixel format not supported. */ + if (strcmp(codec_name, "h264_nvv4l2") == 0) +@@ -584,13 +575,9 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s + } + #endif + +- int ret = find_codec(NULL, codec_name, st->codecpar->codec_type, 0, pcodec); +- if (ret < 0) +- return ret; +- st->codecpar->codec_id = (*pcodec)->id; +- if (recast_media && st->codecpar->codec_type != (*pcodec)->type) +- st->codecpar->codec_type = (*pcodec)->type; +- return 0; ++ const AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0); ++ st->codecpar->codec_id = codec->id; ++ return codec; + } + + static int guess_input_channel_layout(InputStream *ist) +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0039-fftools-ffmpeg-set-find_codec_or_die-logctx-to-NULL.patch b/packages/multimedia/ffmpeg/patches/L4T/0039-fftools-ffmpeg-set-find_codec_or_die-logctx-to-NULL.patch new file mode 100644 index 0000000000..8b09e81a42 --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0039-fftools-ffmpeg-set-find_codec_or_die-logctx-to-NULL.patch @@ -0,0 +1,25 @@ +From a8e8a2151948790f9702802aa87b65bbf5049ac1 Mon Sep 17 00:00:00 2001 +From: azkali +Date: Tue, 23 Jan 2024 18:50:41 +0100 +Subject: [PATCH 39/39] fftools/ffmpeg: set find_codec_or_die logctx to NULL + +--- + fftools/ffmpeg_demux.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c +index f791c3a898..975a9f5f17 100644 +--- a/fftools/ffmpeg_demux.c ++++ b/fftools/ffmpeg_demux.c +@@ -575,7 +575,7 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s + } + #endif + +- const AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0); ++ const AVCodec *codec = find_codec_or_die(NULL, codec_name, st->codecpar->codec_type, 0); + st->codecpar->codec_id = codec->id; + return codec; + } +-- +2.25.1 + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0040-nvv4l2-do-not-override-key_frame.patch b/packages/multimedia/ffmpeg/patches/L4T/0040-nvv4l2-do-not-override-key_frame.patch new file mode 100644 index 0000000000..92d4351fe1 --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/L4T/0040-nvv4l2-do-not-override-key_frame.patch @@ -0,0 +1,43 @@ +From 91e53cd8349f6a6a74ef7bc9498052467345cff4 Mon Sep 17 00:00:00 2001 +From: CTCaer +Date: Sat, 27 Jan 2024 00:34:28 +0000 +Subject: [PATCH] nvv4l2: do not override key_frame Some apps are managing this + by replacing the ffmpeg get buffer function. Additionally, some badly coded + apps use that for actually starting outputting to screen or framebuffer, even + though the expected frames from the decoder are always full frames. + +--- + libavcodec/nvv4l2_dec.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c +index b2ac349201a..751f4379e89 100644 +--- a/libavcodec/nvv4l2_dec.c ++++ b/libavcodec/nvv4l2_dec.c +@@ -1,5 +1,5 @@ + /* +- * Copyright (c) 2021-2023, CTCaer ++ * Copyright (c) 2021-2024, CTCaer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), +@@ -1236,12 +1236,13 @@ nvv4l2dec_decode(AVCodecContext *avctx, void *data, int *got_frame, + if (_nvframe.pts != AV_NOPTS_VALUE) { + avframe->pts = _nvframe.pts; + } else { +- avframe->pts = _nvframe.pts; ++ /*! NOTE: Investigate if setting reordered_opaque to pts instead ++ * is better for no-pts streams compatibility. ++ */ ++ avframe->pts = AV_NOPTS_VALUE; + avframe->reordered_opaque = _nvframe.user_pts; + } + +- avframe->key_frame = 0; +- + avctx->coded_width = _nvframe.width; + avctx->coded_height = _nvframe.height; + avctx->width = _nvframe.width; +-- +GitLab + diff --git a/packages/multimedia/ffmpeg/patches/L4T/0023-fix-libreelec-configure.patch b/packages/multimedia/ffmpeg/patches/L4T/0041-fix-libreelec-configure.patch similarity index 100% rename from packages/multimedia/ffmpeg/patches/L4T/0023-fix-libreelec-configure.patch rename to packages/multimedia/ffmpeg/patches/L4T/0041-fix-libreelec-configure.patch diff --git a/packages/network/bluez/package.mk b/packages/network/bluez/package.mk index 8aebaabdf6..7737b6ed14 100644 --- a/packages/network/bluez/package.mk +++ b/packages/network/bluez/package.mk @@ -70,7 +70,7 @@ post_makeinstall_target() { -e "s|^#AutoEnable.*|AutoEnable=true|g" \ -e "s|^#JustWorksRepairing.*|JustWorksRepairing=always|g" - if [ "${DISTRO}" = "Lakka" ]; then + if [ "${DISTRO}" = "Lakka" ] || [ "${PROJECT}" = "L4T" -a "${DEVICE}" = "Switch" ]; then sed -i $INSTALL/etc/bluetooth/main.conf \ -e "s|^#FastConnectable.*|FastConnectable=true|g" \ -e "s|^# Privacy =.*|Privacy = device|g" diff --git a/projects/L4T/devices/Switch/linux/linux.aarch64.conf b/projects/L4T/devices/Switch/linux/linux.aarch64.conf index ec115aa3af..80a4a519df 100644 --- a/projects/L4T/devices/Switch/linux/linux.aarch64.conf +++ b/projects/L4T/devices/Switch/linux/linux.aarch64.conf @@ -2619,7 +2619,7 @@ CONFIG_REGULATOR_PWM=y # CONFIG_REGULATOR_PMIC_OTP is not set CONFIG_MEDIA_SUPPORT=y CONFIG_STAGING_MEDIA=y -CONFIG_MEDIA_CEC=y +CONFIG_MEDIA_CEC_SUPPORT=y # # Multimedia core support diff --git a/projects/L4T/devices/Switch/options b/projects/L4T/devices/Switch/options index 01d324ab8d..32b676f0e0 100644 --- a/projects/L4T/devices/Switch/options +++ b/projects/L4T/devices/Switch/options @@ -27,7 +27,7 @@ else echo "Unknown distro, expect issues" fi -ADDITIONAL_PACKAGES+=" switch-bsp libcec v4l-utils" +ADDITIONAL_PACKAGES+=" switch-bsp v4l-utils" #Remove since we include driver in kernel now. Module Config/udev rules #Included in switch-bsp package, to match version in kernel(0.9.5). diff --git a/projects/L4T/devices/Switch/packages/kodi/system.d/kodi.service b/projects/L4T/devices/Switch/packages/kodi/system.d/kodi.service index 0ad29a8bdf..87490a9765 100644 --- a/projects/L4T/devices/Switch/packages/kodi/system.d/kodi.service +++ b/projects/L4T/devices/Switch/packages/kodi/system.d/kodi.service @@ -5,8 +5,6 @@ Requires=graphical.target Wants=network-online.target [Service] -User=LibreELEC -Group=LibreELEC Environment=HOME=/storage DISPLAY=:0 PULSE_SERVER=127.0.0.1 EnvironmentFile=/usr/lib/kodi/kodi.conf EnvironmentFile=-/run/libreelec/kodi.conf diff --git a/projects/L4T/devices/Switch/packages/switch-bsp/package.mk b/projects/L4T/devices/Switch/packages/switch-bsp/package.mk index 1060977847..541e1b8728 100755 --- a/projects/L4T/devices/Switch/packages/switch-bsp/package.mk +++ b/projects/L4T/devices/Switch/packages/switch-bsp/package.mk @@ -1,10 +1,14 @@ PKG_NAME="switch-bsp" -PKG_VERSION="1.1" +PKG_VERSION="1.2" PKG_LICENSE="GPL" -PKG_DEPENDS_TARGET="joycond rewritefs xdotool alsa-lib alsa-ucm-conf usb-gadget-scripts v4l-utils" +PKG_DEPENDS_TARGET="joycond rewritefs xdotool alsa-lib alsa-ucm-conf usb-gadget-scripts" PKG_SECTION="virtual" PKG_LONGDESC="LibreELEC Nintendo Switch Board Support" +if [ ! ${PROJECT} = "LibreELEC" ]; then + PKG_DEPENDS_TARGET="v4l-utils" # We use this for CEC in lakka, in libreELEC kodi handles that via libCEC. +fi + post_install() { enable_service xorg-configure-switch.service enable_service var-bluetoothconfig.mount diff --git a/projects/L4T/devices/Switch/packages/switch-bsp/scripts/dock-hotplug b/projects/L4T/devices/Switch/packages/switch-bsp/scripts/dock-hotplug index f321ed34a7..b86112fa5e 100755 --- a/projects/L4T/devices/Switch/packages/switch-bsp/scripts/dock-hotplug +++ b/projects/L4T/devices/Switch/packages/switch-bsp/scripts/dock-hotplug @@ -69,10 +69,12 @@ if [[ "$1" -eq 1 ]]; then LOOPS=5; fi while [ "$i" -le "$LOOPS" ]; do if grep -q 1 "/sys/class/switch/dp/state"; then DP_ENABLED=1; else DP_ENABLED=0; fi - # Prepare CEC info. - if [ -f /tmp/.CEC ]; then - if [[ "$DP_ENABLED" -eq 0 ]]; then cec-ctl -C - else cec-ctl -s -o NintendoSwitch --playback --active-source phys-addr="$(cec-ctl | sed -n 's/.*Physical Address.*: //p')"; fi + # Prepare CEC info. ignore if libreelec, kodi will handle this. + if [ "$(cat /etc/os-release | grep LibreELEC)" = "" ]; then + if [ -f /tmp/.CEC ]; then + if [[ "$DP_ENABLED" -eq 0 ]]; then cec-ctl -C + else cec-ctl -s -o NintendoSwitch --playback --active-source phys-addr="$(cec-ctl | sed -n 's/.*Physical Address.*: //p')"; fi + fi fi # Configure dock diff --git a/projects/L4T/devices/Switch/patches/linux/0004-fix-libcec-build.patch b/projects/L4T/devices/Switch/patches/linux/0004-fix-libcec-build.patch new file mode 100644 index 0000000000..41e22bbf21 --- /dev/null +++ b/projects/L4T/devices/Switch/patches/linux/0004-fix-libcec-build.patch @@ -0,0 +1,304 @@ +From 0dbacebede1e4e44bf500f94d692fad05eb2c293 Mon Sep 17 00:00:00 2001 +From: Hans Verkuil +Date: Wed, 2 Nov 2016 08:25:28 -0200 +Subject: [PATCH] [media] cec: move the CEC framework out of staging and to + media + +The last open issues have been addressed, so it is time to move +this out of staging and into the mainline and to move the public +cec headers to include/uapi/linux. + +Signed-off-by: Hans Verkuil +Signed-off-by: Mauro Carvalho Chehab +--- + Documentation/media/Makefile | 2 +- + drivers/media/Kconfig | 16 ++++++++++++++++ + drivers/media/Makefile | 4 ++++ + drivers/{staging => }/media/cec/Makefile | 2 +- + drivers/{staging => }/media/cec/cec-adap.c | 0 + drivers/{staging => }/media/cec/cec-api.c | 0 + drivers/{staging => }/media/cec/cec-core.c | 0 + drivers/{staging => }/media/cec/cec-priv.h | 0 + drivers/media/i2c/Kconfig | 6 +++--- + drivers/media/platform/vivid/Kconfig | 2 +- + drivers/staging/media/Kconfig | 2 -- + drivers/staging/media/Makefile | 1 - + drivers/staging/media/cec/Kconfig | 12 ------------ + drivers/staging/media/cec/TODO | 9 --------- + drivers/staging/media/pulse8-cec/Kconfig | 2 +- + drivers/staging/media/s5p-cec/Kconfig | 2 +- + drivers/staging/media/st-cec/Kconfig | 2 +- + include/media/cec.h | 2 +- + include/uapi/linux/Kbuild | 2 ++ + include/{ => uapi}/linux/cec-funcs.h | 6 ------ + include/{ => uapi}/linux/cec.h | 6 ------ + 21 files changed, 32 insertions(+), 46 deletions(-) + rename drivers/{staging => }/media/cec/Makefile (70%) + rename drivers/{staging => }/media/cec/cec-adap.c (100%) + rename drivers/{staging => }/media/cec/cec-api.c (100%) + rename drivers/{staging => }/media/cec/cec-core.c (100%) + rename drivers/{staging => }/media/cec/cec-priv.h (100%) + delete mode 100644 drivers/staging/media/cec/Kconfig + delete mode 100644 drivers/staging/media/cec/TODO + rename include/{ => uapi}/linux/cec-funcs.h (99%) + rename include/{ => uapi}/linux/cec.h (99%) + +diff --git a/Documentation/media/Makefile b/Documentation/media/Makefile +index a7fb35291f6c61..61afa052c501a1 100644 +--- a/Documentation/media/Makefile ++++ b/Documentation/media/Makefile +@@ -51,7 +51,7 @@ $(BUILDDIR)/videodev2.h.rst: ${UAPI}/videodev2.h ${PARSER} $(SRC_DIR)/videodev2. + $(BUILDDIR)/media.h.rst: ${UAPI}/media.h ${PARSER} $(SRC_DIR)/media.h.rst.exceptions + @$($(quiet)gen_rst) + +-$(BUILDDIR)/cec.h.rst: ${KAPI}/cec.h ${PARSER} $(SRC_DIR)/cec.h.rst.exceptions ++$(BUILDDIR)/cec.h.rst: ${UAPI}/cec.h ${PARSER} $(SRC_DIR)/cec.h.rst.exceptions + @$($(quiet)gen_rst) + + $(BUILDDIR)/lirc.h.rst: ${UAPI}/lirc.h ${PARSER} $(SRC_DIR)/lirc.h.rst.exceptions +diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig +index 7b854029121731..bc643cbf813ef8 100644 +--- a/drivers/media/Kconfig ++++ b/drivers/media/Kconfig +@@ -80,6 +80,22 @@ config MEDIA_RC_SUPPORT + + Say Y when you have a TV or an IR device. + ++config MEDIA_CEC_SUPPORT ++ bool "HDMI CEC support" ++ select MEDIA_CEC_EDID ++ ---help--- ++ Enable support for HDMI CEC (Consumer Electronics Control), ++ which is an optional HDMI feature. ++ ++ Say Y when you have an HDMI receiver, transmitter or a USB CEC ++ adapter that supports HDMI CEC. ++ ++config MEDIA_CEC_DEBUG ++ bool "HDMI CEC debugfs interface" ++ depends on MEDIA_CEC_SUPPORT && DEBUG_FS ++ ---help--- ++ Turns on the DebugFS interface for CEC devices. ++ + config MEDIA_CEC_EDID + bool + +diff --git a/drivers/media/Makefile b/drivers/media/Makefile +index 0deaa93efdee61..d87ccb8eeabe6b 100644 +--- a/drivers/media/Makefile ++++ b/drivers/media/Makefile +@@ -6,6 +6,10 @@ ifeq ($(CONFIG_MEDIA_CEC_EDID),y) + obj-$(CONFIG_MEDIA_SUPPORT) += cec-edid.o + endif + ++ifeq ($(CONFIG_MEDIA_CEC_SUPPORT),y) ++ obj-$(CONFIG_MEDIA_SUPPORT) += cec/ ++endif ++ + media-objs := media-device.o media-devnode.o media-entity.o + + # +diff --git a/drivers/staging/media/cec/Makefile b/drivers/media/cec/Makefile +similarity index 70% +rename from drivers/staging/media/cec/Makefile +rename to drivers/media/cec/Makefile +index bd7f3c5934680b..d6686337275ff8 100644 +--- a/drivers/staging/media/cec/Makefile ++++ b/drivers/media/cec/Makefile +@@ -1,5 +1,5 @@ + cec-objs := cec-core.o cec-adap.o cec-api.o + +-ifeq ($(CONFIG_MEDIA_CEC),y) ++ifeq ($(CONFIG_MEDIA_CEC_SUPPORT),y) + obj-$(CONFIG_MEDIA_SUPPORT) += cec.o + endif +diff --git a/drivers/staging/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c +similarity index 100% +rename from drivers/staging/media/cec/cec-adap.c +rename to drivers/media/cec/cec-adap.c +diff --git a/drivers/staging/media/cec/cec-api.c b/drivers/media/cec/cec-api.c +similarity index 100% +rename from drivers/staging/media/cec/cec-api.c +rename to drivers/media/cec/cec-api.c +diff --git a/drivers/staging/media/cec/cec-core.c b/drivers/media/cec/cec-core.c +similarity index 100% +rename from drivers/staging/media/cec/cec-core.c +rename to drivers/media/cec/cec-core.c +diff --git a/drivers/staging/media/cec/cec-priv.h b/drivers/media/cec/cec-priv.h +similarity index 100% +rename from drivers/staging/media/cec/cec-priv.h +rename to drivers/media/cec/cec-priv.h +diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig +index 2669b4bad91068..b31fa6fae00917 100644 +--- a/drivers/media/i2c/Kconfig ++++ b/drivers/media/i2c/Kconfig +@@ -221,7 +221,7 @@ config VIDEO_ADV7604 + + config VIDEO_ADV7604_CEC + bool "Enable Analog Devices ADV7604 CEC support" +- depends on VIDEO_ADV7604 && MEDIA_CEC ++ depends on VIDEO_ADV7604 && MEDIA_CEC_SUPPORT + ---help--- + When selected the adv7604 will support the optional + HDMI CEC feature. +@@ -242,7 +242,7 @@ config VIDEO_ADV7842 + + config VIDEO_ADV7842_CEC + bool "Enable Analog Devices ADV7842 CEC support" +- depends on VIDEO_ADV7842 && MEDIA_CEC ++ depends on VIDEO_ADV7842 && MEDIA_CEC_SUPPORT + ---help--- + When selected the adv7842 will support the optional + HDMI CEC feature. +@@ -481,7 +481,7 @@ config VIDEO_ADV7511 + + config VIDEO_ADV7511_CEC + bool "Enable Analog Devices ADV7511 CEC support" +- depends on VIDEO_ADV7511 && MEDIA_CEC ++ depends on VIDEO_ADV7511 && MEDIA_CEC_SUPPORT + ---help--- + When selected the adv7511 will support the optional + HDMI CEC feature. +diff --git a/drivers/media/platform/vivid/Kconfig b/drivers/media/platform/vivid/Kconfig +index 8e6918c5c87c5d..db0dd19d227acc 100644 +--- a/drivers/media/platform/vivid/Kconfig ++++ b/drivers/media/platform/vivid/Kconfig +@@ -25,7 +25,7 @@ config VIDEO_VIVID + + config VIDEO_VIVID_CEC + bool "Enable CEC emulation support" +- depends on VIDEO_VIVID && MEDIA_CEC ++ depends on VIDEO_VIVID && MEDIA_CEC_SUPPORT + ---help--- + When selected the vivid module will emulate the optional + HDMI CEC feature. +diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig +index 6620d96ee44d2f..0abe5ffb49346d 100644 +--- a/drivers/staging/media/Kconfig ++++ b/drivers/staging/media/Kconfig +@@ -21,8 +21,6 @@ if STAGING_MEDIA && MEDIA_SUPPORT + # Please keep them in alphabetic order + source "drivers/staging/media/bcm2048/Kconfig" + +-source "drivers/staging/media/cec/Kconfig" +- + source "drivers/staging/media/cxd2099/Kconfig" + + source "drivers/staging/media/davinci_vpfe/Kconfig" +diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile +index 906257e94dda89..246299eff80dc3 100644 +--- a/drivers/staging/media/Makefile ++++ b/drivers/staging/media/Makefile +@@ -1,5 +1,4 @@ + obj-$(CONFIG_I2C_BCM2048) += bcm2048/ +-obj-$(CONFIG_MEDIA_CEC) += cec/ + obj-$(CONFIG_VIDEO_SAMSUNG_S5P_CEC) += s5p-cec/ + obj-$(CONFIG_DVB_CXD2099) += cxd2099/ + obj-$(CONFIG_LIRC_STAGING) += lirc/ +diff --git a/drivers/staging/media/cec/Kconfig b/drivers/staging/media/cec/Kconfig +deleted file mode 100644 +index 6e12d41b1f86a7..00000000000000 +--- a/drivers/staging/media/cec/Kconfig ++++ /dev/null +@@ -1,12 +0,0 @@ +-config MEDIA_CEC +- bool "CEC API (EXPERIMENTAL)" +- depends on MEDIA_SUPPORT +- select MEDIA_CEC_EDID +- ---help--- +- Enable the CEC API. +- +-config MEDIA_CEC_DEBUG +- bool "CEC debugfs interface (EXPERIMENTAL)" +- depends on MEDIA_CEC && DEBUG_FS +- ---help--- +- Turns on the DebugFS interface for CEC devices. +diff --git a/drivers/staging/media/pulse8-cec/Kconfig b/drivers/staging/media/pulse8-cec/Kconfig +index c6aa2d1c9df0ad..6ffc407de62fbd 100644 +--- a/drivers/staging/media/pulse8-cec/Kconfig ++++ b/drivers/staging/media/pulse8-cec/Kconfig +@@ -1,6 +1,6 @@ + config USB_PULSE8_CEC + tristate "Pulse Eight HDMI CEC" +- depends on USB_ACM && MEDIA_CEC ++ depends on USB_ACM && MEDIA_CEC_SUPPORT + select SERIO + select SERIO_SERPORT + ---help--- +diff --git a/drivers/staging/media/s5p-cec/Kconfig b/drivers/staging/media/s5p-cec/Kconfig +index 0315fd7ad0f1bd..ddfd955da0d40d 100644 +--- a/drivers/staging/media/s5p-cec/Kconfig ++++ b/drivers/staging/media/s5p-cec/Kconfig +@@ -1,6 +1,6 @@ + config VIDEO_SAMSUNG_S5P_CEC + tristate "Samsung S5P CEC driver" +- depends on VIDEO_DEV && MEDIA_CEC && (PLAT_S5P || ARCH_EXYNOS || COMPILE_TEST) ++ depends on VIDEO_DEV && MEDIA_CEC_SUPPORT && (PLAT_S5P || ARCH_EXYNOS || COMPILE_TEST) + ---help--- + This is a driver for Samsung S5P HDMI CEC interface. It uses the + generic CEC framework interface. +diff --git a/drivers/staging/media/st-cec/Kconfig b/drivers/staging/media/st-cec/Kconfig +index 784d2c600aca10..c04283db58d6d1 100644 +--- a/drivers/staging/media/st-cec/Kconfig ++++ b/drivers/staging/media/st-cec/Kconfig +@@ -1,6 +1,6 @@ + config VIDEO_STI_HDMI_CEC + tristate "STMicroelectronics STiH4xx HDMI CEC driver" +- depends on VIDEO_DEV && MEDIA_CEC && (ARCH_STI || COMPILE_TEST) ++ depends on VIDEO_DEV && MEDIA_CEC_SUPPORT && (ARCH_STI || COMPILE_TEST) + ---help--- + This is a driver for STIH4xx HDMI CEC interface. It uses the + generic CEC framework interface. +diff --git a/include/media/cec.h b/include/media/cec.h +index fdb5d600e4bb98..717eaf552f3d0c 100644 +--- a/include/media/cec.h ++++ b/include/media/cec.h +@@ -196,7 +196,7 @@ static inline bool cec_is_sink(const struct cec_adapter *adap) + return adap->phys_addr == 0; + } + +-#if IS_ENABLED(CONFIG_MEDIA_CEC) ++#if IS_ENABLED(CONFIG_MEDIA_CEC_SUPPORT) + struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops, + void *priv, const char *name, u32 caps, u8 available_las, + struct device *parent); +diff --git a/include/linux/cec-funcs.h b/include/uapi/linux/cec-funcs.h +similarity index 99% +rename from include/linux/cec-funcs.h +rename to include/uapi/linux/cec-funcs.h +index 138bbf721e70ca..1a1de2169f4891 100644 +--- a/include/linux/cec-funcs.h ++++ b/include/uapi/linux/cec-funcs.h +@@ -33,12 +33,6 @@ + * SOFTWARE. + */ + +-/* +- * Note: this framework is still in staging and it is likely the API +- * will change before it goes out of staging. +- * +- * Once it is moved out of staging this header will move to uapi. +- */ + #ifndef _CEC_UAPI_FUNCS_H + #define _CEC_UAPI_FUNCS_H + +diff --git a/include/linux/cec.h b/include/uapi/linux/cec.h +similarity index 99% +rename from include/linux/cec.h +rename to include/uapi/linux/cec.h +index 9c87711c0e1c0b..f4ec0af67707aa 100644 +--- a/include/linux/cec.h ++++ b/include/uapi/linux/cec.h +@@ -33,12 +33,6 @@ + * SOFTWARE. + */ + +-/* +- * Note: this framework is still in staging and it is likely the API +- * will change before it goes out of staging. +- * +- * Once it is moved out of staging this header will move to uapi. +- */ + #ifndef _CEC_UAPI_H + #define _CEC_UAPI_H + diff --git a/projects/L4T/devices/Switch/patches/linux/0005-fix-libcec-build-2.patch b/projects/L4T/devices/Switch/patches/linux/0005-fix-libcec-build-2.patch new file mode 100644 index 0000000000..8ea7df04fc --- /dev/null +++ b/projects/L4T/devices/Switch/patches/linux/0005-fix-libcec-build-2.patch @@ -0,0 +1,12 @@ +diff -Naur linux-Switch-5.1.2/nvidia/drivers/video/tegra/Kconfig linux-Switch-5.1.2-2/nvidia/drivers/video/tegra/Kconfig +--- linux-Switch-5.1.2/nvidia/drivers/video/tegra/Kconfig 2024-01-29 05:57:16.331738434 +0100 ++++ linux-Switch-5.1.2-2/nvidia/drivers/video/tegra/Kconfig 2024-01-29 07:21:54.862883090 +0100 +@@ -231,7 +231,7 @@ + + config TEGRA_DP_BRANCH_STDP2550 + bool "Enable DP branch STDP2550/RTD2172N support." +- depends on TEGRA_DP && MEDIA_CEC ++ depends on TEGRA_DP && MEDIA_CEC_SUPPORT + default n + help + Say Y here to enable the DP branch MegaChips STDP2550 and Realtek diff --git a/projects/L4T/options b/projects/L4T/options index 236884bd0c..c63c5ceda3 100644 --- a/projects/L4T/options +++ b/projects/L4T/options @@ -108,7 +108,7 @@ LINUX="L4T" # CEC Support - #CEC_FRAMEWORK_SUPPORT="yes" + CEC_FRAMEWORK_SUPPORT="yes" # Set Distro Specific options if [ "${DISTRO}" = "LibreELEC" ]; then diff --git a/projects/L4T/packages/glibc/patches/fix_autoconf.patch b/projects/L4T/packages/glibc/patches/fix_autoconf.patch deleted file mode 100644 index 3981c38e33..0000000000 --- a/projects/L4T/packages/glibc/patches/fix_autoconf.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -Naur glibc-2.27/aclocal.m4 glibc-2.27-2/aclocal.m4 ---- glibc-2.27/aclocal.m4 2022-04-20 02:23:50.549365949 +0200 -+++ glibc-2.27-2/aclocal.m4 2022-04-20 02:26:23.179843270 +0200 -@@ -2,7 +2,7 @@ - dnl the internal functions defined and used by the main configure script - dnl match those expected by the fragments. When changing this version, - dnl install.texi also needs to be updated. --m4_define([GLIBC_AUTOCONF_VERSION], [2.69]) -+m4_define([GLIBC_AUTOCONF_VERSION], [2.71]) - m4_if(m4_defn([AC_AUTOCONF_VERSION]), GLIBC_AUTOCONF_VERSION, [], - [m4_fatal(m4_flatten( - Exactly version GLIBC_AUTOCONF_VERSION of Autoconf is required but you have diff --git a/projects/L4T/packages/libcec/package.mk b/projects/L4T/packages/libcec/package.mk deleted file mode 100644 index a97f713a67..0000000000 --- a/projects/L4T/packages/libcec/package.mk +++ /dev/null @@ -1,46 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv) -# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv) - -PKG_NAME="libcec" -PKG_VERSION="4.0.3" -PKG_SHA256="ef90d6e4cf9d5847c14d3ff21b71579e5110643f31e8574766d3fa6c89c6239c" -PKG_LICENSE="GPL" -PKG_SITE="http://libcec.pulse-eight.com/" -PKG_URL="https://github.com/Pulse-Eight/libcec/archive/libcec-${PKG_VERSION}.tar.gz" -PKG_DEPENDS_TARGET="toolchain systemd p8-platform swig:host" -PKG_LONGDESC="libCEC is an open-source dual licensed library designed for communicating with the Pulse-Eight USB - CEC Adaptor." - -PKG_CMAKE_OPTS_TARGET="-DBUILD_SHARED_LIBS=1 \ - -DCMAKE_INSTALL_LIBDIR:STRING=lib \ - -DCMAKE_INSTALL_LIBDIR_NOARCH:STRING=lib \ - -DSKIP_PYTHON_WRAPPER=1 \ - -DHAVE_IMX_API=0 \ - -DHAVE_AOCEC_API=0 -DHAVE_AMLOGIC_API=0 \ - -DHAVE_GIT_BIN=0 \ - -DHAVE_RPI_LIB=0" - -# libX11 and xrandr to read the sink's EDID, used to determine the PC's HDMI physical address -if [ "${DISPLAYSERVER}" = "x11" ]; then - PKG_DEPENDS_TARGET+=" libX11 libXrandr" -fi - -if [ "${CEC_FRAMEWORK_SUPPORT}" = "yes" ]; then - PKG_CMAKE_OPTS_TARGET+=" -DHAVE_LINUX_API=1" -else - PKG_CMAKE_OPTS_TARGET+=" -DHAVE_LINUX_API=0" -fi - -if [ ${PROJECT} = "L4T" ]; then - PKG_PATCH_DIRS="${PROJECT}" -fi - -post_makeinstall_target() { - # Remove the Python3 demo - useless for us - rm -f ${INSTALL}/usr/bin/pyCecClient - - PYTHON_DIR=${INSTALL}/usr/lib/${PKG_PYTHON_VERSION} - if [ -d ${PYTHON_DIR}/dist-packages ]; then - mv ${PYTHON_DIR}/dist-packages ${PYTHON_DIR}/site-packages - fi -}