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
78520340
Commit
78520340
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 cavlc trellis
parent
3a08e36e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/vlc.c
+1
-1
1 addition, 1 deletion
common/vlc.c
encoder/rdo.c
+5
-5
5 additions, 5 deletions
encoder/rdo.c
with
6 additions
and
6 deletions
common/vlc.c
+
1
−
1
View file @
78520340
...
...
@@ -37,7 +37,7 @@ void x264_cavlc_init( x264_t *h )
{
int
mask
=
level
>>
15
;
int
abs_level
=
(
level
^
mask
)
-
mask
;
int
i_level_code
=
abs_level
*
2
-
mask
-
2
;
int
i_level_code
=
abs_level
?
abs_level
*
2
-
mask
-
2
:
0
;
int
i_next
=
i_suffix
;
vlc_large_t
*
vlc
=
&
x264_level_token
[
i_suffix
][
level
+
LEVEL_TABLE_SIZE
/
2
];
...
...
This diff is collapsed.
Click to expand it.
encoder/rdo.c
+
5
−
5
View file @
78520340
...
...
@@ -927,7 +927,7 @@ int quant_trellis_cavlc( x264_t *h, dctcoef *dct,
ALIGNED_ARRAY_16
(
dctcoef
,
coefs
,[
16
]
);
const
uint32_t
*
coef_weight1
=
b_8x8
?
x264_dct8_weight_tab
:
x264_dct4_weight_tab
;
const
uint32_t
*
coef_weight2
=
b_8x8
?
x264_dct8_weight2_tab
:
x264_dct4_weight2_tab
;
int
delta_distortion
[
16
];
int
64_t
delta_distortion
[
16
];
int64_t
score
=
1ULL
<<
62
;
int
i
,
j
;
const
int
f
=
1
<<
15
;
...
...
@@ -954,7 +954,7 @@ int quant_trellis_cavlc( x264_t *h, dctcoef *dct,
/* Find last non-zero coefficient. */
for
(
i
=
end
;
i
>=
start
;
i
-=
step
)
if
(
(
unsigned
)
(
dct
[
zigzag
[
i
]]
*
(
dc
?
quant_mf
[
0
]
>>
1
:
quant_mf
[
zigzag
[
i
]])
+
f
-
1
)
>=
2
*
f
)
if
(
abs
(
dct
[
zigzag
[
i
]]
)
*
(
dc
?
quant_mf
[
0
]
>>
1
:
quant_mf
[
zigzag
[
i
]])
>=
f
)
break
;
if
(
i
<
start
)
...
...
@@ -987,7 +987,7 @@ int quant_trellis_cavlc( x264_t *h, dctcoef *dct,
int
unquant0
=
(((
dc
?
unquant_mf
[
0
]
<<
1
:
unquant_mf
[
zigzag
[
j
]])
*
(
nearest_quant
-
1
)
+
128
)
>>
8
);
int
d1
=
abs_coef
-
unquant1
;
int
d0
=
abs_coef
-
unquant0
;
delta_distortion
[
i
]
=
(
d0
*
d0
-
d1
*
d1
)
*
(
dc
?
256
:
coef_weight2
[
zigzag
[
j
]]);
delta_distortion
[
i
]
=
(
int64_t
)
(
d0
*
d0
-
d1
*
d1
)
*
(
dc
?
256
:
coef_weight2
[
zigzag
[
j
]]);
/* Psy trellis: bias in favor of higher AC coefficients in the reconstructed frame. */
if
(
h
->
mb
.
i_psy_trellis
&&
j
&&
!
dc
&&
!
b_chroma
)
...
...
@@ -1025,7 +1025,7 @@ int quant_trellis_cavlc( x264_t *h, dctcoef *dct,
while
(
1
)
{
int64_t
iter_score
=
score
;
int
iter_distortion_delta
=
0
;
int
64_t
iter_distortion_delta
=
0
;
int
iter_coef
=
-
1
;
int
iter_mask
=
coef_mask
;
int
iter_round
=
round_mask
;
...
...
@@ -1040,7 +1040,7 @@ int quant_trellis_cavlc( x264_t *h, dctcoef *dct,
int
old_coef
=
coefs
[
i
];
int
new_coef
=
quant_coefs
[
round_change
][
i
];
int
cur_mask
=
(
coef_mask
&~
(
1
<<
i
))
|
(
!!
new_coef
<<
i
);
int
cur_distortion_delta
=
delta_distortion
[
i
]
*
(
round_change
?
-
1
:
1
);
int
64_t
cur_distortion_delta
=
delta_distortion
[
i
]
*
(
round_change
?
-
1
:
1
);
int64_t
cur_score
=
cur_distortion_delta
;
coefs
[
i
]
=
new_coef
;
...
...
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