FastLED 3.9.15
Loading...
Searching...
No Matches

◆ vorbis_finish_frame()

static int32_t fl::third_party::vorbis::vorbis_finish_frame ( stb_vorbis * f,
int32_t len,
int32_t left,
int32_t right )
static

Definition at line 3186 of file stb_vorbis.cpp.hpp.

3187{
3188 int32_t prev,i,j;
3189 // we use right&left (the start of the right- and left-window sin()-regions)
3190 // to determine how much to return, rather than inferring from the rules
3191 // (same result, clearer code); 'left' indicates where our sin() window
3192 // starts, therefore where the previous window's right edge starts, and
3193 // therefore where to start mixing from the previous buffer. 'right'
3194 // indicates where our sin() ending-window starts, therefore that's where
3195 // we start saving, and where our returned-data ends.
3196
3197 // mixin from previous window
3198 if (f->previous_length) {
3199 int32_t i,j, n = f->previous_length;
3200 float *w = get_window(f, n);
3201 if (w == nullptr) return 0;
3202 for (i=0; i < f->channels; ++i) {
3203 for (j=0; j < n; ++j)
3204 f->channel_buffers[i][left+j] =
3205 f->channel_buffers[i][left+j]*w[ j] +
3206 f->previous_window[i][ j]*w[n-1-j];
3207 }
3208 }
3209
3210 prev = f->previous_length;
3211
3212 // last half of this data becomes previous window
3213 f->previous_length = len - right;
3214
3215 // @OPTIMIZE: could avoid this copy by double-buffering the
3216 // output (flipping previous_window with channel_buffers), but
3217 // then previous_window would have to be 2x as large, and
3218 // channel_buffers couldn't be temp mem (although they're NOT
3219 // currently temp mem, they could be (unless we want to level
3220 // performance by spreading out the computation))
3221 for (i=0; i < f->channels; ++i)
3222 for (j=0; right+j < len; ++j)
3223 f->previous_window[i][j] = f->channel_buffers[i][right+j];
3224
3225 if (!prev)
3226 // there was no previous packet, so this data isn't valid...
3227 // this isn't entirely true, only the would-have-overlapped data
3228 // isn't valid, but this seems to be what the spec requires
3229 return 0;
3230
3231 // truncate a short frame
3232 if (len < right) right = len;
3233
3234 f->samples_output += right-left;
3235
3236 return right - left;
3237}
static float * get_window(vorb *f, int32_t len) FL_NOEXCEPT
float * previous_window[FL_STB_VORBIS_MAX_CHANNELS]
float * channel_buffers[FL_STB_VORBIS_MAX_CHANNELS]
fl::i32 int32_t
Definition coder.h:220

References FL_NOEXCEPT, and get_window().

Referenced by stb_vorbis_decode_frame_pushdata(), stb_vorbis_get_frame_float(), and vorbis_pump_first_frame().

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