libhevcdec: add support for deblock filter for yuv 444 format

Test: ./hevcdec

Change-Id: I013e44e024258f2f84690fdcc01b4cd56f0fbd19
This commit is contained in:
Vivek R Jadhav 2026-05-08 17:14:44 +05:30 committed by Harish Mahendrakar
parent 15deccc068
commit 70ee4f3d29
10 changed files with 270 additions and 96 deletions

View file

@ -41,6 +41,7 @@
.equ tc_offset_div2_offset, 48
.equ filter_p_offset, 52
.equ filter_q_offset, 56
.equ chroma_fmt, 60
.text
.align 4
@ -76,23 +77,38 @@ ihevc_deblk_chroma_horz_a9q:
ldr r8,[sp,#filter_p_offset]
vld1.8 {d16},[r6]
ldr r9,[sp,#filter_q_offset]
ldr r11, [sp, #chroma_fmt]
adds r1,r10,r2,asr #1
vmovl.u8 q1,d2
ldr r7,[sp,#qp_offset_v_offset]
ldr r3,gai4_ihevc_qp_table_addr
ulbl1:
add r3, r3, pc
cmp r11,#1
bgt qp_u_min_51_horz
bmi l1.3312
cmp r1,#0x39
ldrle r1,[r3,r1,lsl #2]
subgt r1,r1,#6
b qp_u_done_horz
qp_u_min_51_horz:
cmp r1,#0x33
movgt r1,#0x33
qp_u_done_horz:
l1.3312:
adds r2,r7,r2,asr #1
vmovl.u8 q2,d4
cmp r11,#1
bgt qp_v_min_51_horz
bmi l1.3332
cmp r2,#0x39
ldrle r2,[r3,r2,lsl #2]
subgt r2,r2,#6
b qp_v_done_horz
qp_v_min_51_horz:
cmp r2,#0x33
movgt r2,#0x33
qp_v_done_horz:
l1.3332:
add r1,r1,r4,lsl #1
vsub.i16 q3,q0,q1

View file

@ -42,6 +42,7 @@
.equ tc_offset_div2_offset, 48
.equ filter_p_offset, 52
.equ filter_q_offset, 56
.equ chroma_fmt, 60
.text
.align 4
@ -82,18 +83,33 @@ ulbl1:
add r7,r7,pc
ldr r12,[sp,#filter_p_offset]
ldr r6,[sp,#qp_offset_v_offset]
ldr r10,[sp,#chroma_fmt]
cmp r10,#1
bgt qp_u_min_51_vert
bmi l1.2944
cmp r3,#0x39
ldrle r3,[r7,r3,lsl #2]
subgt r3,r3,#6
b qp_u_done_vert
qp_u_min_51_vert:
cmp r3,#0x33
movgt r3,#0x33
qp_u_done_vert:
l1.2944:
vtrn.16 d5,d16
adds r2,r6,r2,asr #1
vtrn.16 d17,d4
cmp r10,#1
bgt qp_v_min_51_vert
bmi l1.2964
cmp r2,#0x39
ldrle r2,[r7,r2,lsl #2]
subgt r2,r2,#6
b qp_v_done_vert
qp_v_min_51_vert:
cmp r2,#0x33
movgt r2,#0x33
qp_v_done_vert:
l1.2964:
vtrn.32 d5,d17
add r3,r3,r5,lsl #1

View file

@ -42,7 +42,8 @@
// WORD32 qp_offset_v,
// WORD32 tc_offset_div2,
// WORD32 filter_flag_p,
// WORD32 filter_flag_q)
// WORD32 filter_flag_q,
// WORD8 chroma_fmt)
//
.include "ihevc_neon_macros.s"
@ -62,6 +63,8 @@ ENTRY ihevc_deblk_chroma_horz_av8
sxtw x6,w6
ldr w9, [sp]
sxtw x9,w9
ldr w11, [sp, #8]
sxtw x11,w11
push_v_regs
stp x19, x20,[sp,#-16]!
mov x10, x4
@ -83,6 +86,8 @@ ENTRY ihevc_deblk_chroma_horz_av8
uxtl v2.8h, v2.8b
adrp x3, :got:gai4_ihevc_qp_table
ldr x3, [x3, #:got_lo12:gai4_ihevc_qp_table]
cmp x11,#1
bgt qp_u_min_51_horz
bmi l1.3312
cmp x1,#0x39
bgt lbl78
@ -90,9 +95,17 @@ ENTRY ihevc_deblk_chroma_horz_av8
lbl78:
sub x20,x1,#6
csel x1, x20, x1,gt
b qp_u_done_horz
qp_u_min_51_horz:
mov x20,#0x33
cmp x1,x20
csel x1, x20, x1,gt
qp_u_done_horz:
l1.3312:
adds x2,x7,x2,asr #1
uxtl v4.8h, v4.8b
cmp x11,#1
bgt qp_v_min_51_horz
bmi l1.3332
cmp x2,#0x39
bgt lbl85
@ -100,6 +113,12 @@ l1.3312:
lbl85:
sub x20,x2,#6
csel x2, x20, x2,gt
b qp_v_done_horz
qp_v_min_51_horz:
mov x20,#0x33
cmp x2,x20
csel x2, x20, x2,gt
qp_v_done_horz:
l1.3332:
add x1,x1,x4,lsl #1
sub v6.8h, v0.8h , v2.8h

View file

@ -44,7 +44,8 @@
// WORD32 qp_offset_v,
// WORD32 tc_offset_div2,
// WORD32 filter_flag_p,
// WORD32 filter_flag_q)
// WORD32 filter_flag_q,
// WORD8 chroma_fmt)
.include "ihevc_neon_macros.s"
.text
@ -67,6 +68,8 @@ ENTRY ihevc_deblk_chroma_vert_av8
mov x12, x7
mov x7, x4
ldr w4, [sp]
ldr w11, [sp, #8]
sxtw x11,w11
push_v_regs
stp x19, x20,[sp,#-16]!
@ -89,6 +92,8 @@ ENTRY ihevc_deblk_chroma_vert_av8
adrp x7, :got:gai4_ihevc_qp_table
ldr x7, [x7, #:got_lo12:gai4_ihevc_qp_table]
cmp x11,#1
bgt qp_u_min_51_vert
bmi l1.2944
cmp x3,#0x39
@ -98,6 +103,12 @@ ENTRY ihevc_deblk_chroma_vert_av8
lbl78:
sub x20,x3,#6
csel x3, x20, x3,gt
b qp_u_done_vert
qp_u_min_51_vert:
mov x20,#0x33
cmp x3,x20
csel x3, x20, x3,gt
qp_u_done_vert:
l1.2944:
trn1 v29.4h, v5.4h, v16.4h
trn2 v16.4h, v5.4h, v16.4h
@ -106,6 +117,8 @@ l1.2944:
trn1 v29.4h, v17.4h, v4.4h
trn2 v4.4h, v17.4h, v4.4h
mov v17.d[0], v29.d[0]
cmp x11,#1
bgt qp_v_min_51_vert
bmi l1.2964
cmp x2,#0x39
bgt lbl86
@ -114,6 +127,12 @@ l1.2944:
lbl86:
sub x20,x2,#6
csel x2, x20, x2,gt
b qp_v_done_vert
qp_v_min_51_vert:
mov x20,#0x33
cmp x2,x20
csel x2, x20, x2,gt
qp_v_done_vert:
l1.2964:
trn1 v29.2s, v5.2s, v17.2s
trn2 v17.2s, v5.2s, v17.2s

View file

@ -69,7 +69,8 @@ typedef void ihevc_deblk_chroma_vert_ft(
WORD32 qp_offset_v,
WORD32 tc_offset_div2,
WORD32 filter_flag_p,
WORD32 filter_flag_q);
WORD32 filter_flag_q,
WORD8 chroma_fmt_idc);
typedef void ihevc_deblk_chroma_horz_ft(
UWORD8 *pu1_src,
@ -80,7 +81,8 @@ typedef void ihevc_deblk_chroma_horz_ft(
WORD32 qp_offset_v,
WORD32 tc_offset_div2,
WORD32 filter_flag_p,
WORD32 filter_flag_q);
WORD32 filter_flag_q,
WORD8 chroma_fmt_idc);
typedef void ihevc_hbd_deblk_luma_vert_ft(
UWORD16 *pu2_src,
@ -116,7 +118,8 @@ typedef void ihevc_hbd_deblk_chroma_vert_ft(
WORD32 tc_offset_div2,
WORD32 filter_flag_p,
WORD32 filter_flag_q,
UWORD8 bit_depth);
UWORD8 bit_depth,
WORD8 chroma_fmt_idc);
typedef void ihevc_hbd_deblk_chroma_horz_ft(
UWORD16 *pu2_src,
@ -128,7 +131,8 @@ typedef void ihevc_hbd_deblk_chroma_horz_ft(
WORD32 tc_offset_div2,
WORD32 filter_flag_p,
WORD32 filter_flag_q,
UWORD8 bit_depth);
UWORD8 bit_depth,
WORD8 chroma_fmt_idc);
ihevc_deblk_luma_vert_ft ihevc_deblk_luma_vert;
ihevc_deblk_luma_horz_ft ihevc_deblk_luma_horz;

View file

@ -46,6 +46,7 @@
#include "ihevc_deblk.h"
#include "ihevc_deblk_tables.h"
#include "ihevc_debug.h"
#include "ihevc_defs.h"
/**
@ -598,7 +599,8 @@ void ihevc_deblk_chroma_vert(UWORD8 *pu1_src,
WORD32 qp_offset_v,
WORD32 tc_offset_div2,
WORD32 filter_flag_p,
WORD32 filter_flag_q)
WORD32 filter_flag_q,
WORD8 chroma_fmt_idc)
{
WORD32 qp_indx_u, qp_chroma_u;
WORD32 qp_indx_v, qp_chroma_v;
@ -613,10 +615,19 @@ void ihevc_deblk_chroma_vert(UWORD8 *pu1_src,
/* chroma processing is done only if BS is 2 */
/* this function is assumed to be called only if BS is 2 */
qp_indx_u = qp_offset_u + ((quant_param_p + quant_param_q + 1) >> 1);
qp_chroma_u = qp_indx_u < 0 ? qp_indx_u : (qp_indx_u > 57 ? qp_indx_u - 6 : gai4_ihevc_qp_table[qp_indx_u]);
qp_indx_v = qp_offset_v + ((quant_param_p + quant_param_q + 1) >> 1);
qp_chroma_v = qp_indx_v < 0 ? qp_indx_v : (qp_indx_v > 57 ? qp_indx_v - 6 : gai4_ihevc_qp_table[qp_indx_v]);
/* 8.7.2.5.5 Filtering process for chroma block edges */
if(chroma_fmt_idc == CHROMA_FMT_IDC_YUV444)
{
qp_chroma_u = MIN(qp_indx_u, 51);
qp_chroma_v = MIN(qp_indx_v, 51);
}
else
{
qp_chroma_u = qp_indx_u < 0 ? qp_indx_u : (qp_indx_u > 57 ? qp_indx_u - 6 : gai4_ihevc_qp_table[qp_indx_u]);
qp_chroma_v = qp_indx_v < 0 ? qp_indx_v : (qp_indx_v > 57 ? qp_indx_v - 6 : gai4_ihevc_qp_table[qp_indx_v]);
}
tc_indx_u = CLIP3(qp_chroma_u + 2 + (tc_offset_div2 << 1), 0, 53);
tc_u = gai4_ihevc_tc_table[tc_indx_u];
@ -718,7 +729,8 @@ void ihevc_deblk_chroma_horz(UWORD8 *pu1_src,
WORD32 qp_offset_v,
WORD32 tc_offset_div2,
WORD32 filter_flag_p,
WORD32 filter_flag_q)
WORD32 filter_flag_q,
WORD8 chroma_fmt_idc)
{
WORD32 qp_indx_u, qp_chroma_u;
WORD32 qp_indx_v, qp_chroma_v;
@ -734,10 +746,19 @@ void ihevc_deblk_chroma_horz(UWORD8 *pu1_src,
/* chroma processing is done only if BS is 2 */
/* this function is assumed to be called only if BS is 2 */
qp_indx_u = qp_offset_u + ((quant_param_p + quant_param_q + 1) >> 1);
qp_chroma_u = qp_indx_u < 0 ? qp_indx_u : (qp_indx_u > 57 ? qp_indx_u - 6 : gai4_ihevc_qp_table[qp_indx_u]);
qp_indx_v = qp_offset_v + ((quant_param_p + quant_param_q + 1) >> 1);
qp_chroma_v = qp_indx_v < 0 ? qp_indx_v : (qp_indx_v > 57 ? qp_indx_v - 6 : gai4_ihevc_qp_table[qp_indx_v]);
/* 8.7.2.5.5. Filtering process for chroma block edges */
if(chroma_fmt_idc == CHROMA_FMT_IDC_YUV444)
{
qp_chroma_u = MIN(qp_indx_u, 51);
qp_chroma_v = MIN(qp_indx_v, 51);
}
else
{
qp_chroma_u = qp_indx_u < 0 ? qp_indx_u : (qp_indx_u > 57 ? qp_indx_u - 6 : gai4_ihevc_qp_table[qp_indx_u]);
qp_chroma_v = qp_indx_v < 0 ? qp_indx_v : (qp_indx_v > 57 ? qp_indx_v - 6 : gai4_ihevc_qp_table[qp_indx_v]);
}
tc_indx_u = CLIP3(qp_chroma_u + 2 + (tc_offset_div2 << 1), 0, 53);
tc_u = gai4_ihevc_tc_table[tc_indx_u];

View file

@ -52,6 +52,7 @@
#include "ihevc_deblk.h"
#include "ihevc_deblk_tables.h"
#include "ihevc_debug.h"
#include "ihevc_defs.h"
/**
@ -601,7 +602,8 @@ void ihevc_hbd_deblk_chroma_vert(UWORD16 *pu2_src,
WORD32 tc_offset_div2,
WORD32 filter_flag_p,
WORD32 filter_flag_q,
UWORD8 bit_depth)
UWORD8 bit_depth,
WORD8 chroma_fmt_idc)
{
WORD32 qp_indx_u, qp_chroma_u;
WORD32 qp_indx_v, qp_chroma_v;
@ -616,10 +618,19 @@ void ihevc_hbd_deblk_chroma_vert(UWORD16 *pu2_src,
/* chroma processing is done only if BS is 2 */
/* this function is assumed to be called only if BS is 2 */
qp_indx_u = qp_offset_u + ((quant_param_p + quant_param_q + 1) >> 1);
qp_chroma_u = qp_indx_u < 0 ? qp_indx_u : (qp_indx_u > 57 ? qp_indx_u - 6 : gai4_ihevc_qp_table[qp_indx_u]);
qp_indx_v = qp_offset_v + ((quant_param_p + quant_param_q + 1) >> 1);
qp_chroma_v = qp_indx_v < 0 ? qp_indx_v : (qp_indx_v > 57 ? qp_indx_v - 6 : gai4_ihevc_qp_table[qp_indx_v]);
/* 8.7.2.5.5 Filtering process for chroma block edges */
if(chroma_fmt_idc == CHROMA_FMT_IDC_YUV444)
{
qp_chroma_u = MIN(qp_indx_u, 51);
qp_chroma_v = MIN(qp_indx_v, 51);
}
else
{
qp_chroma_u = qp_indx_u < 0 ? qp_indx_u : (qp_indx_u > 57 ? qp_indx_u - 6 : gai4_ihevc_qp_table[qp_indx_u]);
qp_chroma_v = qp_indx_v < 0 ? qp_indx_v : (qp_indx_v > 57 ? qp_indx_v - 6 : gai4_ihevc_qp_table[qp_indx_v]);
}
tc_indx_u = CLIP3(qp_chroma_u + 2 + (tc_offset_div2 << 1), 0, 53);
tc_u = gai4_ihevc_tc_table[tc_indx_u] * (1 << (bit_depth - 8));
@ -715,7 +726,8 @@ void ihevc_deblk_422chroma_vert(UWORD8 *pu1_src,
WORD32 qp_offset_v,
WORD32 tc_offset_div2,
WORD32 filter_flag_p,
WORD32 filter_flag_q)
WORD32 filter_flag_q,
WORD8 chroma_fmt_idc)
{
WORD32 qp_indx_u, qp_chroma_u;
WORD32 qp_indx_v, qp_chroma_v;
@ -833,7 +845,8 @@ void ihevc_hbd_deblk_422chroma_vert(UWORD16 *pu2_src,
WORD32 tc_offset_div2,
WORD32 filter_flag_p,
WORD32 filter_flag_q,
UWORD8 bit_depth)
UWORD8 bit_depth,
WORD8 chroma_fmt_idc)
{
WORD32 qp_indx_u, qp_chroma_u;
WORD32 qp_indx_v, qp_chroma_v;
@ -950,7 +963,8 @@ void ihevc_deblk_422chroma_horz
WORD32 qp_offset_v,
WORD32 tc_offset_div2,
WORD32 filter_flag_p,
WORD32 filter_flag_q
WORD32 filter_flag_q,
WORD8 chroma_fmt_idc
)
{
WORD32 qp_indx_u, qp_chroma_u;
@ -1065,7 +1079,8 @@ void ihevc_hbd_deblk_chroma_horz(UWORD16 *pu2_src,
WORD32 tc_offset_div2,
WORD32 filter_flag_p,
WORD32 filter_flag_q,
UWORD8 bit_depth)
UWORD8 bit_depth,
WORD8 chroma_fmt_idc)
{
WORD32 qp_indx_u, qp_chroma_u;
WORD32 qp_indx_v, qp_chroma_v;
@ -1081,10 +1096,19 @@ void ihevc_hbd_deblk_chroma_horz(UWORD16 *pu2_src,
/* chroma processing is done only if BS is 2 */
/* this function is assumed to be called only if BS is 2 */
qp_indx_u = qp_offset_u + ((quant_param_p + quant_param_q + 1) >> 1);
qp_chroma_u = qp_indx_u < 0 ? qp_indx_u : (qp_indx_u > 57 ? qp_indx_u - 6 : gai4_ihevc_qp_table[qp_indx_u]);
qp_indx_v = qp_offset_v + ((quant_param_p + quant_param_q + 1) >> 1);
qp_chroma_v = qp_indx_v < 0 ? qp_indx_v : (qp_indx_v > 57 ? qp_indx_v - 6 : gai4_ihevc_qp_table[qp_indx_v]);
/* 8.7.2.5.5 Filtering process for chroma block edges */
if(chroma_fmt_idc == CHROMA_FMT_IDC_YUV444)
{
qp_chroma_u = MIN(qp_indx_u, 51);
qp_chroma_v = MIN(qp_indx_v, 51);
}
else
{
qp_chroma_u = qp_indx_u < 0 ? qp_indx_u : (qp_indx_u > 57 ? qp_indx_u - 6 : gai4_ihevc_qp_table[qp_indx_u]);
qp_chroma_v = qp_indx_v < 0 ? qp_indx_v : (qp_indx_v > 57 ? qp_indx_v - 6 : gai4_ihevc_qp_table[qp_indx_v]);
}
tc_indx_u = CLIP3(qp_chroma_u + 2 + (tc_offset_div2 << 1), 0, 53);
tc_u = gai4_ihevc_tc_table[tc_indx_u] * (1 << (bit_depth - 8));
@ -1177,7 +1201,8 @@ void ihevc_hbd_deblk_422chroma_horz(UWORD16 *pu2_src,
WORD32 tc_offset_div2,
WORD32 filter_flag_p,
WORD32 filter_flag_q,
UWORD8 bit_depth)
UWORD8 bit_depth,
WORD8 chroma_fmt_idc)
{
WORD32 qp_indx_u, qp_chroma_u;
WORD32 qp_indx_v, qp_chroma_v;

View file

@ -46,6 +46,7 @@
#include "ihevc_deblk.h"
#include "ihevc_deblk_tables.h"
#include "ihevc_debug.h"
#include "ihevc_defs.h"
#include "ihevc_tables_x86_intr.h"
@ -993,7 +994,8 @@ void ihevc_deblk_chroma_vert_ssse3(UWORD8 *pu1_src,
WORD32 qp_offset_v,
WORD32 tc_offset_div2,
WORD32 filter_flag_p,
WORD32 filter_flag_q)
WORD32 filter_flag_q,
WORD8 chroma_fmt_idc)
{
WORD32 qp_indx_u, qp_chroma_u;
WORD32 qp_indx_v, qp_chroma_v;
@ -1006,10 +1008,19 @@ void ihevc_deblk_chroma_vert_ssse3(UWORD8 *pu1_src,
/* chroma processing is done only if BS is 2 */
/* this function is assumed to be called only if BS is 2 */
qp_indx_u = qp_offset_u + ((quant_param_p + quant_param_q + 1) >> 1);
qp_chroma_u = qp_indx_u < 0 ? qp_indx_u : (qp_indx_u > 57 ? qp_indx_u - 6 : gai4_ihevc_qp_table[qp_indx_u]);
qp_indx_v = qp_offset_v + ((quant_param_p + quant_param_q + 1) >> 1);
qp_chroma_v = qp_indx_v < 0 ? qp_indx_v : (qp_indx_v > 57 ? qp_indx_v - 6 : gai4_ihevc_qp_table[qp_indx_v]);
/* 8.7.2.5.5 Filtering process for chroma block edges */
if(chroma_fmt_idc == CHROMA_FMT_IDC_YUV444 || chroma_fmt_idc == CHROMA_FMT_IDC_YUV422)
{
qp_chroma_u = MIN(qp_indx_u, 51);
qp_chroma_v = MIN(qp_indx_v, 51);
}
else
{
qp_chroma_u = qp_indx_u < 0 ? qp_indx_u : (qp_indx_u > 57 ? qp_indx_u - 6 : gai4_ihevc_qp_table[qp_indx_u]);
qp_chroma_v = qp_indx_v < 0 ? qp_indx_v : (qp_indx_v > 57 ? qp_indx_v - 6 : gai4_ihevc_qp_table[qp_indx_v]);
}
tc_indx_u = CLIP3(qp_chroma_u + 2 + (tc_offset_div2 << 1), 0, 53);
tc_u = gai4_ihevc_tc_table[tc_indx_u];
@ -1144,7 +1155,8 @@ void ihevc_deblk_chroma_horz_ssse3(UWORD8 *pu1_src,
WORD32 qp_offset_v,
WORD32 tc_offset_div2,
WORD32 filter_flag_p,
WORD32 filter_flag_q)
WORD32 filter_flag_q,
WORD8 chroma_fmt_idc)
{
WORD32 qp_indx_u, qp_chroma_u;
WORD32 qp_indx_v, qp_chroma_v;
@ -1159,10 +1171,19 @@ void ihevc_deblk_chroma_horz_ssse3(UWORD8 *pu1_src,
/* chroma processing is done only if BS is 2 */
/* this function is assumed to be called only if BS is 2 */
qp_indx_u = qp_offset_u + ((quant_param_p + quant_param_q + 1) >> 1);
qp_chroma_u = qp_indx_u < 0 ? qp_indx_u : (qp_indx_u > 57 ? qp_indx_u - 6 : gai4_ihevc_qp_table[qp_indx_u]);
qp_indx_v = qp_offset_v + ((quant_param_p + quant_param_q + 1) >> 1);
qp_chroma_v = qp_indx_v < 0 ? qp_indx_v : (qp_indx_v > 57 ? qp_indx_v - 6 : gai4_ihevc_qp_table[qp_indx_v]);
/* 8.7.2.5.5 Filtering process for chroma block edges */
if(chroma_fmt_idc == CHROMA_FMT_IDC_YUV444 || chroma_fmt_idc == CHROMA_FMT_IDC_YUV422)
{
qp_chroma_u = MIN(qp_indx_u, 51);
qp_chroma_v = MIN(qp_indx_v, 51);
}
else
{
qp_chroma_u = qp_indx_u < 0 ? qp_indx_u : (qp_indx_u > 57 ? qp_indx_u - 6 : gai4_ihevc_qp_table[qp_indx_u]);
qp_chroma_v = qp_indx_v < 0 ? qp_indx_v : (qp_indx_v > 57 ? qp_indx_v - 6 : gai4_ihevc_qp_table[qp_indx_v]);
}
tc_indx_u = CLIP3(qp_chroma_u + 2 + (tc_offset_div2 << 1), 0, 53);
tc_u = gai4_ihevc_tc_table[tc_indx_u];

View file

@ -111,7 +111,7 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk,
UWORD32 *pu4_vert_bs, *pu4_horz_bs;
UWORD32 *pu4_ctb_vert_bs, *pu4_ctb_horz_bs;
WORD32 bs_strd;
WORD32 src_strd;
WORD32 src_strd, chroma_strd;
UWORD8 *pu1_qp;
UWORD16 *pu2_ctb_no_loop_filter_flag;
UWORD16 au2_ctb_no_loop_filter_flag[9];
@ -135,6 +135,11 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk,
ps_codec = ps_deblk->ps_codec;
ps_slice_hdr = ps_deblk->ps_slice_hdr;
WORD32 is_yuv444 = ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV444 ? 1 : 0;
WORD32 h_samp_factor = (CHROMA_FMT_IDC_YUV444 == ps_sps->i1_chroma_format_idc) ? 1 : 2;
WORD32 v_samp_factor = (CHROMA_FMT_IDC_YUV420 == ps_sps->i1_chroma_format_idc) ? 2 : 1;
WORD32 chroma_pixel_strd = 2;
log2_ctb_size = ps_sps->i1_log2_ctb_size;
ctb_size = (1 << ps_sps->i1_log2_ctb_size);
@ -211,6 +216,7 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk,
}
src_strd = ps_codec->i4_strd;
chroma_strd = src_strd * chroma_pixel_strd / h_samp_factor;
/* Luma Vertical Edge */
@ -508,14 +514,14 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk,
ps_slice_hdr_top = ps_codec->ps_slice_hdr_base + ps_deblk->pu1_slice_idx[cur_ctb_indx - ps_sps->i2_pic_wd_in_ctb];
}
pu1_src = ps_deblk->pu1_cur_pic_chroma + ((ps_deblk->i4_ctb_x + ps_deblk->i4_ctb_y * ps_deblk->ps_codec->i4_strd / 2) << log2_ctb_size);
pu1_src += i4_is_last_ctb_y ? (ps_deblk->ps_codec->i4_strd / 2) << log2_ctb_size : 0;
pu1_src = ps_deblk->pu1_cur_pic_chroma + ((ps_deblk->i4_ctb_x * chroma_pixel_strd / h_samp_factor + ps_deblk->i4_ctb_y * ps_deblk->ps_codec->i4_strd * chroma_pixel_strd / (h_samp_factor * v_samp_factor)) << log2_ctb_size);
pu1_src += i4_is_last_ctb_y ? ((ps_codec->i4_strd * chroma_pixel_strd) / (h_samp_factor * v_samp_factor)) << log2_ctb_size : 0;
/** Deblocking is done on a shifted CTB -
* Vertical edge processing is done by shifting the CTB up by four pixels */
pu1_src -= 4 * src_strd;
pu1_src -= 4 * chroma_strd;
for(col = 0; col < ctb_size / 16; col++)
for(col = 0; col < ctb_size / (8 * h_samp_factor); col++)
{
/* BS for the column - Last row is excluded and the top row is included*/
@ -529,22 +535,24 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk,
u4_bs |= u4_top_bs & 3;
}
/* Every alternate boundary strength value is used for chroma */
u4_bs &= 0x22222222;
if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV420) {
/* Every alternate boundary strength value is used for chroma */
u4_bs &= 0x22222222;
}
for(row = 0; row < ctb_size / 8;)
for(row = 0; row < ctb_size / (4 * v_samp_factor);)
{
WORD8 i1_tc_offset_div2 = ps_slice_hdr->i1_tc_offset_div2;
bs_tz = CTZ(u4_bs) >> 2;
bs_tz = CTZ(u4_bs) >> v_samp_factor;
if(0 != bs_tz)
{
if((row + bs_tz) >= (ctb_size / 8))
pu1_src += 4 * (ctb_size / 8 - row) * src_strd;
if((row + bs_tz) >= (ctb_size / (4 * v_samp_factor)))
pu1_src += 4 * (ctb_size / (4 * v_samp_factor) - row) * chroma_strd;
else
pu1_src += 4 * bs_tz * src_strd;
pu1_src += 4 * bs_tz * chroma_strd;
row += bs_tz;
u4_bs = u4_bs >> (bs_tz << 2);
u4_bs = u4_bs >> (bs_tz << v_samp_factor);
continue;
}
@ -562,12 +570,12 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk,
{
qp_p = u4_qp_const_in_ctb[1] ?
pu1_qp[-ctb_size / 8 * qp_strd] :
pu1_qp[2 * col - 1 - qp_strd];
pu1_qp[h_samp_factor * col - 1 - qp_strd];
}
qp_q = u4_qp_const_in_ctb[1] ?
pu1_qp[-ctb_size / 8 * qp_strd] :
pu1_qp[2 * col - qp_strd];
pu1_qp[h_samp_factor * col - qp_strd];
}
else
{
@ -575,30 +583,32 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk,
{
qp_p = u4_qp_const_in_ctb[2] ?
pu1_qp[-ctb_size / 8] :
pu1_qp[(row - 1) * qp_strd - 1];
pu1_qp[((row - 1) >> (2 - v_samp_factor)) * qp_strd - 1];
}
else
{
qp_p = u4_qp_const_in_ctb[3] ?
pu1_qp[0] :
pu1_qp[(row - 1) * qp_strd + 2 * col - 1];
pu1_qp[((row - 1) >> (2 - v_samp_factor)) * qp_strd + h_samp_factor * col - 1];
}
qp_q = u4_qp_const_in_ctb[3] ?
pu1_qp[0] :
pu1_qp[(row - 1) * qp_strd + 2 * col];
pu1_qp[((row - 1) >> (2 - v_samp_factor)) * qp_strd + h_samp_factor * col];
}
filter_p = (pu2_ctb_no_loop_filter_flag[row] >> (col << 1)) & 1;
filter_q = (pu2_ctb_no_loop_filter_flag[row] >> (col << 1)) & 2;
filter_p = (pu2_ctb_no_loop_filter_flag[(row + (2 - v_samp_factor)) >> (2 - v_samp_factor)] >> (col << (h_samp_factor - 1))) & 1;
filter_q = (pu2_ctb_no_loop_filter_flag[(row + (2 - v_samp_factor)) >> (2 - v_samp_factor)] >> (col << (h_samp_factor - 1))) & 2;
/* filter_p and filter_q are inverted as they are calculated using no_loop_filter_flags */
filter_p = !filter_p;
filter_q = !filter_q;
if(filter_p || filter_q)
{
ASSERT(1 == ((u4_bs & 3) >> 1));
DUMP_DEBLK_CHROMA_VERT(pu1_src, src_strd,
if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV420) {
ASSERT(1 == ((u4_bs & 3) >> 1));
}
DUMP_DEBLK_CHROMA_VERT(pu1_src, chroma_strd,
u4_bs & 3, qp_p, qp_q,
ps_pps->i1_pic_cb_qp_offset,
ps_pps->i1_pic_cr_qp_offset,
@ -607,36 +617,45 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk,
if(chroma_yuv420sp_vu)
{
ps_codec->s_func_selector.ihevc_deblk_chroma_vert_fptr(pu1_src,
src_strd,
chroma_strd,
qp_q,
qp_p,
ps_pps->i1_pic_cr_qp_offset,
ps_pps->i1_pic_cb_qp_offset,
i1_tc_offset_div2,
filter_q,
filter_p);
filter_p,
ps_sps->i1_chroma_format_idc);
}
else
{
ps_codec->s_func_selector.ihevc_deblk_chroma_vert_fptr(pu1_src,
src_strd,
chroma_strd,
qp_p,
qp_q,
ps_pps->i1_pic_cb_qp_offset,
ps_pps->i1_pic_cr_qp_offset,
i1_tc_offset_div2,
filter_p,
filter_q);
filter_q,
ps_sps->i1_chroma_format_idc);
}
}
pu1_src += 4 * src_strd;
u4_bs = u4_bs >> 4;
pu1_src += 4 * chroma_strd;
u4_bs = u4_bs >> (2 * v_samp_factor);
row++;
}
pu4_vert_bs += (64 == ctb_size) ? 2 : 1;
pu1_src -= ((src_strd / 2) << log2_ctb_size);
pu1_src -= (((src_strd * chroma_pixel_strd) / (h_samp_factor * v_samp_factor)) << log2_ctb_size);
if(is_yuv444)
{
if((64 ==ctb_size) || ((32 == ctb_size) && (col & 1))) pu4_vert_bs++;
}
else
{
pu4_vert_bs += (64 == ctb_size) ? 2 : 1;
}
pu1_src += 16;
}
}
@ -655,13 +674,13 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk,
ps_slice_hdr_left = ps_codec->ps_slice_hdr_base + ps_deblk->pu1_slice_idx[cur_ctb_indx - 1];
}
pu1_src = ps_deblk->pu1_cur_pic_chroma + ((ps_deblk->i4_ctb_x + ps_deblk->i4_ctb_y * ps_deblk->ps_codec->i4_strd / 2) << log2_ctb_size);
pu1_src += i4_is_last_ctb_x ? ctb_size : 0;
pu1_src = ps_deblk->pu1_cur_pic_chroma + ((ps_deblk->i4_ctb_x * chroma_pixel_strd / h_samp_factor + ps_deblk->i4_ctb_y * ps_deblk->ps_codec->i4_strd * chroma_pixel_strd / (v_samp_factor * h_samp_factor)) << log2_ctb_size);
pu1_src += i4_is_last_ctb_x ? ctb_size * chroma_pixel_strd / h_samp_factor : 0;
/** Deblocking is done on a shifted CTB -
* Vertical edge processing is done by shifting the CTB up by four pixels (8 here beacuse UV are interleaved) */
pu1_src -= 8;
for(row = 0; row < ctb_size / 16; row++)
for(row = 0; row < ctb_size / (8 * v_samp_factor); row++)
{
/* BS for the row - Last column is excluded and the left column is included*/
u4_bs = pu4_horz_bs[0] << 2;
@ -676,20 +695,22 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk,
u4_bs |= u4_left_bs & 3;
}
/* Every alternate boundary strength value is used for chroma */
u4_bs &= 0x22222222;
if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV420) {
/* Every alternate boundary strength value is used for chroma */
u4_bs &= 0x22222222;
}
for(col = 0; col < ctb_size / 8;)
for(col = 0; col < ctb_size / (4 * h_samp_factor);)
{
WORD8 i1_tc_offset_div2 = ps_slice_hdr->i1_tc_offset_div2;
bs_tz = CTZ(u4_bs) >> 2;
bs_tz = CTZ(u4_bs) >> h_samp_factor;
if(0 != bs_tz)
{
u4_bs = u4_bs >> (bs_tz << 2);
u4_bs = u4_bs >> (bs_tz << h_samp_factor);
if((col + bs_tz) >= (ctb_size / 8))
pu1_src += 8 * (ctb_size / 8 - col);
if((col + bs_tz) >= (ctb_size / (4 * h_samp_factor)))
pu1_src += 8 * (ctb_size / (4 * h_samp_factor) - col);
else
pu1_src += 8 * bs_tz;
@ -711,12 +732,12 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk,
{
qp_p = u4_qp_const_in_ctb[2] ?
pu1_qp[-ctb_size / 8] :
pu1_qp[(2 * row - 1) * qp_strd - 1];
pu1_qp[(v_samp_factor * row - 1) * qp_strd - 1];
}
qp_q = u4_qp_const_in_ctb[2] ?
pu1_qp[-ctb_size / 8] :
pu1_qp[(2 * row) * qp_strd - 1];
pu1_qp[(v_samp_factor * row) * qp_strd - 1];
}
else
{
@ -724,30 +745,31 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk,
{
qp_p = u4_qp_const_in_ctb[1] ?
pu1_qp[-ctb_size / 8 * qp_strd] :
pu1_qp[col - 1 - qp_strd];
pu1_qp[((col - 1) >> (2 - h_samp_factor)) - qp_strd];
}
else
{
qp_p = u4_qp_const_in_ctb[3] ?
pu1_qp[0] :
pu1_qp[(col - 1) + (2 * row - 1) * qp_strd];
pu1_qp[((col - 1) >> (2 - h_samp_factor)) + (v_samp_factor * row - 1) * qp_strd];
}
qp_q = u4_qp_const_in_ctb[3] ?
pu1_qp[0] :
pu1_qp[(col - 1) + 2 * row * qp_strd];
pu1_qp[((col - 1) >> (2 - h_samp_factor)) + v_samp_factor * row * qp_strd];
}
filter_p = (pu2_ctb_no_loop_filter_flag[row << 1] >> col) & 1;
filter_q = (pu2_ctb_no_loop_filter_flag[(row << 1) + 1] >> col) & 1;
filter_p = (pu2_ctb_no_loop_filter_flag[row * v_samp_factor] >> ((col + 2 - h_samp_factor) >> (2 - h_samp_factor))) & 1;
filter_q = (pu2_ctb_no_loop_filter_flag[(row * v_samp_factor) + 1] >> ((col + 2 - h_samp_factor) >> (2 - h_samp_factor))) & 1;
/* filter_p and filter_q are inverted as they are calculated using no_loop_filter_flags */
filter_p = !filter_p;
filter_q = !filter_q;
if(filter_p || filter_q)
{
ASSERT(1 == ((u4_bs & 3) >> 1));
DUMP_DEBLK_CHROMA_HORZ(pu1_src, src_strd,
if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV420) {
ASSERT(1 == ((u4_bs & 3) >> 1));
}
DUMP_DEBLK_CHROMA_HORZ(pu1_src, chroma_strd,
u4_bs & 3, qp_p, qp_q,
ps_pps->i1_pic_cb_qp_offset,
ps_pps->i1_pic_cr_qp_offset,
@ -756,37 +778,45 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk,
if(chroma_yuv420sp_vu)
{
ps_codec->s_func_selector.ihevc_deblk_chroma_horz_fptr(pu1_src,
src_strd,
chroma_strd,
qp_q,
qp_p,
ps_pps->i1_pic_cr_qp_offset,
ps_pps->i1_pic_cb_qp_offset,
i1_tc_offset_div2,
filter_q,
filter_p);
filter_p,
ps_sps->i1_chroma_format_idc);
}
else
{
ps_codec->s_func_selector.ihevc_deblk_chroma_horz_fptr(pu1_src,
src_strd,
chroma_strd,
qp_p,
qp_q,
ps_pps->i1_pic_cb_qp_offset,
ps_pps->i1_pic_cr_qp_offset,
i1_tc_offset_div2,
filter_p,
filter_q);
filter_q,
ps_sps->i1_chroma_format_idc);
}
}
pu1_src += 8;
u4_bs = u4_bs >> 4;
u4_bs = u4_bs >> (2 * h_samp_factor);
col++;
}
pu4_horz_bs += (64 == ctb_size) ? 2 : 1;
pu1_src -= ctb_size;
pu1_src += 8 * src_strd;
if(is_yuv444)
{
if((64 == ctb_size) || ((32 == ctb_size) && (row & 1))) pu4_horz_bs++;
}
else
{
pu4_horz_bs += (64 == ctb_size) ? 2 : 1;
}
pu1_src -= ctb_size * (chroma_pixel_strd / h_samp_factor);
pu1_src += 8 * chroma_strd;
}
}

View file

@ -455,7 +455,8 @@ void ihevce_deblk_ctb(
ps_deblk->i4_cr_qp_indx_offset,
ps_deblk->i4_tc_offset_div2,
filter_p,
filter_q);
filter_q,
ps_deblk->u1_chroma_array_type);
u4_bs = u4_bs << (1 << i4_log2_num_bits_per_bs);
pu1_curr_src += (ps_deblk->i4_chroma_pic_stride << 2);
@ -627,7 +628,8 @@ void ihevce_deblk_ctb(
ps_deblk->i4_cr_qp_indx_offset,
ps_deblk->i4_tc_offset_div2,
1,
1);
1,
ps_deblk->u1_chroma_array_type);
}
pu1_src_uv += 8;
@ -662,7 +664,8 @@ void ihevce_deblk_ctb(
ps_deblk->i4_cr_qp_indx_offset,
ps_deblk->i4_tc_offset_div2,
filter_p,
filter_q);
filter_q,
ps_deblk->u1_chroma_array_type);
pu1_src_uv += 8;
u4_bs = u4_bs << 4;