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

Function save_bits

libavcodec/wmaprodec.c:1569–1614  ·  view source on GitHub ↗

*@brief Fill the bit reservoir with a (partial) frame. *@param s codec context *@param gb bitstream reader context *@param len length of the partial frame *@param append decides whether to reset the buffer or not */

Source from the content-addressed store, hash-verified

1567 *@param append decides whether to reset the buffer or not
1568 */
1569static void save_bits(WMAProDecodeCtx *s, GetBitContext* gb, int len,
1570 int append)
1571{
1572 int buflen;
1573
1574 /** when the frame data does not need to be concatenated, the input buffer
1575 is reset and additional bits from the previous frame are copied
1576 and skipped later so that a fast byte copy is possible */
1577
1578 if (!append) {
1579 s->frame_offset = get_bits_count(gb) & 7;
1580 s->num_saved_bits = s->frame_offset;
1581 init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
1582 buflen = (s->num_saved_bits + len + 7) >> 3;
1583 } else
1584 buflen = (put_bits_count(&s->pb) + len + 7) >> 3;
1585
1586 if (len <= 0 || buflen > MAX_FRAMESIZE) {
1587 avpriv_request_sample(s->avctx, "Too small input buffer");
1588 s->packet_loss = 1;
1589 return;
1590 }
1591
1592 av_assert0(len <= put_bits_left(&s->pb));
1593
1594 s->num_saved_bits += len;
1595 if (!append) {
1596 ff_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3),
1597 s->num_saved_bits);
1598 } else {
1599 int align = 8 - (get_bits_count(gb) & 7);
1600 align = FFMIN(align, len);
1601 put_bits(&s->pb, align, get_bits(gb, align));
1602 len -= align;
1603 ff_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), len);
1604 }
1605 skip_bits_long(gb, len);
1606
1607 {
1608 PutBitContext tmp = s->pb;
1609 flush_put_bits(&tmp);
1610 }
1611
1612 init_get_bits(&s->gb, s->frame_data, s->num_saved_bits);
1613 skip_bits(&s->gb, s->frame_offset);
1614}
1615
1616static int decode_packet(AVCodecContext *avctx, WMAProDecodeCtx *s,
1617 AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)

Callers 1

decode_packetFunction · 0.70

Calls 12

get_bits_countFunction · 0.85
init_put_bitsFunction · 0.85
put_bits_countFunction · 0.85
avpriv_request_sampleFunction · 0.85
put_bits_leftFunction · 0.85
ff_copy_bitsFunction · 0.85
skip_bits_longFunction · 0.85
flush_put_bitsFunction · 0.85
init_get_bitsFunction · 0.85
skip_bitsFunction · 0.85
put_bitsFunction · 0.70
get_bitsFunction · 0.70

Tested by

no test coverage detected