FastLED 3.10.6
Loading...
Searching...
No Matches

◆ decodeStream()

Decoded autoresearch::mp3_check::decodeStream ( fl::third_party::mp3dec_t * dec,
fl::third_party::mp3dec_scratch_t * scratch,
fl::i16 * pcm,
const mp3_fixture::Stream & stream )
inline

Decode one stream.

dec is supplied by the caller so the same decoder can be driven across two streams of different layers, which is what exercises the Layer I/II + Layer III scratch union on real hardware.

Definition at line 98 of file AutoResearchMp3.h.

100 {
101 Decoded out;
102 out.fnv1a = 2166136261u;
103 out.samples = 0;
104 out.frames = 0;
105 out.hz = 0;
106 out.channels = 0;
107 out.layer = 0;
108
109 fl::u32 offset = 0;
110 while (offset + 4 < stream.size) {
111 fl::third_party::mp3dec_frame_info_t info;
112 fl::memset(&info, 0, sizeof(info));
113 const int samples = fl::third_party::mp3dec_decode_frame_r(
114 dec, scratch, stream.data + offset, (int)(stream.size - offset),
115 pcm, &info);
116 if (info.frame_bytes <= 0) {
117 break;
118 }
119 offset += (fl::u32)info.frame_bytes;
120 if (samples > 0) {
121 const fl::u32 count = (fl::u32)samples * (fl::u32)info.channels;
122 out.fnv1a = fnv1a(out.fnv1a, pcm, count);
123 out.samples += count;
124 ++out.frames;
125 out.hz = (fl::u32)info.hz;
126 out.channels = (fl::u32)info.channels;
127 out.layer = (fl::u32)info.layer;
128 }
129 }
130 return out;
131}
fl::UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
fl::u32 fnv1a(fl::u32 hash, const fl::i16 *samples, fl::u32 count)
void * memset(void *s, int c, size_t n) FL_NO_EXCEPT

References autoresearch::mp3_check::Decoded::channels, autoresearch::mp3_fixture::Stream::data, autoresearch::mp3_check::Decoded::fnv1a, fnv1a(), autoresearch::mp3_check::Decoded::frames, autoresearch::mp3_check::Decoded::hz, autoresearch::mp3_check::Decoded::layer, fl::memset(), offset(), autoresearch::mp3_check::Decoded::samples, and autoresearch::mp3_fixture::Stream::size.

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: