]> git.sesse.net Git - ffmpeg/commit
vc2enc: do not allocate packet until exact frame size is known
authorRostislav Pehlivanov <atomnuker@gmail.com>
Wed, 2 Mar 2016 12:37:09 +0000 (12:37 +0000)
committerRostislav Pehlivanov <atomnuker@gmail.com>
Fri, 4 Mar 2016 22:40:58 +0000 (22:40 +0000)
commitb88be742fac7a77a8095e8155ba8790db4b77568
tree0bbf0dd664338a2ddbefcc6a7c5af0d445da1bc8
parent3c658e2655179fa2738a7806a342f89a17bd9230
vc2enc: do not allocate packet until exact frame size is known

This commit solves most of the crashes and issues with the encoder and
the bitrate setting. Now the encoder will always allocate the absolute
lowest amount of memory regardless of what the bitrate has been set to.
Therefore if a user inputs a very low bitrate the encoder will use the
maximum possible quantization (basically zero out all coefficients),
allocate a packet and encode it. There is no coupling between the
bitrate and the allocation size and so no crashes because the buffer
isn't large enough.

The maximum quantizer was raised to the size of the table now to both
keep the overshoot at ridiculous bitrates low and to improve quality
with higher bit depths (since the coefficients grow larger per transform
quantizing them to the same relative level requires larger quantization
indices).

Since the quantization index start follows the previous quantization
index for that slice, the quantization step was reduced to a static 1
to improve performance. Previously with quant/5 the step was usually
set to 0 upon start (and was later clipped to 1), that isn't a big change.
As the step size increases so does the amount of bits leftover and so
the redistribution algorithm has to iterate more and thus waste more
time.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
libavcodec/vc2enc.c