| 67 | char m_UnCache[4*1024*1024]; |
| 68 | |
| 69 | void DecodeAndTime(const dmSoundCodec::DecoderInfo *decoder, unsigned char *buf, uint32_t size, const char *decoder_name, dmSound::SoundDataType sound_datatype, bool skip, const char *test_name) |
| 70 | { |
| 71 | int junk = 0; |
| 72 | for (unsigned int i=0;i<size;i+=4096) |
| 73 | junk += buf[i]; |
| 74 | for (unsigned int i=0;i<sizeof(m_UnCache);i++) |
| 75 | m_UnCache[i] += junk; |
| 76 | |
| 77 | // Setup two output buffers (dummy) so we can support interleaved and non-interleaved data output |
| 78 | char tmp_l[4096*2]; |
| 79 | char tmp_r[4096*2]; |
| 80 | char* tmp_ptr[] = {tmp_l, tmp_r}; |
| 81 | dmSoundCodec::HDecodeStream stream; |
| 82 | |
| 83 | dmSound::HSoundData sd = 0; |
| 84 | dmSound::NewSoundData(buf, size, sound_datatype, &sd, dmHashString64(test_name)); |
| 85 | |
| 86 | const uint64_t time_beg = dmTime::GetMonotonicTime(); |
| 87 | ASSERT_EQ(decoder->m_OpenStream(sd, &stream), dmSoundCodec::RESULT_OK); |
| 88 | const uint64_t time_open = dmTime::GetMonotonicTime(); |
| 89 | |
| 90 | // select output buffer size depending if we have int16_t or float data being produced (we are not interested in PCM8 here) to make sure we 'chunk' the decode the same for both |
| 91 | |
| 92 | dmSoundCodec::Info info; |
| 93 | decoder->m_GetStreamInfo(stream, &info); |
| 94 | |
| 95 | // Make sure we get half the buffers only if we decode to int16 not float (to keep chunking the same) |
| 96 | uint32_t out_size = sizeof(tmp_l) / (32 / info.m_BitsPerSample); |
| 97 | if (!info.m_IsInterleaved) |
| 98 | { |
| 99 | // Half the buffer size if we have non-interleaved data (as we use per channel buffers) |
| 100 | out_size /= info.m_Channels; |
| 101 | assert(info.m_Channels <= 2); |
| 102 | } |
| 103 | |
| 104 | uint64_t max_chunk_time = 0; |
| 105 | uint64_t iterations = 0; |
| 106 | uint64_t total_decoded = 0; |
| 107 | |
| 108 | while (true) |
| 109 | { |
| 110 | iterations++; |
| 111 | |
| 112 | uint32_t decoded; |
| 113 | |
| 114 | const uint64_t chunk_begin = dmTime::GetMonotonicTime(); |
| 115 | |
| 116 | if (skip) |
| 117 | decoder->m_SkipInStream(stream, out_size, &decoded); |
| 118 | else |
| 119 | decoder->m_DecodeStream(stream, tmp_ptr, out_size, &decoded); |
| 120 | |
| 121 | total_decoded += decoded * (info.m_IsInterleaved ? 1 : info.m_Channels); |
| 122 | |
| 123 | if (decoded != out_size) |
| 124 | break; |
| 125 | |
| 126 | const uint64_t chunk_time = dmTime::GetMonotonicTime() - chunk_begin; |
nothing calls this directly
no test coverage detected