[FFmpeg-trac] #3625(swscale:new): Unscaled conversion from yuv420p to gray is slow
FFmpeg
trac at avcodec.org
Fri May 9 00:21:30 CEST 2014
#3625: Unscaled conversion from yuv420p to gray is slow
----------------------------------+--------------------------------------
Reporter: andreasg | Type: defect
Status: new | Priority: normal
Component: swscale | Version: git-master
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
----------------------------------+--------------------------------------
Summary of the bug:
It is very slow to use sws_scale to convert from yuv420p to gray without
scaling. It was still fast in FFmpeg 1.0.1 and was slow in FFmpeg 2.0 and
newer, including the current git head. The fast version needs 0.93 ms per
frame (1920x1088) and the slow version 6.99 ms.
How to reproduce:
{{{
ffmpeg version 2.2.git-996fffb Copyright (c) 2000-2014 the FFmpeg
developers
built on May 8 2014 13:51:28 with gcc 4.8.2 (GCC) 20131212 (Red Hat
4.8.2-7)
gray_convert_ctx = sws_getContext (w, h, codec_ctx->pix_fmt, w, h,
PIX_FMT_GRAY8, SWS_POINT, 0, 0, 0);
sws_scale (gray_convert_ctx, frame->data, frame->linesize, 0, h,
gray_frame->data, gray_frame->linesize);
}}}
This can be fixed by adding dstFormat==AV_PIX_FMT_GRAY8 here:
libswscale/utils.c:1638:
{{{
/* unscaled special cases */
if (unscaled && !usesHFilter && !usesVFilter &&
(c->srcRange == c->dstRange || isAnyRGB(dstFormat) || dstFormat ==
AV_PIX_FMT_GRAY8)) {
ff_get_unscaled_swscale(c);
}}}
The patch produces the following output:
[swscaler @ 0x25d2240] nearest neighbor / point scaler, from yuv420p to
gray using MMXEXT
[swscaler @ 0x25d2240] using unscaled yuv420p -> gray special converter
That is probably not the correct way to patch it for all situations but
some sort of test is needed here.
Patches should be submitted to the ffmpeg-devel mailing list and not this
bug tracker.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/3625>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list