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
d639dcda
Commit
d639dcda
authored
Jul 20, 2016
by
Vittorio Giovara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ratecontrol: Move Xvid-related functions to the place they are actually used
This will simplify the de-MpegEncContextualization.
parent
44972e22
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
33 deletions
+39
-33
libxvid.h
libavcodec/libxvid.h
+7
-0
mpegvideo_enc.c
libavcodec/mpegvideo_enc.c
+32
-1
ratecontrol.c
libavcodec/ratecontrol.c
+0
-28
ratecontrol.h
libavcodec/ratecontrol.h
+0
-4
No files found.
libavcodec/libxvid.h
View file @
d639dcda
...
...
@@ -28,4 +28,11 @@
int
ff_tempfile
(
const
char
*
prefix
,
char
**
filename
);
struct
MpegEncContext
;
/* rate control */
int
ff_xvid_rate_control_init
(
struct
MpegEncContext
*
s
);
void
ff_xvid_rate_control_uninit
(
struct
MpegEncContext
*
s
);
float
ff_xvid_rate_estimate_qscale
(
struct
MpegEncContext
*
s
,
int
dry_run
);
#endif
/* AVCODEC_LIBXVID_H */
libavcodec/mpegvideo_enc.c
View file @
d639dcda
...
...
@@ -60,6 +60,7 @@
#include "bytestream.h"
#include "wmv2.h"
#include "rv10.h"
#include "libxvid.h"
#include <limits.h>
#define QUANT_BIAS_SHIFT 8
...
...
@@ -871,9 +872,28 @@ FF_ENABLE_DEPRECATION_WARNINGS
31
,
0
);
}
#if FF_API_RC_STRATEGY
FF_DISABLE_DEPRECATION_WARNINGS
if
(
!
s
->
rc_strategy
)
s
->
rc_strategy
=
s
->
avctx
->
rc_strategy
;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if
(
ff_rate_control_init
(
s
)
<
0
)
return
-
1
;
if
((
s
->
avctx
->
flags
&
AV_CODEC_FLAG_PASS2
)
&&
s
->
rc_strategy
==
1
)
{
#if CONFIG_LIBXVID
ret
=
ff_xvid_rate_control_init
(
s
);
#else
ret
=
AVERROR
(
ENOSYS
);
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Xvid ratecontrol requires libavcodec compiled with Xvid support.
\n
"
);
#endif
if
(
ret
<
0
)
return
ret
;
}
#if FF_API_ERROR_RATE
FF_DISABLE_DEPRECATION_WARNINGS
if
(
avctx
->
error_rate
)
...
...
@@ -967,6 +987,10 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
int
i
;
ff_rate_control_uninit
(
s
);
#if CONFIG_LIBXVID
if
((
avctx
->
flags
&
AV_CODEC_FLAG_PASS2
)
&&
s
->
rc_strategy
==
1
)
ff_xvid_rate_control_uninit
(
s
);
#endif
ff_mpv_common_end
(
s
);
if
(
CONFIG_MJPEG_ENCODER
&&
...
...
@@ -3385,8 +3409,15 @@ static int estimate_qp(MpegEncContext *s, int dry_run){
s
->
current_picture
.
f
->
quality
=
s
->
next_lambda
;
if
(
!
dry_run
)
s
->
next_lambda
=
0
;
}
else
if
(
!
s
->
fixed_qscale
)
{
int
quality
;
#if CONFIG_LIBXVID
if
((
s
->
avctx
->
flags
&
AV_CODEC_FLAG_PASS2
)
&&
s
->
rc_strategy
==
1
)
quality
=
ff_xvid_rate_estimate_qscale
(
s
,
dry_run
);
else
#endif
quality
=
ff_rate_estimate_qscale
(
s
,
dry_run
);
s
->
current_picture_ptr
->
f
->
quality
=
s
->
current_picture
.
f
->
quality
=
ff_rate_estimate_qscale
(
s
,
dry_run
)
;
s
->
current_picture
.
f
->
quality
=
quality
;
if
(
s
->
current_picture
.
f
->
quality
<
0
)
return
-
1
;
}
...
...
libavcodec/ratecontrol.c
View file @
d639dcda
...
...
@@ -110,13 +110,6 @@ av_cold int ff_rate_control_init(MpegEncContext *s)
return
res
;
}
#if FF_API_RC_STRATEGY
FF_DISABLE_DEPRECATION_WARNINGS
if
(
!
s
->
rc_strategy
)
s
->
rc_strategy
=
s
->
avctx
->
rc_strategy
;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
for
(
i
=
0
;
i
<
5
;
i
++
)
{
rcc
->
pred
[
i
].
coeff
=
FF_QP2LAMBDA
*
7
.
0
;
rcc
->
pred
[
i
].
count
=
1
.
0
;
...
...
@@ -198,17 +191,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
ff_rate_control_uninit
(
s
);
return
-
1
;
}
// FIXME maybe move to end
if
((
s
->
avctx
->
flags
&
AV_CODEC_FLAG_PASS2
)
&&
s
->
rc_strategy
==
1
)
{
#if CONFIG_LIBXVID
return
ff_xvid_rate_control_init
(
s
);
#else
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Xvid ratecontrol requires libavcodec compiled with Xvid support.
\n
"
);
return
-
1
;
#endif
}
}
if
(
!
(
s
->
avctx
->
flags
&
AV_CODEC_FLAG_PASS2
))
{
...
...
@@ -278,11 +260,6 @@ av_cold void ff_rate_control_uninit(MpegEncContext *s)
av_expr_free
(
rcc
->
rc_eq_eval
);
av_freep
(
&
rcc
->
entry
);
#if CONFIG_LIBXVID
if
((
s
->
avctx
->
flags
&
AV_CODEC_FLAG_PASS2
)
&&
s
->
rc_strategy
==
1
)
ff_xvid_rate_control_uninit
(
s
);
#endif
}
int
ff_vbv_update
(
MpegEncContext
*
s
,
int
frame_size
)
...
...
@@ -723,11 +700,6 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
Picture
*
const
pic
=
&
s
->
current_picture
;
emms_c
();
#if CONFIG_LIBXVID
if
((
s
->
avctx
->
flags
&
AV_CODEC_FLAG_PASS2
)
&&
s
->
rc_strategy
==
1
)
return
ff_xvid_rate_estimate_qscale
(
s
,
dry_run
);
#endif
get_qminmax
(
&
qmin
,
&
qmax
,
s
,
pict_type
);
fps
=
1
/
av_q2d
(
s
->
avctx
->
time_base
);
...
...
libavcodec/ratecontrol.h
View file @
d639dcda
...
...
@@ -95,8 +95,4 @@ void ff_rate_control_uninit(struct MpegEncContext *s);
int
ff_vbv_update
(
struct
MpegEncContext
*
s
,
int
frame_size
);
void
ff_get_2pass_fcode
(
struct
MpegEncContext
*
s
);
int
ff_xvid_rate_control_init
(
struct
MpegEncContext
*
s
);
void
ff_xvid_rate_control_uninit
(
struct
MpegEncContext
*
s
);
float
ff_xvid_rate_estimate_qscale
(
struct
MpegEncContext
*
s
,
int
dry_run
);
#endif
/* AVCODEC_RATECONTROL_H */
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