@@ -2,6 +2,9 @@ The last version increases of all libraries were on
2023-02-09
API changes, most recent first:
+2023-0x-xx - xxxxxxxxxx - lavc 60.11.100 - avcodec.h
+ Add AV_CODEC_FLAG_STRICT_BITRATE.
+
2023-04-10 - xxxxxxxxxx - lavu 58.6.100 - frame.h
av_frame_get_plane_buffer() now accepts const AVFrame*.
@@ -1106,6 +1106,17 @@ static int aac_encode_frame(AVCodecContext
*avctx, AVPacket *avpkt,
too_many_bits = FFMIN(too_many_bits, 6144 * s->channels - 3);
too_few_bits = FFMIN(FFMAX(rate_bits - rate_bits/4, target_bits),
too_many_bits);
+ if (avctx->flags & AV_CODEC_FLAG_STRICT_BITRATE) {
+ if (rate_bits < frame_bits) {
+ /* temporarily degrade quality and repeat until frame fits */
+ s->lambda *= 0.75f;
+ continue;
+ }
+ /* reset lambda when solution is found */
+ s->lambda = avctx->global_quality > 0 ? avctx->global_quality : 120;
+ break;
+ }
+
/* When using ABR, be strict (but only for increasing) */
too_few_bits = too_few_bits - too_few_bits/8;
too_many_bits = too_many_bits + too_many_bits/2;
@@ -333,6 +333,10 @@ typedef struct RcOverride{
* H.263 advanced intra coding / MPEG-4 AC prediction
*/
#define AV_CODEC_FLAG_AC_PRED (1 << 24)
+/**
+ * Treat specified bit rate as upper bound up to frame level.
+ */
+#define AV_CODEC_FLAG_STRICT_BITRATE (1 << 25)
/**
* interlaced motion estimation
*/
@@ -29,7 +29,7 @@
#include "version_major.h"
-#define LIBAVCODEC_VERSION_MINOR 10
+#define LIBAVCODEC_VERSION_MINOR 11
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
--
2.40.0.634.g4ca3ef3211-goog
In certain use cases, controlling the maximum frame size is critical. An example is when transmitting AAC packets over Bluetooth A2DP. While the spec allows the packets be fragmented (though UNRECOMMENDED), in practice most headsets do not recognize nor reassemble such packets. In this patch, we add a new mode to specify that the configured bit rate should be followed strictly up to frame level. Signed-off-by: Jeremy Wu <jrwu@chromium.org> --- doc/APIchanges | 3 +++ libavcodec/aacenc.c | 11 +++++++++++ libavcodec/avcodec.h | 4 ++++ libavcodec/version.h | 2 +- 4 files changed, 19 insertions(+), 1 deletion(-)