History

all: Use av_frame_replace() where appropriate

Andreas Rheinhardt committed 3 years ago

Commit cfa47fd1 parent 048778631 files · +34 −67Browse files

Showing the changes to libavcodec (28 of 31 files). Show all

Unified · Split

28 files
  1. libavcodec/agm.c +1 −2
  2. libavcodec/arbc.c +1 −2
  3. libavcodec/audiotoolboxenc.c +1 −2
  4. libavcodec/bink.c +1 −2
  5. libavcodec/cdgraphics.c +1 −2
  6. libavcodec/dxa.c +1 −2
  7. libavcodec/eacmv.c +2 −3
  8. libavcodec/eamad.c +1 −2
  9. libavcodec/eatgv.c +1 −2
  10. libavcodec/escape124.c +1 −2
  11. libavcodec/gif.c +1 −2
  12. libavcodec/imm4.c +1 −2
  13. libavcodec/interplayvideo.c +1 −2
  14. libavcodec/mss2.c +1 −2
  15. libavcodec/mv30.c +1 −2
  16. libavcodec/mwsc.c +1 −2
  17. libavcodec/pdvdec.c +1 −2
  18. libavcodec/pngenc.c +1 −2
  19. libavcodec/qpeg.c +1 −2
  20. libavcodec/qsvenc.c +1 −2
  21. libavcodec/qtrleenc.c +1 −2
  22. libavcodec/smcenc.c +1 −2
  23. libavcodec/snowenc.c +1 −2
  24. libavcodec/svq1dec.c +1 −2
  25. libavcodec/vmdvideo.c +1 −2
  26. libavcodec/vp56.c +2 −4
  27. libavcodec/xan.c +1 −2
  28. libavcodec/zerocodec.c +1 −2
