summaryrefslogtreecommitdiff
path: root/fftools
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-04-30 12:32:32 +0200
committerAnton Khirnov <anton@khirnov.net>2023-05-08 10:38:59 +0200
commitc26a6c5a523032873dc8bc7fe467b15fdcaa93ea (patch)
treefa8b3a996a99ca39072e8cf2527480457cf0fe90 /fftools
parent5356f5ed23677d9ed683154b03760ed003ec7f25 (diff)
downloadffmpeg-c26a6c5a523032873dc8bc7fe467b15fdcaa93ea.tar.gz
fftools/ffmpeg_filter: use av_buffer_replace() to improve code
It is shorter and more efficient.
Diffstat (limited to 'fftools')
-rw-r--r--fftools/ffmpeg_filter.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 34c51c23d9..0165be8f77 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1415,7 +1415,9 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr
AVFrameSideData *sd;
int ret;
- av_buffer_unref(&ifp->hw_frames_ctx);
+ ret = av_buffer_replace(&ifp->hw_frames_ctx, frame->hw_frames_ctx);
+ if (ret < 0)
+ return ret;
ifilter->format = frame->format;
@@ -1433,12 +1435,6 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr
if (sd)
ifp->displaymatrix = av_memdup(sd->data, sizeof(int32_t) * 9);
- if (frame->hw_frames_ctx) {
- ifp->hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx);
- if (!ifp->hw_frames_ctx)
- return AVERROR(ENOMEM);
- }
-
return 0;
}