.macro _neon_normalxx_8_16_line_middle src, dst, pal, counter, reg1, reg2, reg3, reg4, reg5, reg6, reg7, reg8, reg9, dststride, dA, dB
ldr \reg1, [\src] @ reg1 = src[0-3]
ldr \reg2, [\src, #4] @ reg2 = src[4-7]
ldr \reg3, [\src, #8] @ reg3 = src[8-11]
ldr \reg4, [\src, #12] @ reg4 = src[12-15]
ubfx \reg5, \reg1, #0, #8 @ reg5 = src[0]
ldr \reg5, [\pal, \reg5, lsl #2] @ reg5 = pal[src[0]]
ubfx \reg6, \reg1, #8, #8 @ reg6 = src[1]
ldr \reg6, [\pal, \reg6, lsl #2] @ reg6 = pal[src[1]]
ubfx \reg7, \reg1, #16, #8 @ reg7 = src[2]
ldr \reg7, [\pal, \reg7, lsl #2] @ reg7 = pal[src[2]]
lsr \reg1, \reg1, #24 @ reg1 = src[3]
ldr \reg1, [\pal, \reg1, lsl #2] @ reg1 = pal[src[3]]
ubfx \reg8, \reg2, #0, #8 @ reg8 = src[4]
ldr \reg8, [\pal, \reg8, lsl #2] @ reg8 = pal[src[4]]
ubfx \reg9, \reg2, #8, #8 @ reg9 = src[5]
ldr \reg9, [\pal, \reg9, lsl #2] @ reg9 = pal[src[5]]
bfi \reg5, \reg6, #16, #16 @ reg5 = pal[src[0]] | pal[src[1]] << 16
bfi \reg7, \reg1, #16, #16 @ reg7 = pal[src[2]] | pal[src[3]] << 16
ubfx \reg6, \reg2, #16, #8 @ reg6 = src[6]
vmov d16, \reg5, \reg7 @ d16 = pal[src[0-3]]
lsr \reg2, \reg2, #24 @ reg2 = src[7]
ldr \reg6, [\pal, \reg6, lsl #2] @ reg6 = pal[src[6]]
bfi \reg8, \reg9, #16, #16 @ reg8 = pal[src[4]] | pal[src[5]] << 16
ldr \reg2, [\pal, \reg2, lsl #2] @ reg2 = pal[src[7]]
ubfx \reg1, \reg3, #0, #8 @ reg1 = src[8]
ldr \reg1, [\pal, \reg1, lsl #2] @ reg1 = pal[src[8]]
ubfx \reg5, \reg3, #8, #8 @ reg5 = src[9]
ldr \reg5, [\pal, \reg5, lsl #2] @ reg5 = pal[src[9]]
ubfx \reg7, \reg3, #16, #8 @ reg7 = src[10]
ldr \reg7, [\pal, \reg7, lsl #2] @ reg7 = pal[src[10]]
bfi \reg6, \reg2, #16, #16 @ reg6 = pal[src[6]] | pal[src[7]] << 16
vmov d17, \reg8, \reg6 @ d17 = pal[src[4-7]]
lsr \reg3, \reg3, #24 @ reg3 = src[11]
ldr \reg3, [\pal, \reg3, lsl #2] @ reg3 = pal[src[11]]
ubfx \reg2, \reg4, #0, #8 @ reg2 = src[12]
ldr \reg2, [\pal, \reg2, lsl #2] @ reg2 = pal[src[12]]
ubfx \reg6, \reg4, #8, #8 @ reg6 = src[13]
ldr \reg6, [\pal, \reg6, lsl #2] @ reg6 = pal[src[13]]
ubfx \reg8, \reg4, #16, #8 @ reg8 = src[14]
ldr \reg8, [\pal, \reg8, lsl #2] @ reg8 = pal[src[14]]
lsr \reg4, \reg4, #24 @ reg4 = src[15]
ldr \reg4, [\pal, \reg4, lsl #2] @ reg4 = pal[src[15]]
bfi \reg1, \reg5, #16, #16 @ reg1 = pal[src[8]] | pal[src[9]] << 16
bfi \reg7, \reg3, #16, #16 @ reg7 = pal[src[10]] | pal[src[11]] << 16
bfi \reg2, \reg6, #16, #16 @ reg2 = pal[src[12]] | pal[src[13]] << 16
vmov \dA, \reg1, \reg7 @ dA = pal[src[8-11]]
sub \counter, \counter, #16 @ counter -= 16
bfi \reg8, \reg4, #16, #16 @ reg8 = pal[src[14]] | pal[src[15]] << 16
add \src, \src, #16 @ src += 16
vmov \dB, \reg2, \reg8 @ dB = pal[src[12-15]]
cmp \counter, #16
.endm