diff options
author | Tobias Rapp <t.rapp@noa-archive.com> | 2017-03-06 08:53:28 +0100 |
---|---|---|
committer | Tobias Rapp <t.rapp@noa-archive.com> | 2017-03-17 11:55:16 +0100 |
commit | 205b8fd078e50aa3f7f401646dbb73de1bb35a10 (patch) | |
tree | abbe5fa686d8d01a1c3bde998e712e5c26f6a561 /libavcodec/r210enc.c | |
parent | 8db301deadfcf113fb274881e65afcbe3e1bd645 (diff) | |
download | ffmpeg-205b8fd078e50aa3f7f401646dbb73de1bb35a10.tar.gz |
avcodec: estimate output bitrate for uncompressed video codecs
Allows to get a more realistic total bitrate (and estimated file size)
in avi_write_header. Previously a static default value of 200k was
assumed.
Adds an internal helper function for bitrate guessing.
Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/r210enc.c')
-rw-r--r-- | libavcodec/r210enc.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libavcodec/r210enc.c b/libavcodec/r210enc.c index 65b3c069fc..a55e5434f3 100644 --- a/libavcodec/r210enc.c +++ b/libavcodec/r210enc.c @@ -24,6 +24,18 @@ #include "internal.h" #include "bytestream.h" +static av_cold int encode_init(AVCodecContext *avctx) +{ + int aligned_width = FFALIGN(avctx->width, + avctx->codec_id == AV_CODEC_ID_R10K ? 1 : 64); + + avctx->bits_per_coded_sample = 32; + if (avctx->width > 0) + avctx->bit_rate = ff_guess_coded_bitrate(avctx) * aligned_width / avctx->width; + + return 0; +} + static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic, int *got_packet) { @@ -73,6 +85,7 @@ AVCodec ff_r210_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Uncompressed RGB 10-bit"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_R210, + .init = encode_init, .encode2 = encode_frame, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB48, AV_PIX_FMT_NONE }, .capabilities = AV_CODEC_CAP_INTRA_ONLY, @@ -84,6 +97,7 @@ AVCodec ff_r10k_encoder = { .long_name = NULL_IF_CONFIG_SMALL("AJA Kona 10-bit RGB Codec"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_R10K, + .init = encode_init, .encode2 = encode_frame, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB48, AV_PIX_FMT_NONE }, .capabilities = AV_CODEC_CAP_INTRA_ONLY, @@ -95,6 +109,7 @@ AVCodec ff_avrp_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Avid 1:1 10-bit RGB Packer"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_AVRP, + .init = encode_init, .encode2 = encode_frame, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB48, AV_PIX_FMT_NONE }, .capabilities = AV_CODEC_CAP_INTRA_ONLY, |