void xtr_wav_c::create_file(xtr_base_c *master, KaxTrackEntry &track) { init_content_decoder(track); int channels = kt_get_a_channels(track); int sfreq = (int)kt_get_a_sfreq(track); int bps = kt_get_a_bps(track); if (-1 == bps) mxerror(boost::format(Y("Track %1% with the CodecID '%2%' is missing the \"bits per second (bps)\" element and cannot be extracted.\n")) % m_tid % m_codec_id); xtr_base_c::create_file(master, track); memcpy(&m_wh.riff.id, "RIFF", 4); memcpy(&m_wh.riff.wave_id, "WAVE", 4); memcpy(&m_wh.format.id, "fmt ", 4); memcpy(&m_wh.data.id, "data", 4); put_uint32_le(&m_wh.format.len, 16); put_uint16_le(&m_wh.common.wFormatTag, 1); put_uint16_le(&m_wh.common.wChannels, channels); put_uint32_le(&m_wh.common.dwSamplesPerSec, sfreq); put_uint32_le(&m_wh.common.dwAvgBytesPerSec, channels * sfreq * bps / 8); put_uint16_le(&m_wh.common.wBlockAlign, 4); put_uint16_le(&m_wh.common.wBitsPerSample, bps); m_out->write(&m_wh, sizeof(wave_header)); }
void xtr_tta_c::create_file(xtr_base_c *, KaxTrackEntry &track) { try { m_out = mm_write_buffer_io_c::open(m_temp_file_name, 5 * 1024 * 1024); } catch (mtx::mm_io::exception &ex) { mxerror(boost::format(Y("Failed to create the temporary file '%1%': %2%\n")) % m_temp_file_name % ex); } m_bps = kt_get_a_bps(track); m_channels = kt_get_a_channels(track); m_sfreq = (int)kt_get_a_sfreq(track); }
void xtr_wav_c::create_file(xtr_base_c *master, KaxTrackEntry &track) { init_content_decoder(track); auto channels = kt_get_a_channels(track); auto sfreq = static_cast<int>(kt_get_a_sfreq(track)); auto bps = kt_get_a_bps(track); auto block_align = bps * channels / boost::math::gcd(8, bps); if (-1 == bps) mxerror(boost::format(Y("Track %1% with the CodecID '%2%' is missing the \"bits per second (bps)\" element and cannot be extracted.\n")) % m_tid % m_codec_id); xtr_base_c::create_file(master, track); memcpy(&m_wh.riff.id, "RIFF", 4); memcpy(&m_wh.riff.wave_id, "WAVE", 4); memcpy(&m_wh.format.id, "fmt ", 4); memcpy(&m_wh.data.id, "data", 4); put_uint32_le(&m_wh.format.len, 16); put_uint16_le(&m_wh.common.wFormatTag, 1); put_uint16_le(&m_wh.common.wChannels, channels); put_uint32_le(&m_wh.common.dwSamplesPerSec, sfreq); put_uint32_le(&m_wh.common.dwAvgBytesPerSec, channels * sfreq * bps / 8); put_uint16_le(&m_wh.common.wBlockAlign, block_align); put_uint16_le(&m_wh.common.wBitsPerSample, bps); m_out->write(&m_wh, sizeof(wave_header)); if (m_codec_id == MKV_A_PCM_BE) m_byte_swapper = [bps](unsigned char const *src, unsigned char *dst, std::size_t num_bytes) { mtx::bytes::swap_buffer(src, dst, num_bytes, bps / 8); }; }