49 #define RF64_AUTO (-1)
53 #define PEAK_BUFFER_SIZE 1024
96 len = strlen(tag->
value);
97 len =
FFMIN(len, maxlen);
107 uint64_t time_reference = 0;
110 bwf_write_bext_string(s,
"description", 256);
111 bwf_write_bext_string(s,
"originator", 32);
112 bwf_write_bext_string(s,
"originator_reference", 32);
113 bwf_write_bext_string(s,
"origination_date", 10);
114 bwf_write_bext_string(s,
"origination_time", 8);
117 time_reference = strtoll(tmp_tag->
value,
NULL, 10);
122 unsigned char umidpart_str[17] = {0};
125 size_t len = strlen(tmp_tag->
value+2);
127 for (i = 0; i < len/16; i++) {
128 memcpy(umidpart_str, tmp_tag->
value + 2 + (i*16), 16);
129 umidpart = strtoll(umidpart_str,
NULL, 16);
164 codec ? codec->
name :
"NONE");
172 "Writing 16 bit peak for 8 bit audio does not make sense\n");
188 peak_free_buffers(s);
201 for (c = 0; c < par->
channels; c++) {
261 memset(timestamp, 0,
sizeof(timestamp));
266 now_secs = now0 / 1000000;
267 if (strftime(timestamp,
sizeof(timestamp),
"%Y:%m:%d:%H:%M:%S:",
localtime_r(&now_secs, &tmpbuf))) {
268 av_strlcatf(timestamp,
sizeof(timestamp),
"%03d", (
int)((now0 / 1000) % 1000));
331 desc ? desc->
name :
"unknown");
345 bwf_write_bext_chunk(s);
349 if ((ret = peak_init_writer(s)) < 0)
412 int64_t file_size, data_size;
413 int64_t number_of_samples = 0;
426 ret = peak_write_chunk(s);
432 data_size = file_size - wav->
data;
435 }
else if (file_size - 8 <= UINT32_MAX) {
437 avio_wl32(pb, (uint32_t)(file_size - 8));
443 "Filesize %"PRId64
" invalid for wav, output file will be broken\n",
454 if (rf64 || (wav->
rf64 ==
RF64_AUTO && number_of_samples > UINT32_MAX)) {
489 peak_free_buffers(s);
494 #define OFFSET(x) offsetof(WAVMuxContext, x)
495 #define ENC AV_OPT_FLAG_ENCODING_PARAM
498 {
"write_peak",
"Write Peak Envelope chunk.",
OFFSET(write_peak),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2,
ENC,
"peak" },
501 {
"only",
"Write only peak chunk, omit wav data.", 0,
AV_OPT_TYPE_CONST, { .i64 =
PEAK_ONLY }, 0, 0,
ENC,
"peak" },
506 {
"peak_block_size",
"Number of audio samples used to generate each peak frame.",
OFFSET(peak_block_size),
AV_OPT_TYPE_INT, { .i64 = 256 }, 0, 65536,
ENC },
508 {
"peak_ppv",
"Number of peak points per peak value (1 or 2).",
OFFSET(peak_ppv),
AV_OPT_TYPE_INT, { .i64 = 2 }, 1, 2,
ENC },
512 static const AVClass wav_muxer_class = {
522 .mime_type =
"audio/x-wav",
532 .priv_class = &wav_muxer_class,
572 codec ? codec->
name :
"NONE");
596 end_guid(pb, wav->
data);
603 int64_t number_of_samples;
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
void avio_wb64(AVIOContext *s, uint64_t val)
void avio_wl16(AVIOContext *s, unsigned int val)
const uint8_t ff_w64_guid_wave[16]
void ff_end_tag(AVIOContext *pb, int64_t start)
int64_t ff_start_tag(AVIOContext *pb, const char *tag)
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int flags)
Write WAVEFORMAT header structure.
const uint8_t ff_w64_guid_fact[16]
#define LIBAVUTIL_VERSION_INT
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * av_default_item_name(void *ptr)
Return the context name.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
This struct describes the properties of an encoded stream.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
void avio_wl32(AVIOContext *s, unsigned int val)
static av_cold int end(AVCodecContext *avctx)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
AVStream ** streams
A list of all streams in the file.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int flags
Flags modifying the (de)muxer behaviour.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s)
void avio_wl64(AVIOContext *s, uint64_t val)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
AVDictionary * metadata
Metadata that applies to the whole file.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const char * name
Name of the codec implementation.
const AVCodecTag ff_codec_wav_tags[]
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int void avio_flush(AVIOContext *s)
Force flushing of buffered data.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
void ffio_fill(AVIOContext *s, int b, int count)
static struct tm * localtime_r(const time_t *clock, struct tm *result)
static int write_trailer(AVFormatContext *s1)
const uint8_t ff_w64_guid_data[16]
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
const uint8_t ff_w64_guid_riff[16]
int avio_put_str(AVIOContext *s, const char *str)
Write a NULL-terminated string.
int64_t av_gettime(void)
Get the current time in microseconds.
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
#define AV_LOG_INFO
Standard information.
AVIOContext * pb
I/O context.
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
void ff_riff_write_info(AVFormatContext *s)
Write all recognized RIFF tags from s->metadata.
Describe the class of an AVClass context structure.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
const char * name
Name of the codec described by this descriptor.
This struct describes the properties of a single codec described by an AVCodecID. ...
#define flags(name, subs,...)
const uint8_t ff_w64_guid_fmt[16]
int sample_rate
Audio only.
const OptionDef options[]
common internal and external API header
uint32_t peak_outbuf_size
uint32_t peak_outbuf_bytes
void * priv_data
Format private data.
static void write_header(FFV1Context *f)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.
void * av_mallocz_array(size_t nmemb, size_t size)