[FFmpeg-devel] [PATCH 4/5] ffmpeg: keep bitdepth where possible
Christophe Gisquet
christophe.gisquet at gmail.com
Wed Aug 20 10:10:47 CEST 2014
Thanks to av_get_pix_fmt_loss, we can determine more precisely if a
conversion will incur some kind of loss. If this loss doesn't modify
in particular bitdepth, the input bitdepth can be reused for the
output.
---
ffmpeg.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/ffmpeg.c b/ffmpeg.c
index fa907b4..2bfa047 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2774,6 +2774,15 @@ static int transcode_init(void)
enc_ctx->bits_per_raw_sample = frame_bits_per_raw_sample;
}
+ if (!(av_get_pix_fmt_loss(enc_ctx->pix_fmt, dec_ctx->pix_fmt, 0)
+ & (FF_LOSS_DEPTH|FF_LOSS_COLORSPACE|FF_LOSS_CHROMA))) {
+ const AVPixFmtDescriptor *pix1 = av_pix_fmt_desc_get(enc_ctx->pix_fmt);
+ const AVPixFmtDescriptor *pix2 = av_pix_fmt_desc_get(dec_ctx->pix_fmt);
+ if (pix1 && pix2 &&
+ av_get_bits_per_pixel(pix1) == av_get_bits_per_pixel(pix2))
+ enc_ctx->bits_per_raw_sample = dec_ctx->bits_per_raw_sample;
+ }
+
if (ost->forced_keyframes) {
if (!strncmp(ost->forced_keyframes, "expr:", 5)) {
ret = av_expr_parse(&ost->forced_keyframes_pexpr, ost->forced_keyframes+5,
--
1.9.2.msysgit.0
More information about the ffmpeg-devel
mailing list