Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
b4356c9c
Commit
b4356c9c
authored
Mar 21, 2014
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/ratecontrol: make (mc_)mb_var_sum(_last) 64bit
This avoids hypothetical integer overflows
parent
e92a78a4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
ratecontrol.c
libavcodec/ratecontrol.c
+6
-5
ratecontrol.h
libavcodec/ratecontrol.h
+4
-4
No files found.
libavcodec/ratecontrol.c
View file @
b4356c9c
...
@@ -207,7 +207,7 @@ av_cold int ff_rate_control_init(MpegEncContext *s)
...
@@ -207,7 +207,7 @@ av_cold int ff_rate_control_init(MpegEncContext *s)
assert
(
picture_number
<
rcc
->
num_entries
);
assert
(
picture_number
<
rcc
->
num_entries
);
rce
=
&
rcc
->
entry
[
picture_number
];
rce
=
&
rcc
->
entry
[
picture_number
];
e
+=
sscanf
(
p
,
" in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%
d var:%d
icount:%d skipcount:%d hbits:%d"
,
e
+=
sscanf
(
p
,
" in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%
"
SCNd64
" var:%"
SCNd64
"
icount:%d skipcount:%d hbits:%d"
,
&
rce
->
pict_type
,
&
rce
->
qscale
,
&
rce
->
i_tex_bits
,
&
rce
->
p_tex_bits
,
&
rce
->
pict_type
,
&
rce
->
qscale
,
&
rce
->
i_tex_bits
,
&
rce
->
p_tex_bits
,
&
rce
->
mv_bits
,
&
rce
->
misc_bits
,
&
rce
->
mv_bits
,
&
rce
->
misc_bits
,
&
rce
->
f_code
,
&
rce
->
b_code
,
&
rce
->
f_code
,
&
rce
->
b_code
,
...
@@ -754,7 +754,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
...
@@ -754,7 +754,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
RateControlEntry
local_rce
,
*
rce
;
RateControlEntry
local_rce
,
*
rce
;
double
bits
;
double
bits
;
double
rate_factor
;
double
rate_factor
;
int
var
;
int
64_t
var
;
const
int
pict_type
=
s
->
pict_type
;
const
int
pict_type
=
s
->
pict_type
;
Picture
*
const
pic
=
&
s
->
current_picture
;
Picture
*
const
pic
=
&
s
->
current_picture
;
emms_c
();
emms_c
();
...
@@ -770,7 +770,8 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
...
@@ -770,7 +770,8 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
fps
=
get_fps
(
s
->
avctx
);
fps
=
get_fps
(
s
->
avctx
);
/* update predictors */
/* update predictors */
if
(
picture_number
>
2
&&
!
dry_run
)
{
if
(
picture_number
>
2
&&
!
dry_run
)
{
const
int
last_var
=
s
->
last_pict_type
==
AV_PICTURE_TYPE_I
?
rcc
->
last_mb_var_sum
const
int64_t
last_var
=
s
->
last_pict_type
==
AV_PICTURE_TYPE_I
?
rcc
->
last_mb_var_sum
:
rcc
->
last_mc_mb_var_sum
;
:
rcc
->
last_mc_mb_var_sum
;
av_assert1
(
s
->
frame_bits
>=
s
->
stuffing_bits
);
av_assert1
(
s
->
frame_bits
>=
s
->
stuffing_bits
);
update_predictor
(
&
rcc
->
pred
[
s
->
last_pict_type
],
update_predictor
(
&
rcc
->
pred
[
s
->
last_pict_type
],
...
@@ -818,7 +819,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
...
@@ -818,7 +819,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
assert
(
pict_type
==
rce
->
new_pict_type
);
assert
(
pict_type
==
rce
->
new_pict_type
);
q
=
rce
->
new_qscale
/
br_compensation
;
q
=
rce
->
new_qscale
/
br_compensation
;
av_dlog
(
s
,
"%f %f %f last:%d var:%
d
type:%d//
\n
"
,
q
,
rce
->
new_qscale
,
av_dlog
(
s
,
"%f %f %f last:%d var:%
"
PRId64
"
type:%d//
\n
"
,
q
,
rce
->
new_qscale
,
br_compensation
,
s
->
frame_bits
,
var
,
pict_type
);
br_compensation
,
s
->
frame_bits
,
var
,
pict_type
);
}
else
{
}
else
{
rce
->
pict_type
=
rce
->
pict_type
=
...
...
libavcodec/ratecontrol.h
View file @
b4356c9c
...
@@ -49,8 +49,8 @@ typedef struct RateControlEntry{
...
@@ -49,8 +49,8 @@ typedef struct RateControlEntry{
uint64_t
expected_bits
;
uint64_t
expected_bits
;
int
new_pict_type
;
int
new_pict_type
;
float
new_qscale
;
float
new_qscale
;
int
mc_mb_var_sum
;
int
64_t
mc_mb_var_sum
;
int
mb_var_sum
;
int
64_t
mb_var_sum
;
int
i_count
;
int
i_count
;
int
skip_count
;
int
skip_count
;
int
f_code
;
int
f_code
;
...
@@ -71,8 +71,8 @@ typedef struct RateControlContext{
...
@@ -71,8 +71,8 @@ typedef struct RateControlContext{
double
pass1_wanted_bits
;
///< bits which should have been outputed by the pass1 code (including complexity init)
double
pass1_wanted_bits
;
///< bits which should have been outputed by the pass1 code (including complexity init)
double
last_qscale
;
double
last_qscale
;
double
last_qscale_for
[
5
];
///< last qscale for a specific pict type, used for max_diff & ipb factor stuff
double
last_qscale_for
[
5
];
///< last qscale for a specific pict type, used for max_diff & ipb factor stuff
int
last_mc_mb_var_sum
;
int
64_t
last_mc_mb_var_sum
;
int
last_mb_var_sum
;
int
64_t
last_mb_var_sum
;
uint64_t
i_cplx_sum
[
5
];
uint64_t
i_cplx_sum
[
5
];
uint64_t
p_cplx_sum
[
5
];
uint64_t
p_cplx_sum
[
5
];
uint64_t
mv_bits_sum
[
5
];
uint64_t
mv_bits_sum
[
5
];
...
...
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