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
964465eb
Commit
964465eb
authored
Oct 10, 2011
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libmodplug: simpler and faster use of eval expr.
parent
d377deaa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
13 deletions
+10
-13
libmodplug.c
libavformat/libmodplug.c
+10
-13
No files found.
libavformat/libmodplug.c
View file @
964465eb
...
@@ -55,7 +55,7 @@ typedef struct ModPlugContext {
...
@@ -55,7 +55,7 @@ typedef struct ModPlugContext {
int
fsize
;
///< constant frame size
int
fsize
;
///< constant frame size
int
linesize
;
///< line size in bytes
int
linesize
;
///< line size in bytes
char
*
color_eval
;
///< color eval user input expression
char
*
color_eval
;
///< color eval user input expression
int
eval_err
;
///< 1 if eval failed once, otherwise 0 (used to disable video)
AVExpr
*
expr
;
///< parsed color eval expression
}
ModPlugContext
;
}
ModPlugContext
;
static
const
char
*
var_names
[]
=
{
static
const
char
*
var_names
[]
=
{
...
@@ -167,7 +167,7 @@ static int modplug_read_header(AVFormatContext *s, AVFormatParameters *ap)
...
@@ -167,7 +167,7 @@ static int modplug_read_header(AVFormatContext *s, AVFormatParameters *ap)
AVIOContext
*
pb
=
s
->
pb
;
AVIOContext
*
pb
=
s
->
pb
;
ModPlug_Settings
settings
;
ModPlug_Settings
settings
;
ModPlugContext
*
modplug
=
s
->
priv_data
;
ModPlugContext
*
modplug
=
s
->
priv_data
;
int
sz
=
avio_size
(
pb
);
int
r
,
sz
=
avio_size
(
pb
);
if
(
sz
<
0
)
{
if
(
sz
<
0
)
{
av_log
(
s
,
AV_LOG_WARNING
,
"Could not determine file size
\n
"
);
av_log
(
s
,
AV_LOG_WARNING
,
"Could not determine file size
\n
"
);
...
@@ -178,6 +178,12 @@ static int modplug_read_header(AVFormatContext *s, AVFormatParameters *ap)
...
@@ -178,6 +178,12 @@ static int modplug_read_header(AVFormatContext *s, AVFormatParameters *ap)
"but demuxing is likely to fail due to incomplete buffer
\n
"
,
"but demuxing is likely to fail due to incomplete buffer
\n
"
,
sz
==
FF_MODPLUG_DEF_FILE_SIZE
?
" (see -max_size)"
:
""
,
sz
);
sz
==
FF_MODPLUG_DEF_FILE_SIZE
?
" (see -max_size)"
:
""
,
sz
);
}
}
r
=
av_expr_parse
(
&
modplug
->
expr
,
modplug
->
color_eval
,
var_names
,
NULL
,
NULL
,
NULL
,
NULL
,
0
,
s
);
if
(
r
<
0
)
return
r
;
modplug
->
buf
=
av_malloc
(
modplug
->
max_size
);
modplug
->
buf
=
av_malloc
(
modplug
->
max_size
);
if
(
!
modplug
->
buf
)
if
(
!
modplug
->
buf
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
...
@@ -294,23 +300,14 @@ static int modplug_read_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -294,23 +300,14 @@ static int modplug_read_packet(AVFormatContext *s, AVPacket *pkt)
PRINT_INFO
(
5
,
"ts"
,
VAR_TIME
);
PRINT_INFO
(
5
,
"ts"
,
VAR_TIME
);
}
}
if
(
modplug
->
color_eval
&&
!
modplug
->
eval_er
r
)
{
if
(
modplug
->
exp
r
)
{
int
x
,
y
;
int
x
,
y
;
for
(
y
=
0
;
y
<
modplug
->
h
;
y
++
)
{
for
(
y
=
0
;
y
<
modplug
->
h
;
y
++
)
{
for
(
x
=
0
;
x
<
modplug
->
w
;
x
++
)
{
for
(
x
=
0
;
x
<
modplug
->
w
;
x
++
)
{
double
color
;
double
color
;
var_values
[
VAR_X
]
=
x
;
var_values
[
VAR_X
]
=
x
;
var_values
[
VAR_Y
]
=
y
;
var_values
[
VAR_Y
]
=
y
;
if
(
av_expr_parse_and_eval
(
&
color
,
modplug
->
color_eval
,
color
=
av_expr_eval
(
modplug
->
expr
,
var_values
,
NULL
);
var_names
,
var_values
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
0
,
s
)
<
0
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Error while evaluating the expression '%s' with x=%d y=%d
\n
"
,
modplug
->
color_eval
,
x
,
y
);
modplug
->
eval_err
=
1
;
return
0
;
}
pkt
->
data
[
y
*
modplug
->
linesize
+
x
*
3
+
2
]
|=
av_clip
((
int
)
color
,
0
,
0xf
)
<<
4
;
pkt
->
data
[
y
*
modplug
->
linesize
+
x
*
3
+
2
]
|=
av_clip
((
int
)
color
,
0
,
0xf
)
<<
4
;
}
}
}
}
...
...
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