Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
X
x264
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bUd
x264
Commits
3a08e36e
Commit
3a08e36e
authored
3 years ago
by
Anton Mitrofanov
Committed by
Anton Mitrofanov
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix integer overflow in cabac psy-trellis
parent
6c142bba
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
encoder/rdo.c
+7
-6
7 additions, 6 deletions
encoder/rdo.c
with
7 additions
and
6 deletions
encoder/rdo.c
+
7
−
6
View file @
3a08e36e
...
...
@@ -471,7 +471,7 @@ int trellis_dc_shortcut( int sign_coef, int quant_coef, int unquant_mf, int coef
/* Optimize rounding for DC coefficients in DC-only luma 4x4/8x8 blocks. */
int
d
=
sign_coef
-
((
SIGN
(
unquant_abs_level
,
sign_coef
)
+
8
)
&~
15
);
uint64_t
score
=
(
u
int64_t
)
d
*
d
*
coef_weight
;
uint64_t
score
=
(
int64_t
)
d
*
d
*
coef_weight
;
/* code the proposed level, and count how much entropy it would take */
if
(
abs_level
)
...
...
@@ -734,11 +734,11 @@ int quant_trellis_cabac( x264_t *h, dctcoef *dct,
trellis_level_t
level_tree
[
64
*
8
*
2
];
int
levels_used
=
1
;
/* init trellis */
trellis_node_t
nodes
[
2
][
8
];
trellis_node_t
nodes
[
2
][
8
]
=
{
0
}
;
trellis_node_t
*
nodes_cur
=
nodes
[
0
];
trellis_node_t
*
nodes_prev
=
nodes
[
1
];
trellis_node_t
*
bnode
;
for
(
int
j
=
1
;
j
<
4
;
j
++
)
for
(
int
j
=
1
;
j
<
8
;
j
++
)
nodes_cur
[
j
].
score
=
TRELLIS_SCORE_MAX
;
nodes_cur
[
0
].
score
=
TRELLIS_SCORE_BIAS
;
nodes_cur
[
0
].
level_idx
=
0
;
...
...
@@ -825,17 +825,18 @@ int quant_trellis_cabac( x264_t *h, dctcoef *dct,
int predicted_coef = orig_coef - sign_coef;\
int psy_value = abs(unquant_abs_level + SIGN(predicted_coef, sign_coef));\
int psy_weight = coef_weight1[zigzag[i]] * h->mb.i_psy_trellis;\
ssd1[k] = (uint64_t)d*d * coef_weight2[zigzag[i]] - psy_weight * psy_value;\
int64_t tmp = (int64_t)d*d * coef_weight2[zigzag[i]] - (int64_t)psy_weight * psy_value;\
ssd1[k] = (uint64_t)tmp;\
}\
else\
/* FIXME: for i16x16 dc is this weight optimal? */
\
ssd1[k] = (
u
int64_t)d*d * (dc?256:coef_weight2[zigzag[i]]);\
ssd1[k] = (int64_t)d*d * (dc?256:coef_weight2[zigzag[i]]);\
ssd0[k] = ssd1[k];\
if( !i && !dc && !ctx_hi )\
{\
/* Optimize rounding for DC coefficients in DC-only luma 4x4/8x8 blocks. */
\
d = sign_coef - ((SIGN(unquant_abs_level, sign_coef) + 8)&~15);\
ssd0[k] = (
u
int64_t)d*d * coef_weight2[zigzag[i]];\
ssd0[k] = (int64_t)d*d * coef_weight2[zigzag[i]];\
}\
}\
\
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment