Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save qyot27/5543894 to your computer and use it in GitHub Desktop.
Save qyot27/5543894 to your computer and use it in GitHub Desktop.
Support for Fade Compensation in libx264
From bcd7b1ac1f688c082bccc7296e4461b1e8bff331 Mon Sep 17 00:00:00 2001
From: Stephen Hutchinson <[email protected]>
Date: Wed, 8 May 2013 00:19:52 -0400
Subject: [PATCH] Support for Fade Compensation in libx264.
Special-casing this is probably beyond my abilities, so this patch
can *only* be used with builds of libx264 that use the fadecomp
patch, as it will probably fail to build against non-fadecomp builds.
---
libavcodec/libx264.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 13d3ff2..e0873cf 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -55,6 +55,7 @@ typedef struct X264Context {
int cqp;
int aq_mode;
float aq_strength;
+ float fade_compensate;
char *psy_rd;
int psy;
int rc_lookahead;
@@ -412,6 +413,8 @@ static av_cold int X264_init(AVCodecContext *avctx)
x4->params.rc.i_aq_mode = x4->aq_mode;
if (x4->aq_strength >= 0)
x4->params.rc.f_aq_strength = x4->aq_strength;
+ if (x4->fade_compensate >= 0)
+ x4->params.rc.f_fade_compensate = x4->fade_compensate;
PARSE_X264_OPT("psy-rd", psy_rd);
PARSE_X264_OPT("deblock", deblock);
PARSE_X264_OPT("partitions", partitions);
@@ -643,6 +646,7 @@ static const AVOption options[] = {
{ "variance", "Variance AQ (complexity mask)", 0, AV_OPT_TYPE_CONST, {.i64 = X264_AQ_VARIANCE}, INT_MIN, INT_MAX, VE, "aq_mode" },
{ "autovariance", "Auto-variance AQ (experimental)", 0, AV_OPT_TYPE_CONST, {.i64 = X264_AQ_AUTOVARIANCE}, INT_MIN, INT_MAX, VE, "aq_mode" },
{ "aq-strength", "AQ strength. Reduces blocking and blurring in flat and textured areas.", OFFSET(aq_strength), AV_OPT_TYPE_FLOAT, {.dbl = -1}, -1, FLT_MAX, VE},
+ { "fade-compensate", "Fade compensation. Tries to allot more bitrate to fades.", OFFSET(fade_compensate), AV_OPT_TYPE_FLOAT, {.dbl = -1}, -1, FLT_MAX, VE},
{ "psy", "Use psychovisual optimizations.", OFFSET(psy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE },
{ "psy-rd", "Strength of psychovisual optimization, in <psy-rd>:<psy-trellis> format.", OFFSET(psy_rd), AV_OPT_TYPE_STRING, {0 }, 0, 0, VE},
{ "rc-lookahead", "Number of frames to look ahead for frametype and ratecontrol", OFFSET(rc_lookahead), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE },
--
1.8.1.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment