FFmpeg
Data Structures | Macros | Functions | Variables
spdifenc.c File Reference
#include <inttypes.h>
#include "avformat.h"
#include "avio_internal.h"
#include "spdif.h"
#include "libavcodec/ac3.h"
#include "libavcodec/adts_parser.h"
#include "libavcodec/dca.h"
#include "libavcodec/dca_syncwords.h"
#include "libavutil/opt.h"

Go to the source code of this file.

Data Structures

struct  IEC61937Context
 

Macros

#define SPDIF_FLAG_BIGENDIAN   0x01
 
#define MAT_FRAME_SIZE   61424
 
#define TRUEHD_FRAME_OFFSET   2560
 
#define MAT_MIDDLE_CODE_OFFSET   -4
 

Functions

static int spdif_header_ac3 (AVFormatContext *s, AVPacket *pkt)
 
static int spdif_header_eac3 (AVFormatContext *s, AVPacket *pkt)
 
static int spdif_dts4_subtype (int period)
 
static int spdif_header_dts4 (AVFormatContext *s, AVPacket *pkt, int core_size, int sample_rate, int blocks)
 
static int spdif_header_dts (AVFormatContext *s, AVPacket *pkt)
 
static int spdif_header_mpeg (AVFormatContext *s, AVPacket *pkt)
 
static int spdif_header_aac (AVFormatContext *s, AVPacket *pkt)
 
static int spdif_header_truehd (AVFormatContext *s, AVPacket *pkt)
 
static int spdif_write_header (AVFormatContext *s)
 
static int spdif_write_trailer (AVFormatContext *s)
 
static av_always_inline void spdif_put_16 (IEC61937Context *ctx, AVIOContext *pb, unsigned int val)
 
static int spdif_write_packet (struct AVFormatContext *s, AVPacket *pkt)
 

Variables

static const AVOption options []
 
static const AVClass spdif_class
 
static enum IEC61937DataType mpeg_data_type [2][3]
 
AVOutputFormat ff_spdif_muxer
 

Detailed Description

IEC-61937 encapsulation of various formats, used by S/PDIF

Author
Bartlomiej Wolowiec
Anssi Hannula
Carl Eugen Hoyos

Definition in file spdifenc.c.

Macro Definition Documentation

◆ SPDIF_FLAG_BIGENDIAN

#define SPDIF_FLAG_BIGENDIAN   0x01

Definition at line 82 of file spdifenc.c.

◆ MAT_FRAME_SIZE

#define MAT_FRAME_SIZE   61424

Definition at line 393 of file spdifenc.c.

◆ TRUEHD_FRAME_OFFSET

#define TRUEHD_FRAME_OFFSET   2560

Definition at line 394 of file spdifenc.c.

◆ MAT_MIDDLE_CODE_OFFSET

#define MAT_MIDDLE_CODE_OFFSET   -4

Definition at line 395 of file spdifenc.c.

Function Documentation

◆ spdif_header_ac3()

static int spdif_header_ac3 ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 105 of file spdifenc.c.

Referenced by spdif_write_header().

◆ spdif_header_eac3()

static int spdif_header_eac3 ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 115 of file spdifenc.c.

Referenced by spdif_write_header().

◆ spdif_dts4_subtype()

static int spdif_dts4_subtype ( int  period)
static

Definition at line 154 of file spdifenc.c.

Referenced by spdif_header_dts4().

◆ spdif_header_dts4()

static int spdif_header_dts4 ( AVFormatContext s,
AVPacket pkt,
int  core_size,
int  sample_rate,
int  blocks 
)
static

Definition at line 167 of file spdifenc.c.

Referenced by spdif_header_dts().

◆ spdif_header_dts()

static int spdif_header_dts ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 244 of file spdifenc.c.

Referenced by spdif_write_header().

◆ spdif_header_mpeg()

static int spdif_header_mpeg ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 327 of file spdifenc.c.

Referenced by spdif_write_header().

◆ spdif_header_aac()

static int spdif_header_aac ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 350 of file spdifenc.c.

Referenced by spdif_write_header().

◆ spdif_header_truehd()

static int spdif_header_truehd ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 397 of file spdifenc.c.

Referenced by spdif_write_header().

◆ spdif_write_header()

static int spdif_write_header ( AVFormatContext s)
static

Definition at line 448 of file spdifenc.c.

