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

Function decode_frame

libavcodec/cscd.c:137–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135#endif
136
137static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
138 AVPacket *avpkt) {
139 const uint8_t *buf = avpkt->data;
140 int buf_size = avpkt->size;
141 CamStudioContext *c = avctx->priv_data;
142 AVFrame *picture = data;
143
144 if (buf_size < 2) {
145 av_log(avctx, AV_LOG_ERROR, "coded frame too small\n");
146 return -1;
147 }
148
149 if (c->pic.data[0])
150 avctx->release_buffer(avctx, &c->pic);
151 c->pic.reference = 1;
152 c->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_READABLE |
153 FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
154 if (avctx->get_buffer(avctx, &c->pic) < 0) {
155 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
156 return -1;
157 }
158
159 // decompress data
160 switch ((buf[0] >> 1) & 7) {
161 case 0: { // lzo compression
162 int outlen = c->decomp_size, inlen = buf_size - 2;
163 if (av_lzo1x_decode(c->decomp_buf, &outlen, &buf[2], &inlen))
164 av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
165 break;
166 }
167 case 1: { // zlib compression
168#if CONFIG_ZLIB
169 unsigned long dlen = c->decomp_size;
170 if (uncompress(c->decomp_buf, &dlen, &buf[2], buf_size - 2) != Z_OK)
171 av_log(avctx, AV_LOG_ERROR, "error during zlib decompression\n");
172 break;
173#else
174 av_log(avctx, AV_LOG_ERROR, "compiled without zlib support\n");
175 return -1;
176#endif
177 }
178 default:
179 av_log(avctx, AV_LOG_ERROR, "unknown compression\n");
180 return -1;
181 }
182
183 // flip upside down, add difference frame
184 if (buf[0] & 1) { // keyframe
185 c->pic.pict_type = FF_I_TYPE;
186 c->pic.key_frame = 1;
187 switch (c->bpp) {
188 case 16:
189 copy_frame_16(&c->pic, c->decomp_buf, c->linelen, c->height);
190 break;
191 case 32:
192 copy_frame_32(&c->pic, c->decomp_buf, c->linelen, c->height);
193 break;
194 default:

Callers

nothing calls this directly

Calls 8

av_logFunction · 0.85
av_lzo1x_decodeFunction · 0.85
copy_frame_16Function · 0.85
copy_frame_32Function · 0.85
copy_frame_defaultFunction · 0.85
add_frame_16Function · 0.85
add_frame_32Function · 0.85
add_frame_defaultFunction · 0.85

Tested by

no test coverage detected