Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
x264
Commits
bf749f76
Commit
bf749f76
authored
Apr 08, 2009
by
Fiona Glaser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CAVLC optimizations
faster bs_write_te, port CABAC context selection optimization to CAVLC.
parent
be3c3d21
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
19 deletions
+24
-19
common/bs.h
common/bs.h
+2
-4
encoder/analyse.c
encoder/analyse.c
+1
-1
encoder/cavlc.c
encoder/cavlc.c
+21
-14
No files found.
common/bs.h
View file @
bf749f76
...
...
@@ -233,7 +233,7 @@ static inline void bs_write_te( bs_t *s, int x, int val )
{
if
(
x
==
1
)
bs_write1
(
s
,
1
^
val
);
else
if
(
x
>
1
)
else
//
if( x > 1 )
bs_write_ue
(
s
,
val
);
}
...
...
@@ -265,10 +265,8 @@ static inline int bs_size_te( int x, int val )
{
if
(
x
==
1
)
return
1
;
else
if
(
x
>
1
)
else
//
if( x > 1 )
return
x264_ue_size_tab
[
val
+
1
];
else
return
0
;
}
#endif
encoder/analyse.c
View file @
bf749f76
...
...
@@ -195,7 +195,7 @@ static void x264_mb_analyse_load_costs( x264_t *h, x264_mb_analysis_t *a )
}
for
(
i
=
0
;
i
<
3
;
i
++
)
for
(
j
=
0
;
j
<
33
;
j
++
)
x264_cost_ref
[
a
->
i_qp
][
i
][
j
]
=
a
->
i_lambda
*
bs_size_te
(
i
,
j
);
x264_cost_ref
[
a
->
i_qp
][
i
][
j
]
=
i
?
a
->
i_lambda
*
bs_size_te
(
i
,
j
)
:
0
;
}
a
->
p_cost_mv
=
p_cost_mv
[
a
->
i_qp
];
a
->
p_cost_ref0
=
x264_cost_ref
[
a
->
i_qp
][
x264_clip3
(
h
->
sh
.
i_num_ref_idx_l0_active
-
1
,
0
,
2
)];
...
...
encoder/cavlc.c
View file @
bf749f76
...
...
@@ -112,16 +112,13 @@ static inline int block_residual_write_cavlc_escape( x264_t *h, bs_t *s, int i_s
return
i_suffix_length
;
}
static
void
block_residual_write_cavlc
(
x264_t
*
h
,
bs_t
*
s
,
int
i_ctxBlockCat
,
int
i_idx
,
int16_t
*
l
,
int
i_count
)
static
void
block_residual_write_cavlc
(
x264_t
*
h
,
bs_t
*
s
,
int
i_ctxBlockCat
,
int
i_idx
,
int16_t
*
l
,
int
i_count
,
int
nC
)
{
static
const
uint8_t
ct_index
[
17
]
=
{
0
,
0
,
1
,
1
,
2
,
2
,
2
,
2
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
};
static
const
uint8_t
ctz_index
[
8
]
=
{
3
,
0
,
1
,
0
,
2
,
0
,
1
,
0
};
x264_run_level_t
runlevel
;
int
i_trailing
,
i_total_zero
,
i_suffix_length
,
i
;
int
i_total
=
0
;
unsigned
int
i_sign
;
/* x264_mb_predict_non_zero_code return 0 <-> (16+16+1)>>1 = 16 */
int
nC
=
i_idx
>=
25
?
4
:
ct_index
[
x264_mb_predict_non_zero_code
(
h
,
i_idx
==
24
?
0
:
i_idx
)];
if
(
!
h
->
mb
.
cache
.
non_zero_count
[
x264_scan8
[
i_idx
]]
)
{
...
...
@@ -198,6 +195,14 @@ static void block_residual_write_cavlc( x264_t *h, bs_t *s, int i_ctxBlockCat, i
}
}
static
const
uint8_t
ct_index
[
17
]
=
{
0
,
0
,
1
,
1
,
2
,
2
,
2
,
2
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
};
#define block_residual_write_cavlc(h,s,cat,idx,l,count)\
{\
int nC = cat == DCT_CHROMA_DC ? 4 : ct_index[x264_mb_predict_non_zero_code( h, cat == DCT_LUMA_DC ? 0 : idx )];\
block_residual_write_cavlc(h,s,cat,idx,l,count,nC);\
}
static
void
cavlc_qp_delta
(
x264_t
*
h
,
bs_t
*
s
)
{
int
i_dqp
=
h
->
mb
.
i_qp
-
h
->
mb
.
i_last_qp
;
...
...
@@ -319,7 +324,7 @@ void x264_macroblock_write_cavlc( x264_t *h, bs_t *s )
}
#if !RDO_SKIP_BS
if
(
i_mb_type
==
I_PCM
)
if
(
i_mb_type
==
I_PCM
)
{
bs_write_ue
(
s
,
i_mb_i_offset
+
25
);
i_mb_pos_tex
=
bs_pos
(
s
);
...
...
@@ -382,7 +387,7 @@ void x264_macroblock_write_cavlc( x264_t *h, bs_t *s )
if
(
h
->
mb
.
i_partition
==
D_16x16
)
{
bs_write
_ue
(
s
,
0
);
bs_write
1
(
s
,
1
);
if
(
h
->
mb
.
pic
.
i_fref
[
0
]
>
1
)
bs_write_te
(
s
,
h
->
mb
.
pic
.
i_fref
[
0
]
-
1
,
h
->
mb
.
cache
.
ref
[
0
][
x264_scan8
[
0
]]
);
...
...
@@ -437,7 +442,7 @@ void x264_macroblock_write_cavlc( x264_t *h, bs_t *s )
else
{
bs_write_ue
(
s
,
3
);
b_sub_ref
=
h
->
mb
.
pic
.
i_fref
[
0
]
>
1
;
b_sub_ref
=
1
;
}
/* sub mb type */
...
...
@@ -468,12 +473,14 @@ void x264_macroblock_write_cavlc( x264_t *h, bs_t *s )
bs_write_ue
(
s
,
sub_mb_type_b_to_golomb
[
h
->
mb
.
i_sub_partition
[
i
]
]
);
/* ref */
for
(
i
=
0
;
i
<
4
;
i
++
)
if
(
x264_mb_partition_listX_table
[
0
][
h
->
mb
.
i_sub_partition
[
i
]
]
)
bs_write_te
(
s
,
h
->
mb
.
pic
.
i_fref
[
0
]
-
1
,
h
->
mb
.
cache
.
ref
[
0
][
x264_scan8
[
i
*
4
]]
);
for
(
i
=
0
;
i
<
4
;
i
++
)
if
(
x264_mb_partition_listX_table
[
1
][
h
->
mb
.
i_sub_partition
[
i
]
]
)
bs_write_te
(
s
,
h
->
mb
.
pic
.
i_fref
[
1
]
-
1
,
h
->
mb
.
cache
.
ref
[
1
][
x264_scan8
[
i
*
4
]]
);
if
(
h
->
mb
.
pic
.
i_fref
[
0
]
>
1
)
for
(
i
=
0
;
i
<
4
;
i
++
)
if
(
x264_mb_partition_listX_table
[
0
][
h
->
mb
.
i_sub_partition
[
i
]
]
)
bs_write_te
(
s
,
h
->
mb
.
pic
.
i_fref
[
0
]
-
1
,
h
->
mb
.
cache
.
ref
[
0
][
x264_scan8
[
i
*
4
]]
);
if
(
h
->
mb
.
pic
.
i_fref
[
1
]
>
1
)
for
(
i
=
0
;
i
<
4
;
i
++
)
if
(
x264_mb_partition_listX_table
[
1
][
h
->
mb
.
i_sub_partition
[
i
]
]
)
bs_write_te
(
s
,
h
->
mb
.
pic
.
i_fref
[
1
]
-
1
,
h
->
mb
.
cache
.
ref
[
1
][
x264_scan8
[
i
*
4
]]
);
/* mvd */
for
(
i
=
0
;
i
<
4
;
i
++
)
...
...
@@ -555,7 +562,7 @@ void x264_macroblock_write_cavlc( x264_t *h, bs_t *s )
}
}
else
if
(
i_mb_type
==
B_DIRECT
)
bs_write
_ue
(
s
,
0
);
bs_write
1
(
s
,
1
);
else
{
x264_log
(
h
,
X264_LOG_ERROR
,
"invalid/unhandled mb_type
\n
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment