FFmpeg
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
libavcodec
mips
cabac.h
Go to the documentation of this file.
1
/*
2
* Loongson SIMD optimized h264chroma
3
*
4
* Copyright (c) 2018 Loongson Technology Corporation Limited
5
* Copyright (c) 2018 Shiyou Yin <yinshiyou-hf@loongson.cn>
6
*
7
* This file is part of FFmpeg.
8
*
9
* FFmpeg is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU Lesser General Public
11
* License as published by the Free Software Foundation; either
12
* version 2.1 of the License, or (at your option) any later version.
13
*
14
* FFmpeg 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 GNU
17
* Lesser General Public License for more details.
18
*
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with FFmpeg; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
*/
23
24
#ifndef AVCODEC_MIPS_CABAC_H
25
#define AVCODEC_MIPS_CABAC_H
26
27
#include "
libavcodec/cabac.h
"
28
#include "
libavutil/mips/mmiutils.h
"
29
#include "
config.h
"
30
31
#define get_cabac_inline get_cabac_inline_mips
32
static
av_always_inline
int
get_cabac_inline
(
CABACContext
*
c
,
33
uint8_t
*
const
state
){
34
mips_reg
tmp0, tmp1, tmp2, bit;
35
36
__asm__
volatile
(
37
"lbu %[bit], 0(%[state]) \n\t"
38
"and %[tmp0], %[c_range], 0xC0 \n\t"
39
PTR_ADDU
"%[tmp0], %[tmp0], %[tmp0] \n\t"
40
PTR_ADDU
"%[tmp0], %[tmp0], %[tables] \n\t"
41
PTR_ADDU
"%[tmp0], %[tmp0], %[bit] \n\t"
42
/* tmp1: RangeLPS */
43
"lbu %[tmp1], %[lps_off](%[tmp0]) \n\t"
44
45
PTR_SUBU
"%[c_range], %[c_range], %[tmp1] \n\t"
46
PTR_SLL
"%[tmp0], %[c_range], 0x11 \n\t"
47
PTR_SUBU
"%[tmp0], %[tmp0], %[c_low] \n\t"
48
49
/* tmp2: lps_mask */
50
PTR_SRA
"%[tmp2], %[tmp0], 0x1F \n\t"
51
/* If tmp0 < 0, lps_mask == 0xffffffff*/
52
/* If tmp0 >= 0, lps_mask == 0x00000000*/
53
"beqz %[tmp2], 1f \n\t"
54
PTR_SLL
"%[tmp0], %[c_range], 0x11 \n\t"
55
PTR_SUBU
"%[c_low], %[c_low], %[tmp0] \n\t"
56
PTR_SUBU
"%[tmp0], %[tmp1], %[c_range] \n\t"
57
PTR_ADDU
"%[c_range], %[c_range], %[tmp0] \n\t"
58
"xor %[bit], %[bit], %[tmp2] \n\t"
59
60
"1: \n\t"
61
/* tmp1: *state */
62
PTR_ADDU
"%[tmp0], %[tables], %[bit] \n\t"
63
"lbu %[tmp1], %[mlps_off](%[tmp0]) \n\t"
64
/* tmp2: lps_mask */
65
PTR_ADDU
"%[tmp0], %[tables], %[c_range] \n\t"
66
"lbu %[tmp2], %[norm_off](%[tmp0]) \n\t"
67
68
"sb %[tmp1], 0(%[state]) \n\t"
69
"and %[bit], %[bit], 0x01 \n\t"
70
PTR_SLL
"%[c_range], %[c_range], %[tmp2] \n\t"
71
PTR_SLL
"%[c_low], %[c_low], %[tmp2] \n\t"
72
73
"and %[tmp0], %[c_low], %[cabac_mask] \n\t"
74
"bnez %[tmp0], 1f \n\t"
75
PTR_ADDI
"%[tmp0], %[c_low], -0X01 \n\t"
76
"xor %[tmp0], %[c_low], %[tmp0] \n\t"
77
PTR_SRA
"%[tmp0], %[tmp0], 0x0f \n\t"
78
PTR_ADDU
"%[tmp0], %[tmp0], %[tables] \n\t"
79
"lbu %[tmp2], %[norm_off](%[tmp0]) \n\t"
80
#if CABAC_BITS == 16
81
"lbu %[tmp0], 0(%[c_bytestream]) \n\t"
82
"lbu %[tmp1], 1(%[c_bytestream]) \n\t"
83
PTR_SLL
"%[tmp0], %[tmp0], 0x09 \n\t"
84
PTR_SLL
"%[tmp1], %[tmp1], 0x01 \n\t"
85
PTR_ADDU
"%[tmp0], %[tmp0], %[tmp1] \n\t"
86
#else
87
"lbu %[tmp0], 0(%[c_bytestream]) \n\t"
88
PTR_SLL
"%[tmp0], %[tmp0], 0x01 \n\t"
89
#endif
90
PTR_SUBU
"%[tmp0], %[tmp0], %[cabac_mask] \n\t"
91
92
"li %[tmp1], 0x07 \n\t"
93
PTR_SUBU
"%[tmp1], %[tmp1], %[tmp2] \n\t"
94
PTR_SLL
"%[tmp0], %[tmp0], %[tmp1] \n\t"
95
PTR_ADDU
"%[c_low], %[c_low], %[tmp0] \n\t"
96
97
#if !UNCHECKED_BITSTREAM_READER
98
"bge %[c_bytestream], %[c_bytestream_end], 1f \n\t"
99
#endif
100
PTR_ADDIU
"%[c_bytestream], %[c_bytestream], 0X02 \n\t"
101
"1: \n\t"
102
: [bit]
"=&r"
(bit), [tmp0]
"=&r"
(tmp0), [tmp1]
"=&r"
(tmp1), [tmp2]
"=&r"
(tmp2),
103
[c_range]
"+&r"
(c->
range
), [c_low]
"+&r"
(c->
low
),
104
[c_bytestream]
"+&r"
(c->
bytestream
)
105
: [state]
"r"
(state), [
tables
]
"r"
(
ff_h264_cabac_tables
),
106
#
if
!
UNCHECKED_BITSTREAM_READER
107
[c_bytestream_end]
"r"
(c->
bytestream_end
),
108
#endif
109
[lps_off]
"i"
(
H264_LPS_RANGE_OFFSET
),
110
[mlps_off]
"i"
(
H264_MLPS_STATE_OFFSET
+ 128),
111
[norm_off]
"i"
(
H264_NORM_SHIFT_OFFSET
),
112
[cabac_mask]
"i"
(
CABAC_MASK
)
113
:
"memory"
114
);
115
116
return
bit;
117
}
118
119
#endif
/* AVCODEC_MIPS_CABAC_H */
mips_reg
#define mips_reg
Definition:
asmdefs.h:44
UNCHECKED_BITSTREAM_READER
#define UNCHECKED_BITSTREAM_READER
Definition:
cabac_functions.h:36
CABACContext::bytestream_end
const uint8_t * bytestream_end
Definition:
cabac.h:49
PTR_SLL
#define PTR_SLL
Definition:
asmdefs.h:55
CABACContext::bytestream
const uint8_t * bytestream
Definition:
cabac.h:48
config.h
uint8_t
uint8_t
Definition:
audio_convert.c:194
PTR_ADDI
#define PTR_ADDI
Definition:
asmdefs.h:49
mmiutils.h
PTR_SUBU
#define PTR_SUBU
Definition:
asmdefs.h:50
state
static struct @303 state
CABACContext
Definition:
cabac.h:43
get_cabac_inline
#define get_cabac_inline
Definition:
cabac.h:31
PTR_ADDIU
#define PTR_ADDIU
Definition:
asmdefs.h:48
CABACContext::range
int range
Definition:
cabac.h:45
H264_MLPS_STATE_OFFSET
#define H264_MLPS_STATE_OFFSET
Definition:
cabac.h:37
H264_NORM_SHIFT_OFFSET
#define H264_NORM_SHIFT_OFFSET
Definition:
cabac.h:35
CABACContext::low
int low
Definition:
cabac.h:44
ff_h264_cabac_tables
const uint8_t ff_h264_cabac_tables[512+4 *2 *64+4 *64+63]
c
static double c[64]
Definition:
vsrc_mptestsrc.c:87
tables
static ConstTables tables[2][NB_SUBBANDS]
Definition:
aptx.c:396
PTR_ADDU
#define PTR_ADDU
Definition:
asmdefs.h:47
av_always_inline
#define av_always_inline
Definition:
attributes.h:39
PTR_SRA
#define PTR_SRA
Definition:
asmdefs.h:53
CABAC_MASK
#define CABAC_MASK
Definition:
cabac.h:41
cabac.h
Context Adaptive Binary Arithmetic Coder.
H264_LPS_RANGE_OFFSET
#define H264_LPS_RANGE_OFFSET
Definition:
cabac.h:36
Generated on Tue Nov 6 2018 18:11:00 for FFmpeg by
1.8.6