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
66a68ddd
Commit
66a68ddd
authored
Oct 27, 2013
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavc: make rc_buffer_aggressivity/rc_initial_cplx into private options of mpegvideo encoders
parent
a75c2eb2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
13 deletions
+27
-13
avcodec.h
libavcodec/avcodec.h
+7
-5
mpegvideo.h
libavcodec/mpegvideo.h
+5
-1
mpegvideo_enc.c
libavcodec/mpegvideo_enc.c
+4
-0
options_table.h
libavcodec/options_table.h
+6
-2
ratecontrol.c
libavcodec/ratecontrol.c
+5
-5
No files found.
libavcodec/avcodec.h
View file @
66a68ddd
...
...
@@ -2132,14 +2132,16 @@ typedef struct AVCodecContext {
*/
int
rc_min_rate
;
float
rc_buffer_aggressivity
;
#if FF_API_MPV_OPT
/**
* initial complexity for pass1 ratecontrol
* - encoding: Set by user.
* - decoding: unused
* @deprecated use encoder private options instead
*/
attribute_deprecated
float
rc_buffer_aggressivity
;
attribute_deprecated
float
rc_initial_cplx
;
#endif
/**
* Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
...
...
libavcodec/mpegvideo.h
View file @
66a68ddd
...
...
@@ -637,6 +637,8 @@ typedef struct MpegEncContext {
float
rc_qsquish
;
float
rc_qmod_amp
;
int
rc_qmod_freq
;
float
rc_initial_cplx
;
float
rc_buffer_aggressivity
;
char
*
rc_eq
;
...
...
@@ -693,7 +695,9 @@ typedef struct MpegEncContext {
"defined in the section 'Expression Evaluation', the following functions are available: " \
"bits2qp(bits), qp2bits(qp). Also the following constants are available: iTex pTex tex mv " \
"fCode iCount mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex avgTex.", \
FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING, .flags = FF_MPV_OPT_FLAGS },
FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING, .flags = FF_MPV_OPT_FLAGS }, \
{"rc_init_cplx", "initial complexity for 1-pass encoding", FF_MPV_OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \
{"rc_buf_aggressivity", "currently useless", FF_MPV_OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \
extern
const
AVOption
ff_mpv_generic_options
[];
...
...
libavcodec/mpegvideo_enc.c
View file @
66a68ddd
...
...
@@ -830,6 +830,10 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
s
->
rc_qmod_amp
=
avctx
->
rc_qmod_amp
;
if
(
avctx
->
rc_qmod_freq
)
s
->
rc_qmod_freq
=
avctx
->
rc_qmod_freq
;
if
(
avctx
->
rc_buffer_aggressivity
!=
1
.
0
)
s
->
rc_buffer_aggressivity
=
avctx
->
rc_buffer_aggressivity
;
if
(
avctx
->
rc_initial_cplx
!=
0
.
0
)
s
->
rc_initial_cplx
=
avctx
->
rc_initial_cplx
;
if
(
avctx
->
rc_eq
)
{
av_freep
(
&
s
->
rc_eq
);
...
...
libavcodec/options_table.h
View file @
66a68ddd
...
...
@@ -176,10 +176,14 @@ static const AVOption avcodec_options[] = {
{
"minrate"
,
"Set minimum bitrate tolerance (in bits/s). Most useful in setting up a CBR encode. It is of little use otherwise."
,
OFFSET
(
rc_min_rate
),
AV_OPT_TYPE_INT
,
{.
i64
=
DEFAULT
},
INT_MIN
,
INT_MAX
,
V
|
A
|
E
},
{
"bufsize"
,
"set ratecontrol buffer size (in bits)"
,
OFFSET
(
rc_buffer_size
),
AV_OPT_TYPE_INT
,
{.
i64
=
DEFAULT
},
INT_MIN
,
INT_MAX
,
A
|
V
|
E
},
{
"rc_buf_aggressivity"
,
"currently useless"
,
OFFSET
(
rc_buffer_aggressivity
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
1
.
0
},
-
FLT_MAX
,
FLT_MAX
,
V
|
E
},
#if FF_API_MPV_OPT
{
"rc_buf_aggressivity"
,
"deprecated, use encoder private options instead"
,
OFFSET
(
rc_buffer_aggressivity
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
1
.
0
},
-
FLT_MAX
,
FLT_MAX
,
V
|
E
},
#endif
{
"i_qfactor"
,
"QP factor between P- and I-frames"
,
OFFSET
(
i_quant_factor
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
-
0
.
8
},
-
FLT_MAX
,
FLT_MAX
,
V
|
E
},
{
"i_qoffset"
,
"QP offset between P- and I-frames"
,
OFFSET
(
i_quant_offset
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
0
.
0
},
-
FLT_MAX
,
FLT_MAX
,
V
|
E
},
{
"rc_init_cplx"
,
"initial complexity for 1-pass encoding"
,
OFFSET
(
rc_initial_cplx
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
DEFAULT
},
-
FLT_MAX
,
FLT_MAX
,
V
|
E
},
#if FF_API_MPV_OPT
{
"rc_init_cplx"
,
"deprecated, use encoder private options instead"
,
OFFSET
(
rc_initial_cplx
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
DEFAULT
},
-
FLT_MAX
,
FLT_MAX
,
V
|
E
},
#endif
{
"dct"
,
"DCT algorithm"
,
OFFSET
(
dct_algo
),
AV_OPT_TYPE_INT
,
{.
i64
=
DEFAULT
},
0
,
INT_MAX
,
V
|
E
,
"dct"
},
{
"auto"
,
"autoselect a good one (default)"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
FF_DCT_AUTO
},
INT_MIN
,
INT_MAX
,
V
|
E
,
"dct"
},
{
"fastint"
,
"fast integer"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
FF_DCT_FASTINT
},
INT_MIN
,
INT_MAX
,
V
|
E
,
"dct"
},
...
...
libavcodec/ratecontrol.c
View file @
66a68ddd
...
...
@@ -236,9 +236,9 @@ av_cold int ff_rate_control_init(MpegEncContext *s)
return
-
1
;
}
/* init stuff with the user specified complexity */
if
(
s
->
avctx
->
rc_initial_cplx
)
{
if
(
s
->
rc_initial_cplx
)
{
for
(
i
=
0
;
i
<
60
*
30
;
i
++
)
{
double
bits
=
s
->
avctx
->
rc_initial_cplx
*
(
i
/
10000
.
0
+
1
.
0
)
*
s
->
mb_num
;
double
bits
=
s
->
rc_initial_cplx
*
(
i
/
10000
.
0
+
1
.
0
)
*
s
->
mb_num
;
RateControlEntry
rce
;
if
(
i
%
((
s
->
gop_size
+
3
)
/
4
)
==
0
)
...
...
@@ -516,7 +516,7 @@ static double modify_qscale(MpegEncContext *s, RateControlEntry *rce,
d
=
1
.
0
;
else
if
(
d
<
0
.
0001
)
d
=
0
.
0001
;
q
*=
pow
(
d
,
1
.
0
/
s
->
avctx
->
rc_buffer_aggressivity
);
q
*=
pow
(
d
,
1
.
0
/
s
->
rc_buffer_aggressivity
);
q_limit
=
bits2qp
(
rce
,
FFMAX
((
min_rate
-
buffer_size
+
rcc
->
buffer_index
)
*
...
...
@@ -536,7 +536,7 @@ static double modify_qscale(MpegEncContext *s, RateControlEntry *rce,
d
=
1
.
0
;
else
if
(
d
<
0
.
0001
)
d
=
0
.
0001
;
q
/=
pow
(
d
,
1
.
0
/
s
->
avctx
->
rc_buffer_aggressivity
);
q
/=
pow
(
d
,
1
.
0
/
s
->
rc_buffer_aggressivity
);
q_limit
=
bits2qp
(
rce
,
FFMAX
(
rcc
->
buffer_index
*
...
...
@@ -552,7 +552,7 @@ static double modify_qscale(MpegEncContext *s, RateControlEntry *rce,
}
av_dlog
(
s
,
"q:%f max:%f min:%f size:%f index:%f agr:%f
\n
"
,
q
,
max_rate
,
min_rate
,
buffer_size
,
rcc
->
buffer_index
,
s
->
avctx
->
rc_buffer_aggressivity
);
s
->
rc_buffer_aggressivity
);
if
(
s
->
rc_qsquish
==
0
.
0
||
qmin
==
qmax
)
{
if
(
q
<
qmin
)
q
=
qmin
;
...
...
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