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

Function save_bits

libavcodec/wmalosslessdec.c:1140–1183  ·  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

1138 * @param append decides whether to reset the buffer or not
1139 */
1140static void save_bits(WmallDecodeCtx *s, GetBitContext* gb, int len,
1141 int append)
1142{
1143 int buflen;
1144 PutBitContext tmp;
1145
1146 /* when the frame data does not need to be concatenated, the input buffer
1147 is reset and additional bits from the previous frame are copied
1148 and skipped later so that a fast byte copy is possible */
1149
1150 if (!append) {
1151 s->frame_offset = get_bits_count(gb) & 7;
1152 s->num_saved_bits = s->frame_offset;
1153 init_put_bits(&s->pb, s->frame_data, s->max_frame_size);
1154 }
1155
1156 buflen = (s->num_saved_bits + len + 8) >> 3;
1157
1158 if (len <= 0 || buflen > s->max_frame_size) {
1159 avpriv_request_sample(s->avctx, "Too small input buffer");
1160 s->packet_loss = 1;
1161 s->num_saved_bits = 0;
1162 return;
1163 }
1164
1165 s->num_saved_bits += len;
1166 if (!append) {
1167 ff_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3),
1168 s->num_saved_bits);
1169 } else {
1170 int align = 8 - (get_bits_count(gb) & 7);
1171 align = FFMIN(align, len);
1172 put_bits(&s->pb, align, get_bits(gb, align));
1173 len -= align;
1174 ff_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), len);
1175 }
1176 skip_bits_long(gb, len);
1177
1178 tmp = s->pb;
1179 flush_put_bits(&tmp);
1180
1181 init_get_bits(&s->gb, s->frame_data, s->num_saved_bits);
1182 skip_bits(&s->gb, s->frame_offset);
1183}
1184
1185static int decode_packet(AVCodecContext *avctx, AVFrame *rframe,
1186 int *got_frame_ptr, AVPacket* avpkt)

Callers 1

decode_packetFunction · 0.70

Calls 10

get_bits_countFunction · 0.85
init_put_bitsFunction · 0.85
avpriv_request_sampleFunction · 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