FFmpeg
Data Structures | Macros | Functions | Variables
webvttdec.c File Reference
#include "avformat.h"
#include "internal.h"
#include "subtitles.h"
#include "libavutil/bprint.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"

Go to the source code of this file.

Data Structures

struct  WebVTTContext
 

Macros

#define SET_SIDE_DATA(name, type)
 
#define OFFSET(x)   offsetof(WebVTTContext, x)
 
#define KIND_FLAGS   AV_OPT_FLAG_SUBTITLE_PARAM|AV_OPT_FLAG_DECODING_PARAM
 

Functions

static int webvtt_probe (const AVProbeData *p)
 
static int64_t read_ts (const char *s)
 
static int webvtt_read_header (AVFormatContext *s)
 
static int webvtt_read_packet (AVFormatContext *s, AVPacket *pkt)
 
static int webvtt_read_seek (AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
 
static int webvtt_read_close (AVFormatContext *s)
 

Variables

static const AVOption options []
 
static const AVClass webvtt_demuxer_class
 
const AVInputFormat ff_webvtt_demuxer
 

Detailed Description

WebVTT subtitle demuxer

See also
http://dev.w3.org/html5/webvtt/

Definition in file webvttdec.c.

Macro Definition Documentation

◆ SET_SIDE_DATA

#define SET_SIDE_DATA (   name,
  type 
)
Value:
do { \
if (name##_len) { \
uint8_t *buf = av_packet_new_side_data(sub, type, name##_len); \
if (!buf) { \
res = AVERROR(ENOMEM); \
goto end; \
} \
memcpy(buf, name, name##_len); \
} \
} while (0)

◆ OFFSET

#define OFFSET (   x)    offsetof(WebVTTContext, x)

Definition at line 192 of file webvttdec.c.

◆ KIND_FLAGS

Definition at line 193 of file webvttdec.c.

Function Documentation

◆ webvtt_probe()

static int webvtt_probe ( const AVProbeData p)
static

Definition at line 40 of file webvttdec.c.

◆ read_ts()

static int64_t read_ts ( const char *  s)
static

Definition at line 52 of file webvttdec.c.

Referenced by webvtt_read_header().

◆ webvtt_read_header()

static int webvtt_read_header ( AVFormatContext s)
static

Definition at line 60 of file webvttdec.c.

◆ webvtt_read_packet()

static int webvtt_read_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 171 of file webvttdec.c.

◆ webvtt_read_seek()

static int webvtt_read_seek ( AVFormatContext s,
int  stream_index,
int64_t  min_ts,
int64_t  ts,
int64_t  max_ts,
int  flags 
)
static

Definition at line 177 of file webvttdec.c.

◆ webvtt_read_close()

static int webvtt_read_close ( AVFormatContext s)
static

Definition at line 185 of file webvttdec.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "kind", "Set kind of WebVTT track", OFFSET(kind), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, KIND_FLAGS, "webvtt_kind" },
{ "subtitles", "WebVTT subtitles kind", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, KIND_FLAGS, "webvtt_kind" },
{ "captions", "WebVTT captions kind", 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CAPTIONS }, INT_MIN, INT_MAX, KIND_FLAGS, "webvtt_kind" },
{ "descriptions", "WebVTT descriptions kind", 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DESCRIPTIONS }, INT_MIN, INT_MAX, KIND_FLAGS, "webvtt_kind" },
{ "metadata", "WebVTT metadata kind", 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, INT_MIN, INT_MAX, KIND_FLAGS, "webvtt_kind" },
{ NULL }
}

Definition at line 195 of file webvttdec.c.

◆ webvtt_demuxer_class

const AVClass webvtt_demuxer_class
static
Initial value:
= {
.class_name = "WebVTT demuxer",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 204 of file webvttdec.c.

◆ ff_webvtt_demuxer

const AVInputFormat ff_webvtt_demuxer
Initial value:
= {
.name = "webvtt",
.long_name = NULL_IF_CONFIG_SMALL("WebVTT subtitle"),
.priv_data_size = sizeof(WebVTTContext),
.flags_internal = FF_FMT_INIT_CLEANUP,
.read_seek2 = webvtt_read_seek,
.extensions = "vtt",
.priv_class = &webvtt_demuxer_class,
}

Definition at line 211 of file webvttdec.c.

name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
FF_FMT_INIT_CLEANUP
#define FF_FMT_INIT_CLEANUP
For an AVInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
Definition: internal.h:49
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
sub
static float sub(float src0, float src1)
Definition: dnn_backend_native_layer_mathbinary.c:31
WebVTTContext
Definition: webvttenc.c:32
OFFSET
#define OFFSET(x)
Definition: webvttdec.c:192
read_close
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:141
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
read_header
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:527
NULL
#define NULL
Definition: coverity.c:32
read_probe
static int read_probe(const AVProbeData *pd)
Definition: jvdec.c:55
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
KIND_FLAGS
#define KIND_FLAGS
Definition: webvttdec.c:193
AV_DISPOSITION_METADATA
#define AV_DISPOSITION_METADATA
The subtitle stream contains time-aligned metadata that is not intended to be directly presented to t...
Definition: avformat.h:895
webvtt_demuxer_class
static const AVClass webvtt_demuxer_class
Definition: webvttdec.c:204
AV_DISPOSITION_CAPTIONS
#define AV_DISPOSITION_CAPTIONS
The subtitle stream contains captions, providing a transcription and possibly a translation of audio.
Definition: avformat.h:884
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
AV_DISPOSITION_DESCRIPTIONS
#define AV_DISPOSITION_DESCRIPTIONS
The subtitle stream contains a textual description of the video content.
Definition: avformat.h:890
webvtt_read_packet
static int webvtt_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: webvttdec.c:171
options
static const AVOption options[]
Definition: webvttdec.c:195
webvtt_read_close
static int webvtt_read_close(AVFormatContext *s)
Definition: webvttdec.c:185
webvtt_probe
static int webvtt_probe(const AVProbeData *p)
Definition: webvttdec.c:40
av_packet_new_side_data
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
Definition: avpacket.c:232
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
webvtt_read_seek
static int webvtt_read_seek(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Definition: webvttdec.c:177
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
webvtt_read_header
static int webvtt_read_header(AVFormatContext *s)
Definition: webvttdec.c:60