mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
all: Use av_frame_replace() where appropriate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
0487786ffe
commit
cfa47fd331
@ -1203,8 +1203,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
av_frame_unref(s->prev_frame);
|
||||
if ((ret = av_frame_ref(s->prev_frame, frame)) < 0)
|
||||
if ((ret = av_frame_replace(s->prev_frame, frame)) < 0)
|
||||
return ret;
|
||||
|
||||
frame->crop_top = avctx->coded_height - avctx->height;
|
||||
|
@ -166,8 +166,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
prev_pixels -= fill_tile4(avctx, fill, frame);
|
||||
}
|
||||
|
||||
av_frame_unref(s->prev_frame);
|
||||
if ((ret = av_frame_ref(s->prev_frame, frame)) < 0)
|
||||
if ((ret = av_frame_replace(s->prev_frame, frame)) < 0)
|
||||
return ret;
|
||||
|
||||
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
|
||||
if (*nb_packets > frame->nb_samples)
|
||||
*nb_packets = frame->nb_samples;
|
||||
|
||||
av_frame_unref(at->encoding_frame);
|
||||
ret = av_frame_ref(at->encoding_frame, frame);
|
||||
ret = av_frame_replace(at->encoding_frame, frame);
|
||||
if (ret < 0) {
|
||||
*nb_packets = 0;
|
||||
return ret;
|
||||
|
@ -1300,8 +1300,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
emms_c();
|
||||
|
||||
if (c->version > 'b') {
|
||||
av_frame_unref(c->last);
|
||||
if ((ret = av_frame_ref(c->last, frame)) < 0)
|
||||
if ((ret = av_frame_replace(c->last, frame)) < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -344,8 +344,7 @@ static int cdg_decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
return ret;
|
||||
|
||||
cdg_scroll(cc, cdg_data, frame, inst == CDG_INST_SCROLL_COPY);
|
||||
av_frame_unref(cc->frame);
|
||||
ret = av_frame_ref(cc->frame, frame);
|
||||
ret = av_frame_replace(cc->frame, frame);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
break;
|
||||
|
@ -317,8 +317,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
av_frame_unref(c->prev);
|
||||
if ((ret = av_frame_ref(c->prev, frame)) < 0)
|
||||
if ((ret = av_frame_replace(c->prev, frame)) < 0)
|
||||
return ret;
|
||||
|
||||
*got_frame = 1;
|
||||
|
@ -210,9 +210,8 @@ static int cmv_decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
cmv_decode_intra(s, frame, buf+2, buf_end);
|
||||
}
|
||||
|
||||
av_frame_unref(s->last2_frame);
|
||||
av_frame_move_ref(s->last2_frame, s->last_frame);
|
||||
if ((ret = av_frame_ref(s->last_frame, frame)) < 0)
|
||||
FFSWAP(AVFrame*, s->last2_frame, s->last_frame);
|
||||
if ((ret = av_frame_replace(s->last_frame, frame)) < 0)
|
||||
return ret;
|
||||
|
||||
*got_frame = 1;
|
||||
|
@ -317,8 +317,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
*got_frame = 1;
|
||||
|
||||
if (chunk_type != MADe_TAG) {
|
||||
av_frame_unref(s->last_frame);
|
||||
if ((ret = av_frame_ref(s->last_frame, frame)) < 0)
|
||||
if ((ret = av_frame_replace(s->last_frame, frame)) < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -338,8 +338,7 @@ static int tgv_decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
}
|
||||
}
|
||||
|
||||
av_frame_unref(s->last_frame);
|
||||
if ((ret = av_frame_ref(s->last_frame, frame)) < 0)
|
||||
if ((ret = av_frame_replace(s->last_frame, frame)) < 0)
|
||||
return ret;
|
||||
|
||||
*got_frame = 1;
|
||||
|
@ -362,8 +362,7 @@ static int escape124_decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
"Escape sizes: %i, %i, %i\n",
|
||||
frame_size, buf_size, get_bits_count(&gb) / 8);
|
||||
|
||||
av_frame_unref(s->frame);
|
||||
if ((ret = av_frame_ref(s->frame, frame)) < 0)
|
||||
if ((ret = av_frame_replace(s->frame, frame)) < 0)
|
||||
return ret;
|
||||
|
||||
*got_frame = 1;
|
||||
|
@ -503,8 +503,7 @@ static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
}
|
||||
|
||||
if (!s->image) {
|
||||
av_frame_unref(s->last_frame);
|
||||
ret = av_frame_ref(s->last_frame, pict);
|
||||
ret = av_frame_replace(s->last_frame, pict);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
@ -453,8 +453,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
av_frame_unref(s->prev_frame);
|
||||
if ((ret = av_frame_ref(s->prev_frame, frame)) < 0)
|
||||
if ((ret = av_frame_replace(s->prev_frame, frame)) < 0)
|
||||
return ret;
|
||||
} else {
|
||||
if (!s->prev_frame->data[0]) {
|
||||
|
@ -1340,9 +1340,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
*got_frame = send_buffer;
|
||||
|
||||
/* shuffle frames */
|
||||
av_frame_unref(s->second_last_frame);
|
||||
FFSWAP(AVFrame*, s->second_last_frame, s->last_frame);
|
||||
if ((ret = av_frame_ref(s->last_frame, frame)) < 0)
|
||||
if ((ret = av_frame_replace(s->last_frame, frame)) < 0)
|
||||
return ret;
|
||||
|
||||
/* report that the buffer was completely consumed */
|
||||
|
@ -797,8 +797,7 @@ static int mss2_decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
av_log(avctx, AV_LOG_WARNING, "buffer not fully consumed\n");
|
||||
|
||||
if (c->mvX < 0 || c->mvY < 0) {
|
||||
av_frame_unref(ctx->last_pic);
|
||||
ret = av_frame_ref(ctx->last_pic, frame);
|
||||
ret = av_frame_replace(ctx->last_pic, frame);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
@ -643,8 +643,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
return ret;
|
||||
}
|
||||
|
||||
av_frame_unref(s->prev_frame);
|
||||
if ((ret = av_frame_ref(s->prev_frame, frame)) < 0)
|
||||
if ((ret = av_frame_replace(s->prev_frame, frame)) < 0)
|
||||
return ret;
|
||||
|
||||
*got_frame = 1;
|
||||
|
@ -127,8 +127,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
|
||||
frame->pict_type = (frame->flags & AV_FRAME_FLAG_KEY) ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
|
||||
|
||||
av_frame_unref(s->prev_frame);
|
||||
if ((ret = av_frame_ref(s->prev_frame, frame)) < 0)
|
||||
if ((ret = av_frame_replace(s->prev_frame, frame)) < 0)
|
||||
return ret;
|
||||
|
||||
*got_frame = 1;
|
||||
|
@ -102,8 +102,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
dst += frame->linesize[0];
|
||||
}
|
||||
|
||||
av_frame_unref(s->previous_frame);
|
||||
if ((ret = av_frame_ref(s->previous_frame, frame)) < 0)
|
||||
if ((ret = av_frame_replace(s->previous_frame, frame)) < 0)
|
||||
return ret;
|
||||
|
||||
if (avpkt->flags & AV_PKT_FLAG_KEY) {
|
||||
|
@ -1059,8 +1059,7 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt,
|
||||
}
|
||||
}
|
||||
|
||||
av_frame_unref(s->last_frame);
|
||||
ret = av_frame_ref(s->last_frame, pict);
|
||||
ret = av_frame_replace(s->last_frame, pict);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
@ -307,8 +307,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
memcpy(p->data[1], a->pal, AVPALETTE_SIZE);
|
||||
|
||||
av_frame_unref(ref);
|
||||
if ((ret = av_frame_ref(ref, p)) < 0)
|
||||
if ((ret = av_frame_replace(ref, p)) < 0)
|
||||
return ret;
|
||||
|
||||
if (intra)
|
||||
|
@ -1996,8 +1996,7 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame,
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
av_frame_unref(qf->frame);
|
||||
ret = av_frame_ref(qf->frame, frame);
|
||||
ret = av_frame_replace(qf->frame, frame);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
@ -385,8 +385,7 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
pkt->size = encode_frame(s, pict, pkt->data);
|
||||
|
||||
/* save the current frame */
|
||||
av_frame_unref(s->previous_frame);
|
||||
ret = av_frame_ref(s->previous_frame, pict);
|
||||
ret = av_frame_replace(s->previous_frame, pict);
|
||||
if (ret < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "cannot add reference\n");
|
||||
return ret;
|
||||
|
@ -566,8 +566,7 @@ static int smc_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
// write chunk length
|
||||
AV_WB24(pkt->data + 1, pkt->size);
|
||||
|
||||
av_frame_unref(s->prev_frame);
|
||||
ret = av_frame_ref(s->prev_frame, frame);
|
||||
ret = av_frame_replace(s->prev_frame, frame);
|
||||
if (ret < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "cannot add reference\n");
|
||||
return ret;
|
||||
|
@ -1887,8 +1887,7 @@ redo_frame:
|
||||
(s->avctx->flags&AV_CODEC_FLAG_PSNR) ? SNOW_MAX_PLANES : 0,
|
||||
s->current_picture->pict_type);
|
||||
if (s->avctx->flags & AV_CODEC_FLAG_RECON_FRAME) {
|
||||
av_frame_unref(avci->recon_frame);
|
||||
av_frame_ref(avci->recon_frame, s->current_picture);
|
||||
av_frame_replace(avci->recon_frame, s->current_picture);
|
||||
}
|
||||
|
||||
pkt->size = ff_rac_terminate(c, 0);
|
||||
|
@ -764,8 +764,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, AVFrame *cur,
|
||||
}
|
||||
|
||||
if (!s->nonref) {
|
||||
av_frame_unref(s->prev);
|
||||
result = av_frame_ref(s->prev, cur);
|
||||
result = av_frame_replace(s->prev, cur);
|
||||
if (result < 0)
|
||||
return result;
|
||||
}
|
||||
|
@ -454,8 +454,7 @@ static int vmdvideo_decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
memcpy(frame->data[1], s->palette, PALETTE_COUNT * 4);
|
||||
|
||||
/* shuffle frames */
|
||||
av_frame_unref(s->prev_frame);
|
||||
if ((ret = av_frame_ref(s->prev_frame, frame)) < 0)
|
||||
if ((ret = av_frame_replace(s->prev_frame, frame)) < 0)
|
||||
return ret;
|
||||
|
||||
*got_frame = 1;
|
||||
|
@ -607,8 +607,7 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
|
||||
}
|
||||
|
||||
if (avctx->pix_fmt == AV_PIX_FMT_YUVA420P) {
|
||||
av_frame_unref(s->alpha_context->frames[VP56_FRAME_CURRENT]);
|
||||
if ((ret = av_frame_ref(s->alpha_context->frames[VP56_FRAME_CURRENT], p)) < 0) {
|
||||
if ((ret = av_frame_replace(s->alpha_context->frames[VP56_FRAME_CURRENT], p)) < 0) {
|
||||
av_frame_unref(p);
|
||||
if (res == VP56_SIZE_CHANGE)
|
||||
ff_set_dimensions(avctx, 0, 0);
|
||||
@ -764,8 +763,7 @@ static int ff_vp56_decode_mbs(AVCodecContext *avctx, void *data,
|
||||
|
||||
next:
|
||||
if ((p->flags & AV_FRAME_FLAG_KEY) || s->golden_frame) {
|
||||
av_frame_unref(s->frames[VP56_FRAME_GOLDEN]);
|
||||
if ((res = av_frame_ref(s->frames[VP56_FRAME_GOLDEN], p)) < 0)
|
||||
if ((res = av_frame_replace(s->frames[VP56_FRAME_GOLDEN], p)) < 0)
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -622,8 +622,7 @@ static int xan_decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
if (xan_wc3_decode_frame(s, frame) < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
av_frame_unref(s->last_frame);
|
||||
if ((ret = av_frame_ref(s->last_frame, frame)) < 0)
|
||||
if ((ret = av_frame_replace(s->last_frame, frame)) < 0)
|
||||
return ret;
|
||||
|
||||
*got_frame = 1;
|
||||
|
@ -93,8 +93,7 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, AVFrame *pic,
|
||||
dst -= pic->linesize[0];
|
||||
}
|
||||
|
||||
av_frame_unref(zc->previous_frame);
|
||||
if ((ret = av_frame_ref(zc->previous_frame, pic)) < 0)
|
||||
if ((ret = av_frame_replace(zc->previous_frame, pic)) < 0)
|
||||
return ret;
|
||||
|
||||
*got_frame = 1;
|
||||
|
@ -781,9 +781,8 @@ static int apply_palette(AVFilterLink *inlink, AVFrame *in, AVFrame **outf)
|
||||
|
||||
set_processing_window(s->diff_mode, s->last_in, in,
|
||||
s->last_out, out, &x, &y, &w, &h);
|
||||
av_frame_unref(s->last_in);
|
||||
av_frame_unref(s->last_out);
|
||||
if ((ret = av_frame_ref(s->last_in, in)) < 0 ||
|
||||
if ((ret = av_frame_replace(s->last_in, in)) < 0 ||
|
||||
(ret = av_frame_ref(s->last_out, out)) < 0 ||
|
||||
(ret = ff_inlink_make_frame_writable(inlink, &s->last_in)) < 0) {
|
||||
av_frame_free(&out);
|
||||
|
@ -1076,8 +1076,7 @@ static int ddagrab_request_frame(AVFilterLink *outlink)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
av_frame_unref(dda->last_frame);
|
||||
ret = av_frame_ref(dda->last_frame, frame);
|
||||
ret = av_frame_replace(dda->last_frame, frame);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
@ -819,8 +819,7 @@ int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags)
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
hwmap = (HWMapDescriptor*)src->buf[0]->data;
|
||||
av_frame_unref(dst);
|
||||
return av_frame_ref(dst, hwmap->source);
|
||||
return av_frame_replace(dst, hwmap->source);
|
||||
}
|
||||
}
|
||||
|
||||
@ -950,6 +949,5 @@ fail:
|
||||
int ff_hwframe_map_replace(AVFrame *dst, const AVFrame *src)
|
||||
{
|
||||
HWMapDescriptor *hwmap = (HWMapDescriptor*)dst->buf[0]->data;
|
||||
av_frame_unref(hwmap->source);
|
||||
return av_frame_ref(hwmap->source, src);
|
||||
return av_frame_replace(hwmap->source, src);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user