Lines Matching full:decoder
75 static void set_defaults_(FLAC__StreamDecoder *decoder);
77 static FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels, …
78 static FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id);
79 static FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder);
80 static FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder);
81 static FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint3…
82 static FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32…
83 static FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_V…
84 static FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_CueShe…
85 static FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_Picture…
86 static FLAC__bool skip_id3v2_tag_(FLAC__StreamDecoder *decoder);
87 static FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder);
88 static FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_…
89 static FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder);
90 static FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC…
91 static FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t …
92 static FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps…
93 static FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, …
94 static FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t …
95 static FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_t predictor_…
96 static FLAC__bool read_zero_padding_(FLAC__StreamDecoder *decoder);
97 static void undo_channel_coding(FLAC__StreamDecoder *decoder);
100 static FLAC__StreamDecoderReadStatus read_callback_ogg_aspect_(const FLAC__StreamDecoder *decoder, …
103 static FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder *decoder, co…
104 static void send_error_to_client_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatu…
105 static FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length…
107 static FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_le…
109 static FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__…
110 static FLAC__StreamDecoderSeekStatus file_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__…
111 static FLAC__StreamDecoderTellStatus file_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__…
112 static FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FL…
113 static FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data);
155 …eset_hack; /* used only during init() so we can call reset to set up the decoder without rewinding…
241 FLAC__StreamDecoder *decoder; in FLAC__stream_decoder_new() local
246 decoder = calloc(1, sizeof(FLAC__StreamDecoder)); in FLAC__stream_decoder_new()
247 if(decoder == 0) { in FLAC__stream_decoder_new()
251 decoder->protected_ = calloc(1, sizeof(FLAC__StreamDecoderProtected)); in FLAC__stream_decoder_new()
252 if(decoder->protected_ == 0) { in FLAC__stream_decoder_new()
253 free(decoder); in FLAC__stream_decoder_new()
257 decoder->private_ = calloc(1, sizeof(FLAC__StreamDecoderPrivate)); in FLAC__stream_decoder_new()
258 if(decoder->private_ == 0) { in FLAC__stream_decoder_new()
259 free(decoder->protected_); in FLAC__stream_decoder_new()
260 free(decoder); in FLAC__stream_decoder_new()
264 decoder->private_->input = FLAC__bitreader_new(); in FLAC__stream_decoder_new()
265 if(decoder->private_->input == 0) { in FLAC__stream_decoder_new()
266 free(decoder->private_); in FLAC__stream_decoder_new()
267 free(decoder->protected_); in FLAC__stream_decoder_new()
268 free(decoder); in FLAC__stream_decoder_new()
272 decoder->private_->metadata_filter_ids_capacity = 16; in FLAC__stream_decoder_new()
273 …if(0 == (decoder->private_->metadata_filter_ids = malloc((FLAC__STREAM_METADATA_APPLICATION_ID_LEN… in FLAC__stream_decoder_new()
274 FLAC__bitreader_delete(decoder->private_->input); in FLAC__stream_decoder_new()
275 free(decoder->private_); in FLAC__stream_decoder_new()
276 free(decoder->protected_); in FLAC__stream_decoder_new()
277 free(decoder); in FLAC__stream_decoder_new()
282 decoder->private_->output[i] = 0; in FLAC__stream_decoder_new()
283 decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; in FLAC__stream_decoder_new()
286 decoder->private_->side_subframe = 0; in FLAC__stream_decoder_new()
288 decoder->private_->output_capacity = 0; in FLAC__stream_decoder_new()
289 decoder->private_->output_channels = 0; in FLAC__stream_decoder_new()
290 decoder->private_->has_seek_table = false; in FLAC__stream_decoder_new()
293 …FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&decoder->private_->partitioned_… in FLAC__stream_decoder_new()
295 decoder->private_->file = 0; in FLAC__stream_decoder_new()
297 set_defaults_(decoder); in FLAC__stream_decoder_new()
299 decoder->protected_->state = FLAC__STREAM_DECODER_UNINITIALIZED; in FLAC__stream_decoder_new()
301 return decoder; in FLAC__stream_decoder_new()
304 FLAC_API void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_delete() argument
308 if (decoder == NULL) in FLAC__stream_decoder_delete()
311 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_delete()
312 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_delete()
313 FLAC__ASSERT(0 != decoder->private_->input); in FLAC__stream_decoder_delete()
315 (void)FLAC__stream_decoder_finish(decoder); in FLAC__stream_decoder_delete()
317 if(0 != decoder->private_->metadata_filter_ids) in FLAC__stream_decoder_delete()
318 free(decoder->private_->metadata_filter_ids); in FLAC__stream_decoder_delete()
320 FLAC__bitreader_delete(decoder->private_->input); in FLAC__stream_decoder_delete()
323 …FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(&decoder->private_->partitioned… in FLAC__stream_decoder_delete()
325 free(decoder->private_); in FLAC__stream_decoder_delete()
326 free(decoder->protected_); in FLAC__stream_decoder_delete()
327 free(decoder); in FLAC__stream_decoder_delete()
337 FLAC__StreamDecoder *decoder, in init_stream_internal_() argument
350 FLAC__ASSERT(0 != decoder); in init_stream_internal_()
352 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in init_stream_internal_()
367 decoder->private_->is_ogg = is_ogg; in init_stream_internal_()
368 if(is_ogg && !FLAC__ogg_decoder_aspect_init(&decoder->protected_->ogg_decoder_aspect)) in init_stream_internal_()
369 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE; in init_stream_internal_()
374 if(!FLAC__bitreader_init(decoder->private_->input, read_callback_, decoder)) { in init_stream_internal_()
375 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in init_stream_internal_()
379 decoder->private_->read_callback = read_callback; in init_stream_internal_()
380 decoder->private_->seek_callback = seek_callback; in init_stream_internal_()
381 decoder->private_->tell_callback = tell_callback; in init_stream_internal_()
382 decoder->private_->length_callback = length_callback; in init_stream_internal_()
383 decoder->private_->eof_callback = eof_callback; in init_stream_internal_()
384 decoder->private_->write_callback = write_callback; in init_stream_internal_()
385 decoder->private_->metadata_callback = metadata_callback; in init_stream_internal_()
386 decoder->private_->error_callback = error_callback; in init_stream_internal_()
387 decoder->private_->client_data = client_data; in init_stream_internal_()
388 decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size = 0; in init_stream_internal_()
389 decoder->private_->samples_decoded = 0; in init_stream_internal_()
390 decoder->private_->has_stream_info = false; in init_stream_internal_()
391 decoder->private_->cached = false; in init_stream_internal_()
393 decoder->private_->do_md5_checking = decoder->protected_->md5_checking; in init_stream_internal_()
394 decoder->private_->is_seeking = false; in init_stream_internal_()
396 …decoder->private_->internal_reset_hack = true; /* so the following reset does not try to rewind th… in init_stream_internal_()
397 if(!FLAC__stream_decoder_reset(decoder)) { in init_stream_internal_()
406 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_stream() argument
419 decoder, in FLAC__stream_decoder_init_stream()
434 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_ogg_stream() argument
447 decoder, in FLAC__stream_decoder_init_ogg_stream()
462 FLAC__StreamDecoder *decoder, in init_FILE_internal_() argument
471 FLAC__ASSERT(0 != decoder); in init_FILE_internal_()
474 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in init_FILE_internal_()
475 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED; in init_FILE_internal_()
478 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS; in init_FILE_internal_()
488 decoder->private_->file = file; in init_FILE_internal_()
491 decoder, in init_FILE_internal_()
493 decoder->private_->file == stdin? 0: file_seek_callback_, in init_FILE_internal_()
494 decoder->private_->file == stdin? 0: file_tell_callback_, in init_FILE_internal_()
495 decoder->private_->file == stdin? 0: file_length_callback_, in init_FILE_internal_()
506 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_FILE() argument
514 …return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, clien… in FLAC__stream_decoder_init_FILE()
518 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_ogg_FILE() argument
526 …return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, clien… in FLAC__stream_decoder_init_ogg_FILE()
530 FLAC__StreamDecoder *decoder, in init_file_internal_() argument
541 FLAC__ASSERT(0 != decoder); in init_file_internal_()
548 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in init_file_internal_()
549 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED; in init_file_internal_()
552 return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS; in init_file_internal_()
559 …return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, clien… in init_file_internal_()
563 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_file() argument
571 …return init_file_internal_(decoder, filename, write_callback, metadata_callback, error_callback, c… in FLAC__stream_decoder_init_file()
575 FLAC__StreamDecoder *decoder, in FLAC__stream_decoder_init_ogg_file() argument
583 …return init_file_internal_(decoder, filename, write_callback, metadata_callback, error_callback, c… in FLAC__stream_decoder_init_ogg_file()
586 FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_finish() argument
591 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_finish()
592 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_finish()
593 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_finish()
595 if(decoder->protected_->state == FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_finish()
601 FLAC__MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context); in FLAC__stream_decoder_finish()
603 free(decoder->private_->seek_table.data.seek_table.points); in FLAC__stream_decoder_finish()
604 decoder->private_->seek_table.data.seek_table.points = 0; in FLAC__stream_decoder_finish()
605 decoder->private_->has_seek_table = false; in FLAC__stream_decoder_finish()
607 FLAC__bitreader_free(decoder->private_->input); in FLAC__stream_decoder_finish()
615 if(0 != decoder->private_->output[i]) { in FLAC__stream_decoder_finish()
616 free(decoder->private_->output[i]-4); in FLAC__stream_decoder_finish()
617 decoder->private_->output[i] = 0; in FLAC__stream_decoder_finish()
619 if(0 != decoder->private_->residual_unaligned[i]) { in FLAC__stream_decoder_finish()
620 free(decoder->private_->residual_unaligned[i]); in FLAC__stream_decoder_finish()
621 decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; in FLAC__stream_decoder_finish()
624 if(0 != decoder->private_->side_subframe) { in FLAC__stream_decoder_finish()
625 free(decoder->private_->side_subframe); in FLAC__stream_decoder_finish()
626 decoder->private_->side_subframe = 0; in FLAC__stream_decoder_finish()
628 decoder->private_->output_capacity = 0; in FLAC__stream_decoder_finish()
629 decoder->private_->output_channels = 0; in FLAC__stream_decoder_finish()
632 if(decoder->private_->is_ogg) in FLAC__stream_decoder_finish()
633 FLAC__ogg_decoder_aspect_finish(&decoder->protected_->ogg_decoder_aspect); in FLAC__stream_decoder_finish()
636 if(0 != decoder->private_->file) { in FLAC__stream_decoder_finish()
637 if(decoder->private_->file != stdin) in FLAC__stream_decoder_finish()
638 fclose(decoder->private_->file); in FLAC__stream_decoder_finish()
639 decoder->private_->file = 0; in FLAC__stream_decoder_finish()
642 if(decoder->private_->do_md5_checking) { in FLAC__stream_decoder_finish()
643 …if(memcmp(decoder->private_->stream_info.data.stream_info.md5sum, decoder->private_->computed_md5s… in FLAC__stream_decoder_finish()
646 decoder->private_->is_seeking = false; in FLAC__stream_decoder_finish()
648 set_defaults_(decoder); in FLAC__stream_decoder_finish()
650 decoder->protected_->state = FLAC__STREAM_DECODER_UNINITIALIZED; in FLAC__stream_decoder_finish()
655 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
657 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_ogg_serial_number()
658 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_ogg_serial_number()
659 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_ogg_serial_number()
660 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_ogg_serial_number()
663 /* can't check decoder->private_->is_ogg since that's not set until init time */ in FLAC__stream_decoder_set_ogg_serial_number()
664 FLAC__ogg_decoder_aspect_set_serial_number(&decoder->protected_->ogg_decoder_aspect, value); in FLAC__stream_decoder_set_ogg_serial_number()
672 FLAC_API FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder *decoder, FLAC__bool … in FLAC__stream_decoder_set_md5_checking() argument
674 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_md5_checking()
675 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_md5_checking()
676 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_md5_checking()
678 decoder->protected_->md5_checking = value; in FLAC__stream_decoder_set_md5_checking()
682 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder *decoder, FLAC__M… in FLAC__stream_decoder_set_metadata_respond() argument
684 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_respond()
685 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_respond()
686 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_respond()
691 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_respond()
693 decoder->private_->metadata_filter[type] = true; in FLAC__stream_decoder_set_metadata_respond()
695 decoder->private_->metadata_filter_ids_count = 0; in FLAC__stream_decoder_set_metadata_respond()
699 …AC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte… in FLAC__stream_decoder_set_metadata_respond_application() argument
701 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_respond_application()
702 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_respond_application()
703 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_respond_application()
705 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_respond_application()
708 if(decoder->private_->metadata_filter[FLAC__METADATA_TYPE_APPLICATION]) in FLAC__stream_decoder_set_metadata_respond_application()
711 FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids); in FLAC__stream_decoder_set_metadata_respond_application()
713 …if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity… in FLAC__stream_decoder_set_metadata_respond_application()
714 …if(0 == (decoder->private_->metadata_filter_ids = safe_realloc_mul_2op_(decoder->private_->metadat… in FLAC__stream_decoder_set_metadata_respond_application()
715 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in FLAC__stream_decoder_set_metadata_respond_application()
718 decoder->private_->metadata_filter_ids_capacity *= 2; in FLAC__stream_decoder_set_metadata_respond_application()
721 …memcpy(decoder->private_->metadata_filter_ids + decoder->private_->metadata_filter_ids_count * (FL… in FLAC__stream_decoder_set_metadata_respond_application()
722 decoder->private_->metadata_filter_ids_count++; in FLAC__stream_decoder_set_metadata_respond_application()
727 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_set_metadata_respond_all() argument
730 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_respond_all()
731 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_respond_all()
732 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_respond_all()
733 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_respond_all()
735 …for(i = 0; i < sizeof(decoder->private_->metadata_filter) / sizeof(decoder->private_->metadata_fil… in FLAC__stream_decoder_set_metadata_respond_all()
736 decoder->private_->metadata_filter[i] = true; in FLAC__stream_decoder_set_metadata_respond_all()
737 decoder->private_->metadata_filter_ids_count = 0; in FLAC__stream_decoder_set_metadata_respond_all()
741 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder *decoder, FLAC__Me… in FLAC__stream_decoder_set_metadata_ignore() argument
743 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_ignore()
744 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_ignore()
745 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_ignore()
750 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_ignore()
752 decoder->private_->metadata_filter[type] = false; in FLAC__stream_decoder_set_metadata_ignore()
754 decoder->private_->metadata_filter_ids_count = 0; in FLAC__stream_decoder_set_metadata_ignore()
758 …LAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder *decoder, const FLAC__byte… in FLAC__stream_decoder_set_metadata_ignore_application() argument
760 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_ignore_application()
761 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_ignore_application()
762 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_ignore_application()
764 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_ignore_application()
767 if(!decoder->private_->metadata_filter[FLAC__METADATA_TYPE_APPLICATION]) in FLAC__stream_decoder_set_metadata_ignore_application()
770 FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids); in FLAC__stream_decoder_set_metadata_ignore_application()
772 …if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity… in FLAC__stream_decoder_set_metadata_ignore_application()
773 …if(0 == (decoder->private_->metadata_filter_ids = safe_realloc_mul_2op_(decoder->private_->metadat… in FLAC__stream_decoder_set_metadata_ignore_application()
774 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in FLAC__stream_decoder_set_metadata_ignore_application()
777 decoder->private_->metadata_filter_ids_capacity *= 2; in FLAC__stream_decoder_set_metadata_ignore_application()
780 …memcpy(decoder->private_->metadata_filter_ids + decoder->private_->metadata_filter_ids_count * (FL… in FLAC__stream_decoder_set_metadata_ignore_application()
781 decoder->private_->metadata_filter_ids_count++; in FLAC__stream_decoder_set_metadata_ignore_application()
786 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_set_metadata_ignore_all() argument
788 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_set_metadata_ignore_all()
789 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_set_metadata_ignore_all()
790 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_set_metadata_ignore_all()
791 if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) in FLAC__stream_decoder_set_metadata_ignore_all()
793 memset(decoder->private_->metadata_filter, 0, sizeof(decoder->private_->metadata_filter)); in FLAC__stream_decoder_set_metadata_ignore_all()
794 decoder->private_->metadata_filter_ids_count = 0; in FLAC__stream_decoder_set_metadata_ignore_all()
798 FLAC_API FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_state() argument
800 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_state()
801 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_state()
802 return decoder->protected_->state; in FLAC__stream_decoder_get_state()
805 …_API const char *FLAC__stream_decoder_get_resolved_state_string(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_resolved_state_string() argument
807 return FLAC__StreamDecoderStateString[decoder->protected_->state]; in FLAC__stream_decoder_get_resolved_state_string()
810 FLAC_API FLAC__bool FLAC__stream_decoder_get_md5_checking(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_md5_checking() argument
812 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_md5_checking()
813 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_md5_checking()
814 return decoder->protected_->md5_checking; in FLAC__stream_decoder_get_md5_checking()
817 FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_total_samples() argument
819 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_total_samples()
820 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_total_samples()
821 …return decoder->private_->has_stream_info? decoder->private_->stream_info.data.stream_info.total_s… in FLAC__stream_decoder_get_total_samples()
824 FLAC_API uint32_t FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_channels() argument
826 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_channels()
827 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_channels()
828 return decoder->protected_->channels; in FLAC__stream_decoder_get_channels()
831 …__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_channel_assignment() argument
833 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_channel_assignment()
834 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_channel_assignment()
835 return decoder->protected_->channel_assignment; in FLAC__stream_decoder_get_channel_assignment()
838 FLAC_API uint32_t FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_bits_per_sample() argument
840 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_bits_per_sample()
841 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_bits_per_sample()
842 return decoder->protected_->bits_per_sample; in FLAC__stream_decoder_get_bits_per_sample()
845 FLAC_API uint32_t FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_sample_rate() argument
847 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_sample_rate()
848 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_sample_rate()
849 return decoder->protected_->sample_rate; in FLAC__stream_decoder_get_sample_rate()
852 FLAC_API uint32_t FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_blocksize() argument
854 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_blocksize()
855 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_get_blocksize()
856 return decoder->protected_->blocksize; in FLAC__stream_decoder_get_blocksize()
859 FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder *decoder, FL… in FLAC__stream_decoder_get_decode_position() argument
861 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_decode_position()
862 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_get_decode_position()
865 if(FLAC__HAS_OGG && decoder->private_->is_ogg) in FLAC__stream_decoder_get_decode_position()
868 if(0 == decoder->private_->tell_callback) in FLAC__stream_decoder_get_decode_position()
870 …if(decoder->private_->tell_callback(decoder, position, decoder->private_->client_data) != FLAC__ST… in FLAC__stream_decoder_get_decode_position()
873 if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) in FLAC__stream_decoder_get_decode_position()
875 FLAC__ASSERT(*position >= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder)); in FLAC__stream_decoder_get_decode_position()
876 *position -= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder); in FLAC__stream_decoder_get_decode_position()
880 FLAC_API const void *FLAC__stream_decoder_get_client_data(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_client_data() argument
882 return decoder->private_->client_data; in FLAC__stream_decoder_get_client_data()
885 FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_flush() argument
887 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_flush()
888 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_flush()
889 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_flush()
891 …if(!decoder->private_->internal_reset_hack && decoder->protected_->state == FLAC__STREAM_DECODER_U… in FLAC__stream_decoder_flush()
894 decoder->private_->samples_decoded = 0; in FLAC__stream_decoder_flush()
895 decoder->private_->do_md5_checking = false; in FLAC__stream_decoder_flush()
896 decoder->private_->last_seen_framesync = 0; in FLAC__stream_decoder_flush()
897 decoder->private_->last_frame_is_set = false; in FLAC__stream_decoder_flush()
900 if(decoder->private_->is_ogg) in FLAC__stream_decoder_flush()
901 FLAC__ogg_decoder_aspect_flush(&decoder->protected_->ogg_decoder_aspect); in FLAC__stream_decoder_flush()
904 if(!FLAC__bitreader_clear(decoder->private_->input)) { in FLAC__stream_decoder_flush()
905 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in FLAC__stream_decoder_flush()
908 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in FLAC__stream_decoder_flush()
913 FLAC_API FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_reset() argument
915 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_reset()
916 FLAC__ASSERT(0 != decoder->private_); in FLAC__stream_decoder_reset()
917 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_reset()
919 if(!FLAC__stream_decoder_flush(decoder)) { in FLAC__stream_decoder_reset()
926 if(decoder->private_->is_ogg) in FLAC__stream_decoder_reset()
927 FLAC__ogg_decoder_aspect_reset(&decoder->protected_->ogg_decoder_aspect); in FLAC__stream_decoder_reset()
935 if(!decoder->private_->internal_reset_hack) { in FLAC__stream_decoder_reset()
936 if(decoder->private_->file == stdin) in FLAC__stream_decoder_reset()
938 …if(decoder->private_->seek_callback && decoder->private_->seek_callback(decoder, 0, decoder->priva… in FLAC__stream_decoder_reset()
942 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_METADATA; in FLAC__stream_decoder_reset()
944 decoder->private_->has_stream_info = false; in FLAC__stream_decoder_reset()
946 free(decoder->private_->seek_table.data.seek_table.points); in FLAC__stream_decoder_reset()
947 decoder->private_->seek_table.data.seek_table.points = 0; in FLAC__stream_decoder_reset()
948 decoder->private_->has_seek_table = false; in FLAC__stream_decoder_reset()
950 decoder->private_->do_md5_checking = decoder->protected_->md5_checking; in FLAC__stream_decoder_reset()
955 decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size = 0; in FLAC__stream_decoder_reset()
963 if(!decoder->private_->internal_reset_hack) { in FLAC__stream_decoder_reset()
966 FLAC__MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context); in FLAC__stream_decoder_reset()
969 decoder->private_->internal_reset_hack = false; in FLAC__stream_decoder_reset()
970 FLAC__MD5Init(&decoder->private_->md5context); in FLAC__stream_decoder_reset()
972 decoder->private_->first_frame_offset = 0; in FLAC__stream_decoder_reset()
973 decoder->private_->unparseable_frame_count = 0; in FLAC__stream_decoder_reset()
974 decoder->private_->last_seen_framesync = 0; in FLAC__stream_decoder_reset()
975 decoder->private_->last_frame_is_set = false; in FLAC__stream_decoder_reset()
980 FLAC_API FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_process_single() argument
983 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_process_single()
984 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_process_single()
987 switch(decoder->protected_->state) { in FLAC__stream_decoder_process_single()
989 if(!find_metadata_(decoder)) in FLAC__stream_decoder_process_single()
993 if(!read_metadata_(decoder)) in FLAC__stream_decoder_process_single()
998 if(!frame_sync_(decoder)) in FLAC__stream_decoder_process_single()
1002 if(!read_frame_(decoder, &got_a_frame, /*do_full_decode=*/true)) in FLAC__stream_decoder_process_single()
1016 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
1018 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_process_until_end_of_metadata()
1019 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_process_until_end_of_metadata()
1022 switch(decoder->protected_->state) { in FLAC__stream_decoder_process_until_end_of_metadata()
1024 if(!find_metadata_(decoder)) in FLAC__stream_decoder_process_until_end_of_metadata()
1028 if(!read_metadata_(decoder)) in FLAC__stream_decoder_process_until_end_of_metadata()
1042 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
1045 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_process_until_end_of_stream()
1046 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_process_until_end_of_stream()
1049 switch(decoder->protected_->state) { in FLAC__stream_decoder_process_until_end_of_stream()
1051 if(!find_metadata_(decoder)) in FLAC__stream_decoder_process_until_end_of_stream()
1055 if(!read_metadata_(decoder)) in FLAC__stream_decoder_process_until_end_of_stream()
1059 if(!frame_sync_(decoder)) in FLAC__stream_decoder_process_until_end_of_stream()
1063 if(!read_frame_(decoder, &dummy, /*do_full_decode=*/true)) in FLAC__stream_decoder_process_until_end_of_stream()
1075 FLAC_API FLAC__bool FLAC__stream_decoder_skip_single_frame(FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_skip_single_frame() argument
1078 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_skip_single_frame()
1079 FLAC__ASSERT(0 != decoder->protected_); in FLAC__stream_decoder_skip_single_frame()
1082 switch(decoder->protected_->state) { in FLAC__stream_decoder_skip_single_frame()
1087 if(!frame_sync_(decoder)) in FLAC__stream_decoder_skip_single_frame()
1091 if(!read_frame_(decoder, &got_a_frame, /*do_full_decode=*/false)) in FLAC__stream_decoder_skip_single_frame()
1105 FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *decoder, FLAC__uint64 s… in FLAC__stream_decoder_seek_absolute() argument
1109 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_seek_absolute()
1112 decoder->protected_->state != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA && in FLAC__stream_decoder_seek_absolute()
1113 decoder->protected_->state != FLAC__STREAM_DECODER_READ_METADATA && in FLAC__stream_decoder_seek_absolute()
1114 decoder->protected_->state != FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC && in FLAC__stream_decoder_seek_absolute()
1115 decoder->protected_->state != FLAC__STREAM_DECODER_READ_FRAME && in FLAC__stream_decoder_seek_absolute()
1116 decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM in FLAC__stream_decoder_seek_absolute()
1120 if(0 == decoder->private_->seek_callback) in FLAC__stream_decoder_seek_absolute()
1123 FLAC__ASSERT(decoder->private_->seek_callback); in FLAC__stream_decoder_seek_absolute()
1124 FLAC__ASSERT(decoder->private_->tell_callback); in FLAC__stream_decoder_seek_absolute()
1125 FLAC__ASSERT(decoder->private_->length_callback); in FLAC__stream_decoder_seek_absolute()
1126 FLAC__ASSERT(decoder->private_->eof_callback); in FLAC__stream_decoder_seek_absolute()
1128 …(FLAC__stream_decoder_get_total_samples(decoder) > 0 && sample >= FLAC__stream_decoder_get_total_s… in FLAC__stream_decoder_seek_absolute()
1131 decoder->private_->is_seeking = true; in FLAC__stream_decoder_seek_absolute()
1134 decoder->private_->do_md5_checking = false; in FLAC__stream_decoder_seek_absolute()
1137 …if(decoder->private_->length_callback(decoder, &length, decoder->private_->client_data) != FLAC__S… in FLAC__stream_decoder_seek_absolute()
1138 decoder->private_->is_seeking = false; in FLAC__stream_decoder_seek_absolute()
1144 decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA || in FLAC__stream_decoder_seek_absolute()
1145 decoder->protected_->state == FLAC__STREAM_DECODER_READ_METADATA in FLAC__stream_decoder_seek_absolute()
1147 if(!FLAC__stream_decoder_process_until_end_of_metadata(decoder)) { in FLAC__stream_decoder_seek_absolute()
1149 decoder->private_->is_seeking = false; in FLAC__stream_decoder_seek_absolute()
1153 …(FLAC__stream_decoder_get_total_samples(decoder) > 0 && sample >= FLAC__stream_decoder_get_total_s… in FLAC__stream_decoder_seek_absolute()
1154 decoder->private_->is_seeking = false; in FLAC__stream_decoder_seek_absolute()
1162 decoder->private_->is_ogg? in FLAC__stream_decoder_seek_absolute()
1163 seek_to_absolute_sample_ogg_(decoder, length, sample) : in FLAC__stream_decoder_seek_absolute()
1165 seek_to_absolute_sample_(decoder, length, sample) in FLAC__stream_decoder_seek_absolute()
1167 decoder->private_->is_seeking = false; in FLAC__stream_decoder_seek_absolute()
1178 uint32_t FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder) in FLAC__stream_decoder_get_input_bytes_unconsumed() argument
1180 FLAC__ASSERT(0 != decoder); in FLAC__stream_decoder_get_input_bytes_unconsumed()
1181 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in FLAC__stream_decoder_get_input_bytes_unconsumed()
1182 FLAC__ASSERT(!(FLAC__bitreader_get_input_bits_unconsumed(decoder->private_->input) & 7)); in FLAC__stream_decoder_get_input_bytes_unconsumed()
1183 return FLAC__bitreader_get_input_bits_unconsumed(decoder->private_->input) / 8; in FLAC__stream_decoder_get_input_bytes_unconsumed()
1192 void set_defaults_(FLAC__StreamDecoder *decoder) in set_defaults_() argument
1194 decoder->private_->is_ogg = false; in set_defaults_()
1195 decoder->private_->read_callback = 0; in set_defaults_()
1196 decoder->private_->seek_callback = 0; in set_defaults_()
1197 decoder->private_->tell_callback = 0; in set_defaults_()
1198 decoder->private_->length_callback = 0; in set_defaults_()
1199 decoder->private_->eof_callback = 0; in set_defaults_()
1200 decoder->private_->write_callback = 0; in set_defaults_()
1201 decoder->private_->metadata_callback = 0; in set_defaults_()
1202 decoder->private_->error_callback = 0; in set_defaults_()
1203 decoder->private_->client_data = 0; in set_defaults_()
1205 memset(decoder->private_->metadata_filter, 0, sizeof(decoder->private_->metadata_filter)); in set_defaults_()
1206 decoder->private_->metadata_filter[FLAC__METADATA_TYPE_STREAMINFO] = true; in set_defaults_()
1207 decoder->private_->metadata_filter_ids_count = 0; in set_defaults_()
1209 decoder->protected_->md5_checking = false; in set_defaults_()
1212 FLAC__ogg_decoder_aspect_set_defaults(&decoder->protected_->ogg_decoder_aspect); in set_defaults_()
1234 FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels, uint32_… in allocate_output_() argument
1239 if(size <= decoder->private_->output_capacity && channels <= decoder->private_->output_channels && in allocate_output_()
1240 (bps < 32 || decoder->private_->side_subframe != 0)) in allocate_output_()
1246 if(0 != decoder->private_->output[i]) { in allocate_output_()
1247 free(decoder->private_->output[i]-4); in allocate_output_()
1248 decoder->private_->output[i] = 0; in allocate_output_()
1250 if(0 != decoder->private_->residual_unaligned[i]) { in allocate_output_()
1251 free(decoder->private_->residual_unaligned[i]); in allocate_output_()
1252 decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; in allocate_output_()
1256 if(0 != decoder->private_->side_subframe) { in allocate_output_()
1257 free(decoder->private_->side_subframe); in allocate_output_()
1258 decoder->private_->side_subframe = 0; in allocate_output_()
1270 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in allocate_output_()
1274 decoder->private_->output[i] = tmp + 4; in allocate_output_()
1276 …if(!FLAC__memory_alloc_aligned_int32_array(size, &decoder->private_->residual_unaligned[i], &decod… in allocate_output_()
1277 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in allocate_output_()
1283 decoder->private_->side_subframe = safe_malloc_mul_2op_p(sizeof(FLAC__int64), /*times (*/size); in allocate_output_()
1284 if(decoder->private_->side_subframe == NULL) { in allocate_output_()
1285 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in allocate_output_()
1290 decoder->private_->output_capacity = size; in allocate_output_()
1291 decoder->private_->output_channels = channels; in allocate_output_()
1296 FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id) in has_id_filtered_() argument
1300 FLAC__ASSERT(0 != decoder); in has_id_filtered_()
1301 FLAC__ASSERT(0 != decoder->private_); in has_id_filtered_()
1303 for(i = 0; i < decoder->private_->metadata_filter_ids_count; i++) in has_id_filtered_()
1304 …if(0 == memcmp(decoder->private_->metadata_filter_ids + i * (FLAC__STREAM_METADATA_APPLICATION_ID_… in has_id_filtered_()
1310 FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder) in find_metadata_() argument
1316 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in find_metadata_()
1319 if(decoder->private_->cached) { in find_metadata_()
1320 x = (FLAC__uint32)decoder->private_->lookahead; in find_metadata_()
1321 decoder->private_->cached = false; in find_metadata_()
1324 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in find_metadata_()
1341 if(!skip_id3v2_tag_(decoder)) in find_metadata_()
1348 decoder->private_->header_warmup[0] = (FLAC__byte)x; in find_metadata_()
1349 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in find_metadata_()
1355 decoder->private_->lookahead = (FLAC__byte)x; in find_metadata_()
1356 decoder->private_->cached = true; in find_metadata_()
1359 decoder->private_->header_warmup[1] = (FLAC__byte)x; in find_metadata_()
1360 decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME; in find_metadata_()
1366 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in find_metadata_()
1371 decoder->protected_->state = FLAC__STREAM_DECODER_READ_METADATA; in find_metadata_()
1375 FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder) in read_metadata_() argument
1380 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_()
1382 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_IS_LAST_LE… in read_metadata_()
1386 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &type, FLAC__STREAM_METADATA_TYPE_LE… in read_metadata_()
1389 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &length, FLAC__STREAM_METADATA_LENGT… in read_metadata_()
1393 if(!read_metadata_streaminfo_(decoder, is_last, length)) in read_metadata_()
1396 decoder->private_->has_stream_info = true; in read_metadata_()
1397 …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_()
1398 decoder->private_->do_md5_checking = false; in read_metadata_()
1399 …if(!decoder->private_->is_seeking && decoder->private_->metadata_filter[FLAC__METADATA_TYPE_STREAM… in read_metadata_()
1400 …decoder->private_->metadata_callback(decoder, &decoder->private_->stream_info, decoder->private_->… in read_metadata_()
1404 decoder->private_->has_seek_table = false; in read_metadata_()
1406 if(!read_metadata_seektable_(decoder, is_last, length)) in read_metadata_()
1409 decoder->private_->has_seek_table = true; in read_metadata_()
1410 …if(!decoder->private_->is_seeking && decoder->private_->metadata_filter[FLAC__METADATA_TYPE_SEEKTA… in read_metadata_()
1411 …decoder->private_->metadata_callback(decoder, &decoder->private_->seek_table, decoder->private_->c… in read_metadata_()
1414 FLAC__bool skip_it = !decoder->private_->metadata_filter[type]; in read_metadata_()
1424 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.applicatio… in read_metadata_()
1428 …decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;/*@@@@@@ maybe wrong err… in read_metadata_()
1434 …if(decoder->private_->metadata_filter_ids_count > 0 && has_id_filtered_(decoder, block.data.applic… in read_metadata_()
1439 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, real_length)) in read_metadata_()
1444 FLAC__bitreader_set_limit(decoder->private_->input, real_length*8); in read_metadata_()
1448 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, real_length)) in read_metadata_()
1455 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_()
1458 …else if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.appli… in read_metadata_()
1465 if(!read_metadata_vorbiscomment_(decoder, &block.data.vorbis_comment, real_length)) in read_metadata_()
1469 if(!read_metadata_cuesheet_(decoder, &block.data.cue_sheet)) in read_metadata_()
1473 if(!read_metadata_picture_(decoder, &block.data.picture)) in read_metadata_()
1483 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_()
1486 …else if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.unkno… in read_metadata_()
1493 if(FLAC__bitreader_limit_remaining(decoder->private_->input) > 0) { in read_metadata_()
1497 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA); in read_metadata_()
1498 if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_METADATA) in read_metadata_()
1499 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_metadata_()
1502 FLAC__bitreader_remove_limit(decoder->private_->input); in read_metadata_()
1503 if(ok && !decoder->private_->is_seeking && decoder->private_->metadata_callback) in read_metadata_()
1504 decoder->private_->metadata_callback(decoder, &block, decoder->private_->client_data); in read_metadata_()
1549 …if(!ok) /* anything that unsets "ok" should also make sure decoder->protected_->state is updated */ in read_metadata_()
1556 if(!FLAC__stream_decoder_get_decode_position(decoder, &decoder->private_->first_frame_offset)) in read_metadata_()
1557 decoder->private_->first_frame_offset = 0; in read_metadata_()
1558 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_metadata_()
1564 FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t len… in read_metadata_streaminfo_() argument
1569 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_streaminfo_()
1571 decoder->private_->stream_info.type = FLAC__METADATA_TYPE_STREAMINFO; in read_metadata_streaminfo_()
1572 decoder->private_->stream_info.is_last = is_last; in read_metadata_streaminfo_()
1573 decoder->private_->stream_info.length = length; in read_metadata_streaminfo_()
1576 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, bits)) in read_metadata_streaminfo_()
1578 decoder->private_->stream_info.data.stream_info.min_blocksize = x; in read_metadata_streaminfo_()
1582 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1584 decoder->private_->stream_info.data.stream_info.max_blocksize = x; in read_metadata_streaminfo_()
1588 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1590 decoder->private_->stream_info.data.stream_info.min_framesize = x; in read_metadata_streaminfo_()
1594 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1596 decoder->private_->stream_info.data.stream_info.max_framesize = x; in read_metadata_streaminfo_()
1600 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1602 decoder->private_->stream_info.data.stream_info.sample_rate = x; in read_metadata_streaminfo_()
1606 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1608 decoder->private_->stream_info.data.stream_info.channels = x+1; in read_metadata_streaminfo_()
1612 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO… in read_metadata_streaminfo_()
1614 decoder->private_->stream_info.data.stream_info.bits_per_sample = x+1; in read_metadata_streaminfo_()
1618 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &decoder->private_->stream_info.data… in read_metadata_streaminfo_()
1622 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, decoder->private_->st… in read_metadata_streaminfo_()
1631 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length)) in read_metadata_streaminfo_()
1637 FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t leng… in read_metadata_seektable_() argument
1642 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_seektable_()
1644 decoder->private_->seek_table.type = FLAC__METADATA_TYPE_SEEKTABLE; in read_metadata_seektable_()
1645 decoder->private_->seek_table.is_last = is_last; in read_metadata_seektable_()
1646 decoder->private_->seek_table.length = length; in read_metadata_seektable_()
1649 FLAC__bitreader_limit_invalidate(decoder->private_->input); in read_metadata_seektable_()
1653 …decoder->private_->seek_table.data.seek_table.num_points = length / FLAC__STREAM_METADATA_SEEKPOIN… in read_metadata_seektable_()
1656 …(0 == (decoder->private_->seek_table.data.seek_table.points = safe_realloc_mul_2op_(decoder->priva… in read_metadata_seektable_()
1657 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_seektable_()
1660 for(i = 0; i < decoder->private_->seek_table.data.seek_table.num_points; i++) { in read_metadata_seektable_()
1661 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT… in read_metadata_seektable_()
1663 decoder->private_->seek_table.data.seek_table.points[i].sample_number = xx; in read_metadata_seektable_()
1665 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT… in read_metadata_seektable_()
1667 decoder->private_->seek_table.data.seek_table.points[i].stream_offset = xx; in read_metadata_seektable_()
1669 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_SEEKPOINT_… in read_metadata_seektable_()
1671 decoder->private_->seek_table.data.seek_table.points[i].frame_samples = x; in read_metadata_seektable_()
1673 …length -= (decoder->private_->seek_table.data.seek_table.num_points * FLAC__STREAM_METADATA_SEEKPO… in read_metadata_seektable_()
1680 FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisCo… in read_metadata_vorbiscomment_() argument
1684 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_vorbiscomment_()
1690 …if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->vendor_string.lengt… in read_metadata_vorbiscomment_()
1701 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_vorbiscomment_()
1704 …if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->vendor_string.e… in read_metadata_vorbiscomment_()
1713 if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->num_comments)) in read_metadata_vorbiscomment_()
1725 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_vorbiscomment_()
1740 …if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->comments[i].length)… in read_metadata_vorbiscomment_()
1747 FLAC__bitreader_limit_invalidate(decoder->private_->input); in read_metadata_vorbiscomment_()
1753 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_vorbiscomment_()
1758 …if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->comments[i].ent… in read_metadata_vorbiscomment_()
1773 FLAC__bitreader_limit_invalidate(decoder->private_->input); in read_metadata_vorbiscomment_()
1784 FLAC__bitreader_limit_invalidate(decoder->private_->input); in read_metadata_vorbiscomment_()
1791 FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_CueSheet *obj) in read_metadata_cuesheet_() argument
1795 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_cuesheet_()
1800 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)obj->med… in read_metadata_cuesheet_()
1803 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &obj->lead_in, FLAC__STREAM_METADATA… in read_metadata_cuesheet_()
1806 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_I… in read_metadata_cuesheet_()
1810 …if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_RESE… in read_metadata_cuesheet_()
1813 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_N… in read_metadata_cuesheet_()
1819 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_cuesheet_()
1824 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &track->offset, FLAC__STREAM_METADAT… in read_metadata_cuesheet_()
1827 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_T… in read_metadata_cuesheet_()
1832 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)track->i… in read_metadata_cuesheet_()
1835 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_T… in read_metadata_cuesheet_()
1839 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_T… in read_metadata_cuesheet_()
1843 …if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_TRAC… in read_metadata_cuesheet_()
1846 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_T… in read_metadata_cuesheet_()
1852 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_cuesheet_()
1857 …if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &indx->offset, FLAC__STREAM_METADATA… in read_metadata_cuesheet_()
1860 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_I… in read_metadata_cuesheet_()
1864 …if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_INDE… in read_metadata_cuesheet_()
1874 FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_Picture *obj) in read_metadata_picture_() argument
1878 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_metadata_picture_()
1881 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_TY… in read_metadata_picture_()
1889 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_MI… in read_metadata_picture_()
1891 if(FLAC__bitreader_limit_remaining(decoder->private_->input) < x){ in read_metadata_picture_()
1892 FLAC__bitreader_limit_invalidate(decoder->private_->input); in read_metadata_picture_()
1896 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_picture_()
1900 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)obj->mim… in read_metadata_picture_()
1906 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_DE… in read_metadata_picture_()
1908 if(FLAC__bitreader_limit_remaining(decoder->private_->input) < x){ in read_metadata_picture_()
1909 FLAC__bitreader_limit_invalidate(decoder->private_->input); in read_metadata_picture_()
1913 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_picture_()
1917 if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->description, x)) in read_metadata_picture_()
1923 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->width, FLAC__STREAM_METADATA_P… in read_metadata_picture_()
1927 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->height, FLAC__STREAM_METADATA_… in read_metadata_picture_()
1931 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->depth, FLAC__STREAM_METADATA_P… in read_metadata_picture_()
1935 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->colors, FLAC__STREAM_METADATA_… in read_metadata_picture_()
1939 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &(obj->data_length), FLAC__STREAM_ME… in read_metadata_picture_()
1941 if(FLAC__bitreader_limit_remaining(decoder->private_->input) < obj->data_length){ in read_metadata_picture_()
1942 FLAC__bitreader_limit_invalidate(decoder->private_->input); in read_metadata_picture_()
1946 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_metadata_picture_()
1950 …if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->data, obj->data_… in read_metadata_picture_()
1957 FLAC__bool skip_id3v2_tag_(FLAC__StreamDecoder *decoder) in skip_id3v2_tag_() argument
1963 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 24)) in skip_id3v2_tag_()
1968 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in skip_id3v2_tag_()
1974 if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, skip)) in skip_id3v2_tag_()
1979 FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder) in frame_sync_() argument
1985 if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) { in frame_sync_()
1986 …f(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__bitreader_bits_left_for_byt… in frame_sync_()
1991 if(decoder->private_->cached) { in frame_sync_()
1992 x = (FLAC__uint32)decoder->private_->lookahead; in frame_sync_()
1993 decoder->private_->cached = false; in frame_sync_()
1996 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in frame_sync_()
2000 decoder->private_->header_warmup[0] = (FLAC__byte)x; in frame_sync_()
2001 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in frame_sync_()
2007 decoder->private_->lookahead = (FLAC__byte)x; in frame_sync_()
2008 decoder->private_->cached = true; in frame_sync_()
2011 decoder->private_->header_warmup[1] = (FLAC__byte)x; in frame_sync_()
2012 decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME; in frame_sync_()
2016 FLAC__bitreader_set_framesync_location(decoder->private_->input); in frame_sync_()
2017 if(!FLAC__stream_decoder_get_decode_position(decoder, &decoder->private_->last_seen_framesync)) in frame_sync_()
2018 decoder->private_->last_seen_framesync = 0; in frame_sync_()
2023 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in frame_sync_()
2031 FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_full_de… in read_frame_() argument
2039 decoder->private_->side_subframe_in_use = false; in read_frame_()
2043 frame_crc = FLAC__CRC16_UPDATE(decoder->private_->header_warmup[0], frame_crc); in read_frame_()
2044 frame_crc = FLAC__CRC16_UPDATE(decoder->private_->header_warmup[1], frame_crc); in read_frame_()
2045 FLAC__bitreader_reset_read_crc16(decoder->private_->input, (FLAC__uint16)frame_crc); in read_frame_()
2047 if(!read_frame_header_(decoder)) in read_frame_()
2049 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means we didn't sy… in read_frame_()
2051 …if(!allocate_output_(decoder, decoder->private_->frame.header.blocksize, decoder->private_->frame.… in read_frame_()
2053 for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) { in read_frame_()
2057 uint32_t bps = decoder->private_->frame.header.bits_per_sample; in read_frame_()
2058 switch(decoder->private_->frame.header.channel_assignment) { in read_frame_()
2063 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2068 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2073 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in read_frame_()
2083 if(!read_subframe_(decoder, channel, bps, do_full_decode)){ in read_frame_()
2085 if(decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM) in read_frame_()
2092 if(decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM) in read_frame_()
2093 if(!read_zero_padding_(decoder)) in read_frame_()
2099 if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME) { in read_frame_()
2100 frame_crc = FLAC__bitreader_get_read_crc16(decoder->private_->input); in read_frame_()
2101 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__FRAME_FOOTER_CRC_LEN)) { in read_frame_()
2103 if(decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM) in read_frame_()
2108 if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME && frame_crc == x) { in read_frame_()
2112 undo_channel_coding(decoder); in read_frame_()
2114 for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) { in read_frame_()
2115 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in read_frame_()
2116 int shift_bits = 32 - decoder->private_->frame.header.bits_per_sample; in read_frame_()
2118 if((decoder->private_->output[channel][i] < (INT32_MIN >> shift_bits)) || in read_frame_()
2119 (decoder->private_->output[channel][i] > (INT32_MAX >> shift_bits))) { in read_frame_()
2121 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH); in read_frame_()
2122 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_()
2130 else if (decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME) { in read_frame_()
2132 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH); in read_frame_()
2133 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_()
2138 …if(decoder->private_->last_frame_is_set && decoder->protected_->state == FLAC__STREAM_DECODER_READ… in read_frame_()
2139 …FLAC__ASSERT(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); in read_frame_()
2140 …FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NU… in read_frame_()
2141 …if(decoder->private_->last_frame.header.number.sample_number + decoder->private_->last_frame.heade… in read_frame_()
2142 …mples_needed = decoder->private_->frame.header.number.sample_number - (decoder->private_->last_fra… in read_frame_()
2148 …if(decoder->private_->last_frame.header.sample_rate == decoder->private_->frame.header.sample_rate… in read_frame_()
2149 decoder->private_->last_frame.header.channels == decoder->private_->frame.header.channels && in read_frame_()
2150 …decoder->private_->last_frame.header.bits_per_sample == decoder->private_->frame.header.bits_per_s… in read_frame_()
2151 decoder->private_->last_frame.header.blocksize >= 16) { in read_frame_()
2154 empty_frame.header = decoder->private_->last_frame.header; in read_frame_()
2168 decoder->protected_->blocksize = empty_frame.header.blocksize; in read_frame_()
2171 …decoder->private_->samples_decoded = empty_frame.header.number.sample_number + empty_frame.header.… in read_frame_()
2173 …if(!allocate_output_(decoder, empty_frame.header.blocksize, empty_frame.header.channels, empty_fra… in read_frame_()
2180 … memset(decoder->private_->output[channel], 0, sizeof(FLAC__int32) * empty_frame.header.blocksize); in read_frame_()
2183 …if(write_audio_frame_to_client_(decoder, &empty_frame, (const FLAC__int32 * const *)decoder->priva… in read_frame_()
2184 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_frame_()
2192 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC || decoder->protected_… in read_frame_()
2194 * isn't checked, if the seek fails the decoder will continue anyway */ in read_frame_()
2195 if(!FLAC__bitreader_rewind_to_after_last_seen_framesync(decoder->private_->input)){ in read_frame_()
2199 if(decoder->private_->seek_callback && decoder->private_->last_seen_framesync){ in read_frame_()
2203 if(FLAC__stream_decoder_get_decode_position(decoder, ¤t_decode_position)) in read_frame_()
2204 …fprintf(stderr, "Bitreader was %" PRIu64 " bytes short\n", current_decode_position-decoder->privat… in read_frame_()
2206 …if(decoder->private_->seek_callback(decoder, decoder->private_->last_seen_framesync, decoder->priv… in read_frame_()
2207 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in read_frame_()
2210 if(!FLAC__bitreader_clear(decoder->private_->input)) { in read_frame_()
2211 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_frame_()
2226 if(decoder->private_->next_fixed_block_size) in read_frame_()
2227 decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size; in read_frame_()
2229 /* put the latest values into the public section of the decoder instance */ in read_frame_()
2230 decoder->protected_->channels = decoder->private_->frame.header.channels; in read_frame_()
2231 decoder->protected_->channel_assignment = decoder->private_->frame.header.channel_assignment; in read_frame_()
2232 decoder->protected_->bits_per_sample = decoder->private_->frame.header.bits_per_sample; in read_frame_()
2233 decoder->protected_->sample_rate = decoder->private_->frame.header.sample_rate; in read_frame_()
2234 decoder->protected_->blocksize = decoder->private_->frame.header.blocksize; in read_frame_()
2236 …FLAC__ASSERT(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); in read_frame_()
2237 …decoder->private_->samples_decoded = decoder->private_->frame.header.number.sample_number + decode… in read_frame_()
2241 …if(write_audio_frame_to_client_(decoder, &decoder->private_->frame, (const FLAC__int32 * const *)d… in read_frame_()
2242 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_frame_()
2248 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_()
2252 FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder) in read_frame_header_() argument
2261 FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); in read_frame_header_()
2264 raw_header[0] = decoder->private_->header_warmup[0]; in read_frame_header_()
2265 raw_header[1] = decoder->private_->header_warmup[1]; in read_frame_header_()
2295 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in read_frame_header_()
2299 decoder->private_->lookahead = (FLAC__byte)x; in read_frame_header_()
2300 decoder->private_->cached = true; in read_frame_header_()
2301 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2302 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2313 decoder->private_->frame.header.blocksize = 192; in read_frame_header_()
2319 decoder->private_->frame.header.blocksize = 576 << (x-2); in read_frame_header_()
2333 decoder->private_->frame.header.blocksize = 256 << (x-8); in read_frame_header_()
2342 if(decoder->private_->has_stream_info) in read_frame_header_()
2343 …decoder->private_->frame.header.sample_rate = decoder->private_->stream_info.data.stream_info.samp… in read_frame_header_()
2348 decoder->private_->frame.header.sample_rate = 88200; in read_frame_header_()
2351 decoder->private_->frame.header.sample_rate = 176400; in read_frame_header_()
2354 decoder->private_->frame.header.sample_rate = 192000; in read_frame_header_()
2357 decoder->private_->frame.header.sample_rate = 8000; in read_frame_header_()
2360 decoder->private_->frame.header.sample_rate = 16000; in read_frame_header_()
2363 decoder->private_->frame.header.sample_rate = 22050; in read_frame_header_()
2366 decoder->private_->frame.header.sample_rate = 24000; in read_frame_header_()
2369 decoder->private_->frame.header.sample_rate = 32000; in read_frame_header_()
2372 decoder->private_->frame.header.sample_rate = 44100; in read_frame_header_()
2375 decoder->private_->frame.header.sample_rate = 48000; in read_frame_header_()
2378 decoder->private_->frame.header.sample_rate = 96000; in read_frame_header_()
2386 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2387 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2395 decoder->private_->frame.header.channels = 2; in read_frame_header_()
2398 decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE; in read_frame_header_()
2401 decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE; in read_frame_header_()
2404 decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_MID_SIDE; in read_frame_header_()
2412 decoder->private_->frame.header.channels = (uint32_t)x + 1; in read_frame_header_()
2413 decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT; in read_frame_header_()
2418 if(decoder->private_->has_stream_info) in read_frame_header_()
2419 …decoder->private_->frame.header.bits_per_sample = decoder->private_->stream_info.data.stream_info.… in read_frame_header_()
2424 decoder->private_->frame.header.bits_per_sample = 8; in read_frame_header_()
2427 decoder->private_->frame.header.bits_per_sample = 12; in read_frame_header_()
2433 decoder->private_->frame.header.bits_per_sample = 16; in read_frame_header_()
2436 decoder->private_->frame.header.bits_per_sample = 20; in read_frame_header_()
2439 decoder->private_->frame.header.bits_per_sample = 24; in read_frame_header_()
2442 decoder->private_->frame.header.bits_per_sample = 32; in read_frame_header_()
2459 …(decoder->private_->has_stream_info && decoder->private_->stream_info.data.stream_info.min_blocksi… in read_frame_header_()
2461 if(!FLAC__bitreader_read_utf8_uint64(decoder->private_->input, &xx, raw_header, &raw_header_len)) in read_frame_header_()
2464 decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */ in read_frame_header_()
2465 decoder->private_->cached = true; in read_frame_header_()
2466 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2467 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2470 decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER; in read_frame_header_()
2471 decoder->private_->frame.header.number.sample_number = xx; in read_frame_header_()
2474 if(!FLAC__bitreader_read_utf8_uint32(decoder->private_->input, &x, raw_header, &raw_header_len)) in read_frame_header_()
2477 decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */ in read_frame_header_()
2478 decoder->private_->cached = true; in read_frame_header_()
2479 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); in read_frame_header_()
2480 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2483 decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER; in read_frame_header_()
2484 decoder->private_->frame.header.number.frame_number = x; in read_frame_header_()
2488 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in read_frame_header_()
2493 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &_x, 8)) in read_frame_header_()
2498 decoder->private_->frame.header.blocksize = x+1; in read_frame_header_()
2502 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) in read_frame_header_()
2507 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &_x, 8)) in read_frame_header_()
2513 decoder->private_->frame.header.sample_rate = x*1000; in read_frame_header_()
2515 decoder->private_->frame.header.sample_rate = x; in read_frame_header_()
2517 decoder->private_->frame.header.sample_rate = x*10; in read_frame_header_()
2521 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) 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_()
2534 decoder->private_->next_fixed_block_size = 0; in read_frame_header_()
2535 if(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER) { in read_frame_header_()
2536 x = decoder->private_->frame.header.number.frame_number; in read_frame_header_()
2537 decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER; in read_frame_header_()
2538 if(decoder->private_->fixed_block_size) in read_frame_header_()
2539 …decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->fixed_bloc… in read_frame_header_()
2540 else if(decoder->private_->has_stream_info) { in read_frame_header_()
2541 …if(decoder->private_->stream_info.data.stream_info.min_blocksize == decoder->private_->stream_info… in read_frame_header_()
2542 …decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->stream_inf… in read_frame_header_()
2543 …decoder->private_->next_fixed_block_size = decoder->private_->stream_info.data.stream_info.max_blo… in read_frame_header_()
2549 decoder->private_->frame.header.number.sample_number = 0; in read_frame_header_()
2550 decoder->private_->next_fixed_block_size = decoder->private_->frame.header.blocksize; in read_frame_header_()
2554 …decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->frame.head… in read_frame_header_()
2559 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_frame_header_()
2560 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_frame_header_()
2567 FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool … in read_subframe_() argument
2573 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) /* MAGIC NUMBER */ in read_subframe_()
2581 if(!FLAC__bitreader_read_unary_unsigned(decoder->private_->input, &u)) in read_subframe_()
2583 decoder->private_->frame.subframes[channel].wasted_bits = u+1; in read_subframe_()
2584 if (decoder->private_->frame.subframes[channel].wasted_bits >= bps) { in read_subframe_()
2585 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_()
2586 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2589 bps -= decoder->private_->frame.subframes[channel].wasted_bits; in read_subframe_()
2592 decoder->private_->frame.subframes[channel].wasted_bits = 0; in read_subframe_()
2598 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_()
2599 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2603 if(!read_subframe_constant_(decoder, channel, bps, do_full_decode)) in read_subframe_()
2607 if(!read_subframe_verbatim_(decoder, channel, bps, do_full_decode)) in read_subframe_()
2611 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_subframe_()
2612 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2617 if(decoder->private_->frame.header.blocksize <= predictor_order){ 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 if(!read_subframe_fixed_(decoder, channel, bps, predictor_order, do_full_decode)) in read_subframe_()
2624 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or … in read_subframe_()
2628 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_subframe_()
2629 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2634 if(decoder->private_->frame.header.blocksize <= predictor_order){ in read_subframe_()
2635 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_()
2636 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_()
2639 if(!read_subframe_lpc_(decoder, channel, bps, predictor_order, do_full_decode)) in read_subframe_()
2641 …if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or … in read_subframe_()
2646 x = decoder->private_->frame.subframes[channel].wasted_bits; in read_subframe_()
2648 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in read_subframe_()
2649 uint32_t val = decoder->private_->output[channel][i]; in read_subframe_()
2650 decoder->private_->output[channel][i] = (val << x); in read_subframe_()
2656 FLAC__ASSERT(!decoder->private_->side_subframe_in_use); in read_subframe_()
2657 decoder->private_->side_subframe_in_use = true; in read_subframe_()
2658 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in read_subframe_()
2659 uint64_t val = decoder->private_->output[channel][i]; in read_subframe_()
2660 decoder->private_->side_subframe[i] = (val << x); in read_subframe_()
2668 FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FL… in read_subframe_constant_() argument
2670 FLAC__Subframe_Constant *subframe = &decoder->private_->frame.subframes[channel].data.constant; in read_subframe_constant_()
2674 decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_CONSTANT; in read_subframe_constant_()
2676 if(!FLAC__bitreader_read_raw_int64(decoder->private_->input, &x, bps)) in read_subframe_constant_()
2684 FLAC__int32 *output = decoder->private_->output[channel]; in read_subframe_constant_()
2685 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) in read_subframe_constant_()
2688 FLAC__int64 *output = decoder->private_->side_subframe; in read_subframe_constant_()
2689 decoder->private_->side_subframe_in_use = true; in read_subframe_constant_()
2690 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) in read_subframe_constant_()
2698 FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const… in read_subframe_fixed_() argument
2700 FLAC__Subframe_Fixed *subframe = &decoder->private_->frame.subframes[channel].data.fixed; in read_subframe_fixed_()
2705 decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_FIXED; in read_subframe_fixed_()
2707 subframe->residual = decoder->private_->residual[channel]; in read_subframe_fixed_()
2712 if(!FLAC__bitreader_read_raw_int64(decoder->private_->input, &i64, bps)) in read_subframe_fixed_()
2718 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TY… in read_subframe_fixed_()
2724 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PA… in read_subframe_fixed_()
2726 if((decoder->private_->frame.header.blocksize >> u32 < order) || in read_subframe_fixed_()
2727 (decoder->private_->frame.header.blocksize % (1 << u32) > 0)) { in read_subframe_fixed_()
2728 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_fixed_()
2729 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_fixed_()
2733 …subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_r… in read_subframe_fixed_()
2736 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_subframe_fixed_()
2737 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_fixed_()
2745 …rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, &decoder->priva… in read_subframe_fixed_()
2757 decoder->private_->output[channel][i] = subframe->warmup[i]; in read_subframe_fixed_()
2759 …LAC__fixed_restore_signal(decoder->private_->residual[channel], decoder->private_->frame.header.bl… in read_subframe_fixed_()
2761 …fixed_restore_signal_wide(decoder->private_->residual[channel], decoder->private_->frame.header.bl… in read_subframe_fixed_()
2764 decoder->private_->side_subframe_in_use = true; in read_subframe_fixed_()
2765 memcpy(decoder->private_->side_subframe, subframe->warmup, sizeof(FLAC__int64) * order); in read_subframe_fixed_()
2766 …restore_signal_wide_33bit(decoder->private_->residual[channel], decoder->private_->frame.header.bl… in read_subframe_fixed_()
2773 FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const u… in read_subframe_lpc_() argument
2775 FLAC__Subframe_LPC *subframe = &decoder->private_->frame.subframes[channel].data.lpc; in read_subframe_lpc_()
2781 decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_LPC; in read_subframe_lpc_()
2783 subframe->residual = decoder->private_->residual[channel]; in read_subframe_lpc_()
2788 if(!FLAC__bitreader_read_raw_int64(decoder->private_->input, &i64, bps)) in read_subframe_lpc_()
2794 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__SUBFRAME_LPC_QLP_COEFF_P… in read_subframe_lpc_()
2797 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_lpc_()
2798 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_lpc_()
2804 …if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, FLAC__SUBFRAME_LPC_QLP_SHIFT_LE… in read_subframe_lpc_()
2807 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_lpc_()
2808 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_lpc_()
2815 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, subframe->qlp_coeff_precision)) in read_subframe_lpc_()
2821 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TY… in read_subframe_lpc_()
2827 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PA… in read_subframe_lpc_()
2829 if((decoder->private_->frame.header.blocksize >> u32 < order) || in read_subframe_lpc_()
2830 (decoder->private_->frame.header.blocksize % (1 << u32) > 0)) { in read_subframe_lpc_()
2831 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_subframe_lpc_()
2832 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_lpc_()
2836 …subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_r… in read_subframe_lpc_()
2839 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); in read_subframe_lpc_()
2840 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_subframe_lpc_()
2848 …rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, &decoder->priva… in read_subframe_lpc_()
2860 decoder->private_->output[channel][i] = subframe->warmup[i]; in read_subframe_lpc_()
2863 …decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->q… in read_subframe_lpc_()
2865 …decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->q… in read_subframe_lpc_()
2868 decoder->private_->side_subframe_in_use = true; in read_subframe_lpc_()
2869 memcpy(decoder->private_->side_subframe, subframe->warmup, sizeof(FLAC__int64) * order); in read_subframe_lpc_()
2870 …decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->q… in read_subframe_lpc_()
2877 FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FL… in read_subframe_verbatim_() argument
2879 FLAC__Subframe_Verbatim *subframe = &decoder->private_->frame.subframes[channel].data.verbatim; in read_subframe_verbatim_()
2882 decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM; in read_subframe_verbatim_()
2885 FLAC__int32 x, *residual = decoder->private_->residual[channel]; in read_subframe_verbatim_()
2890 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in read_subframe_verbatim_()
2891 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &x, bps)) in read_subframe_verbatim_()
2898 …memcpy(decoder->private_->output[channel], subframe->data.int32, sizeof(FLAC__int32) * decoder->pr… in read_subframe_verbatim_()
2901 FLAC__int64 x, *side = decoder->private_->side_subframe; in read_subframe_verbatim_()
2905 decoder->private_->side_subframe_in_use = true; in read_subframe_verbatim_()
2907 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in read_subframe_verbatim_()
2908 if(!FLAC__bitreader_read_raw_int64(decoder->private_->input, &x, bps)) in read_subframe_verbatim_()
2917 FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_t predictor_order, … in read_residual_partitioned_rice_() argument
2923 const uint32_t partition_samples = decoder->private_->frame.header.blocksize >> partition_order; in read_residual_partitioned_rice_()
2928 …FLAC__ASSERT(partition_order > 0? partition_samples >= predictor_order : decoder->private_->frame.… in read_residual_partitioned_rice_()
2931 decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; in read_residual_partitioned_rice_()
2937 if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &rice_parameter, plen)) in read_residual_partitioned_rice_()
2943 …if(!FLAC__bitreader_read_rice_signed_block(decoder->private_->input, residual + sample, u, rice_pa… in read_residual_partitioned_rice_()
2944 if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME) { in read_residual_partitioned_rice_()
2947 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_residual_partitioned_rice_()
2948 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_residual_partitioned_rice_()
2957 …if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &rice_parameter, FLAC__ENTROPY_CODIN… in read_residual_partitioned_rice_()
2966 if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i, rice_parameter)) in read_residual_partitioned_rice_()
2977 FLAC__bool read_zero_padding_(FLAC__StreamDecoder *decoder) in read_zero_padding_() argument
2979 if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) { in read_zero_padding_()
2981 …(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &zero, FLAC__bitreader_bits_left_for_b… in read_zero_padding_()
2985 send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); in read_zero_padding_()
2986 decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; in read_zero_padding_()
2995 FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder *)client_data; in read_callback_() local
3000 !decoder->private_->is_ogg && in read_callback_()
3002 …decoder->private_->eof_callback && decoder->private_->eof_callback(decoder, decoder->private_->cli… in read_callback_()
3005 decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM; in read_callback_()
3019 if(decoder->private_->is_seeking && decoder->private_->unparseable_frame_count > 20) { in read_callback_()
3020 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_callback_()
3026 decoder->private_->is_ogg? in read_callback_()
3027 read_callback_ogg_aspect_(decoder, buffer, bytes) : in read_callback_()
3029 decoder->private_->read_callback(decoder, buffer, bytes, decoder->private_->client_data) in read_callback_()
3032 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_callback_()
3041 !decoder->private_->is_ogg && in read_callback_()
3043 …decoder->private_->eof_callback && decoder->private_->eof_callback(decoder, decoder->private_->cli… in read_callback_()
3046 decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM; in read_callback_()
3058 decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; in read_callback_()
3062 * for Ogg FLAC. This is because the ogg decoder aspect can lose sync in read_callback_()
3067 * So to keep the decoder from stopping at this point we gate the call in read_callback_()
3068 * to the eof_callback and let the Ogg decoder aspect set the in read_callback_()
3076 * decoder, having overflows in this section is unavoidable. Also,
3081 void undo_channel_coding(FLAC__StreamDecoder *decoder) { in undo_channel_coding() argument
3083 switch(decoder->private_->frame.header.channel_assignment) { in undo_channel_coding()
3088 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in undo_channel_coding()
3089 …FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->fram… in undo_channel_coding()
3090 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) in undo_channel_coding()
3091 if(decoder->private_->side_subframe_in_use) in undo_channel_coding()
3092 …decoder->private_->output[1][i] = decoder->private_->output[0][i] - decoder->private_->side_subfra… in undo_channel_coding()
3094 …decoder->private_->output[1][i] = decoder->private_->output[0][i] - decoder->private_->output[1][i… in undo_channel_coding()
3097 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in undo_channel_coding()
3098 …FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->fram… in undo_channel_coding()
3099 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) in undo_channel_coding()
3100 if(decoder->private_->side_subframe_in_use) in undo_channel_coding()
3101 …decoder->private_->output[0][i] = decoder->private_->output[1][i] + decoder->private_->side_subfra… in undo_channel_coding()
3103 decoder->private_->output[0][i] += decoder->private_->output[1][i]; in undo_channel_coding()
3106 FLAC__ASSERT(decoder->private_->frame.header.channels == 2); in undo_channel_coding()
3107 …FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->fram… in undo_channel_coding()
3108 for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { in undo_channel_coding()
3109 if(!decoder->private_->side_subframe_in_use){ in undo_channel_coding()
3111 mid = decoder->private_->output[0][i]; in undo_channel_coding()
3112 side = decoder->private_->output[1][i]; in undo_channel_coding()
3115 decoder->private_->output[0][i] = (mid + side) >> 1; in undo_channel_coding()
3116 decoder->private_->output[1][i] = (mid - side) >> 1; in undo_channel_coding()
3120 mid = ((uint64_t)decoder->private_->output[0][i]) << 1; in undo_channel_coding()
3121 mid |= (decoder->private_->side_subframe[i] & 1); /* i.e. if 'side' is odd... */ in undo_channel_coding()
3122 decoder->private_->output[0][i] = (mid + decoder->private_->side_subframe[i]) >> 1; in undo_channel_coding()
3123 decoder->private_->output[1][i] = (mid - decoder->private_->side_subframe[i]) >> 1; in undo_channel_coding()
3134 FLAC__StreamDecoderReadStatus read_callback_ogg_aspect_(const FLAC__StreamDecoder *decoder, FLAC__b… in read_callback_ogg_aspect_() argument
3136 …spect_read_callback_wrapper(&decoder->protected_->ogg_decoder_aspect, buffer, bytes, read_callback… in read_callback_ogg_aspect_()
3141 * FLAC decoder catch the error in read_callback_ogg_aspect_()
3162 FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder*)void_decoder; in read_callback_proxy_() local
3164 switch(decoder->private_->read_callback(decoder, buffer, bytes, client_data)) { in read_callback_proxy_()
3179 FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder *decoder, const FLA… in write_audio_frame_to_client_() argument
3181 decoder->private_->last_frame = *frame; /* save the frame */ in write_audio_frame_to_client_()
3182 decoder->private_->last_frame_is_set = true; in write_audio_frame_to_client_()
3183 if(decoder->private_->is_seeking) { in write_audio_frame_to_client_()
3186 FLAC__uint64 target_sample = decoder->private_->target_sample; in write_audio_frame_to_client_()
3191 decoder->private_->got_a_frame = true; in write_audio_frame_to_client_()
3196 decoder->private_->is_seeking = false; in write_audio_frame_to_client_()
3203 decoder->private_->last_frame.header.blocksize -= delta; in write_audio_frame_to_client_()
3204 decoder->private_->last_frame.header.number.sample_number += (FLAC__uint64)delta; in write_audio_frame_to_client_()
3206 …return decoder->private_->write_callback(decoder, &decoder->private_->last_frame, newbuffer, decod… in write_audio_frame_to_client_()
3210 … return decoder->private_->write_callback(decoder, frame, buffer, decoder->private_->client_data); in write_audio_frame_to_client_()
3222 if(!decoder->private_->has_stream_info) in write_audio_frame_to_client_()
3223 decoder->private_->do_md5_checking = false; in write_audio_frame_to_client_()
3224 if(decoder->private_->do_md5_checking) { in write_audio_frame_to_client_()
3225 …if(!FLAC__MD5Accumulate(&decoder->private_->md5context, buffer, frame->header.channels, frame->hea… in write_audio_frame_to_client_()
3228 return decoder->private_->write_callback(decoder, frame, buffer, decoder->private_->client_data); in write_audio_frame_to_client_()
3232 void send_error_to_client_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus statu… in send_error_to_client_() argument
3234 if(!decoder->private_->is_seeking) in send_error_to_client_()
3235 decoder->private_->error_callback(decoder, status, decoder->private_->client_data); in send_error_to_client_()
3237 decoder->private_->unparseable_frame_count++; in send_error_to_client_()
3240 FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC_… in seek_to_absolute_sample_() argument
3242 …FLAC__uint64 first_frame_offset = decoder->private_->first_frame_offset, lower_bound, upper_bound,… in seek_to_absolute_sample_()
3247 const FLAC__uint64 total_samples = FLAC__stream_decoder_get_total_samples(decoder); in seek_to_absolute_sample_()
3248 const uint32_t min_blocksize = decoder->private_->stream_info.data.stream_info.min_blocksize; in seek_to_absolute_sample_()
3249 const uint32_t max_blocksize = decoder->private_->stream_info.data.stream_info.max_blocksize; in seek_to_absolute_sample_()
3250 const uint32_t max_framesize = decoder->private_->stream_info.data.stream_info.max_framesize; in seek_to_absolute_sample_()
3251 const uint32_t min_framesize = decoder->private_->stream_info.data.stream_info.min_framesize; in seek_to_absolute_sample_()
3253 uint32_t channels = FLAC__stream_decoder_get_channels(decoder); in seek_to_absolute_sample_()
3254 uint32_t bps = FLAC__stream_decoder_get_bits_per_sample(decoder); in seek_to_absolute_sample_()
3255 …const FLAC__StreamMetadata_SeekTable *seek_table = decoder->private_->has_seek_table? &decoder->pr… in seek_to_absolute_sample_()
3259 channels = decoder->private_->stream_info.data.stream_info.channels; in seek_to_absolute_sample_()
3261 bps = decoder->private_->stream_info.data.stream_info.bits_per_sample; in seek_to_absolute_sample_()
3291 if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC && in seek_to_absolute_sample_()
3292 decoder->private_->samples_decoded != 0) { in seek_to_absolute_sample_()
3293 if(target_sample < decoder->private_->samples_decoded) { in seek_to_absolute_sample_()
3294 if(FLAC__stream_decoder_get_decode_position(decoder, &upper_bound)) in seek_to_absolute_sample_()
3295 upper_bound_sample = decoder->private_->samples_decoded; in seek_to_absolute_sample_()
3297 if(FLAC__stream_decoder_get_decode_position(decoder, &lower_bound)) in seek_to_absolute_sample_()
3298 lower_bound_sample = decoder->private_->samples_decoded; in seek_to_absolute_sample_()
3369 decoder->private_->target_sample = target_sample; in seek_to_absolute_sample_()
3371 /* check whether decoder is still valid so bad state isn't overwritten in seek_to_absolute_sample_()
3373 if(decoder->protected_->state == FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR || in seek_to_absolute_sample_()
3374 decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED) in seek_to_absolute_sample_()
3380 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3403 …if(decoder->private_->seek_callback(decoder, (FLAC__uint64)pos, decoder->private_->client_data) !=… in seek_to_absolute_sample_()
3404 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3407 if(!FLAC__stream_decoder_flush(decoder)) { in seek_to_absolute_sample_()
3417 decoder->private_->unparseable_frame_count = 0; in seek_to_absolute_sample_()
3418 …C__stream_decoder_process_single(decoder) || decoder->protected_->state == FLAC__STREAM_DECODER_AB… in seek_to_absolute_sample_()
3420 …if(decoder->protected_->state != FLAC__STREAM_DECODER_ABORTED && decoder->private_->eof_callback(d… in seek_to_absolute_sample_()
3421 /* decoder has hit end of stream while processing corrupt in seek_to_absolute_sample_()
3429 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3436 …/* actually, we could have got_a_frame if our decoder is at FLAC__STREAM_DECODER_END_OF_STREAM so … in seek_to_absolute_sample_()
3437 if(!decoder->private_->is_seeking) in seek_to_absolute_sample_()
3440 …FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NU… in seek_to_absolute_sample_()
3441 this_frame_sample = decoder->private_->last_frame.header.number.sample_number; in seek_to_absolute_sample_()
3443 …if(this_frame_sample + decoder->private_->last_frame.header.blocksize >= upper_bound_sample && !fi… in seek_to_absolute_sample_()
3446 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3458 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3464 upper_bound_sample = this_frame_sample + decoder->private_->last_frame.header.blocksize; in seek_to_absolute_sample_()
3466 if(!FLAC__stream_decoder_get_decode_position(decoder, &upper_bound)) { in seek_to_absolute_sample_()
3467 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3473 lower_bound_sample = this_frame_sample + decoder->private_->last_frame.header.blocksize; in seek_to_absolute_sample_()
3474 if(!FLAC__stream_decoder_get_decode_position(decoder, &lower_bound)) { in seek_to_absolute_sample_()
3475 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_()
3486 FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, F… in seek_to_absolute_sample_ogg_() argument
3489 FLAC__uint64 left_sample = 0, right_sample = FLAC__stream_decoder_get_total_samples(decoder); in seek_to_absolute_sample_ogg_()
3515 decoder->private_->target_sample = target_sample; in seek_to_absolute_sample_ogg_()
3520 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3545 …if(decoder->private_->seek_callback((FLAC__StreamDecoder*)decoder, (FLAC__uint64)pos, decoder->pri… in seek_to_absolute_sample_ogg_()
3546 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3549 if(!FLAC__stream_decoder_flush(decoder)) { in seek_to_absolute_sample_ogg_()
3558 decoder->private_->got_a_frame = false; in seek_to_absolute_sample_ogg_()
3559 if(!FLAC__stream_decoder_process_single(decoder) || in seek_to_absolute_sample_ogg_()
3560 decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED) { in seek_to_absolute_sample_ogg_()
3561 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3564 if(!decoder->private_->got_a_frame) { in seek_to_absolute_sample_ogg_()
3577 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3582 else if(!decoder->private_->is_seeking) { in seek_to_absolute_sample_ogg_()
3586 this_frame_sample = decoder->private_->last_frame.header.number.sample_number; in seek_to_absolute_sample_ogg_()
3587 …FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NU… in seek_to_absolute_sample_ogg_()
3602 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3611 decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; in seek_to_absolute_sample_ogg_()
3624 FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte bu… in file_read_callback_() argument
3629 *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, decoder->private_->file); in file_read_callback_()
3630 if(ferror(decoder->private_->file)) in file_read_callback_()
3641 FLAC__StreamDecoderSeekStatus file_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 … in file_seek_callback_() argument
3645 if(decoder->private_->file == stdin) in file_seek_callback_()
3647 else if(fseeko(decoder->private_->file, (FLAC__off_t)absolute_byte_offset, SEEK_SET) < 0) in file_seek_callback_()
3653 FLAC__StreamDecoderTellStatus file_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 … in file_tell_callback_() argument
3658 if(decoder->private_->file == stdin) in file_tell_callback_()
3660 else if((pos = ftello(decoder->private_->file)) < 0) in file_tell_callback_()
3668 FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FLAC__uin… in file_length_callback_() argument
3673 if(decoder->private_->file == stdin) in file_length_callback_()
3677 if(flac_fstat(fileno(decoder->private_->file), &filestats) != 0) in file_length_callback_()
3679 filestats.st_size = _filelengthi64(fileno(decoder->private_->file)); in file_length_callback_()
3689 FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data) in file_eof_callback_() argument
3693 return feof(decoder->private_->file)? true : false; in file_eof_callback_()