23#include "config_components.h"
40#define ARGO_CVG_HEADER_SIZE 12
41#define ARGO_CVG_BLOCK_ALIGN 0x10
42#define ARGO_CVG_NB_BLOCKS 32
43#define ARGO_CVG_SAMPLES_PER_BLOCK 28
67#if CONFIG_ARGO_CVG_DEMUXER
70#define OVERRIDE_FILES(FILE) \
71 FILE(CRYS, 23592, 0, 1, 2495499, 88200) \
72 FILE(REDCRY88, 38280, 0, 1, 4134848, 88200) \
73 FILE(DANLOOP1, 54744, 1, 0, 5684641, 37800) \
74 FILE(PICKUP88, 12904, 0, 1, 1348091, 48000) \
75 FILE(SELECT1, 5080, 0, 1, 549987, 44100) \
77#define MAX_FILENAME_SIZE(NAME, SIZE, LOOP, REVERB, CHECKSUM, SAMPLE_RATE) \
78 MAX_SIZE_BEFORE_ ## NAME, \
79 MAX_SIZE_UNTIL_ ## NAME ## _MINUS1 = FFMAX(sizeof(#NAME ".CVG"), MAX_SIZE_BEFORE_ ## NAME) - 1,
81 OVERRIDE_FILES(MAX_FILENAME_SIZE)
82 MAX_OVERRIDE_FILENAME_SIZE
85typedef struct ArgoCVGOverride {
86 const char name[MAX_OVERRIDE_FILENAME_SIZE];
92#define FILE(NAME, SIZE, LOOP, REVERB, CHECKSUM, SAMPLE_RATE) \
93 { #NAME ".CVG", { SIZE, LOOP, REVERB }, CHECKSUM, SAMPLE_RATE },
94static const ArgoCVGOverride overrides[] = {
172 if (
ctx->header.size < 8)
175 if ((ret = argo_cvg_read_checksum(
s->pb, &
ctx->header, &
ctx->checksum)) < 0)
193 const ArgoCVGOverride *ovr = overrides +
i;
194 if (ovr->header.size !=
ctx->header.size ||
195 ovr->header.loop !=
ctx->header.loop ||
196 ovr->header.reverb !=
ctx->header.reverb ||
197 ovr->checksum !=
ctx->checksum ||
230 if (
ctx->blocks_read >=
ctx->num_blocks)
242 pkt->stream_index = 0;
258 if (
pts != 0 || stream_index != 0)
264 ctx->blocks_read = 0;
269 .p.name =
"argo_cvg",
279#if CONFIG_ARGO_CVG_MUXER
314 ctx->checksum = !!
ctx->loop + !!
ctx->reverb;
331 if (
ctx->size > UINT32_MAX)
334 for (
int i = 0;
i <
pkt->size;
i++)
345 ctx->checksum += (
ctx->size & 255)
346 + ((
ctx->size>> 8) & 255)
347 + ((
ctx->size>>16) & 255)
355 if ((ret =
avio_seek(
s->pb, 0, SEEK_SET)) < 0)
362static const AVOption argo_cvg_options[] = {
364 .name =
"skip_rate_check",
365 .help =
"skip sample rate check",
368 .default_val = {.i64 = 0},
375 .help =
"set loop flag",
378 .default_val = {.i64 = 0},
385 .help =
"set reverb flag",
388 .default_val = {.i64 = 1},
396static const AVClass argo_cvg_muxer_class = {
397 .class_name =
"argo_cvg_muxer",
399 .option = argo_cvg_options,
404 .p.name =
"argo_cvg",
406 .p.extensions =
"cvg",
410 .p.priv_class = &argo_cvg_muxer_class,
413 .init = argo_cvg_write_init,
414 .write_header = argo_cvg_write_header,
415 .write_packet = argo_cvg_write_packet,
416 .write_trailer = argo_cvg_write_trailer,
static AVFormatContext * ctx
#define ARGO_CVG_BLOCK_ALIGN
#define ARGO_CVG_NB_BLOCKS
#define ARGO_CVG_SAMPLES_PER_BLOCK
#define ARGO_CVG_HEADER_SIZE
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
void avio_wl32(AVIOContext *s, unsigned int val)
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
Public libavutil channel layout APIs header.
static int read_header(FFV1Context *f, RangeCoder *c)
#define AV_OPT_FLAG_ENCODING_PARAM
A generic parameter which can be set by the user for muxing or encoding.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
int av_match_ext(const char *filename, const char *extensions)
Return a positive value if the given filename has one of the given extensions, 0 otherwise.
#define AV_CHANNEL_LAYOUT_MONO
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set() that converts the value to a string and stores it.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
const char * av_basename(const char *path)
Thread safe basename.
#define LIBAVUTIL_VERSION_INT
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
#define FF_OFMT_FLAG_MAX_ONE_OF_EACH
If this flag is set, it indicates that for each codec type whose corresponding default codec (i....
#define FF_OFMT_FLAG_ONLY_DEFAULT_CODECS
If this flag is set, then the only permitted audio/video/subtitle codec ids are AVOutputFormat....
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
static const uint8_t header[24]
#define FF_ARRAY_ELEMS(a)
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
This struct describes the properties of an encoded stream.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
AVChannelLayout ch_layout
The channel layout and number of channels.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
enum AVMediaType codec_type
General type of the encoded data.
int block_align
The number of bytes per coded audio frame, required by some formats.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
This structure stores compressed data.
This structure contains the data a format has to probe a file.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int64_t nb_frames
number of frames in this stream if known or 0
int64_t duration
Decoding: duration of the stream, in stream time base.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.