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
ff71a383
Commit
ff71a383
authored
Feb 27, 2012
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mpegvideo_enc: add qp_rd flag to mpv_flags.
Deprecate CODEC_FLAG_QP_RD.
parent
a249f0cc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
12 deletions
+21
-12
avcodec.h
libavcodec/avcodec.h
+1
-1
mpegvideo.h
libavcodec/mpegvideo.h
+3
-1
mpegvideo_enc.c
libavcodec/mpegvideo_enc.c
+11
-6
options.c
libavcodec/options.c
+3
-1
codec-regression.sh
tests/codec-regression.sh
+3
-3
No files found.
libavcodec/avcodec.h
View file @
ff71a383
...
@@ -562,7 +562,6 @@ typedef struct RcOverride{
...
@@ -562,7 +562,6 @@ typedef struct RcOverride{
/* Fx : Flag for h263+ extra options */
/* Fx : Flag for h263+ extra options */
#define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
#define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
#define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp.
#define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp.
#define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon.
#define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
#define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
#define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
#define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
#define CODEC_FLAG_CLOSED_GOP 0x80000000
#define CODEC_FLAG_CLOSED_GOP 0x80000000
...
@@ -570,6 +569,7 @@ typedef struct RcOverride{
...
@@ -570,6 +569,7 @@ typedef struct RcOverride{
#define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
#define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
#define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
#define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
#if FF_API_MPV_GLOBAL_OPTS
#if FF_API_MPV_GLOBAL_OPTS
#define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon.
#define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size.
#define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size.
#define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping
#define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping
#endif
#endif
...
...
libavcodec/mpegvideo.h
View file @
ff71a383
...
@@ -701,13 +701,15 @@ typedef struct MpegEncContext {
...
@@ -701,13 +701,15 @@ typedef struct MpegEncContext {
/* mpegvideo_enc common options */
/* mpegvideo_enc common options */
#define FF_MPV_FLAG_SKIP_RD 0x0001
#define FF_MPV_FLAG_SKIP_RD 0x0001
#define FF_MPV_FLAG_STRICT_GOP 0x0002
#define FF_MPV_FLAG_STRICT_GOP 0x0002
#define FF_MPV_FLAG_QP_RD 0x0004
#define FF_MPV_OFFSET(x) offsetof(MpegEncContext, x)
#define FF_MPV_OFFSET(x) offsetof(MpegEncContext, x)
#define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
#define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
#define FF_MPV_COMMON_OPTS \
#define FF_MPV_COMMON_OPTS \
{ "mpv_flags", "Flags common for all mpegvideo-based encoders.", FF_MPV_OFFSET(mpv_flags), AV_OPT_TYPE_FLAGS, { 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "mpv_flags", "Flags common for all mpegvideo-based encoders.", FF_MPV_OFFSET(mpv_flags), AV_OPT_TYPE_FLAGS, { 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "skip_rd", "RD optimal MB level residual skipping", 0, AV_OPT_TYPE_CONST, { FF_MPV_FLAG_SKIP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "skip_rd", "RD optimal MB level residual skipping", 0, AV_OPT_TYPE_CONST, { FF_MPV_FLAG_SKIP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "strict_gop", "Strictly enforce gop size", 0, AV_OPT_TYPE_CONST, { FF_MPV_FLAG_STRICT_GOP }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },
{ "strict_gop", "Strictly enforce gop size", 0, AV_OPT_TYPE_CONST, { FF_MPV_FLAG_STRICT_GOP }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "qp_rd", "Use rate distortion optimization for qp selection", 0, AV_OPT_TYPE_CONST, { FF_MPV_FLAG_QP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },
extern
const
AVOption
ff_mpv_generic_options
[];
extern
const
AVOption
ff_mpv_generic_options
[];
...
...
libavcodec/mpegvideo_enc.c
View file @
ff71a383
...
@@ -374,13 +374,18 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
...
@@ -374,13 +374,18 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
/* Fixed QSCALE */
/* Fixed QSCALE */
s
->
fixed_qscale
=
!!
(
avctx
->
flags
&
CODEC_FLAG_QSCALE
);
s
->
fixed_qscale
=
!!
(
avctx
->
flags
&
CODEC_FLAG_QSCALE
);
#if FF_API_MPV_GLOBAL_OPTS
if
(
s
->
flags
&
CODEC_FLAG_QP_RD
)
s
->
mpv_flags
|=
FF_MPV_FLAG_QP_RD
;
#endif
s
->
adaptive_quant
=
(
s
->
avctx
->
lumi_masking
||
s
->
adaptive_quant
=
(
s
->
avctx
->
lumi_masking
||
s
->
avctx
->
dark_masking
||
s
->
avctx
->
dark_masking
||
s
->
avctx
->
temporal_cplx_masking
||
s
->
avctx
->
temporal_cplx_masking
||
s
->
avctx
->
spatial_cplx_masking
||
s
->
avctx
->
spatial_cplx_masking
||
s
->
avctx
->
p_masking
||
s
->
avctx
->
p_masking
||
s
->
avctx
->
border_masking
||
s
->
avctx
->
border_masking
||
(
s
->
flags
&
CODEC
_FLAG_QP_RD
))
&&
(
s
->
mpv_flags
&
FF_MPV
_FLAG_QP_RD
))
&&
!
s
->
fixed_qscale
;
!
s
->
fixed_qscale
;
s
->
loop_filter
=
!!
(
s
->
flags
&
CODEC_FLAG_LOOP_FILTER
);
s
->
loop_filter
=
!!
(
s
->
flags
&
CODEC_FLAG_LOOP_FILTER
);
...
@@ -495,7 +500,7 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
...
@@ -495,7 +500,7 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
return
-
1
;
return
-
1
;
}
}
if
((
s
->
flags
&
CODEC
_FLAG_QP_RD
)
&&
if
((
s
->
mpv_flags
&
FF_MPV
_FLAG_QP_RD
)
&&
s
->
avctx
->
mb_decision
!=
FF_MB_DECISION_RD
)
{
s
->
avctx
->
mb_decision
!=
FF_MB_DECISION_RD
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"QP RD needs mbd=2
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"QP RD needs mbd=2
\n
"
);
return
-
1
;
return
-
1
;
...
@@ -1727,7 +1732,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
...
@@ -1727,7 +1732,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
s
->
lambda
=
s
->
lambda_table
[
mb_xy
];
s
->
lambda
=
s
->
lambda_table
[
mb_xy
];
update_qscale
(
s
);
update_qscale
(
s
);
if
(
!
(
s
->
flags
&
CODEC
_FLAG_QP_RD
))
{
if
(
!
(
s
->
mpv_flags
&
FF_MPV
_FLAG_QP_RD
))
{
s
->
qscale
=
s
->
current_picture_ptr
->
f
.
qscale_table
[
mb_xy
];
s
->
qscale
=
s
->
current_picture_ptr
->
f
.
qscale_table
[
mb_xy
];
s
->
dquant
=
s
->
qscale
-
last_qp
;
s
->
dquant
=
s
->
qscale
-
last_qp
;
...
@@ -1747,7 +1752,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
...
@@ -1747,7 +1752,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
}
}
}
}
ff_set_qscale
(
s
,
last_qp
+
s
->
dquant
);
ff_set_qscale
(
s
,
last_qp
+
s
->
dquant
);
}
else
if
(
s
->
flags
&
CODEC
_FLAG_QP_RD
)
}
else
if
(
s
->
mpv_flags
&
FF_MPV
_FLAG_QP_RD
)
ff_set_qscale
(
s
,
s
->
qscale
+
s
->
dquant
);
ff_set_qscale
(
s
,
s
->
qscale
+
s
->
dquant
);
wrap_y
=
s
->
linesize
;
wrap_y
=
s
->
linesize
;
...
@@ -2508,7 +2513,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
...
@@ -2508,7 +2513,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
s
->
mb_skipped
=
0
;
s
->
mb_skipped
=
0
;
s
->
dquant
=
0
;
//only for QP_RD
s
->
dquant
=
0
;
//only for QP_RD
if
(
mb_type
&
(
mb_type
-
1
)
||
(
s
->
flags
&
CODEC_FLAG_QP_RD
)){
// more than 1 MB type possible or CODEC
_FLAG_QP_RD
if
(
mb_type
&
(
mb_type
-
1
)
||
(
s
->
mpv_flags
&
FF_MPV_FLAG_QP_RD
))
{
// more than 1 MB type possible or FF_MPV
_FLAG_QP_RD
int
next_block
=
0
;
int
next_block
=
0
;
int
pb_bits_count
,
pb2_bits_count
,
tex_pb_bits_count
;
int
pb_bits_count
,
pb2_bits_count
,
tex_pb_bits_count
;
...
@@ -2645,7 +2650,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
...
@@ -2645,7 +2650,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
}
}
}
}
if
((
s
->
flags
&
CODEC_FLAG_QP_RD
)
&&
dmin
<
INT_MAX
)
{
if
((
s
->
mpv_flags
&
FF_MPV_FLAG_QP_RD
)
&&
dmin
<
INT_MAX
)
{
if
(
best_s
.
mv_type
==
MV_TYPE_16X16
){
//FIXME move 4mv after QPRD
if
(
best_s
.
mv_type
==
MV_TYPE_16X16
){
//FIXME move 4mv after QPRD
const
int
last_qp
=
backup_s
.
qscale
;
const
int
last_qp
=
backup_s
.
qscale
;
int
qpi
,
qp
,
dc
[
6
];
int
qpi
,
qp
,
dc
[
6
];
...
...
libavcodec/options.c
View file @
ff71a383
...
@@ -98,7 +98,9 @@ static const AVOption options[]={
...
@@ -98,7 +98,9 @@ static const AVOption options[]={
{
"bitexact"
,
"use only bitexact stuff (except (i)dct)"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
CODEC_FLAG_BITEXACT
},
INT_MIN
,
INT_MAX
,
A
|
V
|
S
|
D
|
E
,
"flags"
},
{
"bitexact"
,
"use only bitexact stuff (except (i)dct)"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
CODEC_FLAG_BITEXACT
},
INT_MIN
,
INT_MAX
,
A
|
V
|
S
|
D
|
E
,
"flags"
},
{
"aic"
,
"h263 advanced intra coding / mpeg4 ac prediction"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
CODEC_FLAG_AC_PRED
},
INT_MIN
,
INT_MAX
,
V
|
E
,
"flags"
},
{
"aic"
,
"h263 advanced intra coding / mpeg4 ac prediction"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
CODEC_FLAG_AC_PRED
},
INT_MIN
,
INT_MAX
,
V
|
E
,
"flags"
},
{
"cbp"
,
"use rate distortion optimization for cbp"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
CODEC_FLAG_CBP_RD
},
INT_MIN
,
INT_MAX
,
V
|
E
,
"flags"
},
{
"cbp"
,
"use rate distortion optimization for cbp"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
CODEC_FLAG_CBP_RD
},
INT_MIN
,
INT_MAX
,
V
|
E
,
"flags"
},
{
"qprd"
,
"use rate distortion optimization for qp selection"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
CODEC_FLAG_QP_RD
},
INT_MIN
,
INT_MAX
,
V
|
E
,
"flags"
},
#if FF_API_MPV_GLOBAL_OPTS
{
"qprd"
,
"Deprecated, use mpegvideo private options instead"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
CODEC_FLAG_QP_RD
},
INT_MIN
,
INT_MAX
,
V
|
E
,
"flags"
},
#endif
{
"ilme"
,
"interlaced motion estimation"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
CODEC_FLAG_INTERLACED_ME
},
INT_MIN
,
INT_MAX
,
V
|
E
,
"flags"
},
{
"ilme"
,
"interlaced motion estimation"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
CODEC_FLAG_INTERLACED_ME
},
INT_MIN
,
INT_MAX
,
V
|
E
,
"flags"
},
{
"cgop"
,
"closed gop"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
CODEC_FLAG_CLOSED_GOP
},
INT_MIN
,
INT_MAX
,
V
|
E
,
"flags"
},
{
"cgop"
,
"closed gop"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
CODEC_FLAG_CLOSED_GOP
},
INT_MIN
,
INT_MAX
,
V
|
E
,
"flags"
},
{
"fast"
,
"allow non spec compliant speedup tricks"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
CODEC_FLAG2_FAST
},
INT_MIN
,
INT_MAX
,
V
|
E
,
"flags2"
},
{
"fast"
,
"allow non spec compliant speedup tricks"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
CODEC_FLAG2_FAST
},
INT_MIN
,
INT_MAX
,
V
|
E
,
"flags2"
},
...
...
tests/codec-regression.sh
View file @
ff71a383
...
@@ -38,13 +38,13 @@ fi
...
@@ -38,13 +38,13 @@ fi
if
[
-n
"
$do_mpeg2_ivlc_qprd
"
]
;
then
if
[
-n
"
$do_mpeg2_ivlc_qprd
"
]
;
then
# mpeg2 encoding intra vlc qprd
# mpeg2 encoding intra vlc qprd
do_video_encoding mpeg2ivlc-qprd.mpg
"-vb 500k -bf 2 -trellis 1 -flags +
qprd+mv0
-intra_vlc 1 -cmp 2 -subcmp 2 -mbd rd -vcodec mpeg2video -f mpeg2video"
do_video_encoding mpeg2ivlc-qprd.mpg
"-vb 500k -bf 2 -trellis 1 -flags +
mv0 -mpv_flags +qp_rd
-intra_vlc 1 -cmp 2 -subcmp 2 -mbd rd -vcodec mpeg2video -f mpeg2video"
do_video_decoding
do_video_decoding
fi
fi
if
[
-n
"
$do_mpeg2_422
"
]
;
then
if
[
-n
"
$do_mpeg2_422
"
]
;
then
#mpeg2 4:2:2 encoding
#mpeg2 4:2:2 encoding
do_video_encoding mpeg2_422.mpg
"-vb 1000k -bf 2 -trellis 1 -flags +
qprd+mv0+ildct+ilme
-intra_vlc 1 -mbd rd -vcodec mpeg2video -pix_fmt yuv422p -f mpeg2video"
do_video_encoding mpeg2_422.mpg
"-vb 1000k -bf 2 -trellis 1 -flags +
mv0+ildct+ilme -mpv_flags +qp_rd
-intra_vlc 1 -mbd rd -vcodec mpeg2video -pix_fmt yuv422p -f mpeg2video"
do_video_decoding
do_video_decoding
fi
fi
...
@@ -128,7 +128,7 @@ do_video_decoding
...
@@ -128,7 +128,7 @@ do_video_decoding
fi
fi
if
[
-n
"
$do_mpeg4_qprd
"
]
;
then
if
[
-n
"
$do_mpeg4_qprd
"
]
;
then
do_video_encoding mpeg4-qprd.avi
"-b 450k -bf 2 -trellis 1 -flags +mv4+
qprd+mv0
-cmp 2 -subcmp 2 -mbd rd -an -vcodec mpeg4"
do_video_encoding mpeg4-qprd.avi
"-b 450k -bf 2 -trellis 1 -flags +mv4+
mv0 -mpv_flags +qp_rd
-cmp 2 -subcmp 2 -mbd rd -an -vcodec mpeg4"
do_video_decoding
do_video_decoding
fi
fi
...
...
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