MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / wavpack_decode_frame

Function wavpack_decode_frame

libavcodec/wavpack.c:675–1019  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

673}
674
675static int wavpack_decode_frame(AVCodecContext *avctx,
676 void *data, int *data_size,
677 AVPacket *avpkt)
678{
679 const uint8_t *buf = avpkt->data;
680 int buf_size = avpkt->size;
681 WavpackContext *s = avctx->priv_data;
682 void *samples = data;
683 int samplecount;
684 int got_terms = 0, got_weights = 0, got_samples = 0, got_entropy = 0, got_bs = 0, got_float = 0;
685 int got_hybrid = 0;
686 const uint8_t* buf_end = buf + buf_size;
687 int i, j, id, size, ssize, weights, t;
688 int bpp;
689
690 if (buf_size == 0){
691 *data_size = 0;
692 return 0;
693 }
694
695 if(!s->samples_left){
696 memset(s->decorr, 0, MAX_TERMS * sizeof(Decorr));
697 memset(s->ch, 0, sizeof(s->ch));
698 s->extra_bits = 0;
699 s->and = s->or = s->shift = 0;
700 s->got_extra_bits = 0;
701 }
702
703 s->samples = AV_RL32(buf); buf += 4;
704 if(!s->samples){
705 *data_size = 0;
706 return buf_size;
707 }
708 s->frame_flags = AV_RL32(buf); buf += 4;
709 if(s->frame_flags&0x80){
710 bpp = sizeof(float);
711 avctx->sample_fmt = SAMPLE_FMT_FLT;
712 } else if((s->frame_flags&0x03) <= 1){
713 bpp = 2;
714 avctx->sample_fmt = SAMPLE_FMT_S16;
715 } else {
716 bpp = 4;
717 avctx->sample_fmt = SAMPLE_FMT_S32;
718 }
719 s->stereo_in = (s->frame_flags & WV_FALSE_STEREO) ? 0 : s->stereo;
720 s->joint = s->frame_flags & WV_JOINT_STEREO;
721 s->hybrid = s->frame_flags & WV_HYBRID_MODE;
722 s->hybrid_bitrate = s->frame_flags & WV_HYBRID_BITRATE;
723 s->post_shift = 8 * (bpp-1-(s->frame_flags&0x03)) + ((s->frame_flags >> 13) & 0x1f);
724 s->CRC = AV_RL32(buf); buf += 4;
725
726 s->max_samples = *data_size / (bpp * avctx->channels);
727 s->max_samples = FFMIN(s->max_samples, s->samples);
728 if(s->samples_left > 0){
729 s->max_samples = FFMIN(s->max_samples, s->samples_left);
730 buf = buf_end;
731 }
732

Callers

nothing calls this directly

Calls 10

av_logFunction · 0.85
wp_exp2Function · 0.85
init_get_bitsFunction · 0.85
get_bits_longFunction · 0.85
get_bits_leftFunction · 0.85
skip_bits_longFunction · 0.85
wv_unpack_stereoFunction · 0.85
wv_unpack_monoFunction · 0.85
AV_RL32Function · 0.50
AV_RL16Function · 0.50

Tested by

no test coverage detected