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);
98 static void undo_channel_coding(FLAC__StreamDecoder *decoder);
101 static FLAC__StreamDecoderReadStatus read_callback_ogg_aspect_(const FLAC__StreamDecoder *decoder, …
104 static FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder *decoder, co…
105 static void send_error_to_client_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatu…
106 static FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length…
108 static FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_le…
110 static FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__…
111 static FLAC__StreamDecoderSeekStatus file_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__…
112 static FLAC__StreamDecoderTellStatus file_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__…
113 static FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FL…
114 static FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data);
157 …eset_hack; /* used only during init() so we can call reset to set up the decoder without rewinding…
244 FLAC__StreamDecoder *decoder; in FLAC__stream_decoder_new() local
249 decoder = calloc(1, sizeof(FLAC__StreamDecoder)); in FLAC__stream_decoder_new()
250 if(decoder == 0) { in FLAC__stream_decoder_new()
254 decoder->protected_ = calloc(1, sizeof(FLAC__StreamDecoderProtected)); in FLAC__stream_decoder_new()
255 if(decoder->protected_ == 0) { in FLAC__stream_decoder_new()
256 free(decoder); in FLAC__stream_decoder_new()
260 decoder->private_ = calloc(1, sizeof(FLAC__StreamDecoderPrivate)); in FLAC__stream_decoder_new()
261 if(decoder->private_ == 0) { in FLAC__stream_decoder_new()
262 free(decoder->protected_); in FLAC__stream_decoder_new()
263 free(decoder); in FLAC__stream_decoder_new()
267 decoder->private_->input = FLAC__bitreader_new(); in FLAC__stream_decoder_new()
268 if(decoder->private_->input == 0) { in FLAC__stream_decoder_new()
269 free(decoder->private_); in FLAC__stream_decoder_new()
270 free(decoder->protected_); in FLAC__stream_decoder_new()
271 free(decoder); in FLAC__stream_decoder_new()
275 decoder->private_->metadata_filter_ids_capacity = 16; in FLAC__stream_decoder_new()
276 …if(0 == (decoder->private_->metadata_filter_ids = malloc((FLAC__STREAM_METADATA_APPLICATION_ID_LEN… in FLAC__stream_decoder_new()
277 FLAC__bitreader_delete(decoder->private_->input); in FLAC__stream_decoder_new()
278 free(decoder->private_); in FLAC__stream_decoder_new()
279 free(decoder->protected_); in FLAC__stream_decoder_new()
280 free(decoder); in FLAC__stream_decoder_new()
285 decoder->private_->output[i] = 0; in FLAC__stream_decoder_new()
286 decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; in FLAC__stream_decoder_new()
289 decoder->private_->side_subframe = 0; in FLAC__stream_decoder_new()
291 decoder->private_->output_capacity = 0; in FLAC__stream_decoder_new()
292 decoder->private_->output_channels = 0; in FLAC__stream_decoder_new()
293 decoder->private_->has_seek_table = false; in FLAC__stream_decoder_new()
296 …FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&decoder->private_->partitioned_… in FLAC__stream_decoder_new()
298 decoder->private_->file = 0; in FLAC__stream_decoder_new()
300 set_defaults_(decoder); in FLAC__stream_decoder_new()
302 decoder->protected_->state = FLAC__STREAM_DECODER_UNINITIALIZED; in FLAC__stream_decoder_new()
304 return decoder; in FLAC__stream_decoder_new()
307 FLAC_API void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_delete() argument
311 if (decoder == NULL) in FLAC__stream_decoder_delete()
314 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_delete()
315 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_delete()
316 FLAC__ASSERT(0 != decoder->private_->input); in FLAC__stream_decoder_delete()
318 (void)FLAC__stream_decoder_finish(decoder); in FLAC__stream_decoder_delete()
320 if(0 != decoder->private_->metadata_filter_ids) in FLAC__stream_decoder_delete()
321 free(decoder->private_->metadata_filter_ids); in FLAC__stream_decoder_delete()
323 FLAC__bitreader_delete(decoder->private_->input); in FLAC__stream_decoder_delete()
326 …FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(&decoder->private_->partitioned… in FLAC__stream_decoder_delete()
328 free(decoder->private_); in FLAC__stream_decoder_delete()
329 free(decoder->protected_); in FLAC__stream_decoder_delete()
330 free(decoder); in FLAC__stream_decoder_delete()
340 FLAC__StreamDecoder *decoder, in init_stream_internal_() argument
353 FLAC__ASSERT(0 != decoder); in init_stream_internal_()
355 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in init_stream_internal_()
370 decoder->private_->is_ogg = is_ogg; in init_stream_internal_()
371 if(is_ogg && !FLAC__ogg_decoder_aspect_init(&decoder->protected_->ogg_decoder_aspect)) in init_stream_internal_()
372 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_()
376 decoder->private_->local_bitreader_read_rice_signed_block = FLAC__bitreader_read_rice_signed_block; in init_stream_internal_()
379 if (decoder->private_->cpuinfo.x86.bmi2) { in init_stream_internal_()
380 …decoder->private_->local_bitreader_read_rice_signed_block = FLAC__bitreader_read_rice_signed_block… in init_stream_internal_()
386 if(!FLAC__bitreader_init(decoder->private_->input, read_callback_, decoder)) { in init_stream_internal_()
387 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in init_stream_internal_()
391 decoder->private_->read_callback = read_callback; in init_stream_internal_()
392 decoder->private_->seek_callback = seek_callback; in init_stream_internal_()
393 decoder->private_->tell_callback = tell_callback; in init_stream_internal_()
394 decoder->private_->length_callback = length_callback; in init_stream_internal_()
395 decoder->private_->eof_callback = eof_callback; in init_stream_internal_()
396 decoder->private_->write_callback = write_callback; in init_stream_internal_()
397 decoder->private_->metadata_callback = metadata_callback; in init_stream_internal_()
398 decoder->private_->error_callback = error_callback; in init_stream_internal_()
399 decoder->private_->client_data = client_data; in init_stream_internal_()
400 decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size = 0; in init_stream_internal_()
401 decoder->private_->samples_decoded = 0; in init_stream_internal_()
402 decoder->private_->has_stream_info = false; in init_stream_internal_()
403 decoder->private_->cached = false; in init_stream_internal_()
405 decoder->private_->do_md5_checking = decoder->protected_->md5_checking; in init_stream_internal_()
406 decoder->private_->is_seeking = false; in init_stream_internal_()
408 …decoder->private_->internal_reset_hack = true; /* so the following reset does not try to rewind th… in init_stream_internal_()
409 if(!FLAC__stream_decoder_reset(decoder)) { in init_stream_internal_()
418 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_stream() argument
431 decoder, in FLAC__stream_decoder_init_stream()
446 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_ogg_stream() argument
459 decoder, in FLAC__stream_decoder_init_ogg_stream()
474 FLAC__StreamDecoder *decoder, in init_FILE_internal_() argument
483 FLAC__ASSERT(0 != decoder); in init_FILE_internal_()
486 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in init_FILE_internal_()
487 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED; in init_FILE_internal_()
490 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS; in init_FILE_internal_()
500 decoder->private_->file = file; in init_FILE_internal_()
503 decoder, in init_FILE_internal_()
505 decoder->private_->file == stdin? 0: file_seek_callback_, in init_FILE_internal_()
506 decoder->private_->file == stdin? 0: file_tell_callback_, in init_FILE_internal_()
507 decoder->private_->file == stdin? 0: file_length_callback_, in init_FILE_internal_()
518 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_FILE() argument
526 …return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, clien… in FLAC__stream_decoder_init_FILE()
530 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_ogg_FILE() argument
538 …return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, clien… in FLAC__stream_decoder_init_ogg_FILE()
542 FLAC__StreamDecoder *decoder, in init_file_internal_() argument
553 FLAC__ASSERT(0 != decoder); in init_file_internal_()
560 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in init_file_internal_()
561 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED; in init_file_internal_()
564 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS; in init_file_internal_()
571 …return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, clien… in init_file_internal_()
575 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_file() argument
583 …return init_file_internal_(decoder, filename, write_callback, metadata_callback, error_callback, c… in FLAC__stream_decoder_init_file()
587 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_ogg_file() argument
595 …return init_file_internal_(decoder, filename, write_callback, metadata_callback, error_callback, c… in FLAC__stream_decoder_init_ogg_file()
598 FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_finish() argument
603 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_finish()
604 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_finish()
605 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_finish()
607 if(decoder->protected_->state == FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_finish()
613 FLAC__MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context); in FLAC__stream_decoder_finish()
615 free(decoder->private_->seek_table.data.seek_table.points); in FLAC__stream_decoder_finish()
616 decoder->private_->seek_table.data.seek_table.points = 0; in FLAC__stream_decoder_finish()
617 decoder->private_->has_seek_table = false; in FLAC__stream_decoder_finish()
619 FLAC__bitreader_free(decoder->private_->input); in FLAC__stream_decoder_finish()
627 if(0 != decoder->private_->output[i]) { in FLAC__stream_decoder_finish()
628 free(decoder->private_->output[i]-4); in FLAC__stream_decoder_finish()
629 decoder->private_->output[i] = 0; in FLAC__stream_decoder_finish()
631 if(0 != decoder->private_->residual_unaligned[i]) { in FLAC__stream_decoder_finish()
632 free(decoder->private_->residual_unaligned[i]); in FLAC__stream_decoder_finish()
633 decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; in FLAC__stream_decoder_finish()
636 if(0 != decoder->private_->side_subframe) { in FLAC__stream_decoder_finish()
637 free(decoder->private_->side_subframe); in FLAC__stream_decoder_finish()
638 decoder->private_->side_subframe = 0; in FLAC__stream_decoder_finish()
640 decoder->private_->output_capacity = 0; in FLAC__stream_decoder_finish()
641 decoder->private_->output_channels = 0; in FLAC__stream_decoder_finish()
644 if(decoder->private_->is_ogg) in FLAC__stream_decoder_finish()
645 FLAC__ogg_decoder_aspect_finish(&decoder->protected_->ogg_decoder_aspect); in FLAC__stream_decoder_finish()
648 if(0 != decoder->private_->file) { in FLAC__stream_decoder_finish()
649 if(decoder->private_->file != stdin) in FLAC__stream_decoder_finish()
650 fclose(decoder->private_->file); in FLAC__stream_decoder_finish()
651 decoder->private_->file = 0; in FLAC__stream_decoder_finish()
654 if(decoder->private_->do_md5_checking) { in FLAC__stream_decoder_finish()
655 …if(memcmp(decoder->private_->stream_info.data.stream_info.md5sum, decoder->private_->computed_md5s… in FLAC__stream_decoder_finish()
658 decoder->private_->is_seeking = false; in FLAC__stream_decoder_finish()
660 set_defaults_(decoder); in FLAC__stream_decoder_finish()
662 decoder->protected_->state = FLAC__STREAM_DECODER_UNINITIALIZED; in FLAC__stream_decoder_finish()
667 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
669 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_ogg_serial_number()
670 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_ogg_serial_number()
671 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_ogg_serial_number()
672 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_ogg_serial_number()
675 /* can't check decoder->private_->is_ogg since that's not set until init time */ in FLAC__stream_decoder_set_ogg_serial_number()
676 FLAC__ogg_decoder_aspect_set_serial_number(&decoder->protected_->ogg_decoder_aspect, value); in FLAC__stream_decoder_set_ogg_serial_number()
684 FLAC_API FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder *decoder, FLAC__bool … in FLAC__stream_decoder_set_md5_checking() argument
686 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_md5_checking()
687 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_md5_checking()
688 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_md5_checking()
690 decoder->protected_->md5_checking = value; in FLAC__stream_decoder_set_md5_checking()
694 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder *decoder, FLAC__M… in FLAC__stream_decoder_set_metadata_respond() argument
696 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_respond()
697 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_respond()
698 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_respond()
703 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_respond()
705 decoder->private_->metadata_filter[type] = true; in FLAC__stream_decoder_set_metadata_respond()
707 decoder->private_->metadata_filter_ids_count = 0; in FLAC__stream_decoder_set_metadata_respond()
711 …AC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte… in FLAC__stream_decoder_set_metadata_respond_application() argument
713 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_respond_application()
714 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_respond_application()
715 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_respond_application()
717 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_respond_application()
720 if(decoder->private_->metadata_filter[FLAC__METADATA_TYPE_APPLICATION]) in FLAC__stream_decoder_set_metadata_respond_application()
723 FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids); in FLAC__stream_decoder_set_metadata_respond_application()
725 …if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity… in FLAC__stream_decoder_set_metadata_respond_application()
726 …if(0 == (decoder->private_->metadata_filter_ids = safe_realloc_mul_2op_(decoder->private_->metadat… in FLAC__stream_decoder_set_metadata_respond_application()
727 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in FLAC__stream_decoder_set_metadata_respond_application()
730 decoder->private_->metadata_filter_ids_capacity *= 2; in FLAC__stream_decoder_set_metadata_respond_application()
733 …memcpy(decoder->private_->metadata_filter_ids + decoder->private_->metadata_filter_ids_count * (FL… in FLAC__stream_decoder_set_metadata_respond_application()
734 decoder->private_->metadata_filter_ids_count++; in FLAC__stream_decoder_set_metadata_respond_application()
739 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_set_metadata_respond_all() argument
742 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_respond_all()
743 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_respond_all()
744 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_respond_all()
745 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_respond_all()
747 …for(i = 0; i < sizeof(decoder->private_->metadata_filter) / sizeof(decoder->private_->metadata_fil… in FLAC__stream_decoder_set_metadata_respond_all()
748 decoder->private_->metadata_filter[i] = true; in FLAC__stream_decoder_set_metadata_respond_all()
749 decoder->private_->metadata_filter_ids_count = 0; in FLAC__stream_decoder_set_metadata_respond_all()
753 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder *decoder, FLAC__Me… in FLAC__stream_decoder_set_metadata_ignore() argument
755 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_ignore()
756 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_ignore()
757 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_ignore()
762 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_ignore()
764 decoder->private_->metadata_filter[type] = false; in FLAC__stream_decoder_set_metadata_ignore()
766 decoder->private_->metadata_filter_ids_count = 0; in FLAC__stream_decoder_set_metadata_ignore()
770 …LAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder *decoder, const FLAC__byte… in FLAC__stream_decoder_set_metadata_ignore_application() argument
772 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_ignore_application()
773 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_ignore_application()
774 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_ignore_application()
776 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_ignore_application()
779 if(!decoder->private_->metadata_filter[FLAC__METADATA_TYPE_APPLICATION]) in FLAC__stream_decoder_set_metadata_ignore_application()
782 FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids); in FLAC__stream_decoder_set_metadata_ignore_application()
784 …if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity… in FLAC__stream_decoder_set_metadata_ignore_application()
785 …if(0 == (decoder->private_->metadata_filter_ids = safe_realloc_mul_2op_(decoder->private_->metadat… in FLAC__stream_decoder_set_metadata_ignore_application()
786 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in FLAC__stream_decoder_set_metadata_ignore_application()
789 decoder->private_->metadata_filter_ids_capacity *= 2; in FLAC__stream_decoder_set_metadata_ignore_application()
792 …memcpy(decoder->private_->metadata_filter_ids + decoder->private_->metadata_filter_ids_count * (FL… in FLAC__stream_decoder_set_metadata_ignore_application()
793 decoder->private_->metadata_filter_ids_count++; in FLAC__stream_decoder_set_metadata_ignore_application()
798 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_set_metadata_ignore_all() argument
800 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_ignore_all()
801 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_ignore_all()
802 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_ignore_all()
803 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_ignore_all()
805 memset(decoder->private_->metadata_filter, 0, sizeof(decoder->private_->metadata_filter)); in FLAC__stream_decoder_set_metadata_ignore_all()
806 decoder->private_->metadata_filter_ids_count = 0; in FLAC__stream_decoder_set_metadata_ignore_all()
810 FLAC_API FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_state() argument
812 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_state()
813 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_state()
814 return decoder->protected_->state; in FLAC__stream_decoder_get_state()
817 …_API const char *FLAC__stream_decoder_get_resolved_state_string(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_resolved_state_string() argument
819 return FLAC__StreamDecoderStateString[decoder->protected_->state]; in FLAC__stream_decoder_get_resolved_state_string()
822 FLAC_API FLAC__bool FLAC__stream_decoder_get_md5_checking(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_md5_checking() argument
824 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_md5_checking()
825 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_md5_checking()
826 return decoder->protected_->md5_checking; in FLAC__stream_decoder_get_md5_checking()
829 FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_total_samples() argument
831 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_total_samples()
832 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_total_samples()
833 …return decoder->private_->has_stream_info? decoder->private_->stream_info.data.stream_info.total_s… in FLAC__stream_decoder_get_total_samples()
836 FLAC_API uint32_t FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_channels() argument
838 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_channels()
839 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_channels()
840 return decoder->protected_->channels; in FLAC__stream_decoder_get_channels()
843 …__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_channel_assignment() argument
845 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_channel_assignment()
846 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_channel_assignment()
847 return decoder->protected_->channel_assignment; in FLAC__stream_decoder_get_channel_assignment()
850 FLAC_API uint32_t FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_bits_per_sample() argument
852 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_bits_per_sample()
853 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_bits_per_sample()
854 return decoder->protected_->bits_per_sample; in FLAC__stream_decoder_get_bits_per_sample()
857 FLAC_API uint32_t FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_sample_rate() argument
859 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_sample_rate()
860 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_sample_rate()
861 return decoder->protected_->sample_rate; in FLAC__stream_decoder_get_sample_rate()
864 FLAC_API uint32_t FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_blocksize() argument
866 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_blocksize()
867 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_blocksize()
868 return decoder->protected_->blocksize; in FLAC__stream_decoder_get_blocksize()
871 FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder *decoder, FL… in FLAC__stream_decoder_get_decode_position() argument
873 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_decode_position()
874 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_get_decode_position()
877 if(FLAC__HAS_OGG && decoder->private_->is_ogg) in FLAC__stream_decoder_get_decode_position()
880 if(0 == decoder->private_->tell_callback) in FLAC__stream_decoder_get_decode_position()
882 …if(decoder->private_->tell_callback(decoder, position, decoder->private_->client_data) != FLAC__ST… in FLAC__stream_decoder_get_decode_position()
885 if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) in FLAC__stream_decoder_get_decode_position()
887 FLAC__ASSERT(*position >= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder)); in FLAC__stream_decoder_get_decode_position()
888 *position -= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder); in FLAC__stream_decoder_get_decode_position()
892 FLAC_API const void *FLAC__stream_decoder_get_client_data(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_client_data() argument
894 return decoder->private_->client_data; in FLAC__stream_decoder_get_client_data()
897 FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_flush() argument
899 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_flush()
900 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_flush()
901 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_flush()
903 …if(!decoder->private_->internal_reset_hack && decoder->protected_->state == FLAC__STREAM_DECODER_U… in FLAC__stream_decoder_flush()
906 decoder->private_->samples_decoded = 0; in FLAC__stream_decoder_flush()
907 decoder->private_->do_md5_checking = false; in FLAC__stream_decoder_flush()
908 decoder->private_->last_seen_framesync = 0; in FLAC__stream_decoder_flush()
909 decoder->private_->last_frame_is_set = false; in FLAC__stream_decoder_flush()
912 if(decoder->private_->is_ogg) in FLAC__stream_decoder_flush()
913 FLAC__ogg_decoder_aspect_flush(&decoder->protected_->ogg_decoder_aspect); in FLAC__stream_decoder_flush()
916 if(!FLAC__bitreader_clear(decoder->private_->input)) { in FLAC__stream_decoder_flush()
917 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in FLAC__stream_decoder_flush()
920 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in FLAC__stream_decoder_flush()
925 FLAC_API FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_reset() argument
927 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_reset()
928 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_reset()
929 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_reset()
931 if(!FLAC__stream_decoder_flush(decoder)) { in FLAC__stream_decoder_reset()
938 if(decoder->private_->is_ogg) in FLAC__stream_decoder_reset()
939 FLAC__ogg_decoder_aspect_reset(&decoder->protected_->ogg_decoder_aspect); in FLAC__stream_decoder_reset()
947 if(!decoder->private_->internal_reset_hack) { in FLAC__stream_decoder_reset()
948 if(decoder->private_->file == stdin) in FLAC__stream_decoder_reset()
950 …if(decoder->private_->seek_callback && decoder->private_->seek_callback(decoder, 0, decoder->priva… in FLAC__stream_decoder_reset()
954 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_METADATA; in FLAC__stream_decoder_reset()
956 decoder->private_->has_stream_info = false; in FLAC__stream_decoder_reset()
958 free(decoder->private_->seek_table.data.seek_table.points); in FLAC__stream_decoder_reset()
959 decoder->private_->seek_table.data.seek_table.points = 0; in FLAC__stream_decoder_reset()
960 decoder->private_->has_seek_table = false; in FLAC__stream_decoder_reset()
962 decoder->private_->do_md5_checking = decoder->protected_->md5_checking; in FLAC__stream_decoder_reset()
967 decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size = 0; in FLAC__stream_decoder_reset()
975 if(!decoder->private_->internal_reset_hack) { in FLAC__stream_decoder_reset()
978 FLAC__MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context); in FLAC__stream_decoder_reset()
981 decoder->private_->internal_reset_hack = false; in FLAC__stream_decoder_reset()
982 FLAC__MD5Init(&decoder->private_->md5context); in FLAC__stream_decoder_reset()
984 decoder->private_->first_frame_offset = 0; in FLAC__stream_decoder_reset()
985 decoder->private_->unparseable_frame_count = 0; in FLAC__stream_decoder_reset()
986 decoder->private_->last_seen_framesync = 0; in FLAC__stream_decoder_reset()
987 decoder->private_->last_frame_is_set = false; in FLAC__stream_decoder_reset()
992 FLAC_API FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_process_single() argument
995 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_process_single()
996 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_process_single()
999 switch(decoder->protected_->state) { in FLAC__stream_decoder_process_single()
1001 if(!find_metadata_(decoder)) in FLAC__stream_decoder_process_single()
1005 if(!read_metadata_(decoder)) in FLAC__stream_decoder_process_single()
1010 if(!frame_sync_(decoder)) in FLAC__stream_decoder_process_single()
1014 if(!read_frame_(decoder, &got_a_frame, /*do_full_decode=*/true)) in FLAC__stream_decoder_process_single()
1028 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
1030 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_process_until_end_of_metadata()
1031 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_process_until_end_of_metadata()
1034 switch(decoder->protected_->state) { in FLAC__stream_decoder_process_until_end_of_metadata()
1036 if(!find_metadata_(decoder)) in FLAC__stream_decoder_process_until_end_of_metadata()
1040 if(!read_metadata_(decoder)) in FLAC__stream_decoder_process_until_end_of_metadata()
1054 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
1057 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_process_until_end_of_stream()
1058 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_process_until_end_of_stream()
1061 switch(decoder->protected_->state) { in FLAC__stream_decoder_process_until_end_of_stream()
1063 if(!find_metadata_(decoder)) in FLAC__stream_decoder_process_until_end_of_stream()
1067 if(!read_metadata_(decoder)) in FLAC__stream_decoder_process_until_end_of_stream()
1071 if(!frame_sync_(decoder)) in FLAC__stream_decoder_process_until_end_of_stream()
1075 if(!read_frame_(decoder, &dummy, /*do_full_decode=*/true)) in FLAC__stream_decoder_process_until_end_of_stream()
1087 FLAC_API FLAC__bool FLAC__stream_decoder_skip_single_frame(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_skip_single_frame() argument
1090 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_skip_single_frame()
1091 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_skip_single_frame()
1094 switch(decoder->protected_->state) { in FLAC__stream_decoder_skip_single_frame()
1099 if(!frame_sync_(decoder)) in FLAC__stream_decoder_skip_single_frame()
1103 if(!read_frame_(decoder, &got_a_frame, /*do_full_decode=*/false)) in FLAC__stream_decoder_skip_single_frame()
1117 FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *decoder, FLAC__uint64 s… in FLAC__stream_decoder_seek_absolute() argument
1121 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_seek_absolute()
1124 decoder->protected_->state != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA && in FLAC__stream_decoder_seek_absolute()
1125 decoder->protected_->state != FLAC__STREAM_DECODER_READ_METADATA && in FLAC__stream_decoder_seek_absolute()
1126 decoder->protected_->state != FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC && in FLAC__stream_decoder_seek_absolute()
1127 decoder->protected_->state != FLAC__STREAM_DECODER_READ_FRAME && in FLAC__stream_decoder_seek_absolute()
1128 decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM in FLAC__stream_decoder_seek_absolute()
1132 if(0 == decoder->private_->seek_callback) in FLAC__stream_decoder_seek_absolute()
1135 FLAC__ASSERT(decoder->private_->seek_callback); in FLAC__stream_decoder_seek_absolute()
1136 FLAC__ASSERT(decoder->private_->tell_callback); in FLAC__stream_decoder_seek_absolute()
1137 FLAC__ASSERT(decoder->private_->length_callback); in FLAC__stream_decoder_seek_absolute()
1138 FLAC__ASSERT(decoder->private_->eof_callback); in FLAC__stream_decoder_seek_absolute()
1140 …(FLAC__stream_decoder_get_total_samples(decoder) > 0 && sample >= FLAC__stream_decoder_get_total_s… in FLAC__stream_decoder_seek_absolute()
1143 decoder->private_->is_seeking = true; in FLAC__stream_decoder_seek_absolute()
1146 decoder->private_->do_md5_checking = false; in FLAC__stream_decoder_seek_absolute()
1149 …if(decoder->private_->length_callback(decoder, &length, decoder->private_->client_data) != FLAC__S… in FLAC__stream_decoder_seek_absolute()
1150 decoder->private_->is_seeking = false; in FLAC__stream_decoder_seek_absolute()
1156 decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA || in FLAC__stream_decoder_seek_absolute()
1157 decoder->protected_->state == FLAC__STREAM_DECODER_READ_METADATA in FLAC__stream_decoder_seek_absolute()
1159 if(!FLAC__stream_decoder_process_until_end_of_metadata(decoder)) { in FLAC__stream_decoder_seek_absolute()
1161 decoder->private_->is_seeking = false; in FLAC__stream_decoder_seek_absolute()
1165 …(FLAC__stream_decoder_get_total_samples(decoder) > 0 && sample >= FLAC__stream_decoder_get_total_s… in FLAC__stream_decoder_seek_absolute()
1166 decoder->private_->is_seeking = false; in FLAC__stream_decoder_seek_absolute()
1174 decoder->private_->is_ogg? in FLAC__stream_decoder_seek_absolute()
1175 seek_to_absolute_sample_ogg_(decoder, length, sample) : in FLAC__stream_decoder_seek_absolute()
1177 seek_to_absolute_sample_(decoder, length, sample) in FLAC__stream_decoder_seek_absolute()
1179 decoder->private_->is_seeking = false; in FLAC__stream_decoder_seek_absolute()
1190 uint32_t FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_input_bytes_unconsumed() argument
1192 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_input_bytes_unconsumed()
1193 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in FLAC__stream_decoder_get_input_bytes_unconsumed()
1194 FLAC__ASSERT(!(FLAC__bitreader_get_input_bits_unconsumed(decoder->private_->input) & 7)); in FLAC__stream_decoder_get_input_bytes_unconsumed()
1195 return FLAC__bitreader_get_input_bits_unconsumed(decoder->private_->input) / 8; in FLAC__stream_decoder_get_input_bytes_unconsumed()
1204 void set_defaults_(FLAC__StreamDecoder *decoder) in set_defaults_() argument
1206 decoder->private_->is_ogg = false; in set_defaults_()
1207 decoder->private_->read_callback = 0; in set_defaults_()
1208 decoder->private_->seek_callback = 0; in set_defaults_()
1209 decoder->private_->tell_callback = 0; in set_defaults_()
1210 decoder->private_->length_callback = 0; in set_defaults_()
1211 decoder->private_->eof_callback = 0; in set_defaults_()
1212 decoder->private_->write_callback = 0; in set_defaults_()
1213 decoder->private_->metadata_callback = 0; in set_defaults_()
1214 decoder->private_->error_callback = 0; in set_defaults_()
1215 decoder->private_->client_data = 0; in set_defaults_()
1217 memset(decoder->private_->metadata_filter, 0, sizeof(decoder->private_->metadata_filter)); in set_defaults_()
1218 decoder->private_->metadata_filter[FLAC__METADATA_TYPE_STREAMINFO] = true; in set_defaults_()
1219 decoder->private_->metadata_filter_ids_count = 0; in set_defaults_()
1221 decoder->protected_->md5_checking = false; in set_defaults_()
1224 FLAC__ogg_decoder_aspect_set_defaults(&decoder->protected_->ogg_decoder_aspect); in set_defaults_()
1246 FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels, uint32_… in allocate_output_() argument
1251 if(size <= decoder->private_->output_capacity && channels <= decoder->private_->output_channels && in allocate_output_()
1252 (bps < 32 || decoder->private_->side_subframe != 0)) in allocate_output_()
1258 if(0 != decoder->private_->output[i]) { in allocate_output_()
1259 free(decoder->private_->output[i]-4); in allocate_output_()
1260 decoder->private_->output[i] = 0; in allocate_output_()
1262 if(0 != decoder->private_->residual_unaligned[i]) { in allocate_output_()
1263 free(decoder->private_->residual_unaligned[i]); in allocate_output_()
1264 decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; in allocate_output_()
1268 if(0 != decoder->private_->side_subframe) { in allocate_output_()
1269 free(decoder->private_->side_subframe); in allocate_output_()
1270 decoder->private_->side_subframe = 0; in allocate_output_()
1282 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in allocate_output_()
1286 decoder->private_->output[i] = tmp + 4; in allocate_output_()
1288 …if(!FLAC__memory_alloc_aligned_int32_array(size, &decoder->private_->residual_unaligned[i], &decod… in allocate_output_()
1289 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in allocate_output_()
1295 decoder->private_->side_subframe = safe_malloc_mul_2op_p(sizeof(FLAC__int64), /*times (*/size); in allocate_output_()
1296 if(decoder->private_->side_subframe == NULL) { in allocate_output_()
1297 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in allocate_output_()
1302 decoder->private_->output_capacity = size; in allocate_output_()
1303 decoder->private_->output_channels = channels; in allocate_output_()
1308 FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id) in has_id_filtered_() argument
1312 FLAC__ASSERT(0 != decoder); in has_id_filtered_()
1313 FLAC__ASSERT(0 != decoder->private_); in has_id_filtered_()
1315 for(i = 0; i < decoder->private_->metadata_filter_ids_count; i++) in has_id_filtered_()
1316 …if(0 == memcmp(decoder->private_->metadata_filter_ids + i * (FLAC__STREAM_METADATA_APPLICATION_ID_… in has_id_filtered_()
1322 FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder) in find_metadata_() argument
1328 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in find_metadata_()
1331 if(decoder->private_->cached) { in find_metadata_()
1332 x = (FLAC__uint32)decoder->private_->lookahead; in find_metadata_()
1333 decoder->private_->cached = false; in find_metadata_()
1336 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in find_metadata_()
1353 if(!skip_id3v2_tag_(decoder)) in find_metadata_()
1360 decoder->private_->header_warmup[0] = (FLAC__byte)x; in find_metadata_()
1361 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in find_metadata_()
1367 decoder->private_->lookahead = (FLAC__byte)x; in find_metadata_()
1368 decoder->private_->cached = true; in find_metadata_()
1371 decoder->private_->header_warmup[1] = (FLAC__byte)x; in find_metadata_()
1372 decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME; in find_metadata_()
1378 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in find_metadata_()
1383 decoder->protected_->state = FLAC__STREAM_DECODER_READ_METADATA; in find_metadata_()
1387 FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder) in read_metadata_() argument
1392 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_()
1394 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_IS_LAST_LE… in read_metadata_()
1398 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &type, FLAC__STREAM_METADATA_TYPE_LE… in read_metadata_()
1401 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &length, FLAC__STREAM_METADATA_LENGT… in read_metadata_()
1405 if(!read_metadata_streaminfo_(decoder, is_last, length)) in read_metadata_()
1408 decoder->private_->has_stream_info = true; in read_metadata_()
1409 …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_()
1410 decoder->private_->do_md5_checking = false; in read_metadata_()
1411 …if(!decoder->private_->is_seeking && decoder->private_->metadata_filter[FLAC__METADATA_TYPE_STREAM… in read_metadata_()
1412 …decoder->private_->metadata_callback(decoder, &decoder->private_->stream_info, decoder->private_->… in read_metadata_()
1416 decoder->private_->has_seek_table = false; in read_metadata_()
1419 if(!read_metadata_seektable_(decoder, is_last, length)) in read_metadata_()
1422 decoder->private_->has_seek_table = true; in read_metadata_()
1423 …if(!decoder->private_->is_seeking && decoder->private_->metadata_filter[FLAC__METADATA_TYPE_SEEKTA… in read_metadata_()
1424 …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_()
1458 FLAC__bitreader_set_limit(decoder->private_->input, real_length*8); in read_metadata_()
1462 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, real_length)) in read_metadata_()
1469 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_()
1472 …else if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.appli… in read_metadata_()
1479 if(!read_metadata_vorbiscomment_(decoder, &block.data.vorbis_comment, real_length)) in read_metadata_()
1483 if(!read_metadata_cuesheet_(decoder, &block.data.cue_sheet)) in read_metadata_()
1487 if(!read_metadata_picture_(decoder, &block.data.picture)) in read_metadata_()
1497 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_()
1500 …else if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.unkno… in read_metadata_()
1507 if(FLAC__bitreader_limit_remaining(decoder->private_->input) > 0) { in read_metadata_()
1511 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA); in read_metadata_()
1512 if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_METADATA) in read_metadata_()
1513 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_metadata_()
1516 FLAC__bitreader_remove_limit(decoder->private_->input); in read_metadata_()
1517 if(ok && !decoder->private_->is_seeking && decoder->private_->metadata_callback) in read_metadata_()
1518 decoder->private_->metadata_callback(decoder, &block, decoder->private_->client_data); in read_metadata_()
1563 …if(!ok) /* anything that unsets "ok" should also make sure decoder->protected_->state is updated */ in read_metadata_()
1570 if(!FLAC__stream_decoder_get_decode_position(decoder, &decoder->private_->first_frame_offset)) in read_metadata_()
1571 decoder->private_->first_frame_offset = 0; in read_metadata_()
1572 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_metadata_()
1578 FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t len… in read_metadata_streaminfo_() argument
1583 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_streaminfo_()
1585 decoder->private_->stream_info.type = FLAC__METADATA_TYPE_STREAMINFO; in read_metadata_streaminfo_()
1586 decoder->private_->stream_info.is_last = is_last; in read_metadata_streaminfo_()
1587 decoder->private_->stream_info.length = length; in read_metadata_streaminfo_()
1590 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, bits)) in read_metadata_streaminfo_()
1592 decoder->private_->stream_info.data.stream_info.min_blocksize = x; in read_metadata_streaminfo_()
1596 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1598 decoder->private_->stream_info.data.stream_info.max_blocksize = x; in read_metadata_streaminfo_()
1602 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1604 decoder->private_->stream_info.data.stream_info.min_framesize = x; in read_metadata_streaminfo_()
1608 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1610 decoder->private_->stream_info.data.stream_info.max_framesize = x; in read_metadata_streaminfo_()
1614 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1616 decoder->private_->stream_info.data.stream_info.sample_rate = x; in read_metadata_streaminfo_()
1620 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1622 decoder->private_->stream_info.data.stream_info.channels = x+1; in read_metadata_streaminfo_()
1626 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1628 decoder->private_->stream_info.data.stream_info.bits_per_sample = x+1; in read_metadata_streaminfo_()
1632 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &decoder->private_->stream_info.data… in read_metadata_streaminfo_()
1636 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, decoder->private_->st… in read_metadata_streaminfo_()
1645 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length)) in read_metadata_streaminfo_()
1651 FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t leng… in read_metadata_seektable_() argument
1656 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_seektable_()
1658 decoder->private_->seek_table.type = FLAC__METADATA_TYPE_SEEKTABLE; in read_metadata_seektable_()
1659 decoder->private_->seek_table.is_last = is_last; in read_metadata_seektable_()
1660 decoder->private_->seek_table.length = length; in read_metadata_seektable_()
1663 FLAC__bitreader_limit_invalidate(decoder->private_->input); in read_metadata_seektable_()
1667 …decoder->private_->seek_table.data.seek_table.num_points = length / FLAC__STREAM_METADATA_SEEKPOIN… in read_metadata_seektable_()
1670 …(0 == (decoder->private_->seek_table.data.seek_table.points = safe_realloc_mul_2op_(decoder->priva… in read_metadata_seektable_()
1671 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_seektable_()
1674 for(i = 0; i < decoder->private_->seek_table.data.seek_table.num_points; i++) { in read_metadata_seektable_()
1675 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT… in read_metadata_seektable_()
1677 decoder->private_->seek_table.data.seek_table.points[i].sample_number = xx; in read_metadata_seektable_()
1679 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT… in read_metadata_seektable_()
1681 decoder->private_->seek_table.data.seek_table.points[i].stream_offset = xx; in read_metadata_seektable_()
1683 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_SEEKPOINT_… in read_metadata_seektable_()
1685 decoder->private_->seek_table.data.seek_table.points[i].frame_samples = x; in read_metadata_seektable_()
1687 …length -= (decoder->private_->seek_table.data.seek_table.num_points * FLAC__STREAM_METADATA_SEEKPO… in read_metadata_seektable_()
1694 FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisCo… in read_metadata_vorbiscomment_() argument
1698 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_vorbiscomment_()
1704 …if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->vendor_string.lengt… in read_metadata_vorbiscomment_()
1714 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_vorbiscomment_()
1717 …if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->vendor_string.e… in read_metadata_vorbiscomment_()
1723 if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->num_comments)) in read_metadata_vorbiscomment_()
1735 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_vorbiscomment_()
1750 …if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->comments[i].length)… in read_metadata_vorbiscomment_()
1756 FLAC__bitreader_limit_invalidate(decoder->private_->input); in read_metadata_vorbiscomment_()
1762 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_vorbiscomment_()
1767 …if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->comments[i].ent… in read_metadata_vorbiscomment_()
1779 FLAC__bitreader_limit_invalidate(decoder->private_->input); in read_metadata_vorbiscomment_()
1790 FLAC__bitreader_limit_invalidate(decoder->private_->input); in read_metadata_vorbiscomment_()
1797 FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_CueSheet *obj) in read_metadata_cuesheet_() argument
1801 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_cuesheet_()
1806 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)obj->med… in read_metadata_cuesheet_()
1809 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &obj->lead_in, FLAC__STREAM_METADATA… in read_metadata_cuesheet_()
1812 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_I… in read_metadata_cuesheet_()
1816 …if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_RESE… in read_metadata_cuesheet_()
1819 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_N… in read_metadata_cuesheet_()
1825 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_cuesheet_()
1830 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &track->offset, FLAC__STREAM_METADAT… in read_metadata_cuesheet_()
1833 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_T… in read_metadata_cuesheet_()
1838 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)track->i… in read_metadata_cuesheet_()
1841 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_T… in read_metadata_cuesheet_()
1845 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_T… in read_metadata_cuesheet_()
1849 …if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_TRAC… in read_metadata_cuesheet_()
1852 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_T… in read_metadata_cuesheet_()
1858 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_cuesheet_()
1863 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &indx->offset, FLAC__STREAM_METADATA… in read_metadata_cuesheet_()
1866 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_I… in read_metadata_cuesheet_()
1870 …if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_INDE… in read_metadata_cuesheet_()
1877 FLAC__bitreader_limit_invalidate(decoder->private_->input); in read_metadata_cuesheet_()
1884 FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_Picture *obj) in read_metadata_picture_() argument
1888 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_picture_()
1891 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_TY… in read_metadata_picture_()
1899 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_MI… in read_metadata_picture_()
1901 if(FLAC__bitreader_limit_remaining(decoder->private_->input) < x){ in read_metadata_picture_()
1902 FLAC__bitreader_limit_invalidate(decoder->private_->input); in read_metadata_picture_()
1906 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_picture_()
1910 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)obj->mim… in read_metadata_picture_()
1916 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_DE… in read_metadata_picture_()
1918 if(FLAC__bitreader_limit_remaining(decoder->private_->input) < x){ in read_metadata_picture_()
1919 FLAC__bitreader_limit_invalidate(decoder->private_->input); in read_metadata_picture_()
1923 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_picture_()
1927 if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->description, x)) in read_metadata_picture_()
1933 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->width, FLAC__STREAM_METADATA_P… in read_metadata_picture_()
1937 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->height, FLAC__STREAM_METADATA_… in read_metadata_picture_()
1941 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->depth, FLAC__STREAM_METADATA_P… in read_metadata_picture_()
1945 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->colors, FLAC__STREAM_METADATA_… in read_metadata_picture_()
1949 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &(obj->data_length), FLAC__STREAM_ME… in read_metadata_picture_()
1951 if(FLAC__bitreader_limit_remaining(decoder->private_->input) < obj->data_length){ in read_metadata_picture_()
1952 FLAC__bitreader_limit_invalidate(decoder->private_->input); in read_metadata_picture_()
1956 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_picture_()
1960 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->data, obj->data_… in read_metadata_picture_()
1967 FLAC__bool skip_id3v2_tag_(FLAC__StreamDecoder *decoder) in skip_id3v2_tag_() argument
1973 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 24)) in skip_id3v2_tag_()
1978 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in skip_id3v2_tag_()
1984 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, skip)) in skip_id3v2_tag_()
1989 FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder) in frame_sync_() argument
1995 if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) { in frame_sync_()
1996 …f(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__bitreader_bits_left_for_byt… in frame_sync_()
2001 if(decoder->private_->cached) { in frame_sync_()
2002 x = (FLAC__uint32)decoder->private_->lookahead; in frame_sync_()
2003 decoder->private_->cached = false; in frame_sync_()
2006 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in frame_sync_()
2010 decoder->private_->header_warmup[0] = (FLAC__byte)x; in frame_sync_()
2011 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in frame_sync_()
2017 decoder->private_->lookahead = (FLAC__byte)x; in frame_sync_()
2018 decoder->private_->cached = true; in frame_sync_()
2021 decoder->private_->header_warmup[1] = (FLAC__byte)x; in frame_sync_()
2022 decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME; in frame_sync_()
2026 FLAC__bitreader_set_framesync_location(decoder->private_->input); in frame_sync_()
2027 if(!FLAC__stream_decoder_get_decode_position(decoder, &decoder->private_->last_seen_framesync)) in frame_sync_()
2028 decoder->private_->last_seen_framesync = 0; in frame_sync_()
2033 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in frame_sync_()
2041 FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_full_de… in read_frame_() argument
2049 decoder->private_->side_subframe_in_use = false; in read_frame_()
2053 frame_crc = FLAC__CRC16_UPDATE(decoder->private_->header_warmup[0], frame_crc); in read_frame_()
2054 frame_crc = FLAC__CRC16_UPDATE(decoder->private_->header_warmup[1], frame_crc); in read_frame_()
2055 FLAC__bitreader_reset_read_crc16(decoder->private_->input, (FLAC__uint16)frame_crc); in read_frame_()
2057 if(!read_frame_header_(decoder)) in read_frame_()
2059 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means we didn't sy… in read_frame_()
2061 …if(!allocate_output_(decoder, decoder->private_->frame.header.blocksize, decoder->private_->frame.… in read_frame_()
2063 for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) { in read_frame_()
2067 uint32_t bps = decoder->private_->frame.header.bits_per_sample; in read_frame_()
2068 switch(decoder->private_->frame.header.channel_assignment) { in read_frame_()
2073 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2078 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2083 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2093 if(!read_subframe_(decoder, channel, bps, do_full_decode)){ in read_frame_()
2095 if(decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM) in read_frame_()
2100 if(decoder->protected_->state != FLAC__STREAM_DECODER_READ_FRAME) in read_frame_()
2104 if(decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM) in read_frame_()
2105 if(!read_zero_padding_(decoder)) in read_frame_()
2111 if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME) { in read_frame_()
2112 frame_crc = FLAC__bitreader_get_read_crc16(decoder->private_->input); in read_frame_()
2113 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__FRAME_FOOTER_CRC_LEN)) { in read_frame_()
2115 if(decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM) in read_frame_()
2120 if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME && frame_crc == x) { in read_frame_()
2124 undo_channel_coding(decoder); in read_frame_()
2126 for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) { in read_frame_()
2127 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in read_frame_()
2128 int shift_bits = 32 - decoder->private_->frame.header.bits_per_sample; in read_frame_()
2130 if((decoder->private_->output[channel][i] < (INT32_MIN >> shift_bits)) || in read_frame_()
2131 (decoder->private_->output[channel][i] > (INT32_MAX >> shift_bits))) { in read_frame_()
2133 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH); in read_frame_()
2134 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_()
2142 else if (decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME) { in read_frame_()
2144 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH); in read_frame_()
2145 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_()
2150 …if(decoder->private_->last_frame_is_set && decoder->protected_->state == FLAC__STREAM_DECODER_READ… in read_frame_()
2151 …FLAC__ASSERT(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); in read_frame_()
2152 …FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NU… in read_frame_()
2153 …if(decoder->private_->last_frame.header.number.sample_number + decoder->private_->last_frame.heade… in read_frame_()
2154 …mples_needed = decoder->private_->frame.header.number.sample_number - (decoder->private_->last_fra… in read_frame_()
2160 …if(decoder->private_->last_frame.header.sample_rate == decoder->private_->frame.header.sample_rate… in read_frame_()
2161 decoder->private_->last_frame.header.channels == decoder->private_->frame.header.channels && in read_frame_()
2162 …decoder->private_->last_frame.header.bits_per_sample == decoder->private_->frame.header.bits_per_s… in read_frame_()
2163 decoder->private_->last_frame.header.blocksize >= 16) { in read_frame_()
2166 empty_frame.header = decoder->private_->last_frame.header; in read_frame_()
2174 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_frame_()
2190 decoder->protected_->blocksize = empty_frame.header.blocksize; in read_frame_()
2193 …decoder->private_->samples_decoded = empty_frame.header.number.sample_number + empty_frame.header.… in read_frame_()
2201 …if(write_audio_frame_to_client_(decoder, &empty_frame, (const FLAC__int32 * const *)empty_buffer) … in read_frame_()
2202 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_frame_()
2217 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC || decoder->protected_… in read_frame_()
2219 * isn't checked, if the seek fails the decoder will continue anyway */ in read_frame_()
2220 if(!FLAC__bitreader_rewind_to_after_last_seen_framesync(decoder->private_->input)){ in read_frame_()
2224 if(decoder->private_->seek_callback && decoder->private_->last_seen_framesync){ in read_frame_()
2228 if(FLAC__stream_decoder_get_decode_position(decoder, ¤t_decode_position)) in read_frame_()
2229 …fprintf(stderr, "Bitreader was %" PRIu64 " bytes short\n", current_decode_position-decoder->privat… in read_frame_()
2231 …if(decoder->private_->seek_callback(decoder, decoder->private_->last_seen_framesync, decoder->priv… in read_frame_()
2232 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in read_frame_()
2235 if(!FLAC__bitreader_clear(decoder->private_->input)) { in read_frame_()
2236 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_frame_()
2251 if(decoder->private_->next_fixed_block_size) in read_frame_()
2252 decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size; in read_frame_()
2254 /* put the latest values into the public section of the decoder instance */ in read_frame_()
2255 decoder->protected_->channels = decoder->private_->frame.header.channels; in read_frame_()
2256 decoder->protected_->channel_assignment = decoder->private_->frame.header.channel_assignment; in read_frame_()
2257 decoder->protected_->bits_per_sample = decoder->private_->frame.header.bits_per_sample; in read_frame_()
2258 decoder->protected_->sample_rate = decoder->private_->frame.header.sample_rate; in read_frame_()
2259 decoder->protected_->blocksize = decoder->private_->frame.header.blocksize; in read_frame_()
2261 …FLAC__ASSERT(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); in read_frame_()
2262 …decoder->private_->samples_decoded = decoder->private_->frame.header.number.sample_number + decode… in read_frame_()
2266 …if(write_audio_frame_to_client_(decoder, &decoder->private_->frame, (const FLAC__int32 * const *)d… in read_frame_()
2267 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_frame_()
2273 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_()
2277 FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder) in read_frame_header_() argument
2286 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_frame_header_()
2289 raw_header[0] = decoder->private_->header_warmup[0]; in read_frame_header_()
2290 raw_header[1] = decoder->private_->header_warmup[1]; in read_frame_header_()
2320 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in read_frame_header_()
2324 decoder->private_->lookahead = (FLAC__byte)x; in read_frame_header_()
2325 decoder->private_->cached = true; in read_frame_header_()
2326 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2327 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2338 decoder->private_->frame.header.blocksize = 192; in read_frame_header_()
2344 decoder->private_->frame.header.blocksize = 576 << (x-2); in read_frame_header_()
2358 decoder->private_->frame.header.blocksize = 256 << (x-8); in read_frame_header_()
2367 if(decoder->private_->has_stream_info) in read_frame_header_()
2368 …decoder->private_->frame.header.sample_rate = decoder->private_->stream_info.data.stream_info.samp… in read_frame_header_()
2373 decoder->private_->frame.header.sample_rate = 88200; in read_frame_header_()
2376 decoder->private_->frame.header.sample_rate = 176400; in read_frame_header_()
2379 decoder->private_->frame.header.sample_rate = 192000; in read_frame_header_()
2382 decoder->private_->frame.header.sample_rate = 8000; in read_frame_header_()
2385 decoder->private_->frame.header.sample_rate = 16000; in read_frame_header_()
2388 decoder->private_->frame.header.sample_rate = 22050; in read_frame_header_()
2391 decoder->private_->frame.header.sample_rate = 24000; in read_frame_header_()
2394 decoder->private_->frame.header.sample_rate = 32000; in read_frame_header_()
2397 decoder->private_->frame.header.sample_rate = 44100; in read_frame_header_()
2400 decoder->private_->frame.header.sample_rate = 48000; in read_frame_header_()
2403 decoder->private_->frame.header.sample_rate = 96000; in read_frame_header_()
2411 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2412 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2420 decoder->private_->frame.header.channels = 2; in read_frame_header_()
2423 decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE; in read_frame_header_()
2426 decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE; in read_frame_header_()
2429 decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_MID_SIDE; in read_frame_header_()
2437 decoder->private_->frame.header.channels = (uint32_t)x + 1; in read_frame_header_()
2438 decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT; in read_frame_header_()
2443 if(decoder->private_->has_stream_info) in read_frame_header_()
2444 …decoder->private_->frame.header.bits_per_sample = decoder->private_->stream_info.data.stream_info.… in read_frame_header_()
2449 decoder->private_->frame.header.bits_per_sample = 8; in read_frame_header_()
2452 decoder->private_->frame.header.bits_per_sample = 12; in read_frame_header_()
2458 decoder->private_->frame.header.bits_per_sample = 16; in read_frame_header_()
2461 decoder->private_->frame.header.bits_per_sample = 20; in read_frame_header_()
2464 decoder->private_->frame.header.bits_per_sample = 24; in read_frame_header_()
2467 decoder->private_->frame.header.bits_per_sample = 32; in read_frame_header_()
2484 …(decoder->private_->has_stream_info && decoder->private_->stream_info.data.stream_info.min_blocksi… in read_frame_header_()
2486 if(!FLAC__bitreader_read_utf8_uint64(decoder->private_->input, &xx, raw_header, &raw_header_len)) in read_frame_header_()
2489 decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */ in read_frame_header_()
2490 decoder->private_->cached = true; in read_frame_header_()
2491 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2492 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2495 decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER; in read_frame_header_()
2496 decoder->private_->frame.header.number.sample_number = xx; in read_frame_header_()
2499 if(!FLAC__bitreader_read_utf8_uint32(decoder->private_->input, &x, raw_header, &raw_header_len)) in read_frame_header_()
2502 decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */ in read_frame_header_()
2503 decoder->private_->cached = true; in read_frame_header_()
2504 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2505 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2508 decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER; in read_frame_header_()
2509 decoder->private_->frame.header.number.frame_number = x; in read_frame_header_()
2513 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in read_frame_header_()
2518 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &_x, 8)) in read_frame_header_()
2523 decoder->private_->frame.header.blocksize = x+1; in read_frame_header_()
2524 if(decoder->private_->frame.header.blocksize > 65535) { /* invalid blocksize (65536) specified */ in read_frame_header_()
2525 decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */ in read_frame_header_()
2526 decoder->private_->cached = true; in read_frame_header_()
2527 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2528 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2535 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in read_frame_header_()
2540 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &_x, 8)) in read_frame_header_()
2546 decoder->private_->frame.header.sample_rate = x*1000; in read_frame_header_()
2548 decoder->private_->frame.header.sample_rate = x; in read_frame_header_()
2550 decoder->private_->frame.header.sample_rate = x*10; in read_frame_header_()
2554 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in read_frame_header_()
2560 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2561 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2567 decoder->private_->next_fixed_block_size = 0; in read_frame_header_()
2568 if(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER) { in read_frame_header_()
2569 x = decoder->private_->frame.header.number.frame_number; in read_frame_header_()
2570 decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER; in read_frame_header_()
2571 if(decoder->private_->fixed_block_size) in read_frame_header_()
2572 …decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->fixed_bloc… in read_frame_header_()
2573 else if(decoder->private_->has_stream_info) { in read_frame_header_()
2574 …if(decoder->private_->stream_info.data.stream_info.min_blocksize == decoder->private_->stream_info… in read_frame_header_()
2575 …decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->stream_inf… in read_frame_header_()
2576 …decoder->private_->next_fixed_block_size = decoder->private_->stream_info.data.stream_info.max_blo… in read_frame_header_()
2582 decoder->private_->frame.header.number.sample_number = 0; in read_frame_header_()
2583 decoder->private_->next_fixed_block_size = decoder->private_->frame.header.blocksize; in read_frame_header_()
2587 …decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->frame.head… in read_frame_header_()
2592 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_frame_header_()
2593 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2600 FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool … in read_subframe_() argument
2606 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) /* MAGIC NUMBER */ in read_subframe_()
2614 if(!FLAC__bitreader_read_unary_unsigned(decoder->private_->input, &u)) in read_subframe_()
2616 decoder->private_->frame.subframes[channel].wasted_bits = u+1; in read_subframe_()
2617 if (decoder->private_->frame.subframes[channel].wasted_bits >= bps) { in read_subframe_()
2618 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_()
2619 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2622 bps -= decoder->private_->frame.subframes[channel].wasted_bits; in read_subframe_()
2625 decoder->private_->frame.subframes[channel].wasted_bits = 0; in read_subframe_()
2631 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_()
2632 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2636 if(!read_subframe_constant_(decoder, channel, bps, do_full_decode)) in read_subframe_()
2640 if(!read_subframe_verbatim_(decoder, channel, bps, do_full_decode)) in read_subframe_()
2644 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_subframe_()
2645 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2650 if(decoder->private_->frame.header.blocksize <= predictor_order){ in read_subframe_()
2651 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_()
2652 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2655 if(!read_subframe_fixed_(decoder, channel, bps, predictor_order, do_full_decode)) in read_subframe_()
2657 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or … in read_subframe_()
2661 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_subframe_()
2662 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2667 if(decoder->private_->frame.header.blocksize <= predictor_order){ in read_subframe_()
2668 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_()
2669 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2672 if(!read_subframe_lpc_(decoder, channel, bps, predictor_order, do_full_decode)) in read_subframe_()
2674 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or … in read_subframe_()
2679 x = decoder->private_->frame.subframes[channel].wasted_bits; in read_subframe_()
2681 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in read_subframe_()
2682 uint32_t val = decoder->private_->output[channel][i]; in read_subframe_()
2683 decoder->private_->output[channel][i] = (val << x); in read_subframe_()
2689 FLAC__ASSERT(!decoder->private_->side_subframe_in_use); in read_subframe_()
2690 decoder->private_->side_subframe_in_use = true; in read_subframe_()
2691 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in read_subframe_()
2692 uint64_t val = decoder->private_->output[channel][i]; in read_subframe_()
2693 decoder->private_->side_subframe[i] = (val << x); in read_subframe_()
2701 FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FL… in read_subframe_constant_() argument
2703 FLAC__Subframe_Constant *subframe = &decoder->private_->frame.subframes[channel].data.constant; in read_subframe_constant_()
2707 decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_CONSTANT; in read_subframe_constant_()
2709 if(!FLAC__bitreader_read_raw_int64(decoder->private_->input, &x, bps)) in read_subframe_constant_()
2717 FLAC__int32 *output = decoder->private_->output[channel]; in read_subframe_constant_()
2718 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) in read_subframe_constant_()
2721 FLAC__int64 *output = decoder->private_->side_subframe; in read_subframe_constant_()
2722 decoder->private_->side_subframe_in_use = true; in read_subframe_constant_()
2723 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) in read_subframe_constant_()
2731 FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const… in read_subframe_fixed_() argument
2733 FLAC__Subframe_Fixed *subframe = &decoder->private_->frame.subframes[channel].data.fixed; in read_subframe_fixed_()
2738 decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_FIXED; in read_subframe_fixed_()
2740 subframe->residual = decoder->private_->residual[channel]; in read_subframe_fixed_()
2745 if(!FLAC__bitreader_read_raw_int64(decoder->private_->input, &i64, bps)) in read_subframe_fixed_()
2751 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TY… in read_subframe_fixed_()
2757 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PA… in read_subframe_fixed_()
2759 if((decoder->private_->frame.header.blocksize >> u32 < order) || in read_subframe_fixed_()
2760 (decoder->private_->frame.header.blocksize % (1 << u32) > 0)) { in read_subframe_fixed_()
2761 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_fixed_()
2762 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_fixed_()
2766 …subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_r… in read_subframe_fixed_()
2769 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_subframe_fixed_()
2770 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_fixed_()
2778 …rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, &decoder->priva… in read_subframe_fixed_()
2790 decoder->private_->output[channel][i] = subframe->warmup[i]; in read_subframe_fixed_()
2792 …LAC__fixed_restore_signal(decoder->private_->residual[channel], decoder->private_->frame.header.bl… in read_subframe_fixed_()
2794 …fixed_restore_signal_wide(decoder->private_->residual[channel], decoder->private_->frame.header.bl… in read_subframe_fixed_()
2797 decoder->private_->side_subframe_in_use = true; in read_subframe_fixed_()
2798 memcpy(decoder->private_->side_subframe, subframe->warmup, sizeof(FLAC__int64) * order); in read_subframe_fixed_()
2799 …restore_signal_wide_33bit(decoder->private_->residual[channel], decoder->private_->frame.header.bl… in read_subframe_fixed_()
2806 FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const u… in read_subframe_lpc_() argument
2808 FLAC__Subframe_LPC *subframe = &decoder->private_->frame.subframes[channel].data.lpc; in read_subframe_lpc_()
2814 decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_LPC; in read_subframe_lpc_()
2816 subframe->residual = decoder->private_->residual[channel]; in read_subframe_lpc_()
2821 if(!FLAC__bitreader_read_raw_int64(decoder->private_->input, &i64, bps)) in read_subframe_lpc_()
2827 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__SUBFRAME_LPC_QLP_COEFF_P… in read_subframe_lpc_()
2830 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_lpc_()
2831 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_lpc_()
2837 …if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, FLAC__SUBFRAME_LPC_QLP_SHIFT_LE… in read_subframe_lpc_()
2840 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_lpc_()
2841 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_lpc_()
2848 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, subframe->qlp_coeff_precision)) in read_subframe_lpc_()
2854 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TY… in read_subframe_lpc_()
2860 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PA… in read_subframe_lpc_()
2862 if((decoder->private_->frame.header.blocksize >> u32 < order) || in read_subframe_lpc_()
2863 (decoder->private_->frame.header.blocksize % (1 << u32) > 0)) { in read_subframe_lpc_()
2864 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_lpc_()
2865 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_lpc_()
2869 …subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_r… in read_subframe_lpc_()
2872 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_subframe_lpc_()
2873 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_lpc_()
2881 …rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, &decoder->priva… in read_subframe_lpc_()
2893 decoder->private_->output[channel][i] = subframe->warmup[i]; in read_subframe_lpc_()
2896 …decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->q… in read_subframe_lpc_()
2898 …decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->q… in read_subframe_lpc_()
2901 decoder->private_->side_subframe_in_use = true; in read_subframe_lpc_()
2902 memcpy(decoder->private_->side_subframe, subframe->warmup, sizeof(FLAC__int64) * order); in read_subframe_lpc_()
2903 …decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->q… in read_subframe_lpc_()
2910 FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FL… in read_subframe_verbatim_() argument
2912 FLAC__Subframe_Verbatim *subframe = &decoder->private_->frame.subframes[channel].data.verbatim; in read_subframe_verbatim_()
2915 decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM; in read_subframe_verbatim_()
2918 FLAC__int32 x, *residual = decoder->private_->residual[channel]; in read_subframe_verbatim_()
2923 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in read_subframe_verbatim_()
2924 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &x, bps)) in read_subframe_verbatim_()
2931 …memcpy(decoder->private_->output[channel], subframe->data.int32, sizeof(FLAC__int32) * decoder->pr… in read_subframe_verbatim_()
2934 FLAC__int64 x, *side = decoder->private_->side_subframe; in read_subframe_verbatim_()
2938 decoder->private_->side_subframe_in_use = true; in read_subframe_verbatim_()
2940 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in read_subframe_verbatim_()
2941 if(!FLAC__bitreader_read_raw_int64(decoder->private_->input, &x, bps)) in read_subframe_verbatim_()
2950 FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_t predictor_order, … in read_residual_partitioned_rice_() argument
2956 const uint32_t partition_samples = decoder->private_->frame.header.blocksize >> partition_order; in read_residual_partitioned_rice_()
2961 …FLAC__ASSERT(partition_order > 0? partition_samples >= predictor_order : decoder->private_->frame.… in read_residual_partitioned_rice_()
2964 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_residual_partitioned_rice_()
2970 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &rice_parameter, plen)) in read_residual_partitioned_rice_()
2976 …if(!decoder->private_->local_bitreader_read_rice_signed_block(decoder->private_->input, residual +… in read_residual_partitioned_rice_()
2977 if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME) { in read_residual_partitioned_rice_()
2980 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_residual_partitioned_rice_()
2981 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_residual_partitioned_rice_()
2990 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &rice_parameter, FLAC__ENTROPY_CODIN… in read_residual_partitioned_rice_()
2999 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i, rice_parameter)) in read_residual_partitioned_rice_()
3010 FLAC__bool read_zero_padding_(FLAC__StreamDecoder *decoder) in read_zero_padding_() argument
3012 if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) { in read_zero_padding_()
3014 …(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &zero, FLAC__bitreader_bits_left_for_b… in read_zero_padding_()
3018 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_zero_padding_()
3019 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_zero_padding_()
3028 FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder *)client_data; in read_callback_() local
3033 !decoder->private_->is_ogg && in read_callback_()
3035 …decoder->private_->eof_callback && decoder->private_->eof_callback(decoder, decoder->private_->cli… in read_callback_()
3038 decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM; in read_callback_()
3052 if(decoder->private_->is_seeking && decoder->private_->unparseable_frame_count > 20) { in read_callback_()
3053 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_callback_()
3059 decoder->private_->is_ogg? in read_callback_()
3060 read_callback_ogg_aspect_(decoder, buffer, bytes) : in read_callback_()
3062 decoder->private_->read_callback(decoder, buffer, bytes, decoder->private_->client_data) in read_callback_()
3065 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_callback_()
3074 !decoder->private_->is_ogg && in read_callback_()
3076 …decoder->private_->eof_callback && decoder->private_->eof_callback(decoder, decoder->private_->cli… in read_callback_()
3079 decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM; in read_callback_()
3091 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_callback_()
3095 * for Ogg FLAC. This is because the ogg decoder aspect can lose sync in read_callback_()
3100 * So to keep the decoder from stopping at this point we gate the call in read_callback_()
3101 * to the eof_callback and let the Ogg decoder aspect set the in read_callback_()
3109 * decoder, having overflows in this section is unavoidable. Also,
3114 void undo_channel_coding(FLAC__StreamDecoder *decoder) { in undo_channel_coding() argument
3116 switch(decoder->private_->frame.header.channel_assignment) { in undo_channel_coding()
3121 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in undo_channel_coding()
3122 …FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->fram… in undo_channel_coding()
3123 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) in undo_channel_coding()
3124 if(decoder->private_->side_subframe_in_use) in undo_channel_coding()
3125 …decoder->private_->output[1][i] = decoder->private_->output[0][i] - decoder->private_->side_subfra… in undo_channel_coding()
3127 …decoder->private_->output[1][i] = decoder->private_->output[0][i] - decoder->private_->output[1][i… in undo_channel_coding()
3130 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in undo_channel_coding()
3131 …FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->fram… in undo_channel_coding()
3132 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) in undo_channel_coding()
3133 if(decoder->private_->side_subframe_in_use) in undo_channel_coding()
3134 …decoder->private_->output[0][i] = decoder->private_->output[1][i] + decoder->private_->side_subfra… in undo_channel_coding()
3136 decoder->private_->output[0][i] += decoder->private_->output[1][i]; in undo_channel_coding()
3139 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in undo_channel_coding()
3140 …FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->fram… in undo_channel_coding()
3141 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in undo_channel_coding()
3142 if(!decoder->private_->side_subframe_in_use){ in undo_channel_coding()
3144 mid = decoder->private_->output[0][i]; in undo_channel_coding()
3145 side = decoder->private_->output[1][i]; in undo_channel_coding()
3148 decoder->private_->output[0][i] = (mid + side) >> 1; in undo_channel_coding()
3149 decoder->private_->output[1][i] = (mid - side) >> 1; in undo_channel_coding()
3153 mid = ((uint64_t)decoder->private_->output[0][i]) << 1; in undo_channel_coding()
3154 mid |= (decoder->private_->side_subframe[i] & 1); /* i.e. if 'side' is odd... */ in undo_channel_coding()
3155 decoder->private_->output[0][i] = (mid + decoder->private_->side_subframe[i]) >> 1; in undo_channel_coding()
3156 decoder->private_->output[1][i] = (mid - decoder->private_->side_subframe[i]) >> 1; in undo_channel_coding()
3167 FLAC__StreamDecoderReadStatus read_callback_ogg_aspect_(const FLAC__StreamDecoder *decoder, FLAC__b… in read_callback_ogg_aspect_() argument
3169 …spect_read_callback_wrapper(&decoder->protected_->ogg_decoder_aspect, buffer, bytes, read_callback… in read_callback_ogg_aspect_()
3174 * FLAC decoder catch the error in read_callback_ogg_aspect_()
3195 FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder*)void_decoder; in read_callback_proxy_() local
3197 switch(decoder->private_->read_callback(decoder, buffer, bytes, client_data)) { in read_callback_proxy_()
3212 FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder *decoder, const FLA… in write_audio_frame_to_client_() argument
3214 decoder->private_->last_frame = *frame; /* save the frame */ in write_audio_frame_to_client_()
3215 decoder->private_->last_frame_is_set = true; in write_audio_frame_to_client_()
3216 if(decoder->private_->is_seeking) { in write_audio_frame_to_client_()
3219 FLAC__uint64 target_sample = decoder->private_->target_sample; in write_audio_frame_to_client_()
3224 decoder->private_->got_a_frame = true; in write_audio_frame_to_client_()
3229 decoder->private_->is_seeking = false; in write_audio_frame_to_client_()
3236 decoder->private_->last_frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM; in write_audio_frame_to_client_()
3237 …decoder->private_->last_frame.subframes[channel].data.verbatim.data_type = FLAC__VERBATIM_SUBFRAME… in write_audio_frame_to_client_()
3238 decoder->private_->last_frame.subframes[channel].data.verbatim.data.int32 = newbuffer[channel]; in write_audio_frame_to_client_()
3240 decoder->private_->last_frame.header.blocksize -= delta; in write_audio_frame_to_client_()
3241 decoder->private_->last_frame.header.number.sample_number += (FLAC__uint64)delta; in write_audio_frame_to_client_()
3243 …return decoder->private_->write_callback(decoder, &decoder->private_->last_frame, newbuffer, decod… in write_audio_frame_to_client_()
3247 … return decoder->private_->write_callback(decoder, frame, buffer, decoder->private_->client_data); in write_audio_frame_to_client_()
3259 if(!decoder->private_->has_stream_info) in write_audio_frame_to_client_()
3260 decoder->private_->do_md5_checking = false; in write_audio_frame_to_client_()
3261 if(decoder->private_->do_md5_checking) { in write_audio_frame_to_client_()
3262 …if(!FLAC__MD5Accumulate(&decoder->private_->md5context, buffer, frame->header.channels, frame->hea… in write_audio_frame_to_client_()
3265 return decoder->private_->write_callback(decoder, frame, buffer, decoder->private_->client_data); in write_audio_frame_to_client_()
3269 void send_error_to_client_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus statu… in send_error_to_client_() argument
3271 if(!decoder->private_->is_seeking) in send_error_to_client_()
3272 decoder->private_->error_callback(decoder, status, decoder->private_->client_data); in send_error_to_client_()
3274 decoder->private_->unparseable_frame_count++; in send_error_to_client_()
3277 FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC_… in seek_to_absolute_sample_() argument
3279 …FLAC__uint64 first_frame_offset = decoder->private_->first_frame_offset, lower_bound, upper_bound,… in seek_to_absolute_sample_()
3284 const FLAC__uint64 total_samples = FLAC__stream_decoder_get_total_samples(decoder); in seek_to_absolute_sample_()
3285 const uint32_t min_blocksize = decoder->private_->stream_info.data.stream_info.min_blocksize; in seek_to_absolute_sample_()
3286 const uint32_t max_blocksize = decoder->private_->stream_info.data.stream_info.max_blocksize; in seek_to_absolute_sample_()
3287 const uint32_t max_framesize = decoder->private_->stream_info.data.stream_info.max_framesize; in seek_to_absolute_sample_()
3288 const uint32_t min_framesize = decoder->private_->stream_info.data.stream_info.min_framesize; in seek_to_absolute_sample_()
3290 uint32_t channels = FLAC__stream_decoder_get_channels(decoder); in seek_to_absolute_sample_()
3291 uint32_t bps = FLAC__stream_decoder_get_bits_per_sample(decoder); in seek_to_absolute_sample_()
3292 …const FLAC__StreamMetadata_SeekTable *seek_table = decoder->private_->has_seek_table? &decoder->pr… in seek_to_absolute_sample_()
3296 channels = decoder->private_->stream_info.data.stream_info.channels; in seek_to_absolute_sample_()
3298 bps = decoder->private_->stream_info.data.stream_info.bits_per_sample; in seek_to_absolute_sample_()
3328 if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC && in seek_to_absolute_sample_()
3329 decoder->private_->samples_decoded != 0) { in seek_to_absolute_sample_()
3330 if(target_sample < decoder->private_->samples_decoded) { in seek_to_absolute_sample_()
3331 if(FLAC__stream_decoder_get_decode_position(decoder, &upper_bound)) in seek_to_absolute_sample_()
3332 upper_bound_sample = decoder->private_->samples_decoded; in seek_to_absolute_sample_()
3334 if(FLAC__stream_decoder_get_decode_position(decoder, &lower_bound)) in seek_to_absolute_sample_()
3335 lower_bound_sample = decoder->private_->samples_decoded; in seek_to_absolute_sample_()
3406 decoder->private_->target_sample = target_sample; in seek_to_absolute_sample_()
3408 /* check whether decoder is still valid so bad state isn't overwritten in seek_to_absolute_sample_()
3410 if(decoder->protected_->state == FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR || in seek_to_absolute_sample_()
3411 decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED) in seek_to_absolute_sample_()
3417 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3440 …if(decoder->private_->seek_callback(decoder, (FLAC__uint64)pos, decoder->private_->client_data) !=… in seek_to_absolute_sample_()
3441 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3444 if(!FLAC__stream_decoder_flush(decoder)) { in seek_to_absolute_sample_()
3454 decoder->private_->unparseable_frame_count = 0; in seek_to_absolute_sample_()
3455 …C__stream_decoder_process_single(decoder) || decoder->protected_->state == FLAC__STREAM_DECODER_AB… in seek_to_absolute_sample_()
3457 …if(decoder->protected_->state != FLAC__STREAM_DECODER_ABORTED && decoder->private_->eof_callback(d… in seek_to_absolute_sample_()
3458 /* decoder has hit end of stream while processing corrupt in seek_to_absolute_sample_()
3466 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3473 …/* actually, we could have got_a_frame if our decoder is at FLAC__STREAM_DECODER_END_OF_STREAM so … in seek_to_absolute_sample_()
3474 if(!decoder->private_->is_seeking) in seek_to_absolute_sample_()
3477 …FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NU… in seek_to_absolute_sample_()
3478 this_frame_sample = decoder->private_->last_frame.header.number.sample_number; in seek_to_absolute_sample_()
3480 …if(this_frame_sample + decoder->private_->last_frame.header.blocksize >= upper_bound_sample && !fi… in seek_to_absolute_sample_()
3483 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3495 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3501 upper_bound_sample = this_frame_sample + decoder->private_->last_frame.header.blocksize; in seek_to_absolute_sample_()
3503 if(!FLAC__stream_decoder_get_decode_position(decoder, &upper_bound)) { in seek_to_absolute_sample_()
3504 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3510 lower_bound_sample = this_frame_sample + decoder->private_->last_frame.header.blocksize; in seek_to_absolute_sample_()
3511 if(!FLAC__stream_decoder_get_decode_position(decoder, &lower_bound)) { in seek_to_absolute_sample_()
3512 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3523 FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, F… in seek_to_absolute_sample_ogg_() argument
3526 FLAC__uint64 left_sample = 0, right_sample = FLAC__stream_decoder_get_total_samples(decoder); in seek_to_absolute_sample_ogg_()
3552 decoder->private_->target_sample = target_sample; in seek_to_absolute_sample_ogg_()
3557 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3582 …if(decoder->private_->seek_callback((FLAC__StreamDecoder*)decoder, (FLAC__uint64)pos, decoder->pri… in seek_to_absolute_sample_ogg_()
3583 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3586 if(!FLAC__stream_decoder_flush(decoder)) { in seek_to_absolute_sample_ogg_()
3595 decoder->private_->got_a_frame = false; in seek_to_absolute_sample_ogg_()
3596 if(!FLAC__stream_decoder_process_single(decoder) || in seek_to_absolute_sample_ogg_()
3597 decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED) { in seek_to_absolute_sample_ogg_()
3598 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3601 if(!decoder->private_->got_a_frame) { in seek_to_absolute_sample_ogg_()
3614 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3619 else if(!decoder->private_->is_seeking) { in seek_to_absolute_sample_ogg_()
3623 this_frame_sample = decoder->private_->last_frame.header.number.sample_number; in seek_to_absolute_sample_ogg_()
3624 …FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NU… in seek_to_absolute_sample_ogg_()
3639 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3648 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3661 FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte bu… in file_read_callback_() argument
3666 *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, decoder->private_->file); in file_read_callback_()
3667 if(ferror(decoder->private_->file)) in file_read_callback_()
3678 FLAC__StreamDecoderSeekStatus file_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 … in file_seek_callback_() argument
3682 if(decoder->private_->file == stdin) in file_seek_callback_()
3684 else if(fseeko(decoder->private_->file, (FLAC__off_t)absolute_byte_offset, SEEK_SET) < 0) in file_seek_callback_()
3690 FLAC__StreamDecoderTellStatus file_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 … in file_tell_callback_() argument
3695 if(decoder->private_->file == stdin) in file_tell_callback_()
3697 else if((pos = ftello(decoder->private_->file)) < 0) in file_tell_callback_()
3705 FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FLAC__uin… in file_length_callback_() argument
3710 if(decoder->private_->file == stdin) in file_length_callback_()
3714 if(flac_fstat(fileno(decoder->private_->file), &filestats) != 0) in file_length_callback_()
3716 filestats.st_size = _filelengthi64(fileno(decoder->private_->file)); in file_length_callback_()
3726 FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data) in file_eof_callback_() argument
3730 return feof(decoder->private_->file)? true : false; in file_eof_callback_()