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
df3222d4
Commit
df3222d4
authored
Dec 18, 2017
by
Ronald S. Bultje
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libvmaf: exit gracefully if the library fails.
Fixes trac issue #6884 and Netflix/vmaf issue #124.
parent
3f887440
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
6 deletions
+23
-6
vf_libvmaf.c
libavfilter/vf_libvmaf.c
+23
-6
No files found.
libavfilter/vf_libvmaf.c
View file @
df3222d4
...
@@ -61,6 +61,7 @@ typedef struct LIBVMAFContext {
...
@@ -61,6 +61,7 @@ typedef struct LIBVMAFContext {
int
ssim
;
int
ssim
;
int
ms_ssim
;
int
ms_ssim
;
char
*
pool
;
char
*
pool
;
int
error
;
}
LIBVMAFContext
;
}
LIBVMAFContext
;
#define OFFSET(x) offsetof(LIBVMAFContext, x)
#define OFFSET(x) offsetof(LIBVMAFContext, x)
...
@@ -158,18 +159,26 @@ static void compute_vmaf_score(LIBVMAFContext *s)
...
@@ -158,18 +159,26 @@ static void compute_vmaf_score(LIBVMAFContext *s)
format
=
(
char
*
)
s
->
desc
->
name
;
format
=
(
char
*
)
s
->
desc
->
name
;
s
->
vmaf_score
=
compute_vmaf
(
format
,
s
->
width
,
s
->
height
,
read_frame
,
s
,
s
->
error
=
compute_vmaf
(
&
s
->
vmaf_score
,
format
,
s
->
width
,
s
->
height
,
s
->
model_path
,
s
->
log_path
,
s
->
log_fmt
,
0
,
0
,
read_frame
,
s
,
s
->
model_path
,
s
->
log_path
,
s
->
enable_transform
,
s
->
phone_model
,
s
->
psnr
,
s
->
log_fmt
,
0
,
0
,
s
->
enable_transform
,
s
->
ssim
,
s
->
ms_ssim
,
s
->
pool
);
s
->
phone_model
,
s
->
psnr
,
s
->
ssim
,
s
->
ms_ssim
,
s
->
pool
);
}
}
static
void
*
call_vmaf
(
void
*
ctx
)
static
void
*
call_vmaf
(
void
*
ctx
)
{
{
LIBVMAFContext
*
s
=
(
LIBVMAFContext
*
)
ctx
;
LIBVMAFContext
*
s
=
(
LIBVMAFContext
*
)
ctx
;
compute_vmaf_score
(
s
);
compute_vmaf_score
(
s
);
av_log
(
ctx
,
AV_LOG_INFO
,
"VMAF score: %f
\n
"
,
s
->
vmaf_score
);
if
(
!
s
->
error
)
{
av_log
(
ctx
,
AV_LOG_INFO
,
"VMAF score: %f
\n
"
,
s
->
vmaf_score
);
}
else
{
pthread_mutex_lock
(
&
s
->
lock
);
pthread_cond_signal
(
&
s
->
cond
);
pthread_mutex_unlock
(
&
s
->
lock
);
}
pthread_exit
(
NULL
);
pthread_exit
(
NULL
);
return
NULL
;
}
}
static
int
do_vmaf
(
FFFrameSync
*
fs
)
static
int
do_vmaf
(
FFFrameSync
*
fs
)
...
@@ -187,10 +196,17 @@ static int do_vmaf(FFFrameSync *fs)
...
@@ -187,10 +196,17 @@ static int do_vmaf(FFFrameSync *fs)
pthread_mutex_lock
(
&
s
->
lock
);
pthread_mutex_lock
(
&
s
->
lock
);
while
(
s
->
frame_set
!=
0
)
{
while
(
s
->
frame_set
&&
!
s
->
error
)
{
pthread_cond_wait
(
&
s
->
cond
,
&
s
->
lock
);
pthread_cond_wait
(
&
s
->
cond
,
&
s
->
lock
);
}
}
if
(
s
->
error
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"libvmaf encountered an error, check log for details
\n
"
);
pthread_mutex_unlock
(
&
s
->
lock
);
return
AVERROR
(
EINVAL
);
}
av_frame_ref
(
s
->
gref
,
ref
);
av_frame_ref
(
s
->
gref
,
ref
);
av_frame_ref
(
s
->
gmain
,
master
);
av_frame_ref
(
s
->
gmain
,
master
);
...
@@ -208,6 +224,7 @@ static av_cold int init(AVFilterContext *ctx)
...
@@ -208,6 +224,7 @@ static av_cold int init(AVFilterContext *ctx)
s
->
gref
=
av_frame_alloc
();
s
->
gref
=
av_frame_alloc
();
s
->
gmain
=
av_frame_alloc
();
s
->
gmain
=
av_frame_alloc
();
s
->
error
=
0
;
pthread_mutex_init
(
&
s
->
lock
,
NULL
);
pthread_mutex_init
(
&
s
->
lock
,
NULL
);
pthread_cond_init
(
&
s
->
cond
,
NULL
);
pthread_cond_init
(
&
s
->
cond
,
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