Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
f931ff7b
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,发现更多精彩内容 >>
提交
f931ff7b
编写于
1月 02, 2003
作者:
M
Michael Niedermayer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pre motion estimation cleanup/bugfix
Originally committed as revision 1390 to
svn://svn.ffmpeg.org/ffmpeg/trunk
上级
f5fb6b34
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
25 deletion
+30
-25
libavcodec/motion_est.c
libavcodec/motion_est.c
+13
-18
libavcodec/motion_est_template.c
libavcodec/motion_est_template.c
+13
-6
libavcodec/mpegvideo.c
libavcodec/mpegvideo.c
+3
-1
libavcodec/mpegvideo.h
libavcodec/mpegvideo.h
+1
-0
未找到文件。
libavcodec/motion_est.c
浏览文件 @
f931ff7b
...
...
@@ -803,7 +803,7 @@ static inline int mv4_search(MpegEncContext *s, int xmin, int ymin, int xmax, in
if
(
P_LEFT
[
0
]
>
(
rel_xmax4
<<
shift
))
P_LEFT
[
0
]
=
(
rel_xmax4
<<
shift
);
/* special case for first line */
if
(
(
s
->
mb_y
==
0
||
s
->
first_slice_line
)
&&
block
<
2
)
{
if
(
s
->
mb_y
==
0
&&
block
<
2
)
{
pred_x4
=
P_LEFT
[
0
];
pred_y4
=
P_LEFT
[
1
];
}
else
{
...
...
@@ -904,11 +904,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
if
(
P_LEFT
[
0
]
>
(
rel_xmax
<<
shift
))
P_LEFT
[
0
]
=
(
rel_xmax
<<
shift
);
/* special case for first line */
if
((
mb_y
==
0
||
s
->
first_slice_line
))
{
pred_x
=
P_LEFT
[
0
];
pred_y
=
P_LEFT
[
1
];
}
else
{
if
(
mb_y
)
{
P_TOP
[
0
]
=
s
->
motion_val
[
mot_xy
-
mot_stride
][
0
];
P_TOP
[
1
]
=
s
->
motion_val
[
mot_xy
-
mot_stride
][
1
];
P_TOPRIGHT
[
0
]
=
s
->
motion_val
[
mot_xy
-
mot_stride
+
2
][
0
];
...
...
@@ -927,7 +923,11 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
pred_x
=
P_LEFT
[
0
];
pred_y
=
P_LEFT
[
1
];
}
}
else
{
pred_x
=
P_LEFT
[
0
];
pred_y
=
P_LEFT
[
1
];
}
}
dmin
=
s
->
me
.
motion_search
[
0
](
s
,
0
,
&
mx
,
&
my
,
P
,
pred_x
,
pred_y
,
rel_xmin
,
rel_ymin
,
rel_xmax
,
rel_ymax
,
&
s
->
last_picture
,
s
->
p_mv_table
,
(
1
<<
16
)
>>
shift
,
mv_penalty
);
...
...
@@ -1055,6 +1055,8 @@ int ff_pre_estimate_p_frame_motion(MpegEncContext * s,
if
(
mb_y
==
s
->
mb_height
-
1
)
{
pred_x
=
P_LEFT
[
0
];
pred_y
=
P_LEFT
[
1
];
P_TOP
[
0
]
=
P_TOPRIGHT
[
0
]
=
P_MEDIAN
[
0
]
=
P_TOP
[
1
]
=
P_TOPRIGHT
[
1
]
=
P_MEDIAN
[
1
]
=
0
;
//FIXME
}
else
{
P_TOP
[
0
]
=
s
->
p_mv_table
[
xy
+
mv_stride
][
0
];
P_TOP
[
1
]
=
s
->
p_mv_table
[
xy
+
mv_stride
][
1
];
...
...
@@ -1067,17 +1069,12 @@ int ff_pre_estimate_p_frame_motion(MpegEncContext * s,
P_MEDIAN
[
0
]
=
mid_pred
(
P_LEFT
[
0
],
P_TOP
[
0
],
P_TOPRIGHT
[
0
]);
P_MEDIAN
[
1
]
=
mid_pred
(
P_LEFT
[
1
],
P_TOP
[
1
],
P_TOPRIGHT
[
1
]);
if
(
s
->
out_format
==
FMT_H263
){
pred_x
=
P_MEDIAN
[
0
];
pred_y
=
P_MEDIAN
[
1
];
}
else
{
/* mpeg1 at least */
pred_x
=
P_LEFT
[
0
];
pred_y
=
P_LEFT
[
1
];
}
pred_x
=
P_MEDIAN
[
0
];
pred_y
=
P_MEDIAN
[
1
];
}
dmin
=
s
->
me
.
motion_search
[
0
](
s
,
0
,
&
mx
,
&
my
,
P
,
pred_x
,
pred_y
,
rel_xmin
,
rel_ymin
,
rel_xmax
,
rel_ymax
,
&
s
->
last_picture
,
s
->
p_mv_table
,
(
1
<<
16
)
>>
shift
,
mv_penalty
);
s
->
p_mv_table
[
xy
][
0
]
=
mx
<<
shift
;
s
->
p_mv_table
[
xy
][
1
]
=
my
<<
shift
;
...
...
@@ -1140,8 +1137,7 @@ int ff_estimate_motion_b(MpegEncContext * s,
if
(
P_LEFT
[
0
]
>
(
rel_xmax
<<
shift
))
P_LEFT
[
0
]
=
(
rel_xmax
<<
shift
);
/* special case for first line */
if
((
mb_y
==
0
||
s
->
first_slice_line
))
{
}
else
{
if
(
mb_y
)
{
P_TOP
[
0
]
=
mv_table
[
mot_xy
-
mot_stride
][
0
];
P_TOP
[
1
]
=
mv_table
[
mot_xy
-
mot_stride
][
1
];
P_TOPRIGHT
[
0
]
=
mv_table
[
mot_xy
-
mot_stride
+
1
][
0
];
...
...
@@ -1332,8 +1328,7 @@ static inline int direct_search(MpegEncContext * s,
P_LEFT
[
1
]
=
clip
(
mv_table
[
mot_xy
-
1
][
1
],
ymin
<<
shift
,
ymax
<<
shift
);
/* special case for first line */
if
((
mb_y
==
0
||
s
->
first_slice_line
))
{
}
else
{
if
(
mb_y
)
{
P_TOP
[
0
]
=
clip
(
mv_table
[
mot_xy
-
mot_stride
][
0
],
xmin
<<
shift
,
xmax
<<
shift
);
P_TOP
[
1
]
=
clip
(
mv_table
[
mot_xy
-
mot_stride
][
1
],
ymin
<<
shift
,
ymax
<<
shift
);
P_TOPRIGHT
[
0
]
=
clip
(
mv_table
[
mot_xy
-
mot_stride
+
1
][
0
],
xmin
<<
shift
,
xmax
<<
shift
);
...
...
libavcodec/motion_est_template.c
浏览文件 @
f931ff7b
...
...
@@ -835,7 +835,7 @@ static int RENAME(epzs_motion_search)(MpegEncContext * s, int block,
score_map
[
0
]
=
dmin
;
/* first line */
if
(
(
s
->
mb_y
==
0
||
s
->
first_slice_line
)
)
{
if
(
s
->
mb_y
==
0
)
{
CHECK_MV
(
P_LEFT
[
0
]
>>
shift
,
P_LEFT
[
1
]
>>
shift
)
CHECK_CLIPED_MV
((
last_mv
[
ref_mv_xy
][
0
]
*
ref_mv_scale
+
(
1
<<
15
))
>>
16
,
(
last_mv
[
ref_mv_xy
][
1
]
*
ref_mv_scale
+
(
1
<<
15
))
>>
16
)
...
...
@@ -858,10 +858,17 @@ static int RENAME(epzs_motion_search)(MpegEncContext * s, int block,
}
}
if
(
dmin
>
256
*
4
){
CHECK_CLIPED_MV
((
last_mv
[
ref_mv_xy
+
1
][
0
]
*
ref_mv_scale
+
(
1
<<
15
))
>>
16
,
(
last_mv
[
ref_mv_xy
+
1
][
1
]
*
ref_mv_scale
+
(
1
<<
15
))
>>
16
)
CHECK_CLIPED_MV
((
last_mv
[
ref_mv_xy
+
ref_mv_stride
][
0
]
*
ref_mv_scale
+
(
1
<<
15
))
>>
16
,
(
last_mv
[
ref_mv_xy
+
ref_mv_stride
][
1
]
*
ref_mv_scale
+
(
1
<<
15
))
>>
16
)
if
(
s
->
me
.
pre_pass
){
CHECK_CLIPED_MV
((
last_mv
[
ref_mv_xy
-
1
][
0
]
*
ref_mv_scale
+
(
1
<<
15
))
>>
16
,
(
last_mv
[
ref_mv_xy
-
1
][
1
]
*
ref_mv_scale
+
(
1
<<
15
))
>>
16
)
CHECK_CLIPED_MV
((
last_mv
[
ref_mv_xy
-
ref_mv_stride
][
0
]
*
ref_mv_scale
+
(
1
<<
15
))
>>
16
,
(
last_mv
[
ref_mv_xy
-
ref_mv_stride
][
1
]
*
ref_mv_scale
+
(
1
<<
15
))
>>
16
)
}
else
{
CHECK_CLIPED_MV
((
last_mv
[
ref_mv_xy
+
1
][
0
]
*
ref_mv_scale
+
(
1
<<
15
))
>>
16
,
(
last_mv
[
ref_mv_xy
+
1
][
1
]
*
ref_mv_scale
+
(
1
<<
15
))
>>
16
)
CHECK_CLIPED_MV
((
last_mv
[
ref_mv_xy
+
ref_mv_stride
][
0
]
*
ref_mv_scale
+
(
1
<<
15
))
>>
16
,
(
last_mv
[
ref_mv_xy
+
ref_mv_stride
][
1
]
*
ref_mv_scale
+
(
1
<<
15
))
>>
16
)
}
}
if
(
s
->
avctx
->
last_predictor_count
){
...
...
@@ -938,7 +945,7 @@ static int RENAME(epzs_motion_search4)(MpegEncContext * s, int block,
dmin
=
1000000
;
//printf("%d %d %d %d //",xmin, ymin, xmax, ymax);
/* first line */
if
(
(
s
->
mb_y
==
0
||
s
->
first_slice_line
)
&&
block
<
2
)
{
if
(
s
->
mb_y
==
0
&&
block
<
2
)
{
CHECK_MV
(
P_LEFT
[
0
]
>>
shift
,
P_LEFT
[
1
]
>>
shift
)
CHECK_CLIPED_MV
((
last_mv
[
ref_mv_xy
][
0
]
*
ref_mv_scale
+
(
1
<<
15
))
>>
16
,
(
last_mv
[
ref_mv_xy
][
1
]
*
ref_mv_scale
+
(
1
<<
15
))
>>
16
)
...
...
libavcodec/mpegvideo.c
浏览文件 @
f931ff7b
...
...
@@ -2789,9 +2789,10 @@ static void encode_picture(MpegEncContext *s, int picture_number)
/* Estimate motion for every MB */
if
(
s
->
pict_type
!=
I_TYPE
){
if
(
s
->
pict_type
!=
B_TYPE
){
if
((
s
->
avctx
->
pre_me
&&
s
->
last_non_b_pict_type
==
I_TYPE
)
||
s
->
avctx
->
pre_me
==
2
){
s
->
me
.
pre_pass
=
1
;
for
(
mb_y
=
s
->
mb_height
-
1
;
mb_y
>=
0
;
mb_y
--
)
{
for
(
mb_x
=
s
->
mb_width
-
1
;
mb_x
>=
0
;
mb_x
--
)
{
s
->
mb_x
=
mb_x
;
...
...
@@ -2799,6 +2800,7 @@ static void encode_picture(MpegEncContext *s, int picture_number)
ff_pre_estimate_p_frame_motion
(
s
,
mb_x
,
mb_y
);
}
}
s
->
me
.
pre_pass
=
0
;
}
}
...
...
libavcodec/mpegvideo.h
浏览文件 @
f931ff7b
...
...
@@ -141,6 +141,7 @@ typedef struct MotionEstContext{
int
map_generation
;
int
penalty_factor
;
int
sub_penalty_factor
;
int
pre_pass
;
/* = 1 for the pre pass */
UINT16
(
*
mv_penalty
)[
MAX_MV
*
2
+
1
];
/* amount of bits needed to encode a MV */
int
(
*
sub_motion_search
)(
struct
MpegEncContext
*
s
,
int
*
mx_ptr
,
int
*
my_ptr
,
int
dmin
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录