FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavfilter/vf_ccrepack.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 0 18 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 "filters.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 FilterLink *l = ff_filter_link(link);
53 CCRepackContext *ctx = link->dst->priv;
54
55 int ret = ff_ccfifo_init(&ctx->cc_fifo, l->frame_rate, ctx);
56 if (ret < 0) {
57 av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n");
58 return ret;
59 }
60
61 return 0;
62 }
63
64 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
65 {
66 CCRepackContext *ctx = inlink->dst->priv;
67 AVFilterLink *outlink = inlink->dst->outputs[0];
68
69 ff_ccfifo_extract(&ctx->cc_fifo, frame);
70 ff_ccfifo_inject(&ctx->cc_fifo, frame);
71
72 return ff_filter_frame(outlink, frame);
73 }
74
75 static av_cold void uninit(AVFilterContext *ctx)
76 {
77 CCRepackContext *s = ctx->priv;
78 ff_ccfifo_uninit(&s->cc_fifo);
79 }
80
81 static const AVFilterPad avfilter_vf_ccrepack_inputs[] = {
82 {
83 .name = "default",
84 .type = AVMEDIA_TYPE_VIDEO,
85 .filter_frame = filter_frame,
86 .config_props = config_input,
87 },
88 };
89
90 const AVFilter ff_vf_ccrepack = {
91 .name = "ccrepack",
92 .description = NULL_IF_CONFIG_SMALL("Repack CEA-708 closed caption metadata"),
93 .uninit = uninit,
94 .priv_size = sizeof(CCRepackContext),
95 .priv_class = &ccrepack_class,
96 FILTER_INPUTS(avfilter_vf_ccrepack_inputs),
97 FILTER_OUTPUTS(ff_video_default_filterpad),
98 };
99