[FFmpeg-devel] [PATCH 11/13] lavc/jpeg2000: Minimize calls to av_codec_is_encoder()

Tomas Härdin tjoppen at acc.umu.se
Wed Jun 15 13:20:35 EEST 2022


tis 2022-06-14 klockan 17:04 +0200 skrev Andreas Rheinhardt:
> Tomas Härdin:
> > 
> > 
> 
> Why call it at all? Why not just add a new parameter to
> ff_jpeg2000_init_component that is always set to 1 when called from
> the
> encoder and 0 when called from the decoder?

Oh yeah that's even simpler

> (And is this really a bottleneck?)

Callgrind certainly thinks so. It's called hundreds of thousands of
times per frame. Remember that this is in the serial part of the code
so any savings there get amplified -threads fold fps-wise. init_tile()
accounts for a mere 0.8 seconds out of 59.8 partly thanks to this.
Here's a rough breakdown for the curious with -threads 64:

 0.8 everything up to and including init_tiles()
23.0 jpeg2000_read_bitstream_packets()
 0.1 jpeg2000_setup_cbs()
24.1 jpeg2000_decode_cb()
 9.8 jpeg2000_idwt()
 2.0 jpeg2000_mct_write_frame()
 0.0 jpeg2000_dec_cleanup()

jpeg2000_read_bitstream_packets() is obviously the main thing to focus
on for anyone wanting to bump the speed up even more. But it's nasty.
Maybe it could be tile-threaded, but it takes some doing..

/Tomas



More information about the ffmpeg-devel mailing list