[PATCH] libavcodec: add bit rate support to the RoQ video encoder
This patch is based mostly on the one by Victor Luchits for 6.1, which was in turn based on my patch for 3.3.2. This patch is for the current repository version, 8.1. I've made a few minor changes to the code to make it about ten percent faster than the original code. The patch allows -b:v to control the target bit rate for the compressed video. The tolerance for the video stream can be set using -bt:v, but the encoder will allow lower bit rate frames through when the frame being encoded is too simple to generate the desired bit rate. We could pad the stream to force it to the target bit rate, but that is currently considered not necessary. We only need the bit rate to not exceed the desired rate (within the tolerance) to avoid issues with devices like single or double speed CDROMs. If not specified, the tolerance defaults to five percent of the set bit rate. The patch also adds keyframe detection on the decoding of the video stream. It had been suggested when Vic posted the first patch that something like binary search be applied to increase the speed of encoding. I did that - it made the encoding slower. This makes sense since 1) the relationship between lambda and the bit rate changes with the content of the frame, and 2) the relationship between lambda and the bit rate is a non-linear function. Binary search is only faster if the range to be searched has equal probability of the target being at any point within the range. This is not the case for the RoQ encoder. As lambda increases, the bit rate drops at a slower rate. If you modify the binary search to account for this, the algorithm becomes more and more like the one currently used. The patch here is approximately twenty-five to thirty percent faster than the best binary search routine I could manage on a range of different encoded videos, be it live action, anime, or computer generated video. I welcome all suggestions and criticisms. I'd love nothing better than to improve the performance of the encoder, if possible. Signed-off-by: Joe Fenton <jlfenton65@gmail.com>
Hi! Any chance this patch might get reviewed and merged into mainline ffmpeg? There's more than one person out there that would find it useful, especially in the 32X development community. Thanks! -- Best regards, Victor
participants (2)
-
Joseph Fenton -
Victor Luchits