FFmpeg
Loading...
Searching...
No Matches
sacddec.c File Reference

Super Audio CD (SACD) demuxer. More...

#include "config.h"
#include <inttypes.h>
#include <string.h>
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/dict.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
#include "avformat.h"
#include "avio_internal.h"
#include "demux.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  SACDArea
 
struct  SACDContext
 

Macros

#define SECTOR_SIZE   2048
 
#define RAW_SECTOR_SIZE   2064
 
#define RAW_SECTOR_HEADER   12
 
#define MASTER_TOC_LSN   510
 
#define FRAMES_PER_SECOND   75
 
#define BITS_PER_SAMPLE   8
 
#define SAMPLE_RATE   (64 * 44100 / BITS_PER_SAMPLE)
 
#define FRAME_SAMPLES   (SAMPLE_RATE / FRAMES_PER_SECOND)
 
#define MAX_FRAME_SECTORS   16
 
#define MAX_PACKET_SIZE   (SECTOR_SIZE - 3)
 
#define MAX_FRAME_SIZE   (MAX_FRAME_SECTORS * MAX_PACKET_SIZE)
 
#define MAX_TRACKS   255
 
#define MAX_TRACK_TEXT_SECTORS   32
 
#define DATA_TYPE_AUDIO   2
 

Enumerations

enum  { FRAME_FORMAT_DST = 0 , FRAME_FORMAT_DSD_3_IN_14 = 2 , FRAME_FORMAT_DSD_3_IN_16 = 3 }
 

Functions

static int sacd_probe (const AVProbeData *p)
 
static int read_sectors (AVFormatContext *s, int64_t lsn, uint8_t *buf, int nb)
 
static int time_code (const uint8_t *tc)
 
static int put_iso8859 (AVBPrint *bp, int part, const uint8_t *str, int len)
 
static void set_string (AVFormatContext *s, AVDictionary **m, const char *key, const uint8_t *str, int max_len, int flags)
 
static void set_text (AVFormatContext *s, AVDictionary **m, const char *key, const uint8_t *buf, int size, int offset, int flags)
 
static void set_genre (AVDictionary **m, const uint8_t *genre)
 
static int text_supported (AVFormatContext *s, const uint8_t *text_channels)
 
static int read_master_toc (AVFormatContext *s, uint32_t *toc_lsn)
 
static void read_track_text (AVFormatContext *s, AVDictionary **m, const uint8_t *buf, int size, int track)
 
static int read_access_list (AVFormatContext *s, SACDArea *a, int64_t lsn)
 
static void seek_frame (AVFormatContext *s, AVStream *st, int64_t pos)
 
static int read_area_toc (AVFormatContext *s, int area, int64_t toc_lsn, int64_t other_toc_lsn)
 
static int sacd_read_header (AVFormatContext *s)
 
static int read_audio_header (SACDArea *a)
 
static int read_frame (AVFormatContext *s, AVStream *st, AVPacket *pkt)
 
static int sacd_read_packet (AVFormatContext *s, AVPacket *pkt)
 
