summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libhb/common.h3
-rw-r--r--libhb/encx264.c20
-rw-r--r--test/test.c15
3 files changed, 31 insertions, 7 deletions
diff --git a/libhb/common.h b/libhb/common.h
index 0bd8971e3..eba152f35 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -124,7 +124,8 @@ struct hb_job_s
int pass;
int h264_13;
int h264_level;
-
+ int crf;
+
/* Audio tracks:
Indexes in hb_title_t's audios list, starting from 0.
-1 indicates the end of the list */
diff --git a/libhb/encx264.c b/libhb/encx264.c
index a72a9603e..1bc24866c 100644
--- a/libhb/encx264.c
+++ b/libhb/encx264.c
@@ -77,11 +77,23 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
if( job->vquality >= 0.0 && job->vquality <= 1.0 )
{
- /* Constant QP */
- param.rc.i_rc_method = X264_RC_CQP;
- param.rc.i_qp_constant = 51 - job->vquality * 51;
- hb_log( "encx264: encoding at constant QP %d",
+ switch(job->crf)
+ {
+ case 1:
+ /*Constant RF*/
+ param.rc.i_rc_method = X264_RC_CRF;
+ param.rc.f_rf_constant = 51 - job->vquality * 51;
+ hb_log( "encx264: Encoding at constant RF %f", param.rc.f_rf_constant );
+ break;
+
+ case 0:
+ /*Constant QP*/
+ param.rc.i_rc_method = X264_RC_CQP;
+ param.rc.i_qp_constant = 51 - job->vquality * 51;
+ hb_log( "encx264: encoding at constant QP %d",
param.rc.i_qp_constant );
+ break;
+ }
}
else
{
diff --git a/test/test.c b/test/test.c
index de499f4fd..9d6543006 100644
--- a/test/test.c
+++ b/test/test.c
@@ -41,6 +41,7 @@ static int mux = 0;
static int acodec = 0;
static int chapter_start = 0;
static int chapter_end = 0;
+static int crf = 0;
/* Exit cleanly on Ctrl-C */
static volatile int die = 0;
@@ -412,6 +413,11 @@ static int HandleEvents( hb_handle_t * h )
}
job->file = strdup( output );
+ if( crf )
+ {
+ job->crf = 1;
+ }
+
if( twoPass )
{
job->pass = 1;
@@ -538,6 +544,7 @@ static void ShowHelp()
fprintf( stderr, " kHz)\n"
" -b, --vb <kb/s> Set video bitrate (default: 1000)\n"
" -q, --quality <float> Set video quality (0.0..1.0)\n"
+ " -Q, --crf Use with -q for CRF instead of CQP\n"
" -S, --size <MB> Set target size\n"
" -B, --ab <kb/s> Set audio bitrate (default: 128)\n"
" -w, --width <number> Set picture width\n"
@@ -583,7 +590,8 @@ static int ParseOptions( int argc, char ** argv )
{ "ab", required_argument, NULL, 'B' },
{ "rate", required_argument, NULL, 'r' },
{ "arate", required_argument, NULL, 'R' },
-
+ { "crf", no_argument, NULL, 'Q' },
+
{ 0, 0, 0, 0 }
};
@@ -591,7 +599,7 @@ static int ParseOptions( int argc, char ** argv )
int c;
c = getopt_long( argc, argv,
- "hvuC:f:i:o:t:c:a:s:e:E:2dgw:l:n:b:q:S:B:r:R:",
+ "hvuC:f:i:o:t:c:a:s:e:E:2dgw:l:n:b:q:S:B:r:R:Q",
long_options, &option_index );
if( c < 0 )
{
@@ -769,6 +777,9 @@ static int ParseOptions( int argc, char ** argv )
case 'B':
abitrate = atoi( optarg );
break;
+ case 'Q':
+ crf = 1;
+ break;
default:
fprintf( stderr, "unknown option (%s)\n", argv[optind] );