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

Function wavpack_decode_block

libavcodec/wavpack.c:1089–1612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1087}
1088
1089static int wavpack_decode_block(AVCodecContext *avctx, AVFrame *frame, int block_no,
1090 const uint8_t *buf, int buf_size, int *new_progress)
1091{
1092 WavpackContext *wc = avctx->priv_data;
1093 WavpackFrameContext *s;
1094 GetByteContext gb;
1095 enum AVSampleFormat sample_fmt;
1096 void *samples_l = NULL, *samples_r = NULL;
1097 int ret;
1098 int got_terms = 0, got_weights = 0, got_samples = 0,
1099 got_entropy = 0, got_pcm = 0, got_float = 0, got_hybrid = 0;
1100 int got_dsd = 0;
1101 int i, j, id, size, ssize, weights, t;
1102 int bpp, chan = 0, orig_bpp, sample_rate = 0, rate_x = 1, dsd_mode = 0;
1103 int multiblock;
1104 uint64_t chmask = 0;
1105
1106 if (block_no >= wc->fdec_num && wv_alloc_frame_context(wc) < 0) {
1107 av_log(avctx, AV_LOG_ERROR, "Error creating frame decode context\n");
1108 return AVERROR_INVALIDDATA;
1109 }
1110
1111 s = wc->fdec[block_no];
1112
1113 memset(s->decorr, 0, MAX_TERMS * sizeof(Decorr));
1114 memset(s->ch, 0, sizeof(s->ch));
1115 s->extra_bits = 0;
1116 s->and = s->or = s->shift = 0;
1117 s->got_extra_bits = 0;
1118
1119 bytestream2_init(&gb, buf, buf_size);
1120
1121 s->samples = bytestream2_get_le32(&gb);
1122 if (s->samples != wc->samples) {
1123 av_log(avctx, AV_LOG_ERROR, "Mismatching number of samples in "
1124 "a sequence: %d and %d\n", wc->samples, s->samples);
1125 return AVERROR_INVALIDDATA;
1126 }
1127 s->frame_flags = bytestream2_get_le32(&gb);
1128
1129 if (s->frame_flags & (WV_FLOAT_DATA | WV_DSD_DATA))
1130 sample_fmt = AV_SAMPLE_FMT_FLTP;
1131 else if ((s->frame_flags & 0x03) <= 1)
1132 sample_fmt = AV_SAMPLE_FMT_S16P;
1133 else
1134 sample_fmt = AV_SAMPLE_FMT_S32P;
1135
1136 if (wc->ch_offset && avctx->sample_fmt != sample_fmt)
1137 return AVERROR_INVALIDDATA;
1138
1139 bpp = av_get_bytes_per_sample(sample_fmt);
1140 orig_bpp = ((s->frame_flags & 0x03) + 1) << 3;
1141 multiblock = (s->frame_flags & WV_SINGLE_BLOCK) != WV_SINGLE_BLOCK;
1142
1143 s->stereo = !(s->frame_flags & WV_MONO);
1144 s->stereo_in = (s->frame_flags & WV_FALSE_STEREO) ? 0 : s->stereo;
1145 s->joint = s->frame_flags & WV_JOINT_STEREO;
1146 s->hybrid = s->frame_flags & WV_HYBRID_MODE;

Callers 1

wavpack_decode_frameFunction · 0.85

Calls 15

wv_alloc_frame_contextFunction · 0.85
av_logFunction · 0.85
bytestream2_initFunction · 0.85
av_get_bytes_per_sampleFunction · 0.85
bytestream2_skipFunction · 0.85
wp_exp2Function · 0.85
bytestream2_get_bufferFunction · 0.85
init_get_bits8Function · 0.85
get_bits_longFunction · 0.85
get_bits_leftFunction · 0.85

Tested by

no test coverage detected