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

Function decode_frame

libavcodec/prores_raw.c:322–516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320}
321
322static int decode_frame(AVCodecContext *avctx,
323 AVFrame *frame, int *got_frame_ptr,
324 AVPacket *avpkt)
325{
326 ProResRAWContext *s = avctx->priv_data;
327 int ret, dimensions_changed = 0, old_version = s->version;
328 DECLARE_ALIGNED(32, uint8_t, qmat)[64];
329 memset(qmat, 1, 64);
330
331 if (avctx->skip_frame >= AVDISCARD_ALL)
332 return avpkt->size;
333
334 switch (avctx->codec_tag) {
335 case 0:
336 break;
337 case MKTAG('a','p','r','n'):
338 avctx->profile = AV_PROFILE_PRORES_RAW;
339 break;
340 case MKTAG('a','p','r','h'):
341 avctx->profile = AV_PROFILE_PRORES_RAW_HQ;
342 break;
343 default:
344 avpriv_request_sample(avctx, "Profile %d", avctx->codec_tag);
345 return AVERROR_PATCHWELCOME;
346 break;
347 }
348
349 GetByteContext gb;
350 bytestream2_init(&gb, avpkt->data, avpkt->size);
351 if (bytestream2_get_be32(&gb) != avpkt->size)
352 return AVERROR_INVALIDDATA;
353
354 /* ProRes RAW frame */
355 if (bytestream2_get_be32(&gb) != MKBETAG('p','r','r','f'))
356 return AVERROR_INVALIDDATA;
357
358 int header_len = bytestream2_get_be16(&gb);
359 if (header_len < 62 || bytestream2_get_bytes_left(&gb) < header_len - 2)
360 return AVERROR_INVALIDDATA;
361
362 GetByteContext gb_hdr;
363 bytestream2_init(&gb_hdr, gb.buffer, header_len - 2);
364 bytestream2_skip(&gb, header_len - 2);
365
366 bytestream2_skip(&gb_hdr, 1);
367 s->version = bytestream2_get_byte(&gb_hdr);
368 if (s->version > 1) {
369 avpriv_request_sample(avctx, "Version %d", s->version);
370 return AVERROR_PATCHWELCOME;
371 }
372
373 /* Vendor header (e.g. "peac" for Panasonic or "atm0" for Atmos) */
374 bytestream2_skip(&gb_hdr, 4);
375
376 /* Width and height must always be even */
377 int w = bytestream2_get_be16(&gb_hdr);
378 int h = bytestream2_get_be16(&gb_hdr);
379 if ((w & 1) || (h & 1))

Callers

nothing calls this directly

Calls 15

avpriv_request_sampleFunction · 0.85
bytestream2_initFunction · 0.85
bytestream2_skipFunction · 0.85
av_logFunction · 0.85
ff_set_dimensionsFunction · 0.85
bytestream2_get_bufferFunction · 0.85
ff_permute_scantableFunction · 0.85
av_fast_malloczFunction · 0.85
bytestream2_tellFunction · 0.85
ffhwaccelFunction · 0.85

Tested by

no test coverage detected