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

Function mp_decode_frame

libavcodec/motionpixels.c:282–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282static int mp_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
283 int *got_frame, AVPacket *avpkt)
284{
285 const uint8_t *buf = avpkt->data;
286 int buf_size = avpkt->size;
287 MotionPixelsContext *mp = avctx->priv_data;
288 GetBitContext gb;
289 int i, count1, count2, sz, ret;
290
291 if ((ret = ff_reget_buffer(avctx, mp->frame, 0)) < 0)
292 return ret;
293
294 /* le32 bitstream msb first */
295 av_fast_padded_malloc(&mp->bswapbuf, &mp->bswapbuf_size, buf_size);
296 if (!mp->bswapbuf)
297 return AVERROR(ENOMEM);
298 mp->bdsp.bswap_buf((uint32_t *) mp->bswapbuf, (const uint32_t *) buf,
299 buf_size / 4);
300 if (buf_size & 3)
301 memcpy(mp->bswapbuf + (buf_size & ~3), buf + (buf_size & ~3), buf_size & 3);
302 init_get_bits(&gb, mp->bswapbuf, buf_size * 8);
303
304 memset(mp->changes_map, 0, avctx->width * avctx->height);
305 for (i = !(avctx->extradata[1] & 2); i < 2; ++i) {
306 count1 = get_bits(&gb, 12);
307 count2 = get_bits(&gb, 12);
308 mp_read_changes_map(mp, &gb, count1, 8, i);
309 mp_read_changes_map(mp, &gb, count2, 4, i);
310 }
311
312 mp->codes_count = get_bits(&gb, 4);
313 if (mp->codes_count == 0)
314 goto end;
315
316 if (mp->changes_map[0] == 0) {
317 *(uint16_t *)mp->frame->data[0] = get_bits(&gb, 15);
318 mp->changes_map[0] = 1;
319 }
320 if (mp_read_codes_table(mp, &gb) < 0)
321 goto end;
322
323 sz = get_bits(&gb, 18);
324 if (avctx->extradata[0] != 5)
325 sz += get_bits(&gb, 18);
326 if (sz == 0)
327 goto end;
328
329 if (mp->codes_count > 1) {
330 /* The entries of the mp->codes array are sorted from right to left
331 * in the Huffman tree, hence -(int)sizeof(HuffCode). */
332 ret = ff_vlc_init_from_lengths(&mp->vlc, mp->max_codes_bits, mp->codes_count,
333 &mp->codes[mp->codes_count - 1].size, -(int)sizeof(HuffCode),
334 &mp->codes[mp->codes_count - 1].delta, -(int)sizeof(HuffCode), 1,
335 0, 0, avctx);
336 if (ret < 0)
337 goto end;
338 }
339 mp_decode_frame_helper(mp, &gb);

Callers

nothing calls this directly

Calls 10

ff_reget_bufferFunction · 0.85
av_fast_padded_mallocFunction · 0.85
init_get_bitsFunction · 0.85
mp_read_changes_mapFunction · 0.85
mp_read_codes_tableFunction · 0.85
ff_vlc_init_from_lengthsFunction · 0.85
mp_decode_frame_helperFunction · 0.85
ff_vlc_freeFunction · 0.85
av_frame_refFunction · 0.85
get_bitsFunction · 0.70

Tested by

no test coverage detected