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

Function gdv_decode_frame

libavcodec/gdv.c:459–554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457}
458
459static int gdv_decode_frame(AVCodecContext *avctx, AVFrame *frame,
460 int *got_frame, AVPacket *avpkt)
461{
462 GDVContext *gdv = avctx->priv_data;
463 GetByteContext *gb = &gdv->gb;
464 PutByteContext *pb = &gdv->pb;
465 int ret, i;
466 int compression;
467 unsigned flags;
468 uint8_t *dst;
469
470 bytestream2_init(gb, avpkt->data, avpkt->size);
471 bytestream2_init_writer(pb, gdv->frame, gdv->frame_size);
472
473 flags = bytestream2_get_le32(gb);
474 compression = flags & 0xF;
475
476 if (compression == 4 || compression == 7 || compression > 8)
477 return AVERROR_INVALIDDATA;
478
479 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
480 return ret;
481 ff_copy_palette(gdv->pal, avpkt, avctx);
482
483 if (compression < 2 && bytestream2_get_bytes_left(gb) < 256*3)
484 return AVERROR_INVALIDDATA;
485 rescale(gdv, gdv->frame, avctx->width, avctx->height,
486 !!(flags & 0x10), !!(flags & 0x20));
487
488 switch (compression) {
489 case 1:
490 memset(gdv->frame + PREAMBLE_SIZE, 0, gdv->frame_size - PREAMBLE_SIZE);
491 case 0:
492 for (i = 0; i < 256; i++) {
493 unsigned r = bytestream2_get_byte(gb);
494 unsigned g = bytestream2_get_byte(gb);
495 unsigned b = bytestream2_get_byte(gb);
496 gdv->pal[i] = 0xFFU << 24 | r << 18 | g << 10 | b << 2;
497 }
498 break;
499 case 2:
500 ret = decompress_2(avctx);
501 break;
502 case 3:
503 break;
504 case 5:
505 ret = decompress_5(avctx, flags >> 8);
506 break;
507 case 6:
508 ret = decompress_68(avctx, flags >> 8, 0);
509 break;
510 case 8:
511 ret = decompress_68(avctx, flags >> 8, 1);
512 break;
513 default:
514 av_assert0(0);
515 }
516 if (ret < 0)

Callers

nothing calls this directly

Calls 10

bytestream2_initFunction · 0.85
bytestream2_init_writerFunction · 0.85
ff_get_bufferFunction · 0.85
ff_copy_paletteFunction · 0.85
decompress_2Function · 0.85
decompress_5Function · 0.85
decompress_68Function · 0.85
scaleupFunction · 0.85
rescaleFunction · 0.70

Tested by

no test coverage detected