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

◆ stb_vorbis_seek_frame()

int32_t fl::third_party::vorbis::stb_vorbis_seek_frame ( stb_vorbis * f,
uint32_t sample_number )

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

4639{
4640 uint32 max_frame_samples;
4641
4643
4644 // fast page-level search
4645 if (!seek_to_sample_coarse(f, sample_number))
4646 return 0;
4647
4648 FL_ASSERT(f->current_loc_valid, "current_loc must be valid");
4649 FL_ASSERT(f->current_loc <= sample_number, "current_loc must be <= sample_number");
4650
4651 // linear search for the relevant packet
4652 max_frame_samples = (f->blocksize_1*3 - f->blocksize_0) >> 2;
4653 while (f->current_loc < sample_number) {
4654 int32_t left_start, left_end, right_start, right_end, mode, frame_samples;
4655 if (!peek_decode_initial(f, &left_start, &left_end, &right_start, &right_end, &mode))
4656 return error(f, VORBIS_seek_failed);
4657 // calculate the number of samples returned by the next frame
4658 frame_samples = right_start - left_start;
4659 if (f->current_loc + frame_samples > sample_number) {
4660 return 1; // the next frame will contain the sample
4661 } else if (f->current_loc + frame_samples + max_frame_samples > sample_number) {
4662 // there's a chance the frame after this could contain the sample
4664 } else {
4665 // this frame is too early to be relevant
4666 f->current_loc += frame_samples;
4667 f->previous_length = 0;
4669 flush_packet(f);
4670 }
4671 }
4672 // the next frame should start with the sample
4673 if (f->current_loc != sample_number) return error(f, VORBIS_seek_failed);
4674 return 1;
4675}
#define FL_ASSERT(x, MSG)
Definition assert.h:6
static void flush_packet(vorb *f) FL_NOEXCEPT
static int32_t error(vorb *f, enum STBVorbisError e) FL_NOEXCEPT
static int32_t vorbis_pump_first_frame(stb_vorbis *f) FL_NOEXCEPT
static int32_t seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number) FL_NOEXCEPT
static int32_t maybe_start_packet(vorb *f) FL_NOEXCEPT
static int32_t peek_decode_initial(vorb *f, int32_t *p_left_start, int32_t *p_left_end, int32_t *p_right_start, int32_t *p_right_end, int32_t *mode) FL_NOEXCEPT
fl::i32 int32_t
Definition coder.h:220
#define FL_STBV_IS_PUSH_MODE(f)

References error(), FL_ASSERT, FL_NOEXCEPT, FL_STBV_IS_PUSH_MODE, flush_packet(), maybe_start_packet(), peek_decode_initial(), seek_to_sample_coarse(), VORBIS_invalid_api_mixing, vorbis_pump_first_frame(), and VORBIS_seek_failed.

Referenced by stb_vorbis_seek().

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