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

Function decode_subframe

libavcodec/flacdec.c:424–481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

422}
423
424static inline int decode_subframe(FLACContext *s, int channel)
425{
426 int type, wasted = 0;
427 int i, tmp;
428
429 s->curr_bps = s->bps;
430 if (channel == 0) {
431 if (s->ch_mode == FLAC_CHMODE_RIGHT_SIDE)
432 s->curr_bps++;
433 } else {
434 if (s->ch_mode == FLAC_CHMODE_LEFT_SIDE || s->ch_mode == FLAC_CHMODE_MID_SIDE)
435 s->curr_bps++;
436 }
437
438 if (get_bits1(&s->gb)) {
439 av_log(s->avctx, AV_LOG_ERROR, "invalid subframe padding\n");
440 return -1;
441 }
442 type = get_bits(&s->gb, 6);
443
444 if (get_bits1(&s->gb)) {
445 wasted = 1;
446 while (!get_bits1(&s->gb))
447 wasted++;
448 s->curr_bps -= wasted;
449 }
450 if (s->curr_bps > 32) {
451 av_log_missing_feature(s->avctx, "decorrelated bit depth > 32", 0);
452 return -1;
453 }
454
455//FIXME use av_log2 for types
456 if (type == 0) {
457 tmp = get_sbits_long(&s->gb, s->curr_bps);
458 for (i = 0; i < s->blocksize; i++)
459 s->decoded[channel][i] = tmp;
460 } else if (type == 1) {
461 for (i = 0; i < s->blocksize; i++)
462 s->decoded[channel][i] = get_sbits_long(&s->gb, s->curr_bps);
463 } else if ((type >= 8) && (type <= 12)) {
464 if (decode_subframe_fixed(s, channel, type & ~0x8) < 0)
465 return -1;
466 } else if (type >= 32) {
467 if (decode_subframe_lpc(s, channel, (type & ~0x20)+1) < 0)
468 return -1;
469 } else {
470 av_log(s->avctx, AV_LOG_ERROR, "invalid coding type\n");
471 return -1;
472 }
473
474 if (wasted) {
475 int i;
476 for (i = 0; i < s->blocksize; i++)
477 s->decoded[channel][i] <<= wasted;
478 }
479
480 return 0;
481}

Callers 1

decode_frameFunction · 0.70

Calls 7

get_bits1Function · 0.85
av_logFunction · 0.85
get_bitsFunction · 0.85
av_log_missing_featureFunction · 0.85
get_sbits_longFunction · 0.85
decode_subframe_fixedFunction · 0.85
decode_subframe_lpcFunction · 0.70

Tested by

no test coverage detected