Unified · Split
| @@ -1203,8 +1203,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 1202 unmodified lines | ||
| 1203 | 1203 | if (ret < 0) |
| 1204 | 1204 | return ret; |
| 1205 | 1205 | |
| 1206 | − av_frame_unref(s->prev_frame); | |
| 1207 | − if ((ret = av_frame_ref(s->prev_frame, frame)) < 0) | |
| 1206 | + if ((ret = av_frame_replace(s->prev_frame, frame)) < 0) | |
| 1208 | 1207 | return ret; |
| 1209 | 1208 | |
| 1210 | 1209 | frame->crop_top = avctx->coded_height - avctx->height; |
| @@ -166,8 +166,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 165 unmodified lines | ||
| 166 | 166 | prev_pixels -= fill_tile4(avctx, fill, frame); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | − av_frame_unref(s->prev_frame); | |
| 170 | − if ((ret = av_frame_ref(s->prev_frame, frame)) < 0) | |
| 169 | + if ((ret = av_frame_replace(s->prev_frame, frame)) < 0) | |
| 171 | 170 | return ret; |
| 172 | 171 | |
| 173 | 172 | frame->pict_type = prev_pixels <= 0 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; |
| @@ -483,8 +483,7 @@ static OSStatus ffat_encode_callback(AudioConverterRef converter, UInt32 *nb_pac · 482 unmodified lines | ||
| 483 | 483 | if (*nb_packets > frame->nb_samples) |
| 484 | 484 | *nb_packets = frame->nb_samples; |
| 485 | 485 | |
| 486 | − av_frame_unref(at->encoding_frame); | |
| 487 | − ret = av_frame_ref(at->encoding_frame, frame); | |
| 486 | + ret = av_frame_replace(at->encoding_frame, frame); | |
| 488 | 487 | if (ret < 0) { |
| 489 | 488 | *nb_packets = 0; |
| 490 | 489 | return ret; |
| @@ -1300,8 +1300,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 1299 unmodified lines | ||
| 1300 | 1300 | emms_c(); |
| 1301 | 1301 | |
| 1302 | 1302 | if (c->version > 'b') { |
| 1303 | − av_frame_unref(c->last); | |
| 1304 | − if ((ret = av_frame_ref(c->last, frame)) < 0) | |
| 1303 | + if ((ret = av_frame_replace(c->last, frame)) < 0) | |
| 1305 | 1304 | return ret; |
| 1306 | 1305 | } |
| 1307 | 1306 | |
| @@ -344,8 +344,7 @@ static int cdg_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 343 unmodified lines | ||
| 344 | 344 | return ret; |
| 345 | 345 | |
| 346 | 346 | cdg_scroll(cc, cdg_data, frame, inst == CDG_INST_SCROLL_COPY); |
| 347 | − av_frame_unref(cc->frame); | |
| 348 | − ret = av_frame_ref(cc->frame, frame); | |
| 347 | + ret = av_frame_replace(cc->frame, frame); | |
| 349 | 348 | if (ret < 0) |
| 350 | 349 | return ret; |
| 351 | 350 | break; |
| @@ -317,8 +317,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 316 unmodified lines | ||
| 317 | 317 | return AVERROR_INVALIDDATA; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | − av_frame_unref(c->prev); | |
| 321 | − if ((ret = av_frame_ref(c->prev, frame)) < 0) | |
| 320 | + if ((ret = av_frame_replace(c->prev, frame)) < 0) | |
| 322 | 321 | return ret; |
| 323 | 322 | |
| 324 | 323 | *got_frame = 1; |
| @@ -210,9 +210,8 @@ static int cmv_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 209 unmodified lines | ||
| 210 | 210 | cmv_decode_intra(s, frame, buf+2, buf_end); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | − av_frame_unref(s->last2_frame); | |
| 214 | − av_frame_move_ref(s->last2_frame, s->last_frame); | |
| 215 | − if ((ret = av_frame_ref(s->last_frame, frame)) < 0) | |
| 213 | + FFSWAP(AVFrame*, s->last2_frame, s->last_frame); | |
| 214 | + if ((ret = av_frame_replace(s->last_frame, frame)) < 0) | |
| 216 | 215 | return ret; |
| 217 | 216 | |
| 218 | 217 | *got_frame = 1; |
| @@ -317,8 +317,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 316 unmodified lines | ||
| 317 | 317 | *got_frame = 1; |
| 318 | 318 | |
| 319 | 319 | if (chunk_type != MADe_TAG) { |
| 320 | − av_frame_unref(s->last_frame); | |
| 321 | − if ((ret = av_frame_ref(s->last_frame, frame)) < 0) | |
| 320 | + if ((ret = av_frame_replace(s->last_frame, frame)) < 0) | |
| 322 | 321 | return ret; |
| 323 | 322 | } |
| 324 | 323 | |
| @@ -338,8 +338,7 @@ static int tgv_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 337 unmodified lines | ||
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | − av_frame_unref(s->last_frame); | |
| 342 | − if ((ret = av_frame_ref(s->last_frame, frame)) < 0) | |
| 341 | + if ((ret = av_frame_replace(s->last_frame, frame)) < 0) | |
| 343 | 342 | return ret; |
| 344 | 343 | |
| 345 | 344 | *got_frame = 1; |
| @@ -362,8 +362,7 @@ static int escape124_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 361 unmodified lines | ||
| 362 | 362 | "Escape sizes: %i, %i, %i\n", |
| 363 | 363 | frame_size, buf_size, get_bits_count(&gb) / 8); |
| 364 | 364 | |
| 365 | − av_frame_unref(s->frame); | |
| 366 | − if ((ret = av_frame_ref(s->frame, frame)) < 0) | |
| 365 | + if ((ret = av_frame_replace(s->frame, frame)) < 0) | |
| 367 | 366 | return ret; |
| 368 | 367 | |
| 369 | 368 | *got_frame = 1; |
| @@ -503,8 +503,7 @@ static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 502 unmodified lines | ||
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | if (!s->image) { |
| 506 | − av_frame_unref(s->last_frame); | |
| 507 | − ret = av_frame_ref(s->last_frame, pict); | |
| 506 | + ret = av_frame_replace(s->last_frame, pict); | |
| 508 | 507 | if (ret < 0) |
| 509 | 508 | return ret; |
| 510 | 509 | } |
| @@ -453,8 +453,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 452 unmodified lines | ||
| 453 | 453 | if (ret < 0) |
| 454 | 454 | return ret; |
| 455 | 455 | |
| 456 | − av_frame_unref(s->prev_frame); | |
| 457 | − if ((ret = av_frame_ref(s->prev_frame, frame)) < 0) | |
| 456 | + if ((ret = av_frame_replace(s->prev_frame, frame)) < 0) | |
| 458 | 457 | return ret; |
| 459 | 458 | } else { |
| 460 | 459 | if (!s->prev_frame->data[0]) { |
| @@ -1340,9 +1340,8 @@ FF_ENABLE_DEPRECATION_WARNINGS · 1339 unmodified lines | ||
| 1340 | 1340 | *got_frame = send_buffer; |
| 1341 | 1341 | |
| 1342 | 1342 | /* shuffle frames */ |
| 1343 | − av_frame_unref(s->second_last_frame); | |
| 1344 | 1343 | FFSWAP(AVFrame*, s->second_last_frame, s->last_frame); |
| 1345 | − if ((ret = av_frame_ref(s->last_frame, frame)) < 0) | |
| 1344 | + if ((ret = av_frame_replace(s->last_frame, frame)) < 0) | |
| 1346 | 1345 | return ret; |
| 1347 | 1346 | |
| 1348 | 1347 | /* report that the buffer was completely consumed */ |
| @@ -797,8 +797,7 @@ static int mss2_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 796 unmodified lines | ||
| 797 | 797 | av_log(avctx, AV_LOG_WARNING, "buffer not fully consumed\n"); |
| 798 | 798 | |
| 799 | 799 | if (c->mvX < 0 || c->mvY < 0) { |
| 800 | − av_frame_unref(ctx->last_pic); | |
| 801 | − ret = av_frame_ref(ctx->last_pic, frame); | |
| 800 | + ret = av_frame_replace(ctx->last_pic, frame); | |
| 802 | 801 | if (ret < 0) |
| 803 | 802 | return ret; |
| 804 | 803 | } |
| @@ -643,8 +643,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 642 unmodified lines | ||
| 643 | 643 | return ret; |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | − av_frame_unref(s->prev_frame); | |
| 647 | − if ((ret = av_frame_ref(s->prev_frame, frame)) < 0) | |
| 646 | + if ((ret = av_frame_replace(s->prev_frame, frame)) < 0) | |
| 648 | 647 | return ret; |
| 649 | 648 | |
| 650 | 649 | *got_frame = 1; |
| @@ -127,8 +127,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 126 unmodified lines | ||
| 127 | 127 | |
| 128 | 128 | frame->pict_type = (frame->flags & AV_FRAME_FLAG_KEY) ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; |
| 129 | 129 | |
| 130 | − av_frame_unref(s->prev_frame); | |
| 131 | − if ((ret = av_frame_ref(s->prev_frame, frame)) < 0) | |
| 130 | + if ((ret = av_frame_replace(s->prev_frame, frame)) < 0) | |
| 132 | 131 | return ret; |
| 133 | 132 | |
| 134 | 133 | *got_frame = 1; |
| @@ -102,8 +102,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 101 unmodified lines | ||
| 102 | 102 | dst += frame->linesize[0]; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | − av_frame_unref(s->previous_frame); | |
| 106 | − if ((ret = av_frame_ref(s->previous_frame, frame)) < 0) | |
| 105 | + if ((ret = av_frame_replace(s->previous_frame, frame)) < 0) | |
| 107 | 106 | return ret; |
| 108 | 107 | |
| 109 | 108 | if (avpkt->flags & AV_PKT_FLAG_KEY) { |
| @@ -1059,8 +1059,7 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt, · 1058 unmodified lines | ||
| 1059 | 1059 | } |
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | − av_frame_unref(s->last_frame); | |
| 1063 | − ret = av_frame_ref(s->last_frame, pict); | |
| 1062 | + ret = av_frame_replace(s->last_frame, pict); | |
| 1064 | 1063 | if (ret < 0) |
| 1065 | 1064 | return ret; |
| 1066 | 1065 | |
| @@ -307,8 +307,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 306 unmodified lines | ||
| 307 | 307 | #endif |
| 308 | 308 | memcpy(p->data[1], a->pal, AVPALETTE_SIZE); |
| 309 | 309 | |
| 310 | − av_frame_unref(ref); | |
| 311 | − if ((ret = av_frame_ref(ref, p)) < 0) | |
| 310 | + if ((ret = av_frame_replace(ref, p)) < 0) | |
| 312 | 311 | return ret; |
| 313 | 312 | |
| 314 | 313 | if (intra) |
| @@ -1996,8 +1996,7 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame, · 1995 unmodified lines | ||
| 1996 | 1996 | return ret; |
| 1997 | 1997 | } |
| 1998 | 1998 | } else { |
| 1999 | − av_frame_unref(qf->frame); | |
| 2000 | − ret = av_frame_ref(qf->frame, frame); | |
| 1999 | + ret = av_frame_replace(qf->frame, frame); | |
| 2001 | 2000 | if (ret < 0) |
| 2002 | 2001 | return ret; |
| 2003 | 2002 | } |
| @@ -385,8 +385,7 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 384 unmodified lines | ||
| 385 | 385 | pkt->size = encode_frame(s, pict, pkt->data); |
| 386 | 386 | |
| 387 | 387 | /* save the current frame */ |
| 388 | − av_frame_unref(s->previous_frame); | |
| 389 | − ret = av_frame_ref(s->previous_frame, pict); | |
| 388 | + ret = av_frame_replace(s->previous_frame, pict); | |
| 390 | 389 | if (ret < 0) { |
| 391 | 390 | av_log(avctx, AV_LOG_ERROR, "cannot add reference\n"); |
| 392 | 391 | return ret; |
| @@ -566,8 +566,7 @@ static int smc_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 565 unmodified lines | ||
| 566 | 566 | // write chunk length |
| 567 | 567 | AV_WB24(pkt->data + 1, pkt->size); |
| 568 | 568 | |
| 569 | − av_frame_unref(s->prev_frame); | |
| 570 | − ret = av_frame_ref(s->prev_frame, frame); | |
| 569 | + ret = av_frame_replace(s->prev_frame, frame); | |
| 571 | 570 | if (ret < 0) { |
| 572 | 571 | av_log(avctx, AV_LOG_ERROR, "cannot add reference\n"); |
| 573 | 572 | return ret; |
| @@ -1887,8 +1887,7 @@ redo_frame: · 1886 unmodified lines | ||
| 1887 | 1887 | (s->avctx->flags&AV_CODEC_FLAG_PSNR) ? SNOW_MAX_PLANES : 0, |
| 1888 | 1888 | s->current_picture->pict_type); |
| 1889 | 1889 | if (s->avctx->flags & AV_CODEC_FLAG_RECON_FRAME) { |
| 1890 | − av_frame_unref(avci->recon_frame); | |
| 1891 | − av_frame_ref(avci->recon_frame, s->current_picture); | |
| 1890 | + av_frame_replace(avci->recon_frame, s->current_picture); | |
| 1892 | 1891 | } |
| 1893 | 1892 | |
| 1894 | 1893 | pkt->size = ff_rac_terminate(c, 0); |
| @@ -764,8 +764,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, AVFrame *cur, · 763 unmodified lines | ||
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | if (!s->nonref) { |
| 767 | − av_frame_unref(s->prev); | |
| 768 | − result = av_frame_ref(s->prev, cur); | |
| 767 | + result = av_frame_replace(s->prev, cur); | |
| 769 | 768 | if (result < 0) |
| 770 | 769 | return result; |
| 771 | 770 | } |
| @@ -454,8 +454,7 @@ static int vmdvideo_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 453 unmodified lines | ||
| 454 | 454 | memcpy(frame->data[1], s->palette, PALETTE_COUNT * 4); |
| 455 | 455 | |
| 456 | 456 | /* shuffle frames */ |
| 457 | − av_frame_unref(s->prev_frame); | |
| 458 | − if ((ret = av_frame_ref(s->prev_frame, frame)) < 0) | |
| 457 | + if ((ret = av_frame_replace(s->prev_frame, frame)) < 0) | |
| 459 | 458 | return ret; |
| 460 | 459 | |
| 461 | 460 | *got_frame = 1; |
| @@ -607,8 +607,7 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, AVFrame *rframe, · 606 unmodified lines | ||
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | if (avctx->pix_fmt == AV_PIX_FMT_YUVA420P) { |
| 610 | − av_frame_unref(s->alpha_context->frames[VP56_FRAME_CURRENT]); | |
| 611 | − if ((ret = av_frame_ref(s->alpha_context->frames[VP56_FRAME_CURRENT], p)) < 0) { | |
| 610 | + if ((ret = av_frame_replace(s->alpha_context->frames[VP56_FRAME_CURRENT], p)) < 0) { | |
| 612 | 611 | av_frame_unref(p); |
| 613 | 612 | if (res == VP56_SIZE_CHANGE) |
| 614 | 613 | ff_set_dimensions(avctx, 0, 0); |
| @@ -764,8 +763,7 @@ static int ff_vp56_decode_mbs(AVCodecContext *avctx, void *data, · 149 unmodified lines | ||
| 764 | 763 | |
| 765 | 764 | next: |
| 766 | 765 | if ((p->flags & AV_FRAME_FLAG_KEY) || s->golden_frame) { |
| 767 | − av_frame_unref(s->frames[VP56_FRAME_GOLDEN]); | |
| 768 | − if ((res = av_frame_ref(s->frames[VP56_FRAME_GOLDEN], p)) < 0) | |
| 766 | + if ((res = av_frame_replace(s->frames[VP56_FRAME_GOLDEN], p)) < 0) | |
| 769 | 767 | return res; |
| 770 | 768 | } |
| 771 | 769 | |
| @@ -622,8 +622,7 @@ static int xan_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 621 unmodified lines | ||
| 622 | 622 | if (xan_wc3_decode_frame(s, frame) < 0) |
| 623 | 623 | return AVERROR_INVALIDDATA; |
| 624 | 624 | |
| 625 | − av_frame_unref(s->last_frame); | |
| 626 | − if ((ret = av_frame_ref(s->last_frame, frame)) < 0) | |
| 625 | + if ((ret = av_frame_replace(s->last_frame, frame)) < 0) | |
| 627 | 626 | return ret; |
| 628 | 627 | |
| 629 | 628 | *got_frame = 1; |
| @@ -93,8 +93,7 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, AVFrame *pic, · 92 unmodified lines | ||
| 93 | 93 | dst -= pic->linesize[0]; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | − av_frame_unref(zc->previous_frame); | |
| 97 | − if ((ret = av_frame_ref(zc->previous_frame, pic)) < 0) | |
| 96 | + if ((ret = av_frame_replace(zc->previous_frame, pic)) < 0) | |
| 98 | 97 | return ret; |
| 99 | 98 | |
| 100 | 99 | *got_frame = 1; |
| @@ -781,9 +781,8 @@ static int apply_palette(AVFilterLink *inlink, AVFrame *in, AVFrame **outf) · 780 unmodified lines | ||
| 781 | 781 | |
| 782 | 782 | set_processing_window(s->diff_mode, s->last_in, in, |
| 783 | 783 | s->last_out, out, &x, &y, &w, &h); |
| 784 | − av_frame_unref(s->last_in); | |
| 785 | 784 | av_frame_unref(s->last_out); |
| 786 | − if ((ret = av_frame_ref(s->last_in, in)) < 0 || | |
| 785 | + if ((ret = av_frame_replace(s->last_in, in)) < 0 || | |
| 787 | 786 | (ret = av_frame_ref(s->last_out, out)) < 0 || |
| 788 | 787 | (ret = ff_inlink_make_frame_writable(inlink, &s->last_in)) < 0) { |
| 789 | 788 | av_frame_free(&out); |
| @@ -1076,8 +1076,7 @@ static int ddagrab_request_frame(AVFilterLink *outlink) · 1075 unmodified lines | ||
| 1076 | 1076 | goto fail; |
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | − av_frame_unref(dda->last_frame); | |
| 1080 | − ret = av_frame_ref(dda->last_frame, frame); | |
| 1079 | + ret = av_frame_replace(dda->last_frame, frame); | |
| 1081 | 1080 | if (ret < 0) |
| 1082 | 1081 | return ret; |
| 1083 | 1082 | |
| @@ -819,8 +819,7 @@ int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags) · 818 unmodified lines | ||
| 819 | 819 | return AVERROR(EINVAL); |
| 820 | 820 | } |
| 821 | 821 | hwmap = (HWMapDescriptor*)src->buf[0]->data; |
| 822 | − av_frame_unref(dst); | |
| 823 | − return av_frame_ref(dst, hwmap->source); | |
| 822 | + return av_frame_replace(dst, hwmap->source); | |
| 824 | 823 | } |
| 825 | 824 | } |
| 826 | 825 | |
| @@ -950,6 +949,5 @@ fail: · 123 unmodified lines | ||
| 950 | 949 | int ff_hwframe_map_replace(AVFrame *dst, const AVFrame *src) |
| 951 | 950 | { |
| 952 | 951 | HWMapDescriptor *hwmap = (HWMapDescriptor*)dst->buf[0]->data; |
| 953 | − av_frame_unref(hwmap->source); | |
| 954 | − return av_frame_ref(hwmap->source, src); | |
| 952 | + return av_frame_replace(hwmap->source, src); | |
| 955 | 953 | } |