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
8be56ee2
Commit
8be56ee2
authored
Dec 04, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_showinfo: allow checksums calculation to be disabled
Fixes #6987.
parent
5ecd4f24
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
16 deletions
+47
-16
filters.texi
doc/filters.texi
+7
-0
vf_showinfo.c
libavfilter/vf_showinfo.c
+40
-16
No files found.
doc/filters.texi
View file @
8be56ee2
...
...
@@ -15304,6 +15304,13 @@ Keep the same colorspace property (default).
Show
a
line
containing
various
information
for
each
input
video
frame
.
The
input
video
is
not
modified
.
This
filter
supports
the
following
options
:
@
table
@
option
@
item
checksum
Calculate
checksums
of
each
plane
.
By
default
enabled
.
@
end
table
The
shown
line
contains
a
sequence
of
key
/
value
pairs
of
the
form
@
var
{
key
}:@
var
{
value
}.
...
...
libavfilter/vf_showinfo.c
View file @
8be56ee2
...
...
@@ -28,6 +28,7 @@
#include "libavutil/display.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/spherical.h"
#include "libavutil/stereo3d.h"
...
...
@@ -38,6 +39,21 @@
#include "internal.h"
#include "video.h"
typedef
struct
ShowInfoContext
{
const
AVClass
*
class
;
int
calculate_checksums
;
}
ShowInfoContext
;
#define OFFSET(x) offsetof(ShowInfoContext, x)
#define VF AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
static
const
AVOption
showinfo_options
[]
=
{
{
"checksum"
,
"calculate checksums"
,
OFFSET
(
calculate_checksums
),
AV_OPT_TYPE_BOOL
,
{.
i64
=
1
},
0
,
1
,
VF
},
{
NULL
}
};
AVFILTER_DEFINE_CLASS
(
showinfo
);
static
void
dump_spherical
(
AVFilterContext
*
ctx
,
AVFrame
*
frame
,
AVFrameSideData
*
sd
)
{
AVSphericalMapping
*
spherical
=
(
AVSphericalMapping
*
)
sd
->
data
;
...
...
@@ -141,13 +157,14 @@ static void update_sample_stats(const uint8_t *src, int len, int64_t *sum, int64
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
frame
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
ShowInfoContext
*
s
=
ctx
->
priv
;
const
AVPixFmtDescriptor
*
desc
=
av_pix_fmt_desc_get
(
inlink
->
format
);
uint32_t
plane_checksum
[
4
]
=
{
0
},
checksum
=
0
;
int64_t
sum
[
4
]
=
{
0
},
sum2
[
4
]
=
{
0
};
int32_t
pixelcount
[
4
]
=
{
0
};
int
i
,
plane
,
vsub
=
desc
->
log2_chroma_h
;
for
(
plane
=
0
;
plane
<
4
&&
frame
->
data
[
plane
]
&&
frame
->
linesize
[
plane
];
plane
++
)
{
for
(
plane
=
0
;
plane
<
4
&&
s
->
calculate_checksums
&&
frame
->
data
[
plane
]
&&
frame
->
linesize
[
plane
];
plane
++
)
{
uint8_t
*
data
=
frame
->
data
[
plane
];
int
h
=
plane
==
1
||
plane
==
2
?
AV_CEIL_RSHIFT
(
inlink
->
h
,
vsub
)
:
inlink
->
h
;
int
linesize
=
av_image_get_linesize
(
frame
->
format
,
frame
->
width
,
plane
);
...
...
@@ -167,8 +184,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
av_log
(
ctx
,
AV_LOG_INFO
,
"n:%4"
PRId64
" pts:%7s pts_time:%-7s pos:%9"
PRId64
" "
"fmt:%s sar:%d/%d s:%dx%d i:%c iskey:%d type:%c "
"checksum:%08"
PRIX32
" plane_checksum:[%08"
PRIX32
,
"fmt:%s sar:%d/%d s:%dx%d i:%c iskey:%d type:%c "
,
inlink
->
frame_count_out
,
av_ts2str
(
frame
->
pts
),
av_ts2timestr
(
frame
->
pts
,
&
inlink
->
time_base
),
frame
->
pkt_pos
,
desc
->
name
,
...
...
@@ -177,19 +193,25 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
!
frame
->
interlaced_frame
?
'P'
:
/* Progressive */
frame
->
top_field_first
?
'T'
:
'B'
,
/* Top / Bottom */
frame
->
key_frame
,
av_get_picture_type_char
(
frame
->
pict_type
),
checksum
,
plane_checksum
[
0
]);
for
(
plane
=
1
;
plane
<
4
&&
frame
->
data
[
plane
]
&&
frame
->
linesize
[
plane
];
plane
++
)
av_log
(
ctx
,
AV_LOG_INFO
,
" %08"
PRIX32
,
plane_checksum
[
plane
]);
av_log
(
ctx
,
AV_LOG_INFO
,
"] mean:["
);
for
(
plane
=
0
;
plane
<
4
&&
frame
->
data
[
plane
]
&&
frame
->
linesize
[
plane
];
plane
++
)
av_log
(
ctx
,
AV_LOG_INFO
,
"%"
PRId64
" "
,
(
sum
[
plane
]
+
pixelcount
[
plane
]
/
2
)
/
pixelcount
[
plane
]);
av_log
(
ctx
,
AV_LOG_INFO
,
"
\b
] stdev:["
);
for
(
plane
=
0
;
plane
<
4
&&
frame
->
data
[
plane
]
&&
frame
->
linesize
[
plane
];
plane
++
)
av_log
(
ctx
,
AV_LOG_INFO
,
"%3.1f "
,
sqrt
((
sum2
[
plane
]
-
sum
[
plane
]
*
(
double
)
sum
[
plane
]
/
pixelcount
[
plane
])
/
pixelcount
[
plane
]));
av_log
(
ctx
,
AV_LOG_INFO
,
"
\b
]
\n
"
);
av_get_picture_type_char
(
frame
->
pict_type
));
if
(
s
->
calculate_checksums
)
{
av_log
(
ctx
,
AV_LOG_INFO
,
"checksum:%08"
PRIX32
" plane_checksum:[%08"
PRIX32
,
checksum
,
plane_checksum
[
0
]);
for
(
plane
=
1
;
plane
<
4
&&
frame
->
data
[
plane
]
&&
frame
->
linesize
[
plane
];
plane
++
)
av_log
(
ctx
,
AV_LOG_INFO
,
" %08"
PRIX32
,
plane_checksum
[
plane
]);
av_log
(
ctx
,
AV_LOG_INFO
,
"] mean:["
);
for
(
plane
=
0
;
plane
<
4
&&
frame
->
data
[
plane
]
&&
frame
->
linesize
[
plane
];
plane
++
)
av_log
(
ctx
,
AV_LOG_INFO
,
"%"
PRId64
" "
,
(
sum
[
plane
]
+
pixelcount
[
plane
]
/
2
)
/
pixelcount
[
plane
]);
av_log
(
ctx
,
AV_LOG_INFO
,
"
\b
] stdev:["
);
for
(
plane
=
0
;
plane
<
4
&&
frame
->
data
[
plane
]
&&
frame
->
linesize
[
plane
];
plane
++
)
av_log
(
ctx
,
AV_LOG_INFO
,
"%3.1f "
,
sqrt
((
sum2
[
plane
]
-
sum
[
plane
]
*
(
double
)
sum
[
plane
]
/
pixelcount
[
plane
])
/
pixelcount
[
plane
]));
av_log
(
ctx
,
AV_LOG_INFO
,
"
\b
]"
);
}
av_log
(
ctx
,
AV_LOG_INFO
,
"
\n
"
);
for
(
i
=
0
;
i
<
frame
->
nb_side_data
;
i
++
)
{
AVFrameSideData
*
sd
=
frame
->
side_data
[
i
];
...
...
@@ -285,4 +307,6 @@ AVFilter ff_vf_showinfo = {
.
description
=
NULL_IF_CONFIG_SMALL
(
"Show textual information for each video frame."
),
.
inputs
=
avfilter_vf_showinfo_inputs
,
.
outputs
=
avfilter_vf_showinfo_outputs
,
.
priv_size
=
sizeof
(
ShowInfoContext
),
.
priv_class
=
&
showinfo_class
,
};
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