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

Function wv_get_value

libavcodec/wavpack.c:261–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259}
260
261static int wv_get_value(WavpackContext *ctx, GetBitContext *gb, int channel, int *last)
262{
263 int t, t2;
264 int sign, base, add, ret;
265 WvChannel *c = &ctx->ch[channel];
266
267 *last = 0;
268
269 if((ctx->ch[0].median[0] < 2U) && (ctx->ch[1].median[0] < 2U) && !ctx->zero && !ctx->one){
270 if(ctx->zeroes){
271 ctx->zeroes--;
272 if(ctx->zeroes){
273 c->slow_level -= LEVEL_DECAY(c->slow_level);
274 return 0;
275 }
276 }else{
277 t = get_unary_0_33(gb);
278 if(t >= 2) t = get_bits(gb, t - 1) | (1 << (t-1));
279 ctx->zeroes = t;
280 if(ctx->zeroes){
281 memset(ctx->ch[0].median, 0, sizeof(ctx->ch[0].median));
282 memset(ctx->ch[1].median, 0, sizeof(ctx->ch[1].median));
283 c->slow_level -= LEVEL_DECAY(c->slow_level);
284 return 0;
285 }
286 }
287 }
288
289 if(get_bits_count(gb) >= ctx->data_size){
290 *last = 1;
291 return 0;
292 }
293
294 if(ctx->zero){
295 t = 0;
296 ctx->zero = 0;
297 }else{
298 t = get_unary_0_33(gb);
299 if(get_bits_count(gb) >= ctx->data_size){
300 *last = 1;
301 return 0;
302 }
303 if(t == 16) {
304 t2 = get_unary_0_33(gb);
305 if(t2 < 2) t += t2;
306 else t += get_bits(gb, t2 - 1) | (1 << (t2 - 1));
307 }
308
309 if(ctx->one){
310 ctx->one = t&1;
311 t = (t>>1) + 1;
312 }else{
313 ctx->one = t&1;
314 t >>= 1;
315 }
316 ctx->zero = !ctx->one;
317 }
318

Callers 2

wv_unpack_stereoFunction · 0.85
wv_unpack_monoFunction · 0.85

Calls 7

get_unary_0_33Function · 0.85
get_bitsFunction · 0.85
get_bits_countFunction · 0.85
update_error_limitFunction · 0.85
get_tailFunction · 0.85
get_bits1Function · 0.85
wp_log2Function · 0.85

Tested by

no test coverage detected