1 ;*****************************************************************************
2 ;* bitstream-a.asm: x86 bitstream functions
3 ;*****************************************************************************
4 ;* Copyright (C) 2010-2011 x264 project
6 ;* Authors: Fiona Glaser <fiona@x264.com>
7 ;* Henrik Gramner <hengar-6@student.ltu.se>
9 ;* This program is free software; you can redistribute it and/or modify
10 ;* it under the terms of the GNU General Public License as published by
11 ;* the Free Software Foundation; either version 2 of the License, or
12 ;* (at your option) any later version.
14 ;* This program is distributed in the hope that it will be useful,
15 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;* GNU General Public License for more details.
19 ;* You should have received a copy of the GNU General Public License
20 ;* along with this program; if not, write to the Free Software
21 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
23 ;* This program is also available under a commercial proprietary license.
24 ;* For more information, contact us at licensing@x264.com.
25 ;*****************************************************************************
28 %include "x86util.asm"
32 ;-----------------------------------------------------------------------------
33 ; uint8_t *x264_nal_escape( uint8_t *dst, uint8_t *src, uint8_t *end )
34 ;-----------------------------------------------------------------------------
38 ; Detect false positive to avoid unneccessary escape loop
53 mova m0, [r1+r2+2*mmsize]
57 mova m1, [r1+r2+3*mmsize]
67 cglobal nal_escape, 3,5
69 sub r1, r2 ; r1 = offset of current src pointer from end of src
71 sub r0, r1 ; r0 = projected end of dst, assuming no more escapes
76 ; Start off by jumping into the escape loop in
77 ; case there's an escape at the start.
78 ; And do a few more in scalar until src is aligned again.
81 NAL_LOOP .loop_aligned, mova
84 NAL_LOOP .loop_unaligned, movu
92 ; Skip bytes that are known to be valid
100 movzx r3d, byte [r1+r2]
106 test r4d, mmsize-1 ; Do SIMD when src is aligned
119 cmp word [r0+r1-2], 0