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
296eff4d
Commit
296eff4d
authored
May 22, 2016
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zmbvenc: get rid of a global table
parent
00b775dd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
zmbvenc.c
libavcodec/zmbvenc.c
+9
-7
No files found.
libavcodec/zmbvenc.c
View file @
296eff4d
...
@@ -54,16 +54,18 @@ typedef struct ZmbvEncContext {
...
@@ -54,16 +54,18 @@ typedef struct ZmbvEncContext {
int
comp_size
;
int
comp_size
;
int
keyint
,
curfrm
;
int
keyint
,
curfrm
;
z_stream
zstream
;
z_stream
zstream
;
int
score_tab
[
256
];
}
ZmbvEncContext
;
}
ZmbvEncContext
;
static
int
score_tab
[
256
];
/** Block comparing function
/** Block comparing function
* XXX should be optimized and moved to DSPContext
* XXX should be optimized and moved to DSPContext
* TODO handle out of edge ME
* TODO handle out of edge ME
*/
*/
static
inline
int
block_cmp
(
uint8_t
*
src
,
int
stride
,
uint8_t
*
src2
,
int
stride2
,
static
inline
int
block_cmp
(
ZmbvEncContext
*
c
,
uint8_t
*
src
,
int
stride
,
int
bw
,
int
bh
,
int
*
xored
)
uint8_t
*
src2
,
int
stride2
,
int
bw
,
int
bh
,
int
*
xored
)
{
{
int
sum
=
0
;
int
sum
=
0
;
int
i
,
j
;
int
i
,
j
;
...
@@ -81,7 +83,7 @@ static inline int block_cmp(uint8_t *src, int stride, uint8_t *src2, int stride2
...
@@ -81,7 +83,7 @@ static inline int block_cmp(uint8_t *src, int stride, uint8_t *src2, int stride2
}
}
for
(
i
=
1
;
i
<
256
;
i
++
)
for
(
i
=
1
;
i
<
256
;
i
++
)
sum
+=
score_tab
[
histogram
[
i
]];
sum
+=
c
->
score_tab
[
histogram
[
i
]];
return
sum
;
return
sum
;
}
}
...
@@ -97,14 +99,14 @@ static int zmbv_me(ZmbvEncContext *c, uint8_t *src, int sstride, uint8_t *prev,
...
@@ -97,14 +99,14 @@ static int zmbv_me(ZmbvEncContext *c, uint8_t *src, int sstride, uint8_t *prev,
*
mx
=
*
my
=
0
;
*
mx
=
*
my
=
0
;
bw
=
FFMIN
(
ZMBV_BLOCK
,
c
->
avctx
->
width
-
x
);
bw
=
FFMIN
(
ZMBV_BLOCK
,
c
->
avctx
->
width
-
x
);
bh
=
FFMIN
(
ZMBV_BLOCK
,
c
->
avctx
->
height
-
y
);
bh
=
FFMIN
(
ZMBV_BLOCK
,
c
->
avctx
->
height
-
y
);
bv
=
block_cmp
(
src
,
sstride
,
prev
,
pstride
,
bw
,
bh
,
xored
);
bv
=
block_cmp
(
c
,
src
,
sstride
,
prev
,
pstride
,
bw
,
bh
,
xored
);
if
(
!
bv
)
return
0
;
if
(
!
bv
)
return
0
;
for
(
ty
=
FFMAX
(
y
-
c
->
range
,
0
);
ty
<
FFMIN
(
y
+
c
->
range
,
c
->
avctx
->
height
-
bh
);
ty
++
){
for
(
ty
=
FFMAX
(
y
-
c
->
range
,
0
);
ty
<
FFMIN
(
y
+
c
->
range
,
c
->
avctx
->
height
-
bh
);
ty
++
){
for
(
tx
=
FFMAX
(
x
-
c
->
range
,
0
);
tx
<
FFMIN
(
x
+
c
->
range
,
c
->
avctx
->
width
-
bw
);
tx
++
){
for
(
tx
=
FFMAX
(
x
-
c
->
range
,
0
);
tx
<
FFMIN
(
x
+
c
->
range
,
c
->
avctx
->
width
-
bw
);
tx
++
){
if
(
tx
==
x
&&
ty
==
y
)
continue
;
// we already tested this block
if
(
tx
==
x
&&
ty
==
y
)
continue
;
// we already tested this block
dx
=
tx
-
x
;
dx
=
tx
-
x
;
dy
=
ty
-
y
;
dy
=
ty
-
y
;
tv
=
block_cmp
(
src
,
sstride
,
prev
+
dx
+
dy
*
pstride
,
pstride
,
bw
,
bh
,
xored
);
tv
=
block_cmp
(
c
,
src
,
sstride
,
prev
+
dx
+
dy
*
pstride
,
pstride
,
bw
,
bh
,
xored
);
if
(
tv
<
bv
){
if
(
tv
<
bv
){
bv
=
tv
;
bv
=
tv
;
*
mx
=
dx
;
*
mx
=
dx
;
...
@@ -279,7 +281,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
...
@@ -279,7 +281,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
int
lvl
=
9
;
int
lvl
=
9
;
for
(
i
=
1
;
i
<
256
;
i
++
)
for
(
i
=
1
;
i
<
256
;
i
++
)
score_tab
[
i
]
=
-
i
*
log
(
i
/
(
double
)(
ZMBV_BLOCK
*
ZMBV_BLOCK
))
*
(
256
/
M_LN2
);
c
->
score_tab
[
i
]
=
-
i
*
log
(
i
/
(
double
)(
ZMBV_BLOCK
*
ZMBV_BLOCK
))
*
(
256
/
M_LN2
);
c
->
avctx
=
avctx
;
c
->
avctx
=
avctx
;
...
...
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