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

Function mp_decode_frame

libavcodec/motionpixels.c:231–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229}
230
231static int mp_decode_frame(AVCodecContext *avctx,
232 void *data, int *data_size,
233 AVPacket *avpkt)
234{
235 const uint8_t *buf = avpkt->data;
236 int buf_size = avpkt->size;
237 MotionPixelsContext *mp = avctx->priv_data;
238 GetBitContext gb;
239 int i, count1, count2, sz;
240
241 mp->frame.reference = 1;
242 mp->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
243 if (avctx->reget_buffer(avctx, &mp->frame)) {
244 av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
245 return -1;
246 }
247
248 /* le32 bitstream msb first */
249 av_fast_malloc(&mp->bswapbuf, &mp->bswapbuf_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
250 if (!mp->bswapbuf)
251 return AVERROR(ENOMEM);
252 mp->dsp.bswap_buf((uint32_t *)mp->bswapbuf, (const uint32_t *)buf, buf_size / 4);
253 if (buf_size & 3)
254 memcpy(mp->bswapbuf + (buf_size & ~3), buf + (buf_size & ~3), buf_size & 3);
255 init_get_bits(&gb, mp->bswapbuf, buf_size * 8);
256
257 memset(mp->changes_map, 0, avctx->width * avctx->height);
258 for (i = !(avctx->extradata[1] & 2); i < 2; ++i) {
259 count1 = get_bits(&gb, 12);
260 count2 = get_bits(&gb, 12);
261 mp_read_changes_map(mp, &gb, count1, 8, i);
262 mp_read_changes_map(mp, &gb, count2, 4, i);
263 }
264
265 mp->codes_count = get_bits(&gb, 4);
266 if (mp->codes_count == 0)
267 goto end;
268
269 if (mp->changes_map[0] == 0) {
270 *(uint16_t *)mp->frame.data[0] = get_bits(&gb, 15);
271 mp->changes_map[0] = 1;
272 }
273 mp_read_codes_table(mp, &gb);
274
275 sz = get_bits(&gb, 18);
276 if (avctx->extradata[0] != 5)
277 sz += get_bits(&gb, 18);
278 if (sz == 0)
279 goto end;
280
281 init_vlc(&mp->vlc, mp->max_codes_bits, mp->codes_count, &mp->codes[0].size, sizeof(HuffCode), 1, &mp->codes[0].code, sizeof(HuffCode), 4, 0);
282 mp_decode_frame_helper(mp, &gb);
283 free_vlc(&mp->vlc);
284
285end:
286 *data_size = sizeof(AVFrame);
287 *(AVFrame *)data = mp->frame;
288 return buf_size;

Callers

nothing calls this directly

Calls 8

av_logFunction · 0.85
av_fast_mallocFunction · 0.85
init_get_bitsFunction · 0.85
get_bitsFunction · 0.85
mp_read_changes_mapFunction · 0.85
mp_read_codes_tableFunction · 0.85
mp_decode_frame_helperFunction · 0.85
free_vlcFunction · 0.85

Tested by

no test coverage detected