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
4ea8406e
Commit
4ea8406e
authored
Sep 01, 2014
by
Reimar Döffinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vf_deshake: reduce stack usage.
Signed-off-by:
Reimar Döffinger
<
Reimar.Doeffinger@gmx.de
>
parent
3980ab12
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
deshake.h
libavfilter/deshake.h
+3
-0
vf_deshake.c
libavfilter/vf_deshake.c
+5
-8
No files found.
libavfilter/deshake.h
View file @
4ea8406e
...
@@ -71,8 +71,11 @@ typedef struct {
...
@@ -71,8 +71,11 @@ typedef struct {
#endif
#endif
#define MAX_R 64
typedef
struct
{
typedef
struct
{
const
AVClass
*
class
;
const
AVClass
*
class
;
int
counts
[
2
*
MAX_R
+
1
][
2
*
MAX_R
+
1
];
/// < Scratch buffer for motion search
AVFrame
*
ref
;
///< Previous frame
AVFrame
*
ref
;
///< Previous frame
int
rx
;
///< Maximum horizontal shift
int
rx
;
///< Maximum horizontal shift
int
ry
;
///< Maximum vertical shift
int
ry
;
///< Maximum vertical shift
...
...
libavfilter/vf_deshake.c
View file @
4ea8406e
...
@@ -67,8 +67,6 @@
...
@@ -67,8 +67,6 @@
#define OFFSET(x) offsetof(DeshakeContext, x)
#define OFFSET(x) offsetof(DeshakeContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
#define MAX_R 64
static
const
AVOption
deshake_options
[]
=
{
static
const
AVOption
deshake_options
[]
=
{
{
"x"
,
"set x for the rectangular search area"
,
OFFSET
(
cx
),
AV_OPT_TYPE_INT
,
{.
i64
=-
1
},
-
1
,
INT_MAX
,
.
flags
=
FLAGS
},
{
"x"
,
"set x for the rectangular search area"
,
OFFSET
(
cx
),
AV_OPT_TYPE_INT
,
{.
i64
=-
1
},
-
1
,
INT_MAX
,
.
flags
=
FLAGS
},
{
"y"
,
"set y for the rectangular search area"
,
OFFSET
(
cy
),
AV_OPT_TYPE_INT
,
{.
i64
=-
1
},
-
1
,
INT_MAX
,
.
flags
=
FLAGS
},
{
"y"
,
"set y for the rectangular search area"
,
OFFSET
(
cy
),
AV_OPT_TYPE_INT
,
{.
i64
=-
1
},
-
1
,
INT_MAX
,
.
flags
=
FLAGS
},
...
@@ -242,7 +240,6 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2,
...
@@ -242,7 +240,6 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2,
{
{
int
x
,
y
;
int
x
,
y
;
IntMotionVector
mv
=
{
0
,
0
};
IntMotionVector
mv
=
{
0
,
0
};
int
counts
[
2
*
MAX_R
+
1
][
2
*
MAX_R
+
1
];
int
count_max_value
=
0
;
int
count_max_value
=
0
;
int
contrast
;
int
contrast
;
...
@@ -254,7 +251,7 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2,
...
@@ -254,7 +251,7 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2,
// Reset counts to zero
// Reset counts to zero
for
(
x
=
0
;
x
<
deshake
->
rx
*
2
+
1
;
x
++
)
{
for
(
x
=
0
;
x
<
deshake
->
rx
*
2
+
1
;
x
++
)
{
for
(
y
=
0
;
y
<
deshake
->
ry
*
2
+
1
;
y
++
)
{
for
(
y
=
0
;
y
<
deshake
->
ry
*
2
+
1
;
y
++
)
{
counts
[
x
][
y
]
=
0
;
deshake
->
counts
[
x
][
y
]
=
0
;
}
}
}
}
...
@@ -270,7 +267,7 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2,
...
@@ -270,7 +267,7 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2,
//av_log(NULL, AV_LOG_ERROR, "%d\n", contrast);
//av_log(NULL, AV_LOG_ERROR, "%d\n", contrast);
find_block_motion
(
deshake
,
src1
,
src2
,
x
,
y
,
stride
,
&
mv
);
find_block_motion
(
deshake
,
src1
,
src2
,
x
,
y
,
stride
,
&
mv
);
if
(
mv
.
x
!=
-
1
&&
mv
.
y
!=
-
1
)
{
if
(
mv
.
x
!=
-
1
&&
mv
.
y
!=
-
1
)
{
counts
[
mv
.
x
+
deshake
->
rx
][
mv
.
y
+
deshake
->
ry
]
+=
1
;
deshake
->
counts
[
mv
.
x
+
deshake
->
rx
][
mv
.
y
+
deshake
->
ry
]
+=
1
;
if
(
x
>
deshake
->
rx
&&
y
>
deshake
->
ry
)
if
(
x
>
deshake
->
rx
&&
y
>
deshake
->
ry
)
angles
[
pos
++
]
=
block_angle
(
x
,
y
,
0
,
0
,
&
mv
);
angles
[
pos
++
]
=
block_angle
(
x
,
y
,
0
,
0
,
&
mv
);
...
@@ -294,11 +291,11 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2,
...
@@ -294,11 +291,11 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2,
// Find the most common motion vector in the frame and use it as the gmv
// Find the most common motion vector in the frame and use it as the gmv
for
(
y
=
deshake
->
ry
*
2
;
y
>=
0
;
y
--
)
{
for
(
y
=
deshake
->
ry
*
2
;
y
>=
0
;
y
--
)
{
for
(
x
=
0
;
x
<
deshake
->
rx
*
2
+
1
;
x
++
)
{
for
(
x
=
0
;
x
<
deshake
->
rx
*
2
+
1
;
x
++
)
{
//av_log(NULL, AV_LOG_ERROR, "%5d ", counts[x][y]);
//av_log(NULL, AV_LOG_ERROR, "%5d ",
deshake->
counts[x][y]);
if
(
counts
[
x
][
y
]
>
count_max_value
)
{
if
(
deshake
->
counts
[
x
][
y
]
>
count_max_value
)
{
t
->
vector
.
x
=
x
-
deshake
->
rx
;
t
->
vector
.
x
=
x
-
deshake
->
rx
;
t
->
vector
.
y
=
y
-
deshake
->
ry
;
t
->
vector
.
y
=
y
-
deshake
->
ry
;
count_max_value
=
counts
[
x
][
y
];
count_max_value
=
deshake
->
counts
[
x
][
y
];
}
}
}
}
//av_log(NULL, AV_LOG_ERROR, "\n");
//av_log(NULL, AV_LOG_ERROR, "\n");
...
...
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