libavcodec/agm.c+1−2
@@ -1203,8 +1203,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 1202 unmodified lines
12031203 if (ret < 0)
12041204 return ret;
12051205
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)
12081207 return ret;
12091208
12101209 frame->crop_top = avctx->coded_height - avctx->height;
libavcodec/arbc.c+1−2
@@ -166,8 +166,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 165 unmodified lines
166166 prev_pixels -= fill_tile4(avctx, fill, frame);
167167 }
168168
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)
171170 return ret;
172171
173172 frame->pict_type = prev_pixels <= 0 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
libavcodec/audiotoolboxenc.c+1−2
@@ -483,8 +483,7 @@ static OSStatus ffat_encode_callback(AudioConverterRef converter, UInt32 *nb_pac · 482 unmodified lines
483483 if (*nb_packets > frame->nb_samples)
484484 *nb_packets = frame->nb_samples;
485485
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);
488487 if (ret < 0) {
489488 *nb_packets = 0;
490489 return ret;
libavcodec/bink.c+1−2
@@ -1300,8 +1300,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 1299 unmodified lines
13001300 emms_c();
13011301
13021302 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)
13051304 return ret;
13061305 }
13071306
libavcodec/cdgraphics.c+1−2
@@ -344,8 +344,7 @@ static int cdg_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 343 unmodified lines
344344 return ret;
345345
346346 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);
349348 if (ret < 0)
350349 return ret;
351350 break;
libavcodec/dxa.c+1−2
@@ -317,8 +317,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 316 unmodified lines
317317 return AVERROR_INVALIDDATA;
318318 }
319319
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)
322321 return ret;
323322
324323 *got_frame = 1;
libavcodec/eacmv.c+2−3
@@ -210,9 +210,8 @@ static int cmv_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 209 unmodified lines
210210 cmv_decode_intra(s, frame, buf+2, buf_end);
211211 }
212212
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)
216215 return ret;
217216
218217 *got_frame = 1;
libavcodec/eamad.c+1−2
@@ -317,8 +317,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 316 unmodified lines
317317 *got_frame = 1;
318318
319319 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)
322321 return ret;
323322 }
324323
libavcodec/eatgv.c+1−2
@@ -338,8 +338,7 @@ static int tgv_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 337 unmodified lines
338338 }
339339 }
340340
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)
343342 return ret;
344343
345344 *got_frame = 1;
libavcodec/escape124.c+1−2
@@ -362,8 +362,7 @@ static int escape124_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 361 unmodified lines
362362 "Escape sizes: %i, %i, %i\n",
363363 frame_size, buf_size, get_bits_count(&gb) / 8);
364364
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)
367366 return ret;
368367
369368 *got_frame = 1;
libavcodec/gif.c+1−2
@@ -503,8 +503,7 @@ static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 502 unmodified lines
503503 }
504504
505505 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);
508507 if (ret < 0)
509508 return ret;
510509 }
libavcodec/imm4.c+1−2
@@ -453,8 +453,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 452 unmodified lines
453453 if (ret < 0)
454454 return ret;
455455
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)
458457 return ret;
459458 } else {
460459 if (!s->prev_frame->data[0]) {
libavcodec/interplayvideo.c+1−2
@@ -1340,9 +1340,8 @@ FF_ENABLE_DEPRECATION_WARNINGS · 1339 unmodified lines
13401340 *got_frame = send_buffer;
13411341
13421342 /* shuffle frames */
1343− av_frame_unref(s->second_last_frame);
13441343 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)
13461345 return ret;
13471346
13481347 /* report that the buffer was completely consumed */
libavcodec/mss2.c+1−2
@@ -797,8 +797,7 @@ static int mss2_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 796 unmodified lines
797797 av_log(avctx, AV_LOG_WARNING, "buffer not fully consumed\n");
798798
799799 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);
802801 if (ret < 0)
803802 return ret;
804803 }
libavcodec/mv30.c+1−2
@@ -643,8 +643,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 642 unmodified lines
643643 return ret;
644644 }
645645
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)
648647 return ret;
649648
650649 *got_frame = 1;
libavcodec/mwsc.c+1−2
@@ -127,8 +127,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 126 unmodified lines
127127
128128 frame->pict_type = (frame->flags & AV_FRAME_FLAG_KEY) ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
129129
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)
132131 return ret;
133132
134133 *got_frame = 1;
libavcodec/pdvdec.c+1−2
@@ -102,8 +102,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 101 unmodified lines
102102 dst += frame->linesize[0];
103103 }
104104
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)
107106 return ret;
108107
109108 if (avpkt->flags & AV_PKT_FLAG_KEY) {
libavcodec/pngenc.c+1−2
@@ -1059,8 +1059,7 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt, · 1058 unmodified lines
10591059 }
10601060 }
10611061
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);
10641063 if (ret < 0)
10651064 return ret;
10661065
libavcodec/qpeg.c+1−2
@@ -307,8 +307,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 306 unmodified lines
307307 #endif
308308 memcpy(p->data[1], a->pal, AVPALETTE_SIZE);
309309
310− av_frame_unref(ref);
311− if ((ret = av_frame_ref(ref, p)) < 0)
310+ if ((ret = av_frame_replace(ref, p)) < 0)
312311 return ret;
313312
314313 if (intra)
libavcodec/qsvenc.c+1−2
@@ -1996,8 +1996,7 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame, · 1995 unmodified lines
19961996 return ret;
19971997 }
19981998 } else {
1999− av_frame_unref(qf->frame);
2000− ret = av_frame_ref(qf->frame, frame);
1999+ ret = av_frame_replace(qf->frame, frame);
20012000 if (ret < 0)
20022001 return ret;
20032002 }
libavcodec/qtrleenc.c+1−2
@@ -385,8 +385,7 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 384 unmodified lines
385385 pkt->size = encode_frame(s, pict, pkt->data);
386386
387387 /* 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);
390389 if (ret < 0) {
391390 av_log(avctx, AV_LOG_ERROR, "cannot add reference\n");
392391 return ret;
libavcodec/smcenc.c+1−2
@@ -566,8 +566,7 @@ static int smc_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 565 unmodified lines
566566 // write chunk length
567567 AV_WB24(pkt->data + 1, pkt->size);
568568
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);
571570 if (ret < 0) {
572571 av_log(avctx, AV_LOG_ERROR, "cannot add reference\n");
573572 return ret;
libavcodec/snowenc.c+1−2
@@ -1887,8 +1887,7 @@ redo_frame: · 1886 unmodified lines
18871887 (s->avctx->flags&AV_CODEC_FLAG_PSNR) ? SNOW_MAX_PLANES : 0,
18881888 s->current_picture->pict_type);
18891889 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);
18921891 }
18931892
18941893 pkt->size = ff_rac_terminate(c, 0);
libavcodec/svq1dec.c+1−2
@@ -764,8 +764,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, AVFrame *cur, · 763 unmodified lines
764764 }
765765
766766 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);
769768 if (result < 0)
770769 return result;
771770 }
libavcodec/vmdvideo.c+1−2
@@ -454,8 +454,7 @@ static int vmdvideo_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 453 unmodified lines
454454 memcpy(frame->data[1], s->palette, PALETTE_COUNT * 4);
455455
456456 /* 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)
459458 return ret;
460459
461460 *got_frame = 1;
libavcodec/vp56.c+2−4
@@ -607,8 +607,7 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, AVFrame *rframe, · 606 unmodified lines
607607 }
608608
609609 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) {
612611 av_frame_unref(p);
613612 if (res == VP56_SIZE_CHANGE)
614613 ff_set_dimensions(avctx, 0, 0);
@@ -764,8 +763,7 @@ static int ff_vp56_decode_mbs(AVCodecContext *avctx, void *data, · 149 unmodified lines
764763
765764 next:
766765 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)
769767 return res;
770768 }
771769
libavcodec/xan.c+1−2
@@ -622,8 +622,7 @@ static int xan_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 621 unmodified lines
622622 if (xan_wc3_decode_frame(s, frame) < 0)
623623 return AVERROR_INVALIDDATA;
624624
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)
627626 return ret;
628627
629628 *got_frame = 1;
libavcodec/zerocodec.c+1−2
@@ -93,8 +93,7 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, AVFrame *pic, · 92 unmodified lines
9393 dst -= pic->linesize[0];
9494 }
9595
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)
9897 return ret;
9998
10099 *got_frame = 1;

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