id	summary	reporter	owner	description	type	status	priority	component	version	resolution	keywords	cc	blockedby	blocking	reproduced	analyzed
2122	Commit 75d900d makes skipping in the input while using swresample very slow	eelco	michael	"In commit 75d900d52edb281eb4ab4989800e75abe7555937 the memory allocation method used for allocating memory for audio switched to using av_mallocz (from av_malloc). I’m curious to learn why this change was made, because it makes skipping in a file (using -ss before the input) several orders of magnitude slower.

Version 1.0:
{{{
% time ./ffmpeg -ss 2 -i ~/Downloads/example.mkv -t 1 -vcodec copy -f matroska -map 0:0 -acodec ac3 -async 1 -map 0:1 -y /dev/null
ffmpeg version 1.0 Copyright (c) 2000-2012 the FFmpeg developers
  built on Dec 28 2012 14:35:11 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
...
frame=   74 fps=7.2 q=-1.0 Lsize=       0kB time=00:00:01.01 bitrate=   0.0kbits/s    
video:28kB audio:56kB subtitle:0 global headers:0kB muxing overhead -100.000000%
       10.32 real         3.52 user         6.74 sys
}}}

Version 1.0 with commit 75d900d reverted:
{{{
% time ./ffmpeg -ss 2 -i ~/Downloads/example.mkv -t 1 -vcodec copy -f matroska -map 0:0 -acodec ac3 -async 1 -map 0:1 -y /dev/null
ffmpeg version 1.0 Copyright (c) 2000-2012 the FFmpeg developers
  built on Dec 28 2012 14:35:11 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
...
frame=   74 fps=0.0 q=-1.0 Lsize=       0kB time=00:00:01.01 bitrate=   0.0kbits/s    
video:28kB audio:56kB subtitle:0 global headers:0kB muxing overhead -100.000000%
        0.46 real         0.05 user         0.35 sys
}}}

(Note that it wasn’t a clean build, so the ‘built on’ banner didn’t change.)

I also tried testing with an -ss value of 100, but killed it after a about 5 minutes. With the commit reverted it takes about a second.

We found the cause of the problem by profiling ffmpeg and saw that all time was being spent in av_mallocz. I haven’t looked into it any further, but I suspect that the av_mallocz call exposes a bug that previously didn’t cause any problem.

I also checked the 1.1 release, the problem is still there."	defect	closed	important	swresample	git-master	fixed	regression				1	0
