FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavfilter/vf_ccrepack.c
Date: 2024-04-19 17:50:32
Exec Total Coverage
Lines: 0 17 0.0%
Functions: 0 3 0.0%
Branches: 0 2 0.0%

Line Branch Exec Source
1 /*
2 * CEA-708 Closed Caption Repacker
3 * Copyright (c) 2023 LTN Global Communications
4 *
5 * Author: Devin Heitmueller <dheitmueller@ltnglobal.com>
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 /*
25 * Repackage CEA-708 arrays, which deals with incorrect cc_count for a given
26 * output framerate, and incorrect 708 padding.
27 *
28 * See CEA CEA-10-A "EIA-708-B Implementation Guidance", Section 26.5
29 * "Grouping DTVCC Data Within user_data() Structure"
30 */
31
32 #include "avfilter.h"
33 #include "internal.h"
34 #include "ccfifo.h"
35 #include "video.h"
36 #include "libavutil/opt.h"
37
38 typedef struct CCRepackContext
39 {
40 const AVClass *class;
41 CCFifo cc_fifo;
42 } CCRepackContext;
43
44 static const AVOption ccrepack_options[] = {
45 { NULL }
46 };
47
48 AVFILTER_DEFINE_CLASS(ccrepack);
49
50 static int config_input(AVFilterLink *link)
51 {
52 CCRepackContext *ctx = link->dst->priv;
53
54 int ret = ff_ccfifo_init(&ctx->cc_fifo, link->frame_rate, ctx);
55 if (ret < 0) {
56 av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n");
57 return ret;
58 }
59
60 return 0;
61 }
62
63 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
64 {
65 CCRepackContext *ctx = inlink->dst->priv;
66 AVFilterLink *outlink = inlink->dst->outputs[0];
67
68 ff_ccfifo_extract(&ctx->cc_fifo, frame);
69 ff_ccfifo_inject(&ctx->cc_fifo, frame);
70
71 return ff_filter_frame(outlink, frame);
72 }
73
74 static av_cold void uninit(AVFilterContext *ctx)
75 {
76 CCRepackContext *s = ctx->priv;
77 ff_ccfifo_uninit(&s->cc_fifo);
78 }
79
80 static const AVFilterPad avfilter_vf_ccrepack_inputs[] = {
81 {
82 .name = "default",
83 .type = AVMEDIA_TYPE_VIDEO,
84 .filter_frame = filter_frame,
85 .config_props = config_input,
86 },
87 };
88
89 const AVFilter ff_vf_ccrepack = {
90 .name = "ccrepack",
91 .description = NULL_IF_CONFIG_SMALL("Repack CEA-708 closed caption metadata"),
92 .uninit = uninit,
93 .priv_size = sizeof(CCRepackContext),
94 .priv_class = &ccrepack_class,
95 FILTER_INPUTS(avfilter_vf_ccrepack_inputs),
96 FILTER_OUTPUTS(ff_video_default_filterpad),
97 };
98