Lines Matching full:decoder
76 static void set_defaults_(FLAC__StreamDecoder *decoder);
78 static FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels);
79 static FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id);
80 static FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder);
81 static FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder);
82 static FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint3…
83 static FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32…
84 static FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_V…
85 static FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_CueShe…
86 static FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_Picture…
87 static FLAC__bool skip_id3v2_tag_(FLAC__StreamDecoder *decoder);
88 static FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder);
89 static FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_…
90 static FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder);
91 static FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC…
92 static FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t …
93 static FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps…
94 static FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, …
95 static FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t …
96 static FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_t predictor_…
97 static FLAC__bool read_zero_padding_(FLAC__StreamDecoder *decoder);
100 static FLAC__StreamDecoderReadStatus read_callback_ogg_aspect_(const FLAC__StreamDecoder *decoder, …
103 static FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder *decoder, co…
104 static void send_error_to_client_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatu…
105 static FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length…
107 static FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_le…
109 static FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__…
110 static FLAC__StreamDecoderSeekStatus file_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__…
111 static FLAC__StreamDecoderTellStatus file_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__…
112 static FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FL…
113 static FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data);
160 …eset_hack; /* used only during init() so we can call reset to set up the decoder without rewinding…
243 FLAC__StreamDecoder *decoder; in FLAC__stream_decoder_new() local
248 decoder = calloc(1, sizeof(FLAC__StreamDecoder)); in FLAC__stream_decoder_new()
249 if(decoder == 0) { in FLAC__stream_decoder_new()
253 decoder->protected_ = calloc(1, sizeof(FLAC__StreamDecoderProtected)); in FLAC__stream_decoder_new()
254 if(decoder->protected_ == 0) { in FLAC__stream_decoder_new()
255 free(decoder); in FLAC__stream_decoder_new()
259 decoder->private_ = calloc(1, sizeof(FLAC__StreamDecoderPrivate)); in FLAC__stream_decoder_new()
260 if(decoder->private_ == 0) { in FLAC__stream_decoder_new()
261 free(decoder->protected_); in FLAC__stream_decoder_new()
262 free(decoder); in FLAC__stream_decoder_new()
266 decoder->private_->input = FLAC__bitreader_new(); in FLAC__stream_decoder_new()
267 if(decoder->private_->input == 0) { in FLAC__stream_decoder_new()
268 free(decoder->private_); in FLAC__stream_decoder_new()
269 free(decoder->protected_); in FLAC__stream_decoder_new()
270 free(decoder); in FLAC__stream_decoder_new()
274 decoder->private_->metadata_filter_ids_capacity = 16; in FLAC__stream_decoder_new()
275 …if(0 == (decoder->private_->metadata_filter_ids = malloc((FLAC__STREAM_METADATA_APPLICATION_ID_LEN… in FLAC__stream_decoder_new()
276 FLAC__bitreader_delete(decoder->private_->input); in FLAC__stream_decoder_new()
277 free(decoder->private_); in FLAC__stream_decoder_new()
278 free(decoder->protected_); in FLAC__stream_decoder_new()
279 free(decoder); in FLAC__stream_decoder_new()
284 decoder->private_->output[i] = 0; in FLAC__stream_decoder_new()
285 decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; in FLAC__stream_decoder_new()
288 decoder->private_->output_capacity = 0; in FLAC__stream_decoder_new()
289 decoder->private_->output_channels = 0; in FLAC__stream_decoder_new()
290 decoder->private_->has_seek_table = false; in FLAC__stream_decoder_new()
293 …FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&decoder->private_->partitioned_… in FLAC__stream_decoder_new()
295 decoder->private_->file = 0; in FLAC__stream_decoder_new()
297 set_defaults_(decoder); in FLAC__stream_decoder_new()
299 decoder->protected_->state = FLAC__STREAM_DECODER_UNINITIALIZED; in FLAC__stream_decoder_new()
301 return decoder; in FLAC__stream_decoder_new()
304 FLAC_API void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_delete() argument
308 if (decoder == NULL) in FLAC__stream_decoder_delete()
311 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_delete()
312 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_delete()
313 FLAC__ASSERT(0 != decoder->private_->input); in FLAC__stream_decoder_delete()
315 (void)FLAC__stream_decoder_finish(decoder); in FLAC__stream_decoder_delete()
317 if(0 != decoder->private_->metadata_filter_ids) in FLAC__stream_decoder_delete()
318 free(decoder->private_->metadata_filter_ids); in FLAC__stream_decoder_delete()
320 FLAC__bitreader_delete(decoder->private_->input); in FLAC__stream_decoder_delete()
323 …FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(&decoder->private_->partitioned… in FLAC__stream_decoder_delete()
325 free(decoder->private_); in FLAC__stream_decoder_delete()
326 free(decoder->protected_); in FLAC__stream_decoder_delete()
327 free(decoder); in FLAC__stream_decoder_delete()
337 FLAC__StreamDecoder *decoder, in init_stream_internal_() argument
350 FLAC__ASSERT(0 != decoder); in init_stream_internal_()
352 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in init_stream_internal_()
367 decoder->private_->is_ogg = is_ogg; in init_stream_internal_()
368 if(is_ogg && !FLAC__ogg_decoder_aspect_init(&decoder->protected_->ogg_decoder_aspect)) in init_stream_internal_()
369 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE; in init_stream_internal_()
375 FLAC__cpu_info(&decoder->private_->cpuinfo); in init_stream_internal_()
377 decoder->private_->local_lpc_restore_signal = FLAC__lpc_restore_signal; in init_stream_internal_()
378 decoder->private_->local_lpc_restore_signal_64bit = FLAC__lpc_restore_signal_wide; in init_stream_internal_()
379 decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal; in init_stream_internal_()
382 if(decoder->private_->cpuinfo.use_asm) { in init_stream_internal_()
384 FLAC__ASSERT(decoder->private_->cpuinfo.type == FLAC__CPUINFO_TYPE_IA32); in init_stream_internal_()
386 …decoder->private_->local_lpc_restore_signal_64bit = FLAC__lpc_restore_signal_wide_asm_ia32; /* OPT… in init_stream_internal_()
387 if (decoder->private_->cpuinfo.x86.mmx) { in init_stream_internal_()
388 decoder->private_->local_lpc_restore_signal = FLAC__lpc_restore_signal_asm_ia32; in init_stream_internal_()
389 decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_asm_ia32_mmx; in init_stream_internal_()
392 decoder->private_->local_lpc_restore_signal = FLAC__lpc_restore_signal_asm_ia32; in init_stream_internal_()
393 decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_asm_ia32; in init_stream_internal_()
398 if (decoder->private_->cpuinfo.x86.sse41) { in init_stream_internal_()
400 decoder->private_->local_lpc_restore_signal = FLAC__lpc_restore_signal_intrin_sse41; in init_stream_internal_()
401 decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_16_intrin_sse41; in init_stream_internal_()
403 decoder->private_->local_lpc_restore_signal_64bit = FLAC__lpc_restore_signal_wide_intrin_sse41; in init_stream_internal_()
408 FLAC__ASSERT(decoder->private_->cpuinfo.type == FLAC__CPUINFO_TYPE_X86_64); in init_stream_internal_()
416 if(!FLAC__bitreader_init(decoder->private_->input, read_callback_, decoder)) { in init_stream_internal_()
417 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in init_stream_internal_()
421 decoder->private_->read_callback = read_callback; in init_stream_internal_()
422 decoder->private_->seek_callback = seek_callback; in init_stream_internal_()
423 decoder->private_->tell_callback = tell_callback; in init_stream_internal_()
424 decoder->private_->length_callback = length_callback; in init_stream_internal_()
425 decoder->private_->eof_callback = eof_callback; in init_stream_internal_()
426 decoder->private_->write_callback = write_callback; in init_stream_internal_()
427 decoder->private_->metadata_callback = metadata_callback; in init_stream_internal_()
428 decoder->private_->error_callback = error_callback; in init_stream_internal_()
429 decoder->private_->client_data = client_data; in init_stream_internal_()
430 decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size = 0; in init_stream_internal_()
431 decoder->private_->samples_decoded = 0; in init_stream_internal_()
432 decoder->private_->has_stream_info = false; in init_stream_internal_()
433 decoder->private_->cached = false; in init_stream_internal_()
435 decoder->private_->do_md5_checking = decoder->protected_->md5_checking; in init_stream_internal_()
436 decoder->private_->is_seeking = false; in init_stream_internal_()
438 …decoder->private_->internal_reset_hack = true; /* so the following reset does not try to rewind th… in init_stream_internal_()
439 if(!FLAC__stream_decoder_reset(decoder)) { in init_stream_internal_()
448 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_stream() argument
461 decoder, in FLAC__stream_decoder_init_stream()
476 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_ogg_stream() argument
489 decoder, in FLAC__stream_decoder_init_ogg_stream()
504 FLAC__StreamDecoder *decoder, in init_FILE_internal_() argument
513 FLAC__ASSERT(0 != decoder); in init_FILE_internal_()
516 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in init_FILE_internal_()
517 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED; in init_FILE_internal_()
520 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS; in init_FILE_internal_()
530 decoder->private_->file = file; in init_FILE_internal_()
533 decoder, in init_FILE_internal_()
535 decoder->private_->file == stdin? 0: file_seek_callback_, in init_FILE_internal_()
536 decoder->private_->file == stdin? 0: file_tell_callback_, in init_FILE_internal_()
537 decoder->private_->file == stdin? 0: file_length_callback_, in init_FILE_internal_()
548 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_FILE() argument
556 …return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, clien… in FLAC__stream_decoder_init_FILE()
560 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_ogg_FILE() argument
568 …return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, clien… in FLAC__stream_decoder_init_ogg_FILE()
572 FLAC__StreamDecoder *decoder, in init_file_internal_() argument
583 FLAC__ASSERT(0 != decoder); in init_file_internal_()
590 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in init_file_internal_()
591 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED; in init_file_internal_()
594 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS; in init_file_internal_()
601 …return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, clien… in init_file_internal_()
605 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_file() argument
613 …return init_file_internal_(decoder, filename, write_callback, metadata_callback, error_callback, c… in FLAC__stream_decoder_init_file()
617 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_ogg_file() argument
625 …return init_file_internal_(decoder, filename, write_callback, metadata_callback, error_callback, c… in FLAC__stream_decoder_init_ogg_file()
628 FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_finish() argument
633 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_finish()
634 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_finish()
635 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_finish()
637 if(decoder->protected_->state == FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_finish()
643 FLAC__MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context); in FLAC__stream_decoder_finish()
645 free(decoder->private_->seek_table.data.seek_table.points); in FLAC__stream_decoder_finish()
646 decoder->private_->seek_table.data.seek_table.points = 0; in FLAC__stream_decoder_finish()
647 decoder->private_->has_seek_table = false; in FLAC__stream_decoder_finish()
649 FLAC__bitreader_free(decoder->private_->input); in FLAC__stream_decoder_finish()
657 if(0 != decoder->private_->output[i]) { in FLAC__stream_decoder_finish()
658 free(decoder->private_->output[i]-4); in FLAC__stream_decoder_finish()
659 decoder->private_->output[i] = 0; in FLAC__stream_decoder_finish()
661 if(0 != decoder->private_->residual_unaligned[i]) { in FLAC__stream_decoder_finish()
662 free(decoder->private_->residual_unaligned[i]); in FLAC__stream_decoder_finish()
663 decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; in FLAC__stream_decoder_finish()
666 decoder->private_->output_capacity = 0; in FLAC__stream_decoder_finish()
667 decoder->private_->output_channels = 0; in FLAC__stream_decoder_finish()
670 if(decoder->private_->is_ogg) in FLAC__stream_decoder_finish()
671 FLAC__ogg_decoder_aspect_finish(&decoder->protected_->ogg_decoder_aspect); in FLAC__stream_decoder_finish()
674 if(0 != decoder->private_->file) { in FLAC__stream_decoder_finish()
675 if(decoder->private_->file != stdin) in FLAC__stream_decoder_finish()
676 fclose(decoder->private_->file); in FLAC__stream_decoder_finish()
677 decoder->private_->file = 0; in FLAC__stream_decoder_finish()
680 if(decoder->private_->do_md5_checking) { in FLAC__stream_decoder_finish()
681 …if(memcmp(decoder->private_->stream_info.data.stream_info.md5sum, decoder->private_->computed_md5s… in FLAC__stream_decoder_finish()
684 decoder->private_->is_seeking = false; in FLAC__stream_decoder_finish()
686 set_defaults_(decoder); in FLAC__stream_decoder_finish()
688 decoder->protected_->state = FLAC__STREAM_DECODER_UNINITIALIZED; in FLAC__stream_decoder_finish()
693 FLAC_API FLAC__bool FLAC__stream_decoder_set_ogg_serial_number(FLAC__StreamDecoder *decoder, long v… in FLAC__stream_decoder_set_ogg_serial_number() argument
695 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_ogg_serial_number()
696 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_ogg_serial_number()
697 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_ogg_serial_number()
698 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_ogg_serial_number()
701 /* can't check decoder->private_->is_ogg since that's not set until init time */ in FLAC__stream_decoder_set_ogg_serial_number()
702 FLAC__ogg_decoder_aspect_set_serial_number(&decoder->protected_->ogg_decoder_aspect, value); in FLAC__stream_decoder_set_ogg_serial_number()
710 FLAC_API FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder *decoder, FLAC__bool … in FLAC__stream_decoder_set_md5_checking() argument
712 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_md5_checking()
713 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_md5_checking()
714 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_md5_checking()
716 decoder->protected_->md5_checking = value; in FLAC__stream_decoder_set_md5_checking()
720 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder *decoder, FLAC__M… in FLAC__stream_decoder_set_metadata_respond() argument
722 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_respond()
723 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_respond()
724 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_respond()
729 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_respond()
731 decoder->private_->metadata_filter[type] = true; in FLAC__stream_decoder_set_metadata_respond()
733 decoder->private_->metadata_filter_ids_count = 0; in FLAC__stream_decoder_set_metadata_respond()
737 …AC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte… in FLAC__stream_decoder_set_metadata_respond_application() argument
739 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_respond_application()
740 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_respond_application()
741 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_respond_application()
743 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_respond_application()
746 if(decoder->private_->metadata_filter[FLAC__METADATA_TYPE_APPLICATION]) in FLAC__stream_decoder_set_metadata_respond_application()
749 FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids); in FLAC__stream_decoder_set_metadata_respond_application()
751 …if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity… in FLAC__stream_decoder_set_metadata_respond_application()
752 …if(0 == (decoder->private_->metadata_filter_ids = safe_realloc_mul_2op_(decoder->private_->metadat… in FLAC__stream_decoder_set_metadata_respond_application()
753 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in FLAC__stream_decoder_set_metadata_respond_application()
756 decoder->private_->metadata_filter_ids_capacity *= 2; in FLAC__stream_decoder_set_metadata_respond_application()
759 …memcpy(decoder->private_->metadata_filter_ids + decoder->private_->metadata_filter_ids_count * (FL… in FLAC__stream_decoder_set_metadata_respond_application()
760 decoder->private_->metadata_filter_ids_count++; in FLAC__stream_decoder_set_metadata_respond_application()
765 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_set_metadata_respond_all() argument
768 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_respond_all()
769 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_respond_all()
770 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_respond_all()
771 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_respond_all()
773 …for(i = 0; i < sizeof(decoder->private_->metadata_filter) / sizeof(decoder->private_->metadata_fil… in FLAC__stream_decoder_set_metadata_respond_all()
774 decoder->private_->metadata_filter[i] = true; in FLAC__stream_decoder_set_metadata_respond_all()
775 decoder->private_->metadata_filter_ids_count = 0; in FLAC__stream_decoder_set_metadata_respond_all()
779 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder *decoder, FLAC__Me… in FLAC__stream_decoder_set_metadata_ignore() argument
781 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_ignore()
782 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_ignore()
783 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_ignore()
788 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_ignore()
790 decoder->private_->metadata_filter[type] = false; in FLAC__stream_decoder_set_metadata_ignore()
792 decoder->private_->metadata_filter_ids_count = 0; in FLAC__stream_decoder_set_metadata_ignore()
796 …LAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder *decoder, const FLAC__byte… in FLAC__stream_decoder_set_metadata_ignore_application() argument
798 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_ignore_application()
799 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_ignore_application()
800 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_ignore_application()
802 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_ignore_application()
805 if(!decoder->private_->metadata_filter[FLAC__METADATA_TYPE_APPLICATION]) in FLAC__stream_decoder_set_metadata_ignore_application()
808 FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids); in FLAC__stream_decoder_set_metadata_ignore_application()
810 …if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity… in FLAC__stream_decoder_set_metadata_ignore_application()
811 …if(0 == (decoder->private_->metadata_filter_ids = safe_realloc_mul_2op_(decoder->private_->metadat… in FLAC__stream_decoder_set_metadata_ignore_application()
812 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in FLAC__stream_decoder_set_metadata_ignore_application()
815 decoder->private_->metadata_filter_ids_capacity *= 2; in FLAC__stream_decoder_set_metadata_ignore_application()
818 …memcpy(decoder->private_->metadata_filter_ids + decoder->private_->metadata_filter_ids_count * (FL… in FLAC__stream_decoder_set_metadata_ignore_application()
819 decoder->private_->metadata_filter_ids_count++; in FLAC__stream_decoder_set_metadata_ignore_application()
824 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_set_metadata_ignore_all() argument
826 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_ignore_all()
827 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_ignore_all()
828 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_ignore_all()
829 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_ignore_all()
831 memset(decoder->private_->metadata_filter, 0, sizeof(decoder->private_->metadata_filter)); in FLAC__stream_decoder_set_metadata_ignore_all()
832 decoder->private_->metadata_filter_ids_count = 0; in FLAC__stream_decoder_set_metadata_ignore_all()
836 FLAC_API FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_state() argument
838 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_state()
839 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_state()
840 return decoder->protected_->state; in FLAC__stream_decoder_get_state()
843 …_API const char *FLAC__stream_decoder_get_resolved_state_string(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_resolved_state_string() argument
845 return FLAC__StreamDecoderStateString[decoder->protected_->state]; in FLAC__stream_decoder_get_resolved_state_string()
848 FLAC_API FLAC__bool FLAC__stream_decoder_get_md5_checking(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_md5_checking() argument
850 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_md5_checking()
851 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_md5_checking()
852 return decoder->protected_->md5_checking; in FLAC__stream_decoder_get_md5_checking()
855 FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_total_samples() argument
857 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_total_samples()
858 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_total_samples()
859 …return decoder->private_->has_stream_info? decoder->private_->stream_info.data.stream_info.total_s… in FLAC__stream_decoder_get_total_samples()
862 FLAC_API uint32_t FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_channels() argument
864 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_channels()
865 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_channels()
866 return decoder->protected_->channels; in FLAC__stream_decoder_get_channels()
869 …__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_channel_assignment() argument
871 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_channel_assignment()
872 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_channel_assignment()
873 return decoder->protected_->channel_assignment; in FLAC__stream_decoder_get_channel_assignment()
876 FLAC_API uint32_t FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_bits_per_sample() argument
878 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_bits_per_sample()
879 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_bits_per_sample()
880 return decoder->protected_->bits_per_sample; in FLAC__stream_decoder_get_bits_per_sample()
883 FLAC_API uint32_t FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_sample_rate() argument
885 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_sample_rate()
886 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_sample_rate()
887 return decoder->protected_->sample_rate; in FLAC__stream_decoder_get_sample_rate()
890 FLAC_API uint32_t FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_blocksize() argument
892 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_blocksize()
893 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_blocksize()
894 return decoder->protected_->blocksize; in FLAC__stream_decoder_get_blocksize()
897 FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder *decoder, FL… in FLAC__stream_decoder_get_decode_position() argument
899 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_decode_position()
900 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_get_decode_position()
903 if(FLAC__HAS_OGG && decoder->private_->is_ogg) in FLAC__stream_decoder_get_decode_position()
906 if(0 == decoder->private_->tell_callback) in FLAC__stream_decoder_get_decode_position()
908 …if(decoder->private_->tell_callback(decoder, position, decoder->private_->client_data) != FLAC__ST… in FLAC__stream_decoder_get_decode_position()
911 if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) in FLAC__stream_decoder_get_decode_position()
913 FLAC__ASSERT(*position >= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder)); in FLAC__stream_decoder_get_decode_position()
914 *position -= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder); in FLAC__stream_decoder_get_decode_position()
918 FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_flush() argument
920 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_flush()
921 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_flush()
922 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_flush()
924 …if(!decoder->private_->internal_reset_hack && decoder->protected_->state == FLAC__STREAM_DECODER_U… in FLAC__stream_decoder_flush()
927 decoder->private_->samples_decoded = 0; in FLAC__stream_decoder_flush()
928 decoder->private_->do_md5_checking = false; in FLAC__stream_decoder_flush()
931 if(decoder->private_->is_ogg) in FLAC__stream_decoder_flush()
932 FLAC__ogg_decoder_aspect_flush(&decoder->protected_->ogg_decoder_aspect); in FLAC__stream_decoder_flush()
935 if(!FLAC__bitreader_clear(decoder->private_->input)) { in FLAC__stream_decoder_flush()
936 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in FLAC__stream_decoder_flush()
939 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in FLAC__stream_decoder_flush()
944 FLAC_API FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_reset() argument
946 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_reset()
947 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_reset()
948 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_reset()
950 if(!FLAC__stream_decoder_flush(decoder)) { in FLAC__stream_decoder_reset()
957 if(decoder->private_->is_ogg) in FLAC__stream_decoder_reset()
958 FLAC__ogg_decoder_aspect_reset(&decoder->protected_->ogg_decoder_aspect); in FLAC__stream_decoder_reset()
966 if(!decoder->private_->internal_reset_hack) { in FLAC__stream_decoder_reset()
967 if(decoder->private_->file == stdin) in FLAC__stream_decoder_reset()
969 …if(decoder->private_->seek_callback && decoder->private_->seek_callback(decoder, 0, decoder->priva… in FLAC__stream_decoder_reset()
973 decoder->private_->internal_reset_hack = false; in FLAC__stream_decoder_reset()
975 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_METADATA; in FLAC__stream_decoder_reset()
977 decoder->private_->has_stream_info = false; in FLAC__stream_decoder_reset()
979 free(decoder->private_->seek_table.data.seek_table.points); in FLAC__stream_decoder_reset()
980 decoder->private_->seek_table.data.seek_table.points = 0; in FLAC__stream_decoder_reset()
981 decoder->private_->has_seek_table = false; in FLAC__stream_decoder_reset()
983 decoder->private_->do_md5_checking = decoder->protected_->md5_checking; in FLAC__stream_decoder_reset()
988 decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size = 0; in FLAC__stream_decoder_reset()
996 FLAC__MD5Init(&decoder->private_->md5context); in FLAC__stream_decoder_reset()
998 decoder->private_->first_frame_offset = 0; in FLAC__stream_decoder_reset()
999 decoder->private_->unparseable_frame_count = 0; in FLAC__stream_decoder_reset()
1004 FLAC_API FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_process_single() argument
1007 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_process_single()
1008 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_process_single()
1011 switch(decoder->protected_->state) { in FLAC__stream_decoder_process_single()
1013 if(!find_metadata_(decoder)) in FLAC__stream_decoder_process_single()
1017 if(!read_metadata_(decoder)) in FLAC__stream_decoder_process_single()
1022 if(!frame_sync_(decoder)) in FLAC__stream_decoder_process_single()
1026 if(!read_frame_(decoder, &got_a_frame, /*do_full_decode=*/true)) in FLAC__stream_decoder_process_single()
1041 FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_metadata(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_process_until_end_of_metadata() argument
1043 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_process_until_end_of_metadata()
1044 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_process_until_end_of_metadata()
1047 switch(decoder->protected_->state) { in FLAC__stream_decoder_process_until_end_of_metadata()
1049 if(!find_metadata_(decoder)) in FLAC__stream_decoder_process_until_end_of_metadata()
1053 if(!read_metadata_(decoder)) in FLAC__stream_decoder_process_until_end_of_metadata()
1068 FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_stream(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_process_until_end_of_stream() argument
1071 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_process_until_end_of_stream()
1072 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_process_until_end_of_stream()
1075 switch(decoder->protected_->state) { in FLAC__stream_decoder_process_until_end_of_stream()
1077 if(!find_metadata_(decoder)) in FLAC__stream_decoder_process_until_end_of_stream()
1081 if(!read_metadata_(decoder)) in FLAC__stream_decoder_process_until_end_of_stream()
1085 if(!frame_sync_(decoder)) in FLAC__stream_decoder_process_until_end_of_stream()
1089 if(!read_frame_(decoder, &dummy, /*do_full_decode=*/true)) in FLAC__stream_decoder_process_until_end_of_stream()
1102 FLAC_API FLAC__bool FLAC__stream_decoder_skip_single_frame(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_skip_single_frame() argument
1105 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_skip_single_frame()
1106 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_skip_single_frame()
1109 switch(decoder->protected_->state) { in FLAC__stream_decoder_skip_single_frame()
1114 if(!frame_sync_(decoder)) in FLAC__stream_decoder_skip_single_frame()
1118 if(!read_frame_(decoder, &got_a_frame, /*do_full_decode=*/false)) in FLAC__stream_decoder_skip_single_frame()
1133 FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *decoder, FLAC__uint64 s… in FLAC__stream_decoder_seek_absolute() argument
1137 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_seek_absolute()
1140 decoder->protected_->state != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA && in FLAC__stream_decoder_seek_absolute()
1141 decoder->protected_->state != FLAC__STREAM_DECODER_READ_METADATA && in FLAC__stream_decoder_seek_absolute()
1142 decoder->protected_->state != FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC && in FLAC__stream_decoder_seek_absolute()
1143 decoder->protected_->state != FLAC__STREAM_DECODER_READ_FRAME && in FLAC__stream_decoder_seek_absolute()
1144 decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM in FLAC__stream_decoder_seek_absolute()
1148 if(0 == decoder->private_->seek_callback) in FLAC__stream_decoder_seek_absolute()
1151 FLAC__ASSERT(decoder->private_->seek_callback); in FLAC__stream_decoder_seek_absolute()
1152 FLAC__ASSERT(decoder->private_->tell_callback); in FLAC__stream_decoder_seek_absolute()
1153 FLAC__ASSERT(decoder->private_->length_callback); in FLAC__stream_decoder_seek_absolute()
1154 FLAC__ASSERT(decoder->private_->eof_callback); in FLAC__stream_decoder_seek_absolute()
1156 …(FLAC__stream_decoder_get_total_samples(decoder) > 0 && sample >= FLAC__stream_decoder_get_total_s… in FLAC__stream_decoder_seek_absolute()
1159 decoder->private_->is_seeking = true; in FLAC__stream_decoder_seek_absolute()
1162 decoder->private_->do_md5_checking = false; in FLAC__stream_decoder_seek_absolute()
1165 …if(decoder->private_->length_callback(decoder, &length, decoder->private_->client_data) != FLAC__S… in FLAC__stream_decoder_seek_absolute()
1166 decoder->private_->is_seeking = false; in FLAC__stream_decoder_seek_absolute()
1172 decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA || in FLAC__stream_decoder_seek_absolute()
1173 decoder->protected_->state == FLAC__STREAM_DECODER_READ_METADATA in FLAC__stream_decoder_seek_absolute()
1175 if(!FLAC__stream_decoder_process_until_end_of_metadata(decoder)) { in FLAC__stream_decoder_seek_absolute()
1177 decoder->private_->is_seeking = false; in FLAC__stream_decoder_seek_absolute()
1181 …(FLAC__stream_decoder_get_total_samples(decoder) > 0 && sample >= FLAC__stream_decoder_get_total_s… in FLAC__stream_decoder_seek_absolute()
1182 decoder->private_->is_seeking = false; in FLAC__stream_decoder_seek_absolute()
1190 decoder->private_->is_ogg? in FLAC__stream_decoder_seek_absolute()
1191 seek_to_absolute_sample_ogg_(decoder, length, sample) : in FLAC__stream_decoder_seek_absolute()
1193 seek_to_absolute_sample_(decoder, length, sample) in FLAC__stream_decoder_seek_absolute()
1195 decoder->private_->is_seeking = false; in FLAC__stream_decoder_seek_absolute()
1206 uint32_t FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_input_bytes_unconsumed() argument
1208 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_input_bytes_unconsumed()
1209 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in FLAC__stream_decoder_get_input_bytes_unconsumed()
1210 FLAC__ASSERT(!(FLAC__bitreader_get_input_bits_unconsumed(decoder->private_->input) & 7)); in FLAC__stream_decoder_get_input_bytes_unconsumed()
1211 return FLAC__bitreader_get_input_bits_unconsumed(decoder->private_->input) / 8; in FLAC__stream_decoder_get_input_bytes_unconsumed()
1220 void set_defaults_(FLAC__StreamDecoder *decoder) in set_defaults_() argument
1222 decoder->private_->is_ogg = false; in set_defaults_()
1223 decoder->private_->read_callback = 0; in set_defaults_()
1224 decoder->private_->seek_callback = 0; in set_defaults_()
1225 decoder->private_->tell_callback = 0; in set_defaults_()
1226 decoder->private_->length_callback = 0; in set_defaults_()
1227 decoder->private_->eof_callback = 0; in set_defaults_()
1228 decoder->private_->write_callback = 0; in set_defaults_()
1229 decoder->private_->metadata_callback = 0; in set_defaults_()
1230 decoder->private_->error_callback = 0; in set_defaults_()
1231 decoder->private_->client_data = 0; in set_defaults_()
1233 memset(decoder->private_->metadata_filter, 0, sizeof(decoder->private_->metadata_filter)); in set_defaults_()
1234 decoder->private_->metadata_filter[FLAC__METADATA_TYPE_STREAMINFO] = true; in set_defaults_()
1235 decoder->private_->metadata_filter_ids_count = 0; in set_defaults_()
1237 decoder->protected_->md5_checking = false; in set_defaults_()
1240 FLAC__ogg_decoder_aspect_set_defaults(&decoder->protected_->ogg_decoder_aspect); in set_defaults_()
1262 FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels) in allocate_output_() argument
1267 if(size <= decoder->private_->output_capacity && channels <= decoder->private_->output_channels) in allocate_output_()
1273 if(0 != decoder->private_->output[i]) { in allocate_output_()
1274 free(decoder->private_->output[i]-4); in allocate_output_()
1275 decoder->private_->output[i] = 0; in allocate_output_()
1277 if(0 != decoder->private_->residual_unaligned[i]) { in allocate_output_()
1278 free(decoder->private_->residual_unaligned[i]); in allocate_output_()
1279 decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; in allocate_output_()
1292 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in allocate_output_()
1296 decoder->private_->output[i] = tmp + 4; in allocate_output_()
1298 …if(!FLAC__memory_alloc_aligned_int32_array(size, &decoder->private_->residual_unaligned[i], &decod… in allocate_output_()
1299 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in allocate_output_()
1304 decoder->private_->output_capacity = size; in allocate_output_()
1305 decoder->private_->output_channels = channels; in allocate_output_()
1310 FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id) in has_id_filtered_() argument
1314 FLAC__ASSERT(0 != decoder); in has_id_filtered_()
1315 FLAC__ASSERT(0 != decoder->private_); in has_id_filtered_()
1317 for(i = 0; i < decoder->private_->metadata_filter_ids_count; i++) in has_id_filtered_()
1318 …if(0 == memcmp(decoder->private_->metadata_filter_ids + i * (FLAC__STREAM_METADATA_APPLICATION_ID_… in has_id_filtered_()
1324 FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder) in find_metadata_() argument
1330 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in find_metadata_()
1333 if(decoder->private_->cached) { in find_metadata_()
1334 x = (FLAC__uint32)decoder->private_->lookahead; in find_metadata_()
1335 decoder->private_->cached = false; in find_metadata_()
1338 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in find_metadata_()
1355 if(!skip_id3v2_tag_(decoder)) in find_metadata_()
1362 decoder->private_->header_warmup[0] = (FLAC__byte)x; in find_metadata_()
1363 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in find_metadata_()
1369 decoder->private_->lookahead = (FLAC__byte)x; in find_metadata_()
1370 decoder->private_->cached = true; in find_metadata_()
1373 decoder->private_->header_warmup[1] = (FLAC__byte)x; in find_metadata_()
1374 decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME; in find_metadata_()
1380 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in find_metadata_()
1385 decoder->protected_->state = FLAC__STREAM_DECODER_READ_METADATA; in find_metadata_()
1389 FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder) in read_metadata_() argument
1394 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_()
1396 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_IS_LAST_LE… in read_metadata_()
1400 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &type, FLAC__STREAM_METADATA_TYPE_LE… in read_metadata_()
1403 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &length, FLAC__STREAM_METADATA_LENGT… in read_metadata_()
1407 if(!read_metadata_streaminfo_(decoder, is_last, length)) in read_metadata_()
1410 decoder->private_->has_stream_info = true; in read_metadata_()
1411 …if(0 == memcmp(decoder->private_->stream_info.data.stream_info.md5sum, "\0\0\0\0\0\0\0\0\0\0\0\0\0… in read_metadata_()
1412 decoder->private_->do_md5_checking = false; in read_metadata_()
1413 …if(!decoder->private_->is_seeking && decoder->private_->metadata_filter[FLAC__METADATA_TYPE_STREAM… in read_metadata_()
1414 …decoder->private_->metadata_callback(decoder, &decoder->private_->stream_info, decoder->private_->… in read_metadata_()
1418 decoder->private_->has_seek_table = false; in read_metadata_()
1420 if(!read_metadata_seektable_(decoder, is_last, length)) in read_metadata_()
1423 decoder->private_->has_seek_table = true; in read_metadata_()
1424 …if(!decoder->private_->is_seeking && decoder->private_->metadata_filter[FLAC__METADATA_TYPE_SEEKTA… in read_metadata_()
1425 …decoder->private_->metadata_callback(decoder, &decoder->private_->seek_table, decoder->private_->c… in read_metadata_()
1428 FLAC__bool skip_it = !decoder->private_->metadata_filter[type]; in read_metadata_()
1438 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.applicatio… in read_metadata_()
1442 …decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;/*@@@@@@ maybe wrong err… in read_metadata_()
1448 …if(decoder->private_->metadata_filter_ids_count > 0 && has_id_filtered_(decoder, block.data.applic… in read_metadata_()
1453 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, real_length)) in read_metadata_()
1461 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, real_length)) in read_metadata_()
1468 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_()
1471 …else if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.appli… in read_metadata_()
1478 if(!read_metadata_vorbiscomment_(decoder, &block.data.vorbis_comment, real_length)) in read_metadata_()
1482 if(!read_metadata_cuesheet_(decoder, &block.data.cue_sheet)) in read_metadata_()
1486 if(!read_metadata_picture_(decoder, &block.data.picture)) in read_metadata_()
1496 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_()
1499 …else if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.unkno… in read_metadata_()
1506 if(ok && !decoder->private_->is_seeking && decoder->private_->metadata_callback) in read_metadata_()
1507 decoder->private_->metadata_callback(decoder, &block, decoder->private_->client_data); in read_metadata_()
1552 …if(!ok) /* anything that unsets "ok" should also make sure decoder->protected_->state is updated */ in read_metadata_()
1559 if(!FLAC__stream_decoder_get_decode_position(decoder, &decoder->private_->first_frame_offset)) in read_metadata_()
1560 decoder->private_->first_frame_offset = 0; in read_metadata_()
1561 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_metadata_()
1567 FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t len… in read_metadata_streaminfo_() argument
1572 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_streaminfo_()
1574 decoder->private_->stream_info.type = FLAC__METADATA_TYPE_STREAMINFO; in read_metadata_streaminfo_()
1575 decoder->private_->stream_info.is_last = is_last; in read_metadata_streaminfo_()
1576 decoder->private_->stream_info.length = length; in read_metadata_streaminfo_()
1579 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, bits)) in read_metadata_streaminfo_()
1581 decoder->private_->stream_info.data.stream_info.min_blocksize = x; in read_metadata_streaminfo_()
1585 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1587 decoder->private_->stream_info.data.stream_info.max_blocksize = x; in read_metadata_streaminfo_()
1591 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1593 decoder->private_->stream_info.data.stream_info.min_framesize = x; in read_metadata_streaminfo_()
1597 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1599 decoder->private_->stream_info.data.stream_info.max_framesize = x; in read_metadata_streaminfo_()
1603 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1605 decoder->private_->stream_info.data.stream_info.sample_rate = x; in read_metadata_streaminfo_()
1609 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1611 decoder->private_->stream_info.data.stream_info.channels = x+1; in read_metadata_streaminfo_()
1615 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1617 decoder->private_->stream_info.data.stream_info.bits_per_sample = x+1; in read_metadata_streaminfo_()
1621 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &decoder->private_->stream_info.data… in read_metadata_streaminfo_()
1625 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, decoder->private_->st… in read_metadata_streaminfo_()
1634 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length)) in read_metadata_streaminfo_()
1640 FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t leng… in read_metadata_seektable_() argument
1645 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_seektable_()
1647 decoder->private_->seek_table.type = FLAC__METADATA_TYPE_SEEKTABLE; in read_metadata_seektable_()
1648 decoder->private_->seek_table.is_last = is_last; in read_metadata_seektable_()
1649 decoder->private_->seek_table.length = length; in read_metadata_seektable_()
1651 …decoder->private_->seek_table.data.seek_table.num_points = length / FLAC__STREAM_METADATA_SEEKPOIN… in read_metadata_seektable_()
1654 …(0 == (decoder->private_->seek_table.data.seek_table.points = safe_realloc_mul_2op_(decoder->priva… in read_metadata_seektable_()
1655 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_seektable_()
1658 for(i = 0; i < decoder->private_->seek_table.data.seek_table.num_points; i++) { in read_metadata_seektable_()
1659 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT… in read_metadata_seektable_()
1661 decoder->private_->seek_table.data.seek_table.points[i].sample_number = xx; in read_metadata_seektable_()
1663 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT… in read_metadata_seektable_()
1665 decoder->private_->seek_table.data.seek_table.points[i].stream_offset = xx; in read_metadata_seektable_()
1667 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_SEEKPOINT_… in read_metadata_seektable_()
1669 decoder->private_->seek_table.data.seek_table.points[i].frame_samples = x; in read_metadata_seektable_()
1671 …length -= (decoder->private_->seek_table.data.seek_table.num_points * FLAC__STREAM_METADATA_SEEKPO… in read_metadata_seektable_()
1675 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length)) in read_metadata_seektable_()
1682 FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisCo… in read_metadata_vorbiscomment_() argument
1686 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_vorbiscomment_()
1692 …if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->vendor_string.lengt… in read_metadata_vorbiscomment_()
1703 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_vorbiscomment_()
1706 …if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->vendor_string.e… in read_metadata_vorbiscomment_()
1715 if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->num_comments)) in read_metadata_vorbiscomment_()
1727 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_vorbiscomment_()
1742 …if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->comments[i].length)… in read_metadata_vorbiscomment_()
1754 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_vorbiscomment_()
1759 …if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->comments[i].ent… in read_metadata_vorbiscomment_()
1781 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length)) in read_metadata_vorbiscomment_()
1788 FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_CueSheet *obj) in read_metadata_cuesheet_() argument
1792 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_cuesheet_()
1797 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)obj->med… in read_metadata_cuesheet_()
1800 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &obj->lead_in, FLAC__STREAM_METADATA… in read_metadata_cuesheet_()
1803 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_I… in read_metadata_cuesheet_()
1807 …if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_RESE… in read_metadata_cuesheet_()
1810 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_N… in read_metadata_cuesheet_()
1816 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_cuesheet_()
1821 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &track->offset, FLAC__STREAM_METADAT… in read_metadata_cuesheet_()
1824 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_T… in read_metadata_cuesheet_()
1829 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)track->i… in read_metadata_cuesheet_()
1832 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_T… in read_metadata_cuesheet_()
1836 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_T… in read_metadata_cuesheet_()
1840 …if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_TRAC… in read_metadata_cuesheet_()
1843 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_T… in read_metadata_cuesheet_()
1849 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_cuesheet_()
1854 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &indx->offset, FLAC__STREAM_METADATA… in read_metadata_cuesheet_()
1857 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_I… in read_metadata_cuesheet_()
1861 …if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_INDE… in read_metadata_cuesheet_()
1871 FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_Picture *obj) in read_metadata_picture_() argument
1875 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_picture_()
1878 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_TY… in read_metadata_picture_()
1883 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_MI… in read_metadata_picture_()
1886 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_picture_()
1890 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)obj->mim… in read_metadata_picture_()
1896 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_DE… in read_metadata_picture_()
1899 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_picture_()
1903 if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->description, x)) in read_metadata_picture_()
1909 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->width, FLAC__STREAM_METADATA_P… in read_metadata_picture_()
1913 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->height, FLAC__STREAM_METADATA_… in read_metadata_picture_()
1917 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->depth, FLAC__STREAM_METADATA_P… in read_metadata_picture_()
1921 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->colors, FLAC__STREAM_METADATA_… in read_metadata_picture_()
1925 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &(obj->data_length), FLAC__STREAM_ME… in read_metadata_picture_()
1928 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_picture_()
1932 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->data, obj->data_… in read_metadata_picture_()
1939 FLAC__bool skip_id3v2_tag_(FLAC__StreamDecoder *decoder) in skip_id3v2_tag_() argument
1945 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 24)) in skip_id3v2_tag_()
1950 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in skip_id3v2_tag_()
1956 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, skip)) in skip_id3v2_tag_()
1961 FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder) in frame_sync_() argument
1968 if(FLAC__stream_decoder_get_total_samples(decoder) > 0) { in frame_sync_()
1969 if(decoder->private_->samples_decoded >= FLAC__stream_decoder_get_total_samples(decoder)) { in frame_sync_()
1970 decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM; in frame_sync_()
1976 if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) { in frame_sync_()
1977 …f(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__bitreader_bits_left_for_byt… in frame_sync_()
1982 if(decoder->private_->cached) { in frame_sync_()
1983 x = (FLAC__uint32)decoder->private_->lookahead; in frame_sync_()
1984 decoder->private_->cached = false; in frame_sync_()
1987 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in frame_sync_()
1991 decoder->private_->header_warmup[0] = (FLAC__byte)x; in frame_sync_()
1992 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in frame_sync_()
1998 decoder->private_->lookahead = (FLAC__byte)x; in frame_sync_()
1999 decoder->private_->cached = true; in frame_sync_()
2002 decoder->private_->header_warmup[1] = (FLAC__byte)x; in frame_sync_()
2003 decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME; in frame_sync_()
2008 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in frame_sync_()
2016 FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_full_de… in read_frame_() argument
2028 frame_crc = FLAC__CRC16_UPDATE(decoder->private_->header_warmup[0], frame_crc); in read_frame_()
2029 frame_crc = FLAC__CRC16_UPDATE(decoder->private_->header_warmup[1], frame_crc); in read_frame_()
2030 FLAC__bitreader_reset_read_crc16(decoder->private_->input, (FLAC__uint16)frame_crc); in read_frame_()
2032 if(!read_frame_header_(decoder)) in read_frame_()
2034 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means we didn't sy… in read_frame_()
2036 …if(!allocate_output_(decoder, decoder->private_->frame.header.blocksize, decoder->private_->frame.… in read_frame_()
2038 for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) { in read_frame_()
2042 uint32_t bps = decoder->private_->frame.header.bits_per_sample; in read_frame_()
2043 switch(decoder->private_->frame.header.channel_assignment) { in read_frame_()
2048 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2053 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2058 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2068 if(!read_subframe_(decoder, channel, bps, do_full_decode)) in read_frame_()
2070 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or … in read_frame_()
2073 if(!read_zero_padding_(decoder)) in read_frame_()
2075 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or … in read_frame_()
2081 frame_crc = FLAC__bitreader_get_read_crc16(decoder->private_->input); in read_frame_()
2082 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__FRAME_FOOTER_CRC_LEN)) in read_frame_()
2087 switch(decoder->private_->frame.header.channel_assignment) { in read_frame_()
2092 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2093 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) in read_frame_()
2094 …decoder->private_->output[1][i] = decoder->private_->output[0][i] - decoder->private_->output[1][i… in read_frame_()
2097 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2098 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) in read_frame_()
2099 decoder->private_->output[0][i] += decoder->private_->output[1][i]; in read_frame_()
2102 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2103 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in read_frame_()
2105 mid = decoder->private_->output[0][i]; in read_frame_()
2106 side = decoder->private_->output[1][i]; in read_frame_()
2109 decoder->private_->output[0][i] = (mid + side) >> 1; in read_frame_()
2110 decoder->private_->output[1][i] = (mid - side) >> 1; in read_frame_()
2113 …mid = (decoder->private_->output[0][i] << 1) | (decoder->private_->output[1][i] & 1); /* i.e. if '… in read_frame_()
2114 decoder->private_->output[0][i] = (mid + decoder->private_->output[1][i]) >> 1; in read_frame_()
2115 decoder->private_->output[1][i] = (mid - decoder->private_->output[1][i]) >> 1; in read_frame_()
2127 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH); in read_frame_()
2129 for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) { in read_frame_()
2130 …memset(decoder->private_->output[channel], 0, sizeof(FLAC__int32) * decoder->private_->frame.heade… in read_frame_()
2138 if(decoder->private_->next_fixed_block_size) in read_frame_()
2139 decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size; in read_frame_()
2141 /* put the latest values into the public section of the decoder instance */ in read_frame_()
2142 decoder->protected_->channels = decoder->private_->frame.header.channels; in read_frame_()
2143 decoder->protected_->channel_assignment = decoder->private_->frame.header.channel_assignment; in read_frame_()
2144 decoder->protected_->bits_per_sample = decoder->private_->frame.header.bits_per_sample; in read_frame_()
2145 decoder->protected_->sample_rate = decoder->private_->frame.header.sample_rate; in read_frame_()
2146 decoder->protected_->blocksize = decoder->private_->frame.header.blocksize; in read_frame_()
2148 FLAC__ASSERT(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); in read_frame_()
2149 …decoder->private_->samples_decoded = decoder->private_->frame.header.number.sample_number + decode… in read_frame_()
2153 …if(write_audio_frame_to_client_(decoder, &decoder->private_->frame, (const FLAC__int32 * const *)d… in read_frame_()
2154 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_frame_()
2159 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_()
2163 FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder) in read_frame_header_() argument
2172 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_frame_header_()
2175 raw_header[0] = decoder->private_->header_warmup[0]; in read_frame_header_()
2176 raw_header[1] = decoder->private_->header_warmup[1]; in read_frame_header_()
2206 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in read_frame_header_()
2210 decoder->private_->lookahead = (FLAC__byte)x; in read_frame_header_()
2211 decoder->private_->cached = true; in read_frame_header_()
2212 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2213 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2224 decoder->private_->frame.header.blocksize = 192; in read_frame_header_()
2230 decoder->private_->frame.header.blocksize = 576 << (x-2); in read_frame_header_()
2244 decoder->private_->frame.header.blocksize = 256 << (x-8); in read_frame_header_()
2253 if(decoder->private_->has_stream_info) in read_frame_header_()
2254 …decoder->private_->frame.header.sample_rate = decoder->private_->stream_info.data.stream_info.samp… in read_frame_header_()
2259 decoder->private_->frame.header.sample_rate = 88200; in read_frame_header_()
2262 decoder->private_->frame.header.sample_rate = 176400; in read_frame_header_()
2265 decoder->private_->frame.header.sample_rate = 192000; in read_frame_header_()
2268 decoder->private_->frame.header.sample_rate = 8000; in read_frame_header_()
2271 decoder->private_->frame.header.sample_rate = 16000; in read_frame_header_()
2274 decoder->private_->frame.header.sample_rate = 22050; in read_frame_header_()
2277 decoder->private_->frame.header.sample_rate = 24000; in read_frame_header_()
2280 decoder->private_->frame.header.sample_rate = 32000; in read_frame_header_()
2283 decoder->private_->frame.header.sample_rate = 44100; in read_frame_header_()
2286 decoder->private_->frame.header.sample_rate = 48000; in read_frame_header_()
2289 decoder->private_->frame.header.sample_rate = 96000; in read_frame_header_()
2297 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2298 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2306 decoder->private_->frame.header.channels = 2; in read_frame_header_()
2309 decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE; in read_frame_header_()
2312 decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE; in read_frame_header_()
2315 decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_MID_SIDE; in read_frame_header_()
2323 decoder->private_->frame.header.channels = (uint32_t)x + 1; in read_frame_header_()
2324 decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT; in read_frame_header_()
2329 if(decoder->private_->has_stream_info) in read_frame_header_()
2330 …decoder->private_->frame.header.bits_per_sample = decoder->private_->stream_info.data.stream_info.… in read_frame_header_()
2335 decoder->private_->frame.header.bits_per_sample = 8; in read_frame_header_()
2338 decoder->private_->frame.header.bits_per_sample = 12; in read_frame_header_()
2341 decoder->private_->frame.header.bits_per_sample = 16; in read_frame_header_()
2344 decoder->private_->frame.header.bits_per_sample = 20; in read_frame_header_()
2347 decoder->private_->frame.header.bits_per_sample = 24; in read_frame_header_()
2366 …(decoder->private_->has_stream_info && decoder->private_->stream_info.data.stream_info.min_blocksi… in read_frame_header_()
2368 if(!FLAC__bitreader_read_utf8_uint64(decoder->private_->input, &xx, raw_header, &raw_header_len)) in read_frame_header_()
2371 decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */ in read_frame_header_()
2372 decoder->private_->cached = true; in read_frame_header_()
2373 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2374 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2377 decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER; in read_frame_header_()
2378 decoder->private_->frame.header.number.sample_number = xx; in read_frame_header_()
2381 if(!FLAC__bitreader_read_utf8_uint32(decoder->private_->input, &x, raw_header, &raw_header_len)) in read_frame_header_()
2384 decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */ in read_frame_header_()
2385 decoder->private_->cached = true; in read_frame_header_()
2386 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2387 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2390 decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER; in read_frame_header_()
2391 decoder->private_->frame.header.number.frame_number = x; in read_frame_header_()
2395 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in read_frame_header_()
2400 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &_x, 8)) in read_frame_header_()
2405 decoder->private_->frame.header.blocksize = x+1; in read_frame_header_()
2409 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in read_frame_header_()
2414 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &_x, 8)) in read_frame_header_()
2420 decoder->private_->frame.header.sample_rate = x*1000; in read_frame_header_()
2422 decoder->private_->frame.header.sample_rate = x; in read_frame_header_()
2424 decoder->private_->frame.header.sample_rate = x*10; in read_frame_header_()
2428 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in read_frame_header_()
2433 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2434 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2439 decoder->private_->next_fixed_block_size = 0; in read_frame_header_()
2440 if(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER) { in read_frame_header_()
2441 x = decoder->private_->frame.header.number.frame_number; in read_frame_header_()
2442 decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER; in read_frame_header_()
2443 if(decoder->private_->fixed_block_size) in read_frame_header_()
2444 …decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->fixed_bloc… in read_frame_header_()
2445 else if(decoder->private_->has_stream_info) { in read_frame_header_()
2446 …if(decoder->private_->stream_info.data.stream_info.min_blocksize == decoder->private_->stream_info… in read_frame_header_()
2447 …decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->stream_inf… in read_frame_header_()
2448 …decoder->private_->next_fixed_block_size = decoder->private_->stream_info.data.stream_info.max_blo… in read_frame_header_()
2454 decoder->private_->frame.header.number.sample_number = 0; in read_frame_header_()
2455 decoder->private_->next_fixed_block_size = decoder->private_->frame.header.blocksize; in read_frame_header_()
2459 …decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->frame.head… in read_frame_header_()
2464 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_frame_header_()
2465 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2472 FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool … in read_subframe_() argument
2478 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) /* MAGIC NUMBER */ in read_subframe_()
2486 if(!FLAC__bitreader_read_unary_unsigned(decoder->private_->input, &u)) in read_subframe_()
2488 decoder->private_->frame.subframes[channel].wasted_bits = u+1; in read_subframe_()
2489 if (decoder->private_->frame.subframes[channel].wasted_bits >= bps) in read_subframe_()
2491 bps -= decoder->private_->frame.subframes[channel].wasted_bits; in read_subframe_()
2494 decoder->private_->frame.subframes[channel].wasted_bits = 0; in read_subframe_()
2500 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_()
2501 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2505 if(!read_subframe_constant_(decoder, channel, bps, do_full_decode)) in read_subframe_()
2509 if(!read_subframe_verbatim_(decoder, channel, bps, do_full_decode)) in read_subframe_()
2513 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_subframe_()
2514 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2518 if(!read_subframe_fixed_(decoder, channel, bps, (x>>1)&7, do_full_decode)) in read_subframe_()
2520 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or … in read_subframe_()
2524 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_subframe_()
2525 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2529 if(!read_subframe_lpc_(decoder, channel, bps, ((x>>1)&31)+1, do_full_decode)) in read_subframe_()
2531 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or … in read_subframe_()
2536 x = decoder->private_->frame.subframes[channel].wasted_bits; in read_subframe_()
2537 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in read_subframe_()
2538 uint32_t val = decoder->private_->output[channel][i]; in read_subframe_()
2539 decoder->private_->output[channel][i] = (val << x); in read_subframe_()
2546 FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FL… in read_subframe_constant_() argument
2548 FLAC__Subframe_Constant *subframe = &decoder->private_->frame.subframes[channel].data.constant; in read_subframe_constant_()
2551 FLAC__int32 *output = decoder->private_->output[channel]; in read_subframe_constant_()
2553 decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_CONSTANT; in read_subframe_constant_()
2555 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &x, bps)) in read_subframe_constant_()
2562 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) in read_subframe_constant_()
2569 FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const… in read_subframe_fixed_() argument
2571 FLAC__Subframe_Fixed *subframe = &decoder->private_->frame.subframes[channel].data.fixed; in read_subframe_fixed_()
2576 decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_FIXED; in read_subframe_fixed_()
2578 subframe->residual = decoder->private_->residual[channel]; in read_subframe_fixed_()
2583 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, bps)) in read_subframe_fixed_()
2589 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TY… in read_subframe_fixed_()
2595 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PA… in read_subframe_fixed_()
2597 if(decoder->private_->frame.header.blocksize >> u32 < order) { in read_subframe_fixed_()
2598 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_fixed_()
2599 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_fixed_()
2603 …subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_r… in read_subframe_fixed_()
2606 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_subframe_fixed_()
2607 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_fixed_()
2615 …rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, &decoder->priva… in read_subframe_fixed_()
2624 memcpy(decoder->private_->output[channel], subframe->warmup, sizeof(FLAC__int32) * order); in read_subframe_fixed_()
2625 …LAC__fixed_restore_signal(decoder->private_->residual[channel], decoder->private_->frame.header.bl… in read_subframe_fixed_()
2631 FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const u… in read_subframe_lpc_() argument
2633 FLAC__Subframe_LPC *subframe = &decoder->private_->frame.subframes[channel].data.lpc; in read_subframe_lpc_()
2638 decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_LPC; in read_subframe_lpc_()
2640 subframe->residual = decoder->private_->residual[channel]; in read_subframe_lpc_()
2645 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, bps)) in read_subframe_lpc_()
2651 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__SUBFRAME_LPC_QLP_COEFF_P… in read_subframe_lpc_()
2654 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_lpc_()
2655 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_lpc_()
2661 …if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, FLAC__SUBFRAME_LPC_QLP_SHIFT_LE… in read_subframe_lpc_()
2664 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_lpc_()
2665 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_lpc_()
2672 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, subframe->qlp_coeff_precision)) in read_subframe_lpc_()
2678 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TY… in read_subframe_lpc_()
2684 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PA… in read_subframe_lpc_()
2686 if(decoder->private_->frame.header.blocksize >> u32 < order) { in read_subframe_lpc_()
2687 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_lpc_()
2688 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_lpc_()
2692 …subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_r… in read_subframe_lpc_()
2695 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_subframe_lpc_()
2696 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_lpc_()
2704 …rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, &decoder->priva… in read_subframe_lpc_()
2713 memcpy(decoder->private_->output[channel], subframe->warmup, sizeof(FLAC__int32) * order); in read_subframe_lpc_()
2716 …decoder->private_->local_lpc_restore_signal_16bit(decoder->private_->residual[channel], decoder->p… in read_subframe_lpc_()
2718 …decoder->private_->local_lpc_restore_signal(decoder->private_->residual[channel], decoder->private… in read_subframe_lpc_()
2720 …decoder->private_->local_lpc_restore_signal_64bit(decoder->private_->residual[channel], decoder->p… in read_subframe_lpc_()
2726 FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FL… in read_subframe_verbatim_() argument
2728 FLAC__Subframe_Verbatim *subframe = &decoder->private_->frame.subframes[channel].data.verbatim; in read_subframe_verbatim_()
2729 FLAC__int32 x, *residual = decoder->private_->residual[channel]; in read_subframe_verbatim_()
2732 decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM; in read_subframe_verbatim_()
2736 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in read_subframe_verbatim_()
2737 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &x, bps)) in read_subframe_verbatim_()
2744 …memcpy(decoder->private_->output[channel], subframe->data, sizeof(FLAC__int32) * decoder->private_… in read_subframe_verbatim_()
2749 FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_t predictor_order, … in read_residual_partitioned_rice_() argument
2755 const uint32_t partition_samples = decoder->private_->frame.header.blocksize >> partition_order; in read_residual_partitioned_rice_()
2760 …FLAC__ASSERT(partition_order > 0? partition_samples >= predictor_order : decoder->private_->frame.… in read_residual_partitioned_rice_()
2763 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_residual_partitioned_rice_()
2769 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &rice_parameter, plen)) in read_residual_partitioned_rice_()
2775 …if(!FLAC__bitreader_read_rice_signed_block(decoder->private_->input, residual + sample, u, rice_pa… in read_residual_partitioned_rice_()
2780 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &rice_parameter, FLAC__ENTROPY_CODIN… in read_residual_partitioned_rice_()
2784 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i, rice_parameter)) in read_residual_partitioned_rice_()
2794 FLAC__bool read_zero_padding_(FLAC__StreamDecoder *decoder) in read_zero_padding_() argument
2796 if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) { in read_zero_padding_()
2798 …(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &zero, FLAC__bitreader_bits_left_for_b… in read_zero_padding_()
2801 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_zero_padding_()
2802 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_zero_padding_()
2810 FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder *)client_data; in read_callback_() local
2815 !decoder->private_->is_ogg && in read_callback_()
2817 …decoder->private_->eof_callback && decoder->private_->eof_callback(decoder, decoder->private_->cli… in read_callback_()
2820 decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM; in read_callback_()
2834 if(decoder->private_->is_seeking && decoder->private_->unparseable_frame_count > 20) { in read_callback_()
2835 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_callback_()
2841 decoder->private_->is_ogg? in read_callback_()
2842 read_callback_ogg_aspect_(decoder, buffer, bytes) : in read_callback_()
2844 decoder->private_->read_callback(decoder, buffer, bytes, decoder->private_->client_data) in read_callback_()
2847 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_callback_()
2856 !decoder->private_->is_ogg && in read_callback_()
2858 …decoder->private_->eof_callback && decoder->private_->eof_callback(decoder, decoder->private_->cli… in read_callback_()
2861 decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM; in read_callback_()
2873 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_callback_()
2877 * for Ogg FLAC. This is because the ogg decoder aspect can lose sync in read_callback_()
2882 * So to keep the decoder from stopping at this point we gate the call in read_callback_()
2883 * to the eof_callback and let the Ogg decoder aspect set the in read_callback_()
2889 FLAC__StreamDecoderReadStatus read_callback_ogg_aspect_(const FLAC__StreamDecoder *decoder, FLAC__b… in read_callback_ogg_aspect_() argument
2891 …spect_read_callback_wrapper(&decoder->protected_->ogg_decoder_aspect, buffer, bytes, read_callback… in read_callback_ogg_aspect_()
2896 * FLAC decoder catch the error in read_callback_ogg_aspect_()
2917 FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder*)void_decoder; in read_callback_proxy_() local
2919 switch(decoder->private_->read_callback(decoder, buffer, bytes, client_data)) { in read_callback_proxy_()
2934 FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder *decoder, const FLA… in write_audio_frame_to_client_() argument
2936 if(decoder->private_->is_seeking) { in write_audio_frame_to_client_()
2939 FLAC__uint64 target_sample = decoder->private_->target_sample; in write_audio_frame_to_client_()
2944 decoder->private_->got_a_frame = true; in write_audio_frame_to_client_()
2946 decoder->private_->last_frame = *frame; /* save the frame */ in write_audio_frame_to_client_()
2950 decoder->private_->is_seeking = false; in write_audio_frame_to_client_()
2957 decoder->private_->last_frame.header.blocksize -= delta; in write_audio_frame_to_client_()
2958 decoder->private_->last_frame.header.number.sample_number += (FLAC__uint64)delta; in write_audio_frame_to_client_()
2960 …return decoder->private_->write_callback(decoder, &decoder->private_->last_frame, newbuffer, decod… in write_audio_frame_to_client_()
2964 … return decoder->private_->write_callback(decoder, frame, buffer, decoder->private_->client_data); in write_audio_frame_to_client_()
2976 if(!decoder->private_->has_stream_info) in write_audio_frame_to_client_()
2977 decoder->private_->do_md5_checking = false; in write_audio_frame_to_client_()
2978 if(decoder->private_->do_md5_checking) { in write_audio_frame_to_client_()
2979 …if(!FLAC__MD5Accumulate(&decoder->private_->md5context, buffer, frame->header.channels, frame->hea… in write_audio_frame_to_client_()
2982 return decoder->private_->write_callback(decoder, frame, buffer, decoder->private_->client_data); in write_audio_frame_to_client_()
2986 void send_error_to_client_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus statu… in send_error_to_client_() argument
2988 if(!decoder->private_->is_seeking) in send_error_to_client_()
2989 decoder->private_->error_callback(decoder, status, decoder->private_->client_data); in send_error_to_client_()
2991 decoder->private_->unparseable_frame_count++; in send_error_to_client_()
2994 FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC_… in seek_to_absolute_sample_() argument
2996 …FLAC__uint64 first_frame_offset = decoder->private_->first_frame_offset, lower_bound, upper_bound,… in seek_to_absolute_sample_()
3001 const FLAC__uint64 total_samples = FLAC__stream_decoder_get_total_samples(decoder); in seek_to_absolute_sample_()
3002 const uint32_t min_blocksize = decoder->private_->stream_info.data.stream_info.min_blocksize; in seek_to_absolute_sample_()
3003 const uint32_t max_blocksize = decoder->private_->stream_info.data.stream_info.max_blocksize; in seek_to_absolute_sample_()
3004 const uint32_t max_framesize = decoder->private_->stream_info.data.stream_info.max_framesize; in seek_to_absolute_sample_()
3005 const uint32_t min_framesize = decoder->private_->stream_info.data.stream_info.min_framesize; in seek_to_absolute_sample_()
3007 uint32_t channels = FLAC__stream_decoder_get_channels(decoder); in seek_to_absolute_sample_()
3008 uint32_t bps = FLAC__stream_decoder_get_bits_per_sample(decoder); in seek_to_absolute_sample_()
3009 …const FLAC__StreamMetadata_SeekTable *seek_table = decoder->private_->has_seek_table? &decoder->pr… in seek_to_absolute_sample_()
3013 channels = decoder->private_->stream_info.data.stream_info.channels; in seek_to_absolute_sample_()
3015 bps = decoder->private_->stream_info.data.stream_info.bits_per_sample; in seek_to_absolute_sample_()
3046 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3115 decoder->private_->target_sample = target_sample; in seek_to_absolute_sample_()
3119 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3138 …if(decoder->private_->seek_callback(decoder, (FLAC__uint64)pos, decoder->private_->client_data) !=… in seek_to_absolute_sample_()
3139 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3142 if(!FLAC__stream_decoder_flush(decoder)) { in seek_to_absolute_sample_()
3152 decoder->private_->unparseable_frame_count = 0; in seek_to_absolute_sample_()
3153 if(!FLAC__stream_decoder_process_single(decoder) || in seek_to_absolute_sample_()
3154 decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED) { in seek_to_absolute_sample_()
3155 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3159 …/* actually, we could have got_a_frame if our decoder is at FLAC__STREAM_DECODER_END_OF_STREAM so … in seek_to_absolute_sample_()
3162 …if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_SEEKING && decoder->protected_->sta… in seek_to_absolute_sample_()
3165 if(!decoder->private_->is_seeking) in seek_to_absolute_sample_()
3168 …FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NU… in seek_to_absolute_sample_()
3169 this_frame_sample = decoder->private_->last_frame.header.number.sample_number; in seek_to_absolute_sample_()
3171 …if (0 == decoder->private_->samples_decoded || (this_frame_sample + decoder->private_->last_frame.… in seek_to_absolute_sample_()
3174 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3186 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3192 upper_bound_sample = this_frame_sample + decoder->private_->last_frame.header.blocksize; in seek_to_absolute_sample_()
3194 if(!FLAC__stream_decoder_get_decode_position(decoder, &upper_bound)) { in seek_to_absolute_sample_()
3195 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3201 lower_bound_sample = this_frame_sample + decoder->private_->last_frame.header.blocksize; in seek_to_absolute_sample_()
3202 if(!FLAC__stream_decoder_get_decode_position(decoder, &lower_bound)) { in seek_to_absolute_sample_()
3203 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3214 FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, F… in seek_to_absolute_sample_ogg_() argument
3217 FLAC__uint64 left_sample = 0, right_sample = FLAC__stream_decoder_get_total_samples(decoder); in seek_to_absolute_sample_ogg_()
3243 decoder->private_->target_sample = target_sample; in seek_to_absolute_sample_ogg_()
3267 …if(decoder->private_->seek_callback((FLAC__StreamDecoder*)decoder, (FLAC__uint64)pos, decoder->pri… in seek_to_absolute_sample_ogg_()
3268 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3271 if(!FLAC__stream_decoder_flush(decoder)) { in seek_to_absolute_sample_ogg_()
3280 decoder->private_->got_a_frame = false; in seek_to_absolute_sample_ogg_()
3281 if(!FLAC__stream_decoder_process_single(decoder) || in seek_to_absolute_sample_ogg_()
3282 decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED) { in seek_to_absolute_sample_ogg_()
3283 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3286 if(!decoder->private_->got_a_frame) { in seek_to_absolute_sample_ogg_()
3299 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3304 else if(!decoder->private_->is_seeking) { in seek_to_absolute_sample_ogg_()
3308 this_frame_sample = decoder->private_->last_frame.header.number.sample_number; in seek_to_absolute_sample_ogg_()
3309 …FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NU… in seek_to_absolute_sample_ogg_()
3324 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3333 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3346 FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte bu… in file_read_callback_() argument
3351 *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, decoder->private_->file); in file_read_callback_()
3352 if(ferror(decoder->private_->file)) in file_read_callback_()
3363 FLAC__StreamDecoderSeekStatus file_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 … in file_seek_callback_() argument
3367 if(decoder->private_->file == stdin) in file_seek_callback_()
3369 else if(fseeko(decoder->private_->file, (FLAC__off_t)absolute_byte_offset, SEEK_SET) < 0) in file_seek_callback_()
3375 FLAC__StreamDecoderTellStatus file_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 … in file_tell_callback_() argument
3380 if(decoder->private_->file == stdin) in file_tell_callback_()
3382 else if((pos = ftello(decoder->private_->file)) < 0) in file_tell_callback_()
3390 FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FLAC__uin… in file_length_callback_() argument
3395 if(decoder->private_->file == stdin) in file_length_callback_()
3397 else if(flac_fstat(fileno(decoder->private_->file), &filestats) != 0) in file_length_callback_()
3405 FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data) in file_eof_callback_() argument
3409 return feof(decoder->private_->file)? true : false; in file_eof_callback_()
3412 FLAC_API const void *FLAC__get_decoder_client_data(FLAC__StreamDecoder *decoder) in FLAC__get_decoder_client_data() argument
3414 return decoder->private_->client_data; in FLAC__get_decoder_client_data()