/src/ffmpeg/libavcodec/bsf/showinfo.c
Line | Count | 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 | 17.1k | { |
36 | 17.1k | ShowinfoContext *priv = ctx->priv_data; |
37 | 17.1k | uint32_t crc; |
38 | 17.1k | int ret; |
39 | | |
40 | 17.1k | ret = ff_bsf_get_packet_ref(ctx, pkt); |
41 | 17.1k | if (ret < 0) |
42 | 8.83k | return ret; |
43 | | |
44 | 8.35k | crc = av_adler32_update(0, pkt->data, pkt->size); |
45 | 8.35k | av_log(ctx, AV_LOG_INFO, |
46 | 8.35k | "n:%7"PRIu64" " |
47 | 8.35k | "size:%7d " |
48 | 8.35k | "pts:%s pt:%s " |
49 | 8.35k | "dts:%s dt:%s " |
50 | 8.35k | "ds:%"PRId64" d:%s " |
51 | 8.35k | "adler32:0x%08"PRIx32 |
52 | 8.35k | "\n", |
53 | 8.35k | priv->nb_packets, pkt->size, |
54 | 8.35k | av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ctx->time_base_in), |
55 | 8.35k | av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ctx->time_base_in), |
56 | 8.35k | pkt->duration, av_ts2timestr(pkt->duration, &ctx->time_base_in), crc); |
57 | | |
58 | 8.35k | priv->nb_packets++; |
59 | | |
60 | 8.35k | return 0; |
61 | 17.1k | } |
62 | | |
63 | | const FFBitStreamFilter ff_showinfo_bsf = { |
64 | | .p.name = "showinfo", |
65 | | .filter = showinfo_filter, |
66 | | .priv_data_size = sizeof(ShowinfoContext), |
67 | | }; |