49 #define RF64_AUTO (-1)
53 #define PEAK_BUFFER_SIZE 1024
92 static inline void bwf_write_bext_string(
AVFormatContext *
s,
const char *key,
int maxlen)
98 len = strlen(tag->
value);
99 len =
FFMIN(len, maxlen);
109 uint64_t time_reference = 0;
112 bwf_write_bext_string(s,
"description", 256);
113 bwf_write_bext_string(s,
"originator", 32);
114 bwf_write_bext_string(s,
"originator_reference", 32);
115 bwf_write_bext_string(s,
"origination_date", 10);
116 bwf_write_bext_string(s,
"origination_time", 8);
119 time_reference = strtoll(tmp_tag->
value,
NULL, 10);
124 unsigned char umidpart_str[17] = {0};
129 for (i = 0; i < len/16; i++) {
130 memcpy(umidpart_str, tmp_tag->
value + 2 + (i*16), 16);
131 umidpart = strtoll(umidpart_str,
NULL, 16);
173 "Writing 16 bit peak for 8 bit audio does not make sense\n");
189 peak_free_buffers(s);
203 for (c = 0; c < enc->
channels; c++) {
269 memset(timestamp, 0,
sizeof(timestamp));
274 now_secs = now0 / 1000000;
275 if (strftime(timestamp,
sizeof(timestamp),
"%Y:%m:%d:%H:%M:%S:",
localtime_r(&now_secs, &tmpbuf))) {
276 av_strlcatf(timestamp,
sizeof(timestamp),
"%03d", (
int)((now0 / 1000) % 1000));
339 desc ? desc->
name :
"unknown");
353 bwf_write_bext_chunk(s);
357 if ((ret = peak_init_writer(s)) < 0)
420 int64_t file_size, data_size;
421 int64_t number_of_samples = 0;
434 ret = peak_write_chunk(s);
440 data_size = file_size - wav->
data;
445 avio_wl32(pb, (uint32_t)(file_size - 8));
458 if (rf64 || (wav->
rf64 ==
RF64_AUTO && number_of_samples > UINT32_MAX)) {
493 peak_free_buffers(s);
498 #define OFFSET(x) offsetof(WAVMuxContext, x)
499 #define ENC AV_OPT_FLAG_ENCODING_PARAM
502 {
"write_peak",
"Write Peak Envelope chunk.",
OFFSET(write_peak),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2,
ENC,
"peak" },
505 {
"only",
"Write only peak chunk, omit wav data.", 0,
AV_OPT_TYPE_CONST, { .i64 =
PEAK_ONLY }, 0, 0,
ENC,
"peak" },
510 {
"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 },
512 {
"peak_ppv",
"Number of peak points per peak value (1 or 2).",
OFFSET(peak_ppv),
AV_OPT_TYPE_INT, { .i64 = 2 }, 1, 2,
ENC },
516 static const AVClass wav_muxer_class = {
526 .mime_type =
"audio/x-wav",
536 .priv_class = &wav_muxer_class,
599 end_guid(pb, wav->
data);
606 int64_t number_of_samples;