48 #define RF64_AUTO (-1)
52 #define PEAK_BUFFER_SIZE 1024
91 static inline void bwf_write_bext_string(
AVFormatContext *
s,
const char *key,
int maxlen)
97 len = strlen(tag->
value);
98 len =
FFMIN(len, maxlen);
108 uint64_t time_reference = 0;
111 bwf_write_bext_string(s,
"description", 256);
112 bwf_write_bext_string(s,
"originator", 32);
113 bwf_write_bext_string(s,
"originator_reference", 32);
114 bwf_write_bext_string(s,
"origination_date", 10);
115 bwf_write_bext_string(s,
"origination_time", 8);
118 time_reference = strtoll(tmp_tag->
value, NULL, 10);
123 unsigned char umidpart_str[17] = {0};
128 for (i = 0; i < len/16; i++) {
129 memcpy(umidpart_str, tmp_tag->
value + 2 + (i*16), 16);
130 umidpart = strtoll(umidpart_str, NULL, 16);
172 "Writing 16 bit peak for 8 bit audio does not make sense\n");
188 peak_free_buffers(s);
202 for (c = 0; c < enc->
channels; c++) {
268 memset(timestamp, 0,
sizeof(timestamp));
272 now_secs = now0 / 1000000;
273 strftime(timestamp,
sizeof(timestamp),
"%Y:%m:%d:%H:%M:%S:", localtime(&now_secs));
274 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;
431 data_size = file_size - wav->
data;
436 avio_wl32(pb, (uint32_t)(file_size - 8));
449 if (rf64 || (wav->
rf64 ==
RF64_AUTO && number_of_samples > UINT32_MAX)) {
484 peak_free_buffers(s);
489 #define OFFSET(x) offsetof(WAVMuxContext, x)
490 #define ENC AV_OPT_FLAG_ENCODING_PARAM
493 {
"write_peak",
"Write Peak Envelope chunk.",
OFFSET(write_peak),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2,
ENC,
"peak" },
496 {
"only",
"Write only peak chunk, omit wav data.", 0,
AV_OPT_TYPE_CONST, { .i64 =
PEAK_ONLY }, 0, 0,
ENC,
"peak" },
501 {
"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 },
503 {
"peak_ppv",
"Number of peak points per peak value (1 or 2).",
OFFSET(peak_ppv),
AV_OPT_TYPE_INT, { .i64 = 2 }, 1, 2,
ENC },
507 static const AVClass wav_muxer_class = {
517 .mime_type =
"audio/x-wav",
527 .priv_class = &wav_muxer_class,
590 end_guid(pb, wav->
data);
597 int64_t number_of_samples;