[FFmpeg-devel] flashsvenc.c - sampling block size too low

Benjamin Larsson banan
Fri May 18 11:17:02 CEST 2007


Jason Askew wrote:
> diff of 2 pass encoding for flashsvenc.c attached
> I'm still actively working on this.  A few things to know:
> const int TP_BLCK_SIZE = 8;
> This can go up to 16.  Things get even slower and the resulting gains
> have been minimal to nonexistence.  That may be a different story
> depending on what the screen cap is of.

I suggest that you use an option to set the max block size to search
for. A default of 8 might be reasonable.

> Each possible block size is iterated through, compared, and zlib'ed.
> This is not efficient.
> Current optimization I'm working on is to do the block compare one
> time only at pixel size of 16x16, and using that data over again for
> larger block sizes.

I had this thought also, it should give a considerable boost.

> The big bottle neck is zlib'ing blocks just to determine their size.
> I'm investigating a theory that optimal block size can be 'chased
> down' by following the least block size through an array, limiting the
> number of zlib compressions that need to take place.

I think a 16x16 block compare cache will give enough speedup to search
all sizes without resorting to guessing the most optimal size.

> Some array pointer access can still be optimized.

One more thing to test is how to compress the blocks. Currently zlib is
called with compress2. Afaik this writes a complete zlib packet with
header. So for every block that is compressed we get a header+data. It
might be possible to not close the zlib packet and chain lots of packet
data after each other. And thus get better compression.

Anyway good work.

Benjamin Larsson

More information about the ffmpeg-devel mailing list