Skip to content

Commit 186bd30

Browse files
author
Janne Grunau
committed
h264/arm64: implement missing 4:2:2 chroma loop filter neon functions
1 parent 7e42d5f commit 186bd30

2 files changed

Lines changed: 46 additions & 8 deletions

File tree

libavcodec/aarch64/h264dsp_init_aarch64.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ void ff_h264_v_loop_filter_chroma_neon(uint8_t *pix, int stride, int alpha,
3737
int beta, int8_t *tc0);
3838
void ff_h264_h_loop_filter_chroma_neon(uint8_t *pix, int stride, int alpha,
3939
int beta, int8_t *tc0);
40+
void ff_h264_h_loop_filter_chroma422_neon(uint8_t *pix, int stride, int alpha,
41+
int beta, int8_t *tc0);
4042
void ff_h264_v_loop_filter_chroma_intra_neon(uint8_t *pix, int stride,
4143
int alpha, int beta);
4244
void ff_h264_h_loop_filter_chroma_intra_neon(uint8_t *pix, int stride,
4345
int alpha, int beta);
46+
void ff_h264_h_loop_filter_chroma422_intra_neon(uint8_t *pix, int stride,
47+
int alpha, int beta);
4448
void ff_h264_h_loop_filter_chroma_mbaff_intra_neon(uint8_t *pix, int stride,
4549
int alpha, int beta);
4650

@@ -91,10 +95,18 @@ av_cold void ff_h264dsp_init_aarch64(H264DSPContext *c, const int bit_depth,
9195
c->h264_h_loop_filter_luma_intra= ff_h264_h_loop_filter_luma_intra_neon;
9296

9397
c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon;
94-
c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon;
9598
c->h264_v_loop_filter_chroma_intra = ff_h264_v_loop_filter_chroma_intra_neon;
96-
c->h264_h_loop_filter_chroma_intra = ff_h264_h_loop_filter_chroma_intra_neon;
97-
c->h264_h_loop_filter_chroma_mbaff_intra = ff_h264_h_loop_filter_chroma_mbaff_intra_neon;
99+
100+
if (chroma_format_idc <= 1) {
101+
c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon;
102+
c->h264_h_loop_filter_chroma_intra = ff_h264_h_loop_filter_chroma_intra_neon;
103+
c->h264_h_loop_filter_chroma_mbaff_intra = ff_h264_h_loop_filter_chroma_mbaff_intra_neon;
104+
} else {
105+
c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma422_neon;
106+
c->h264_h_loop_filter_chroma_mbaff = ff_h264_h_loop_filter_chroma_neon;
107+
c->h264_h_loop_filter_chroma_intra = ff_h264_h_loop_filter_chroma422_intra_neon;
108+
c->h264_h_loop_filter_chroma_mbaff_intra = ff_h264_h_loop_filter_chroma_intra_neon;
109+
}
98110

99111
c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels_16_neon;
100112
c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels_8_neon;

libavcodec/aarch64/h264dsp_neon.S

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
ldr w6, [x4]
2929
ccmp w3, #0, #0, ne
3030
mov v24.S[0], w6
31-
and w6, w6, w6, lsl #16
31+
and w8, w6, w6, lsl #16
3232
b.eq 1f
33-
ands w6, w6, w6, lsl #8
33+
ands w8, w8, w8, lsl #8
3434
b.ge 2f
3535
1:
3636
ret
@@ -394,10 +394,10 @@ endfunc
394394
usubw v4.8H, v4.8H, v16.8B
395395
and v26.8B, v26.8B, v30.8B
396396
shl v4.8H, v4.8H, #2
397-
mov x2, v26.d[0]
397+
mov x8, v26.d[0]
398398
sli v24.8H, v24.8H, #8
399399
uaddw v4.8H, v4.8H, v18.8B
400-
cbz x2, 9f
400+
cbz x8, 9f
401401
usubw v4.8H, v4.8H, v2.8B
402402
rshrn v4.8B, v4.8H, #3
403403
smin v4.8B, v4.8B, v24.8B
@@ -436,6 +436,7 @@ function ff_h264_h_loop_filter_chroma_neon, export=1
436436
sxtw x1, w1
437437

438438
sub x0, x0, #2
439+
h_loop_filter_chroma420:
439440
ld1 {v18.S}[0], [x0], x1
440441
ld1 {v16.S}[0], [x0], x1
441442
ld1 {v0.S}[0], [x0], x1
@@ -464,6 +465,19 @@ function ff_h264_h_loop_filter_chroma_neon, export=1
464465
ret
465466
endfunc
466467

468+
function ff_h264_h_loop_filter_chroma422_neon, export=1
469+
sxtw x1, w1
470+
h264_loop_filter_start
471+
add x5, x0, x1
472+
sub x0, x0, #2
473+
add x1, x1, x1
474+
mov x7, x30
475+
bl h_loop_filter_chroma420
476+
mov x30, x7
477+
sub x0, x5, #2
478+
mov v24.s[0], w6
479+
b h_loop_filter_chroma420
480+
endfunc
467481

468482
.macro h264_loop_filter_chroma_intra
469483
uabd v26.8b, v16.8b, v17.8b // abs(p0 - q0)
@@ -536,14 +550,15 @@ function ff_h264_h_loop_filter_chroma_intra_neon, export=1
536550

537551
sub x4, x0, #2
538552
sub x0, x0, #1
553+
h_loop_filter_chroma420_intra:
539554
ld1 {v18.8b}, [x4], x1
540555
ld1 {v16.8b}, [x4], x1
541556
ld1 {v17.8b}, [x4], x1
542557
ld1 {v19.8b}, [x4], x1
543558
ld1 {v18.s}[1], [x4], x1
544559
ld1 {v16.s}[1], [x4], x1
545560
ld1 {v17.s}[1], [x4], x1
546-
ld1 {v19.s}[1], [x4]
561+
ld1 {v19.s}[1], [x4], x1
547562

548563
transpose_4x8B v18, v16, v17, v19, v26, v27, v28, v29
549564

@@ -562,6 +577,17 @@ function ff_h264_h_loop_filter_chroma_intra_neon, export=1
562577
ret
563578
endfunc
564579

580+
function ff_h264_h_loop_filter_chroma422_intra_neon, export=1
581+
h264_loop_filter_start_intra
582+
sub x4, x0, #2
583+
add x5, x0, x1, lsl #3
584+
sub x0, x0, #1
585+
mov x7, x30
586+
bl h_loop_filter_chroma420_intra
587+
sub x0, x5, #1
588+
mov x30, x7
589+
b h_loop_filter_chroma420_intra
590+
endfunc
565591

566592
.macro biweight_16 macs, macd
567593
dup v0.16B, w5

0 commit comments

Comments
 (0)