[FFmpeg-devel] H264 cleanup performance effects

wm4 nfxjfg at googlemail.com
Sun Mar 22 16:49:28 CET 2015


On Sun, 22 Mar 2015 15:12:04 +0100
Michael Niedermayer <michaelni at gmx.at> wrote:

> Hi anton, everyone else

I appreciate that you contacted the author of these patches as well.

> the "cosmetic" commits from yesterday
> (665e0c10a63d31dd6c7b1fba14db074625d54614..fa7c08d5e192aea77fdfb7f52c44c196a3ba4452) /
> (d8a45d2d49f54fde042b195f9d5859251252493d..c28ed1d743443e783537d279ae721be3bbdf7646)
> 
> cause a ~1% speed loss in the H.264 decoder which is probably the
> most important decoder in the codebase
> 
> after the patchset:
> -threads 1 -benchmark -i cathedral-beta2-400extra-crop-avc.mp4 -an -f null -
> utime=5.448s
> utime=5.424s
> utime=5.436s
> utime=5.428s
> utime=5.448s
> 
> 
> before the patchset:
> -threads 1 -benchmark -i cathedral-beta2-400extra-crop-avc.mp4 -an -f null -
> utime=5.360s
> utime=5.328s
> utime=5.356s
> utime=5.376s
> utime=5.360s
> 
> Testing has been done with a single thread as the results with
> multiple threads where inconsistent/unstable
> 
> The speedloss is reproduceable with ffmpeg as well as libav

At this point I'd argue that 1% speedloss in exchange for much cleaner
and saner code is not the world's end. Especially because ffmpeg is
probably already the fastest software decoder on x86, and cleaner code
may in fact help improving the decoder further. (But then I don't know
the h264 decoder, and may be talking out of my ass.)

> also in some of the commits there where hidden optimizations:
> for example in a12d3188cbec15e22070e139fa5cc541da07e2c3 there was:
> 
> -    for (list = 0; list < 2; list++) {
> +    for (list = 0; list < sl->list_count; list++) {
> 
> @@ -130,16 +130,20 @@ void ff_h264_direct_ref_list_init(const H264Context *const h, H264SliceContext *
>      cur->mbaff = FRAME_MBAFF(h);
> 
>      sl->col_fieldoff = 0;
> +
> +    if (sl->list_count != 2 || !sl->ref_count[1])
> +        return;
> +
> 
> @@ -340,20 +340,24 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl)
>  void ff_h264_fill_mbaff_ref_list(H264Context *h, H264SliceContext *sl)
>  {
>      int list, i, j;
> -    for (list = 0; list < 2; list++) { //FIXME try list_count
> +    for (list = 0; list < sl->list_count; list++) { //FIXME try list_count
> 
> 



More information about the ffmpeg-devel mailing list