fmt conversion: convert several files

This commit is contained in:
Moritz Bunkus 2018-11-18 17:27:35 +01:00
parent 0bbc8a30e4
commit 00957c6b61
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
3 changed files with 307 additions and 308 deletions

View File

@ -216,7 +216,7 @@ latm_parser_c::parse_audio_specific_config(size_t asc_length) {
void
latm_parser_c::parse_stream_mux_config() {
mxdebug_if(m_debug, boost::format("Parsing stream mux config\n"));
mxdebug_if(m_debug, fmt::format("Parsing stream mux config\n"));
auto start_position = m_bc->get_bit_position();
m_audio_mux_version = m_bc->get_bit();
@ -224,7 +224,7 @@ latm_parser_c::parse_stream_mux_config() {
m_audio_mux_version_a = m_bc->get_bit();
if (m_audio_mux_version_a != 0) {
mxdebug_if(m_debug, boost::format("audio_mux_version_a is not 0; not supported\n"));
mxdebug_if(m_debug, fmt::format("audio_mux_version_a is not 0; not supported\n"));
throw false;
}
@ -236,14 +236,14 @@ latm_parser_c::parse_stream_mux_config() {
if (m_bc->get_bits(4) != 0) {
// More than one program is not supported at the moment; DVB
// always only uses a single program.
mxdebug_if(m_debug, boost::format("more than one program in LOAS/LATM\n"));
mxdebug_if(m_debug, fmt::format("more than one program in LOAS/LATM\n"));
throw false;
}
if (m_bc->get_bits(3) != 0) {
// More than one layer is not supported at the moment; DVB
// always only uses a single layer.
mxdebug_if(m_debug, boost::format("more than one layer in LOAS/LATM\n"));
mxdebug_if(m_debug, fmt::format("more than one layer in LOAS/LATM\n"));
throw false;
}
@ -298,8 +298,8 @@ latm_parser_c::parse_stream_mux_config() {
m_bc->skip_bits(8); // config_crc
mxdebug_if(m_debug,
boost::format("stream_mux_config: bit size %1% m_audio_mux_version %2% m_audio_mux_version_a %3% m_frame_length_type %4% m_fixed_frame_length %5% header %6%\n")
% (m_bc->get_bit_position() - start_position) % m_audio_mux_version % m_audio_mux_version_a % m_frame_length_type % m_fixed_frame_length % m_header);
fmt::format("stream_mux_config: bit size {0} m_audio_mux_version {1} m_audio_mux_version_a {2} m_frame_length_type {3} m_fixed_frame_length {4} header {5}\n",
m_bc->get_bit_position() - start_position, m_audio_mux_version, m_audio_mux_version_a, m_frame_length_type, m_fixed_frame_length, m_header));
}
size_t
@ -358,7 +358,7 @@ latm_parser_c::parse_audio_mux_element() {
}
if (!m_config_parsed) {
mxdebug_if(m_debug, boost::format("Configuration not parsed; not continuing with audio mux element parsing\n"));
mxdebug_if(m_debug, fmt::format("Configuration not parsed; not continuing with audio mux element parsing\n"));
throw false;
}
@ -394,18 +394,18 @@ std::string
frame_c::to_string(bool verbose)
const {
if (!verbose)
return (boost::format("position %1% size %2% ID %3% profile %4%") % m_stream_position % m_header.bytes % m_header.id % m_header.config.profile).str();
return fmt::format("position {0} size {1} ID {2} profile {3}", m_stream_position, m_header.bytes, m_header.id, m_header.config.profile);
return (boost::format("position %1% size %2% garbage %3% ID %4% profile %5% sample rate %6% bit rate %7% channels %8%")
% m_stream_position
% m_header.bytes
% m_garbage_size
% m_header.id
% m_header.config.profile
% m_header.config.sample_rate
% m_header.bit_rate
% m_header.config.channels
).str();
return fmt::format("position {0} size {1} garbage {2} ID {3} profile {4} sample rate {5} bit rate {6} channels {7}",
m_stream_position,
m_header.bytes,
m_garbage_size,
m_header.id,
m_header.config.profile,
m_header.config.sample_rate,
m_header.bit_rate,
m_header.config.channels
);
}
// ------------------------------------------------------------
@ -618,8 +618,8 @@ parser_c::decode_loas_latm_header(unsigned char const *buffer,
if (decoded_frame_end_bits > (loas_frame_end * 8)) {
mxdebug_if(m_debug,
boost::format("decode_loas_latm_header: decoded_frame_end_bits (%1%) > loas_frame_end_bits (%2%); decoded_frame_length: %3% end_of_header_bit_pos %4%\n")
% decoded_frame_end_bits % (loas_frame_end * 8) % decoded_frame_length % end_of_header_bit_pos);
fmt::format("decode_loas_latm_header: decoded_frame_end_bits ({0}) > loas_frame_end_bits ({1}); decoded_frame_length: {2} end_of_header_bit_pos {3}\n",
decoded_frame_end_bits, loas_frame_end * 8, decoded_frame_length, end_of_header_bit_pos));
return { failure, 2 };
}
@ -646,10 +646,10 @@ parser_c::decode_loas_latm_header(unsigned char const *buffer,
push_frame(frame);
mxdebug_if(m_debug,
boost::format("decode_loas_latm_header: headerok %6% buffer_size %1% loas_frame_size %2% header_byte_size %3% data_byte_size %4% bytes %5% decoded_frame_offset %7% decoded_frame_length %8% "
"first_four_bytes %|9$08x| end_of_header_bit_pos %10%\n")
% buffer_size % loas_frame_size % frame.m_header.header_byte_size % frame.m_header.data_byte_size % frame.m_header.bytes % new_header.is_valid % m_latm_parser.get_frame_bit_offset() % decoded_frame_length
% (dst_buffer && (decoded_frame_length >= 4) ? get_uint32_be(dst_buffer) : 0) % end_of_header_bit_pos);
fmt::format("decode_loas_latm_header: headerok {5} buffer_size {0} loas_frame_size {1} header_byte_size {2} data_byte_size {3} bytes {4} decoded_frame_offset {6} decoded_frame_length {7} "
"first_four_bytes {8:08x} end_of_header_bit_pos {9}\n",
buffer_size, loas_frame_size, frame.m_header.header_byte_size, frame.m_header.data_byte_size, frame.m_header.bytes, new_header.is_valid, m_latm_parser.get_frame_bit_offset(), decoded_frame_length,
dst_buffer && (decoded_frame_length >= 4) ? get_uint32_be(dst_buffer) : 0, end_of_header_bit_pos));
return { success, loas_frame_end };
@ -730,9 +730,9 @@ parser_c::parse() {
m_parsed_stream_position += num_bytes;
mxdebug_if(m_debug,
boost::format("result_status %1% remainig_bytes %2% result_bytes %3% num_bytes %4% position before %5% after %6%\n")
% (result.first == success ? "success" : result.first == failure ? "failure" : "need-more-data")
% remaining_bytes % result.second % num_bytes % (position - num_bytes) % position);
fmt::format("result_status {0} remainig_bytes {1} result_bytes {2} num_bytes {3} position before {4} after {5}\n",
result.first == success ? "success" : result.first == failure ? "failure" : "need-more-data",
remaining_bytes, result.second, num_bytes, position - num_bytes, position));
if (result.first == failure) {
m_garbage_size += num_bytes;
@ -775,7 +775,7 @@ parser_c::find_consecutive_frames(unsigned char const *buffer,
static auto s_debug = debugging_option_c{"aac_consecutive_frames"};
for (int base = 0; (base + 8) < static_cast<int>(buffer_size); ++base) {
mxdebug_if(s_debug, boost::format("Starting search for %2% headers with base %1%, buffer size %3%\n") % base % num_required_frames % buffer_size);
mxdebug_if(s_debug, fmt::format("Starting search for {1} headers with base {0}, buffer size {2}\n", base, num_required_frames, buffer_size));
auto value = get_uint24_be(&buffer[base]);
// Speeding up checks by using shortcuts here instead of going
@ -834,12 +834,12 @@ parser_c::find_consecutive_frames(unsigned char const *buffer,
auto frame = parser.get_frame();
frames.push_back(frame);
garbage_sizes += (boost::format(" %1%") % frame.m_garbage_size).str();
garbage_sizes += fmt::format(" {0}", frame.m_garbage_size);
if (frame.m_garbage_size)
garbage_found = true;
}
mxdebug_if(s_debug, boost::format(" Found enough headers at %1%; garbage sizes:%2% found garbage: %3%\n") % base % garbage_sizes % garbage_found);
mxdebug_if(s_debug, fmt::format(" Found enough headers at {0}; garbage sizes:{1} found garbage: {2}\n", base, garbage_sizes, garbage_found));
if (garbage_found)
continue;
@ -854,12 +854,12 @@ parser_c::find_consecutive_frames(unsigned char const *buffer,
&& (current_frame.m_header.config.channels != first_frame.m_header.config.channels)
&& (current_frame.m_header.config.sample_rate != first_frame.m_header.config.sample_rate)) {
mxdebug_if(s_debug,
boost::format("Current frame number %9% at %10% differs from first frame. (first/current) ID: %1%/%2% profile: %3%/%4% channels: %5%/%6% sample rate: %7%/%8%\n")
% first_frame.m_header.id % current_frame.m_header.id
% first_frame.m_header.config.profile % current_frame.m_header.config.profile
% first_frame.m_header.config.channels % current_frame.m_header.config.channels
% first_frame.m_header.config.sample_rate % current_frame.m_header.config.sample_rate
% frame_idx % (base + current_frame.m_stream_position));
fmt::format("Current frame number {8} at {9} differs from first frame. (first/current) ID: {0}/{1} profile: {2}/{3} channels: {4}/{5} sample rate: {6}/{7}\n",
first_frame.m_header.id , current_frame.m_header.id,
first_frame.m_header.config.profile , current_frame.m_header.config.profile,
first_frame.m_header.config.channels , current_frame.m_header.config.channels,
first_frame.m_header.config.sample_rate, current_frame.m_header.config.sample_rate,
frame_idx, base + current_frame.m_stream_position));
mismatch_found = true;
@ -879,8 +879,8 @@ parser_c::find_consecutive_frames(unsigned char const *buffer,
std::string
header_c::to_string()
const {
return (boost::format("sample_rate: %1%; bit_rate: %2%; channels: %3%; bytes: %4%; id: %5%; profile: %6%; header_bit_size: %7%; header_byte_size: %8%; data_byte_size: %9%; is_sbr: %10%; is_valid: %11%")
% config.sample_rate % bit_rate % config.channels % bytes % id % config.profile % header_bit_size % header_byte_size % data_byte_size % config.sbr % is_valid).str();
return fmt::format("sample_rate: {0}; bit_rate: {1}; channels: {2}; bytes: {3}; id: {4}; profile: {5}; header_bit_size: {6}; header_byte_size: {7}; data_byte_size: {8}; is_sbr: {9}; is_valid: {10}",
config.sample_rate, bit_rate, config.channels, bytes, id, config.profile, header_bit_size, header_byte_size, data_byte_size, config.sbr, is_valid);
}
int
@ -1051,7 +1051,7 @@ header_c::parse_audio_specific_config(mtx::bits::reader_c &bc,
read_eld_specific_config();
else
throw "aac_object_type_not_ga_specific. %1%\n";
throw "aac_object_type_not_ga_specific. {0}\n";
if ((MP4AOT_ER_AAC_LC == object_type) || ((MP4AOT_ER_AAC_LTP <= object_type) && (MP4AOT_ER_PARAM >= object_type))) {
int ep_config = m_bc->get_bits(2);
@ -1088,7 +1088,7 @@ header_c::parse_audio_specific_config(mtx::bits::reader_c &bc,
}
} catch (mtx::exception &ex) {
mxdebug_if(s_debug_parse_data, boost::format("mtx::aac::parse_audio_specific_config: exception: %1%\n") % ex);
mxdebug_if(s_debug_parse_data, fmt::format("mtx::aac::parse_audio_specific_config: exception: {0}\n", ex));
}
m_bc = nullptr;
@ -1101,7 +1101,7 @@ header_c::parse_audio_specific_config(const unsigned char *data,
if (size < 2)
return;
mxdebug_if(s_debug_parse_data, boost::format("mtx::aac::parse_audio_specific_config: size %1%, data: %2%\n") % size % to_hex(data, size));
mxdebug_if(s_debug_parse_data, fmt::format("mtx::aac::parse_audio_specific_config: size {0}, data: {1}\n", size, to_hex(data, size)));
mtx::bits::reader_c bc{data, static_cast<unsigned int>(size)};
parse_audio_specific_config(bc, look_for_sync_extension);
@ -1115,7 +1115,7 @@ header_c::parse_program_config_element(mtx::bits::reader_c &bc) {
read_program_config_element();
} catch (mtx::exception &ex) {
mxdebug_if(s_debug_parse_data, boost::format("mtx::aac::parse_audio_specific_config: exception: %1%\n") % ex);
mxdebug_if(s_debug_parse_data, fmt::format("mtx::aac::parse_audio_specific_config: exception: {0}\n", ex));
}
m_bc = nullptr;

View File

@ -308,7 +308,7 @@ std::string
frame_c::to_string(bool verbose)
const {
if (!verbose)
return (boost::format("position %1% BS ID %2% size %3% E-AC-3 %4%") % m_stream_position % m_bs_id % m_bytes % is_eac3()).str();
return fmt::format("position {0} BS ID {1} size {2} E-AC-3 {3}", m_stream_position, m_bs_id, m_bytes, is_eac3());
const std::string &frame_type = !is_eac3() ? "---"
: m_frame_type == EAC3_FRAME_TYPE_INDEPENDENT ? "independent"
@ -317,28 +317,27 @@ frame_c::to_string(bool verbose)
: m_frame_type == EAC3_FRAME_TYPE_RESERVED ? "reserved"
: "unknown";
std::string output = (boost::format("position %1% size %3% garbage %2% BS ID %4% E-AC-3 %15% sample rate %5% bit rate %6% channels %7% (effective layout 0x%|16$08x|) flags %8% samples %9% type %10% (%13%) "
"sub stream ID %11% has dependent frames %12% total size %14%")
% m_stream_position
% m_garbage_size
% m_bytes
% m_bs_id
% m_sample_rate
% m_bit_rate
% m_channels
% m_flags
% m_samples
% m_frame_type
% m_sub_stream_id
% m_dependent_frames.size()
% frame_type
% (m_data ? m_data->get_size() : 0)
% is_eac3()
% get_effective_channel_layout()
).str();
auto output = fmt::format("position {0} size {2} garbage {1} BS ID {3} E-AC-3 {14} sample rate {4} bit rate {5} channels {6} (effective layout 0x{15:08x}) flags {7} samples {8} type {9} ({12}) "
"sub stream ID {10} has dependent frames {11} total size {13}",
m_stream_position,
m_garbage_size,
m_bytes,
m_bs_id,
m_sample_rate,
m_bit_rate,
m_channels,
m_flags,
m_samples,
m_frame_type,
m_sub_stream_id,
m_dependent_frames.size(),
frame_type,
m_data ? m_data->get_size() : 0,
is_eac3(),
get_effective_channel_layout());
for (auto &frame : m_dependent_frames)
output += (boost::format(" { %1% }") % frame.to_string(verbose)).str();
output += fmt::format(" { {0} }", frame.to_string(verbose));
return output;
}
@ -447,7 +446,7 @@ parser_c::find_consecutive_frames(unsigned char const *buffer,
std::size_t base = 0;
do {
mxdebug_if(s_debug, boost::format("Starting search for %2% headers with base %1%, buffer size %3%\n") % base % num_required_headers % buffer_size);
mxdebug_if(s_debug, fmt::format("Starting search for {1} headers with base {0}, buffer size {2}\n", base, num_required_headers, buffer_size));
std::size_t position = base;
@ -455,7 +454,7 @@ parser_c::find_consecutive_frames(unsigned char const *buffer,
while (((position + 8) < buffer_size) && !first_frame.decode_header(&buffer[position], buffer_size - position))
++position;
mxdebug_if(s_debug, boost::format("First frame at %1% valid %2%\n") % position % first_frame.m_valid);
mxdebug_if(s_debug, fmt::format("First frame at {0} valid {1}\n", position, first_frame.m_valid));
if (!first_frame.m_valid)
return -1;
@ -471,7 +470,7 @@ parser_c::find_consecutive_frames(unsigned char const *buffer,
break;
if (8 > current_frame.m_bytes) {
mxdebug_if(s_debug, boost::format("Current frame at %1% has invalid size %2%\n") % offset % current_frame.m_bytes);
mxdebug_if(s_debug, fmt::format("Current frame at {0} has invalid size {1}\n", offset, current_frame.m_bytes));
break;
}
@ -479,19 +478,19 @@ parser_c::find_consecutive_frames(unsigned char const *buffer,
&& (current_frame.m_channels != first_frame.m_channels)
&& (current_frame.m_sample_rate != first_frame.m_sample_rate)) {
mxdebug_if(s_debug,
boost::format("Current frame at %7% differs from first frame. (first/current) BS ID: %1%/%2% channels: %3%/%4% sample rate: %5%/%6%\n")
% first_frame.m_bs_id % current_frame.m_bs_id % first_frame.m_channels % current_frame.m_channels % first_frame.m_sample_rate % current_frame.m_sample_rate % offset);
fmt::format("Current frame at {6} differs from first frame. (first/current) BS ID: {0}/{1} channels: {2}/{3} sample rate: {4}/{5}\n",
first_frame.m_bs_id, current_frame.m_bs_id, first_frame.m_channels, current_frame.m_channels, first_frame.m_sample_rate, current_frame.m_sample_rate, offset));
break;
}
mxdebug_if(s_debug, boost::format("Current frame at %1% equals first frame, found %2%\n") % offset % (num_headers_found + 1));
mxdebug_if(s_debug, fmt::format("Current frame at {0} equals first frame, found {1}\n", offset, num_headers_found + 1));
++num_headers_found;
offset += current_frame.m_bytes;
}
if (num_headers_found == num_required_headers) {
mxdebug_if(s_debug, boost::format("Found required number of headers at %1%\n") % position);
mxdebug_if(s_debug, fmt::format("Found required number of headers at {0}\n", position));
return position;
}
@ -611,13 +610,13 @@ remove_dialog_normalization_gain_impl(unsigned char *buf,
if ( (frame.m_dialog_normalization_gain == removed_level)
&& ( !frame.m_dialog_normalization_gain2
|| (*frame.m_dialog_normalization_gain2 == removed_level))) {
mxdebug_if(s_debug, boost::format("no need to remove the dialog normalization gain, it's already set to -%1% dB\n") % removed_level);
mxdebug_if(s_debug, fmt::format("no need to remove the dialog normalization gain, it's already set to -{0} dB\n", removed_level));
return;
}
mxdebug_if(s_debug,
boost::format("changing dialog normalization gain from -%1% dB (%2%) to -%3% dB\n")
% frame.m_dialog_normalization_gain % (frame.m_dialog_normalization_gain2 ? (boost::format("-%1% dB") % *frame.m_dialog_normalization_gain2).str() : ""s) % removed_level);
fmt::format("changing dialog normalization gain from -{0} dB ({1}) to -{2} dB\n",
frame.m_dialog_normalization_gain, frame.m_dialog_normalization_gain2 ? fmt::format("-{0} dB", *frame.m_dialog_normalization_gain2) : ""s, removed_level));
mtx::bits::writer_c w{buf, frame.m_bytes};

File diff suppressed because it is too large Load Diff