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

Function decode_frame

libavcodec/wcmv.c:42–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40} WCMVContext;
41
42static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
43 int *got_frame, AVPacket *avpkt)
44{
45 WCMVContext *s = avctx->priv_data;
46 z_stream *const zstream = &s->zstream.zstream;
47 int skip, blocks, zret, ret, intra = 0, flags = 0, bpp = s->bpp;
48 GetByteContext gb;
49 uint8_t *dst;
50
51 ret = inflateReset(zstream);
52 if (ret != Z_OK) {
53 av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", ret);
54 return AVERROR_EXTERNAL;
55 }
56
57 bytestream2_init(&gb, avpkt->data, avpkt->size);
58 blocks = bytestream2_get_le16(&gb);
59 if (!blocks)
60 flags |= FF_REGET_BUFFER_FLAG_READONLY;
61
62 if ((ret = ff_reget_buffer(avctx, s->prev_frame, flags)) < 0)
63 return ret;
64
65 if (blocks > 5) {
66 GetByteContext bgb;
67 int x = 0, size;
68
69 if (blocks * 8 >= 0xFFFF)
70 size = bytestream2_get_le24(&gb);
71 else if (blocks * 8 >= 0xFF)
72 size = bytestream2_get_le16(&gb);
73 else
74 size = bytestream2_get_byte(&gb);
75
76 skip = bytestream2_tell(&gb);
77 if (size > avpkt->size - skip)
78 return AVERROR_INVALIDDATA;
79
80 zstream->next_in = avpkt->data + skip;
81 zstream->avail_in = size;
82 zstream->next_out = s->block_data;
83 zstream->avail_out = sizeof(s->block_data);
84
85 zret = inflate(zstream, Z_FINISH);
86 if (zret != Z_STREAM_END) {
87 av_log(avctx, AV_LOG_ERROR,
88 "Inflate failed with return code: %d.\n", zret);
89 return AVERROR_INVALIDDATA;
90 }
91
92 ret = inflateReset(zstream);
93 if (ret != Z_OK) {
94 av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", ret);
95 return AVERROR_EXTERNAL;
96 }
97
98 bytestream2_skip(&gb, size);
99 bytestream2_init(&bgb, s->block_data, blocks * 8);

Callers

nothing calls this directly

Calls 10

av_logFunction · 0.85
bytestream2_initFunction · 0.85
ff_reget_bufferFunction · 0.85
bytestream2_tellFunction · 0.85
inflateFunction · 0.85
bytestream2_skipFunction · 0.85
bytestream2_seekFunction · 0.85
av_image_fill_blackFunction · 0.85
av_frame_refFunction · 0.85

Tested by

no test coverage detected