Showing the changes to libavcodec (28 of 31 files). Show all
Unified · Split
| @@ -1203,8 +1203,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 1202 unmodified lines | |||
| 1203 | if (ret < 0) | 1203 | if (ret < 0) |
| 1204 | return ret; | 1204 | return ret; |
| 1205 | 1205 | ||
| 1206 | av_frame_unref(s->prev_frame); | 1206 | if ((ret = av_frame_replace(s->prev_frame, frame)) < 0) |
| 1207 | if ((ret = av_frame_ref(s->prev_frame, frame)) < 0) | ||
| 1208 | return ret; | 1207 | return ret; |
| 1209 | 1208 | ||
| 1210 | frame->crop_top = avctx->coded_height - avctx->height; | 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 | prev_pixels -= fill_tile4(avctx, fill, frame); | 166 | prev_pixels -= fill_tile4(avctx, fill, frame); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | av_frame_unref(s->prev_frame); | 169 | if ((ret = av_frame_replace(s->prev_frame, frame)) < 0) |
| 170 | if ((ret = av_frame_ref(s->prev_frame, frame)) < 0) | ||
| 171 | return ret; | 170 | return ret; |
| 172 | 171 | ||
| 173 | frame->pict_type = prev_pixels <= 0 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; | 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 | if (*nb_packets > frame->nb_samples) | 483 | if (*nb_packets > frame->nb_samples) |
| 484 | *nb_packets = frame->nb_samples; | 484 | *nb_packets = frame->nb_samples; |
| 485 | 485 | ||
| 486 | av_frame_unref(at->encoding_frame); | 486 | ret = av_frame_replace(at->encoding_frame, frame); |
| 487 | ret = av_frame_ref(at->encoding_frame, frame); | ||
| 488 | if (ret < 0) { | 487 | if (ret < 0) { |
| 489 | *nb_packets = 0; | 488 | *nb_packets = 0; |
| 490 | return ret; | 489 | return ret; |
| @@ -1300,8 +1300,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 1299 unmodified lines | |||
| 1300 | emms_c(); | 1300 | emms_c(); |
| 1301 | 1301 | ||
| 1302 | if (c->version > 'b') { | 1302 | if (c->version > 'b') { |
| 1303 | av_frame_unref(c->last); | 1303 | if ((ret = av_frame_replace(c->last, frame)) < 0) |
| 1304 | if ((ret = av_frame_ref(c->last, frame)) < 0) | ||
| 1305 | return ret; | 1304 | return ret; |
| 1306 | } | 1305 | } |
| 1307 | 1306 | ||
| @@ -344,8 +344,7 @@ static int cdg_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 343 unmodified lines | |||
| 344 | return ret; | 344 | return ret; |
| 345 | 345 | ||
| 346 | cdg_scroll(cc, cdg_data, frame, inst == CDG_INST_SCROLL_COPY); | 346 | cdg_scroll(cc, cdg_data, frame, inst == CDG_INST_SCROLL_COPY); |
| 347 | av_frame_unref(cc->frame); | 347 | ret = av_frame_replace(cc->frame, frame); |
| 348 | ret = av_frame_ref(cc->frame, frame); | ||
| 349 | if (ret < 0) | 348 | if (ret < 0) |
| 350 | return ret; | 349 | return ret; |
| 351 | break; | 350 | break; |
| @@ -317,8 +317,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 316 unmodified lines | |||
| 317 | return AVERROR_INVALIDDATA; | 317 | return AVERROR_INVALIDDATA; |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | av_frame_unref(c->prev); | 320 | if ((ret = av_frame_replace(c->prev, frame)) < 0) |
| 321 | if ((ret = av_frame_ref(c->prev, frame)) < 0) | ||
| 322 | return ret; | 321 | return ret; |
| 323 | 322 | ||
| 324 | *got_frame = 1; | 323 | *got_frame = 1; |
| @@ -210,9 +210,8 @@ static int cmv_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 209 unmodified lines | |||
| 210 | cmv_decode_intra(s, frame, buf+2, buf_end); | 210 | cmv_decode_intra(s, frame, buf+2, buf_end); |
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | av_frame_unref(s->last2_frame); | 213 | FFSWAP(AVFrame*, s->last2_frame, s->last_frame); |
| 214 | av_frame_move_ref(s->last2_frame, s->last_frame); | 214 | if ((ret = av_frame_replace(s->last_frame, frame)) < 0) |
| 215 | if ((ret = av_frame_ref(s->last_frame, frame)) < 0) | ||
| 216 | return ret; | 215 | return ret; |
| 217 | 216 | ||
| 218 | *got_frame = 1; | 217 | *got_frame = 1; |
| @@ -317,8 +317,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 316 unmodified lines | |||
| 317 | *got_frame = 1; | 317 | *got_frame = 1; |
| 318 | 318 | ||
| 319 | if (chunk_type != MADe_TAG) { | 319 | if (chunk_type != MADe_TAG) { |
| 320 | av_frame_unref(s->last_frame); | 320 | if ((ret = av_frame_replace(s->last_frame, frame)) < 0) |
| 321 | if ((ret = av_frame_ref(s->last_frame, frame)) < 0) | ||
| 322 | return ret; | 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); | 341 | if ((ret = av_frame_replace(s->last_frame, frame)) < 0) |
| 342 | if ((ret = av_frame_ref(s->last_frame, frame)) < 0) | ||
| 343 | return ret; | 342 | return ret; |
| 344 | 343 | ||
| 345 | *got_frame = 1; | 344 | *got_frame = 1; |
| @@ -362,8 +362,7 @@ static int escape124_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 361 unmodified lines | |||
| 362 | "Escape sizes: %i, %i, %i\n", | 362 | "Escape sizes: %i, %i, %i\n", |
| 363 | frame_size, buf_size, get_bits_count(&gb) / 8); | 363 | frame_size, buf_size, get_bits_count(&gb) / 8); |
| 364 | 364 | ||
| 365 | av_frame_unref(s->frame); | 365 | if ((ret = av_frame_replace(s->frame, frame)) < 0) |
| 366 | if ((ret = av_frame_ref(s->frame, frame)) < 0) | ||
| 367 | return ret; | 366 | return ret; |
| 368 | 367 | ||
| 369 | *got_frame = 1; | 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 | if (!s->image) { | 505 | if (!s->image) { |
| 506 | av_frame_unref(s->last_frame); | 506 | ret = av_frame_replace(s->last_frame, pict); |
| 507 | ret = av_frame_ref(s->last_frame, pict); | ||
| 508 | if (ret < 0) | 507 | if (ret < 0) |
| 509 | return ret; | 508 | return ret; |
| 510 | } | 509 | } |
| @@ -453,8 +453,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 452 unmodified lines | |||
| 453 | if (ret < 0) | 453 | if (ret < 0) |
| 454 | return ret; | 454 | return ret; |
| 455 | 455 | ||
| 456 | av_frame_unref(s->prev_frame); | 456 | if ((ret = av_frame_replace(s->prev_frame, frame)) < 0) |
| 457 | if ((ret = av_frame_ref(s->prev_frame, frame)) < 0) | ||
| 458 | return ret; | 457 | return ret; |
| 459 | } else { | 458 | } else { |
| 460 | if (!s->prev_frame->data[0]) { | 459 | if (!s->prev_frame->data[0]) { |
| @@ -1340,9 +1340,8 @@ FF_ENABLE_DEPRECATION_WARNINGS · 1339 unmodified lines | |||
| 1340 | *got_frame = send_buffer; | 1340 | *got_frame = send_buffer; |
| 1341 | 1341 | ||
| 1342 | /* shuffle frames */ | 1342 | /* shuffle frames */ |
| 1343 | av_frame_unref(s->second_last_frame); | ||
| 1344 | FFSWAP(AVFrame*, s->second_last_frame, s->last_frame); | 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 | return ret; | 1345 | return ret; |
| 1347 | 1346 | ||
| 1348 | /* report that the buffer was completely consumed */ | 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 | av_log(avctx, AV_LOG_WARNING, "buffer not fully consumed\n"); | 797 | av_log(avctx, AV_LOG_WARNING, "buffer not fully consumed\n"); |
| 798 | 798 | ||
| 799 | if (c->mvX < 0 || c->mvY < 0) { | 799 | if (c->mvX < 0 || c->mvY < 0) { |
| 800 | av_frame_unref(ctx->last_pic); | 800 | ret = av_frame_replace(ctx->last_pic, frame); |
| 801 | ret = av_frame_ref(ctx->last_pic, frame); | ||
| 802 | if (ret < 0) | 801 | if (ret < 0) |
| 803 | return ret; | 802 | return ret; |
| 804 | } | 803 | } |
| @@ -643,8 +643,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 642 unmodified lines | |||
| 643 | return ret; | 643 | return ret; |
| 644 | } | 644 | } |
| 645 | 645 | ||
| 646 | av_frame_unref(s->prev_frame); | 646 | if ((ret = av_frame_replace(s->prev_frame, frame)) < 0) |
| 647 | if ((ret = av_frame_ref(s->prev_frame, frame)) < 0) | ||
| 648 | return ret; | 647 | return ret; |
| 649 | 648 | ||
| 650 | *got_frame = 1; | 649 | *got_frame = 1; |
| @@ -127,8 +127,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 126 unmodified lines | |||
| 127 | 127 | ||
| 128 | frame->pict_type = (frame->flags & AV_FRAME_FLAG_KEY) ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; | 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); | 130 | if ((ret = av_frame_replace(s->prev_frame, frame)) < 0) |
| 131 | if ((ret = av_frame_ref(s->prev_frame, frame)) < 0) | ||
| 132 | return ret; | 131 | return ret; |
| 133 | 132 | ||
| 134 | *got_frame = 1; | 133 | *got_frame = 1; |
| @@ -102,8 +102,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 101 unmodified lines | |||
| 102 | dst += frame->linesize[0]; | 102 | dst += frame->linesize[0]; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | av_frame_unref(s->previous_frame); | 105 | if ((ret = av_frame_replace(s->previous_frame, frame)) < 0) |
| 106 | if ((ret = av_frame_ref(s->previous_frame, frame)) < 0) | ||
| 107 | return ret; | 106 | return ret; |
| 108 | 107 | ||
| 109 | if (avpkt->flags & AV_PKT_FLAG_KEY) { | 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); | 1062 | ret = av_frame_replace(s->last_frame, pict); |
| 1063 | ret = av_frame_ref(s->last_frame, pict); | ||
| 1064 | if (ret < 0) | 1063 | if (ret < 0) |
| 1065 | return ret; | 1064 | return ret; |
| 1066 | 1065 | ||
| @@ -307,8 +307,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 306 unmodified lines | |||
| 307 | #endif | 307 | #endif |
| 308 | memcpy(p->data[1], a->pal, AVPALETTE_SIZE); | 308 | memcpy(p->data[1], a->pal, AVPALETTE_SIZE); |
| 309 | 309 | ||
| 310 | av_frame_unref(ref); | 310 | if ((ret = av_frame_replace(ref, p)) < 0) |
| 311 | if ((ret = av_frame_ref(ref, p)) < 0) | ||
| 312 | return ret; | 311 | return ret; |
| 313 | 312 | ||
| 314 | if (intra) | 313 | if (intra) |
| @@ -1996,8 +1996,7 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame, · 1995 unmodified lines | |||
| 1996 | return ret; | 1996 | return ret; |
| 1997 | } | 1997 | } |
| 1998 | } else { | 1998 | } else { |
| 1999 | av_frame_unref(qf->frame); | 1999 | ret = av_frame_replace(qf->frame, frame); |
| 2000 | ret = av_frame_ref(qf->frame, frame); | ||
| 2001 | if (ret < 0) | 2000 | if (ret < 0) |
| 2002 | return ret; | 2001 | return ret; |
| 2003 | } | 2002 | } |
| @@ -385,8 +385,7 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 384 unmodified lines | |||
| 385 | pkt->size = encode_frame(s, pict, pkt->data); | 385 | pkt->size = encode_frame(s, pict, pkt->data); |
| 386 | 386 | ||
| 387 | /* save the current frame */ | 387 | /* save the current frame */ |
| 388 | av_frame_unref(s->previous_frame); | 388 | ret = av_frame_replace(s->previous_frame, pict); |
| 389 | ret = av_frame_ref(s->previous_frame, pict); | ||
| 390 | if (ret < 0) { | 389 | if (ret < 0) { |
| 391 | av_log(avctx, AV_LOG_ERROR, "cannot add reference\n"); | 390 | av_log(avctx, AV_LOG_ERROR, "cannot add reference\n"); |
| 392 | return ret; | 391 | return ret; |
| @@ -566,8 +566,7 @@ static int smc_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 565 unmodified lines | |||
| 566 | // write chunk length | 566 | // write chunk length |
| 567 | AV_WB24(pkt->data + 1, pkt->size); | 567 | AV_WB24(pkt->data + 1, pkt->size); |
| 568 | 568 | ||
| 569 | av_frame_unref(s->prev_frame); | 569 | ret = av_frame_replace(s->prev_frame, frame); |
| 570 | ret = av_frame_ref(s->prev_frame, frame); | ||
| 571 | if (ret < 0) { | 570 | if (ret < 0) { |
| 572 | av_log(avctx, AV_LOG_ERROR, "cannot add reference\n"); | 571 | av_log(avctx, AV_LOG_ERROR, "cannot add reference\n"); |
| 573 | return ret; | 572 | return ret; |
| @@ -1887,8 +1887,7 @@ redo_frame: · 1886 unmodified lines | |||
| 1887 | (s->avctx->flags&AV_CODEC_FLAG_PSNR) ? SNOW_MAX_PLANES : 0, | 1887 | (s->avctx->flags&AV_CODEC_FLAG_PSNR) ? SNOW_MAX_PLANES : 0, |
| 1888 | s->current_picture->pict_type); | 1888 | s->current_picture->pict_type); |
| 1889 | if (s->avctx->flags & AV_CODEC_FLAG_RECON_FRAME) { | 1889 | if (s->avctx->flags & AV_CODEC_FLAG_RECON_FRAME) { |
| 1890 | av_frame_unref(avci->recon_frame); | 1890 | av_frame_replace(avci->recon_frame, s->current_picture); |
| 1891 | av_frame_ref(avci->recon_frame, s->current_picture); | ||
| 1892 | } | 1891 | } |
| 1893 | 1892 | ||
| 1894 | pkt->size = ff_rac_terminate(c, 0); | 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 | if (!s->nonref) { | 766 | if (!s->nonref) { |
| 767 | av_frame_unref(s->prev); | 767 | result = av_frame_replace(s->prev, cur); |
| 768 | result = av_frame_ref(s->prev, cur); | ||
| 769 | if (result < 0) | 768 | if (result < 0) |
| 770 | return result; | 769 | return result; |
| 771 | } | 770 | } |
| @@ -454,8 +454,7 @@ static int vmdvideo_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 453 unmodified lines | |||
| 454 | memcpy(frame->data[1], s->palette, PALETTE_COUNT * 4); | 454 | memcpy(frame->data[1], s->palette, PALETTE_COUNT * 4); |
| 455 | 455 | ||
| 456 | /* shuffle frames */ | 456 | /* shuffle frames */ |
| 457 | av_frame_unref(s->prev_frame); | 457 | if ((ret = av_frame_replace(s->prev_frame, frame)) < 0) |
| 458 | if ((ret = av_frame_ref(s->prev_frame, frame)) < 0) | ||
| 459 | return ret; | 458 | return ret; |
| 460 | 459 | ||
| 461 | *got_frame = 1; | 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 | if (avctx->pix_fmt == AV_PIX_FMT_YUVA420P) { | 609 | if (avctx->pix_fmt == AV_PIX_FMT_YUVA420P) { |
| 610 | av_frame_unref(s->alpha_context->frames[VP56_FRAME_CURRENT]); | 610 | if ((ret = av_frame_replace(s->alpha_context->frames[VP56_FRAME_CURRENT], p)) < 0) { |
| 611 | if ((ret = av_frame_ref(s->alpha_context->frames[VP56_FRAME_CURRENT], p)) < 0) { | ||
| 612 | av_frame_unref(p); | 611 | av_frame_unref(p); |
| 613 | if (res == VP56_SIZE_CHANGE) | 612 | if (res == VP56_SIZE_CHANGE) |
| 614 | ff_set_dimensions(avctx, 0, 0); | 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 | next: | 764 | next: |
| 766 | if ((p->flags & AV_FRAME_FLAG_KEY) || s->golden_frame) { | 765 | if ((p->flags & AV_FRAME_FLAG_KEY) || s->golden_frame) { |
| 767 | av_frame_unref(s->frames[VP56_FRAME_GOLDEN]); | 766 | if ((res = av_frame_replace(s->frames[VP56_FRAME_GOLDEN], p)) < 0) |
| 768 | if ((res = av_frame_ref(s->frames[VP56_FRAME_GOLDEN], p)) < 0) | ||
| 769 | return res; | 767 | return res; |
| 770 | } | 768 | } |
| 771 | 769 | ||
| @@ -622,8 +622,7 @@ static int xan_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 621 unmodified lines | |||
| 622 | if (xan_wc3_decode_frame(s, frame) < 0) | 622 | if (xan_wc3_decode_frame(s, frame) < 0) |
| 623 | return AVERROR_INVALIDDATA; | 623 | return AVERROR_INVALIDDATA; |
| 624 | 624 | ||
| 625 | av_frame_unref(s->last_frame); | 625 | if ((ret = av_frame_replace(s->last_frame, frame)) < 0) |
| 626 | if ((ret = av_frame_ref(s->last_frame, frame)) < 0) | ||
| 627 | return ret; | 626 | return ret; |
| 628 | 627 | ||
| 629 | *got_frame = 1; | 628 | *got_frame = 1; |
| @@ -93,8 +93,7 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, AVFrame *pic, · 92 unmodified lines | |||
| 93 | dst -= pic->linesize[0]; | 93 | dst -= pic->linesize[0]; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | av_frame_unref(zc->previous_frame); | 96 | if ((ret = av_frame_replace(zc->previous_frame, pic)) < 0) |
| 97 | if ((ret = av_frame_ref(zc->previous_frame, pic)) < 0) | ||
| 98 | return ret; | 97 | return ret; |
| 99 | 98 | ||
| 100 | *got_frame = 1; | 99 | *got_frame = 1; |