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
1fb4890b
Commit
1fb4890b
authored
Aug 22, 2002
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better scene change detection
Originally committed as revision 858 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
90cee0c3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
2 deletions
+12
-2
motion_est.c
libavcodec/motion_est.c
+8
-0
mpegvideo.c
libavcodec/mpegvideo.c
+3
-2
mpegvideo.h
libavcodec/mpegvideo.h
+1
-0
No files found.
libavcodec/motion_est.c
View file @
1fb4890b
...
...
@@ -1183,6 +1183,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
sum
=
(
sum
+
8
)
>>
4
;
varc
=
(
pix_norm1
(
pix
,
s
->
linesize
)
-
sum
*
sum
+
500
+
128
)
>>
8
;
vard
=
(
pix_norm
(
pix
,
ppix
,
s
->
linesize
)
+
128
)
>>
8
;
//printf("%d %d %d %X %X %X\n", s->mb_width, mb_x, mb_y,(int)s, (int)s->mb_var, (int)s->mc_mb_var); fflush(stdout);
s
->
mb_var
[
s
->
mb_width
*
mb_y
+
mb_x
]
=
varc
;
s
->
mc_mb_var
[
s
->
mb_width
*
mb_y
+
mb_x
]
=
vard
;
...
...
@@ -1195,6 +1196,11 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
varc, s->avg_mb_var, sum, vard, mx - xx, my - yy);
#endif
if
(
s
->
flags
&
CODEC_FLAG_HQ
){
if
(
vard
<=
64
||
vard
<
varc
)
s
->
scene_change_score
+=
ff_sqrt
(
vard
)
-
ff_sqrt
(
varc
);
else
s
->
scene_change_score
+=
20
;
if
(
vard
*
2
+
200
>
varc
)
mb_type
|=
MB_TYPE_INTRA
;
if
(
varc
*
2
+
200
>
vard
){
...
...
@@ -1221,6 +1227,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
set_p_mv_tables
(
s
,
mx
,
my
,
1
);
}
else
{
if
(
vard
<=
64
||
vard
<
varc
)
{
s
->
scene_change_score
+=
ff_sqrt
(
vard
)
-
ff_sqrt
(
varc
);
mb_type
|=
MB_TYPE_INTER
;
if
(
s
->
me_method
!=
ME_ZERO
)
{
if
(
s
->
me_method
>=
ME_EPZS
)
...
...
@@ -1251,6 +1258,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
}
#endif
}
else
{
s
->
scene_change_score
+=
20
;
mb_type
|=
MB_TYPE_INTRA
;
mx
=
0
;
my
=
0
;
...
...
libavcodec/mpegvideo.c
View file @
1fb4890b
...
...
@@ -1978,6 +1978,8 @@ static void encode_picture(MpegEncContext *s, int picture_number)
if
(
s
->
h263_pred
&&
!
s
->
h263_msmpeg4
)
ff_set_mpeg4_time
(
s
,
s
->
picture_number
);
s
->
scene_change_score
=
0
;
/* Estimate motion for every MB */
if
(
s
->
pict_type
!=
I_TYPE
){
for
(
mb_y
=
0
;
mb_y
<
s
->
mb_height
;
mb_y
++
)
{
...
...
@@ -2009,8 +2011,7 @@ static void encode_picture(MpegEncContext *s, int picture_number)
memset
(
s
->
p_mv_table
,
0
,
sizeof
(
INT16
)
*
(
s
->
mb_width
+
2
)
*
(
s
->
mb_height
+
2
)
*
2
);
memset
(
s
->
mb_type
,
MB_TYPE_INTRA
,
sizeof
(
UINT8
)
*
s
->
mb_width
*
s
->
mb_height
);
}
if
(
s
->
mb_var_sum
<
s
->
mc_mb_var_sum
&&
s
->
pict_type
==
P_TYPE
){
//FIXME subtract MV bits
if
(
s
->
scene_change_score
>
0
&&
s
->
pict_type
==
P_TYPE
){
s
->
pict_type
=
I_TYPE
;
memset
(
s
->
mb_type
,
MB_TYPE_INTRA
,
sizeof
(
UINT8
)
*
s
->
mb_width
*
s
->
mb_height
);
if
(
s
->
max_b_frames
==
0
){
...
...
libavcodec/mpegvideo.h
View file @
1fb4890b
...
...
@@ -195,6 +195,7 @@ typedef struct MpegEncContext {
uint16_t
*
me_score_map
;
/* map to store the SADs */
int
me_map_generation
;
int
skip_me
;
/* set if ME is skiped for the current MB */
int
scene_change_score
;
int
mv_dir
;
#define MV_DIR_BACKWARD 1
#define MV_DIR_FORWARD 2
...
...
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