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

Function decode_subframe_length

libavcodec/wmaprodec.c:613–642  ·  view source on GitHub ↗

*@brief Decode the subframe length. *@param s context *@param offset sample offset in the frame *@return decoded subframe length on success, < 0 in case of an error */

Source from the content-addressed store, hash-verified

611 *@return decoded subframe length on success, < 0 in case of an error
612 */
613static int decode_subframe_length(WMAProDecodeCtx *s, int offset)
614{
615 int frame_len_shift = 0;
616 int subframe_len;
617
618 /** no need to read from the bitstream when only one length is possible */
619 if (offset == s->samples_per_frame - s->min_samples_per_subframe)
620 return s->min_samples_per_subframe;
621
622 if (get_bits_left(&s->gb) < 1)
623 return AVERROR_INVALIDDATA;
624
625 /** 1 bit indicates if the subframe is of maximum length */
626 if (s->max_subframe_len_bit) {
627 if (get_bits1(&s->gb))
628 frame_len_shift = 1 + get_bits(&s->gb, s->subframe_len_bits-1);
629 } else
630 frame_len_shift = get_bits(&s->gb, s->subframe_len_bits);
631
632 subframe_len = s->samples_per_frame >> frame_len_shift;
633
634 /** sanity check the length */
635 if (subframe_len < s->min_samples_per_subframe ||
636 subframe_len > s->samples_per_frame) {
637 av_log(s->avctx, AV_LOG_ERROR, "broken frame: subframe_len %i\n",
638 subframe_len);
639 return AVERROR_INVALIDDATA;
640 }
641 return subframe_len;
642}
643
644/**
645 *@brief Decode how the data in the frame is split into subframes.

Callers 1

decode_tilehdrFunction · 0.70

Calls 4

get_bits_leftFunction · 0.85
get_bits1Function · 0.85
av_logFunction · 0.85
get_bitsFunction · 0.70

Tested by

no test coverage detected