FFmpeg
libavcodec
bsf
showinfo.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2024 Anton Khirnov <anton@khirnov.net>
3
*
4
* This file is part of FFmpeg.
5
*
6
* FFmpeg is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
10
*
11
* FFmpeg is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with FFmpeg; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
21
#include <inttypes.h>
22
23
#include "
bsf.h
"
24
#include "
bsf_internal.h
"
25
26
#include "
libavutil/adler32.h
"
27
#include "
libavutil/log.h
"
28
#include "
libavutil/timestamp.h
"
29
30
typedef
struct
ShowinfoContext
{
31
uint64_t
nb_packets
;
32
}
ShowinfoContext
;
33
34
static
int
showinfo_filter
(
AVBSFContext
*
ctx
,
AVPacket
*
pkt
)
35
{
36
ShowinfoContext
*priv =
ctx
->
priv_data
;
37
uint32_t crc;
38
int
ret
;
39
40
ret
=
ff_bsf_get_packet_ref
(
ctx
,
pkt
);
41
if
(
ret
< 0)
42
return
ret
;
43
44
crc =
av_adler32_update
(0,
pkt
->
data
,
pkt
->
size
);
45
av_log
(
ctx
,
AV_LOG_INFO
,
46
"n:%7"
PRIu64
" "
47
"size:%7d "
48
"pts:%s pt:%s "
49
"dts:%s dt:%s "
50
"ds:%"
PRId64
" d:%s "
51
"adler32:0x%08"
PRIx32
52
"\n"
,
53
priv->
nb_packets
,
pkt
->
size
,
54
av_ts2str
(
pkt
->
pts
),
av_ts2timestr
(
pkt
->
pts
, &
ctx
->time_base_in),
55
av_ts2str
(
pkt
->
dts
),
av_ts2timestr
(
pkt
->
dts
, &
ctx
->time_base_in),
56
pkt
->
duration
,
av_ts2timestr
(
pkt
->
duration
, &
ctx
->time_base_in), crc);
57
58
priv->
nb_packets
++;
59
60
return
0;
61
}
62
63
const
FFBitStreamFilter
ff_showinfo_bsf
= {
64
.
p
.
name
=
"showinfo"
,
65
.filter =
showinfo_filter
,
66
.priv_data_size =
sizeof
(
ShowinfoContext
),
67
};
bsf_internal.h
AVBitStreamFilter::name
const char * name
Definition:
bsf.h:112
AVPacket::data
uint8_t * data
Definition:
packet.h:539
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition:
packet.h:557
showinfo_filter
static int showinfo_filter(AVBSFContext *ctx, AVPacket *pkt)
Definition:
showinfo.c:34
AVBSFContext
The bitstream filter state.
Definition:
bsf.h:68
bsf.h
pkt
AVPacket * pkt
Definition:
movenc.c:60
ctx
AVFormatContext * ctx
Definition:
movenc.c:49
FFBitStreamFilter
Definition:
bsf_internal.h:27
adler32.h
av_adler32_update
AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf, size_t len)
Calculate the Adler32 checksum of a buffer.
Definition:
adler32.c:44
FFBitStreamFilter::p
AVBitStreamFilter p
The public AVBitStreamFilter.
Definition:
bsf_internal.h:31
av_ts2timestr
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition:
timestamp.h:83
AVPacket::size
int size
Definition:
packet.h:540
ff_showinfo_bsf
const FFBitStreamFilter ff_showinfo_bsf
Definition:
showinfo.c:63
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition:
packet.h:538
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition:
log.h:220
log.h
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition:
packet.h:532
ShowinfoContext
Definition:
showinfo.c:30
ShowinfoContext::nb_packets
uint64_t nb_packets
Definition:
showinfo.c:31
ret
ret
Definition:
filter_design.txt:187
AVPacket
This structure stores compressed data.
Definition:
packet.h:516
timestamp.h
av_log
#define av_log(a,...)
Definition:
tableprint_vlc.h:27
ff_bsf_get_packet_ref
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
Called by bitstream filters to get packet for filtering.
Definition:
bsf.c:256
av_ts2str
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition:
timestamp.h:54
AVFormatContext::priv_data
void * priv_data
Format private data.
Definition:
avformat.h:1328
Generated on Thu Nov 21 2024 19:21:32 for FFmpeg by
1.8.17