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
2f5feea4
Commit
2f5feea4
authored
Apr 11, 2003
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
10l (adaptve quant fix)
Originally committed as revision 1752 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
67cbe681
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
ratecontrol.c
libavcodec/ratecontrol.c
+11
-7
No files found.
libavcodec/ratecontrol.c
View file @
2f5feea4
...
...
@@ -479,17 +479,19 @@ static void adaptive_quantization(MpegEncContext *s, double q){
const
int
qmin
=
s
->
avctx
->
mb_qmin
;
const
int
qmax
=
s
->
avctx
->
mb_qmax
;
Picture
*
const
pic
=
&
s
->
current_picture
;
int
last_qscale
=
0
;
for
(
i
=
0
;
i
<
s
->
mb_num
;
i
++
){
float
temp_cplx
=
sqrt
(
pic
->
mc_mb_var
[
i
]);
float
spat_cplx
=
sqrt
(
pic
->
mb_var
[
i
]);
const
int
lumi
=
pic
->
mb_mean
[
i
];
const
int
mb_xy
=
s
->
mb_index2xy
[
i
];
float
temp_cplx
=
sqrt
(
pic
->
mc_mb_var
[
mb_xy
]);
float
spat_cplx
=
sqrt
(
pic
->
mb_var
[
mb_xy
]);
const
int
lumi
=
pic
->
mb_mean
[
mb_xy
];
float
bits
,
cplx
,
factor
;
if
(
spat_cplx
<
q
/
3
)
spat_cplx
=
q
/
3
;
//FIXME finetune
if
(
temp_cplx
<
q
/
3
)
temp_cplx
=
q
/
3
;
//FIXME finetune
if
((
s
->
mb_type
[
i
]
&
MB_TYPE_INTRA
)){
//FIXME hq mode
if
((
s
->
mb_type
[
mb_xy
]
&
MB_TYPE_INTRA
)){
//FIXME hq mode
cplx
=
spat_cplx
;
factor
=
1
.
0
+
p_masking
;
}
else
{
...
...
@@ -530,6 +532,7 @@ static void adaptive_quantization(MpegEncContext *s, double q){
}
for
(
i
=
0
;
i
<
s
->
mb_num
;
i
++
){
const
int
mb_xy
=
s
->
mb_index2xy
[
i
];
float
newq
=
q
*
cplx_tab
[
i
]
/
bits_tab
[
i
];
int
intq
;
...
...
@@ -537,8 +540,8 @@ static void adaptive_quantization(MpegEncContext *s, double q){
newq
*=
bits_sum
/
cplx_sum
;
}
if
(
i
&&
ABS
(
pic
->
qscale_table
[
i
-
1
]
-
newq
)
<
0
.
75
)
intq
=
pic
->
qscale_table
[
i
-
1
]
;
if
(
i
&&
ABS
(
last_qscale
-
newq
)
<
0
.
75
)
intq
=
last_qscale
;
else
intq
=
(
int
)(
newq
+
0
.
5
);
...
...
@@ -546,7 +549,8 @@ static void adaptive_quantization(MpegEncContext *s, double q){
else
if
(
intq
<
qmin
)
intq
=
qmin
;
//if(i%s->mb_width==0) printf("\n");
//printf("%2d%3d ", intq, ff_sqrt(s->mc_mb_var[i]));
pic
->
qscale_table
[
i
]
=
intq
;
last_qscale
=
pic
->
qscale_table
[
mb_xy
]
=
intq
;
}
}
...
...
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