Lines Matching refs:decoder
76 static void set_defaults_(FLAC__StreamDecoder *decoder);
78 static FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, unsigned size, unsigned 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, unsig…
83 static FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsign…
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, unsigned channel, unsigned bps, FLAC…
92 static FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned …
93 static FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps…
94 static FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, …
95 static FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned …
96 static FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, unsigned 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);
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.ia32.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.ia32.sse2) { in init_stream_internal_()
399 decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_16_intrin_sse2; in init_stream_internal_()
403 if(decoder->private_->cpuinfo.ia32.sse41) { in init_stream_internal_()
404 decoder->private_->local_lpc_restore_signal_64bit = FLAC__lpc_restore_signal_wide_intrin_sse41; in init_stream_internal_()
409 FLAC__ASSERT(decoder->private_->cpuinfo.type == FLAC__CPUINFO_TYPE_X86_64); in init_stream_internal_()
417 if(!FLAC__bitreader_init(decoder->private_->input, read_callback_, decoder)) { in init_stream_internal_()
418 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in init_stream_internal_()
422 decoder->private_->read_callback = read_callback; in init_stream_internal_()
423 decoder->private_->seek_callback = seek_callback; in init_stream_internal_()
424 decoder->private_->tell_callback = tell_callback; in init_stream_internal_()
425 decoder->private_->length_callback = length_callback; in init_stream_internal_()
426 decoder->private_->eof_callback = eof_callback; in init_stream_internal_()
427 decoder->private_->write_callback = write_callback; in init_stream_internal_()
428 decoder->private_->metadata_callback = metadata_callback; in init_stream_internal_()
429 decoder->private_->error_callback = error_callback; in init_stream_internal_()
430 decoder->private_->client_data = client_data; in init_stream_internal_()
431 decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size = 0; in init_stream_internal_()
432 decoder->private_->samples_decoded = 0; in init_stream_internal_()
433 decoder->private_->has_stream_info = false; in init_stream_internal_()
434 decoder->private_->cached = false; in init_stream_internal_()
436 decoder->private_->do_md5_checking = decoder->protected_->md5_checking; in init_stream_internal_()
437 decoder->private_->is_seeking = false; in init_stream_internal_()
439 …decoder->private_->internal_reset_hack = true; /* so the following reset does not try to rewind th… in init_stream_internal_()
440 if(!FLAC__stream_decoder_reset(decoder)) { in init_stream_internal_()
449 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_stream() argument
462 decoder, in FLAC__stream_decoder_init_stream()
477 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_ogg_stream() argument
490 decoder, in FLAC__stream_decoder_init_ogg_stream()
505 FLAC__StreamDecoder *decoder, in init_FILE_internal_() argument
514 FLAC__ASSERT(0 != decoder); in init_FILE_internal_()
517 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in init_FILE_internal_()
518 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED; in init_FILE_internal_()
521 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS; in init_FILE_internal_()
531 decoder->private_->file = file; in init_FILE_internal_()
534 decoder, in init_FILE_internal_()
536 decoder->private_->file == stdin? 0: file_seek_callback_, in init_FILE_internal_()
537 decoder->private_->file == stdin? 0: file_tell_callback_, in init_FILE_internal_()
538 decoder->private_->file == stdin? 0: file_length_callback_, in init_FILE_internal_()
549 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_FILE() argument
557 …return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, clien… in FLAC__stream_decoder_init_FILE()
561 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_ogg_FILE() argument
569 …return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, clien… in FLAC__stream_decoder_init_ogg_FILE()
573 FLAC__StreamDecoder *decoder, in init_file_internal_() argument
584 FLAC__ASSERT(0 != decoder); in init_file_internal_()
591 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in init_file_internal_()
592 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED; in init_file_internal_()
595 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS; in init_file_internal_()
602 …return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, clien… in init_file_internal_()
606 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_file() argument
614 …return init_file_internal_(decoder, filename, write_callback, metadata_callback, error_callback, c… in FLAC__stream_decoder_init_file()
618 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_ogg_file() argument
626 …return init_file_internal_(decoder, filename, write_callback, metadata_callback, error_callback, c… in FLAC__stream_decoder_init_ogg_file()
629 FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_finish() argument
634 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_finish()
635 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_finish()
636 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_finish()
638 if(decoder->protected_->state == FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_finish()
644 FLAC__MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context); in FLAC__stream_decoder_finish()
646 free(decoder->private_->seek_table.data.seek_table.points); in FLAC__stream_decoder_finish()
647 decoder->private_->seek_table.data.seek_table.points = 0; in FLAC__stream_decoder_finish()
648 decoder->private_->has_seek_table = false; in FLAC__stream_decoder_finish()
650 FLAC__bitreader_free(decoder->private_->input); in FLAC__stream_decoder_finish()
658 if(0 != decoder->private_->output[i]) { in FLAC__stream_decoder_finish()
659 free(decoder->private_->output[i]-4); in FLAC__stream_decoder_finish()
660 decoder->private_->output[i] = 0; in FLAC__stream_decoder_finish()
662 if(0 != decoder->private_->residual_unaligned[i]) { in FLAC__stream_decoder_finish()
663 free(decoder->private_->residual_unaligned[i]); in FLAC__stream_decoder_finish()
664 decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; in FLAC__stream_decoder_finish()
667 decoder->private_->output_capacity = 0; in FLAC__stream_decoder_finish()
668 decoder->private_->output_channels = 0; in FLAC__stream_decoder_finish()
671 if(decoder->private_->is_ogg) in FLAC__stream_decoder_finish()
672 FLAC__ogg_decoder_aspect_finish(&decoder->protected_->ogg_decoder_aspect); in FLAC__stream_decoder_finish()
675 if(0 != decoder->private_->file) { in FLAC__stream_decoder_finish()
676 if(decoder->private_->file != stdin) in FLAC__stream_decoder_finish()
677 fclose(decoder->private_->file); in FLAC__stream_decoder_finish()
678 decoder->private_->file = 0; in FLAC__stream_decoder_finish()
681 if(decoder->private_->do_md5_checking) { in FLAC__stream_decoder_finish()
682 …if(memcmp(decoder->private_->stream_info.data.stream_info.md5sum, decoder->private_->computed_md5s… in FLAC__stream_decoder_finish()
685 decoder->private_->is_seeking = false; in FLAC__stream_decoder_finish()
687 set_defaults_(decoder); in FLAC__stream_decoder_finish()
689 decoder->protected_->state = FLAC__STREAM_DECODER_UNINITIALIZED; in FLAC__stream_decoder_finish()
694 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
696 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_ogg_serial_number()
697 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_ogg_serial_number()
698 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_ogg_serial_number()
699 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_ogg_serial_number()
703 FLAC__ogg_decoder_aspect_set_serial_number(&decoder->protected_->ogg_decoder_aspect, value); in FLAC__stream_decoder_set_ogg_serial_number()
711 FLAC_API FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder *decoder, FLAC__bool … in FLAC__stream_decoder_set_md5_checking() argument
713 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_md5_checking()
714 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_md5_checking()
715 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_md5_checking()
717 decoder->protected_->md5_checking = value; in FLAC__stream_decoder_set_md5_checking()
721 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder *decoder, FLAC__M… in FLAC__stream_decoder_set_metadata_respond() argument
723 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_respond()
724 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_respond()
725 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_respond()
730 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_respond()
732 decoder->private_->metadata_filter[type] = true; in FLAC__stream_decoder_set_metadata_respond()
734 decoder->private_->metadata_filter_ids_count = 0; in FLAC__stream_decoder_set_metadata_respond()
738 …AC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte… in FLAC__stream_decoder_set_metadata_respond_application() argument
740 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_respond_application()
741 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_respond_application()
742 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_respond_application()
744 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_respond_application()
747 if(decoder->private_->metadata_filter[FLAC__METADATA_TYPE_APPLICATION]) in FLAC__stream_decoder_set_metadata_respond_application()
750 FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids); in FLAC__stream_decoder_set_metadata_respond_application()
752 …if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity… in FLAC__stream_decoder_set_metadata_respond_application()
753 …if(0 == (decoder->private_->metadata_filter_ids = safe_realloc_mul_2op_(decoder->private_->metadat… in FLAC__stream_decoder_set_metadata_respond_application()
754 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in FLAC__stream_decoder_set_metadata_respond_application()
757 decoder->private_->metadata_filter_ids_capacity *= 2; in FLAC__stream_decoder_set_metadata_respond_application()
760 …memcpy(decoder->private_->metadata_filter_ids + decoder->private_->metadata_filter_ids_count * (FL… in FLAC__stream_decoder_set_metadata_respond_application()
761 decoder->private_->metadata_filter_ids_count++; in FLAC__stream_decoder_set_metadata_respond_application()
766 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_set_metadata_respond_all() argument
769 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_respond_all()
770 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_respond_all()
771 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_respond_all()
772 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_respond_all()
774 …for(i = 0; i < sizeof(decoder->private_->metadata_filter) / sizeof(decoder->private_->metadata_fil… in FLAC__stream_decoder_set_metadata_respond_all()
775 decoder->private_->metadata_filter[i] = true; in FLAC__stream_decoder_set_metadata_respond_all()
776 decoder->private_->metadata_filter_ids_count = 0; in FLAC__stream_decoder_set_metadata_respond_all()
780 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder *decoder, FLAC__Me… in FLAC__stream_decoder_set_metadata_ignore() argument
782 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_ignore()
783 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_ignore()
784 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_ignore()
789 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_ignore()
791 decoder->private_->metadata_filter[type] = false; in FLAC__stream_decoder_set_metadata_ignore()
793 decoder->private_->metadata_filter_ids_count = 0; in FLAC__stream_decoder_set_metadata_ignore()
797 …LAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder *decoder, const FLAC__byte… in FLAC__stream_decoder_set_metadata_ignore_application() argument
799 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_ignore_application()
800 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_ignore_application()
801 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_ignore_application()
803 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_ignore_application()
806 if(!decoder->private_->metadata_filter[FLAC__METADATA_TYPE_APPLICATION]) in FLAC__stream_decoder_set_metadata_ignore_application()
809 FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids); in FLAC__stream_decoder_set_metadata_ignore_application()
811 …if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity… in FLAC__stream_decoder_set_metadata_ignore_application()
812 …if(0 == (decoder->private_->metadata_filter_ids = safe_realloc_mul_2op_(decoder->private_->metadat… in FLAC__stream_decoder_set_metadata_ignore_application()
813 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in FLAC__stream_decoder_set_metadata_ignore_application()
816 decoder->private_->metadata_filter_ids_capacity *= 2; in FLAC__stream_decoder_set_metadata_ignore_application()
819 …memcpy(decoder->private_->metadata_filter_ids + decoder->private_->metadata_filter_ids_count * (FL… in FLAC__stream_decoder_set_metadata_ignore_application()
820 decoder->private_->metadata_filter_ids_count++; in FLAC__stream_decoder_set_metadata_ignore_application()
825 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_set_metadata_ignore_all() argument
827 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_ignore_all()
828 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_ignore_all()
829 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_ignore_all()
830 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_ignore_all()
832 memset(decoder->private_->metadata_filter, 0, sizeof(decoder->private_->metadata_filter)); in FLAC__stream_decoder_set_metadata_ignore_all()
833 decoder->private_->metadata_filter_ids_count = 0; in FLAC__stream_decoder_set_metadata_ignore_all()
837 FLAC_API FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_state() argument
839 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_state()
840 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_state()
841 return decoder->protected_->state; in FLAC__stream_decoder_get_state()
844 …_API const char *FLAC__stream_decoder_get_resolved_state_string(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_resolved_state_string() argument
846 return FLAC__StreamDecoderStateString[decoder->protected_->state]; in FLAC__stream_decoder_get_resolved_state_string()
849 FLAC_API FLAC__bool FLAC__stream_decoder_get_md5_checking(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_md5_checking() argument
851 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_md5_checking()
852 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_md5_checking()
853 return decoder->protected_->md5_checking; in FLAC__stream_decoder_get_md5_checking()
856 FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_total_samples() argument
858 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_total_samples()
859 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_total_samples()
860 …return decoder->private_->has_stream_info? decoder->private_->stream_info.data.stream_info.total_s… in FLAC__stream_decoder_get_total_samples()
863 FLAC_API unsigned FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_channels() argument
865 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_channels()
866 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_channels()
867 return decoder->protected_->channels; in FLAC__stream_decoder_get_channels()
870 …__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_channel_assignment() argument
872 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_channel_assignment()
873 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_channel_assignment()
874 return decoder->protected_->channel_assignment; in FLAC__stream_decoder_get_channel_assignment()
877 FLAC_API unsigned FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_bits_per_sample() argument
879 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_bits_per_sample()
880 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_bits_per_sample()
881 return decoder->protected_->bits_per_sample; in FLAC__stream_decoder_get_bits_per_sample()
884 FLAC_API unsigned FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_sample_rate() argument
886 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_sample_rate()
887 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_sample_rate()
888 return decoder->protected_->sample_rate; in FLAC__stream_decoder_get_sample_rate()
891 FLAC_API unsigned FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_blocksize() argument
893 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_blocksize()
894 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_blocksize()
895 return decoder->protected_->blocksize; in FLAC__stream_decoder_get_blocksize()
898 FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder *decoder, FL… in FLAC__stream_decoder_get_decode_position() argument
900 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_decode_position()
901 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_get_decode_position()
904 if(FLAC__HAS_OGG && decoder->private_->is_ogg) in FLAC__stream_decoder_get_decode_position()
907 if(0 == decoder->private_->tell_callback) in FLAC__stream_decoder_get_decode_position()
909 …if(decoder->private_->tell_callback(decoder, position, decoder->private_->client_data) != FLAC__ST… in FLAC__stream_decoder_get_decode_position()
912 if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) in FLAC__stream_decoder_get_decode_position()
914 FLAC__ASSERT(*position >= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder)); in FLAC__stream_decoder_get_decode_position()
915 *position -= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder); in FLAC__stream_decoder_get_decode_position()
919 FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_flush() argument
921 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_flush()
922 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_flush()
923 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_flush()
925 …if(!decoder->private_->internal_reset_hack && decoder->protected_->state == FLAC__STREAM_DECODER_U… in FLAC__stream_decoder_flush()
928 decoder->private_->samples_decoded = 0; in FLAC__stream_decoder_flush()
929 decoder->private_->do_md5_checking = false; in FLAC__stream_decoder_flush()
932 if(decoder->private_->is_ogg) in FLAC__stream_decoder_flush()
933 FLAC__ogg_decoder_aspect_flush(&decoder->protected_->ogg_decoder_aspect); in FLAC__stream_decoder_flush()
936 if(!FLAC__bitreader_clear(decoder->private_->input)) { in FLAC__stream_decoder_flush()
937 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in FLAC__stream_decoder_flush()
940 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in FLAC__stream_decoder_flush()
945 FLAC_API FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_reset() argument
947 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_reset()
948 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_reset()
949 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_reset()
951 if(!FLAC__stream_decoder_flush(decoder)) { in FLAC__stream_decoder_reset()
958 if(decoder->private_->is_ogg) in FLAC__stream_decoder_reset()
959 FLAC__ogg_decoder_aspect_reset(&decoder->protected_->ogg_decoder_aspect); in FLAC__stream_decoder_reset()
967 if(!decoder->private_->internal_reset_hack) { in FLAC__stream_decoder_reset()
968 if(decoder->private_->file == stdin) in FLAC__stream_decoder_reset()
970 …if(decoder->private_->seek_callback && decoder->private_->seek_callback(decoder, 0, decoder->priva… in FLAC__stream_decoder_reset()
974 decoder->private_->internal_reset_hack = false; in FLAC__stream_decoder_reset()
976 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_METADATA; in FLAC__stream_decoder_reset()
978 decoder->private_->has_stream_info = false; in FLAC__stream_decoder_reset()
980 free(decoder->private_->seek_table.data.seek_table.points); in FLAC__stream_decoder_reset()
981 decoder->private_->seek_table.data.seek_table.points = 0; in FLAC__stream_decoder_reset()
982 decoder->private_->has_seek_table = false; in FLAC__stream_decoder_reset()
984 decoder->private_->do_md5_checking = decoder->protected_->md5_checking; in FLAC__stream_decoder_reset()
989 decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size = 0; in FLAC__stream_decoder_reset()
997 FLAC__MD5Init(&decoder->private_->md5context); in FLAC__stream_decoder_reset()
999 decoder->private_->first_frame_offset = 0; in FLAC__stream_decoder_reset()
1000 decoder->private_->unparseable_frame_count = 0; in FLAC__stream_decoder_reset()
1005 FLAC_API FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_process_single() argument
1008 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_process_single()
1009 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_process_single()
1012 switch(decoder->protected_->state) { in FLAC__stream_decoder_process_single()
1014 if(!find_metadata_(decoder)) in FLAC__stream_decoder_process_single()
1018 if(!read_metadata_(decoder)) in FLAC__stream_decoder_process_single()
1023 if(!frame_sync_(decoder)) in FLAC__stream_decoder_process_single()
1027 if(!read_frame_(decoder, &got_a_frame, /*do_full_decode=*/true)) in FLAC__stream_decoder_process_single()
1042 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
1044 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_process_until_end_of_metadata()
1045 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_process_until_end_of_metadata()
1048 switch(decoder->protected_->state) { in FLAC__stream_decoder_process_until_end_of_metadata()
1050 if(!find_metadata_(decoder)) in FLAC__stream_decoder_process_until_end_of_metadata()
1054 if(!read_metadata_(decoder)) in FLAC__stream_decoder_process_until_end_of_metadata()
1069 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
1072 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_process_until_end_of_stream()
1073 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_process_until_end_of_stream()
1076 switch(decoder->protected_->state) { in FLAC__stream_decoder_process_until_end_of_stream()
1078 if(!find_metadata_(decoder)) in FLAC__stream_decoder_process_until_end_of_stream()
1082 if(!read_metadata_(decoder)) in FLAC__stream_decoder_process_until_end_of_stream()
1086 if(!frame_sync_(decoder)) in FLAC__stream_decoder_process_until_end_of_stream()
1090 if(!read_frame_(decoder, &dummy, /*do_full_decode=*/true)) in FLAC__stream_decoder_process_until_end_of_stream()
1103 FLAC_API FLAC__bool FLAC__stream_decoder_skip_single_frame(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_skip_single_frame() argument
1106 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_skip_single_frame()
1107 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_skip_single_frame()
1110 switch(decoder->protected_->state) { in FLAC__stream_decoder_skip_single_frame()
1115 if(!frame_sync_(decoder)) in FLAC__stream_decoder_skip_single_frame()
1119 if(!read_frame_(decoder, &got_a_frame, /*do_full_decode=*/false)) in FLAC__stream_decoder_skip_single_frame()
1134 FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *decoder, FLAC__uint64 s… in FLAC__stream_decoder_seek_absolute() argument
1138 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_seek_absolute()
1141 decoder->protected_->state != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA && in FLAC__stream_decoder_seek_absolute()
1142 decoder->protected_->state != FLAC__STREAM_DECODER_READ_METADATA && in FLAC__stream_decoder_seek_absolute()
1143 decoder->protected_->state != FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC && in FLAC__stream_decoder_seek_absolute()
1144 decoder->protected_->state != FLAC__STREAM_DECODER_READ_FRAME && in FLAC__stream_decoder_seek_absolute()
1145 decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM in FLAC__stream_decoder_seek_absolute()
1149 if(0 == decoder->private_->seek_callback) in FLAC__stream_decoder_seek_absolute()
1152 FLAC__ASSERT(decoder->private_->seek_callback); in FLAC__stream_decoder_seek_absolute()
1153 FLAC__ASSERT(decoder->private_->tell_callback); in FLAC__stream_decoder_seek_absolute()
1154 FLAC__ASSERT(decoder->private_->length_callback); in FLAC__stream_decoder_seek_absolute()
1155 FLAC__ASSERT(decoder->private_->eof_callback); in FLAC__stream_decoder_seek_absolute()
1157 …(FLAC__stream_decoder_get_total_samples(decoder) > 0 && sample >= FLAC__stream_decoder_get_total_s… in FLAC__stream_decoder_seek_absolute()
1160 decoder->private_->is_seeking = true; in FLAC__stream_decoder_seek_absolute()
1163 decoder->private_->do_md5_checking = false; in FLAC__stream_decoder_seek_absolute()
1166 …if(decoder->private_->length_callback(decoder, &length, decoder->private_->client_data) != FLAC__S… in FLAC__stream_decoder_seek_absolute()
1167 decoder->private_->is_seeking = false; in FLAC__stream_decoder_seek_absolute()
1173 decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA || in FLAC__stream_decoder_seek_absolute()
1174 decoder->protected_->state == FLAC__STREAM_DECODER_READ_METADATA in FLAC__stream_decoder_seek_absolute()
1176 if(!FLAC__stream_decoder_process_until_end_of_metadata(decoder)) { in FLAC__stream_decoder_seek_absolute()
1178 decoder->private_->is_seeking = false; in FLAC__stream_decoder_seek_absolute()
1182 …(FLAC__stream_decoder_get_total_samples(decoder) > 0 && sample >= FLAC__stream_decoder_get_total_s… in FLAC__stream_decoder_seek_absolute()
1183 decoder->private_->is_seeking = false; in FLAC__stream_decoder_seek_absolute()
1191 decoder->private_->is_ogg? in FLAC__stream_decoder_seek_absolute()
1192 seek_to_absolute_sample_ogg_(decoder, length, sample) : in FLAC__stream_decoder_seek_absolute()
1194 seek_to_absolute_sample_(decoder, length, sample) in FLAC__stream_decoder_seek_absolute()
1196 decoder->private_->is_seeking = false; in FLAC__stream_decoder_seek_absolute()
1207 unsigned FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_input_bytes_unconsumed() argument
1209 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_input_bytes_unconsumed()
1210 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in FLAC__stream_decoder_get_input_bytes_unconsumed()
1211 FLAC__ASSERT(!(FLAC__bitreader_get_input_bits_unconsumed(decoder->private_->input) & 7)); in FLAC__stream_decoder_get_input_bytes_unconsumed()
1212 return FLAC__bitreader_get_input_bits_unconsumed(decoder->private_->input) / 8; in FLAC__stream_decoder_get_input_bytes_unconsumed()
1221 void set_defaults_(FLAC__StreamDecoder *decoder) in set_defaults_() argument
1223 decoder->private_->is_ogg = false; in set_defaults_()
1224 decoder->private_->read_callback = 0; in set_defaults_()
1225 decoder->private_->seek_callback = 0; in set_defaults_()
1226 decoder->private_->tell_callback = 0; in set_defaults_()
1227 decoder->private_->length_callback = 0; in set_defaults_()
1228 decoder->private_->eof_callback = 0; in set_defaults_()
1229 decoder->private_->write_callback = 0; in set_defaults_()
1230 decoder->private_->metadata_callback = 0; in set_defaults_()
1231 decoder->private_->error_callback = 0; in set_defaults_()
1232 decoder->private_->client_data = 0; in set_defaults_()
1234 memset(decoder->private_->metadata_filter, 0, sizeof(decoder->private_->metadata_filter)); in set_defaults_()
1235 decoder->private_->metadata_filter[FLAC__METADATA_TYPE_STREAMINFO] = true; in set_defaults_()
1236 decoder->private_->metadata_filter_ids_count = 0; in set_defaults_()
1238 decoder->protected_->md5_checking = false; in set_defaults_()
1241 FLAC__ogg_decoder_aspect_set_defaults(&decoder->protected_->ogg_decoder_aspect); in set_defaults_()
1266 FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, unsigned size, unsigned channels) in allocate_output_() argument
1271 if(size <= decoder->private_->output_capacity && channels <= decoder->private_->output_channels) in allocate_output_()
1277 if(0 != decoder->private_->output[i]) { in allocate_output_()
1278 free(decoder->private_->output[i]-4); in allocate_output_()
1279 decoder->private_->output[i] = 0; in allocate_output_()
1281 if(0 != decoder->private_->residual_unaligned[i]) { in allocate_output_()
1282 free(decoder->private_->residual_unaligned[i]); in allocate_output_()
1283 decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; in allocate_output_()
1296 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in allocate_output_()
1300 decoder->private_->output[i] = tmp + 4; in allocate_output_()
1302 …if(!FLAC__memory_alloc_aligned_int32_array(size, &decoder->private_->residual_unaligned[i], &decod… in allocate_output_()
1303 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in allocate_output_()
1308 decoder->private_->output_capacity = size; in allocate_output_()
1309 decoder->private_->output_channels = channels; in allocate_output_()
1314 FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id) in has_id_filtered_() argument
1318 FLAC__ASSERT(0 != decoder); in has_id_filtered_()
1319 FLAC__ASSERT(0 != decoder->private_); in has_id_filtered_()
1321 for(i = 0; i < decoder->private_->metadata_filter_ids_count; i++) in has_id_filtered_()
1322 …if(0 == memcmp(decoder->private_->metadata_filter_ids + i * (FLAC__STREAM_METADATA_APPLICATION_ID_… in has_id_filtered_()
1328 FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder) in find_metadata_() argument
1334 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in find_metadata_()
1337 if(decoder->private_->cached) { in find_metadata_()
1338 x = (FLAC__uint32)decoder->private_->lookahead; in find_metadata_()
1339 decoder->private_->cached = false; in find_metadata_()
1342 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in find_metadata_()
1359 if(!skip_id3v2_tag_(decoder)) in find_metadata_()
1366 decoder->private_->header_warmup[0] = (FLAC__byte)x; in find_metadata_()
1367 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in find_metadata_()
1373 decoder->private_->lookahead = (FLAC__byte)x; in find_metadata_()
1374 decoder->private_->cached = true; in find_metadata_()
1377 decoder->private_->header_warmup[1] = (FLAC__byte)x; in find_metadata_()
1378 decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME; in find_metadata_()
1384 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in find_metadata_()
1389 decoder->protected_->state = FLAC__STREAM_DECODER_READ_METADATA; in find_metadata_()
1393 FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder) in read_metadata_() argument
1398 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_()
1400 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_IS_LAST_LE… in read_metadata_()
1404 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &type, FLAC__STREAM_METADATA_TYPE_LE… in read_metadata_()
1407 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &length, FLAC__STREAM_METADATA_LENGT… in read_metadata_()
1411 if(!read_metadata_streaminfo_(decoder, is_last, length)) in read_metadata_()
1414 decoder->private_->has_stream_info = true; in read_metadata_()
1415 …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_()
1416 decoder->private_->do_md5_checking = false; in read_metadata_()
1417 …if(!decoder->private_->is_seeking && decoder->private_->metadata_filter[FLAC__METADATA_TYPE_STREAM… in read_metadata_()
1418 …decoder->private_->metadata_callback(decoder, &decoder->private_->stream_info, decoder->private_->… in read_metadata_()
1422 decoder->private_->has_seek_table = false; in read_metadata_()
1424 if(!read_metadata_seektable_(decoder, is_last, length)) in read_metadata_()
1427 decoder->private_->has_seek_table = true; in read_metadata_()
1428 …if(!decoder->private_->is_seeking && decoder->private_->metadata_filter[FLAC__METADATA_TYPE_SEEKTA… in read_metadata_()
1429 …decoder->private_->metadata_callback(decoder, &decoder->private_->seek_table, decoder->private_->c… in read_metadata_()
1432 FLAC__bool skip_it = !decoder->private_->metadata_filter[type]; in read_metadata_()
1442 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.applicatio… in read_metadata_()
1446 …decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;/*@@@@@@ maybe wrong err… in read_metadata_()
1452 …if(decoder->private_->metadata_filter_ids_count > 0 && has_id_filtered_(decoder, block.data.applic… in read_metadata_()
1457 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, real_length)) in read_metadata_()
1465 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, real_length)) in read_metadata_()
1472 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_()
1475 …else if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.appli… in read_metadata_()
1482 if(!read_metadata_vorbiscomment_(decoder, &block.data.vorbis_comment, real_length)) in read_metadata_()
1486 if(!read_metadata_cuesheet_(decoder, &block.data.cue_sheet)) in read_metadata_()
1490 if(!read_metadata_picture_(decoder, &block.data.picture)) in read_metadata_()
1500 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_()
1503 …else if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.unkno… in read_metadata_()
1510 if(ok && !decoder->private_->is_seeking && decoder->private_->metadata_callback) in read_metadata_()
1511 decoder->private_->metadata_callback(decoder, &block, decoder->private_->client_data); in read_metadata_()
1563 if(!FLAC__stream_decoder_get_decode_position(decoder, &decoder->private_->first_frame_offset)) in read_metadata_()
1564 decoder->private_->first_frame_offset = 0; in read_metadata_()
1565 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_metadata_()
1571 FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsigned len… in read_metadata_streaminfo_() argument
1576 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_streaminfo_()
1578 decoder->private_->stream_info.type = FLAC__METADATA_TYPE_STREAMINFO; in read_metadata_streaminfo_()
1579 decoder->private_->stream_info.is_last = is_last; in read_metadata_streaminfo_()
1580 decoder->private_->stream_info.length = length; in read_metadata_streaminfo_()
1583 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, bits)) in read_metadata_streaminfo_()
1585 decoder->private_->stream_info.data.stream_info.min_blocksize = x; in read_metadata_streaminfo_()
1589 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1591 decoder->private_->stream_info.data.stream_info.max_blocksize = x; in read_metadata_streaminfo_()
1595 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1597 decoder->private_->stream_info.data.stream_info.min_framesize = x; in read_metadata_streaminfo_()
1601 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1603 decoder->private_->stream_info.data.stream_info.max_framesize = x; in read_metadata_streaminfo_()
1607 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1609 decoder->private_->stream_info.data.stream_info.sample_rate = x; in read_metadata_streaminfo_()
1613 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1615 decoder->private_->stream_info.data.stream_info.channels = x+1; in read_metadata_streaminfo_()
1619 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1621 decoder->private_->stream_info.data.stream_info.bits_per_sample = x+1; in read_metadata_streaminfo_()
1625 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &decoder->private_->stream_info.data… in read_metadata_streaminfo_()
1629 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, decoder->private_->st… in read_metadata_streaminfo_()
1636 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length)) in read_metadata_streaminfo_()
1642 FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsigned leng… in read_metadata_seektable_() argument
1647 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_seektable_()
1649 decoder->private_->seek_table.type = FLAC__METADATA_TYPE_SEEKTABLE; in read_metadata_seektable_()
1650 decoder->private_->seek_table.is_last = is_last; in read_metadata_seektable_()
1651 decoder->private_->seek_table.length = length; in read_metadata_seektable_()
1653 …decoder->private_->seek_table.data.seek_table.num_points = length / FLAC__STREAM_METADATA_SEEKPOIN… in read_metadata_seektable_()
1656 …(0 == (decoder->private_->seek_table.data.seek_table.points = safe_realloc_mul_2op_(decoder->priva… in read_metadata_seektable_()
1657 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_seektable_()
1660 for(i = 0; i < decoder->private_->seek_table.data.seek_table.num_points; i++) { in read_metadata_seektable_()
1661 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT… in read_metadata_seektable_()
1663 decoder->private_->seek_table.data.seek_table.points[i].sample_number = xx; in read_metadata_seektable_()
1665 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT… in read_metadata_seektable_()
1667 decoder->private_->seek_table.data.seek_table.points[i].stream_offset = xx; in read_metadata_seektable_()
1669 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_SEEKPOINT_… in read_metadata_seektable_()
1671 decoder->private_->seek_table.data.seek_table.points[i].frame_samples = x; in read_metadata_seektable_()
1673 …length -= (decoder->private_->seek_table.data.seek_table.num_points * FLAC__STREAM_METADATA_SEEKPO… in read_metadata_seektable_()
1677 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length)) in read_metadata_seektable_()
1684 FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisCo… in read_metadata_vorbiscomment_() argument
1688 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_vorbiscomment_()
1694 …if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->vendor_string.lengt… in read_metadata_vorbiscomment_()
1705 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_vorbiscomment_()
1708 …if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->vendor_string.e… in read_metadata_vorbiscomment_()
1717 if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->num_comments)) in read_metadata_vorbiscomment_()
1729 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_vorbiscomment_()
1744 …if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->comments[i].length)… in read_metadata_vorbiscomment_()
1756 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_vorbiscomment_()
1761 …if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->comments[i].ent… in read_metadata_vorbiscomment_()
1780 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length)) in read_metadata_vorbiscomment_()
1787 FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_CueSheet *obj) in read_metadata_cuesheet_() argument
1791 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_cuesheet_()
1796 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)obj->med… in read_metadata_cuesheet_()
1799 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &obj->lead_in, FLAC__STREAM_METADATA… in read_metadata_cuesheet_()
1802 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_I… in read_metadata_cuesheet_()
1806 …if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_RESE… in read_metadata_cuesheet_()
1809 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_N… in read_metadata_cuesheet_()
1815 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_cuesheet_()
1820 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &track->offset, FLAC__STREAM_METADAT… in read_metadata_cuesheet_()
1823 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_T… in read_metadata_cuesheet_()
1828 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)track->i… in read_metadata_cuesheet_()
1831 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_T… in read_metadata_cuesheet_()
1835 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_T… in read_metadata_cuesheet_()
1839 …if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_TRAC… in read_metadata_cuesheet_()
1842 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_T… in read_metadata_cuesheet_()
1848 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_cuesheet_()
1853 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &indx->offset, FLAC__STREAM_METADATA… in read_metadata_cuesheet_()
1856 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_I… in read_metadata_cuesheet_()
1860 …if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_INDE… in read_metadata_cuesheet_()
1870 FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_Picture *obj) in read_metadata_picture_() argument
1874 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_picture_()
1877 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_TY… in read_metadata_picture_()
1882 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_MI… in read_metadata_picture_()
1885 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_picture_()
1889 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)obj->mim… in read_metadata_picture_()
1895 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_DE… in read_metadata_picture_()
1898 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_picture_()
1902 if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->description, x)) in read_metadata_picture_()
1908 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->width, FLAC__STREAM_METADATA_P… in read_metadata_picture_()
1912 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->height, FLAC__STREAM_METADATA_… in read_metadata_picture_()
1916 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->depth, FLAC__STREAM_METADATA_P… in read_metadata_picture_()
1920 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->colors, FLAC__STREAM_METADATA_… in read_metadata_picture_()
1924 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &(obj->data_length), FLAC__STREAM_ME… in read_metadata_picture_()
1927 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_picture_()
1931 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->data, obj->data_… in read_metadata_picture_()
1938 FLAC__bool skip_id3v2_tag_(FLAC__StreamDecoder *decoder) in skip_id3v2_tag_() argument
1944 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 24)) in skip_id3v2_tag_()
1949 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in skip_id3v2_tag_()
1955 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, skip)) in skip_id3v2_tag_()
1960 FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder) in frame_sync_() argument
1967 if(FLAC__stream_decoder_get_total_samples(decoder) > 0) { in frame_sync_()
1968 if(decoder->private_->samples_decoded >= FLAC__stream_decoder_get_total_samples(decoder)) { in frame_sync_()
1969 decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM; in frame_sync_()
1975 if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) { in frame_sync_()
1976 …f(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__bitreader_bits_left_for_byt… in frame_sync_()
1981 if(decoder->private_->cached) { in frame_sync_()
1982 x = (FLAC__uint32)decoder->private_->lookahead; in frame_sync_()
1983 decoder->private_->cached = false; in frame_sync_()
1986 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in frame_sync_()
1990 decoder->private_->header_warmup[0] = (FLAC__byte)x; in frame_sync_()
1991 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in frame_sync_()
1997 decoder->private_->lookahead = (FLAC__byte)x; in frame_sync_()
1998 decoder->private_->cached = true; in frame_sync_()
2001 decoder->private_->header_warmup[1] = (FLAC__byte)x; in frame_sync_()
2002 decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME; in frame_sync_()
2007 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in frame_sync_()
2015 FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_full_de… in read_frame_() argument
2027 frame_crc = FLAC__CRC16_UPDATE(decoder->private_->header_warmup[0], frame_crc); in read_frame_()
2028 frame_crc = FLAC__CRC16_UPDATE(decoder->private_->header_warmup[1], frame_crc); in read_frame_()
2029 FLAC__bitreader_reset_read_crc16(decoder->private_->input, (FLAC__uint16)frame_crc); in read_frame_()
2031 if(!read_frame_header_(decoder)) in read_frame_()
2033 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means we didn't sy… in read_frame_()
2035 …if(!allocate_output_(decoder, decoder->private_->frame.header.blocksize, decoder->private_->frame.… in read_frame_()
2037 for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) { in read_frame_()
2041 unsigned bps = decoder->private_->frame.header.bits_per_sample; in read_frame_()
2042 switch(decoder->private_->frame.header.channel_assignment) { in read_frame_()
2047 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2052 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2057 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2067 if(!read_subframe_(decoder, channel, bps, do_full_decode)) in read_frame_()
2069 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or … in read_frame_()
2072 if(!read_zero_padding_(decoder)) in read_frame_()
2074 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or … in read_frame_()
2080 frame_crc = FLAC__bitreader_get_read_crc16(decoder->private_->input); in read_frame_()
2081 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__FRAME_FOOTER_CRC_LEN)) in read_frame_()
2086 switch(decoder->private_->frame.header.channel_assignment) { in read_frame_()
2091 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2092 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) in read_frame_()
2093 …decoder->private_->output[1][i] = decoder->private_->output[0][i] - decoder->private_->output[1][i… in read_frame_()
2096 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2097 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) in read_frame_()
2098 decoder->private_->output[0][i] += decoder->private_->output[1][i]; in read_frame_()
2101 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2102 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in read_frame_()
2104 mid = decoder->private_->output[0][i]; in read_frame_()
2105 side = decoder->private_->output[1][i]; in read_frame_()
2108 decoder->private_->output[0][i] = (mid + side) >> 1; in read_frame_()
2109 decoder->private_->output[1][i] = (mid - side) >> 1; in read_frame_()
2112 …mid = (decoder->private_->output[0][i] << 1) | (decoder->private_->output[1][i] & 1); /* i.e. if '… in read_frame_()
2113 decoder->private_->output[0][i] = (mid + decoder->private_->output[1][i]) >> 1; in read_frame_()
2114 decoder->private_->output[1][i] = (mid - decoder->private_->output[1][i]) >> 1; in read_frame_()
2126 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH); in read_frame_()
2128 for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) { in read_frame_()
2129 …memset(decoder->private_->output[channel], 0, sizeof(FLAC__int32) * decoder->private_->frame.heade… in read_frame_()
2137 if(decoder->private_->next_fixed_block_size) in read_frame_()
2138 decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size; in read_frame_()
2141 decoder->protected_->channels = decoder->private_->frame.header.channels; in read_frame_()
2142 decoder->protected_->channel_assignment = decoder->private_->frame.header.channel_assignment; in read_frame_()
2143 decoder->protected_->bits_per_sample = decoder->private_->frame.header.bits_per_sample; in read_frame_()
2144 decoder->protected_->sample_rate = decoder->private_->frame.header.sample_rate; in read_frame_()
2145 decoder->protected_->blocksize = decoder->private_->frame.header.blocksize; in read_frame_()
2147 FLAC__ASSERT(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); in read_frame_()
2148 …decoder->private_->samples_decoded = decoder->private_->frame.header.number.sample_number + decode… in read_frame_()
2152 …if(write_audio_frame_to_client_(decoder, &decoder->private_->frame, (const FLAC__int32 * const *)d… in read_frame_()
2153 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_frame_()
2158 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_()
2162 FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder) in read_frame_header_() argument
2171 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_frame_header_()
2174 raw_header[0] = decoder->private_->header_warmup[0]; in read_frame_header_()
2175 raw_header[1] = decoder->private_->header_warmup[1]; in read_frame_header_()
2205 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in read_frame_header_()
2209 decoder->private_->lookahead = (FLAC__byte)x; in read_frame_header_()
2210 decoder->private_->cached = true; in read_frame_header_()
2211 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2212 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2223 decoder->private_->frame.header.blocksize = 192; in read_frame_header_()
2229 decoder->private_->frame.header.blocksize = 576 << (x-2); in read_frame_header_()
2243 decoder->private_->frame.header.blocksize = 256 << (x-8); in read_frame_header_()
2252 if(decoder->private_->has_stream_info) in read_frame_header_()
2253 …decoder->private_->frame.header.sample_rate = decoder->private_->stream_info.data.stream_info.samp… in read_frame_header_()
2258 decoder->private_->frame.header.sample_rate = 88200; in read_frame_header_()
2261 decoder->private_->frame.header.sample_rate = 176400; in read_frame_header_()
2264 decoder->private_->frame.header.sample_rate = 192000; in read_frame_header_()
2267 decoder->private_->frame.header.sample_rate = 8000; in read_frame_header_()
2270 decoder->private_->frame.header.sample_rate = 16000; in read_frame_header_()
2273 decoder->private_->frame.header.sample_rate = 22050; in read_frame_header_()
2276 decoder->private_->frame.header.sample_rate = 24000; in read_frame_header_()
2279 decoder->private_->frame.header.sample_rate = 32000; in read_frame_header_()
2282 decoder->private_->frame.header.sample_rate = 44100; in read_frame_header_()
2285 decoder->private_->frame.header.sample_rate = 48000; in read_frame_header_()
2288 decoder->private_->frame.header.sample_rate = 96000; in read_frame_header_()
2296 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2297 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2305 decoder->private_->frame.header.channels = 2; in read_frame_header_()
2308 decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE; in read_frame_header_()
2311 decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE; in read_frame_header_()
2314 decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_MID_SIDE; in read_frame_header_()
2322 decoder->private_->frame.header.channels = (unsigned)x + 1; in read_frame_header_()
2323 decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT; in read_frame_header_()
2328 if(decoder->private_->has_stream_info) in read_frame_header_()
2329 …decoder->private_->frame.header.bits_per_sample = decoder->private_->stream_info.data.stream_info.… in read_frame_header_()
2334 decoder->private_->frame.header.bits_per_sample = 8; in read_frame_header_()
2337 decoder->private_->frame.header.bits_per_sample = 12; in read_frame_header_()
2340 decoder->private_->frame.header.bits_per_sample = 16; in read_frame_header_()
2343 decoder->private_->frame.header.bits_per_sample = 20; in read_frame_header_()
2346 decoder->private_->frame.header.bits_per_sample = 24; in read_frame_header_()
2365 …(decoder->private_->has_stream_info && decoder->private_->stream_info.data.stream_info.min_blocksi… in read_frame_header_()
2367 if(!FLAC__bitreader_read_utf8_uint64(decoder->private_->input, &xx, raw_header, &raw_header_len)) in read_frame_header_()
2370 decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */ in read_frame_header_()
2371 decoder->private_->cached = true; in read_frame_header_()
2372 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2373 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2376 decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER; in read_frame_header_()
2377 decoder->private_->frame.header.number.sample_number = xx; in read_frame_header_()
2380 if(!FLAC__bitreader_read_utf8_uint32(decoder->private_->input, &x, raw_header, &raw_header_len)) in read_frame_header_()
2383 decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */ in read_frame_header_()
2384 decoder->private_->cached = true; in read_frame_header_()
2385 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2386 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2389 decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER; in read_frame_header_()
2390 decoder->private_->frame.header.number.frame_number = x; in read_frame_header_()
2394 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in read_frame_header_()
2399 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &_x, 8)) in read_frame_header_()
2404 decoder->private_->frame.header.blocksize = x+1; in read_frame_header_()
2408 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in read_frame_header_()
2413 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &_x, 8)) in read_frame_header_()
2419 decoder->private_->frame.header.sample_rate = x*1000; in read_frame_header_()
2421 decoder->private_->frame.header.sample_rate = x; in read_frame_header_()
2423 decoder->private_->frame.header.sample_rate = x*10; in read_frame_header_()
2427 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in read_frame_header_()
2432 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2433 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2438 decoder->private_->next_fixed_block_size = 0; in read_frame_header_()
2439 if(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER) { in read_frame_header_()
2440 x = decoder->private_->frame.header.number.frame_number; in read_frame_header_()
2441 decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER; in read_frame_header_()
2442 if(decoder->private_->fixed_block_size) in read_frame_header_()
2443 …decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->fixed_bloc… in read_frame_header_()
2444 else if(decoder->private_->has_stream_info) { in read_frame_header_()
2445 …if(decoder->private_->stream_info.data.stream_info.min_blocksize == decoder->private_->stream_info… in read_frame_header_()
2446 …decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->stream_inf… in read_frame_header_()
2447 …decoder->private_->next_fixed_block_size = decoder->private_->stream_info.data.stream_info.max_blo… in read_frame_header_()
2453 decoder->private_->frame.header.number.sample_number = 0; in read_frame_header_()
2454 decoder->private_->next_fixed_block_size = decoder->private_->frame.header.blocksize; in read_frame_header_()
2458 …decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->frame.head… in read_frame_header_()
2463 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_frame_header_()
2464 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2471 FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool … in read_subframe_() argument
2477 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) /* MAGIC NUMBER */ in read_subframe_()
2485 if(!FLAC__bitreader_read_unary_unsigned(decoder->private_->input, &u)) in read_subframe_()
2487 decoder->private_->frame.subframes[channel].wasted_bits = u+1; in read_subframe_()
2488 if (decoder->private_->frame.subframes[channel].wasted_bits >= bps) in read_subframe_()
2490 bps -= decoder->private_->frame.subframes[channel].wasted_bits; in read_subframe_()
2493 decoder->private_->frame.subframes[channel].wasted_bits = 0; in read_subframe_()
2499 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_()
2500 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2504 if(!read_subframe_constant_(decoder, channel, bps, do_full_decode)) in read_subframe_()
2508 if(!read_subframe_verbatim_(decoder, channel, bps, do_full_decode)) in read_subframe_()
2512 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_subframe_()
2513 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2517 if(!read_subframe_fixed_(decoder, channel, bps, (x>>1)&7, do_full_decode)) in read_subframe_()
2519 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or … in read_subframe_()
2523 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_subframe_()
2524 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2528 if(!read_subframe_lpc_(decoder, channel, bps, ((x>>1)&31)+1, do_full_decode)) in read_subframe_()
2530 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or … in read_subframe_()
2535 x = decoder->private_->frame.subframes[channel].wasted_bits; in read_subframe_()
2536 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in read_subframe_()
2537 uint32_t val = decoder->private_->output[channel][i]; in read_subframe_()
2538 decoder->private_->output[channel][i] = (val << x); in read_subframe_()
2545 FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FL… in read_subframe_constant_() argument
2547 FLAC__Subframe_Constant *subframe = &decoder->private_->frame.subframes[channel].data.constant; in read_subframe_constant_()
2550 FLAC__int32 *output = decoder->private_->output[channel]; in read_subframe_constant_()
2552 decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_CONSTANT; in read_subframe_constant_()
2554 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &x, bps)) in read_subframe_constant_()
2561 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) in read_subframe_constant_()
2568 FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const… in read_subframe_fixed_() argument
2570 FLAC__Subframe_Fixed *subframe = &decoder->private_->frame.subframes[channel].data.fixed; in read_subframe_fixed_()
2575 decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_FIXED; in read_subframe_fixed_()
2577 subframe->residual = decoder->private_->residual[channel]; in read_subframe_fixed_()
2582 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, bps)) in read_subframe_fixed_()
2588 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TY… in read_subframe_fixed_()
2594 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PA… in read_subframe_fixed_()
2596 if(decoder->private_->frame.header.blocksize >> u32 < order) { in read_subframe_fixed_()
2597 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_fixed_()
2598 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_fixed_()
2602 …subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_r… in read_subframe_fixed_()
2605 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_subframe_fixed_()
2606 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_fixed_()
2614 …rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, &decoder->priva… in read_subframe_fixed_()
2623 memcpy(decoder->private_->output[channel], subframe->warmup, sizeof(FLAC__int32) * order); in read_subframe_fixed_()
2624 …LAC__fixed_restore_signal(decoder->private_->residual[channel], decoder->private_->frame.header.bl… in read_subframe_fixed_()
2630 FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const u… in read_subframe_lpc_() argument
2632 FLAC__Subframe_LPC *subframe = &decoder->private_->frame.subframes[channel].data.lpc; in read_subframe_lpc_()
2637 decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_LPC; in read_subframe_lpc_()
2639 subframe->residual = decoder->private_->residual[channel]; in read_subframe_lpc_()
2644 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, bps)) in read_subframe_lpc_()
2650 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__SUBFRAME_LPC_QLP_COEFF_P… in read_subframe_lpc_()
2653 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_lpc_()
2654 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_lpc_()
2660 …if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, FLAC__SUBFRAME_LPC_QLP_SHIFT_LE… in read_subframe_lpc_()
2663 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_lpc_()
2664 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_lpc_()
2671 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, subframe->qlp_coeff_precision)) in read_subframe_lpc_()
2677 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TY… in read_subframe_lpc_()
2683 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PA… in read_subframe_lpc_()
2685 if(decoder->private_->frame.header.blocksize >> u32 < order) { in read_subframe_lpc_()
2686 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_lpc_()
2687 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_lpc_()
2691 …subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_r… in read_subframe_lpc_()
2694 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_subframe_lpc_()
2695 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_lpc_()
2703 …rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, &decoder->priva… in read_subframe_lpc_()
2712 memcpy(decoder->private_->output[channel], subframe->warmup, sizeof(FLAC__int32) * order); in read_subframe_lpc_()
2715 …decoder->private_->local_lpc_restore_signal_16bit(decoder->private_->residual[channel], decoder->p… in read_subframe_lpc_()
2717 …decoder->private_->local_lpc_restore_signal(decoder->private_->residual[channel], decoder->private… in read_subframe_lpc_()
2719 …decoder->private_->local_lpc_restore_signal_64bit(decoder->private_->residual[channel], decoder->p… in read_subframe_lpc_()
2725 FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FL… in read_subframe_verbatim_() argument
2727 FLAC__Subframe_Verbatim *subframe = &decoder->private_->frame.subframes[channel].data.verbatim; in read_subframe_verbatim_()
2728 FLAC__int32 x, *residual = decoder->private_->residual[channel]; in read_subframe_verbatim_()
2731 decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM; in read_subframe_verbatim_()
2735 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in read_subframe_verbatim_()
2736 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &x, bps)) in read_subframe_verbatim_()
2743 …memcpy(decoder->private_->output[channel], subframe->data, sizeof(FLAC__int32) * decoder->private_… in read_subframe_verbatim_()
2748 FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, unsigned predictor_order, … in read_residual_partitioned_rice_() argument
2754 …partition_samples = partition_order > 0? decoder->private_->frame.header.blocksize >> partition_or… in read_residual_partitioned_rice_()
2759 …FLAC__ASSERT(partition_order > 0? partition_samples >= predictor_order : decoder->private_->frame.… in read_residual_partitioned_rice_()
2762 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_residual_partitioned_rice_()
2768 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &rice_parameter, plen)) in read_residual_partitioned_rice_()
2774 …if(!FLAC__bitreader_read_rice_signed_block(decoder->private_->input, residual + sample, u, rice_pa… in read_residual_partitioned_rice_()
2779 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &rice_parameter, FLAC__ENTROPY_CODIN… in read_residual_partitioned_rice_()
2783 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i, rice_parameter)) in read_residual_partitioned_rice_()
2793 FLAC__bool read_zero_padding_(FLAC__StreamDecoder *decoder) in read_zero_padding_() argument
2795 if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) { in read_zero_padding_()
2797 …(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &zero, FLAC__bitreader_bits_left_for_b… in read_zero_padding_()
2800 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_zero_padding_()
2801 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_zero_padding_()
2809 FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder *)client_data; in read_callback_() local
2814 !decoder->private_->is_ogg && in read_callback_()
2816 …decoder->private_->eof_callback && decoder->private_->eof_callback(decoder, decoder->private_->cli… in read_callback_()
2819 decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM; in read_callback_()
2833 if(decoder->private_->is_seeking && decoder->private_->unparseable_frame_count > 20) { in read_callback_()
2834 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_callback_()
2840 decoder->private_->is_ogg? in read_callback_()
2841 read_callback_ogg_aspect_(decoder, buffer, bytes) : in read_callback_()
2843 decoder->private_->read_callback(decoder, buffer, bytes, decoder->private_->client_data) in read_callback_()
2846 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_callback_()
2855 !decoder->private_->is_ogg && in read_callback_()
2857 …decoder->private_->eof_callback && decoder->private_->eof_callback(decoder, decoder->private_->cli… in read_callback_()
2860 decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM; in read_callback_()
2872 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_callback_()
2888 FLAC__StreamDecoderReadStatus read_callback_ogg_aspect_(const FLAC__StreamDecoder *decoder, FLAC__b… in read_callback_ogg_aspect_() argument
2890 …spect_read_callback_wrapper(&decoder->protected_->ogg_decoder_aspect, buffer, bytes, read_callback… in read_callback_ogg_aspect_()
2916 FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder*)void_decoder; in read_callback_proxy_() local
2918 switch(decoder->private_->read_callback(decoder, buffer, bytes, client_data)) { in read_callback_proxy_()
2933 FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder *decoder, const FLA… in write_audio_frame_to_client_() argument
2935 if(decoder->private_->is_seeking) { in write_audio_frame_to_client_()
2938 FLAC__uint64 target_sample = decoder->private_->target_sample; in write_audio_frame_to_client_()
2943 decoder->private_->got_a_frame = true; in write_audio_frame_to_client_()
2945 decoder->private_->last_frame = *frame; /* save the frame */ in write_audio_frame_to_client_()
2949 decoder->private_->is_seeking = false; in write_audio_frame_to_client_()
2956 decoder->private_->last_frame.header.blocksize -= delta; in write_audio_frame_to_client_()
2957 decoder->private_->last_frame.header.number.sample_number += (FLAC__uint64)delta; in write_audio_frame_to_client_()
2959 …return decoder->private_->write_callback(decoder, &decoder->private_->last_frame, newbuffer, decod… in write_audio_frame_to_client_()
2963 … return decoder->private_->write_callback(decoder, frame, buffer, decoder->private_->client_data); in write_audio_frame_to_client_()
2975 if(!decoder->private_->has_stream_info) in write_audio_frame_to_client_()
2976 decoder->private_->do_md5_checking = false; in write_audio_frame_to_client_()
2977 if(decoder->private_->do_md5_checking) { in write_audio_frame_to_client_()
2978 …if(!FLAC__MD5Accumulate(&decoder->private_->md5context, buffer, frame->header.channels, frame->hea… in write_audio_frame_to_client_()
2981 return decoder->private_->write_callback(decoder, frame, buffer, decoder->private_->client_data); in write_audio_frame_to_client_()
2985 void send_error_to_client_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus statu… in send_error_to_client_() argument
2987 if(!decoder->private_->is_seeking) in send_error_to_client_()
2988 decoder->private_->error_callback(decoder, status, decoder->private_->client_data); in send_error_to_client_()
2990 decoder->private_->unparseable_frame_count++; in send_error_to_client_()
2993 FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC_… in seek_to_absolute_sample_() argument
2995 …FLAC__uint64 first_frame_offset = decoder->private_->first_frame_offset, lower_bound, upper_bound,… in seek_to_absolute_sample_()
3000 const FLAC__uint64 total_samples = FLAC__stream_decoder_get_total_samples(decoder); in seek_to_absolute_sample_()
3001 const unsigned min_blocksize = decoder->private_->stream_info.data.stream_info.min_blocksize; in seek_to_absolute_sample_()
3002 const unsigned max_blocksize = decoder->private_->stream_info.data.stream_info.max_blocksize; in seek_to_absolute_sample_()
3003 const unsigned max_framesize = decoder->private_->stream_info.data.stream_info.max_framesize; in seek_to_absolute_sample_()
3004 const unsigned min_framesize = decoder->private_->stream_info.data.stream_info.min_framesize; in seek_to_absolute_sample_()
3006 unsigned channels = FLAC__stream_decoder_get_channels(decoder); in seek_to_absolute_sample_()
3007 unsigned bps = FLAC__stream_decoder_get_bits_per_sample(decoder); in seek_to_absolute_sample_()
3008 …const FLAC__StreamMetadata_SeekTable *seek_table = decoder->private_->has_seek_table? &decoder->pr… in seek_to_absolute_sample_()
3012 channels = decoder->private_->stream_info.data.stream_info.channels; in seek_to_absolute_sample_()
3014 bps = decoder->private_->stream_info.data.stream_info.bits_per_sample; in seek_to_absolute_sample_()
3108 decoder->private_->target_sample = target_sample; in seek_to_absolute_sample_()
3112 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3128 …if(decoder->private_->seek_callback(decoder, (FLAC__uint64)pos, decoder->private_->client_data) !=… in seek_to_absolute_sample_()
3129 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3132 if(!FLAC__stream_decoder_flush(decoder)) { in seek_to_absolute_sample_()
3142 decoder->private_->unparseable_frame_count = 0; in seek_to_absolute_sample_()
3143 if(!FLAC__stream_decoder_process_single(decoder) || in seek_to_absolute_sample_()
3144 decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED) { in seek_to_absolute_sample_()
3145 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3152 …if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_SEEKING && decoder->protected_->sta… in seek_to_absolute_sample_()
3155 if(!decoder->private_->is_seeking) in seek_to_absolute_sample_()
3158 …FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NU… in seek_to_absolute_sample_()
3159 this_frame_sample = decoder->private_->last_frame.header.number.sample_number; in seek_to_absolute_sample_()
3161 …if (0 == decoder->private_->samples_decoded || (this_frame_sample + decoder->private_->last_frame.… in seek_to_absolute_sample_()
3164 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3176 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3182 upper_bound_sample = this_frame_sample + decoder->private_->last_frame.header.blocksize; in seek_to_absolute_sample_()
3184 if(!FLAC__stream_decoder_get_decode_position(decoder, &upper_bound)) { in seek_to_absolute_sample_()
3185 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3191 lower_bound_sample = this_frame_sample + decoder->private_->last_frame.header.blocksize; in seek_to_absolute_sample_()
3192 if(!FLAC__stream_decoder_get_decode_position(decoder, &lower_bound)) { in seek_to_absolute_sample_()
3193 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3204 FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, F… in seek_to_absolute_sample_ogg_() argument
3207 FLAC__uint64 left_sample = 0, right_sample = FLAC__stream_decoder_get_total_samples(decoder); in seek_to_absolute_sample_ogg_()
3233 decoder->private_->target_sample = target_sample; in seek_to_absolute_sample_ogg_()
3257 …if(decoder->private_->seek_callback((FLAC__StreamDecoder*)decoder, (FLAC__uint64)pos, decoder->pri… in seek_to_absolute_sample_ogg_()
3258 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3261 if(!FLAC__stream_decoder_flush(decoder)) { in seek_to_absolute_sample_ogg_()
3270 decoder->private_->got_a_frame = false; in seek_to_absolute_sample_ogg_()
3271 if(!FLAC__stream_decoder_process_single(decoder) || in seek_to_absolute_sample_ogg_()
3272 decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED) { in seek_to_absolute_sample_ogg_()
3273 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3276 if(!decoder->private_->got_a_frame) { in seek_to_absolute_sample_ogg_()
3289 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3294 else if(!decoder->private_->is_seeking) { in seek_to_absolute_sample_ogg_()
3298 this_frame_sample = decoder->private_->last_frame.header.number.sample_number; in seek_to_absolute_sample_ogg_()
3299 …FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NU… in seek_to_absolute_sample_ogg_()
3314 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3323 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3336 FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte bu… in file_read_callback_() argument
3341 *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, decoder->private_->file); in file_read_callback_()
3342 if(ferror(decoder->private_->file)) in file_read_callback_()
3353 FLAC__StreamDecoderSeekStatus file_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 … in file_seek_callback_() argument
3357 if(decoder->private_->file == stdin) in file_seek_callback_()
3359 else if(fseeko(decoder->private_->file, (FLAC__off_t)absolute_byte_offset, SEEK_SET) < 0) in file_seek_callback_()
3365 FLAC__StreamDecoderTellStatus file_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 … in file_tell_callback_() argument
3370 if(decoder->private_->file == stdin) in file_tell_callback_()
3372 else if((pos = ftello(decoder->private_->file)) < 0) in file_tell_callback_()
3380 FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FLAC__uin… in file_length_callback_() argument
3385 if(decoder->private_->file == stdin) in file_length_callback_()
3387 else if(flac_fstat(fileno(decoder->private_->file), &filestats) != 0) in file_length_callback_()
3395 FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data) in file_eof_callback_() argument
3399 return feof(decoder->private_->file)? true : false; in file_eof_callback_()