FFmpeg
Loading...
Searching...
No Matches
ccfifo.h
Go to the documentation of this file.
1/*
2 * CEA-708 Closed Captioning FIFO
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 * @file
26 * CC FIFO Buffer
27 */
28
29#ifndef AVFILTER_CCFIFO_H
30#define AVFILTER_CCFIFO_H
31
32#include <stddef.h>
33#include <stdint.h>
34
35#include "libavutil/frame.h"
36#include "libavutil/rational.h"
37
38#define CC_BYTES_PER_ENTRY 3
39
52
53/**
54 * Initialize a CCFifo.
55 *
56 * @param framerate output framerate
57 * @param log_ctx used for any av_log() calls
58 * @return Zero on success, or negative AVERROR code on failure.
59 */
60int ff_ccfifo_init(CCFifo *ccf, AVRational framerate, void *log_ctx);
61
62/**
63 * Free all memory allocated in a CCFifo and clear the context.
64 *
65 * @param ccf Pointer to the CCFifo which should be uninitialized
66 */
67void ff_ccfifo_uninit(CCFifo *ccf);
68
69/**
70 * Extract CC data from an AVFrame
71 *
72 * Extract CC bytes from the AVFrame, insert them into our queue, and
73 * remove the side data from the AVFrame. The side data is removed
74 * as it will be re-inserted at the appropriate rate later in the
75 * filter.
76 *
77 * @param af CCFifo to write to
78 * @param frame AVFrame with the video frame to operate on
79 * @return Zero on success, or negative AVERROR
80 * code on failure. On failure, the tuples that fit are
81 * still queued and the side data is still removed.
82 */
84
85/**
86 *Just like ff_ccfifo_extract(), but takes the raw bytes instead of an AVFrame
87 */
88int ff_ccfifo_extractbytes(CCFifo *ccf, uint8_t *data, size_t len);
89
90/**
91 * Provide the size in bytes of an output buffer to allocate
92 *
93 * Ask for how many bytes the output will contain, so the caller can allocate
94 * an appropriately sized buffer and pass it to ff_ccfifo_injectbytes()
95 *
96 */
97static inline int ff_ccfifo_getoutputsize(const CCFifo *ccf)
98{
100}
101
102
103/**
104 * Insert CC data from the FIFO into an AVFrame (as side data)
105 *
106 * Dequeue the appropriate number of CC tuples based on the
107 * frame rate, and insert them into the AVFrame
108 *
109 * @param af CCFifo to read from
110 * @param frame AVFrame with the video frame to operate on
111 * @return Zero on success, or negative AVERROR
112 * code on failure.
113 */
115
116/**
117 * Just like ff_ccfifo_inject(), but takes the raw bytes to insert the CC data
118 * int rather than an AVFrame
119 */
120int ff_ccfifo_injectbytes(CCFifo *ccf, uint8_t *data, size_t len);
121
122/**
123 * Returns 1 if captions have been found as a prior call
124 * to ff_ccfifo_extract() or ff_ccfifo_extractbytes()
125 */
126static inline int ff_ccfifo_ccdetected(const CCFifo *ccf)
127{
128 return ccf->cc_detected;
129}
130
131#endif /* AVFILTER_CCFIFO_H */
int ff_ccfifo_inject(CCFifo *ccf, AVFrame *frame)
Insert CC data from the FIFO into an AVFrame (as side data)
Definition ccfifo.c:142
static int ff_ccfifo_ccdetected(const CCFifo *ccf)
Returns 1 if captions have been found as a prior call to ff_ccfifo_extract() or ff_ccfifo_extractbyte...
Definition ccfifo.h:126
int ff_ccfifo_init(CCFifo *ccf, AVRational framerate, void *log_ctx)
Initialize a CCFifo.
Definition ccfifo.c:57
int ff_ccfifo_injectbytes(CCFifo *ccf, uint8_t *data, size_t len)
Just like ff_ccfifo_inject(), but takes the raw bytes to insert the CC data int rather than an AVFram...
Definition ccfifo.c:101
static int ff_ccfifo_getoutputsize(const CCFifo *ccf)
Provide the size in bytes of an output buffer to allocate.
Definition ccfifo.h:97
#define CC_BYTES_PER_ENTRY
Definition ccfifo.h:38
void ff_ccfifo_uninit(CCFifo *ccf)
Free all memory allocated in a CCFifo and clear the context.
Definition ccfifo.c:50
int ff_ccfifo_extractbytes(CCFifo *ccf, uint8_t *data, size_t len)
Just like ff_ccfifo_extract(), but takes the raw bytes instead of an AVFrame.
Definition ccfifo.c:163
int ff_ccfifo_extract(CCFifo *ccf, AVFrame *frame)
Extract CC data from an AVFrame.
Definition ccfifo.c:200
static AVFrame * frame
reference-counted frame API
const char data[16]
Definition mxf.c:149
Utilities for rational number calculation.
Definition fifo.c:35
This structure describes decoded (raw) audio or video data.
Definition frame.h:479
Rational number (pair of numerator and denominator).
Definition rational.h:58
int expected_cc_count
Definition ccfifo.h:44
int cc_detected
Definition ccfifo.h:46
struct AVFifo * cc_608_fifo
Definition ccfifo.h:41
int expected_608
Definition ccfifo.h:45
struct AVFifo * cc_708_fifo
Definition ccfifo.h:42
void * log_ctx
Definition ccfifo.h:50
int overflow_warning
Definition ccfifo.h:49
int passthrough_warning
Definition ccfifo.h:48
AVRational framerate
Definition ccfifo.h:43
int passthrough
Definition ccfifo.h:47
float framerate
Definition av1_levels.c:29
int len