Line |
Branch |
Exec |
Source |
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 |
|
|
}; |
68 |
|
|
|