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

Function decode_frame

libavcodec/bink.c:1255–1309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1253}
1254
1255static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
1256 int *got_frame, AVPacket *pkt)
1257{
1258 BinkContext * const c = avctx->priv_data;
1259 GetBitContext gb;
1260 int plane, plane_idx, ret;
1261 int bits_count = pkt->size << 3;
1262
1263 if (c->version > 'b') {
1264 if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
1265 return ret;
1266 } else {
1267 if ((ret = ff_reget_buffer(avctx, c->last, 0)) < 0)
1268 return ret;
1269 if ((ret = av_frame_ref(frame, c->last)) < 0)
1270 return ret;
1271 }
1272
1273 init_get_bits(&gb, pkt->data, bits_count);
1274 if (c->has_alpha) {
1275 if (c->version >= 'i')
1276 skip_bits_long(&gb, 32);
1277 if ((ret = bink_decode_plane(c, frame, &gb, 3, 0)) < 0)
1278 return ret;
1279 }
1280 if (c->version >= 'i')
1281 skip_bits_long(&gb, 32);
1282
1283 c->frame_num++;
1284
1285 for (plane = 0; plane < 3; plane++) {
1286 plane_idx = (!plane || !c->swap_planes) ? plane : (plane ^ 3);
1287
1288 if (c->version > 'b') {
1289 if ((ret = bink_decode_plane(c, frame, &gb, plane_idx, !!plane)) < 0)
1290 return ret;
1291 } else {
1292 if ((ret = binkb_decode_plane(c, frame, &gb, plane_idx,
1293 c->frame_num == 1, !!plane)) < 0)
1294 return ret;
1295 }
1296 if (get_bits_count(&gb) >= bits_count)
1297 break;
1298 }
1299
1300 if (c->version > 'b') {
1301 if ((ret = av_frame_replace(c->last, frame)) < 0)
1302 return ret;
1303 }
1304
1305 *got_frame = 1;
1306
1307 /* always report that the buffer was completely consumed */
1308 return pkt->size;
1309}
1310
1311static av_cold void bink_init_vlcs(void)
1312{

Callers

nothing calls this directly

Calls 9

ff_get_bufferFunction · 0.85
ff_reget_bufferFunction · 0.85
av_frame_refFunction · 0.85
init_get_bitsFunction · 0.85
skip_bits_longFunction · 0.85
bink_decode_planeFunction · 0.85
binkb_decode_planeFunction · 0.85
get_bits_countFunction · 0.85
av_frame_replaceFunction · 0.85

Tested by

no test coverage detected