<html><head><meta http-equiv="content-type" content="text/html; charset=GB2312"><style>body { line-height: 1.5; }body { font-size: 10.5pt; font-family: 'Segoe UI'; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span></span><span style="font-family: "" segoe="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'="">From 42f66a8e7b25865945222447fcaa924a5580669d Mon Sep 17 00:00:00 2001<br>From: xuefeng <xuefeng@multicorewareinc.com><br>Date: Thu, 24 Sep 2015 15:54:17 +0800<br>Subject: [PATCH] Support 12bit and add ultra calss based on AVC-Ultra<br> Specification from Panasonic Corporation, T-REC-H.264-201402-I!!PDF-E.pdf and<br> C-AVC Intra specification v1.1 20080404.doc<br><br>---<br> common/common.c | 69 +++-<br> common/common.h | 2 +-<br> common/macroblock.h | 6 +<br> common/set.h | 109 ++++++<br> configure | 6 +-<br> encoder/analyse.c | 15 +-<br> encoder/encoder.c | 913 +++++++++++++++++++++++++++++++++++++++++++++++++-<br> encoder/ratecontrol.c | 4 +-<br> encoder/set.c | 16 +-<br> x264.c | 37 +-<br> x264.h | 1 +<br> 11 files changed, 1146 insertions(+), 32 deletions(-)<br><br>diff --git a/common/common.c b/common/common.c<br>index 6999a00..012fbb2 100644<br>--- a/common/common.c<br>+++ b/common/common.c<br>@@ -453,7 +453,7 @@ static int profile_string_to_int( const char *str )<br> return -1;<br> }<br> <br>-int x264_param_apply_profile( x264_param_t *param, const char *profile )<br>+static int x264_param_apply_default_profile( x264_param_t *param, const char *profile )<br> {<br> if( !profile )<br> return 0;<br>@@ -514,6 +514,73 @@ int x264_param_apply_profile( x264_param_t *param, const char *profile )<br> return 0;<br> }<br> <br>+static int class_string_to_int( const char *str )<br>+{<br>+#if BIT_DEPTH == 10<br>+ if( !strcasecmp( str, "intra-480" ) )<br>+ return AVCULTRA_CLASS_480;<br>+ if( !strcasecmp( str, "intra-300" ) )<br>+ return AVCULTRA_CLASS_300;<br>+ if( !strcasecmp( str, "intra-200" ) )<br>+ return AVCULTRA_CLASS_200;<br>+ if( !strcasecmp( str, "intra-100" ) )<br>+ return AVCULTRA_CLASS_100;<br>+ if( !strcasecmp( str, "intra-50" ) )<br>+ return AVCULTRA_CLASS_50;<br>+<br>+ if( !strcasecmp( str, "xavc-class-x25" ) )<br>+ return XAVC_CLASS_X25;<br>+ if( !strcasecmp( str, "xavc-class-x35" ) )<br>+ return XAVC_CLASS_X35;<br>+ if( !strcasecmp( str, "xavc-class-x50" ) )<br>+ return XAVC_CLASS_X50;<br>+#elif BIT_DEPTH == 12<br>+ if( !strcasecmp( str, "intra-444-220" ) )<br>+ return AVCULTRA_CLASS_220;<br>+ if( !strcasecmp( str, "intra-480" ) )<br>+ return AVCULTRA_CLASS_480;<br>+ if( !strcasecmp( str, "intra-444-600" ) )<br>+ return AVCULTRA_CLASS_600;<br>+#endif<br>+ return 0;<br>+}<br>+<br>+int x264_param_apply_profile( x264_param_t *param, const char *profiles )<br>+{<br>+ if( !profiles )<br>+ return 0;<br>+ const char *profile = profiles;<br>+ // test whether the first param is a param for class ultra or class xavc<br>+ if( param->i_ex_class > 0)<br>+ {<br>+ int csp = param->i_ex_class;<br>+ param->i_ex_class = class_string_to_int( profile );<br>+#if BIT_DEPTH == 10<br>+ if ( AVCULTRA_CLASS_480 == param->i_ex_class && !( 422 == csp ) )<br>+ param->i_ex_class = 0;<br>+#elif BIT_DEPTH == 12<br>+ if ( AVCULTRA_CLASS_480 == param->i_ex_class && !( 444 == csp ) )<br>+ param->i_ex_class = 0;<br>+#endif<br>+ if( param->i_ex_class == 0 )<br>+ {<br>+ x264_log( NULL, X264_LOG_ERROR, "invalid constraint class: %s\n", profile );<br>+#if BIT_DEPTH == 10<br>+ x264_log( NULL, X264_LOG_ERROR, "%d bits constraint: intra-50, intra-100, intra-200, intra-300, intra-480\n", BIT_DEPTH );<br>+#elif BIT_DEPTH == 12<br>+ x264_log( NULL, X264_LOG_ERROR, "%d bits constraint support: intra-444-220, intra-480, intra-444-600 \n", BIT_DEPTH );<br>+#endif<br>+ return -1;<br>+ }<br>+ profile = profiles + (strlen( profile ) + 1);<br>+ if( 0 == *profile )<br>+ return 0;<br>+ }<br>+ x264_param_apply_default_profile( param, profile );<br>+<br>+ return 0;<br>+}<br>+<br> static int parse_enum( const char *arg, const char * const *names, int *dst )<br> {<br> for( int i = 0; names[i]; i++ )<br>diff --git a/common/common.h b/common/common.h<br>index 9cda187..e1ccdcc 100644<br>--- a/common/common.h<br>+++ b/common/common.h<br>@@ -109,7 +109,7 @@ do {\<br> <br> #define NALU_OVERHEAD 5 // startcode + NAL type costs 5 bytes per frame<br> #define FILLER_OVERHEAD (NALU_OVERHEAD+1)<br>-#define SEI_OVERHEAD (NALU_OVERHEAD - (h->param.b_annexb && !h->param.i_avcintra_class && (h->out.i_nal-1)))<br>+#define SEI_OVERHEAD (NALU_OVERHEAD - (h->param.b_annexb && !( h->param.i_avcintra_class || h->param.i_ex_class ) && (h->out.i_nal-1)))<br> <br> /****************************************************************************<br> * Includes<br>diff --git a/common/macroblock.h b/common/macroblock.h<br>index 7974f5a..41fac75 100644<br>--- a/common/macroblock.h<br>+++ b/common/macroblock.h<br>@@ -250,6 +250,12 @@ static const uint8_t i_chroma_qp_table[QP_MAX+1+12*2] =<br> {<br> 0, 0, 0, 0, 0, 0,<br> 0, 0, 0, 0, 0, 0,<br>+#if BIT_DEPTH > 11<br>+ QP(-24), QP(-23), QP(-22), QP(-21), QP(-20), QP(-19),<br>+#endif<br>+#if BIT_DEPTH > 10<br>+ QP(-18), QP(-17), QP(-16), QP(-15), QP(-14), QP(-13),<br>+#endif<br> #if BIT_DEPTH > 9<br> QP(-12),QP(-11),QP(-10), QP(-9), QP(-8), QP(-7),<br> #endif<br>diff --git a/common/set.h b/common/set.h<br>index 0d4f806..489dd80 100644<br>--- a/common/set.h<br>+++ b/common/set.h<br>@@ -37,6 +37,27 @@ enum profile_e<br> PROFILE_HIGH444_PREDICTIVE = 244,<br> };<br> <br>+enum class_e<br>+{<br>+ // avcultra class<br>+#if BIT_DEPTH == 10<br>+ AVCULTRA_CLASS_50 = 1,<br>+ AVCULTRA_CLASS_100,<br>+ AVCULTRA_CLASS_200,<br>+ AVCULTRA_CLASS_300,<br>+ AVCULTRA_CLASS_480,<br>+#elif BIT_DEPTH == 12<br>+ AVCULTRA_CLASS_220 = 1,<br>+ AVCULTRA_CLASS_480,<br>+ AVCULTRA_CLASS_600,<br>+#endif<br>+<br>+ // xavc class<br>+ XAVC_CLASS_X25,<br>+ XAVC_CLASS_X35,<br>+ XAVC_CLASS_X50,<br>+};<br>+<br> enum chroma_format_e<br> {<br> CHROMA_400 = 0,<br>@@ -257,6 +278,42 @@ static const uint8_t x264_cqm_avci50_4ic[16] =<br> 40,44,48,60<br> };<br> <br>+//2160p25_avci300 //TODO: The temporary quantization matrix<br>+static const uint8_t x264_cqm_avci300_2160_4ic[16] =<br>+{<br>+ 16,16,16,16,<br>+ 16,16,16,16,<br>+ 16,16,16,16,<br>+ 16,16,16,16<br>+};<br>+<br>+//2160p25_avci480 //TODO: The temporary quantization matrix<br>+static const uint8_t x264_cqm_avci480_2160_4ic[16] =<br>+{<br>+ 16,16,16,16,<br>+ 16,16,16,16,<br>+ 16,16,16,16,<br>+ 16,16,16,16<br>+};<br>+<br>+//2160p25_avci600 //TODO: The temporary quantization matrix<br>+static const uint8_t x264_cqm_avci600_2160_4ic[16] =<br>+{<br>+ 16,16,16,16,<br>+ 16,16,16,16,<br>+ 16,16,16,16,<br>+ 16,16,16,16<br>+};<br>+<br>+//1080p25_avci220 //TODO: The temporary quantization matrix<br>+static const uint8_t x264_cqm_avci220_1080_4ic[16] =<br>+{<br>+ 16,16,16,16,<br>+ 16,16,16,16,<br>+ 16,16,16,16,<br>+ 16,16,16,16<br>+};<br>+<br> // 1080i25_avci50,<br> static const uint8_t x264_cqm_avci50_1080i_8iy[64] =<br> {<br>@@ -340,6 +397,58 @@ static const uint8_t x264_cqm_avci100_720p_8iy[64] =<br> 32,32,32,34,34,36,38,42<br> };<br> <br>+// 2160p25_avci300,2160p50_avci300 //TODO: The temporary quantization matrix<br>+static const uint8_t x264_cqm_avci300_2160p_8iy[64] =<br>+{<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16<br>+};<br>+<br>+// 2160p25_avci480,2160p25_avci480 //TODO: The temporary quantization matrix<br>+static const uint8_t x264_cqm_avci480_2160p_8iy[64] =<br>+{<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16<br>+};<br>+<br>+// 2160p25_avci600 //TODO: The temporary quantization matrix<br>+static const uint8_t x264_cqm_avci600_2160p_8iy[64] =<br>+{<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16<br>+};<br>+<br>+// 1080p25_avci220 //TODO: The temporary quantization matrix<br>+static const uint8_t x264_cqm_avci220_1080p_8iy[64] =<br>+{<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16,<br>+ 16,16,16,16,16,16,16,16<br>+};<br>+<br> int x264_cqm_init( x264_t *h );<br> void x264_cqm_delete( x264_t *h );<br> int x264_cqm_parse_file( x264_t *h, const char *filename );<br>diff --git a/configure b/configure<br>index 57a47ac..c905df8 100755<br>--- a/configure<br>+++ b/configure<br>@@ -30,7 +30,7 @@ Configuration options:<br> --disable-thread disable multithreaded encoding<br> --enable-win32thread use win32threads (windows only)<br> --disable-interlaced disable interlaced encoding support<br>- --bit-depth=BIT_DEPTH set output bit depth (8-10) [8]<br>+ --bit-depth=BIT_DEPTH set output bit depth (8-12) [8]<br> --chroma-format=FORMAT output chroma format (420, 422, 444, all) [all]<br> <br> Advanced options:<br>@@ -481,8 +481,8 @@ for opt do<br> ;;<br> --bit-depth=*)<br> bit_depth="$optarg"<br>- if [ "$bit_depth" -lt "8" -o "$bit_depth" -gt "10" ]; then<br>- echo "Supplied bit depth must be in range [8,10]."<br>+ if [ "$bit_depth" -lt "8" -o "$bit_depth" -gt "12" ]; then<br>+ echo "Supplied bit depth must be in range [8,12]."<br> exit 1<br> fi<br> bit_depth=`expr $bit_depth + 0`<br>diff --git a/encoder/analyse.c b/encoder/analyse.c<br>index b82f647..5a22036 100644<br>--- a/encoder/analyse.c<br>+++ b/encoder/analyse.c<br>@@ -436,7 +436,7 @@ static void x264_mb_analyse_init( x264_t *h, x264_mb_analysis_t *a, int qp )<br> /* non-RD PCM decision is inaccurate (as is psy-rd), so don't do it.<br> * PCM cost can overflow with high lambda2, so cap it at COST_MAX. */<br> uint64_t pcm_cost = ((uint64_t)X264_PCM_COST*a->i_lambda2 + 128) >> 8;<br>- a->i_satd_pcm = !h->param.i_avcintra_class && !h->mb.i_psy_rd && a->i_mbrd && pcm_cost < COST_MAX ? pcm_cost : COST_MAX;<br>+ a->i_satd_pcm = !h->param.i_avcintra_class && !h->param.i_ex_class && !h->mb.i_psy_rd && a->i_mbrd && pcm_cost < COST_MAX ? pcm_cost : COST_MAX;<br> <br> a->b_fast_intra = 0;<br> a->b_avoid_topright = 0;<br>@@ -812,7 +812,7 @@ static void x264_mb_analyse_intra( x264_t *h, x264_mb_analysis_t *a, int i_satd_<br> <br> /*---------------- Try all mode and calculate their score ---------------*/<br> /* Disabled i16x16 for AVC-Intra compat */<br>- if( !h->param.i_avcintra_class )<br>+ if( !( h->param.i_avcintra_class || h->param.i_ex_class ) )<br> {<br> const int8_t *predict_mode = predict_16x16_mode_available( h->mb.i_neighbour_intra );<br> <br>@@ -3055,10 +3055,13 @@ intra_analysis:<br> if( analysis.i_mbrd )<br> x264_intra_rd( h, &analysis, COST_MAX );<br> <br>- i_cost = analysis.i_satd_i16x16;<br>- h->mb.i_type = I_16x16;<br>- COPY2_IF_LT( i_cost, analysis.i_satd_i4x4, h->mb.i_type, I_4x4 );<br>- COPY2_IF_LT( i_cost, analysis.i_satd_i8x8, h->mb.i_type, I_8x8 );<br>+ if ( !( h->param.i_avcintra_class || h->param.i_ex_class ) )<br>+ {<br>+ i_cost = analysis.i_satd_i16x16;<br>+ h->mb.i_type = I_16x16;<br>+ COPY2_IF_LT( i_cost, analysis.i_satd_i4x4, h->mb.i_type, I_4x4 );<br>+ COPY2_IF_LT( i_cost, analysis.i_satd_i8x8, h->mb.i_type, I_8x8 );<br>+ }<br> if( analysis.i_satd_pcm < i_cost )<br> h->mb.i_type = I_PCM;<br> <br>diff --git a/encoder/encoder.c b/encoder/encoder.c<br>index 79997b9..4722c98 100644<br>--- a/encoder/encoder.c<br>+++ b/encoder/encoder.c<br>@@ -410,6 +410,885 @@ static void x264_encoder_thread_init( x264_t *h )<br> }<br> #endif<br> <br>+#if BIT_DEPTH == 10<br>+static int apply_avcultra_class_50_profile( x264_t *h )<br>+{<br>+ if( h->param.nalu_process )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "nalu_process is not supported in AVC-Intra mode\n" );<br>+ h->param.i_ex_class = 0;<br>+ return -1;<br>+ }<br>+<br>+ if( !h->param.b_repeat_headers )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "Separate headers not supported in AVC-Intra mode\n" );<br>+ h->param.i_ex_class = 0;<br>+ return -1;<br>+ }<br>+<br>+ h->param.b_cabac = 1;<br>+ h->param.i_keyint_max = 1;<br>+ h->param.b_deblocking_filter = 0;<br>+ h->param.i_nal_hrd = X264_NAL_HRD_CBR;<br>+ h->param.i_slice_count = 10;<br>+ h->param.analyse.b_transform_8x8 = 1;<br>+ h->param.analyse.intra = X264_ANALYSE_I8x8;<br>+ h->param.rc.i_rc_method = X264_RC_ABR;<br>+<br>+ // sps set<br>+ h->param.vui.i_sar_width = 4;<br>+ h->param.vui.i_sar_height = 3;<br>+ h->param.vui.i_overscan = 2;<br>+ h->param.vui.i_vidformat = 0;<br>+ h->param.vui.b_fullrange = 0;<br>+ h->param.vui.i_colorprim = 1;<br>+ h->param.vui.i_transfer = 1;<br>+ h->param.vui.i_colmatrix = 1;<br>+ h->param.b_pic_struct = 0;<br>+<br>+ // pps set<br>+ h->param.i_frame_reference = 1;<br>+ h->param.analyse.i_weighted_pred = 0;<br>+ h->param.analyse.i_chroma_qp_offset = 4;<br>+ h->param.b_stitchable = 1;<br>+<br>+ if( h->param.i_width == 960 && h->param.i_height == 720 )<br>+ {<br>+ (h->param.i_fps_num == 60000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 53276)) ||<br>+ (h->param.i_fps_num == 50000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 54067)) ||<br>+ (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 26638)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 27033)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 27033)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 21314)) ||<br>+ (h->param.i_ex_class = 0);<br>+<br>+ h->param.i_level_idc = 32;<br>+ }<br>+ else if( h->param.i_width == 1440 && h->param.i_height == 1080 )<br>+ {<br>+ if( (h->param.i_fps_num == 60000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 107044)) ||<br>+ (h->param.i_fps_num == 50000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 108544)) )<br>+ {<br>+ h->param.i_level_idc = 42;<br>+ }<br>+ else if( (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 1 && (h->param.rc.i_bitrate = 107044)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 1 && (h->param.rc.i_bitrate = 108544)) ||<br>+ (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 53522)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 54272)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 54272)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 42800)) )<br>+ {<br>+ h->param.i_level_idc = 40;<br>+ }<br>+ else<br>+ {<br>+ h->param.i_ex_class = 0;<br>+ }<br>+ }<br>+ else<br>+ h->param.i_ex_class = 0;<br>+<br>+ if( !h->param.i_ex_class )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "Resolution %dx%d invalid or FPS %d invalid or Interlaced %c invalid for AVC-Ultra 50 Class\n",<br>+ h->param.i_width, h->param.i_height, h->param.i_fps_num, h->param.b_interlaced ? 'I' : 'P' );<br>+ return -1;<br>+ }<br>+<br>+ memcpy( h->param.cqm_4iy, x264_cqm_jvt4i, sizeof( h->param.cqm_4iy ) );<br>+ memcpy( h->param.cqm_4ic, x264_cqm_avci50_4ic, sizeof( h->param.cqm_4ic ) );<br>+ if( PARAM_INTERLACED == 0 )<br>+ {<br>+ memcpy( h->param.cqm_8iy, x264_cqm_avci50_p_8iy, sizeof( h->param.cqm_8iy ) );<br>+ }<br>+ else<br>+ {<br>+ memcpy( h->param.cqm_8iy, x264_cqm_avci50_1080i_8iy, sizeof( h->param.cqm_8iy ) );<br>+ }<br>+<br>+ h->param.rc.i_vbv_max_bitrate = h->param.rc.i_bitrate;<br>+ h->param.rc.i_vbv_buffer_size = h->param.rc.i_bitrate * h->param.i_fps_den / h->param.i_fps_num;<br>+<br>+ return 0;<br>+}<br>+<br>+static int apply_avcultra_class_100_profile( x264_t *h )<br>+{<br>+ if( h->param.nalu_process )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "nalu_process is not supported in AVC-Intra mode\n" );<br>+ h->param.i_ex_class = 0;<br>+ return -1;<br>+ }<br>+<br>+ if( !h->param.b_repeat_headers )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "Separate headers not supported in AVC-Intra mode\n" );<br>+ h->param.i_ex_class = 0;<br>+ return -1;<br>+ }<br>+<br>+ h->param.b_cabac = 0;<br>+ h->param.i_keyint_max = 1;<br>+ h->param.b_deblocking_filter = 0;<br>+ h->param.i_slice_count = 10;<br>+ h->param.analyse.b_transform_8x8 = 1;<br>+ h->param.analyse.intra = X264_ANALYSE_I8x8;<br>+<br>+ // sps set<br>+ h->param.vui.i_sar_width = 1;<br>+ h->param.vui.i_sar_height = 1;<br>+ h->param.vui.i_overscan = 2;<br>+ h->param.vui.i_vidformat = 0;<br>+ h->param.vui.b_fullrange = 0;<br>+ h->param.vui.i_colorprim = 1;<br>+ h->param.vui.i_transfer = 1;<br>+ h->param.vui.i_colmatrix = 1;<br>+ h->param.b_pic_struct = 0;<br>+<br>+ // pps set<br>+ h->param.i_frame_reference = 1;<br>+ h->param.analyse.i_weighted_pred = 0;<br>+ h->param.b_stitchable = 1;<br>+<br>+ if( h->param.i_width == 1280 && h->param.i_height == 720 )<br>+ {<br>+ (h->param.i_fps_num == 60000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 110726)) ||<br>+ (h->param.i_fps_num == 50000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 111616)) ||<br>+ (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 55363)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 55800)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 55800)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 44298)) ||<br>+ (h->param.i_ex_class = 0);<br>+<br>+ h->param.i_level_idc = 41;<br>+ h->param.i_nal_hrd = X264_NAL_HRD_CBR;<br>+ h->param.analyse.i_chroma_qp_offset = 4;<br>+ }<br>+ else if( h->param.i_width == 1920 && h->param.i_height == 1080 )<br>+ {<br>+ if( (h->param.i_fps_num == 60000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 221944)) ||<br>+ (h->param.i_fps_num == 50000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 223641)) )<br>+ {<br>+ h->param.i_level_idc = 42;<br>+ }<br>+ else if( (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 1 && (h->param.rc.i_bitrate = 221944)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 1 && (h->param.rc.i_bitrate = 223641)) ||<br>+ (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 110972)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 111820)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 111820)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 88700)) )<br>+ {<br>+ h->param.i_level_idc = 41;<br>+ }<br>+ else<br>+ {<br>+ h->param.i_ex_class = 0;<br>+ }<br>+<br>+ h->param.i_nal_hrd = X264_NAL_HRD_CBR;<br>+ h->param.analyse.i_chroma_qp_offset = 3;<br>+ }<br>+ else if( h->param.i_width == 2048 && h->param.i_height == 1080 )<br>+ {<br>+ (h->param.i_fps_num == 60000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 213000) && (h->param.rc.i_vbv_max_bitrate = 232000)) ||<br>+ (h->param.i_fps_num == 50000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 215000) && (h->param.rc.i_vbv_max_bitrate = 235000)) ||<br>+ (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 106000) && (h->param.rc.i_vbv_max_bitrate = 116000)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 107000) && (h->param.rc.i_vbv_max_bitrate = 117000)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 107000) && (h->param.rc.i_vbv_max_bitrate = 117000)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 90000) && (h->param.rc.i_vbv_max_bitrate = 98000)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 85000) && (h->param.rc.i_vbv_max_bitrate = 93000)) ||<br>+ (h->param.i_ex_class = 0);<br>+<br>+ h->param.i_level_idc = 42;<br>+ h->param.i_nal_hrd = X264_NAL_HRD_VBR;<br>+ h->param.i_slice_count = 8;<br>+ h->param.analyse.i_chroma_qp_offset = 3;<br>+ }<br>+ else<br>+ h->param.i_ex_class = 0;<br>+<br>+ if( !h->param.i_ex_class )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "Resolution %dx%d invalid or FPS %d invalid or Interlaced %c invalid for AVC-Ultra 100 Class\n",<br>+ h->param.i_width, h->param.i_height, h->param.i_fps_num, h->param.b_interlaced ? 'I' : 'P' );<br>+ return -1;<br>+ }<br>+<br>+ memcpy( h->param.cqm_4iy, x264_cqm_jvt4i, sizeof( h->param.cqm_4iy ) );<br>+ if( h->param.i_height == 720 )<br>+ {<br>+ memcpy( h->param.cqm_4ic, x264_cqm_avci100_720p_4ic, sizeof( h->param.cqm_4ic ) );<br>+ memcpy( h->param.cqm_8iy, x264_cqm_avci100_720p_8iy, sizeof( h->param.cqm_8iy ) );<br>+ }<br>+ else<br>+ {<br>+ memcpy( h->param.cqm_4ic, x264_cqm_avci100_1080_4ic, sizeof( h->param.cqm_4ic ) );<br>+ if( PARAM_INTERLACED == 0 )<br>+ {<br>+ memcpy( h->param.cqm_8iy, x264_cqm_avci100_1080p_8iy, sizeof( h->param.cqm_8iy ) );<br>+ }<br>+ else<br>+ {<br>+ memcpy( h->param.cqm_8iy, x264_cqm_avci100_1080i_8iy, sizeof( h->param.cqm_8iy ) );<br>+ }<br>+ }<br>+<br>+ if( X264_NAL_HRD_CBR == h->param.i_nal_hrd )<br>+ {<br>+ h->param.rc.i_rc_method = X264_RC_ABR;<br>+ h->param.rc.i_vbv_max_bitrate = h->param.rc.i_bitrate;<br>+ h->param.rc.i_vbv_buffer_size = h->param.rc.i_bitrate * h->param.i_fps_den / h->param.i_fps_num;<br>+ }<br>+ else<br>+ {<br>+ h->param.rc.i_rc_method = X264_RC_ABR;<br>+ h->param.rc.i_vbv_buffer_size = h->param.rc.i_vbv_max_bitrate * h->param.i_fps_den / h->param.i_fps_num;<br>+ }<br>+<br>+ return 0;<br>+}<br>+<br>+static int apply_avcultra_class_200_profile( x264_t *h )<br>+{<br>+ if( h->param.nalu_process )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "nalu_process is not supported in AVC-Intra mode\n" );<br>+ h->param.i_ex_class = 0;<br>+ return -1;<br>+ }<br>+<br>+ if( !h->param.b_repeat_headers )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "Separate headers not supported in AVC-Intra mode\n" );<br>+ h->param.i_ex_class = 0;<br>+ return -1;<br>+ }<br>+<br>+ h->param.b_cabac = 0;<br>+ h->param.i_keyint_max = 1;<br>+ h->param.b_deblocking_filter = 0;<br>+ h->param.i_slice_count = 10;<br>+ h->param.analyse.b_transform_8x8 = 1;<br>+ h->param.analyse.intra = X264_ANALYSE_I8x8;<br>+<br>+ // sps set<br>+ h->param.vui.i_sar_width = 1;<br>+ h->param.vui.i_sar_height = 1;<br>+ h->param.vui.i_overscan = 2;<br>+ h->param.vui.i_vidformat = 0;<br>+ h->param.vui.b_fullrange = 0;<br>+ h->param.vui.i_colorprim = 1;<br>+ h->param.vui.i_transfer = 1;<br>+ h->param.vui.i_colmatrix = 1;<br>+ h->param.b_pic_struct = 0;<br>+<br>+ // pps set<br>+ h->param.i_frame_reference = 1;<br>+ h->param.analyse.i_weighted_pred = 0;<br>+ h->param.b_stitchable = 1;<br>+<br>+ if( h->param.i_width == 1280 && h->param.i_height == 720 )<br>+ {<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 90364)) ||<br>+ (h->param.i_fps_num == 23980 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 90364)) ||<br>+ (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 112936)) ||<br>+ (h->param.i_fps_num == 29970 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 112936)) ||<br>+ (h->param.i_fps_num == 60000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 225873)) ||<br>+ (h->param.i_fps_num == 59940 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 225873)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 113356)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 113356)) ||<br>+ (h->param.i_fps_num == 50000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 226713)) ||<br>+ (h->param.i_ex_class = 0);<br>+<br>+ h->param.i_level_idc = 41;<br>+ h->param.i_nal_hrd = X264_NAL_HRD_CBR;<br>+ h->param.analyse.i_chroma_qp_offset = 4;<br>+ }<br>+ else if( h->param.i_width == 1920 && h->param.i_height == 1080 )<br>+ {<br>+ if( (h->param.i_fps_num == 60000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 451700)) ||<br>+ (h->param.i_fps_num == 50000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 453200)) )<br>+ {<br>+ h->param.i_level_idc = 50;<br>+ }<br>+ else if( (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 1 && (h->param.rc.i_bitrate = 451700)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 1 && (h->param.rc.i_bitrate = 453200)) ||<br>+ (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 225854)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 226600)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 226600)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 180713)) )<br>+ {<br>+ h->param.i_level_idc = 41;<br>+ }<br>+ else<br>+ {<br>+ h->param.i_ex_class = 0;<br>+ }<br>+<br>+ h->param.i_nal_hrd = X264_NAL_HRD_CBR;<br>+ h->param.analyse.i_chroma_qp_offset = 3;<br>+ }<br>+ else if( h->param.i_width == 2048 && h->param.i_height == 1080 )<br>+ {<br>+ (h->param.i_fps_num == 60000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 220000) && (h->param.rc.i_vbv_max_bitrate = 240000)) ||<br>+ (h->param.i_fps_num == 50000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 220000) && (h->param.rc.i_vbv_max_bitrate = 240000)) ||<br>+ (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 110000) && (h->param.rc.i_vbv_max_bitrate = 120000)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 110000) && (h->param.rc.i_vbv_max_bitrate = 120000)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 110000) && (h->param.rc.i_vbv_max_bitrate = 120000)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 90000) && (h->param.rc.i_vbv_max_bitrate = 98000)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 90000) && (h->param.rc.i_vbv_max_bitrate = 98000)) ||<br>+ (h->param.i_ex_class = 0);<br>+<br>+ h->param.i_level_idc = 50;<br>+ h->param.i_nal_hrd = X264_NAL_HRD_VBR;<br>+ h->param.i_slice_count = 8;<br>+ h->param.analyse.i_chroma_qp_offset = 3;<br>+ }<br>+ else<br>+ h->param.i_ex_class = 0;<br>+<br>+ if( !h->param.i_ex_class )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "Resolution %dx%d invalid or FPS %d invalid for AVC-Ultra 200 Class\n",<br>+ h->param.i_width, h->param.i_height, h->param.i_fps_num );<br>+ return -1;<br>+ }<br>+<br>+ memcpy( h->param.cqm_4iy, x264_cqm_jvt4i, sizeof( h->param.cqm_4iy ) );<br>+ memcpy( h->param.cqm_4ic, x264_cqm_avci100_1080_4ic, sizeof( h->param.cqm_4ic ) );<br>+ if( PARAM_INTERLACED == 0 )<br>+ {<br>+ memcpy( h->param.cqm_8iy, x264_cqm_avci100_1080p_8iy, sizeof( h->param.cqm_8iy ) );<br>+ }<br>+ else<br>+ {<br>+ memcpy( h->param.cqm_8iy, x264_cqm_avci100_1080i_8iy, sizeof( h->param.cqm_8iy ) );<br>+ }<br>+<br>+ if( X264_NAL_HRD_CBR == h->param.i_nal_hrd )<br>+ {<br>+ h->param.rc.i_rc_method = X264_RC_ABR;<br>+ h->param.rc.i_vbv_max_bitrate = h->param.rc.i_bitrate;<br>+ h->param.rc.i_vbv_buffer_size = h->param.rc.i_bitrate * h->param.i_fps_den / h->param.i_fps_num;<br>+ }<br>+ else<br>+ {<br>+ h->param.rc.i_rc_method = X264_RC_ABR;<br>+ h->param.rc.i_vbv_buffer_size = h->param.rc.i_vbv_max_bitrate * h->param.i_fps_den / h->param.i_fps_num;<br>+ }<br>+<br>+ return 0;<br>+}<br>+<br>+static int apply_avcultra_class_300_profile( x264_t *h )<br>+{<br>+ if( h->param.nalu_process )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "nalu_process is not supported in AVC-Intra mode\n" );<br>+ h->param.i_ex_class = 0;<br>+ return -1;<br>+ }<br>+<br>+ if( !h->param.b_repeat_headers )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "Separate headers not supported in AVC-Intra mode\n" );<br>+ h->param.i_ex_class = 0;<br>+ return -1;<br>+ }<br>+<br>+ h->param.b_cabac = 0;<br>+ h->param.i_nal_hrd = X264_NAL_HRD_VBR;<br>+ h->param.rc.i_rc_method = X264_RC_ABR;<br>+ h->param.i_level_idc = 52;<br>+ h->param.i_keyint_max = 1;<br>+ h->param.b_deblocking_filter = 0;<br>+ h->param.i_slice_count = 16;<br>+ h->param.analyse.b_transform_8x8 = 1;<br>+ h->param.analyse.intra = X264_ANALYSE_I8x8;<br>+<br>+ // sps set<br>+ h->param.vui.i_sar_width = 1;<br>+ h->param.vui.i_sar_height = 1;<br>+ h->param.vui.i_overscan = 2;<br>+ h->param.vui.i_vidformat = 0;<br>+ h->param.vui.b_fullrange = 0;<br>+ h->param.vui.i_colorprim = 1;<br>+ h->param.vui.i_transfer = 1;<br>+ h->param.vui.i_colmatrix = 1;<br>+ h->param.b_pic_struct = 0;<br>+<br>+ // pps set<br>+ h->param.i_frame_reference = 1;<br>+ h->param.analyse.i_weighted_pred = 0;<br>+ h->param.b_stitchable = 1;<br>+ h->param.analyse.i_chroma_qp_offset = 3;<br>+<br>+ if( h->param.i_width == 3840 && h->param.i_height == 2160 )<br>+ {<br>+ (h->param.i_fps_num == 60000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 576000) && (h->param.rc.i_vbv_max_bitrate = 627000)) ||<br>+ (h->param.i_fps_num == 50000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 480000) && (h->param.rc.i_vbv_max_bitrate = 523000)) ||<br>+ (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 288000) && (h->param.rc.i_vbv_max_bitrate = 313920)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 240000) && (h->param.rc.i_vbv_max_bitrate = 261600)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 240000) && (h->param.rc.i_vbv_max_bitrate = 261600)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 230000) && (h->param.rc.i_vbv_max_bitrate = 251000)) ||<br>+ (h->param.i_ex_class = 0);<br>+ }<br>+ else if( h->param.i_width == 4096 && h->param.i_height == 2160 )<br>+ {<br>+ (h->param.i_fps_num == 60000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 576000) && (h->param.rc.i_vbv_max_bitrate = 627000)) ||<br>+ (h->param.i_fps_num == 50000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 480000) && (h->param.rc.i_vbv_max_bitrate = 523000)) ||<br>+ (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 288000) && (h->param.rc.i_vbv_max_bitrate = 313920)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 240000) && (h->param.rc.i_vbv_max_bitrate = 261600)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 240000) && (h->param.rc.i_vbv_max_bitrate = 261600)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 230000) && (h->param.rc.i_vbv_max_bitrate = 251000)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 230000) && (h->param.rc.i_vbv_max_bitrate = 251000)) ||<br>+ (h->param.i_ex_class = 0);<br>+ }<br>+ else<br>+ h->param.i_ex_class = 0;<br>+<br>+ if( !h->param.i_ex_class )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "Resolution %dx%d invalid or FPS %d invalid for AVC-Ultra 300 Class\n",<br>+ h->param.i_width, h->param.i_height, h->param.i_fps_num );<br>+ return -1;<br>+ }<br>+<br>+ memcpy( h->param.cqm_4iy, x264_cqm_jvt4i, sizeof( h->param.cqm_4iy ) );<br>+ memcpy( h->param.cqm_4ic, x264_cqm_avci300_2160_4ic, sizeof( h->param.cqm_4ic ) );<br>+ memcpy( h->param.cqm_8iy, x264_cqm_avci300_2160p_8iy, sizeof( h->param.cqm_8iy ) );<br>+<br>+ h->param.rc.i_vbv_buffer_size = h->param.rc.i_vbv_max_bitrate * h->param.i_fps_den / h->param.i_fps_num;<br>+<br>+ return 0;<br>+}<br>+<br>+static int apply_avcultra_class_480_profile( x264_t *h )<br>+{<br>+ if( h->param.nalu_process )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "nalu_process is not supported in AVC-Intra mode\n" );<br>+ h->param.i_ex_class = 0;<br>+ return -1;<br>+ }<br>+<br>+ if( !h->param.b_repeat_headers )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "Separate headers not supported in AVC-Intra mode\n" );<br>+ h->param.i_ex_class = 0;<br>+ return -1;<br>+ }<br>+<br>+ int i_csp = h->param.i_csp & X264_CSP_MASK;<br>+ if( i_csp != X264_CSP_I422)<br>+ {<br>+ x264_log( NULL, X264_LOG_ERROR, "10 bits intra-480 need csp i422\n" );<br>+ return -1;<br>+ }<br>+<br>+ h->param.i_nal_hrd = X264_NAL_HRD_VBR;<br>+ h->param.rc.i_rc_method = X264_RC_ABR;<br>+ h->param.i_level_idc = 52;<br>+ h->param.b_cabac = 0;<br>+ h->param.i_keyint_max = 1;<br>+ h->param.b_deblocking_filter = 0;<br>+ h->param.i_slice_count = 16;<br>+ h->param.analyse.b_transform_8x8 = 1;<br>+ h->param.analyse.intra = X264_ANALYSE_I8x8;<br>+<br>+ // sps set<br>+ h->param.vui.i_sar_width = 1;<br>+ h->param.vui.i_sar_height = 1;<br>+ h->param.vui.i_overscan = 2;<br>+ h->param.vui.i_vidformat = 0;<br>+ h->param.vui.b_fullrange = 0;<br>+ h->param.vui.i_colorprim = 1;<br>+ h->param.vui.i_transfer = 1;<br>+ h->param.vui.i_colmatrix = 1;<br>+ h->param.b_pic_struct = 0;<br>+<br>+ // pps set<br>+ h->param.i_frame_reference = 1;<br>+ h->param.analyse.i_weighted_pred = 0;<br>+ h->param.b_stitchable = 1;<br>+ h->param.analyse.i_chroma_qp_offset = 3;<br>+<br>+ if( h->param.i_width == 3840 && h->param.i_height == 2160 )<br>+ {<br>+ (h->param.i_fps_num == 60000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 576000) && (h->param.rc.i_vbv_max_bitrate = 627000)) ||<br>+ (h->param.i_fps_num == 50000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 480000) && (h->param.rc.i_vbv_max_bitrate = 523000)) ||<br>+ (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 288000) && (h->param.rc.i_vbv_max_bitrate = 313920)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 240000) && (h->param.rc.i_vbv_max_bitrate = 261600)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 240000) && (h->param.rc.i_vbv_max_bitrate = 261600)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 230000) && (h->param.rc.i_vbv_max_bitrate = 251000)) ||<br>+ (h->param.i_ex_class = 0);<br>+ }<br>+ else if( h->param.i_width == 4096 && h->param.i_height == 2160 )<br>+ {<br>+ (h->param.i_fps_num == 60000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 576000) && (h->param.rc.i_vbv_max_bitrate = 627000)) ||<br>+ (h->param.i_fps_num == 50000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 480000) && (h->param.rc.i_vbv_max_bitrate = 523000)) ||<br>+ (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 288000) && (h->param.rc.i_vbv_max_bitrate = 313920)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 240000) && (h->param.rc.i_vbv_max_bitrate = 261600)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 240000) && (h->param.rc.i_vbv_max_bitrate = 261600)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 230000) && (h->param.rc.i_vbv_max_bitrate = 251000)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 230000) && (h->param.rc.i_vbv_max_bitrate = 251000)) ||<br>+ (h->param.i_ex_class = 0);<br>+ }<br>+ else<br>+ h->param.i_ex_class = 0;<br>+<br>+ if( !h->param.i_ex_class )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "Resolution %dx%d invalid or FPS %d invalid for AVC-Ultra 480 Class\n",<br>+ h->param.i_width, h->param.i_height, h->param.i_fps_num );<br>+ return -1;<br>+ }<br>+<br>+ memcpy( h->param.cqm_4iy, x264_cqm_jvt4i, sizeof( h->param.cqm_4iy ) );<br>+ memcpy( h->param.cqm_4ic, x264_cqm_avci480_2160_4ic, sizeof( h->param.cqm_4ic ) );<br>+ memcpy( h->param.cqm_8iy, x264_cqm_avci480_2160p_8iy, sizeof( h->param.cqm_8iy ) );<br>+<br>+ h->param.rc.i_vbv_buffer_size = h->param.rc.i_vbv_max_bitrate * h->param.i_fps_den / h->param.i_fps_num;<br>+<br>+ return 0;<br>+}<br>+<br>+#elif BIT_DEPTH == 12<br>+static int apply_avcultra_class_220_profile( x264_t *h )<br>+{<br>+ if( h->param.nalu_process )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "nalu_process is not supported in AVC-Intra mode\n" );<br>+ h->param.i_ex_class = 0;<br>+ return -1;<br>+ }<br>+<br>+ if( !h->param.b_repeat_headers )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "Separate headers not supported in AVC-Intra mode\n" );<br>+ h->param.i_ex_class = 0;<br>+ return -1;<br>+ }<br>+<br>+ h->param.i_nal_hrd = X264_NAL_HRD_VBR;<br>+ h->param.rc.i_rc_method = X264_RC_ABR;<br>+ h->param.b_cabac = 0;<br>+ h->param.i_keyint_max = 1;<br>+ h->param.b_deblocking_filter = 0;<br>+ h->param.i_slice_count = 8;<br>+ h->param.analyse.b_transform_8x8 = 1;<br>+ h->param.analyse.intra = X264_ANALYSE_I8x8;<br>+<br>+ // sps set<br>+ h->param.vui.i_sar_width = 1;<br>+ h->param.vui.i_sar_height = 1;<br>+ h->param.vui.i_overscan = 2;<br>+ h->param.vui.i_vidformat = 0;<br>+ h->param.vui.b_fullrange = 0;<br>+ h->param.vui.i_colorprim = 1;<br>+ h->param.vui.i_transfer = 1;<br>+ h->param.vui.i_colmatrix = 1;<br>+ h->param.b_pic_struct = 0;<br>+<br>+ // pps set<br>+ h->param.i_frame_reference = 1;<br>+ h->param.analyse.i_weighted_pred = 0;<br>+ h->param.analyse.i_chroma_qp_offset = 3;<br>+ h->param.b_stitchable = 1;<br>+<br>+<br>+ if( h->param.i_width == 1920 && h->param.i_height == 1080 )<br>+ {<br>+ if( (h->param.i_fps_num == 60000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 439676) && (h->param.rc.i_vbv_max_bitrate = 479980)) ||<br>+ (h->param.i_fps_num == 50000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 367018) && (h->param.rc.i_vbv_max_bitrate = 400384)) )<br>+ {<br>+ h->param.i_level_idc = 50;<br>+ }<br>+ else if( (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 219990) && (h->param.rc.i_vbv_max_bitrate = 239990)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 219990) && (h->param.rc.i_vbv_max_bitrate = 200192)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 219990) && (h->param.rc.i_vbv_max_bitrate = 200192)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 176348) && (h->param.rc.i_vbv_max_bitrate = 192024)) )<br>+ {<br>+ h->param.i_level_idc = 41;<br>+ }<br>+ else<br>+ {<br>+ h->param.i_ex_class = 0;<br>+ }<br>+ }<br>+ else if( h->param.i_width == 2048 && h->param.i_height == 1080 )<br>+ {<br>+ if( (h->param.i_fps_num == 60000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 439981) && (h->param.rc.i_vbv_max_bitrate = 479980)) ||<br>+ (h->param.i_fps_num == 50000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 367018) && (h->param.rc.i_vbv_max_bitrate = 400384)) )<br>+ {<br>+ h->param.i_level_idc = 50;<br>+ }<br>+ else if( (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 219990) && (h->param.rc.i_vbv_max_bitrate = 239990)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 183509) && (h->param.rc.i_vbv_max_bitrate = 200192)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 183509) && (h->param.rc.i_vbv_max_bitrate = 200192)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 176495) && (h->param.rc.i_vbv_max_bitrate = 192184)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 176348) && (h->param.rc.i_vbv_max_bitrate = 192024)) )<br>+ {<br>+ h->param.i_level_idc = 42;<br>+ }<br>+ else<br>+ {<br>+ h->param.i_ex_class = 0;<br>+ }<br>+ }<br>+ else<br>+ h->param.i_ex_class = 0;<br>+<br>+ if( !h->param.i_ex_class )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "Resolution %dx%d invalid or FPS %d invalid for AVC-Ultra 220 Class\n",<br>+ h->param.i_width, h->param.i_height, h->param.i_fps_num );<br>+ return -1;<br>+ }<br>+<br>+ memcpy( h->param.cqm_4iy, x264_cqm_jvt4i, sizeof( h->param.cqm_4iy ) );<br>+ memcpy( h->param.cqm_4ic, x264_cqm_avci220_1080_4ic, sizeof( h->param.cqm_4ic ) );<br>+ memcpy( h->param.cqm_8iy, x264_cqm_avci220_1080p_8iy, sizeof( h->param.cqm_8iy ) );<br>+<br>+ h->param.rc.i_vbv_buffer_size = h->param.rc.i_vbv_max_bitrate * h->param.i_fps_den / h->param.i_fps_num;<br>+<br>+ return 0;<br>+}<br>+static int apply_avcultra_class_480_profile( x264_t *h )<br>+{<br>+ if( h->param.nalu_process )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "nalu_process is not supported in AVC-Intra mode\n" );<br>+ h->param.i_ex_class = 0;<br>+ return -1;<br>+ }<br>+<br>+ if( !h->param.b_repeat_headers )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "Separate headers not supported in AVC-Intra mode\n" );<br>+ h->param.i_ex_class = 0;<br>+ return -1;<br>+ }<br>+<br>+ int i_csp = h->param.i_csp & X264_CSP_MASK;<br>+ if( i_csp != X264_CSP_I444 )<br>+ {<br>+ x264_log( NULL, X264_LOG_ERROR, "12 bits intra-480 need csp i444\n" );<br>+ return -1;<br>+ }<br>+<br>+ h->param.i_nal_hrd = X264_NAL_HRD_VBR;<br>+ h->param.rc.i_rc_method = X264_RC_ABR;<br>+ h->param.i_level_idc = 52;<br>+ h->param.b_cabac = 0;<br>+ h->param.i_keyint_max = 1;<br>+ h->param.b_deblocking_filter = 0;<br>+ h->param.i_slice_count = 16;<br>+ h->param.analyse.b_transform_8x8 = 1;<br>+ h->param.analyse.intra = X264_ANALYSE_I8x8;<br>+<br>+ // sps set<br>+ h->param.vui.i_sar_width = 1;<br>+ h->param.vui.i_sar_height = 1;<br>+ h->param.vui.i_overscan = 2;<br>+ h->param.vui.i_vidformat = 0;<br>+ h->param.vui.b_fullrange = 0;<br>+ h->param.vui.i_colorprim = 1;<br>+ h->param.vui.i_transfer = 1;<br>+ h->param.vui.i_colmatrix = 1;<br>+ h->param.b_pic_struct = 0;<br>+<br>+ // pps set<br>+ h->param.i_frame_reference = 1;<br>+ h->param.analyse.i_weighted_pred = 0;<br>+ h->param.analyse.i_chroma_qp_offset = 3;<br>+ h->param.b_stitchable = 1;<br>+<br>+ if( h->param.i_width == 3840 && h->param.i_height == 2160 )<br>+ {<br>+ (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 439898) && (h->param.rc.i_vbv_max_bitrate = 479489)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 366948) && (h->param.rc.i_vbv_max_bitrate = 399974)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 366948) && (h->param.rc.i_vbv_max_bitrate = 399974)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 352112) && (h->param.rc.i_vbv_max_bitrate = 383655)) ||<br>+ (h->param.i_ex_class = 0);<br>+ }<br>+ else if( h->param.i_width == 4096 && h->param.i_height == 2160 )<br>+ {<br>+ (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 439898) && (h->param.rc.i_vbv_max_bitrate = 479489)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 366948) && (h->param.rc.i_vbv_max_bitrate = 399974)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 366948) && (h->param.rc.i_vbv_max_bitrate = 399974)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 352405) && (h->param.rc.i_vbv_max_bitrate = 383975)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 352112) && (h->param.rc.i_vbv_max_bitrate = 383655)) ||<br>+ (h->param.i_ex_class = 0);<br>+ }<br>+ else<br>+ h->param.i_ex_class = 0;<br>+<br>+ if( !h->param.i_ex_class )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "Resolution %dx%d invalid or FPS %d invalid for AVC-Ultra 480 Class\n",<br>+ h->param.i_width, h->param.i_height, h->param.i_fps_num );<br>+ return -1;<br>+ }<br>+<br>+ memcpy( h->param.cqm_4iy, x264_cqm_jvt4i, sizeof( h->param.cqm_4iy ) );<br>+ memcpy( h->param.cqm_4ic, x264_cqm_avci480_2160_4ic, sizeof( h->param.cqm_4ic ) );<br>+ memcpy( h->param.cqm_8iy, x264_cqm_avci480_2160p_8iy, sizeof( h->param.cqm_8iy ) );<br>+<br>+ h->param.rc.i_vbv_buffer_size = h->param.rc.i_vbv_max_bitrate * h->param.i_fps_den / h->param.i_fps_num;<br>+<br>+ return 0;<br>+}<br>+static int apply_avcultra_class_600_profile( x264_t *h )<br>+{<br>+ if( h->param.nalu_process )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "nalu_process is not supported in AVC-Intra mode\n" );<br>+ h->param.i_ex_class = 0;<br>+ return -1;<br>+ }<br>+<br>+ if( !h->param.b_repeat_headers )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "Separate headers not supported in AVC-Intra mode\n" );<br>+ h->param.i_ex_class = 0;<br>+ return -1;<br>+ }<br>+<br>+ h->param.i_nal_hrd = X264_NAL_HRD_VBR;<br>+ h->param.rc.i_rc_method = X264_RC_ABR;<br>+ h->param.i_level_idc = 52;<br>+ h->param.b_cabac = 0;<br>+ h->param.i_keyint_max = 1;<br>+ h->param.b_deblocking_filter = 0;<br>+ h->param.i_slice_count = 16;<br>+ h->param.analyse.b_transform_8x8 = 1;<br>+ h->param.analyse.intra = X264_ANALYSE_I8x8;<br>+<br>+ // sps set<br>+ h->param.vui.i_sar_width = 1;<br>+ h->param.vui.i_sar_height = 1;<br>+ h->param.vui.i_overscan = 2;<br>+ h->param.vui.i_vidformat = 0;<br>+ h->param.vui.b_fullrange = 0;<br>+ h->param.vui.i_colorprim = 1;<br>+ h->param.vui.i_transfer = 1;<br>+ h->param.vui.i_colmatrix = 1;<br>+ h->param.b_pic_struct = 0;<br>+<br>+ // pps set<br>+ h->param.i_frame_reference = 1;<br>+ h->param.analyse.i_weighted_pred = 0;<br>+ h->param.analyse.i_chroma_qp_offset = 3;<br>+ h->param.b_stitchable = 1;<br>+<br>+ if( h->param.i_width == 3840 && h->param.i_height == 2160 )<br>+ {<br>+ (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 599933) && (h->param.rc.i_vbv_max_bitrate = 653927)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 500444) && (h->param.rc.i_vbv_max_bitrate = 545484)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 500444) && (h->param.rc.i_vbv_max_bitrate = 545484)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 480210) && (h->param.rc.i_vbv_max_bitrate = 523229)) ||<br>+ (h->param.i_ex_class = 0);<br>+ }<br>+ else if( h->param.i_width == 4096 && h->param.i_height == 2160 )<br>+ {<br>+ (h->param.i_fps_num == 30000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 599933) && (h->param.rc.i_vbv_max_bitrate = 653927)) ||<br>+ (h->param.i_fps_num == 25000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 500444) && (h->param.rc.i_vbv_max_bitrate = 545484)) ||<br>+ (h->param.i_fps_num == 25 && h->param.i_fps_den == 1 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 500444) && (h->param.rc.i_vbv_max_bitrate = 545484)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1000 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 480000) && (h->param.rc.i_vbv_max_bitrate = 523229)) ||<br>+ (h->param.i_fps_num == 24000 && h->param.i_fps_den == 1001 && PARAM_INTERLACED == 0 && (h->param.rc.i_bitrate = 480610) && (h->param.rc.i_vbv_max_bitrate = 523665)) ||<br>+ (h->param.i_ex_class = 0);<br>+ }<br>+ else<br>+ h->param.i_ex_class = 0;<br>+<br>+ if( !h->param.i_ex_class )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "Resolution %dx%d invalid or FPS %d invalid for AVC-Ultra 600 Class\n",<br>+ h->param.i_width, h->param.i_height, h->param.i_fps_num );<br>+ return -1;<br>+ }<br>+<br>+ memcpy( h->param.cqm_4iy, x264_cqm_jvt4i, sizeof( h->param.cqm_4iy ) );<br>+ memcpy( h->param.cqm_4ic, x264_cqm_avci600_2160_4ic, sizeof( h->param.cqm_4ic ) );<br>+ memcpy( h->param.cqm_8iy, x264_cqm_avci600_2160p_8iy, sizeof( h->param.cqm_8iy ) );<br>+<br>+ h->param.rc.i_vbv_buffer_size = h->param.rc.i_vbv_max_bitrate * h->param.i_fps_den / h->param.i_fps_num;<br>+<br>+ return 0;<br>+}<br>+#endif<br>+<br>+static int x264_param_apply_class_profile( x264_t *h )<br>+{<br>+ if( !h->param.i_ex_class )<br>+ {<br>+ return -1;<br>+ }<br>+<br>+ if( BIT_DEPTH < 10 )<br>+ {<br>+ x264_log( h, X264_LOG_ERROR, "%2d-bit AVC-Intra is not widely compatible\n", BIT_DEPTH );<br>+ x264_log( h, X264_LOG_ERROR, "HIGH_BIT_DEPTH is required to encode AVC-Intra\n" );<br>+ return -1;<br>+ }<br>+<br>+ switch( h->param.i_ex_class )<br>+ {<br>+#if BIT_DEPTH == 10<br>+ case AVCULTRA_CLASS_50:<br>+ if(apply_avcultra_class_50_profile( h ))<br>+ return -1;<br>+ break;<br>+ case AVCULTRA_CLASS_100:<br>+ if(apply_avcultra_class_100_profile( h ))<br>+ return -1;<br>+ break;<br>+ case AVCULTRA_CLASS_200:<br>+ if(apply_avcultra_class_200_profile( h ))<br>+ return -1;<br>+ break;<br>+ case AVCULTRA_CLASS_300:<br>+ if(apply_avcultra_class_300_profile( h ))<br>+ return -1;<br>+ break;<br>+ case AVCULTRA_CLASS_480:<br>+ if(apply_avcultra_class_480_profile( h ))<br>+ return -1;<br>+ break;<br>+<br>+ case XAVC_CLASS_X25:<br>+ // add the constriction for class p25<br>+ break;<br>+ case XAVC_CLASS_X35:<br>+ // add the constriction for class p35<br>+ break;<br>+ case XAVC_CLASS_X50:<br>+ // add the constriction for class p50<br>+ break;<br>+#elif BIT_DEPTH == 12<br>+ case AVCULTRA_CLASS_220:<br>+ if( apply_avcultra_class_220_profile( h ) )<br>+ return -1;<br>+ break;<br>+ case AVCULTRA_CLASS_480:<br>+ if( apply_avcultra_class_480_profile( h ) )<br>+ return -1;<br>+ break;<br>+ case AVCULTRA_CLASS_600:<br>+ if( apply_avcultra_class_600_profile( h ) )<br>+ return -1;<br>+ break;<br>+#endif<br>+ default:<br>+ x264_log( h, X264_LOG_ERROR, "Invalid AVC-Ultra class\n" );<br>+ return -1;<br>+ }<br>+ return 0;<br>+}<br>+<br> /****************************************************************************<br> *<br> ****************************************************************************<br>@@ -825,6 +1704,12 @@ static int x264_validate_parameters( x264_t *h, int b_open )<br> h->param.rc.i_qp_min = X264_MAX( h->param.rc.i_qp_min, QP_BD_OFFSET + 1 );<br> }<br> <br>+ if( h->param.i_ex_class )<br>+ {<br>+ if( x264_param_apply_class_profile( h ) )<br>+ return -1;<br>+ }<br>+<br> h->param.rc.f_rf_constant = x264_clip3f( h->param.rc.f_rf_constant, -QP_BD_OFFSET, 51 );<br> h->param.rc.f_rf_constant_max = x264_clip3f( h->param.rc.f_rf_constant_max, -QP_BD_OFFSET, 51 );<br> h->param.rc.i_qp_constant = x264_clip3( h->param.rc.i_qp_constant, 0, QP_MAX );<br>@@ -1124,14 +2009,14 @@ static int x264_validate_parameters( x264_t *h, int b_open )<br> h->mb.i_psy_trellis = h->param.analyse.i_trellis ? FIX8( h->param.analyse.f_psy_trellis / 4 ) : 0;<br> h->param.analyse.i_chroma_qp_offset = x264_clip3(h->param.analyse.i_chroma_qp_offset, -32, 32);<br> /* In 4:4:4 mode, chroma gets twice as much resolution, so we can halve its quality. */<br>- if( b_open && i_csp >= X264_CSP_I444 && i_csp < X264_CSP_BGR && h->param.analyse.b_psy )<br>+ if( b_open && i_csp >= X264_CSP_I444 && i_csp < X264_CSP_BGR && h->param.analyse.b_psy && h->param.i_ex_class <= 0 )<br> h->param.analyse.i_chroma_qp_offset += 6;<br> /* Psy RDO increases overall quantizers to improve the quality of luma--this indirectly hurts chroma quality */<br> /* so we lower the chroma QP offset to compensate */<br>- if( b_open && h->mb.i_psy_rd && !h->param.i_avcintra_class )<br>+ if( b_open && h->mb.i_psy_rd && !( h->param.i_avcintra_class || h->param.i_ex_class) )<br> h->param.analyse.i_chroma_qp_offset -= h->param.analyse.f_psy_rd < 0.25 ? 1 : 2;<br> /* Psy trellis has a similar effect. */<br>- if( b_open && h->mb.i_psy_trellis && !h->param.i_avcintra_class )<br>+ if( b_open && h->mb.i_psy_trellis && !( h->param.i_avcintra_class || h->param.i_ex_class) )<br> h->param.analyse.i_chroma_qp_offset -= h->param.analyse.f_psy_trellis < 0.25 ? 1 : 2;<br> h->param.analyse.i_chroma_qp_offset = x264_clip3(h->param.analyse.i_chroma_qp_offset, -12, 12);<br> /* MB-tree requires AQ to be on, even if the strength is zero. */<br>@@ -1448,7 +2333,7 @@ x264_t *x264_encoder_open( x264_param_t *param )<br> h->i_frame = -1;<br> h->i_frame_num = 0;<br> <br>- if( h->param.i_avcintra_class )<br>+ if( h->param.i_avcintra_class || h->param.i_ex_class )<br> h->i_idr_pic_id = 5;<br> else<br> h->i_idr_pic_id = 0;<br>@@ -1960,10 +2845,10 @@ static int x264_encoder_encapsulate_nals( x264_t *h, int start )<br> {<br> int old_payload_len = h->out.nal[i].i_payload;<br> h->out.nal[i].b_long_startcode = !i || h->out.nal[i].i_type == NAL_SPS || h->out.nal[i].i_type == NAL_PPS ||<br>- h->param.i_avcintra_class;<br>+ h->param.i_avcintra_class || h->param.i_ex_class;<br> x264_nal_encode( h, nal_buffer, &h->out.nal[i] );<br> nal_buffer += h->out.nal[i].i_payload;<br>- if( h->param.i_avcintra_class )<br>+ if( h->param.i_avcintra_class || h->param.i_ex_class )<br> {<br> h->out.nal[i].i_padding -= h->out.nal[i].i_payload - (old_payload_len + NALU_OVERHEAD);<br> if( h->out.nal[i].i_padding > 0 )<br>@@ -2504,7 +3389,7 @@ static inline void x264_slice_init( x264_t *h, int i_nal_type, int i_global_qp )<br> x264_slice_header_init( h, &h->sh, h->sps, h->pps, h->i_idr_pic_id, h->i_frame_num, i_global_qp );<br> <br> /* alternate id */<br>- if( h->param.i_avcintra_class )<br>+ if( h->param.i_avcintra_class || h->param.i_ex_class )<br> {<br> switch( h->i_idr_pic_id )<br> {<br>@@ -3555,7 +4440,7 @@ int x264_encoder_encode( x264_t *h,<br> if( x264_nal_end( h ) )<br> return -1;<br> /* Pad AUD/SPS to 256 bytes like Panasonic */<br>- if( h->param.i_avcintra_class )<br>+ if( h->param.i_avcintra_class || h->param.i_ex_class )<br> h->out.nal[h->out.i_nal-1].i_padding = 256 - bs_pos( &h->out.bs ) / 8 - 2*NALU_OVERHEAD;<br> overhead += h->out.nal[h->out.i_nal-1].i_payload + h->out.nal[h->out.i_nal-1].i_padding + NALU_OVERHEAD;<br> <br>@@ -3564,7 +4449,7 @@ int x264_encoder_encode( x264_t *h,<br> x264_pps_write( &h->out.bs, h->sps, h->pps );<br> if( x264_nal_end( h ) )<br> return -1;<br>- if( h->param.i_avcintra_class )<br>+ if( h->param.i_avcintra_class || h->param.i_ex_class )<br> h->out.nal[h->out.i_nal-1].i_padding = 256 - h->out.nal[h->out.i_nal-1].i_payload - NALU_OVERHEAD;<br> overhead += h->out.nal[h->out.i_nal-1].i_payload + h->out.nal[h->out.i_nal-1].i_padding + NALU_OVERHEAD;<br> }<br>@@ -3607,7 +4492,7 @@ int x264_encoder_encode( x264_t *h,<br> if( h->fenc->b_keyframe )<br> {<br> /* Avid's decoder strictly wants two SEIs for AVC-Intra so we can't insert the x264 SEI */<br>- if( h->param.b_repeat_headers && h->fenc->i_frame == 0 && !h->param.i_avcintra_class )<br>+ if( h->param.b_repeat_headers && h->fenc->i_frame == 0 && !( h->param.i_avcintra_class || h->param.i_ex_class ) )<br> {<br> /* identify ourself */<br> x264_nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE );<br>@@ -3639,7 +4524,7 @@ int x264_encoder_encode( x264_t *h,<br> }<br> <br> /* generate sei pic timing */<br>- if( h->sps->vui.b_pic_struct_present || h->sps->vui.b_nal_hrd_parameters_present )<br>+ if( (h->sps->vui.b_pic_struct_present || h->sps->vui.b_nal_hrd_parameters_present) && (h->param.i_ex_class < 1) )<br> {<br> x264_nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE );<br> x264_sei_pic_timing_write( h, &h->out.bs );<br>@@ -3663,7 +4548,7 @@ int x264_encoder_encode( x264_t *h,<br> h->i_cpb_delay_pir_offset_next = h->fenc->i_cpb_delay;<br> <br> /* Filler space: 10 or 18 SEIs' worth of space, depending on resolution */<br>- if( h->param.i_avcintra_class )<br>+ if( h->param.i_avcintra_class || h->param.i_ex_class )<br> {<br> /* Write an empty filler NAL to mimic the AUD in the P2 format*/<br> x264_nal_start( h, NAL_FILLER, NAL_PRIORITY_DISPOSABLE );<br>@@ -3774,7 +4659,7 @@ static int x264_encoder_frame_end( x264_t *h, x264_t *thread_current,<br> x264_emms();<br> <br> /* generate buffering period sei and insert it into place */<br>- if( h->i_thread_frames > 1 && h->fenc->b_keyframe && h->sps->vui.b_nal_hrd_parameters_present )<br>+ if( h->i_thread_frames > 1 && h->fenc->b_keyframe && h->sps->vui.b_nal_hrd_parameters_present && (h->param.i_ex_class < 1) )<br> {<br> x264_hrd_fullness( h );<br> x264_nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE );<br>@@ -3835,7 +4720,7 @@ static int x264_encoder_frame_end( x264_t *h, x264_t *thread_current,<br> <br> /* Filler in AVC-Intra mode is written as zero bytes to the last slice<br> * We don't know the size of the last slice until encapsulation so we add filler to the encapsulated NAL */<br>- if( h->param.i_avcintra_class )<br>+ if( h->param.i_avcintra_class || h->param.i_ex_class )<br> {<br> x264_t *h0 = h->thread[0];<br> int ret = x264_check_encapsulated_buffer( h, h0, h->out.i_nal, frame_size, frame_size + filler );<br>diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c<br>index d49e2a2..43c486f 100644<br>--- a/encoder/ratecontrol.c<br>+++ b/encoder/ratecontrol.c<br>@@ -2134,7 +2134,7 @@ static int update_vbv( x264_t *h, int bits )<br> rct->buffer_fill_final_min = 0;<br> }<br> <br>- if( h->param.i_avcintra_class )<br>+ if( h->param.i_avcintra_class || h->param.i_ex_class )<br> buffer_diff = buffer_size;<br> else<br> buffer_diff = (uint64_t)bitrate * h->sps->vui.i_num_units_in_tick * h->fenc->i_cpb_duration;<br>@@ -2147,7 +2147,7 @@ static int update_vbv( x264_t *h, int bits )<br> {<br> int64_t scale = (int64_t)h->sps->vui.i_time_scale * 8;<br> filler = (rct->buffer_fill_final - buffer_size + scale - 1) / scale;<br>- bits = h->param.i_avcintra_class ? filler * 8 : X264_MAX( (FILLER_OVERHEAD - h->param.b_annexb), filler ) * 8;<br>+ bits = (h->param.i_avcintra_class || h->param.i_ex_class) ? filler * 8 : X264_MAX( (FILLER_OVERHEAD - h->param.b_annexb), filler ) * 8;<br> buffer_diff = (uint64_t)bits * h->sps->vui.i_time_scale;<br> rct->buffer_fill_final -= buffer_diff;<br> rct->buffer_fill_final_min -= buffer_diff;<br>diff --git a/encoder/set.c b/encoder/set.c<br>index 9e65e62..c57baa5 100644<br>--- a/encoder/set.c<br>+++ b/encoder/set.c<br>@@ -166,7 +166,7 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )<br> while( (1 << sps->i_log2_max_frame_num) <= max_frame_num )<br> sps->i_log2_max_frame_num++;<br> <br>- sps->i_poc_type = param->i_bframe || param->b_interlaced || param->i_avcintra_class ? 0 : 2;<br>+ sps->i_poc_type = param->i_bframe || param->b_interlaced || param->i_avcintra_class || param->i_ex_class ? 0 : 2;<br> if( sps->i_poc_type == 0 )<br> {<br> int max_delta_poc = (param->i_bframe + 2) * (!!param->i_bframe_pyramid + 1) * 2;<br>@@ -241,12 +241,20 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )<br> if( sps->vui.b_timing_info_present )<br> {<br> sps->vui.i_num_units_in_tick = param->i_timebase_num;<br>- sps->vui.i_time_scale = param->i_timebase_den * 2;<br>+ if( param->b_interlaced == 1 && param->i_ex_class > 0 )<br>+ {<br>+ sps->vui.i_time_scale = param->i_timebase_den;<br>+ }<br>+ else<br>+ sps->vui.i_time_scale = param->i_timebase_den * 2;<br> sps->vui.b_fixed_frame_rate = !param->b_vfr_input;<br> }<br> <br> sps->vui.b_vcl_hrd_parameters_present = 0; // we don't support VCL HRD<br>- sps->vui.b_nal_hrd_parameters_present = !!param->i_nal_hrd;<br>+ if( param->i_ex_class <= 0 )<br>+ {<br>+ sps->vui.b_nal_hrd_parameters_present = !!param->i_nal_hrd;<br>+ }<br> sps->vui.b_pic_struct_present = param->b_pic_struct;<br> <br> // NOTE: HRD related parts of the SPS are initialised in x264_ratecontrol_init_reconfigurable<br>@@ -423,7 +431,7 @@ void x264_pps_init( x264_pps_t *pps, int i_id, x264_param_t *param, x264_sps_t *<br> pps->i_sps_id = sps->i_id;<br> pps->b_cabac = param->b_cabac;<br> <br>- pps->b_pic_order = !param->i_avcintra_class && param->b_interlaced;<br>+ pps->b_pic_order = !(param->i_avcintra_class || param->i_ex_class) && param->b_interlaced;<br> pps->i_num_slice_groups = 1;<br> <br> pps->i_num_ref_idx_l0_default_active = param->i_frame_reference;<br>diff --git a/x264.c b/x264.c<br>index 4dd2a26..404d33c 100644<br>--- a/x264.c<br>+++ b/x264.c<br>@@ -895,6 +895,15 @@ static void help( x264_param_t *defaults, int longhelp )<br> H1( " --bluray-compat Enable compatibility hacks for Blu-ray support\n" );<br> H1( " --avcintra-class <integer> Use compatibility hacks for AVC-Intra class\n"<br> " - 50, 100, 200\n" );<br>+ H1( " --constraint <string> Specify output constraint of AVC-Ultra or XAVC [\"class type\"]\n"<br>+#if BIT_DEPTH == 10<br>+ " intra-50, intra-100, intra-200, intra-300, intra-480 \n"<br>+ " xavc-class-x25, xavc-class-x35, xavc-class-x50 \n"<br>+#elif BIT_DEPTH == 12<br>+ " intra-444-220, intra-480, intra-444-600,\n"<br>+#endif<br>+ );<br>+ H1( " Note: Requires set FPS and resolution.\n" );<br> H1( " --stitchable Don't optimize headers based on video content\n"<br> " Ensures ability to recombine a segmented encode\n" );<br> H1( "\n" );<br>@@ -952,6 +961,7 @@ typedef enum<br> OPT_NOPROGRESS,<br> OPT_LONGHELP,<br> OPT_PROFILE,<br>+ OPT_CONSTRAINT,<br> OPT_PRESET,<br> OPT_TUNE,<br> OPT_SLOWFIRSTPASS,<br>@@ -997,6 +1007,7 @@ static struct option long_options[] =<br> { "open-gop", no_argument, NULL, 0 },<br> { "bluray-compat", no_argument, NULL, 0 },<br> { "avcintra-class", required_argument, NULL, 0 },<br>+ { "constraint", required_argument, NULL, OPT_CONSTRAINT },<br> { "min-keyint", required_argument, NULL, 'i' },<br> { "keyint", required_argument, NULL, 'I' },<br> { "intra-refresh", no_argument, NULL, 0 },<br>@@ -1353,6 +1364,7 @@ static int parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt )<br> char *tcfile_name = NULL;<br> x264_param_t defaults;<br> char *profile = NULL;<br>+ char *constraint = NULL;<br> char *vid_filters = NULL;<br> int b_thread_input = 0;<br> int b_turbo = 1;<br>@@ -1474,6 +1486,10 @@ static int parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt )<br> case OPT_PROFILE:<br> profile = optarg;<br> break;<br>+ case OPT_CONSTRAINT:<br>+ constraint = optarg;<br>+ param->i_ex_class = 1;<br>+ break;<br> case OPT_SLOWFIRSTPASS:<br> b_turbo = 0;<br> break;<br>@@ -1571,7 +1587,26 @@ generic_option:<br> x264_param_apply_fastfirstpass( param );<br> <br> /* Apply profile restrictions. */<br>- if( x264_param_apply_profile( param, profile ) < 0 )<br>+ char profiles[32];<br>+ memset( profiles, 0, 32 );<br>+ int profile_len = 0;<br>+ if( param->i_ex_class )<br>+ {<br>+ if( input_opt.colorspace == NULL )<br>+ param->i_ex_class = 420;<br>+ else<br>+ {<br>+ param->i_ex_class = !strcasecmp( "i420", input_opt.colorspace ) ? 420 :<br>+ !strcasecmp( "i422", input_opt.colorspace ) ? 422 : !strcasecmp( "i444", input_opt.colorspace ) ? 444 : 0;<br>+ FAIL_IF_ERROR( !param->i_ex_class, "input colorspace is not supported for avcultra or xavc.\n" )<br>+ }<br>+ memcpy( profiles, constraint, strlen( constraint ) );<br>+ profiles[strlen( constraint )] = '\0';<br>+ profile_len = strlen( constraint ) + 1;<br>+ }<br>+ profile && memcpy( profiles + profile_len, profile, strlen( profile ) );<br>+<br>+ if( x264_param_apply_profile( param, profiles ) < 0 )<br> return -1;<br> <br> /* Get the file name */<br>diff --git a/x264.h b/x264.h<br>index 9b6d8f4..2597ce9 100644<br>--- a/x264.h<br>+++ b/x264.h<br>@@ -333,6 +333,7 @@ typedef struct x264_param_t<br> int b_open_gop;<br> int b_bluray_compat;<br> int i_avcintra_class;<br>+ int i_ex_class; // used for avcultra class and xavc class<br> <br> int b_deblocking_filter;<br> int i_deblocking_filter_alphac0; /* [-6, 6] -6 light filter, 6 strong */<br>-- <br>1.9.4.msysgit.2<br><br></span></div>
<div><br></div><hr style="width: 210px; height: 1px;" color="#b5c4df" size="1" align="left">
<div><span><div style="MARGIN-LEFT: 10px; MARGIN-TOP: 10px; MARGIN-RIGHT: 10px">
<div><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; COLOR: #000000">Regards,</span></div>
<div><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; COLOR: #000000"></span> </div>
<div><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; COLOR: #000000"> Xuefeng
Jiang</span></div>
<div><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; COLOR: #000000"></span> </div>
<div><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; COLOR: #000000"><a href="mailto:xuefeng@multicorewareinc.com">xuefeng@multicorewareinc.com</a></span></div></div></span></div>
</body></html>