From d7443f67331e392b580564f815a34c5762f71f03 Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Sun, 20 Feb 2005 01:26:03 +0000 Subject: [PATCH] Configurable level. Levels are still not enforced; it's up to the user to select a level compatible with the rest of the encoding options. Patch by Jeff Clagg . git-svn-id: svn://svn.videolan.org/x264/trunk@132 df754926-b1dd-0310-bc7b-ec298dee348c --- common/common.c | 2 ++ encoder/set.c | 6 ++---- x264.c | 6 ++++++ x264.h | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/common/common.c b/common/common.c index 9550df1e..dbdc3f0d 100644 --- a/common/common.c +++ b/common/common.c @@ -55,6 +55,8 @@ void x264_param_default( x264_param_t *param ) param->i_fps_num = 25; param->i_fps_den = 1; param->i_maxframes = 0; + param->i_level_idc = 40; /* level 4.0 is sufficient for 720x576 with + 16 reference frames */ /* Encoder parameters */ param->i_frame_reference = 1; diff --git a/encoder/set.c b/encoder/set.c index 8d559d3c..1adb819f 100644 --- a/encoder/set.c +++ b/encoder/set.c @@ -43,10 +43,8 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param ) sps->i_profile_idc = PROFILE_MAIN; else sps->i_profile_idc = PROFILE_BASELINE; + sps->i_level_idc = param->i_level_idc; - /* FIXME: level 4.0 is sufficient for 720x576 with 16 reference frames, - * but this should be adjustable */ - sps->i_level_idc = 40; sps->b_constraint_set0 = 0; sps->b_constraint_set1 = 0; sps->b_constraint_set2 = 0; @@ -213,7 +211,7 @@ void x264_sps_write( bs_t *s, x264_sps_t *sps ) } else { - bs_write( s, 8, 255); /* aspect_ration_idc (extented) */ + bs_write( s, 8, 255); /* aspect_ratio_idc (extented) */ bs_write( s, 16, sps->vui.i_sar_width ); bs_write( s, 16, sps->vui.i_sar_height ); } diff --git a/x264.c b/x264.c index 52d40066..3ffa4f22 100644 --- a/x264.c +++ b/x264.c @@ -139,6 +139,7 @@ static void Help( x264_param_t *defaults ) " - none, spatial, temporal\n" " -m, --subme Subpixel motion estimation quality: 1=fast, 5=best. [%d]\n" "\n" + " --level Specify IDC level\n" " -s, --sar width:height Specify Sample Aspect Ratio\n" " --fps Specify framerate\n" " --frames Maximum number of frames to encode\n" @@ -213,6 +214,7 @@ static int Parse( int argc, char **argv, #define OPT_FRAMES 273 #define OPT_FPS 274 #define OPT_DIRECT 275 +#define OPT_LEVEL 276 static struct option long_options[] = { @@ -238,6 +240,7 @@ static int Parse( int argc, char **argv, { "analyse", required_argument, NULL, 'A' }, { "direct", required_argument, NULL, OPT_DIRECT }, { "subme", required_argument, NULL, 'm' }, + { "level", required_argument, NULL, OPT_LEVEL }, { "rcsens", required_argument, NULL, OPT_RCSENS }, { "rcbuf", required_argument, NULL, OPT_RCBUF }, { "rcinitbuf",required_argument,NULL, OPT_RCIBUF }, @@ -385,6 +388,9 @@ static int Parse( int argc, char **argv, case 'm': param->analyse.i_subpel_refine = atoi(optarg); break; + case OPT_LEVEL: + param->i_level_idc = atoi(optarg); + break; case OPT_RCBUF: param->rc.i_rc_buffer_size = atoi(optarg); break; diff --git a/x264.h b/x264.h index fa24186a..1c1b3251 100644 --- a/x264.h +++ b/x264.h @@ -94,6 +94,7 @@ typedef struct int i_width; int i_height; int i_csp; /* CSP of encoded bitstream, only i420 supported */ + int i_level_idc; struct { -- 2.47.3