void dts_reader_c::read_headers() { try { if (m_in->read(m_buf[m_cur_buf], READ_SIZE) != READ_SIZE) throw mtx::input::header_parsing_x(); m_in->setFilePointer(0, seek_beginning); } catch (...) { throw mtx::input::open_x(); } detect_dts(m_buf[m_cur_buf], READ_SIZE, m_dts14_to_16, m_swap_bytes); mxdebug_if(m_debug, boost::format("DTS: 14->16 %1% swap %2%\n") % m_dts14_to_16 % m_swap_bytes); decode_buffer(READ_SIZE); int pos = find_dts_header(reinterpret_cast<const unsigned char *>(m_buf[m_cur_buf]), READ_SIZE, &m_dtsheader); if (0 > pos) throw mtx::input::header_parsing_x(); m_ti.m_id = 0; // ID for this track. show_demuxer_info(); }
int dts_reader_c::probe_file(mm_io_c *in, uint64_t size, bool strict_mode) { if (size < READ_SIZE) return 0; try { unsigned char buf[READ_SIZE]; bool dts14_to_16 = false, swap_bytes = false; in->setFilePointer(0, seek_beginning); if (in->read(buf, READ_SIZE) != READ_SIZE) return 0; in->setFilePointer(0, seek_beginning); if (!strict_mode && detect_dts(buf, READ_SIZE, dts14_to_16, swap_bytes)) return 1; int pos = find_consecutive_dts_headers(buf, READ_SIZE, 5); if ((!strict_mode && (0 <= pos)) || (strict_mode && (0 == pos))) return 1; } catch (...) { } return 0; }
bool wav_dts_demuxer_c::probe(mm_io_cptr &io) { io->save_pos(); int len = io->read(m_buf[m_cur_buf]->get_buffer(), DTS_READ_SIZE); io->restore_pos(); if (detect_dts(m_buf[m_cur_buf]->get_buffer(), len, m_pack_14_16, m_swap_bytes)) { len = decode_buffer(len); int pos = find_consecutive_dts_headers(m_buf[m_cur_buf]->get_buffer(), len, 5); if (0 <= pos) { if (0 > find_dts_header(m_buf[m_cur_buf]->get_buffer() + pos, len - pos, &m_dtsheader)) return false; mxverb(3, boost::format("DTSinWAV: 14->16 %1% swap %2%\n") % m_pack_14_16 % m_swap_bytes); return true; } } return false; }