Unified · Split
| @@ -1377,6 +1377,23 @@ fail: · 1376 unmodified lines | ||
| 1377 | 1377 | return ret; |
| 1378 | 1378 | } |
| 1379 | 1379 | |
| 1380 | +static av_cold int alloc_dummy_frame(AVCodecContext *avctx, SVQ3Frame *pic) | |
| 1381 | +{ | |
| 1382 | + av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n"); | |
| 1383 | + av_frame_unref(pic->f); | |
| 1384 | + int ret = get_buffer(avctx, pic); | |
| 1385 | + if (ret < 0) | |
| 1386 | + return ret; | |
| 1387 | + | |
| 1388 | + memset(pic->f->data[0], 0, avctx->height * pic->f->linesize[0]); | |
| 1389 | + memset(pic->f->data[1], 0x80, (avctx->height / 2) * | |
| 1390 | + pic->f->linesize[1]); | |
| 1391 | + memset(pic->f->data[2], 0x80, (avctx->height / 2) * | |
| 1392 | + pic->f->linesize[2]); | |
| 1393 | + | |
| 1394 | + return 0; | |
| 1395 | +} | |
| 1396 | + | |
| 1380 | 1397 | static int svq3_decode_frame(AVCodecContext *avctx, AVFrame *rframe, |
| 1381 | 1398 | int *got_frame, AVPacket *avpkt) |
| 1382 | 1399 | { |
| @@ -1441,29 +1458,15 @@ static int svq3_decode_frame(AVCodecContext *avctx, AVFrame *rframe, · 58 unmodified lines | ||
| 1441 | 1458 | |
| 1442 | 1459 | if (s->pict_type != AV_PICTURE_TYPE_I) { |
| 1443 | 1460 | if (!s->last_pic->f->data[0]) { |
| 1444 | − av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n"); | |
| 1445 | − av_frame_unref(s->last_pic->f); | |
| 1446 | − ret = get_buffer(avctx, s->last_pic); | |
| 1461 | + ret = alloc_dummy_frame(avctx, s->last_pic); | |
| 1447 | 1462 | if (ret < 0) |
| 1448 | 1463 | return ret; |
| 1449 | − memset(s->last_pic->f->data[0], 0, avctx->height * s->last_pic->f->linesize[0]); | |
| 1450 | − memset(s->last_pic->f->data[1], 0x80, (avctx->height / 2) * | |
| 1451 | − s->last_pic->f->linesize[1]); | |
| 1452 | − memset(s->last_pic->f->data[2], 0x80, (avctx->height / 2) * | |
| 1453 | − s->last_pic->f->linesize[2]); | |
| 1454 | 1464 | } |
| 1455 | 1465 | |
| 1456 | 1466 | if (s->pict_type == AV_PICTURE_TYPE_B && !s->next_pic->f->data[0]) { |
| 1457 | − av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n"); | |
| 1458 | − av_frame_unref(s->next_pic->f); | |
| 1459 | − ret = get_buffer(avctx, s->next_pic); | |
| 1467 | + ret = alloc_dummy_frame(avctx, s->next_pic); | |
| 1460 | 1468 | if (ret < 0) |
| 1461 | 1469 | return ret; |
| 1462 | − memset(s->next_pic->f->data[0], 0, avctx->height * s->next_pic->f->linesize[0]); | |
| 1463 | − memset(s->next_pic->f->data[1], 0x80, (avctx->height / 2) * | |
| 1464 | − s->next_pic->f->linesize[1]); | |
| 1465 | − memset(s->next_pic->f->data[2], 0x80, (avctx->height / 2) * | |
| 1466 | − s->next_pic->f->linesize[2]); | |
| 1467 | 1470 | } |
| 1468 | 1471 | } |
| 1469 | 1472 | |