diff options
author | boogie | 2023-04-03 17:14:43 +0200 |
---|---|---|
committer | boogie | 2023-04-03 17:14:43 +0200 |
commit | 9c9e5a3a90ae8d300832feb40418deaaef9cd101 (patch) | |
tree | 2ce1019362d04923b9919549c4dff2251765f253 /0002-rkmpp-4.patch | |
parent | be646612f29932225d49faacb2ecc5cd03873659 (diff) | |
download | aur-9c9e5a3a90ae8d300832feb40418deaaef9cd101.tar.gz |
add av1 support and fix format detection
Diffstat (limited to '0002-rkmpp-4.patch')
-rw-r--r-- | 0002-rkmpp-4.patch | 231 |
1 files changed, 186 insertions, 45 deletions
diff --git a/0002-rkmpp-4.patch b/0002-rkmpp-4.patch index 5c8734c1535a..9446714d30cc 100644 --- a/0002-rkmpp-4.patch +++ b/0002-rkmpp-4.patch @@ -1,7 +1,7 @@ From 9590c16111eb27ba8cb1b5c46ea57dc9052e82ed Mon Sep 17 00:00:00 2001 From: Jeffy Chen <jeffy.chen@rock-chips.com> Date: Wed, 4 Sep 2019 17:24:37 +0800 -Subject: [PATCH 01/16] avcodec/rkmppdec: Clear eos flag after reset +Subject: [PATCH 01/18] avcodec/rkmppdec: Clear eos flag after reset Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> --- @@ -21,13 +21,13 @@ index a60962dc86..3654437268 100644 av_log(avctx, AV_LOG_ERROR, "Failed to reset MPI (code = %d)\n", ret); } -- -2.39.0 +2.40.0 From 43fc7807c58999a57d4c407dcda0d3d2fac7405b Mon Sep 17 00:00:00 2001 From: Jeffy Chen <jeffy.chen@rock-chips.com> Date: Wed, 4 Sep 2019 17:27:46 +0800 -Subject: [PATCH 02/16] avcodec/rkmppdec: Compatible with old reordered_opaque +Subject: [PATCH 02/18] avcodec/rkmppdec: Compatible with old reordered_opaque and pkt_pts Some users might still using these deprecated APIs. @@ -65,13 +65,13 @@ index 3654437268..6256abe63c 100644 frame->color_primaries = mpp_frame_get_color_primaries(mppframe); frame->color_trc = mpp_frame_get_color_trc(mppframe); -- -2.39.0 +2.40.0 From 6b5e686cea5638fe6c2c92eeaaabe16d9a72121b Mon Sep 17 00:00:00 2001 From: Jeffy Chen <jeffy.chen@rock-chips.com> Date: Wed, 19 May 2021 09:55:03 +0800 -Subject: [PATCH 03/16] rkmppdec: Remove frame buffer limit +Subject: [PATCH 03/18] rkmppdec: Remove frame buffer limit It would hang when reaching the limit. @@ -107,13 +107,13 @@ index 6256abe63c..96696e84dc 100644 av_log(avctx, AV_LOG_DEBUG, "RKMPP decoder initialized successfully.\n"); -- -2.39.0 +2.40.0 From 668ec8c36d1112c5c4939ddc3d3b7cff487cedc1 Mon Sep 17 00:00:00 2001 From: Jeffy Chen <jeffy.chen@rock-chips.com> Date: Thu, 20 May 2021 10:19:15 +0800 -Subject: [PATCH 04/16] avcodec/rkmppdec: Rework decoding flow +Subject: [PATCH 04/18] avcodec/rkmppdec: Rework decoding flow Stop using the deprecated MPP_DEC_GET_STREAM_COUNT API. @@ -791,13 +791,13 @@ index 96696e84dc..7c28378120 100644 static const AVCodecHWConfigInternal *const rkmpp_hw_configs[] = { -- -2.39.0 +2.40.0 From 3f94c029c3eeca764c63e32435e8ca8241a87dfc Mon Sep 17 00:00:00 2001 From: Jeffy Chen <jeffy.chen@rock-chips.com> Date: Fri, 21 May 2021 04:23:36 +0800 -Subject: [PATCH 05/16] HACK: avcodec/rkmppdec: Force aligning coded width and +Subject: [PATCH 05/18] HACK: avcodec/rkmppdec: Force aligning coded width and height to 64 The chromium would try to align planes' width and height to 32, which @@ -827,13 +827,13 @@ index 7c28378120..bae3ca6cb5 100644 decoder->mpi->control(decoder->ctx, MPP_DEC_SET_INFO_CHANGE_READY, NULL); -- -2.39.0 +2.40.0 From 804808de6c6af583b71526ff9e11196e1515e542 Mon Sep 17 00:00:00 2001 From: Jeffy Chen <jeffy.chen@rock-chips.com> Date: Thu, 20 May 2021 10:20:17 +0800 -Subject: [PATCH 06/16] HACK: avcodec/rkmppdec: Support outputing YUV420P +Subject: [PATCH 06/18] HACK: avcodec/rkmppdec: Support outputing YUV420P Lots of users support YUV420P format rather than DRM_PRIME. @@ -1061,13 +1061,13 @@ index bae3ca6cb5..c621e687e0 100644 .hw_configs = rkmpp_hw_configs, \ .bsfs = BSFS, \ -- -2.39.0 +2.40.0 From ad6f4d3518eea4795f457b81d44d27da943be982 Mon Sep 17 00:00:00 2001 From: Jeffy Chen <jeffy.chen@rock-chips.com> Date: Mon, 27 Sep 2021 10:20:54 +0800 -Subject: [PATCH 07/16] avcodec/rkmppdec: Support logging fps +Subject: [PATCH 07/18] avcodec/rkmppdec: Support logging fps Set env FFMPEG_RKMPP_LOG_FPS=1 to enable it. @@ -1183,13 +1183,13 @@ index c621e687e0..82834c27a6 100644 av_packet_unref(&decoder->packet); } -- -2.39.0 +2.40.0 -From 8b7cfe72359520a7f1cae3b3ce935a2ea549f705 Mon Sep 17 00:00:00 2001 -From: boogie <boogiepop@gmx.com> +From 64a938f131b053a736d1158069300813cf2d16cc Mon Sep 17 00:00:00 2001 +From: Jeffy Chen <jeffy.chen@rock-chips.com> Date: Thu, 5 Jan 2023 22:41:48 +0100 -Subject: [PATCH 08/16] HACK: libavcodec & rkmppdec: Add +Subject: [PATCH 08/18] HACK: libavcodec & rkmppdec: Add FF_CODEC_CAP_CONTIGUOUS_BUFFERS Add FF_CODEC_CAP_CONTIGUOUS_BUFFERS to alloc contiguous buffers. @@ -1307,13 +1307,13 @@ index 82834c27a6..a05c77977d 100644 AV_PIX_FMT_YUV420P, \ AV_PIX_FMT_NONE}, \ -- -2.39.0 +2.40.0 -From d1ab43ce9ccb0b832dc1bd620785a1a455e15bed Mon Sep 17 00:00:00 2001 +From ff895c90cca06ec9e0235d5aa06c25eaeb4b9f3f Mon Sep 17 00:00:00 2001 From: Jeffy Chen <jeffy.chen@rock-chips.com> Date: Mon, 13 Dec 2021 15:44:43 +0800 -Subject: [PATCH 09/16] HACK: avcodec/rkmppdec: Define DRM_FORMAT_NV12_10 +Subject: [PATCH 09/18] HACK: avcodec/rkmppdec: Define DRM_FORMAT_NV12_10 DRM_FORMAT_NV12_10 is a downstream custom format for Rockchip. @@ -1348,13 +1348,13 @@ index a05c77977d..2aa3ee2a30 100644 } } -- -2.39.0 +2.40.0 -From 486ff6b9a813c48bca125b04a33088c5b3bf512d Mon Sep 17 00:00:00 2001 +From c36fb133a52a3b80b682b97b37b9e754de62eca0 Mon Sep 17 00:00:00 2001 From: Jeffy Chen <jeffy.chen@rock-chips.com> Date: Wed, 15 Dec 2021 15:34:48 +0800 -Subject: [PATCH 10/16] avcodec/rkmppdec: Support NV16 +Subject: [PATCH 10/18] avcodec/rkmppdec: Support NV16 The MPP might output NV16 format. @@ -1407,13 +1407,13 @@ index 2aa3ee2a30..82288cad03 100644 hwframes->height = avctx->height; ret = av_hwframe_ctx_init(decoder->frames_ref); -- -2.39.0 +2.40.0 -From 7bf50d04f27c963a1bac402beb04f8f13a3773a4 Mon Sep 17 00:00:00 2001 +From 31cbeac7974485c9bbf55d155ebc742f87e98f11 Mon Sep 17 00:00:00 2001 From: Jeffy Chen <jeffy.chen@rock-chips.com> Date: Wed, 23 Mar 2022 14:20:16 +0800 -Subject: [PATCH 11/16] avcodec/rkmppdec: Support sync mode +Subject: [PATCH 11/18] avcodec/rkmppdec: Support sync mode Some people just don't know how to handle async APIs :( @@ -1465,13 +1465,13 @@ index 82288cad03..c8b400e910 100644 } } -- -2.39.0 +2.40.0 -From 8725010e4431bc5f8933e0389b195ba7f8a8fa46 Mon Sep 17 00:00:00 2001 -From: boogie <boogiepop@gmx.com> +From 8eb641d7f655691086e9e1fa0a6d116be9af3e44 Mon Sep 17 00:00:00 2001 +From: Jeffy Chen <jeffy.chen@rock-chips.com> Date: Thu, 5 Jan 2023 23:04:45 +0100 -Subject: [PATCH 12/16] avcodec/rkmppdec: Add H263/MPEG1/MPEG2/MPEG4 +Subject: [PATCH 12/18] avcodec/rkmppdec: Add H263/MPEG1/MPEG2/MPEG4 Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> --- @@ -1612,13 +1612,13 @@ index c8b400e910..79baab932d 100644 +RKMPP_DEC(mpeg2, AV_CODEC_ID_MPEG2VIDEO, NULL) +RKMPP_DEC(mpeg4, AV_CODEC_ID_MPEG4, "mpeg4_unpack_bframes") -- -2.39.0 +2.40.0 -From a1795f4a3ea85a4b499765a66427db8d39c844da Mon Sep 17 00:00:00 2001 -From: boogie <boogiepop@gmx.com> +From fadc27c2b4bfddb869c1df32d2e6fe7ecb4cb3e8 Mon Sep 17 00:00:00 2001 +From: Jeffy Chen <jeffy.chen@rock-chips.com> Date: Fri, 6 Jan 2023 20:39:23 +0100 -Subject: [PATCH 13/16] allow nv15 and allow probing +Subject: [PATCH 13/18] allow nv15 and allow probing --- libavcodec/rkmppdec.c | 4 ++-- @@ -1647,13 +1647,13 @@ index 79baab932d..93c426eeb3 100644 .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_DRM_PRIME, \ AV_PIX_FMT_YUV420P, \ -- -2.39.0 +2.40.0 -From 73f8dc251ae7111b2f8ce9c4084071e157765e33 Mon Sep 17 00:00:00 2001 +From c1684a12173449e5d0792a2a6fe9b9fabed9aa21 Mon Sep 17 00:00:00 2001 From: boogie <boogiepop@gmx.com> Date: Fri, 6 Jan 2023 21:36:04 +0100 -Subject: [PATCH 14/16] priotrize the rkmpp variants first +Subject: [PATCH 14/18] priotrize the rkmpp variants first --- libavcodec/allcodecs.c | 16 ++++++++-------- @@ -1732,13 +1732,13 @@ index 5b2d8abe80..409e7f33e4 100644 extern AVCodec ff_vqa_decoder; extern AVCodec ff_webp_decoder; -- -2.39.0 +2.40.0 -From 15cc4a4c861e6c0cb527e023332d875a75b6b732 Mon Sep 17 00:00:00 2001 -From: boogie <boogiepop@gmx.com> +From 76ec717e3fa8d21101cb9442c5a7c658a0f08f27 Mon Sep 17 00:00:00 2001 +From: icecream95 <the.real.icecream95@gmail.com> Date: Fri, 13 Jan 2023 22:27:01 +0100 -Subject: [PATCH 15/16] rkmpp: interface with kernel directly for rga and ditch +Subject: [PATCH 15/18] rkmpp: interface with kernel directly for rga and ditch librga credit goes to icecream95: https://gitlab.com/-/snippets/2460396 @@ -2728,13 +2728,13 @@ index 93c426eeb3..325150f483 100644 if (ret < 0) goto out; -- -2.39.0 +2.40.0 -From 44ccb8a4f398dbb05c2bd2fd9a0dcd56ca8ceb54 Mon Sep 17 00:00:00 2001 +From 3da5435d3ae03dc59175f966ef904645537aa8ae Mon Sep 17 00:00:00 2001 From: boogie <boogiepop@gmx.com> Date: Tue, 17 Jan 2023 01:02:19 +0100 -Subject: [PATCH 16/16] ugliest hack: vp8&9 color space workaround +Subject: [PATCH 16/18] ugliest hack: vp8&9 color space workaround --- libavcodec/rkmppdec.c | 15 +++++++++++++++ @@ -2767,5 +2767,146 @@ index 325150f483..ad9208f0e6 100644 frame->interlaced_frame = ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_DEINTERLACED); frame->top_field_first = ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_TOP_FIRST); -- -2.39.0 +2.40.0 + + +From 07f976d610833f6198ab12af514e945108d23708 Mon Sep 17 00:00:00 2001 +From: Jeffy Chen <jeffy.chen@rock-chips.com> +Date: Tue, 17 Jan 2023 18:31:57 +0800 +Subject: [PATCH 17/18] rkmppdec: AV1 support + +--- + configure | 1 + + libavcodec/Makefile | 2 ++ + libavcodec/allcodecs.c | 1 + + libavcodec/rkmppdec.c | 14 ++------------ + 4 files changed, 6 insertions(+), 12 deletions(-) + +diff --git a/configure b/configure +index 6e72375e09..6926a58f95 100755 +--- a/configure ++++ b/configure +@@ -3072,6 +3072,7 @@ nvenc_encoder_deps="nvenc" + aac_mf_encoder_deps="mediafoundation" + ac3_mf_encoder_deps="mediafoundation" + av1_cuvid_decoder_deps="cuvid CUVIDAV1PICPARAMS" ++av1_rkmpp_decoder_deps="rkmpp" + h263_v4l2m2m_decoder_deps="v4l2_m2m h263_v4l2_m2m" + h263_v4l2m2m_encoder_deps="v4l2_m2m h263_v4l2_m2m" + h263_rkmpp_decoder_deps="rkmpp" +diff --git a/libavcodec/Makefile b/libavcodec/Makefile +index 345b6a5816..004a00c761 100644 +--- a/libavcodec/Makefile ++++ b/libavcodec/Makefile +@@ -60,6 +60,8 @@ OBJS = ac3_parser.o \ + xiph.o \ + + # subsystems ++OBJS-$(CONFIG_AV1_RKMPP_DECODER) += rkmppdec.o ++ + OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o + OBJS-$(CONFIG_AC3DSP) += ac3dsp.o ac3.o ac3tab.o + OBJS-$(CONFIG_ADTS_HEADER) += adts_header.o mpeg4audio.o +diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c +index 409e7f33e4..dc9104fb75 100644 +--- a/libavcodec/allcodecs.c ++++ b/libavcodec/allcodecs.c +@@ -29,6 +29,7 @@ + #include "avcodec.h" + #include "version.h" + ++extern AVCodec ff_av1_rkmpp_decoder; + extern AVCodec ff_a64multi_encoder; + extern AVCodec ff_a64multi5_encoder; + extern AVCodec ff_aasc_decoder; +diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c +index ad9208f0e6..452c89a590 100644 +--- a/libavcodec/rkmppdec.c ++++ b/libavcodec/rkmppdec.c +@@ -95,6 +95,7 @@ static MppCodingType rkmpp_get_codingtype(AVCodecContext *avctx) + case AV_CODEC_ID_H263: return MPP_VIDEO_CodingH263; + case AV_CODEC_ID_H264: return MPP_VIDEO_CodingAVC; + case AV_CODEC_ID_HEVC: return MPP_VIDEO_CodingHEVC; ++ case AV_CODEC_ID_AV1: return MPP_VIDEO_CodingAV1; + case AV_CODEC_ID_VP8: return MPP_VIDEO_CodingVP8; + case AV_CODEC_ID_VP9: return MPP_VIDEO_CodingVP9; + case AV_CODEC_ID_MPEG1VIDEO: /* fallthrough */ +@@ -186,20 +187,8 @@ static int rkmpp_prepare_decoder(AVCodecContext *avctx) + { + RKMPPDecodeContext *rk_context = avctx->priv_data; + RKMPPDecoder *decoder = (RKMPPDecoder *)rk_context->decoder_ref->data; +- MppPacket packet; + int ret; + +- // send extra data +- if (avctx->extradata_size) { +- ret = mpp_packet_init(&packet, avctx->extradata, avctx->extradata_size); +- if (ret < 0) +- return AVERROR_UNKNOWN; +- ret = decoder->mpi->decode_put_packet(decoder->ctx, packet); +- mpp_packet_deinit(&packet); +- if (ret < 0) +- return AVERROR_UNKNOWN; +- } +- + if (getenv("FFMPEG_RKMPP_SYNC")) { + // wait for decode result after feeding any packets + decoder->sync = 1; +@@ -1000,6 +989,7 @@ static const AVCodecHWConfigInternal *const rkmpp_hw_configs[] = { + RKMPP_DEC(h263, AV_CODEC_ID_H263, NULL) + RKMPP_DEC(h264, AV_CODEC_ID_H264, "h264_mp4toannexb") + RKMPP_DEC(hevc, AV_CODEC_ID_HEVC, "hevc_mp4toannexb") ++RKMPP_DEC(av1, AV_CODEC_ID_AV1, NULL) + RKMPP_DEC(vp8, AV_CODEC_ID_VP8, NULL) + RKMPP_DEC(vp9, AV_CODEC_ID_VP9, NULL) + RKMPP_DEC(mpeg1, AV_CODEC_ID_MPEG1VIDEO, NULL) +-- +2.40.0 + + +From f37ea966915150e661b805208c855d2fc14e1a18 Mon Sep 17 00:00:00 2001 +From: Jeffy Chen <jeffy.chen@rock-chips.com> +Date: Mon, 27 Mar 2023 17:44:09 +0800 +Subject: [PATCH 18/18] rkmppdec: Ignore special MPP format masks + +We should use the basic format in format conversion. + +Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> +--- + libavcodec/rkmppdec.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c +index 452c89a590..735478da9b 100644 +--- a/libavcodec/rkmppdec.c ++++ b/libavcodec/rkmppdec.c +@@ -107,7 +107,7 @@ static MppCodingType rkmpp_get_codingtype(AVCodecContext *avctx) + + static uint32_t rkmpp_get_frameformat(MppFrameFormat mppformat) + { +- switch (mppformat) { ++ switch (mppformat & MPP_FRAME_FMT_MASK) { + case MPP_FMT_YUV420SP: return DRM_FORMAT_NV12; + case MPP_FMT_YUV420SP_10BIT: return DRM_FORMAT_NV12_10; + case MPP_FMT_YUV422SP: return DRM_FORMAT_NV16; +@@ -117,7 +117,7 @@ static uint32_t rkmpp_get_frameformat(MppFrameFormat mppformat) + + static uint32_t rkmpp_get_avformat(MppFrameFormat mppformat) + { +- switch (mppformat) { ++ switch (mppformat & MPP_FRAME_FMT_MASK) { + case MPP_FMT_YUV420SP: return AV_PIX_FMT_NV12; + case MPP_FMT_YUV420SP_10BIT: return AV_PIX_FMT_NONE; + case MPP_FMT_YUV422SP: return AV_PIX_FMT_NV16; +@@ -127,7 +127,7 @@ static uint32_t rkmpp_get_avformat(MppFrameFormat mppformat) + + static uint32_t rkmpp_get_rgaformat(MppFrameFormat mppformat) + { +- switch (mppformat) { ++ switch (mppformat & MPP_FRAME_FMT_MASK) { + case MPP_FMT_YUV420SP: return RGA_FORMAT_YCbCr_420_SP; + case MPP_FMT_YUV420SP_10BIT: return RGA_FORMAT_YCbCr_420_SP_10B; + case MPP_FMT_YUV422SP: return RGA_FORMAT_YCbCr_422_SP; +-- +2.40.0 |