Files
libva-v4l2-request-fourier/src/tiled_yuv.S
T
test0r c45fea96e3 fourier-local: stateless control modernization + HEVC strip
Compound patch carrying the fork's pre-Step-1 substrate, originally
authored by Jernej Škrabec / fourier on top of bootlin's a3c2476:

- src/h264.c + src/picture.c: V4L2_CID_MPEG_VIDEO_H264_* renamed to
  V4L2_CID_STATELESS_H264_*, struct shapes tracked to mainline
  (V4L2_CID_STATELESS_H264_DECODE_MODE/_START_CODE added to the
  passthrough shim).
- include/hevc-ctrls.h: redirect shim to <linux/v4l2-controls.h>
  (kernel-side HEVC controls now live in the canonical UAPI header).
- src/meson.build: src/h265.c / src/h265.h commented out — HEVC
  build path is excluded from this fork (RK3568 hantro G1/G2 has
  no HEVC, and the kernel-side HEVC controls have a separate
  rework in flight upstream).
- src/tiled_yuv.S: aarch64 stub for tiled_to_planar (assembly
  source was sunxi-cedrus armv7-only; aarch64 needs a stub to keep
  the build linking).
- include/h264-ctrls.h: removed (dead post-fourier — no source
  includes it; the passthrough shim's CID aliases live in the
  kernel header now).

Functionally equivalent to the prior fork master commits:
  c1f5108 V4L2_PIX_FMT_H264_SLICE rename
  4ccbfe9 Strip HEVC build path
  da9f2a5 include/h264-ctrls.h passthrough + CID aliases
  fc4bb10 src/h264.c track upstream UAPI shape
  13e9b64 src/h264.c drop num_slices field
  4d14ffb src/tiled_yuv.S aarch64 stub
  1b02c9b src/h264.c include utils.h

Folded into one commit during 2026-05-04 Step 1 reconciliation
(see ../phase0_evidence/2026-05-04/findings.md). Per-patch history
of the early fork commits preserved on the pre-step1 branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 09:40:14 +00:00

186 lines
3.7 KiB
ArmAsm

/*
* Copyright (C) 2014 Jens Kuske <jenskuske@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/*
* The Sunxi Video Engine outputs buffers in a specific format similar to NV12
* but with "tiles" of size 32x32. This code converts the data from this tiled
* format to two NV12 planes.
*/
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
#endif
#ifdef __arm__
.text
.syntax unified
.arch armv7-a
.fpu neon
.thumb
.macro thumb_function fname
.global \fname
#ifdef __ELF__
.hidden \fname
.type \fname, %function
#endif
.thumb_func
\fname:
.endm
.macro end_function fname
#ifdef __ELF__
.size \fname, .-\fname
#endif
.endm
SRC .req r0
DST .req r1
PITCH .req r2
CNT .req r3
TLINE .req r4
HEIGHT .req r5
REST .req r6
NTILES .req r7
TMPSRC .req r8
DST2 .req r9
TSIZE .req r12
NEXTLIN .req lr
thumb_function tiled_to_planar
push {r4, r5, r6, r7, r8, lr}
ldr HEIGHT, [sp, #24]
add NEXTLIN, r3, #31
lsrs NTILES, r3, #5
bic NEXTLIN, NEXTLIN, #31
and REST, r3, #31
lsl NEXTLIN, NEXTLIN, #5
subs PITCH, r2, r3
movs TLINE, #32
rsb NEXTLIN, NEXTLIN, #32
mov TSIZE, #1024
/* y loop */
1: cbz NTILES, 3f
mov CNT, NTILES
/* x loop complete tiles */
2: pld [SRC, TSIZE]
vld1.8 {d0 - d3}, [SRC :256], TSIZE
subs CNT, #1
vst1.8 {d0 - d3}, [DST]!
bne 2b
3: cbnz REST, 4f
/* fix up dest pointer if pitch != width */
7: add DST, PITCH
/* fix up src pointer at end of line */
subs TLINE, #1
itee ne
addne SRC, NEXTLIN
subeq SRC, #992
moveq TLINE, #32
subs HEIGHT, #1
bne 1b
pop {r4, r5, r6, r7, r8, pc}
/* partly copy last tile of line */
4: mov TMPSRC, SRC
tst REST, #16
beq 5f
vld1.8 {d0 - d1}, [TMPSRC :128]!
vst1.8 {d0 - d1}, [DST]!
5: add SRC, TSIZE
ands CNT, REST, #15
beq 7b
6: vld1.8 {d0[0]}, [TMPSRC]!
subs CNT, #1
vst1.8 {d0[0]}, [DST]!
bne 6b
b 7b
end_function tiled_to_planar
thumb_function tiled_deinterleave_to_planar
push {r4, r5, r6, r7, r8, r9, lr}
mov DST2, r2
ldr HEIGHT, [sp, #32]
ldr r4, [sp, #28]
add NEXTLIN, r4, #31
lsrs NTILES, r4, #5
bic NEXTLIN, NEXTLIN, #31
ubfx REST, r4, #1, #4
lsl NEXTLIN, NEXTLIN, #5
sub PITCH, r3, r4, lsr #1
movs TLINE, #32
rsb NEXTLIN, NEXTLIN, #32
mov TSIZE, #1024
/* y loop */
1: cbz NTILES, 3f
mov CNT, NTILES
/* x loop complete tiles */
2: pld [SRC, TSIZE]
vld2.8 {d0 - d3}, [SRC :256], TSIZE
subs CNT, #1
vst1.8 {d0 - d1}, [DST]!
vst1.8 {d2 - d3}, [DST2]!
bne 2b
3: cbnz REST, 4f
/* fix up dest pointer if pitch != width */
7: add DST, PITCH
add DST2, PITCH
/* fix up src pointer at end of line */
subs TLINE, #1
itee ne
addne SRC, NEXTLIN
subeq SRC, #992
moveq TLINE, #32
subs HEIGHT, #1
bne 1b
pop {r4, r5, r6, r7, r8, r9, pc}
/* partly copy last tile of line */
4: mov TMPSRC, SRC
tst REST, #8
beq 5f
vld2.8 {d0 - d1}, [TMPSRC :128]!
vst1.8 {d0}, [DST]!
vst1.8 {d1}, [DST2]!
5: add SRC, TSIZE
ands CNT, REST, #7
beq 7b
6: vld2.8 {d0[0], d1[0]}, [TMPSRC]!
subs CNT, #1
vst1.8 {d0[0]}, [DST]!
vst1.8 {d1[0]}, [DST2]!
bne 6b
b 7b
end_function tiled_deinterleave_to_planar
#endif