diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-03-09 13:37:14 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-03-09 13:37:29 +0100 |
commit | fa4f57399774b7c09c5978652b2eaea77f8851e1 (patch) | |
tree | 2b3ed943f0f50750cb99e762ff86f53f9007b3cb /libavcodec/arm | |
parent | cbee7ff0b7dfefab7f9a5d8639e493ab90c0a0cb (diff) | |
parent | 634d9d8b398982647b3d7160641198744901d8d8 (diff) | |
download | ffmpeg-fa4f57399774b7c09c5978652b2eaea77f8851e1.tar.gz |
Merge commit '634d9d8b398982647b3d7160641198744901d8d8'
* commit '634d9d8b398982647b3d7160641198744901d8d8':
arm: get_cabac inline asm
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/arm')
-rw-r--r-- | libavcodec/arm/cabac.h | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/libavcodec/arm/cabac.h b/libavcodec/arm/cabac.h new file mode 100644 index 0000000000..f581d86e70 --- /dev/null +++ b/libavcodec/arm/cabac.h @@ -0,0 +1,102 @@ +/* + * 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 + */ + +#ifndef AVCODEC_ARM_CABAC_H +#define AVCODEC_ARM_CABAC_H + +#include "config.h" +#if HAVE_ARMV6T2_INLINE + +#include "libavutil/attributes.h" +#include "libavutil/internal.h" +#include "libavcodec/cabac.h" + +#define get_cabac_inline get_cabac_inline_arm +static av_always_inline int get_cabac_inline_arm(CABACContext *c, + uint8_t *const state) +{ + int bit; + void *reg_b, *reg_c, *tmp; + + __asm__ volatile( + "ldrb %[bit] , [%[state]] \n\t" + "add %[r_b] , %[tables] , %[lps_off] \n\t" + "mov %[tmp] , %[range] \n\t" + "and %[range] , %[range] , #0xC0 \n\t" + "add %[r_b] , %[r_b] , %[bit] \n\t" + "ldrb %[range] , [%[r_b], %[range], lsl #1] \n\t" + "add %[r_b] , %[tables] , %[norm_off] \n\t" + "sub %[r_c] , %[tmp] , %[range] \n\t" + "lsl %[tmp] , %[r_c] , #17 \n\t" + "cmp %[tmp] , %[low] \n\t" + "it gt \n\t" + "movgt %[range] , %[r_c] \n\t" + "itt cc \n\t" + "mvncc %[bit] , %[bit] \n\t" + "subcc %[low] , %[low] , %[tmp] \n\t" + "add %[r_c] , %[tables] , %[mlps_off] \n\t" + "ldrb %[tmp] , [%[r_b], %[range]] \n\t" + "ldrb %[r_b] , [%[r_c], %[bit]] \n\t" + "lsl %[low] , %[low] , %[tmp] \n\t" + "lsl %[range] , %[range] , %[tmp] \n\t" + "uxth %[r_c] , %[low] \n\t" + "strb %[r_b] , [%[state]] \n\t" + "tst %[r_c] , %[r_c] \n\t" + "bne 2f \n\t" + "ldr %[r_c] , [%[c], %[byte]] \n\t" + "ldr %[r_b] , [%[c], %[end]] \n\t" + "ldrh %[tmp] , [%[r_c]] \n\t" + "cmp %[r_c] , %[r_b] \n\t" + "itt lt \n\t" + "addlt %[r_c] , %[r_c] , #2 \n\t" + "strlt %[r_c] , [%[c], %[byte]] \n\t" + "sub %[r_c] , %[low] , #1 \n\t" + "add %[r_b] , %[tables] , %[norm_off] \n\t" + "eor %[r_c] , %[low] , %[r_c] \n\t" + "rev %[tmp] , %[tmp] \n\t" + "lsr %[r_c] , %[r_c] , #15 \n\t" + "lsr %[tmp] , %[tmp] , #15 \n\t" + "ldrb %[r_c] , [%[r_b], %[r_c]] \n\t" + "movw %[r_b] , #0xFFFF \n\t" + "sub %[tmp] , %[tmp] , %[r_b] \n\t" + "rsb %[r_c] , %[r_c] , #7 \n\t" + "lsl %[tmp] , %[tmp] , %[r_c] \n\t" + "add %[low] , %[low] , %[tmp] \n\t" + "2: \n\t" + : [bit]"=&r"(bit), + [low]"+&r"(c->low), + [range]"+&r"(c->range), + [r_b]"=&r"(reg_b), + [r_c]"=&r"(reg_c), + [tmp]"=&r"(tmp) + : [c]"r"(c), + [state]"r"(state), + [tables]"r"(ff_h264_cabac_tables), + [byte]"M"(offsetof(CABACContext, bytestream)), + [end]"M"(offsetof(CABACContext, bytestream_end)), + [norm_off]"I"(H264_NORM_SHIFT_OFFSET), + [lps_off]"I"(H264_LPS_RANGE_OFFSET), + [mlps_off]"I"(H264_MLPS_STATE_OFFSET + 128) + : "memory", "cc" + ); + + return bit & 1; +} +#endif /* HAVE_ARMV6T2_INLINE */ + +#endif /* AVCODEC_ARM_CABAC_H */ |