MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / mad_frame_decode

Function mad_frame_decode

modules/data/mp3/libmad/frame.c:434–479  ·  view source on GitHub ↗

* NAME: frame->decode() * DESCRIPTION: decode a single frame from a bitstream */

Source from the content-addressed store, hash-verified

432 * DESCRIPTION: decode a single frame from a bitstream
433 */
434int mad_frame_decode(struct mad_frame *frame, struct mad_stream *stream)
435{
436 frame->options = stream->options;
437
438 /* header() */
439 /* error_check() */
440
441 if (!(frame->header.flags & MAD_FLAG_INCOMPLETE) &&
442 mad_header_decode(&frame->header, stream) == -1)
443 goto fail;
444
445 /* audio_data() */
446
447 frame->header.flags &= ~MAD_FLAG_INCOMPLETE;
448
449 // EFP3 - On non-MP3 frames, abort instead of crash..we removed MP-II/MP-I decoders
450 if (!decoder_table[frame->header.layer - 1]) {
451 goto fail;
452 }
453
454 if (decoder_table[frame->header.layer - 1](stream, frame) == -1) {
455 if (!MAD_RECOVERABLE(stream->error))
456 stream->next_frame = stream->this_frame;
457
458 goto fail;
459 }
460
461 /* ancillary_data() */
462
463 if (frame->header.layer != MAD_LAYER_III) {
464 struct mad_bitptr next_frame;
465
466 mad_bit_init(&next_frame, stream->next_frame);
467
468 stream->anc_ptr = stream->ptr;
469 stream->anc_bitlen = mad_bit_length(&stream->ptr, &next_frame);
470
471 mad_bit_finish(&next_frame);
472 }
473
474 return 0;
475
476 fail:
477 stream->anc_bitlen = 0;
478 return -1;
479}
480
481/*
482 * NAME: frame->mute()

Callers 2

xs_mp3_decodeFunction · 0.85
run_syncFunction · 0.85

Calls 3

mad_header_decodeFunction · 0.85
mad_bit_initFunction · 0.85
mad_bit_lengthFunction · 0.85

Tested by

no test coverage detected