Go to the documentation of this file.
49 #define RF64_AUTO (-1)
106 uint64_t time_reference = 0;
109 bwf_write_bext_string(
s,
"description", 256);
110 bwf_write_bext_string(
s,
"originator", 32);
111 bwf_write_bext_string(
s,
"originator_reference", 32);
112 bwf_write_bext_string(
s,
"origination_date", 10);
113 bwf_write_bext_string(
s,
"origination_time", 8);
116 time_reference = strtoll(tmp_tag->
value,
NULL, 10);
121 unsigned char umidpart_str[17] = {0};
124 size_t len = strlen(tmp_tag->
value+2);
126 for (
i = 0;
i <
len/16;
i++) {
127 memcpy(umidpart_str, tmp_tag->
value + 2 + (
i*16), 16);
128 umidpart = strtoll(umidpart_str,
NULL, 16);
170 "Writing 16 bit peak for 8 bit audio does not make sense\n");
197 if (new_size > INT_MAX) {
257 int ret = peak_write_frame(
s);
262 memset(timestamp, 0,
sizeof(timestamp));
267 now_secs = now0 / 1000000;
268 if (strftime(timestamp,
sizeof(timestamp),
"%Y:%m:%d:%H:%M:%S:",
localtime_r(&now_secs, &tmpbuf))) {
269 av_strlcatf(timestamp,
sizeof(timestamp),
"%03d", (
int)((now0 / 1000) % 1000));
303 if (
s->nb_streams != 1) {
337 if (
s->streams[0]->codecpar->codec_tag != 0x01
345 bwf_write_bext_chunk(
s);
349 if ((
ret = peak_init_writer(
s)) < 0)
387 if (++
c ==
s->streams[0]->codecpar->channels) {
390 int ret = peak_write_frame(
s);
412 int64_t file_size, data_size;
413 int64_t number_of_samples = 0;
423 ret = peak_write_chunk(
s);
428 data_size = file_size - wav->
data;
431 }
else if (file_size - 8 <= UINT32_MAX) {
433 avio_wl32(pb, (uint32_t)(file_size - 8));
437 "Filesize %"PRId64
" invalid for wav, output file will be broken\n",
441 s->streams[0]->time_base,
442 av_make_q(1,
s->streams[0]->codecpar->sample_rate));
444 if(
s->streams[0]->codecpar->codec_tag != 0x01) {
447 if (rf64 || (wav->
rf64 ==
RF64_AUTO && number_of_samples > UINT32_MAX)) {
482 #define OFFSET(x) offsetof(WAVMuxContext, x)
483 #define ENC AV_OPT_FLAG_ENCODING_PARAM
486 {
"write_peak",
"Write Peak Envelope chunk.",
OFFSET(write_peak),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2,
ENC,
"peak" },
489 {
"only",
"Write only peak chunk, omit wav data.", 0,
AV_OPT_TYPE_CONST, { .i64 =
PEAK_ONLY }, 0, 0,
ENC,
"peak" },
494 {
"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 },
496 {
"peak_ppv",
"Number of peak points per peak value (1 or 2).",
OFFSET(peak_ppv),
AV_OPT_TYPE_INT, { .i64 = 2 }, 1, 2,
ENC },
500 static const AVClass wav_muxer_class = {
510 .mime_type =
"audio/x-wav",
521 .priv_class = &wav_muxer_class,
528 static void start_guid(
AVIOContext *pb,
const uint8_t *guid, int64_t *
pos)
536 static void end_guid(
AVIOContext *pb, int64_t start)
565 if (
s->streams[0]->codecpar->codec_tag != 0x01
584 end_guid(pb, wav->
data);
590 if (
s->streams[0]->codecpar->codec_tag != 0x01) {
591 int64_t number_of_samples;
594 s->streams[0]->codecpar->sample_rate * (int64_t)
s->streams[0]->time_base.num,
595 s->streams[0]->time_base.den);
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
static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s)
This struct describes the properties of an encoded stream.
static void deinit(AVFormatContext *s)
void avio_wl64(AVIOContext *s, uint64_t val)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
uint32_t peak_outbuf_bytes
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
void avio_wl16(AVIOContext *s, unsigned int val)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int64_t ff_start_tag(AVIOContext *pb, const char *tag)
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int flags)
Write WAVEFORMAT header structure.
static int write_trailer(AVFormatContext *s1)
const char * av_default_item_name(void *ptr)
Return the context name.
void ffio_fill(AVIOContext *s, int b, int64_t count)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
const uint8_t ff_w64_guid_fmt[16]
const OptionDef options[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
static AVRational av_make_q(int num, int den)
Create an AVRational.
#define AV_NOPTS_VALUE
Undefined timestamp value.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
void avio_wl32(AVIOContext *s, unsigned int val)
void ff_end_tag(AVIOContext *pb, int64_t start)
#define AV_LOG_INFO
Standard information.
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
const uint8_t ff_w64_guid_wave[16]
const uint8_t ff_w64_guid_fact[16]
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
void * av_calloc(size_t nmemb, size_t size)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
unsigned peak_outbuf_size
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 keep it simple and lowercase description are in without and describe what they for example set the foo of the bar offset is the offset of the field in your see the OFFSET() macro
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
void ff_riff_write_info(AVFormatContext *s)
Write all recognized RIFF tags from s->metadata.
void avio_wb64(AVIOContext *s, uint64_t val)
int64_t av_gettime(void)
Get the current time in microseconds.
const uint8_t ff_w64_guid_data[16]
const uint8_t ff_w64_guid_riff[16]
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
#define flags(name, subs,...)
static void write_header(FFV1Context *f)
int avio_put_str(AVIOContext *s, const char *str)
Write a NULL-terminated string.
const AVCodecTag *const ff_wav_codec_tags_list[]