History

avcodec/svq3: Deduplicate allocating dummy frame

Andreas Rheinhardt committed 1 year ago

Commit eacde6e1 parent cb54eca1 file · +19 −16Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/svq3.c+19−16
@@ -1377,6 +1377,23 @@ fail: · 1376 unmodified lines
1377 return ret;1377 return ret;
1378}1378}
1379 1379
1380static 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
1380static int svq3_decode_frame(AVCodecContext *avctx, AVFrame *rframe,1397static int svq3_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
1381 int *got_frame, AVPacket *avpkt)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 if (s->pict_type != AV_PICTURE_TYPE_I) {1459 if (s->pict_type != AV_PICTURE_TYPE_I) {
1443 if (!s->last_pic->f->data[0]) {1460 if (!s->last_pic->f->data[0]) {
1444 av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n");1461 ret = alloc_dummy_frame(avctx, s->last_pic);
1445 av_frame_unref(s->last_pic->f);
1446 ret = get_buffer(avctx, s->last_pic);
1447 if (ret < 0)1462 if (ret < 0)
1448 return ret;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 if (s->pict_type == AV_PICTURE_TYPE_B && !s->next_pic->f->data[0]) {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");1467 ret = alloc_dummy_frame(avctx, s->next_pic);
1458 av_frame_unref(s->next_pic->f);
1459 ret = get_buffer(avctx, s->next_pic);
1460 if (ret < 0)1468 if (ret < 0)
1461 return ret;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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t