◆ spdif_write_trailer()

static int spdif_write_trailer ( AVFormatContext s)
static

Definition at line 485 of file spdifenc.c.

◆ spdif_put_16()

static av_always_inline void spdif_put_16 ( IEC61937Context ctx,
AVIOContext pb,
unsigned int  val 
)
static

Definition at line 493 of file spdifenc.c.

Referenced by spdif_write_packet().

◆ spdif_write_packet()

static int spdif_write_packet ( struct AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 502 of file spdifenc.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "spdif_flags", "IEC 61937 encapsulation flags", 0x42, AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "spdif_flags" },
{ "be", "output in big-endian format (for use as s16be)", 0, AV_OPT_TYPE_CONST, {.i64 = SPDIF_FLAG_BIGENDIAN}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "spdif_flags" },
{ "dtshd_rate", "mux complete DTS frames in HD mode at the specified IEC958 rate (in Hz, default 0=disabled)", 0x42, AV_OPT_TYPE_INT, {.i64 = 0}, 0, 768000, AV_OPT_FLAG_ENCODING_PARAM },
{ "dtshd_fallback_time", "min secs to strip HD for after an overflow (-1: till the end, default 60)", 0x42, AV_OPT_TYPE_INT, {.i64 = 60}, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
{ NULL },
}

Definition at line 90 of file spdifenc.c.

◆ spdif_class

const AVClass spdif_class
static
Initial value:
= {
.class_name = "spdif",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 98 of file spdifenc.c.

◆ mpeg_data_type

enum IEC61937DataType mpeg_data_type[2][3]
static

◆ ff_spdif_muxer

AVOutputFormat ff_spdif_muxer
Initial value:
= {
.name = "spdif",
.long_name = NULL_IF_CONFIG_SMALL("IEC 61937 (used on S/PDIF - IEC958)"),
.extensions = "spdif",
.priv_data_size = sizeof(IEC61937Context),
.audio_codec = AV_CODEC_ID_AC3,
.video_codec = AV_CODEC_ID_NONE,
.priv_class = &spdif_class,
}

Definition at line 554 of file spdifenc.c.

AV_CODEC_ID_AC3
@ AV_CODEC_ID_AC3
Definition: avcodec.h:567
AVFMT_NOTIMESTAMPS
#define AVFMT_NOTIMESTAMPS
Format does not need / have any timestamps.
Definition: avformat.h:467
spdif_write_packet
static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt)
Definition: spdifenc.c:502
IEC61937_MPEG2_LAYER1_LSF
@ IEC61937_MPEG2_LAYER1_LSF
MPEG-2, layer-1 low sampling frequency.
Definition: spdif.h:38
spdif_class
static const AVClass spdif_class
Definition: spdifenc.c:98
SPDIF_FLAG_BIGENDIAN
#define SPDIF_FLAG_BIGENDIAN
Definition: spdifenc.c:82
AV_OPT_FLAG_ENCODING_PARAM
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
Definition: opt.h:276
IEC61937Context
Definition: spdifenc.c:58
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
write_trailer
static int write_trailer(AVFormatContext *s1)
Definition: v4l2enc.c:94
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
IEC61937_MPEG1_LAYER23
@ IEC61937_MPEG1_LAYER23
MPEG-1 layer 2 or 3 data or MPEG-2 without extension.
Definition: spdif.h:35
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:188
spdif_write_header
static int spdif_write_header(AVFormatContext *s)
Definition: spdifenc.c:448
spdif_write_trailer
static int spdif_write_trailer(AVFormatContext *s)
Definition: spdifenc.c:485
write_packet
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
Definition: ffmpeg.c:690
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: avcodec.h:216
IEC61937_MPEG1_LAYER1
@ IEC61937_MPEG1_LAYER1
MPEG-1 layer 1.
Definition: spdif.h:34
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
IEC61937_MPEG2_LAYER2_LSF
@ IEC61937_MPEG2_LAYER2_LSF
MPEG-2, layer-2 low sampling frequency.
Definition: spdif.h:39
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:222
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:565
options
static const AVOption options[]
Definition: spdifenc.c:90
write_header
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:337
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:232
IEC61937_MPEG2_LAYER3_LSF
@ IEC61937_MPEG2_LAYER3_LSF
MPEG-2, layer-3 low sampling frequency.
Definition: spdif.h:40