0
0
mirror of https://github.com/libretro/Lakka-LibreELEC.git synced 2025-01-09 13:45:21 +00:00
Lakka-LibreELEC/packages/multimedia/ffmpeg/patches/L4T/0019-codecs-nvv4l2-align-enc-plane-width-per-format-plane.patch
GavinDarkglider 600e246a94 L4T/Ayn: upstream changes from 5.x
Lakka 5.x Switch changes (#1853)
Lakka v5.x switchroot 5.1.2 (#1871)
Fix Switch Issue's in upstream 5.x (#1888)
Minor Switch Changes (#1893)
Lakka v5.x switch 3 (#1895)
Lakka v5.x switch 4 (#1898)
L4T: Xorg-server: Fix build issue (#1924)
Switch: remove ra patch
Lakka v5.x switch 6 (#1926)
Cleanups, More LibreELEC Stuff, more permission fixes, Misc switch stuff. (#1930)
Switch: U-Boot: bump version to 2024-NX02 (#1946)

L4T/Ayn post-upstreaming fixes
- retroarch_joypad_autoconfig: remove spaces from file names
- retroarch: remove Switch specific patch merged upstream
- libXv: move to L4T packages folder (package removed in upstream)
- bring some packages from v5.x to L4T packages
- ffmpeg: remove vulkan
- remove stella core from Switch build (missing C++ headers)
- Ayn/Odin: use proper kernel arg to not hide kernel messages in console
- connman: add wpa_supplicant support back
2024-05-21 15:41:36 +02:00

84 lines
3.1 KiB
Diff

From c5751e2bb1faeb0fd8e4442461bbbcd9448c3960 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Wed, 29 Jun 2022 06:38:26 +0000
Subject: [PATCH 19/39] codecs: nvv4l2: align enc plane width per format/plane
Take two on creating a heuristic of the needed alignment.
Unlike in VIC/NVDEC, in encoding the conversion is from Pitch to Block linear.
That needs precise alignments for each plane, per format.
This supports way more resolutions than before, but still lacks support for non-standard ones.
For example, 854 width needs 32B alignment (instead of 64!) for yuv420 on main plane.
And the other 2 planes need 64B.
As usual, TRM is not helpful on that (only has 64/256B alignments for block/pitch)
and there's probably an algorithm on the drivers that causes that issue by aligning
sizes for NVENC without notifying user.
---
libavcodec/nvv4l2_enc.c | 38 ++++++++++++++++++++++++++++++++------
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/libavcodec/nvv4l2_enc.c b/libavcodec/nvv4l2_enc.c
index 7bd8e84227..6fc74472ef 100644
--- a/libavcodec/nvv4l2_enc.c
+++ b/libavcodec/nvv4l2_enc.c
@@ -646,6 +646,7 @@ int nvv4l2_encoder_put_frame(AVCodecContext *avctx, nvv4l2_ctx_t *ctx,
NvFrame *frame)
{
int ret;
+ int alignment;
struct v4l2_buffer v4l2_buf_op;
struct v4l2_plane queue_op_planes[NV_MAX_PLANES];
NvBuffer *buffer;
@@ -685,14 +686,39 @@ int nvv4l2_encoder_put_frame(AVCodecContext *avctx, nvv4l2_ctx_t *ctx,
}
}
+ /*
+ ** Due to NvMap/VIC stride conversion constrains, the transformation
+ ** must be aligned per format/plane. Otherwise the frame might be
+ ** produced as scrambled.
+ **
+ ** !TODO: Have a proper algorithm to calculate needed alignements.
+ */
+ switch (ctx->op_pixfmt) {
+ case V4L2_PIX_FMT_NV12M:
+ alignment = 16;
+ break;
+ case V4L2_PIX_FMT_YUV420M:
+ alignment = 64;
+ break;
+ case V4L2_PIX_FMT_YUV444M:
+ alignment = 32;
+ break;
+ case V4L2_PIX_FMT_P010M:
+ default:
+ alignment = 1;
+ break;
+ }
+
/* Import frame into output plane */
for (uint32_t i = 0; i < buffer->n_planes; i++) {
- /*
- ** Due to VIC constrains the transformation from Block Linear to Pitch
- ** must have aligned widths to 64B. Otherwise the frame might be
- ** produced as scrambled.
- */
- int aligned_plane_width = NVALIGN(ctx->op_planefmts[i].width, 64);
+ int aligned_plane_width = NVALIGN(ctx->op_planefmts[i].width, alignment);
+
+ /* If plane is reduced, use alignment of main plane */
+ if (ctx->op_planefmts[i].width == ctx->op_planefmts[0].width / 2)
+ aligned_plane_width = NVALIGN(ctx->op_planefmts[0].width, alignment) / 2;
+
+ av_log(avctx, AV_LOG_VERBOSE, "Plane %d: width %d -> %d\n",
+ i, ctx->op_planefmts[i].width, aligned_plane_width);
Raw2NvBuffer(frame->payload[i], i, aligned_plane_width,
ctx->op_planefmts[i].height, buffer->planes[i].fd);
--
2.25.1