static int sacd_read_seek (AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
 
static int sacd_read_close (AVFormatContext *s)
 

Variables

struct { 
 
   int   toc_address 
 
   const char *   signature 
 
   const char *   name 
 
} areas [] 
 
static const uint8_t iso8859_parts []
 
static const char *const genres []
 
const FFInputFormat ff_sacd_demuxer
 

Detailed Description

Super Audio CD (SACD) demuxer.

A disc holds a Master TOC and up to two Audio Areas, a multi channel one and a 2-channel stereo one, as a rule two mixes of the same tracks. Each area has an Area TOC in front of and behind its Track Area. The Track Area is a run of Audio Sectors, whose headers cut it into the packets of Multiplexed Frames of 1/75 s, which carry either plain DSD or one DST frame.

Each area is a program with one stream here. A file has one list of chapters, which are the tracks of the first area.

The structure and field names are the ones of the Super Audio CD System Description, as far as they are public.

Master TOC EP 0956557 B1 Audio Area, Audio Sector, Time Code US 6522695 B1 Audio_Header, Packet_Info US 6661762 B1 Frame_Info US 7028152 B2 frame formats with 14 and 16 sectors US 6275457 B1 Track_List_2 EP 0987709 A2 Access_List US 6643228 B1 channel order, pauses Philips, DSDIFF 1.5 character sets, text items Sonic Studio, SACD Text Overview

Definition in file sacddec.c.

Macro Definition Documentation

◆ SECTOR_SIZE

#define SECTOR_SIZE   2048

◆ RAW_SECTOR_SIZE

#define RAW_SECTOR_SIZE   2064

Definition at line 74 of file sacddec.c.

Referenced by read_master_toc(), and sacd_probe().

◆ RAW_SECTOR_HEADER

#define RAW_SECTOR_HEADER   12

Definition at line 75 of file sacddec.c.

Referenced by read_master_toc(), and sacd_probe().

◆ MASTER_TOC_LSN

#define MASTER_TOC_LSN   510

Definition at line 77 of file sacddec.c.

Referenced by read_master_toc(), and sacd_probe().

◆ FRAMES_PER_SECOND

#define FRAMES_PER_SECOND   75

Definition at line 79 of file sacddec.c.

Referenced by read_area_toc(), and time_code().

◆ BITS_PER_SAMPLE

#define BITS_PER_SAMPLE   8

Definition at line 80 of file sacddec.c.

Referenced by read_area_toc().

◆ SAMPLE_RATE

#define SAMPLE_RATE   (64 * 44100 / BITS_PER_SAMPLE)

Definition at line 82 of file sacddec.c.

Referenced by config_input(), and read_area_toc().

◆ FRAME_SAMPLES

#define FRAME_SAMPLES   (SAMPLE_RATE / FRAMES_PER_SECOND)

Definition at line 83 of file sacddec.c.

◆ MAX_FRAME_SECTORS

#define MAX_FRAME_SECTORS   16

Definition at line 85 of file sacddec.c.

◆ MAX_PACKET_SIZE

#define MAX_PACKET_SIZE   (SECTOR_SIZE - 3)

Definition at line 86 of file sacddec.c.

◆ MAX_FRAME_SIZE

#define MAX_FRAME_SIZE   (MAX_FRAME_SECTORS * MAX_PACKET_SIZE)

Definition at line 87 of file sacddec.c.

◆ MAX_TRACKS

#define MAX_TRACKS   255

Definition at line 89 of file sacddec.c.

Referenced by read_area_toc().

◆ MAX_TRACK_TEXT_SECTORS

#define MAX_TRACK_TEXT_SECTORS   32

Definition at line 90 of file sacddec.c.

Referenced by read_area_toc().

◆ DATA_TYPE_AUDIO

#define DATA_TYPE_AUDIO   2

Definition at line 107 of file sacddec.c.

Referenced by read_frame().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
FRAME_FORMAT_DST 
FRAME_FORMAT_DSD_3_IN_14 
FRAME_FORMAT_DSD_3_IN_16 

Definition at line 101 of file sacddec.c.

Function Documentation

◆ sacd_probe()

static int sacd_probe ( const AVProbeData * p)
static

Definition at line 137 of file sacddec.c.

◆ read_sectors()

static int read_sectors ( AVFormatContext * s,
int64_t lsn,
uint8_t * buf,
int nb )
static

Definition at line 151 of file sacddec.c.

Referenced by read_access_list(), read_area_toc(), read_frame(), and read_master_toc().

◆ time_code()

static int time_code ( const uint8_t * tc)
static

◆ put_iso8859()

static int put_iso8859 ( AVBPrint * bp,
int part,
const uint8_t * str,
int len )
static

Definition at line 182 of file sacddec.c.

Referenced by set_string().

◆ set_string()

static void set_string ( AVFormatContext * s,
AVDictionary ** m,
const char * key,
const uint8_t * str,
int max_len,
int flags )
static

Definition at line 220 of file sacddec.c.

Referenced by read_area_toc(), read_master_toc(), read_track_text(), and set_text().

◆ set_text()

static void set_text ( AVFormatContext * s,
AVDictionary ** m,
const char * key,
const uint8_t * buf,
int size,
int offset,
int flags )
static

Definition at line 264 of file sacddec.c.

Referenced by read_area_toc(), and read_master_toc().

◆ set_genre()

static void set_genre ( AVDictionary ** m,
const uint8_t * genre )
static

Definition at line 303 of file sacddec.c.

Referenced by read_area_toc(), and read_master_toc().

◆ text_supported()

static int text_supported ( AVFormatContext * s,
const uint8_t * text_channels )
static

Definition at line 313 of file sacddec.c.

Referenced by read_area_toc(), and read_master_toc().

◆ read_master_toc()

static int read_master_toc ( AVFormatContext * s,
uint32_t * toc_lsn )
static

Definition at line 331 of file sacddec.c.

Referenced by sacd_read_header().

◆ read_track_text()

static void read_track_text ( AVFormatContext * s,
AVDictionary ** m,
const uint8_t * buf,
int size,
int track )
static

Definition at line 397 of file sacddec.c.

Referenced by read_area_toc().

◆ read_access_list()

static int read_access_list ( AVFormatContext * s,
SACDArea * a,
int64_t lsn )
static

Definition at line 426 of file sacddec.c.

Referenced by read_area_toc().

◆ seek_frame()

static void seek_frame ( AVFormatContext * s,
AVStream * st,
int64_t pos )
static

Definition at line 460 of file sacddec.c.

Referenced by read_area_toc(), sacd_read_packet(), and sacd_read_seek().

◆ read_area_toc()

static int read_area_toc ( AVFormatContext * s,
int area,
int64_t toc_lsn,
int64_t other_toc_lsn )
static

Definition at line 506 of file sacddec.c.

Referenced by sacd_read_header().

◆ sacd_read_header()

static int sacd_read_header ( AVFormatContext * s)
static

Definition at line 675 of file sacddec.c.

◆ read_audio_header()

static int read_audio_header ( SACDArea * a)
static

Definition at line 698 of file sacddec.c.

Referenced by read_frame().

◆ read_frame()

static int read_frame ( AVFormatContext * s,
AVStream * st,
AVPacket * pkt )
static

Definition at line 726 of file sacddec.c.

Referenced by sacd_read_packet().

◆ sacd_read_packet()

static int sacd_read_packet ( AVFormatContext * s,
AVPacket * pkt )
static

Definition at line 807 of file sacddec.c.

◆ sacd_read_seek()

static int sacd_read_seek ( AVFormatContext * s,
int stream_index,
int64_t timestamp,
int flags )
static

Definition at line 847 of file sacddec.c.

◆ sacd_read_close()

static int sacd_read_close ( AVFormatContext * s)
static

Definition at line 871 of file sacddec.c.

Variable Documentation

◆ toc_address

int toc_address

Definition at line 93 of file sacddec.c.

Referenced by read_master_toc().

◆ signature

const char* signature

Definition at line 94 of file sacddec.c.

◆ name

const char* name

Definition at line 95 of file sacddec.c.

◆ [struct]

const struct { ... } areas[]
Initial value:
= {
{ 0x48, "MULCHTOC", "Multi Channel" },
{ 0x40, "TWOCHTOC", "2-Channel Stereo" },
}

Referenced by read_area_toc(), read_master_toc(), and sacd_read_header().

◆ iso8859_parts

const uint8_t iso8859_parts[]
static
Initial value:
= {
['A'] = 1, ['B'] = 2, ['C'] = 3, ['D'] = 4, ['L'] = 5, ['G'] = 6,
['F'] = 7, ['H'] = 8, ['M'] = 9, ['V'] = 10, ['T'] = 11, ['Y'] = 13,
['_'] = 14, ['b'] = 15, ['f'] = 16,
}

Definition at line 176 of file sacddec.c.

Referenced by set_string().

◆ genres

const char* const genres[]
static
Initial value:
= {
[ 2] = "Adult Contemporary",
[ 3] = "Alternative Rock",
[ 4] = "Children's Music",
[ 5] = "Classical",
[ 6] = "Contemporary Christian",
[ 7] = "Country",
[ 8] = "Dance",
[ 9] = "Easy Listening",
[10] = "Erotic",
[11] = "Folk",
[12] = "Gospel",
[13] = "Hip Hop",
[14] = "Jazz",
[15] = "Latin",
[16] = "Musical",
[17] = "New Age",
[18] = "Opera",
[19] = "Operetta",
[20] = "Pop Music",
[21] = "Rap",
[22] = "Reggae",
[23] = "Rock Music",
[24] = "Rhythm & Blues",
[25] = "Sound Effects",
[26] = "Sound Track",
[27] = "Spoken Word",
[28] = "World Music",
[29] = "Blues",
}

Definition at line 272 of file sacddec.c.

Referenced by set_genre().

◆ ff_sacd_demuxer

const FFInputFormat ff_sacd_demuxer
Initial value:
= {
.p.name = "sacd",
.p.long_name = NULL_IF_CONFIG_SMALL("Super Audio CD (SACD)"),
.priv_data_size = sizeof(SACDContext),
.flags_internal = FF_INFMT_FLAG_INIT_CLEANUP,
}
#define AVFMT_NO_BYTE_SEEK
Format does not allow seeking by bytes.
Definition avformat.h:508
#define AVFMT_NOGENSEARCH
Format does not allow to fall back on generic search.
Definition avformat.h:507
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static int read_probe(const AVProbeData *p)
Definition cdg.c:30
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
Definition demux.h:35
static int read_header(FFV1Context *f, RangeCoder *c)
Definition ffv1dec.c:580
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:97
static av_cold int read_close(AVFormatContext *ctx)
Definition libcdio.c:143
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition libcdio.c:151
static int sacd_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition sacddec.c:807
static int sacd_read_header(AVFormatContext *s)
Definition sacddec.c:675
static int sacd_probe(const AVProbeData *p)
Definition sacddec.c:137
static int sacd_read_close(AVFormatContext *s)
Definition sacddec.c:871
static int sacd_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition sacddec.c:847

Definition at line 880 of file sacddec.c.