31#include "config_components.h"
111 uint64_t time_reference = 0;
114 bwf_write_bext_string(
s,
"description", 256);
115 bwf_write_bext_string(
s,
"originator", 32);
116 bwf_write_bext_string(
s,
"originator_reference", 32);
117 bwf_write_bext_string(
s,
"origination_date", 10);
118 bwf_write_bext_string(
s,
"origination_time", 8);
121 time_reference = strtoll(tmp_tag->
value,
NULL, 10);
126 unsigned char umidpart_str[17] = {0};
129 size_t len = strlen(tmp_tag->
value+2);
131 for (
i = 0;
i <
len/16;
i++) {
132 memcpy(umidpart_str, tmp_tag->
value + 2 + (
i*16), 16);
133 umidpart = strtoull(umidpart_str,
NULL, 16);
175 "Writing 16 bit peak for 8 bit audio does not make sense\n");
202 if (new_size > INT_MAX) {
262 int ret = peak_write_frame(
s);
267 memset(timestamp, 0,
sizeof(timestamp));
272 now_secs = now0 / 1000000;
273 if (strftime(timestamp,
sizeof(timestamp),
"%Y:%m:%d:%H:%M:%S:",
localtime_r(&now_secs, &tmpbuf))) {
274 av_strlcatf(timestamp,
sizeof(timestamp),
"%03d", (
int)((now0 / 1000) % 1000));
351 if (
s->streams[0]->codecpar->codec_tag != 0x01
359 bwf_write_bext_chunk(
s);
363 if ((ret = peak_init_writer(
s)) < 0)
401 if (++
c ==
s->streams[0]->codecpar->ch_layout.nb_channels) {
404 int ret = peak_write_frame(
s);
439 ret = peak_write_chunk(
s);
446 }
else if (file_size - 8 <= UINT32_MAX) {
448 avio_wl32(pb, (uint32_t)(file_size - 8));
452 "Filesize %"PRId64
" invalid for wav, output file will be broken\n",
456 s->streams[0]->time_base,
457 av_make_q(1,
s->streams[0]->codecpar->sample_rate));
459 if(
s->streams[0]->codecpar->codec_tag != 0x01) {
462 if (rf64 || (wav->
rf64 ==
RF64_AUTO && number_of_samples > UINT32_MAX)) {
502#define OFFSET(x) offsetof(WAVMuxContext, x)
503#define ENC AV_OPT_FLAG_ENCODING_PARAM
506 {
"write_peak",
"Write Peak Envelope chunk.",
OFFSET(write_peak),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2,
ENC, .unit =
"peak" },
509 {
"only",
"Write only peak chunk, omit wav data.", 0,
AV_OPT_TYPE_CONST, { .i64 =
PEAK_ONLY }, 0, 0,
ENC, .unit =
"peak" },
514 {
"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 },
516 {
"peak_ppv",
"Number of peak points per peak value (1 or 2).",
OFFSET(peak_ppv),
AV_OPT_TYPE_INT, { .i64 = 2 }, 1, 2,
ENC },
520static const AVClass wav_muxer_class = {
521 .class_name =
"WAV muxer",
530 .p.mime_type =
"audio/x-wav",
531 .p.extensions =
"wav",
536 .write_header = wav_write_header,
537 .write_packet = wav_write_packet,
538 .write_trailer = wav_write_trailer,
539 .deinit = wav_deinit,
542 .p.priv_class = &wav_muxer_class,
587 if (
s->streams[0]->codecpar->codec_tag != 0x01
606 end_guid(pb, wav->
data);
612 if (
s->streams[0]->codecpar->codec_tag != 0x01) {
616 s->streams[0]->codecpar->sample_rate * (
int64_t)
s->streams[0]->time_base.num,
617 s->streams[0]->time_base.den);
631 .p.extensions =
"w64",
636 .write_header = w64_write_header,
637 .write_packet = wav_write_packet,
638 .write_trailer = w64_write_trailer,
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_wl64(AVIOContext *s, uint64_t val)
void avio_wl32(AVIOContext *s, unsigned int val)
void avio_wl16(AVIOContext *s, unsigned int val)
int avio_put_str(AVIOContext *s, const char *str)
Write a NULL-terminated string.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
void avio_wb64(AVIOContext *s, uint64_t val)
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 ffio_fill(AVIOContext *s, int b, int64_t count)
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
#define i(width, name, range_min, range_max)
common internal and external API header
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
static AVRational av_make_q(int num, int den)
Create an AVRational.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
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.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define LIBAVUTIL_VERSION_INT
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
#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....
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
internal header for RIFF based (de)muxers do NOT include this in end user applications
void ff_end_tag(AVIOContext *pb, int64_t start)
void ff_riff_write_info(AVFormatContext *s)
Write all recognized RIFF tags from s->metadata.
int64_t ff_start_tag(AVIOContext *pb, const char *tag)
int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int flags)
Write WAVEFORMAT header structure.
const AVCodecTag *const ff_wav_codec_tags_list[]
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.
AVChannelLayout ch_layout
The channel layout and number of channels.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
This structure stores compressed data.
uint32_t peak_outbuf_bytes
unsigned peak_outbuf_size
int64_t av_gettime(void)
Get the current time in microseconds.
const uint8_t ff_w64_guid_wave[16]
const uint8_t ff_w64_guid_riff[16]
const uint8_t ff_w64_guid_data[16]
const uint8_t ff_w64_guid_fact[16]
const uint8_t ff_w64_guid_fmt[16]