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

Function decode_frame

libavcodec/nuv.c:130–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
131 AVPacket *avpkt) {
132 const uint8_t *buf = avpkt->data;
133 int buf_size = avpkt->size;
134 NuvContext *c = avctx->priv_data;
135 AVFrame *picture = data;
136 int orig_size = buf_size;
137 int keyframe;
138 int result;
139 enum {NUV_UNCOMPRESSED = '0', NUV_RTJPEG = '1',
140 NUV_RTJPEG_IN_LZO = '2', NUV_LZO = '3',
141 NUV_BLACK = 'N', NUV_COPY_LAST = 'L'} comptype;
142
143 if (buf_size < 12) {
144 av_log(avctx, AV_LOG_ERROR, "coded frame too small\n");
145 return -1;
146 }
147
148 // codec data (rtjpeg quant tables)
149 if (buf[0] == 'D' && buf[1] == 'R') {
150 int ret;
151 // skip rest of the frameheader.
152 buf = &buf[12];
153 buf_size -= 12;
154 ret = get_quant(avctx, c, buf, buf_size);
155 if (ret < 0)
156 return ret;
157 rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq, c->cq);
158 return orig_size;
159 }
160
161 if (buf[0] != 'V' || buf_size < 12) {
162 av_log(avctx, AV_LOG_ERROR, "not a nuv video frame\n");
163 return -1;
164 }
165 comptype = buf[1];
166 switch (comptype) {
167 case NUV_RTJPEG_IN_LZO:
168 case NUV_RTJPEG:
169 keyframe = !buf[2]; break;
170 case NUV_COPY_LAST:
171 keyframe = 0; break;
172 default:
173 keyframe = 1; break;
174 }
175 // skip rest of the frameheader.
176 buf = &buf[12];
177 buf_size -= 12;
178 if (comptype == NUV_RTJPEG_IN_LZO || comptype == NUV_LZO) {
179 int outlen = c->decomp_size, inlen = buf_size;
180 if (av_lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen))
181 av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
182 buf = c->decomp_buf;
183 buf_size = c->decomp_size;
184 }
185 if (c->codec_frameheader) {
186 int w, h, q;
187 if (buf_size < 12) {

Callers

nothing calls this directly

Calls 8

av_logFunction · 0.85
get_quantFunction · 0.85
rtjpeg_decode_initFunction · 0.85
av_lzo1x_decodeFunction · 0.85
codec_reinitFunction · 0.85
copy_frameFunction · 0.85
AV_RL16Function · 0.50

Tested by

no test coverage detected