lavc/decode: move unrefcount_frame() right before its only caller

Will make wrapping it in deprecation guards simpler.
This commit is contained in:
Anton Khirnov 2021-01-25 11:55:32 +01:00
parent da99b4c878
commit 25f4304ebb

View File

@ -165,52 +165,6 @@ static int extract_packet_props(AVCodecInternal *avci, AVPacket *pkt)
return ret; return ret;
} }
static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame)
{
int ret;
/* move the original frame to our backup */
av_frame_unref(avci->to_free);
av_frame_move_ref(avci->to_free, frame);
/* now copy everything except the AVBufferRefs back
* note that we make a COPY of the side data, so calling av_frame_free() on
* the caller's frame will work properly */
ret = av_frame_copy_props(frame, avci->to_free);
if (ret < 0)
return ret;
memcpy(frame->data, avci->to_free->data, sizeof(frame->data));
memcpy(frame->linesize, avci->to_free->linesize, sizeof(frame->linesize));
if (avci->to_free->extended_data != avci->to_free->data) {
int planes = avci->to_free->channels;
int size = planes * sizeof(*frame->extended_data);
if (!size) {
av_frame_unref(frame);
return AVERROR_BUG;
}
frame->extended_data = av_malloc(size);
if (!frame->extended_data) {
av_frame_unref(frame);
return AVERROR(ENOMEM);
}
memcpy(frame->extended_data, avci->to_free->extended_data,
size);
} else
frame->extended_data = frame->data;
frame->format = avci->to_free->format;
frame->width = avci->to_free->width;
frame->height = avci->to_free->height;
frame->channel_layout = avci->to_free->channel_layout;
frame->nb_samples = avci->to_free->nb_samples;
frame->channels = avci->to_free->channels;
return 0;
}
int ff_decode_bsfs_init(AVCodecContext *avctx) int ff_decode_bsfs_init(AVCodecContext *avctx)
{ {
AVCodecInternal *avci = avctx->internal; AVCodecInternal *avci = avctx->internal;
@ -739,6 +693,52 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr
return 0; return 0;
} }
static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame)
{
int ret;
/* move the original frame to our backup */
av_frame_unref(avci->to_free);
av_frame_move_ref(avci->to_free, frame);
/* now copy everything except the AVBufferRefs back
* note that we make a COPY of the side data, so calling av_frame_free() on
* the caller's frame will work properly */
ret = av_frame_copy_props(frame, avci->to_free);
if (ret < 0)
return ret;
memcpy(frame->data, avci->to_free->data, sizeof(frame->data));
memcpy(frame->linesize, avci->to_free->linesize, sizeof(frame->linesize));
if (avci->to_free->extended_data != avci->to_free->data) {
int planes = avci->to_free->channels;
int size = planes * sizeof(*frame->extended_data);
if (!size) {
av_frame_unref(frame);
return AVERROR_BUG;
}
frame->extended_data = av_malloc(size);
if (!frame->extended_data) {
av_frame_unref(frame);
return AVERROR(ENOMEM);
}
memcpy(frame->extended_data, avci->to_free->extended_data,
size);
} else
frame->extended_data = frame->data;
frame->format = avci->to_free->format;
frame->width = avci->to_free->width;
frame->height = avci->to_free->height;
frame->channel_layout = avci->to_free->channel_layout;
frame->nb_samples = avci->to_free->nb_samples;
frame->channels = avci->to_free->channels;
return 0;
}
static int compat_decode(AVCodecContext *avctx, AVFrame *frame, static int compat_decode(AVCodecContext *avctx, AVFrame *frame,
int *got_frame, const AVPacket *pkt) int *got_frame, const AVPacket *pkt)
{ {