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
316a2ec8
Commit
316a2ec8
authored
Dec 23, 2005
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bidir refine support
Originally committed as revision 4768 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
377798d6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
3 deletions
+71
-3
avcodec.h
libavcodec/avcodec.h
+7
-0
motion_est.c
libavcodec/motion_est.c
+63
-3
utils.c
libavcodec/utils.c
+1
-0
No files found.
libavcodec/avcodec.h
View file @
316a2ec8
...
@@ -1862,6 +1862,13 @@ typedef struct AVCodecContext {
...
@@ -1862,6 +1862,13 @@ typedef struct AVCodecContext {
* - decoding: set by user.
* - decoding: set by user.
*/
*/
enum
AVDiscard
skip_frame
;
enum
AVDiscard
skip_frame
;
/**
*
* - encoding: set by user.
* - decoding: unused
*/
int
bidir_refine
;
}
AVCodecContext
;
}
AVCodecContext
;
/**
/**
...
...
libavcodec/motion_est.c
View file @
316a2ec8
...
@@ -1617,6 +1617,7 @@ static inline int check_bidir_mv(MpegEncContext * s,
...
@@ -1617,6 +1617,7 @@ static inline int check_bidir_mv(MpegEncContext * s,
/* refine the bidir vectors in hq mode and return the score in both lq & hq mode*/
/* refine the bidir vectors in hq mode and return the score in both lq & hq mode*/
static
inline
int
bidir_refine
(
MpegEncContext
*
s
,
int
mb_x
,
int
mb_y
)
static
inline
int
bidir_refine
(
MpegEncContext
*
s
,
int
mb_x
,
int
mb_y
)
{
{
MotionEstContext
*
const
c
=
&
s
->
me
;
const
int
mot_stride
=
s
->
mb_stride
;
const
int
mot_stride
=
s
->
mb_stride
;
const
int
xy
=
mb_y
*
mot_stride
+
mb_x
;
const
int
xy
=
mb_y
*
mot_stride
+
mb_x
;
int
fbmin
;
int
fbmin
;
...
@@ -1628,8 +1629,13 @@ static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y)
...
@@ -1628,8 +1629,13 @@ static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y)
int
motion_fy
=
s
->
b_bidir_forw_mv_table
[
xy
][
1
]
=
s
->
b_forw_mv_table
[
xy
][
1
];
int
motion_fy
=
s
->
b_bidir_forw_mv_table
[
xy
][
1
]
=
s
->
b_forw_mv_table
[
xy
][
1
];
int
motion_bx
=
s
->
b_bidir_back_mv_table
[
xy
][
0
]
=
s
->
b_back_mv_table
[
xy
][
0
];
int
motion_bx
=
s
->
b_bidir_back_mv_table
[
xy
][
0
]
=
s
->
b_back_mv_table
[
xy
][
0
];
int
motion_by
=
s
->
b_bidir_back_mv_table
[
xy
][
1
]
=
s
->
b_back_mv_table
[
xy
][
1
];
int
motion_by
=
s
->
b_bidir_back_mv_table
[
xy
][
1
]
=
s
->
b_back_mv_table
[
xy
][
1
];
const
int
flags
=
c
->
sub_flags
;
//FIXME do refinement and add flag
const
int
qpel
=
flags
&
FLAG_QPEL
;
const
int
shift
=
1
+
qpel
;
const
int
xmin
=
c
->
xmin
<<
shift
;
const
int
ymin
=
c
->
ymin
<<
shift
;
const
int
xmax
=
c
->
xmax
<<
shift
;
const
int
ymax
=
c
->
ymax
<<
shift
;
fbmin
=
check_bidir_mv
(
s
,
motion_fx
,
motion_fy
,
fbmin
=
check_bidir_mv
(
s
,
motion_fx
,
motion_fy
,
motion_bx
,
motion_by
,
motion_bx
,
motion_by
,
...
@@ -1637,7 +1643,61 @@ static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y)
...
@@ -1637,7 +1643,61 @@ static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y)
pred_bx
,
pred_by
,
pred_bx
,
pred_by
,
0
,
16
);
0
,
16
);
return
fbmin
;
if
(
s
->
avctx
->
bidir_refine
){
int
score
,
end
;
#define CHECK_BIDIR(fx,fy,bx,by)\
score= check_bidir_mv(s, motion_fx+fx, motion_fy+fy, motion_bx+bx, motion_by+by, pred_fx, pred_fy, pred_bx, pred_by, 0, 16);\
if(score < fbmin){\
fbmin= score;\
motion_fx+=fx;\
motion_fy+=fy;\
motion_bx+=bx;\
motion_by+=by;\
end=0;\
}
#define CHECK_BIDIR2(a,b,c,d)\
CHECK_BIDIR(a,b,c,d)\
CHECK_BIDIR(-a,-b,-c,-d)
#define CHECK_BIDIRR(a,b,c,d)\
CHECK_BIDIR2(a,b,c,d)\
CHECK_BIDIR2(b,c,d,a)\
CHECK_BIDIR2(c,d,a,b)\
CHECK_BIDIR2(d,a,b,c)
do
{
end
=
1
;
if
(
motion_fx
>=
xmax
||
motion_bx
>=
xmax
||
motion_fx
<=
xmin
||
motion_bx
<=
xmin
||
motion_fy
>=
ymax
||
motion_by
>=
ymax
||
motion_fy
<=
ymin
||
motion_by
<=
ymin
)
break
;
CHECK_BIDIRR
(
0
,
0
,
0
,
1
)
if
(
s
->
avctx
->
bidir_refine
>
1
){
CHECK_BIDIRR
(
0
,
0
,
1
,
1
)
CHECK_BIDIR2
(
0
,
1
,
0
,
1
)
CHECK_BIDIR2
(
1
,
0
,
1
,
0
)
CHECK_BIDIRR
(
0
,
0
,
-
1
,
1
)
CHECK_BIDIR2
(
0
,
-
1
,
0
,
1
)
CHECK_BIDIR2
(
-
1
,
0
,
1
,
0
)
if
(
s
->
avctx
->
bidir_refine
>
2
){
CHECK_BIDIRR
(
0
,
1
,
1
,
1
)
CHECK_BIDIRR
(
0
,
-
1
,
1
,
1
)
CHECK_BIDIRR
(
0
,
1
,
-
1
,
1
)
CHECK_BIDIRR
(
0
,
1
,
1
,
-
1
)
if
(
s
->
avctx
->
bidir_refine
>
3
){
CHECK_BIDIR2
(
1
,
1
,
1
,
1
)
CHECK_BIDIRR
(
1
,
1
,
1
,
-
1
)
CHECK_BIDIR2
(
1
,
1
,
-
1
,
-
1
)
CHECK_BIDIR2
(
1
,
-
1
,
-
1
,
1
)
CHECK_BIDIR2
(
1
,
-
1
,
1
,
-
1
)
}
}
}
}
while
(
!
end
);
}
return
fbmin
;
}
}
static
inline
int
direct_search
(
MpegEncContext
*
s
,
int
mb_x
,
int
mb_y
)
static
inline
int
direct_search
(
MpegEncContext
*
s
,
int
mb_x
,
int
mb_y
)
...
...
libavcodec/utils.c
View file @
316a2ec8
...
@@ -707,6 +707,7 @@ static AVOption options[]={
...
@@ -707,6 +707,7 @@ static AVOption options[]={
{
"mb_lmin"
,
NULL
,
OFFSET
(
mb_lmin
),
FF_OPT_TYPE_INT
,
DEFAULT
,
INT_MIN
,
INT_MAX
,
V
|
E
},
{
"mb_lmin"
,
NULL
,
OFFSET
(
mb_lmin
),
FF_OPT_TYPE_INT
,
DEFAULT
,
INT_MIN
,
INT_MAX
,
V
|
E
},
{
"mb_lmax"
,
NULL
,
OFFSET
(
mb_lmax
),
FF_OPT_TYPE_INT
,
DEFAULT
,
INT_MIN
,
INT_MAX
,
V
|
E
},
{
"mb_lmax"
,
NULL
,
OFFSET
(
mb_lmax
),
FF_OPT_TYPE_INT
,
DEFAULT
,
INT_MIN
,
INT_MAX
,
V
|
E
},
{
"me_penalty_compensation"
,
NULL
,
OFFSET
(
me_penalty_compensation
),
FF_OPT_TYPE_INT
,
DEFAULT
,
INT_MIN
,
INT_MAX
,
V
|
E
},
{
"me_penalty_compensation"
,
NULL
,
OFFSET
(
me_penalty_compensation
),
FF_OPT_TYPE_INT
,
DEFAULT
,
INT_MIN
,
INT_MAX
,
V
|
E
},
{
"bidir_refine"
,
NULL
,
OFFSET
(
bidir_refine
),
FF_OPT_TYPE_INT
,
DEFAULT
,
0
,
4
,
V
|
E
},
{
NULL
},
{
NULL
},
};
};
...
...
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