/*
* Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
* Copyright (c) 2013 Janne Grunau <janne-libav@jannau.net>
*
* This file is part of FFmpeg.
*
* FFmpeg 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.
*
* FFmpeg 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 FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config_components.h"
#include "libavutil/aarch64/asm.S"
/* chroma_mc8(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y) */
.macro h264_chroma_mc8 type, codec=h264
function ff_\type\()_\codec\()_chroma_mc8_neon, export=1
.ifc \type,avg
mov x8, x0
.endif
prfm pldl1strm, [x1]
prfm pldl1strm, [x1, x2]
.ifc \codec,rv40
movrel x6, rv40bias
lsr w9, w5, #1
lsr w10, w4, #1
lsl w9, w9, #3
lsl w10, w10, #1
add w9, w9, w10
add x6, x6, w9, uxtw
ld1r {v22.8 h}, [x6]
.endif
.ifc \codec,vc1
movi v22.8 h, #28
.endif
mul w7, w4, w5
lsl w14, w5, #3
lsl w13, w4, #3
cmp w7, #0
sub w6, w14, w7
sub w12, w13, w7
sub w4, w7, w13
sub w4, w4, w14
add w4, w4, #64
b.eq 2 f
dup v0.8 b, w4
dup v1.8 b, w12
ld1 {v4.8 b, v5.8 b}, [x1], x2
dup v2.8 b, w6
dup v3.8 b, w7
ext v5.8 b, v4.8 b, v5.8 b, #1
1 : ld1 {v6.8 b, v7.8 b}, [x1], x2
umull v16.8 h, v4.8 b, v0.8 b
umlal v16.8 h, v5.8 b, v1.8 b
ext v7.8 b, v6.8 b, v7.8 b, #1
ld1 {v4.8 b, v5.8 b}, [x1], x2
umlal v16.8 h, v6.8 b, v2.8 b
prfm pldl1strm, [x1]
ext v5.8 b, v4.8 b, v5.8 b, #1
umlal v16.8 h, v7.8 b, v3.8 b
umull v17.8 h, v6.8 b, v0.8 b
subs w3, w3, #2
umlal v17.8 h, v7.8 b, v1.8 b
umlal v17.8 h, v4.8 b, v2.8 b
umlal v17.8 h, v5.8 b, v3.8 b
prfm pldl1strm, [x1, x2]
.ifc \codec,h264
rshrn v16.8 b, v16.8 h, #6
rshrn v17.8 b, v17.8 h, #6
.else
add v16.8 h, v16.8 h, v22.8 h
add v17.8 h, v17.8 h, v22.8 h
shrn v16.8 b, v16.8 h, #6
shrn v17.8 b, v17.8 h, #6
.endif
.ifc \type,avg
ld1 {v20.8 b}, [x8], x2
ld1 {v21.8 b}, [x8], x2
urhadd v16.8 b, v16.8 b, v20.8 b
urhadd v17.8 b, v17.8 b, v21.8 b
.endif
st1 {v16.8 b}, [x0], x2
st1 {v17.8 b}, [x0], x2
b.gt 1 b
ret
2 : adds w12, w12, w6
dup v0.8 b, w4
b.eq 5 f
tst w6, w6
dup v1.8 b, w12
b.eq 4 f
ld1 {v4.8 b}, [x1], x2
3 : ld1 {v6.8 b}, [x1], x2
umull v16.8 h, v4.8 b, v0.8 b
umlal v16.8 h, v6.8 b, v1.8 b
ld1 {v4.8 b}, [x1], x2
umull v17.8 h, v6.8 b, v0.8 b
umlal v17.8 h, v4.8 b, v1.8 b
prfm pldl1strm, [x1]
.ifc \codec,h264
rshrn v16.8 b, v16.8 h, #6
rshrn v17.8 b, v17.8 h, #6
.else
add v16.8 h, v16.8 h, v22.8 h
add v17.8 h, v17.8 h, v22.8 h
shrn v16.8 b, v16.8 h, #6
shrn v17.8 b, v17.8 h, #6
.endif
prfm pldl1strm, [x1, x2]
.ifc \type,avg
ld1 {v20.8 b}, [x8], x2
ld1 {v21.8 b}, [x8], x2
urhadd v16.8 b, v16.8 b, v20.8 b
urhadd v17.8 b, v17.8 b, v21.8 b
.endif
subs w3, w3, #2
st1 {v16.8 b}, [x0], x2
st1 {v17.8 b}, [x0], x2
b.gt 3 b
ret
4 : ld1 {v4.8 b, v5.8 b}, [x1], x2
ld1 {v6.8 b, v7.8 b}, [x1], x2
ext v5.8 b, v4.8 b, v5.8 b, #1
ext v7.8 b, v6.8 b, v7.8 b, #1
prfm pldl1strm, [x1]
subs w3, w3, #2
umull v16.8 h, v4.8 b, v0.8 b
umlal v16.8 h, v5.8 b, v1.8 b
umull v17.8 h, v6.8 b, v0.8 b
umlal v17.8 h, v7.8 b, v1.8 b
prfm pldl1strm, [x1, x2]
.ifc \codec,h264
rshrn v16.8 b, v16.8 h, #6
rshrn v17.8 b, v17.8 h, #6
.else
add v16.8 h, v16.8 h, v22.8 h
add v17.8 h, v17.8 h, v22.8 h
shrn v16.8 b, v16.8 h, #6
shrn v17.8 b, v17.8 h, #6
.endif
.ifc \type,avg
ld1 {v20.8 b}, [x8], x2
ld1 {v21.8 b}, [x8], x2
urhadd v16.8 b, v16.8 b, v20.8 b
urhadd v17.8 b, v17.8 b, v21.8 b
.endif
st1 {v16.8 b}, [x0], x2
st1 {v17.8 b}, [x0], x2
b.gt 4 b
ret
5 : ld1 {v4.8 b}, [x1], x2
ld1 {v5.8 b}, [x1], x2
prfm pldl1strm, [x1]
subs w3, w3, #2
umull v16.8 h, v4.8 b, v0.8 b
umull v17.8 h, v5.8 b, v0.8 b
prfm pldl1strm, [x1, x2]
.ifc \codec,h264
rshrn v16.8 b, v16.8 h, #6
rshrn v17.8 b, v17.8 h, #6
.else
add v16.8 h, v16.8 h, v22.8 h
add v17.8 h, v17.8 h, v22.8 h
shrn v16.8 b, v16.8 h, #6
shrn v17.8 b, v17.8 h, #6
.endif
.ifc \type,avg
ld1 {v20.8 b}, [x8], x2
ld1 {v21.8 b}, [x8], x2
urhadd v16.8 b, v16.8 b, v20.8 b
urhadd v17.8 b, v17.8 b, v21.8 b
.endif
st1 {v16.8 b}, [x0], x2
st1 {v17.8 b}, [x0], x2
b.gt 5 b
ret
endfunc
.endm
/* chroma_mc4(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y) */
.macro h264_chroma_mc4 type, codec=h264
function ff_\type\()_\codec\()_chroma_mc4_neon, export=1
.ifc \type,avg
mov x8, x0
.endif
prfm pldl1strm, [x1]
prfm pldl1strm, [x1, x2]
.ifc \codec,rv40
movrel x6, rv40bias
lsr w9, w5, #1
lsr w10, w4, #1
lsl w9, w9, #3
lsl w10, w10, #1
add w9, w9, w10
add x6, x6, w9, uxtw
ld1r {v22.8 h}, [x6]
.endif
.ifc \codec,vc1
movi v22.8 h, #28
.endif
mul w7, w4, w5
lsl w14, w5, #3
lsl w13, w4, #3
cmp w7, #0
sub w6, w14, w7
sub w12, w13, w7
sub w4, w7, w13
sub w4, w4, w14
add w4, w4, #64
b.eq 2 f
dup v24.8 b, w4
dup v25.8 b, w12
ld1 {v4.8 b}, [x1], x2
dup v26.8 b, w6
dup v27.8 b, w7
ext v5.8 b, v4.8 b, v5.8 b, #1
trn1 v0.2 s, v24.2 s, v25.2 s
trn1 v2.2 s, v26.2 s, v27.2 s
trn1 v4.2 s, v4.2 s, v5.2 s
1 : ld1 {v6.8 b}, [x1], x2
ext v7.8 b, v6.8 b, v7.8 b, #1
trn1 v6.2 s, v6.2 s, v7.2 s
umull v18.8 h, v4.8 b, v0.8 b
umlal v18.8 h, v6.8 b, v2.8 b
ld1 {v4.8 b}, [x1], x2
ext v5.8 b, v4.8 b, v5.8 b, #1
trn1 v4.2 s, v4.2 s, v5.2 s
prfm pldl1strm, [x1]
umull v19.8 h, v6.8 b, v0.8 b
umlal v19.8 h, v4.8 b, v2.8 b
trn1 v30.2 d, v18.2 d, v19.2 d
trn2 v31.2 d, v18.2 d, v19.2 d
add v18.8 h, v30.8 h, v31.8 h
.ifc \codec,h264
rshrn v16.8 b, v18.8 h, #6
.else
add v18.8 h, v18.8 h, v22.8 h
shrn v16.8 b, v18.8 h, #6
.endif
subs w3, w3, #2
prfm pldl1strm, [x1, x2]
.ifc \type,avg
ld1 {v20.s}[0 ], [x8], x2
ld1 {v20.s}[1 ], [x8], x2
urhadd v16.8 b, v16.8 b, v20.8 b
.endif
st1 {v16.s}[0 ], [x0], x2
st1 {v16.s}[1 ], [x0], x2
b.gt 1 b
ret
2 : adds w12, w12, w6
dup v30.8 b, w4
b.eq 5 f
tst w6, w6
dup v31.8 b, w12
trn1 v0.2 s, v30.2 s, v31.2 s
trn2 v1.2 s, v30.2 s, v31.2 s
b.eq 4 f
ext v1.8 b, v0.8 b, v1.8 b, #4
ld1 {v4.s}[0 ], [x1], x2
3 : ld1 {v4.s}[1 ], [x1], x2
umull v18.8 h, v4.8 b, v0.8 b
ld1 {v4.s}[0 ], [x1], x2
umull v19.8 h, v4.8 b, v1.8 b
trn1 v30.2 d, v18.2 d, v19.2 d
trn2 v31.2 d, v18.2 d, v19.2 d
add v18.8 h, v30.8 h, v31.8 h
prfm pldl1strm, [x1]
.ifc \codec,h264
rshrn v16.8 b, v18.8 h, #6
.else
add v18.8 h, v18.8 h, v22.8 h
shrn v16.8 b, v18.8 h, #6
.endif
.ifc \type,avg
ld1 {v20.s}[0 ], [x8], x2
ld1 {v20.s}[1 ], [x8], x2
urhadd v16.8 b, v16.8 b, v20.8 b
.endif
subs w3, w3, #2
prfm pldl1strm, [x1, x2]
st1 {v16.s}[0 ], [x0], x2
st1 {v16.s}[1 ], [x0], x2
b.gt 3 b
ret
4 : ld1 {v4.8 b}, [x1], x2
ld1 {v6.8 b}, [x1], x2
ext v5.8 b, v4.8 b, v5.8 b, #1
ext v7.8 b, v6.8 b, v7.8 b, #1
trn1 v4.2 s, v4.2 s, v5.2 s
trn1 v6.2 s, v6.2 s, v7.2 s
umull v18.8 h, v4.8 b, v0.8 b
umull v19.8 h, v6.8 b, v0.8 b
subs w3, w3, #2
trn1 v30.2 d, v18.2 d, v19.2 d
trn2 v31.2 d, v18.2 d, v19.2 d
add v18.8 h, v30.8 h, v31.8 h
prfm pldl1strm, [x1]
.ifc \codec,h264
rshrn v16.8 b, v18.8 h, #6
.else
add v18.8 h, v18.8 h, v22.8 h
shrn v16.8 b, v18.8 h, #6
.endif
.ifc \type,avg
ld1 {v20.s}[0 ], [x8], x2
ld1 {v20.s}[1 ], [x8], x2
urhadd v16.8 b, v16.8 b, v20.8 b
.endif
prfm pldl1strm, [x1]
st1 {v16.s}[0 ], [x0], x2
st1 {v16.s}[1 ], [x0], x2
b.gt 4 b
ret
5 : ld1 {v4.s}[0 ], [x1], x2
ld1 {v4.s}[1 ], [x1], x2
umull v18.8 h, v4.8 b, v30.8 b
subs w3, w3, #2
prfm pldl1strm, [x1]
.ifc \codec,h264
rshrn v16.8 b, v18.8 h, #6
.else
add v18.8 h, v18.8 h, v22.8 h
shrn v16.8 b, v18.8 h, #6
.endif
.ifc \type,avg
ld1 {v20.s}[0 ], [x8], x2
ld1 {v20.s}[1 ], [x8], x2
urhadd v16.8 b, v16.8 b, v20.8 b
.endif
prfm pldl1strm, [x1]
st1 {v16.s}[0 ], [x0], x2
st1 {v16.s}[1 ], [x0], x2
b.gt 5 b
ret
endfunc
.endm
.macro h264_chroma_mc2 type
function ff_\type\()_h264_chroma_mc2_neon, export=1
prfm pldl1strm, [x1]
prfm pldl1strm, [x1, x2]
orr w7, w4, w5
cbz w7, 2 f
mul w7, w4, w5
lsl w14, w5, #3
lsl w13, w4, #3
sub w6, w14, w7
sub w12, w13, w7
sub w4, w7, w13
sub w4, w4, w14
add w4, w4, #64
dup v0.8 b, w4
dup v2.8 b, w12
dup v1.8 b, w6
dup v3.8 b, w7
trn1 v0.4 h, v0.4 h, v2.4 h
trn1 v1.4 h, v1.4 h, v3.4 h
1 :
ld1 {v4.s}[0 ], [x1], x2
ld1 {v4.s}[1 ], [x1], x2
rev64 v5.2 s, v4.2 s
ld1 {v5.s}[1 ], [x1]
ext v6.8 b, v4.8 b, v5.8 b, #1
ext v7.8 b, v5.8 b, v4.8 b, #1
trn1 v4.4 h, v4.4 h, v6.4 h
trn1 v5.4 h, v5.4 h, v7.4 h
umull v16.8 h, v4.8 b, v0.8 b
umlal v16.8 h, v5.8 b, v1.8 b
.ifc \type,avg
ld1 {v18.h}[0 ], [x0], x2
ld1 {v18.h}[2 ], [x0]
sub x0, x0, x2
.endif
rev64 v17.4 s, v16.4 s
add v16.8 h, v16.8 h, v17.8 h
rshrn v16.8 b, v16.8 h, #6
.ifc \type,avg
urhadd v16.8 b, v16.8 b, v18.8 b
.endif
st1 {v16.h}[0 ], [x0], x2
st1 {v16.h}[2 ], [x0], x2
subs w3, w3, #2
b.gt 1 b
ret
2 :
ld1 {v16.h}[0 ], [x1], x2
ld1 {v16.h}[1 ], [x1], x2
.ifc \type,avg
ld1 {v18.h}[0 ], [x0], x2
ld1 {v18.h}[1 ], [x0]
sub x0, x0, x2
urhadd v16.8 b, v16.8 b, v18.8 b
.endif
st1 {v16.h}[0 ], [x0], x2
st1 {v16.h}[1 ], [x0], x2
subs w3, w3, #2
b.gt 2 b
ret
endfunc
.endm
h264_chroma_mc8 put
h264_chroma_mc8 avg
h264_chroma_mc4 put
h264_chroma_mc4 avg
h264_chroma_mc2 put
h264_chroma_mc2 avg
#if CONFIG_RV40_DECODER
const rv40bias
.short 0 , 16 , 32 , 16
.short 32 , 28 , 32 , 28
.short 0 , 32 , 16 , 32
.short 32 , 28 , 32 , 28
endconst
h264_chroma_mc8 put, rv40
h264_chroma_mc8 avg, rv40
h264_chroma_mc4 put, rv40
h264_chroma_mc4 avg, rv40
#endif
#if CONFIG_VC1DSP
h264_chroma_mc8 put, vc1
h264_chroma_mc8 avg, vc1
h264_chroma_mc4 put, vc1
h264_chroma_mc4 avg, vc1
#endif
Messung V0.5 in Prozent C=100 H=100 G=100