mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-03-13 09:00:40 +08:00
swscale/tests/swscale: always allocate frame in scale_legacy()
Legacy swscale may overwrite the pixel formats in the context (see handle_formats() in libswscale/utils.c). This may lead to an issue where, when sws_frame_start() allocates a new frame, it uses the wrong pixel format. Instead of fixing the issue in swscale, just make sure dst is always allocated prior to calling the legacy scaler. Sponsored-by: Sovereign Tech Fund Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
This commit is contained in:
@@ -224,14 +224,20 @@ static int scale_legacy(AVFrame *dst, const AVFrame *src, struct mode mode,
|
||||
sws_legacy->dither = mode.dither;
|
||||
sws_legacy->threads = opts.threads;
|
||||
|
||||
av_frame_unref(dst);
|
||||
dst->width = sws_legacy->dst_w;
|
||||
dst->height = sws_legacy->dst_h;
|
||||
dst->format = sws_legacy->dst_format;
|
||||
ret = av_frame_get_buffer(dst, 0);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
|
||||
if ((ret = sws_init_context(sws_legacy, NULL, NULL)) < 0)
|
||||
goto error;
|
||||
|
||||
int64_t time = av_gettime_relative();
|
||||
for (int i = 0; ret >= 0 && i < opts.iters; i++) {
|
||||
unref_buffers(dst);
|
||||
for (int i = 0; ret >= 0 && i < opts.iters; i++)
|
||||
ret = sws_scale_frame(sws_legacy, dst, src);
|
||||
}
|
||||
*out_time = av_gettime_relative() - time;
|
||||
|
||||
error:
|
||||
|
||||
Reference in New Issue
Block a user