Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
1f26c6f3
F
Ffmpeg
项目概览
小白菜888
/
Ffmpeg
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Ffmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1f26c6f3
编写于
11月 12, 2003
作者:
M
Michael Niedermayer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rate distored optimal lambda->qp support
Originally committed as revision 2509 to
svn://svn.ffmpeg.org/ffmpeg/trunk
上级
567e36d8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
9 deletion
+63
-9
libavcodec/avcodec.h
libavcodec/avcodec.h
+2
-0
libavcodec/mpegvideo.c
libavcodec/mpegvideo.c
+61
-9
未找到文件。
libavcodec/avcodec.h
浏览文件 @
1f26c6f3
...
...
@@ -255,6 +255,7 @@ static const __attribute__((unused)) int Motion_Est_QTab[] =
#define CODEC_FLAG_AC_PRED 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction
#define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
#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
/* For advanced prediction mode, we reuse the 4MV flag */
/* Unsupported options :
* Syntax Arithmetic coding (SAC)
...
...
@@ -1065,6 +1066,7 @@ typedef struct AVCodecContext {
/**
* sample aspect ratio (0 if unknown).
* numerator and denominator must be relative prime and smaller then 256 for some video standards
* - encoding: set by user.
* - decoding: set by lavc.
*/
...
...
libavcodec/mpegvideo.c
浏览文件 @
1f26c6f3
...
...
@@ -664,7 +664,8 @@ int MPV_encode_init(AVCodecContext *avctx)
||
s
->
avctx
->
dark_masking
||
s
->
avctx
->
temporal_cplx_masking
||
s
->
avctx
->
spatial_cplx_masking
||
s
->
avctx
->
p_masking
)
||
s
->
avctx
->
p_masking
||
(
s
->
flags
&
CODEC_FLAG_QP_RD
))
&&
!
s
->
fixed_qscale
;
s
->
progressive_sequence
=
!
(
avctx
->
flags
&
CODEC_FLAG_INTERLACED_DCT
);
...
...
@@ -2898,15 +2899,18 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
s
->
lambda
=
s
->
lambda_table
[
mb_xy
];
update_qscale
(
s
);
s
->
dquant
=
s
->
qscale
-
last_qp
;
if
(
!
(
s
->
flags
&
CODEC_FLAG_QP_RD
)){
s
->
dquant
=
s
->
qscale
-
last_qp
;
if
(
s
->
out_format
==
FMT_H263
)
s
->
dquant
=
clip
(
s
->
dquant
,
-
2
,
2
);
//FIXME RD
if
(
s
->
out_format
==
FMT_H263
)
s
->
dquant
=
clip
(
s
->
dquant
,
-
2
,
2
);
//FIXME RD
if
(
s
->
codec_id
==
CODEC_ID_MPEG4
){
if
(
!
s
->
mb_intra
){
if
((
s
->
mv_dir
&
MV_DIRECT
)
||
s
->
mv_type
==
MV_TYPE_8X8
)
s
->
dquant
=
0
;
if
(
s
->
codec_id
==
CODEC_ID_MPEG4
){
if
(
!
s
->
mb_intra
){
if
((
s
->
mv_dir
&
MV_DIRECT
)
||
s
->
mv_type
==
MV_TYPE_8X8
)
s
->
dquant
=
0
;
}
}
}
s
->
qscale
=
last_qp
+
s
->
dquant
;
...
...
@@ -3256,6 +3260,7 @@ static inline void copy_context_before_encode(MpegEncContext *d, MpegEncContext
d
->
mb_skiped
=
0
;
d
->
qscale
=
s
->
qscale
;
d
->
dquant
=
s
->
dquant
;
}
static
inline
void
copy_context_after_encode
(
MpegEncContext
*
d
,
MpegEncContext
*
s
,
int
type
){
...
...
@@ -3724,8 +3729,9 @@ static void encode_picture(MpegEncContext *s, int picture_number)
}
s
->
mb_skiped
=
0
;
s
->
dquant
=
0
;
//only for QP_RD
if
(
mb_type
&
(
mb_type
-
1
)){
// more than 1 MB type possible
if
(
mb_type
&
(
mb_type
-
1
)
||
(
s
->
flags
&
CODEC_FLAG_QP_RD
)
){
// more than 1 MB type possible
int
next_block
=
0
;
int
pb_bits_count
,
pb2_bits_count
,
tex_pb_bits_count
;
...
...
@@ -3823,6 +3829,52 @@ static void encode_picture(MpegEncContext *s, int picture_number)
ff_clean_intra_table_entries
(
s
);
//old mode?
}
}
if
(
s
->
flags
&
CODEC_FLAG_QP_RD
){
if
(
best_s
.
mv_type
==
MV_TYPE_16X16
&&
!
(
best_s
.
mv_dir
&
MV_DIRECT
)){
const
int
last_qp
=
backup_s
.
qscale
;
int
dquant
,
dir
,
qp
,
dc
[
6
];
assert
(
backup_s
.
dquant
==
0
);
//FIXME intra
s
->
mv_dir
=
best_s
.
mv_dir
;
s
->
mv_type
=
MV_TYPE_16X16
;
s
->
mb_intra
=
best_s
.
mb_intra
;
s
->
mv
[
0
][
0
][
0
]
=
best_s
.
mv
[
0
][
0
][
0
];
s
->
mv
[
0
][
0
][
1
]
=
best_s
.
mv
[
0
][
0
][
1
];
s
->
mv
[
1
][
0
][
0
]
=
best_s
.
mv
[
1
][
0
][
0
];
s
->
mv
[
1
][
0
][
1
]
=
best_s
.
mv
[
1
][
0
][
1
];
dir
=
s
->
pict_type
==
B_TYPE
?
2
:
1
;
if
(
last_qp
+
dir
>=
s
->
avctx
->
qmax
)
dir
=
-
dir
;
for
(
dquant
=
dir
;
dquant
<=
2
&&
dquant
>=-
2
;
dquant
+=
dir
){
qp
=
last_qp
+
dquant
;
if
(
qp
<
s
->
avctx
->
qmin
||
qp
>
s
->
avctx
->
qmax
)
break
;
backup_s
.
dquant
=
dquant
;
for
(
i
=
0
;
i
<
6
;
i
++
){
dc
[
i
]
=
s
->
dc_val
[
0
][
s
->
block_index
[
i
]
];
//FIXME AC
}
//printf("%d %d\n", backup_s.dquant, backup_s.qscale);
encode_mb_hq
(
s
,
&
backup_s
,
&
best_s
,
MB_TYPE_INTER
/* wrong but unused */
,
pb
,
pb2
,
tex_pb
,
&
dmin
,
&
next_block
,
s
->
mv
[
0
][
0
][
0
],
s
->
mv
[
0
][
0
][
1
]);
if
(
best_s
.
qscale
!=
qp
){
for
(
i
=
0
;
i
<
6
;
i
++
){
s
->
dc_val
[
0
][
s
->
block_index
[
i
]
]
=
dc
[
i
];
}
if
(
dir
>
0
&&
dquant
==
dir
){
dquant
=
0
;
dir
=
-
dir
;
}
else
break
;
}
}
qp
=
best_s
.
qscale
;
s
->
current_picture
.
qscale_table
[
xy
]
=
qp
;
}
}
copy_context_after_encode
(
s
,
&
best_s
,
-
1
);
pb_bits_count
=
get_bit_count
(
&
s
->
pb
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录