Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -uNrp p/common/common.c po/common/common.c
- --- p/common/common.c Thu Sep 22 22:18:22 2011
- +++ po/common/common.c Fri Sep 23 00:53:05 2011
- @@ -105,8 +105,27 @@ void x264_param_default( x264_param_t *p
- param->rc.i_qp_step = 4;
- param->rc.f_ip_factor = 1.4;
- param->rc.f_pb_factor = 1.3;
- - param->rc.i_aq_mode = X264_AQ_VARIANCE;
- - param->rc.f_aq_strength = 1.0;
- + param->rc.i_aq_mode = X264_AQ_ORE;
- + param->rc.f_aq_strength = 0.5;
- + param->rc.f_aq_strengths[0][0] = 0;
- + param->rc.f_aq_strengths[0][1] = 0;
- + param->rc.f_aq_strengths[0][2] = 0;
- + param->rc.f_aq_strengths[0][3] = 0;
- + param->rc.f_aq_strengths[1][0] = 0;
- + param->rc.f_aq_strengths[1][1] = 0;
- + param->rc.f_aq_strengths[1][2] = 0;
- + param->rc.f_aq_strengths[1][3] = 0;
- + param->rc.f_aq_sensitivity = 10;
- + param->rc.f_aq_ifactor[0] = 1.0;
- + param->rc.f_aq_ifactor[1] = 1.0;
- + param->rc.f_aq_pfactor[0] = 1.0;
- + param->rc.f_aq_pfactor[1] = 1.0;
- + param->rc.f_aq_bfactor[0] = 1.0;
- + param->rc.f_aq_bfactor[1] = 1.0;
- + param->rc.b_aq_boundary = 0;
- + param->rc.i_aq_boundary[0] = 192;
- + param->rc.i_aq_boundary[1] = 64;
- + param->rc.i_aq_boundary[2] = 24;
- param->rc.i_lookahead = 40;
- param->rc.b_stat_write = 0;
- @@ -358,7 +377,7 @@ static int x264_param_apply_tune( x264_p
- else if( !strncasecmp( s, "ssim", 4 ) )
- {
- if( psy_tuning_used++ ) goto psy_failure;
- - param->rc.i_aq_mode = X264_AQ_AUTOVARIANCE;
- + param->rc.i_aq_mode = X264_AQ_MIXORE;
- param->analyse.b_psy = 0;
- }
- else if( !strncasecmp( s, "fastdecode", 10 ) )
- @@ -991,7 +1010,61 @@ int x264_param_parse( x264_param_t *p, c
- OPT("aq-mode")
- p->rc.i_aq_mode = atoi(value);
- OPT("aq-strength")
- - p->rc.f_aq_strength = atof(value);
- + {
- + if( 8 == sscanf( value, "%f:%f:%f:%f:%f:%f:%f:%f",
- + &p->rc.f_aq_strengths[0][0], &p->rc.f_aq_strengths[1][0], &p->rc.f_aq_strengths[0][1], &p->rc.f_aq_strengths[1][1],
- + &p->rc.f_aq_strengths[0][2], &p->rc.f_aq_strengths[1][2], &p->rc.f_aq_strengths[0][3], &p->rc.f_aq_strengths[1][3] ) ||
- + 8 == sscanf( value, "%f,%f,%f,%f,%f,%f,%f,%f",
- + &p->rc.f_aq_strengths[0][0], &p->rc.f_aq_strengths[1][0], &p->rc.f_aq_strengths[0][1], &p->rc.f_aq_strengths[1][1],
- + &p->rc.f_aq_strengths[0][2], &p->rc.f_aq_strengths[1][2], &p->rc.f_aq_strengths[0][3], &p->rc.f_aq_strengths[1][3] ) )
- + p->rc.f_aq_strength = 0.0;
- + else if( 2 == sscanf( value, "%f:%f", &p->rc.f_aq_strengths[0][0], &p->rc.f_aq_strengths[1][0] ) ||
- + 2 == sscanf( value, "%f,%f", &p->rc.f_aq_strengths[0][0], &p->rc.f_aq_strengths[1][0] ) )
- + {
- + p->rc.f_aq_strength = 0.0;
- + for( i = 0; i < 2; i++ )
- + for( int j = 1; j < 4; j++ )
- + p->rc.f_aq_strengths[i][j] = p->rc.f_aq_strengths[i][0];
- + }
- + else if( sscanf( value, "%f", &p->rc.f_aq_strength ) )
- + for( i = 0; i < 2; i++ )
- + for( int j = 0; j < 4; j++ )
- + p->rc.f_aq_strengths[i][j] = p->rc.f_aq_strength;
- + }
- + OPT("aq-sensitivity")
- + p->rc.f_aq_sensitivity = atof(value);
- + OPT("aq-ifactor")
- + if( 2 == sscanf( value, "%f:%f", &p->rc.f_aq_ifactor[0], &p->rc.f_aq_ifactor[1] ) ||
- + 2 == sscanf( value, "%f,%f", &p->rc.f_aq_ifactor[0], &p->rc.f_aq_ifactor[1] ) )
- + { }
- + else if( sscanf( value, "%f", &p->rc.f_aq_ifactor[0] ) )
- + p->rc.f_aq_ifactor[1] = p->rc.f_aq_ifactor[0];
- + else
- + p->rc.f_aq_ifactor[1] = p->rc.f_aq_ifactor[0] = 1.0;
- + OPT("aq-pfactor")
- + if( 2 == sscanf( value, "%f:%f", &p->rc.f_aq_pfactor[0], &p->rc.f_aq_pfactor[1] ) ||
- + 2 == sscanf( value, "%f,%f", &p->rc.f_aq_pfactor[0], &p->rc.f_aq_pfactor[1] ) )
- + { }
- + else if( sscanf( value, "%f", &p->rc.f_aq_pfactor[0] ) )
- + p->rc.f_aq_pfactor[1] = p->rc.f_aq_pfactor[0];
- + else
- + p->rc.f_aq_pfactor[1] = p->rc.f_aq_pfactor[0] = 1.0;
- + OPT("aq-bfactor")
- + if( 2 == sscanf( value, "%f:%f", &p->rc.f_aq_bfactor[0], &p->rc.f_aq_bfactor[1] ) ||
- + 2 == sscanf( value, "%f,%f", &p->rc.f_aq_bfactor[0], &p->rc.f_aq_bfactor[1] ) )
- + { }
- + else if( sscanf( value, "%f", &p->rc.f_aq_bfactor[0] ) )
- + p->rc.f_aq_bfactor[1] = p->rc.f_aq_bfactor[0];
- + else
- + p->rc.f_aq_bfactor[1] = p->rc.f_aq_bfactor[0] = 1.0;
- + OPT("aq-boundary")
- + {
- + if( 3 == sscanf( value, "%d:%d:%d", &p->rc.i_aq_boundary[0], &p->rc.i_aq_boundary[1], &p->rc.i_aq_boundary[2] ) ||
- + 3 == sscanf( value, "%d,%d,%d", &p->rc.i_aq_boundary[0], &p->rc.i_aq_boundary[1], &p->rc.i_aq_boundary[2] ) )
- + p->rc.b_aq_boundary = 1;
- + else
- + p->rc.i_aq_boundary[0] = p->rc.i_aq_boundary[1] = p->rc.i_aq_boundary[2] = 0;
- + }
- OPT("fgo")
- p->analyse.i_fgo = atoi(value);
- OPT("fade-compensate")
- @@ -1434,7 +1507,16 @@ char *x264_param2string( x264_param_t *p
- s += sprintf( s, " pb_ratio=%.2f", p->rc.f_pb_factor );
- s += sprintf( s, " aq=%d", p->rc.i_aq_mode );
- if( p->rc.i_aq_mode )
- - s += sprintf( s, ":%.2f", p->rc.f_aq_strength );
- + {
- + s += sprintf( s, " aq-strength=%.2f:%.2f:%.2f:%.2f:%.2f:%.2f:%.2f:%.2f",
- + p->rc.f_aq_strengths[0][0], p->rc.f_aq_strengths[1][0], p->rc.f_aq_strengths[0][1], p->rc.f_aq_strengths[1][1],
- + p->rc.f_aq_strengths[0][2], p->rc.f_aq_strengths[1][2], p->rc.f_aq_strengths[0][3], p->rc.f_aq_strengths[1][3] );
- + s += sprintf( s, " aq-sensitivity=%.2f", p->rc.f_aq_sensitivity );
- + s += sprintf( s, " aq-ifactor=%.2f:%.2f", p->rc.f_aq_ifactor[0], p->rc.f_aq_ifactor[1] );
- + s += sprintf( s, " aq-pfactor=%.2f:%.2f", p->rc.f_aq_pfactor[0], p->rc.f_aq_pfactor[1] );
- + s += sprintf( s, " aq-bfactor=%.2f:%.2f", p->rc.f_aq_bfactor[0], p->rc.f_aq_bfactor[1] );
- + s += sprintf( s, " aq-boundary=%d:%d:%d", p->rc.i_aq_boundary[0], p->rc.i_aq_boundary[1], p->rc.i_aq_boundary[2] );
- + }
- if( p->rc.psz_zones )
- s += sprintf( s, " zones=%s", p->rc.psz_zones );
- else if( p->rc.i_zones )
- diff -uNrp p/common/common.h po/common/common.h
- --- p/common/common.h Thu Sep 22 19:25:38 2011
- +++ po/common/common.h Fri Sep 23 00:54:09 2011
- @@ -847,6 +847,13 @@ struct x264_t
- int64_t i_ssd[3];
- double f_ssim;
- int i_ssim_cnt;
- +
- + /* AQ stats per frame */
- + uint64_t i_aq_count[5];
- + uint64_t i_aq_result[5][3];
- + uint64_t i_aq_change[2*QP_MAX_SPEC+1];
- + int i_aq_change_min;
- + int i_aq_change_max;
- } frame;
- /* Cumulated stats */
- @@ -877,6 +884,13 @@ struct x264_t
- int i_direct_frames[2];
- /* num p-frames weighted */
- int i_wpred[2];
- + /* */
- + uint64_t i_aq_count_total;
- + uint64_t i_aq_count[5];
- + uint64_t i_aq_result[5][3];
- + uint64_t i_aq_change[2*QP_MAX_SPEC+1];
- + int i_aq_change_min;
- + int i_aq_change_max;
- } stat;
- diff -uNrp p/common/frame.c po/common/frame.c
- --- p/common/frame.c Thu Sep 22 19:25:38 2011
- +++ po/common/frame.c Fri Sep 23 00:55:09 2011
- @@ -238,6 +238,7 @@ static x264_frame_t *x264_frame_new( x26
- {
- CHECKED_MALLOC( frame->f_qp_offset, h->mb.i_mb_count * sizeof(float) );
- CHECKED_MALLOC( frame->f_qp_offset_aq, h->mb.i_mb_count * sizeof(float) );
- + CHECKED_MALLOC( frame->i_aq_type, h->mb.i_mb_count * sizeof(uint8_t) );
- if( h->frames.b_have_lowres )
- /* shouldn't really be initialized, just silences a valgrind false-positive in x264_mbtree_propagate_cost_sse2 */
- CHECKED_MALLOCZERO( frame->i_inv_qscale_factor, (h->mb.i_mb_count+3) * sizeof(uint16_t) );
- @@ -284,6 +285,7 @@ void x264_frame_delete( x264_frame_t *fr
- x264_free( frame->lowres_costs[j][i] );
- x264_free( frame->f_qp_offset );
- x264_free( frame->f_qp_offset_aq );
- + x264_free( frame->i_aq_type );
- x264_free( frame->i_inv_qscale_factor );
- x264_free( frame->i_row_bits );
- x264_free( frame->f_row_qp );
- diff -uNrp p/common/frame.h po/common/frame.h
- --- p/common/frame.h Thu Sep 22 19:25:38 2011
- +++ po/common/frame.h Fri Sep 23 00:55:32 2011
- @@ -125,6 +125,7 @@ typedef struct x264_frame
- float *f_row_qscale;
- float *f_qp_offset;
- float *f_qp_offset_aq;
- + uint8_t *i_aq_type; // OreAQ mode type
- int b_intra_calculated;
- uint16_t *i_intra_cost;
- uint16_t *i_propagate_cost;
- diff -uNrp p/common/pixel.c po/common/pixel.c
- --- p/common/pixel.c Thu Sep 22 22:18:22 2011
- +++ po/common/pixel.c Fri Sep 23 00:57:25 2011
- @@ -72,6 +72,20 @@ PIXEL_SAD_C( x264_pixel_sad_4x16, 4, 1
- PIXEL_SAD_C( x264_pixel_sad_4x8, 4, 8 )
- PIXEL_SAD_C( x264_pixel_sad_4x4, 4, 4 )
- +#define PIXEL_COUNT_C( name, lx, ly ) \
- +static int name( pixel *pix, int i_pix, pixel threshold ) \
- +{ \
- + int i_sum = 0; \
- + for( int y = 0; y < ly; y++, pix += i_pix ) \
- + for( int x = 0; x < lx; x++ ) \
- + i_sum += pix[x] > threshold; \
- + return i_sum; \
- +}
- +
- +PIXEL_COUNT_C( x264_pixel_count_16x16, 16, 16 )
- +PIXEL_COUNT_C( x264_pixel_count_8x16, 8, 16 )
- +PIXEL_COUNT_C( x264_pixel_count_8x8, 8, 8 )
- +
- /****************************************************************************
- * pixel_ssd_WxH
- ****************************************************************************/
- @@ -876,6 +890,9 @@ void x264_pixel_init( int cpu, x264_pixe
- pixf->ssim_4x4x2_core = ssim_4x4x2_core;
- pixf->ssim_end4 = ssim_end4;
- pixf->vsad = pixel_vsad;
- + pixf->pixel_count[PIXEL_16x16] = x264_pixel_count_16x16;
- + pixf->pixel_count[PIXEL_8x16] = x264_pixel_count_8x16;
- + pixf->pixel_count[PIXEL_8x8] = x264_pixel_count_8x8;
- pixf->intra_sad_x3_4x4 = x264_intra_sad_x3_4x4;
- pixf->intra_satd_x3_4x4 = x264_intra_satd_x3_4x4;
- diff -uNrp p/common/pixel.h po/common/pixel.h
- --- p/common/pixel.h Thu Sep 22 22:18:22 2011
- +++ po/common/pixel.h Fri Sep 23 00:58:00 2011
- @@ -116,6 +116,8 @@ typedef struct
- int (*ads[7])( int enc_dc[4], uint16_t *sums, int delta,
- uint16_t *cost_mvx, int16_t *mvs, int width, int thresh );
- + int (*pixel_count[4])( pixel *pix, int i_pix, pixel threshold );
- +
- /* calculate satd or sad of V, H, and DC modes. */
- void (*intra_mbcmp_x3_16x16)( pixel *fenc, pixel *fdec, int res[3] );
- void (*intra_satd_x3_16x16) ( pixel *fenc, pixel *fdec, int res[3] );
- diff -uNrp p/encoder/analyse.c po/encoder/analyse.c
- --- p/encoder/analyse.c Thu Sep 22 22:18:22 2011
- +++ po/encoder/analyse.c Fri Sep 23 00:58:30 2011
- @@ -200,7 +200,10 @@ const float x264_log2_lut[128] =
- /* Avoid an int/float conversion. */
- const float x264_log2_lz_lut[32] =
- {
- - 31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
- + 31.00024, 30.00024, 29.00024, 28.00024, 27.00024, 26.00024, 25.00024, 24.00024,
- + 23.00024, 22.00024, 21.00024, 20.00024, 19.00024, 18.00024, 17.00024, 16.00024,
- + 15.00024, 14.00024, 13.00024, 12.00024, 11.00024, 10.00024, 9.00024, 8.00024,
- + 7.00024, 6.00024, 5.00024, 4.00024, 3.00024, 2.00024, 1.00024, 0.00024
- };
- // should the intra and inter lambdas be different?
- diff -uNrp p/encoder/encoder.c po/encoder/encoder.c
- --- p/encoder/encoder.c Thu Sep 22 22:18:22 2011
- +++ po/encoder/encoder.c Fri Sep 23 01:07:40 2011
- @@ -787,9 +787,41 @@ static int x264_validate_parameters( x26
- h->param.rc.f_fade_compensate = 0;
- h->param.rc.i_aq_mode = x264_clip3( h->param.rc.i_aq_mode, 0, 3 );
- - h->param.rc.f_aq_strength = x264_clip3f( h->param.rc.f_aq_strength, 0, 3 );
- - if( h->param.rc.f_aq_strength == 0 )
- - h->param.rc.i_aq_mode = 0;
- + h->param.rc.f_aq_strength = x264_clip3f( h->param.rc.f_aq_strength, -3, 3 );
- + for( int i = 0; i < 2; i++ )
- + for( int j = 0; j < 4; j++ )
- + h->param.rc.f_aq_strengths[i][j] = x264_clip3f( h->param.rc.f_aq_strengths[i][j], -3, 3 );
- + if( h->param.rc.f_aq_strengths[0][0] == 0 && h->param.rc.f_aq_strengths[1][0] == 0 &&
- + h->param.rc.f_aq_strengths[0][1] == 0 && h->param.rc.f_aq_strengths[1][1] == 0 &&
- + h->param.rc.f_aq_strengths[0][2] == 0 && h->param.rc.f_aq_strengths[1][2] == 0 &&
- + h->param.rc.f_aq_strengths[0][3] == 0 && h->param.rc.f_aq_strengths[1][3] == 0 )
- + {
- + if( h->param.rc.f_aq_strength == 0 )
- + h->param.rc.i_aq_mode = 0;
- + else
- + for( int i = 0; i < 2; i++ )
- + for( int j = 0; j < 4; j++ )
- + h->param.rc.f_aq_strengths[i][j] = h->param.rc.f_aq_strength;
- + }
- + if( h->param.rc.f_aq_sensitivity < 0 )
- + h->param.rc.f_aq_sensitivity = 0;
- + for( int i = 0; i < 2; i++ )
- + {
- + h->param.rc.f_aq_ifactor[i] = x264_clip3f( h->param.rc.f_aq_ifactor[i], -10, 10 );
- + h->param.rc.f_aq_pfactor[i] = x264_clip3f( h->param.rc.f_aq_pfactor[i], -10, 10 );
- + h->param.rc.f_aq_bfactor[i] = x264_clip3f( h->param.rc.f_aq_bfactor[i], -10, 10 );
- + }
- + h->param.rc.i_aq_boundary[0] = x264_clip3( h->param.rc.i_aq_boundary[0], 0, 255 );
- + h->param.rc.i_aq_boundary[1] = x264_clip3( h->param.rc.i_aq_boundary[1], 0, 255 );
- + h->param.rc.i_aq_boundary[2] = x264_clip3( h->param.rc.i_aq_boundary[2], 0, 255 );
- + if( !h->param.rc.b_aq_boundary ||
- + h->param.rc.i_aq_boundary[0] <= h->param.rc.i_aq_boundary[1] || h->param.rc.i_aq_boundary[1] <= h->param.rc.i_aq_boundary[2] )
- + {
- + int shift = BIT_DEPTH - 8;
- + h->param.rc.i_aq_boundary[0] = (h->param.vui.b_fullrange == 1 ? 205 : 192) << shift;
- + h->param.rc.i_aq_boundary[1] = (h->param.vui.b_fullrange == 1 ? 56 : 64) << shift;
- + h->param.rc.i_aq_boundary[2] = (h->param.vui.b_fullrange == 1 ? 9 : 24) << shift;
- + }
- if( h->param.i_log_level < X264_LOG_INFO && (!h->param.psz_log_file || h->param.i_log_file_level < X264_LOG_INFO) )
- {
- @@ -3275,6 +3307,22 @@ static int x264_encoder_frame_end( x264_
- }
- psz_message[79] = '\0';
- + if( h->param.rc.i_aq_mode )
- + {
- + h->stat.i_aq_count_total += h->mb.i_mb_count;
- + for( int i = 0; i < 5; i++ )
- + {
- + h->stat.i_aq_count[i] += h->stat.frame.i_aq_count[i];
- + h->stat.i_aq_result[i][0] += h->stat.frame.i_aq_result[i][0];
- + h->stat.i_aq_result[i][1] += h->stat.frame.i_aq_result[i][1];
- + h->stat.i_aq_result[i][2] += h->stat.frame.i_aq_result[i][2];
- + }
- + for( int i = h->stat.frame.i_aq_change_min+QP_MAX_SPEC; i <= h->stat.frame.i_aq_change_max+QP_MAX_SPEC; i++ )
- + h->stat.i_aq_change[i] += h->stat.frame.i_aq_change[i];
- + h->stat.i_aq_change_min = X264_MIN(h->stat.i_aq_change_min, h->stat.frame.i_aq_change_min);
- + h->stat.i_aq_change_max = X264_MAX(h->stat.i_aq_change_max, h->stat.frame.i_aq_change_max);
- + }
- +
- x264_log( h, X264_LOG_DEBUG,
- "frame=%4d QP=%.2f NAL=%d Slice:%c Poc:%-3d I:%-4d P:%-4d SKIP:%-4d size=%d bytes%s\n",
- h->i_frame,
- @@ -3344,7 +3392,7 @@ void x264_encoder_close ( x264_t *h
- {
- int64_t i_yuv_size = FRAME_SIZE( h->param.i_width * h->param.i_height );
- int64_t i_mb_count_size[2][7] = {{0}};
- - char buf[200];
- + char buf[1500];
- int b_print_pcm = h->stat.i_mb_count[SLICE_TYPE_I][I_PCM]
- || h->stat.i_mb_count[SLICE_TYPE_P][I_PCM]
- || h->stat.i_mb_count[SLICE_TYPE_B][I_PCM];
- @@ -3611,6 +3659,37 @@ void x264_encoder_close ( x264_t *h
- p += sprintf( p, " %4.1f%%", 100. * h->stat.i_mb_count_ref[i_slice][i_list][i] / i_den );
- x264_log( h, X264_LOG_INFO, "ref %c L%d:%s\n", "PB"[i_slice], i_list, buf );
- }
- +
- + if( h->stat.i_aq_count_total && !h->param.rc.b_mb_tree )
- + {
- +#define GET_AQ_RESULT(x) \
- + 100.0 / h->stat.i_aq_count_total * h->stat.i_aq_count[x], \
- + h->stat.i_aq_count[x] ? (100.0 / h->stat.i_aq_count[x] * h->stat.i_aq_result[x][0]) : 0, \
- + h->stat.i_aq_count[x] ? (100.0 / h->stat.i_aq_count[x] * h->stat.i_aq_result[x][1]) : 0, \
- + h->stat.i_aq_count[x] ? (100.0 / h->stat.i_aq_count[x] * h->stat.i_aq_result[x][2]) : 0
- + char *p = buf;
- +
- + x264_log( h, X264_LOG_INFO,
- + "AQ Result Bright MB:%5.2f%% QP Up:%5.2f%% Down:%5.2f%% Even:%5.2f%%\n",
- + GET_AQ_RESULT(1));
- +
- + x264_log( h, X264_LOG_INFO,
- + "AQ Result Middle MB:%5.2f%% QP Up:%5.2f%% Down:%5.2f%% Even:%5.2f%%\n",
- + GET_AQ_RESULT(2));
- +
- + x264_log( h, X264_LOG_INFO,
- + "AQ Result Dark MB:%5.2f%% QP Up:%5.2f%% Down:%5.2f%% Even:%5.2f%%\n",
- + GET_AQ_RESULT(3));
- +
- + x264_log( h, X264_LOG_INFO,
- + "AQ Result M.Dark MB:%5.2f%% QP Up:%5.2f%% Down:%5.2f%% Even:%5.2f%%\n",
- + GET_AQ_RESULT(4));
- +
- + for( int i = h->stat.i_aq_change_min; i <= h->stat.i_aq_change_max; i++ )
- + p += sprintf( p, " %d:%.2f%%", -i, 100.0 / h->stat.i_aq_count_total * h->stat.i_aq_change[i + QP_MAX_SPEC] );
- + x264_log( h, X264_LOG_INFO, "AQ change value %s\n", buf );
- +
- + }
- if( h->param.analyse.b_ssim )
- {
- diff -uNrp p/encoder/ratecontrol.c po/encoder/ratecontrol.c
- --- p/encoder/ratecontrol.c Thu Sep 22 22:18:22 2011
- +++ po/encoder/ratecontrol.c Fri Sep 23 01:42:22 2011
- @@ -149,6 +149,9 @@ struct x264_ratecontrol_t
- int bframes; /* # consecutive B-frames before this P-frame */
- int bframe_bits; /* total cost of those frames */
- + /* AQ stuff */
- + float aq_threshold;
- +
- int i_zones;
- x264_zone_t *zones;
- x264_zone_t *prev_zone;
- @@ -240,7 +243,7 @@ static ALWAYS_INLINE uint32_t ac_energy_
- }
- // Find the total AC energy of the block in all planes.
- -static NOINLINE uint32_t x264_ac_energy_mb( x264_t *h, int mb_x, int mb_y, x264_frame_t *frame )
- +static NOINLINE uint32_t x264_ac_energy_mb( x264_t *h, int mb_x, int mb_y, x264_frame_t *frame, uint32_t *energy )
- {
- /* This function contains annoying hacks because GCC has a habit of reordering emms
- * and putting it after floating point ops. As a result, we put the emms at the end of the
- @@ -251,40 +254,230 @@ static NOINLINE uint32_t x264_ac_energy_
- {
- /* We don't know the super-MB mode we're going to pick yet, so
- * simply try both and pick the lower of the two. */
- - uint32_t var_interlaced, var_progressive;
- - var_interlaced = ac_energy_plane( h, mb_x, mb_y, frame, 0, 0, 1, 1 );
- - var_progressive = ac_energy_plane( h, mb_x, mb_y, frame, 0, 0, 0, 0 );
- + uint32_t var_interlaced_y = ac_energy_plane( h, mb_x, mb_y, frame, 0, 0, 1, 1 );
- + uint32_t var_progressive_y = ac_energy_plane( h, mb_x, mb_y, frame, 0, 0, 0, 0 );
- + uint32_t var_interlaced_uv;
- + uint32_t var_progressive_uv;
- if( CHROMA444 )
- {
- - var_interlaced += ac_energy_plane( h, mb_x, mb_y, frame, 1, 0, 1, 1 );
- - var_progressive += ac_energy_plane( h, mb_x, mb_y, frame, 1, 0, 0, 0 );
- - var_interlaced += ac_energy_plane( h, mb_x, mb_y, frame, 2, 0, 1, 1 );
- - var_progressive += ac_energy_plane( h, mb_x, mb_y, frame, 2, 0, 0, 0 );
- + var_interlaced_uv = ac_energy_plane( h, mb_x, mb_y, frame, 1, 0, 1, 1 );
- + var_progressive_uv = ac_energy_plane( h, mb_x, mb_y, frame, 1, 0, 0, 0 );
- + var_interlaced_uv += ac_energy_plane( h, mb_x, mb_y, frame, 2, 0, 1, 1 );
- + var_progressive_uv += ac_energy_plane( h, mb_x, mb_y, frame, 2, 0, 0, 0 );
- + }
- + else
- + {
- + var_interlaced_uv = ac_energy_plane( h, mb_x, mb_y, frame, 1, 1, 1, 1 );
- + var_progressive_uv = ac_energy_plane( h, mb_x, mb_y, frame, 1, 1, 0, 0 );
- + }
- + uint32_t var_interlaced = var_interlaced_y + var_interlaced_uv;
- + uint32_t var_progressive = var_progressive_y + var_progressive_uv;
- + if( var_interlaced < var_progressive )
- + {
- + var = var_interlaced;
- + energy[0] = var_interlaced_y;
- + energy[1] = var_interlaced_uv;
- }
- else
- {
- - var_interlaced += ac_energy_plane( h, mb_x, mb_y, frame, 1, 1, 1, 1 );
- - var_progressive += ac_energy_plane( h, mb_x, mb_y, frame, 1, 1, 0, 0 );
- + var = var_progressive;
- + energy[0] = var_progressive_y;
- + energy[1] = var_progressive_uv;
- }
- - var = X264_MIN( var_interlaced, var_progressive );
- }
- else
- {
- - var = ac_energy_plane( h, mb_x, mb_y, frame, 0, 0, PARAM_INTERLACED, 1 );
- +
- + energy[0] = ac_energy_plane( h, mb_x, mb_y, frame, 0, 0, PARAM_INTERLACED, 1 );
- if( CHROMA444 )
- {
- - var += ac_energy_plane( h, mb_x, mb_y, frame, 1, 0, PARAM_INTERLACED, 1 );
- - var += ac_energy_plane( h, mb_x, mb_y, frame, 2, 0, PARAM_INTERLACED, 1 );
- + energy[1] = ac_energy_plane( h, mb_x, mb_y, frame, 1, 0, PARAM_INTERLACED, 1 );
- + energy[1] += ac_energy_plane( h, mb_x, mb_y, frame, 2, 0, PARAM_INTERLACED, 1 );
- }
- else
- - var += ac_energy_plane( h, mb_x, mb_y, frame, 1, 1, PARAM_INTERLACED, 1 );
- + energy[1] = ac_energy_plane( h, mb_x, mb_y, frame, 1, 1, PARAM_INTERLACED, 1 );
- + var = energy[0] + energy[1];
- }
- x264_emms();
- return var;
- }
- +static NOINLINE void get_image_mb( x264_t *h, int mb_x, int mb_y, x264_frame_t *frame, int b_field, int *luma, int *bluePoint )
- +{
- +#define BLUE_THRESHOLD (0x81<<(BIT_DEPTH-8))
- +#define RED_THRESHOLD (0x87<<(BIT_DEPTH-8))
- + ALIGNED_16( static uint8_t zero[17] ) = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
- + if( CHROMA444 )
- + {
- + int stride[3];
- + int offset[3];
- + for( int i = 0; i < 3; i++ )
- + {
- + stride[i] = frame->i_stride[i];
- + offset[i] = b_field
- + ? 16 * (mb_x + (mb_y&~1) * stride[i]) + (mb_y&1) * stride[i]
- + : 16 * (mb_x + mb_y * stride[i]);
- + stride[i] <<= b_field;
- + }
- + *luma = h->pixf.sad[PIXEL_16x16]( frame->plane[0] + offset[0], stride[0], zero, 0 ) >> 8;
- + *bluePoint =
- + (h->pixf.pixel_count[PIXEL_16x16]( frame->plane[1] + offset[1], stride[1], BLUE_THRESHOLD ) >= 160) &&
- + (h->pixf.pixel_count[PIXEL_16x16]( frame->plane[2] + offset[2], stride[2], RED_THRESHOLD ) <= 96);
- + }
- + else
- + {
- + int height[2];
- + int stride[2];
- + int offset[2];
- + for( int i = 0; i < 2; i++ )
- + {
- + height[i] = i ? 16>>h->mb.chroma_v_shift : 16;
- + stride[i] = frame->i_stride[i];
- + offset[i] = b_field
- + ? 16 * mb_x + height[i] *(mb_y&~1) * stride[i] + (mb_y&1) * stride[i]
- + : 16 * mb_x + height[i] * mb_y * stride[i];
- + stride[i] <<= b_field;
- + }
- + *luma = h->pixf.sad[PIXEL_16x16]( frame->plane[0] + offset[0], stride[0], zero, 0 ) >> 8;
- + ALIGNED_ARRAY_16( pixel, pix,[FENC_STRIDE*16] );
- + int chromapix = h->luma2chroma_pixel[PIXEL_16x16];
- + int weight = 1 + (chromapix == PIXEL_8x16);
- + h->mc.load_deinterleave_chroma_fenc( pix, frame->plane[1] + offset[1], stride[1], height[1] );
- + *bluePoint =
- + (h->pixf.pixel_count[chromapix]( pix, FENC_STRIDE, BLUE_THRESHOLD ) >= 40 * weight) &&
- + (h->pixf.pixel_count[chromapix]( pix+FENC_STRIDE/2, FENC_STRIDE, RED_THRESHOLD ) <= 24 * weight);
- + }
- +#undef BLUE_THRESHOLD
- +#undef RED_THRESHOLD
- +}
- +
- +static NOINLINE float x264_adjust_OreAQ( x264_t *h, int mb_x, int mb_y, x264_frame_t *frame, uint32_t *energy )
- +{
- + uint8_t mode;
- + int bluePoint = 0;
- + int luma = 0;
- + float energy_y, energy_uv, f_qp_adj;
- + uint32_t _energy_y, _energy_uv;
- +
- + get_image_mb( h, mb_x, mb_y, frame, PARAM_INTERLACED, &luma, &bluePoint );
- + x264_emms();
- +
- + _energy_y = X264_MAX( energy[0], 1 );
- + _energy_uv = X264_MAX( energy[1], 1 );
- +
- + // logf(energy) = 1.0397 * x264_log2( energy ) / 1.5
- + // energy_y = 1.2 * (logf(_energy_y ) - ((h->rc->aq_threshold + 2*(BIT_DEPTH-8)) * .91) + 0.5);
- + // energy_uv = 0.8 * (logf(_energy_uv) - ((h->rc->aq_threshold + 2*(BIT_DEPTH-8)) * .91) + 0.5);
- + energy_y = 0.83176f * x264_log2( _energy_y ) - ((h->rc->aq_threshold + 2*(BIT_DEPTH-8)) * 1.092f) + 0.5f;
- + energy_uv = 0.55451f * x264_log2( _energy_uv ) - ((h->rc->aq_threshold + 2*(BIT_DEPTH-8)) * 0.728f) + 0.5f;
- + f_qp_adj = 0.f;
- +
- + if( luma > h->param.rc.i_aq_boundary[0] )
- + {
- + // *** Bright ***
- + // Y & UV Flat -> qp up
- + // Y Flat / UV Bump -> qp y up
- + // Y Bump / UV Flat -> even
- + // Y & UV Bump -> qp down
- + mode = 0x00;
- +
- + // qp up
- + if( !bluePoint && energy_y < 0 && energy_uv < 0 )
- + f_qp_adj = X264_MIN( energy_y, energy_uv );
- + // qp y up
- + else if( !bluePoint && energy_y < 0 && energy_uv >= 0 )
- + f_qp_adj = energy_y;
- + // qp down
- + else if( energy_y >= 0 && energy_uv >= 0 )
- + f_qp_adj = X264_MAX( energy_y, energy_uv ) * 0.5f;
- + }
- + else if( luma > h->param.rc.i_aq_boundary[1] )
- + {
- + // *** Middle ***
- + // Y & UV Flat -> qp up
- + // Y Flat / UV Bump -> even
- + // Y Bump / UV Flat -> qp mix down
- + // Y & UV Bump -> qp down
- + mode = 0x01;
- +
- + // qp up
- + if( !bluePoint && energy_y < 0 && energy_uv < 0 )
- + f_qp_adj = X264_MAX( energy_y, energy_uv );
- + // qp mix down
- + else if( energy_y >= 0 && energy_uv < 0 )
- + f_qp_adj = X264_MAX( energy_y + (!bluePoint * energy_uv), 0 ) * 0.5f;
- + // qp down
- + else if( energy_y >= 0 && energy_uv >= 0 )
- + f_qp_adj = X264_MAX( energy_y, bluePoint * energy_uv );
- + }
- + else if( luma > h->param.rc.i_aq_boundary[2] )
- + {
- + // *** Dark ***
- + // Y & UV Flat -> qp up
- + // Y Flat / UV Bump -> qp uv down
- + // Y Bump / UV Flat -> qp y down
- + // Y & UV Bump -> qp down
- + mode = 0x02;
- +
- + // qp up
- + if( energy_y < 0 && energy_uv < 0 )
- + f_qp_adj = X264_MAX( energy_y, energy_uv ) * 0.5f;
- + // qp uv down
- + else if( energy_y < 0 && energy_uv >= 0 )
- + f_qp_adj = energy_uv * 1.25f;
- + // qp y down
- + else if( energy_y >= 0 && energy_uv < 0 )
- + f_qp_adj = energy_y * 1.25f;
- + // qp down
- + else if( energy_y >= 0 && energy_uv >= 0 )
- + f_qp_adj = X264_MAX( energy_y, energy_uv ) * 1.25f;
- + }
- + else
- + {
- + // *** M.Dark ***
- + // Y & UV Flat -> qp double up
- + // Y Flat / UV Bump -> qp y up
- + // Y Bump / UV Flat -> qp uv up
- + // Y & UV Bump -> even
- + mode = 0x03;
- +
- + // qp double up
- + if( energy_y < 0 && energy_uv < 0 )
- + f_qp_adj = energy_y + energy_uv;
- + // qp mix up
- + else if( energy_y < 0 && energy_uv >= 0 )
- + f_qp_adj = energy_y;
- + // qp uv down
- + else if( energy_y >= 0 && energy_uv < 0 )
- + f_qp_adj = energy_uv * 0.5f;
- + }
- +
- + /* If f_qp_adj is positive, then lower the qp. */
- + f_qp_adj *= h->param.rc.f_aq_strengths[f_qp_adj>0][mode];
- +
- + frame->i_aq_type[mb_x + mb_y*h->mb.i_mb_stride] = mode + 0x01;
- +
- + if( h->param.rc.i_aq_mode == X264_AQ_ORE )
- + {
- + /* If current MB is frame edge, lower the qp. */
- + if( mb_x == 0 || mb_y == 0 || mb_x == h->sps->i_mb_width - 1 || mb_y == h->sps->i_mb_height - 1 )
- + f_qp_adj += (float)( (energy_y<0) + (energy_uv<0) + 1 ) * ( h->param.rc.f_aq_strengths[1][3] + 0.5f );
- + }
- +
- + return -f_qp_adj;
- +}
- +
- void x264_adaptive_quant_frame( x264_t *h, x264_frame_t *frame, float *quant_offsets )
- {
- + /* constants chosen to result in approximately the same overall bitrate as without AQ.
- + * FIXME: while they're written in 5 significant digits, they're only tuned to 2. */
- + float strength = 0.f;
- + float avg_adj = 0.f;
- + uint32_t energy_yuv[2] = {0, 0};
- + int no_aq = h->param.rc.f_aq_strengths[0][0] == 0 && h->param.rc.f_aq_strengths[1][0] == 0 &&
- + h->param.rc.f_aq_strengths[0][1] == 0 && h->param.rc.f_aq_strengths[1][1] == 0 &&
- + h->param.rc.f_aq_strengths[0][2] == 0 && h->param.rc.f_aq_strengths[1][2] == 0 &&
- + h->param.rc.f_aq_strengths[0][3] == 0 && h->param.rc.f_aq_strengths[1][3] == 0;
- /* Initialize frame stats */
- for( int i = 0; i < 3; i++ )
- {
- @@ -293,10 +486,10 @@ void x264_adaptive_quant_frame( x264_t *
- }
- /* Degenerate cases */
- - if( h->param.rc.i_aq_mode == X264_AQ_NONE || h->param.rc.f_aq_strength == 0 )
- + if( h->param.rc.i_aq_mode == X264_AQ_NONE || no_aq )
- {
- /* Need to init it anyways for MB tree */
- - if( h->param.rc.i_aq_mode && h->param.rc.f_aq_strength == 0 )
- + if( h->param.rc.i_aq_mode && no_aq )
- {
- if( quant_offsets )
- {
- @@ -314,13 +507,14 @@ void x264_adaptive_quant_frame( x264_t *
- for( int mb_xy = 0; mb_xy < h->mb.i_mb_count; mb_xy++ )
- frame->i_inv_qscale_factor[mb_xy] = 256;
- }
- + memset( frame->i_aq_type, 0, h->mb.i_mb_count * sizeof(uint8_t) );
- }
- /* Need variance data for weighted prediction */
- if( h->param.analyse.i_weighted_pred )
- {
- for( int mb_y = 0; mb_y < h->mb.i_mb_height; mb_y++ )
- for( int mb_x = 0; mb_x < h->mb.i_mb_width; mb_x++ )
- - x264_ac_energy_mb( h, mb_x, mb_y, frame );
- + x264_ac_energy_mb( h, mb_x, mb_y, frame, energy_yuv );
- }
- else
- return;
- @@ -328,53 +522,49 @@ void x264_adaptive_quant_frame( x264_t *
- /* Actual adaptive quantization */
- else
- {
- - /* constants chosen to result in approximately the same overall bitrate as without AQ.
- - * FIXME: while they're written in 5 significant digits, they're only tuned to 2. */
- - float strength;
- - float avg_adj = 0.f;
- - float mod_strength = 0.f;
- + h->rc->aq_threshold = logf( powf( h->param.rc.f_aq_sensitivity, 4 ) / 2.0 );
- - if( h->param.rc.i_aq_mode == X264_AQ_AUTOVARIANCE || h->param.rc.i_aq_mode == X264_AQ_AUTOVARIANCE_MOD )
- + if( h->param.rc.i_aq_mode == X264_AQ_MIXORE )
- {
- - float bit_depth_correction = 1.f / (1 << (2*(BIT_DEPTH-8)));
- + float bit_depth_correction = powf(1 << (BIT_DEPTH-8), 0.5f);
- float avg_adj_pow2 = 0.f;
- for( int mb_y = 0; mb_y < h->mb.i_mb_height; mb_y++ )
- for( int mb_x = 0; mb_x < h->mb.i_mb_width; mb_x++ )
- {
- - uint32_t energy = x264_ac_energy_mb( h, mb_x, mb_y, frame );
- - float qp_adj = powf( energy * bit_depth_correction + 1, 0.125f );
- - frame->f_qp_offset[mb_x + mb_y*h->mb.i_mb_stride] = qp_adj;
- + uint32_t energy = x264_ac_energy_mb( h, mb_x, mb_y, frame, energy_yuv );
- + float qp_adj = powf( energy + 1, 0.125f );
- avg_adj += qp_adj;
- avg_adj_pow2 += qp_adj * qp_adj;
- + frame->f_qp_offset[mb_x + mb_y*h->mb.i_mb_stride] = qp_adj;
- + frame->f_qp_offset_aq[mb_x + mb_y*h->mb.i_mb_stride] = x264_adjust_OreAQ( h, mb_x, mb_y, frame, energy_yuv );
- }
- avg_adj /= h->mb.i_mb_count;
- avg_adj_pow2 /= h->mb.i_mb_count;
- - strength = h->param.rc.f_aq_strength * avg_adj;
- - avg_adj = avg_adj - 0.5f * (avg_adj_pow2 - 14.f) / avg_adj;
- - mod_strength = h->param.rc.f_aq_strength;
- + strength = h->param.rc.f_aq_strengths[1][3] * avg_adj / bit_depth_correction;
- + avg_adj = avg_adj - 0.5f * (avg_adj_pow2 - (14.f * bit_depth_correction)) / avg_adj;
- }
- - else
- - strength = h->param.rc.f_aq_strength * 1.0397f;
- for( int mb_y = 0; mb_y < h->mb.i_mb_height; mb_y++ )
- for( int mb_x = 0; mb_x < h->mb.i_mb_width; mb_x++ )
- {
- float qp_adj;
- int mb_xy = mb_x + mb_y*h->mb.i_mb_stride;
- - if( h->param.rc.i_aq_mode == X264_AQ_AUTOVARIANCE_MOD )
- - {
- - qp_adj = frame->f_qp_offset[mb_xy];
- - qp_adj = strength * (qp_adj - avg_adj) + mod_strength * (1.f - 14.f / (qp_adj * qp_adj));
- - }
- - else if( h->param.rc.i_aq_mode == X264_AQ_AUTOVARIANCE )
- + if( h->param.rc.i_aq_mode == X264_AQ_MIXORE )
- {
- - qp_adj = frame->f_qp_offset[mb_xy];
- - qp_adj = strength * (qp_adj - avg_adj);
- + if( frame->f_qp_offset_aq[mb_xy] < -1 )
- + {
- + qp_adj = strength * (frame->f_qp_offset[mb_xy] - avg_adj);
- + qp_adj = X264_MIN( qp_adj, frame->f_qp_offset_aq[mb_xy] );
- + }
- + else if( frame->f_qp_offset_aq[mb_xy] >= 1 )
- + qp_adj = frame->f_qp_offset_aq[mb_xy];
- + else
- + qp_adj = strength * (frame->f_qp_offset[mb_xy] - avg_adj);
- }
- else
- {
- - uint32_t energy = x264_ac_energy_mb( h, mb_x, mb_y, frame );
- - qp_adj = strength * (x264_log2( X264_MAX(energy, 1) ) - (14.427f + 2*(BIT_DEPTH-8)));
- + x264_ac_energy_mb( h, mb_x, mb_y, frame, energy_yuv );
- + qp_adj = x264_adjust_OreAQ( h, mb_x, mb_y, frame, energy_yuv );
- }
- if( quant_offsets )
- qp_adj += quant_offsets[mb_xy];
- @@ -430,6 +620,8 @@ int x264_macroblock_tree_read( x264_t *h
- frame->i_inv_qscale_factor[i] = x264_exp2fix8(frame->f_qp_offset[i]);
- }
- rc->qpbuf_pos--;
- +
- + memset( frame->i_aq_type, 0, h->mb.i_mb_count * sizeof(uint8_t) );
- }
- else
- x264_stack_align( x264_adaptive_quant_frame, h, frame, quant_offsets );
- @@ -1534,17 +1726,32 @@ int x264_ratecontrol_qp( x264_t *h )
- int x264_ratecontrol_mb_qp( x264_t *h )
- {
- x264_emms();
- - float qp = h->rc->qpm;
- - if( h->param.rc.i_aq_mode )
- - {
- - /* MB-tree currently doesn't adjust quantizers in unreferenced frames. */
- - float qp_offset = h->fdec->b_kept_as_ref ? h->fenc->f_qp_offset[h->mb.i_mb_xy] : h->fenc->f_qp_offset_aq[h->mb.i_mb_xy];
- - /* Scale AQ's effect towards zero in emergency mode. */
- - if( qp > QP_MAX_SPEC )
- - qp_offset *= (QP_MAX - qp) / (QP_MAX - QP_MAX_SPEC);
- - qp += qp_offset;
- - }
- - return x264_clip3( qp + 0.5f, h->param.rc.i_qp_min, h->param.rc.i_qp_max );
- + float f_qp = h->rc->qpm;
- + if( !h->param.rc.i_aq_mode )
- + return x264_clip3( f_qp + 0.5f, h->param.rc.i_qp_min, h->param.rc.i_qp_max );
- +
- + /* MB-tree currently doesn't adjust quantizers in unreferenced frames. */
- + float qp_offset = h->fdec->b_kept_as_ref ? h->fenc->f_qp_offset[h->mb.i_mb_xy] : h->fenc->f_qp_offset_aq[h->mb.i_mb_xy];
- +
- + qp_offset *= h->sh.i_type == SLICE_TYPE_I ? h->param.rc.f_aq_ifactor[qp_offset<0]
- + : h->sh.i_type == SLICE_TYPE_P ? h->param.rc.f_aq_pfactor[qp_offset<0]
- + : h->sh.i_type == SLICE_TYPE_B ? h->param.rc.f_aq_bfactor[qp_offset<0]
- + : 1.f;
- +
- + /* Scale AQ's effect towards zero in emergency mode. */
- + if( f_qp > QP_MAX_SPEC )
- + qp_offset *= (QP_MAX - f_qp) / (QP_MAX - QP_MAX_SPEC);
- +
- + int i_qp = (int)(f_qp + qp_offset + 0.5f);
- + int i_qp_adj = x264_clip3( f_qp - i_qp + 0.5f, -QP_MAX_SPEC, QP_MAX_SPEC );
- +
- + h->stat.frame.i_aq_change[i_qp_adj + QP_MAX_SPEC] += 1;
- + h->stat.frame.i_aq_count[ h->fenc->i_aq_type[h->mb.i_mb_xy] ] += 1;
- + h->stat.frame.i_aq_result[ h->fenc->i_aq_type[h->mb.i_mb_xy] ][ i_qp_adj < 0 ? 0 :(i_qp_adj > 0 ? 1 : 2) ] += 1;
- + h->stat.frame.i_aq_change_min = X264_MIN(h->stat.frame.i_aq_change_min, i_qp_adj);
- + h->stat.frame.i_aq_change_max = X264_MAX(h->stat.frame.i_aq_change_max, i_qp_adj);
- +
- + return x264_clip3( i_qp, h->param.rc.i_qp_min, h->param.rc.i_qp_max );
- }
- /* In 2pass, force the same frame types as in the 1st pass */
- diff -uNrp p/x264.c po/x264.c
- --- p/x264.c Thu Sep 22 22:18:23 2011
- +++ po/x264.c Fri Sep 23 01:44:22 2011
- @@ -690,11 +690,27 @@ static void help( x264_param_t *defaults
- H2( " --chroma-qp-offset <integer> QP difference between chroma and luma [%d]\n", defaults->analyse.i_chroma_qp_offset );
- H2( " --aq-mode <integer> AQ method [%d]\n"
- " - 0: Disabled\n"
- - " - 1: Variance AQ (complexity mask)\n"
- - " - 2: Auto-variance AQ (experimental)\n"
- - " - 3: Auto-variance AQ modification\n", defaults->rc.i_aq_mode );
- - H1( " --aq-strength <float> Reduces blocking and blurring in flat and\n"
- - " textured areas. [%.1f]\n", defaults->rc.f_aq_strength );
- + " - 1: OreAQ\n"
- + " - 2: MixOre (experimental)\n", defaults->rc.i_aq_mode );
- + H1( " --aq-strength <float> Reduces blocking and blurring in bump and\n"
- + " clear-cut areas. [%.1f]\n", defaults->rc.f_aq_strength );
- + H2( " <Up:Down> or <Up1:Down1:Up2:Down2:Up3:Down3:Up4:OtherStuff>\n"
- + " Set QP up/down strength.\n" );
- + H1( " --aq-sensitivity <float> \"Center\" of AQ curve. [%.1f]\n"
- + " - 5: most QPs are raised\n"
- + " - 10: good general-use sensitivity\n"
- + " - 15: most QPs are lowered\n", defaults->rc.f_aq_sensitivity );
- + H2( " --aq-ifactor <Up:Down> AQ strength factor of I-frames [%.1f:%.1f]\n", defaults->rc.f_aq_ifactor[0], defaults->rc.f_aq_ifactor[1] );
- + H2( " --aq-pfactor <Up:Down> AQ strength factor of P-frames [%.1f:%.1f]\n", defaults->rc.f_aq_pfactor[0], defaults->rc.f_aq_pfactor[1] );
- + H2( " --aq-bfactor <Up:Down> AQ strength factor of B-frames [%.1f:%.1f]\n", defaults->rc.f_aq_bfactor[0], defaults->rc.f_aq_bfactor[1] );
- + H2( " --aq-boundary <int:int:int> AQ boundary. \n"
- + " fullrange=off: [%d:%d:%d]\n"
- + " fullrange=on : [%d:%d:%d]\n"
- + " #1: Bright-Middle\n"
- + " #2: Middle-Dark\n"
- + " #3: Dark-M.Dark\n",
- + 192<<(BIT_DEPTH-8), 64<<(BIT_DEPTH-8), 24<<(BIT_DEPTH-8),
- + 205<<(BIT_DEPTH-8), 56<<(BIT_DEPTH-8), 9<<(BIT_DEPTH-8) );
- H1( " --fade-compensate <float> Allocate more bits to fades [%.1f]\n", defaults->rc.f_fade_compensate );
- H2( " Approximate sane range: 0.0 - 1.0\n" );
- H1( "\n" );
- @@ -1067,7 +1083,12 @@ static struct option long_options[] =
- { "no-fast-pskip", no_argument, NULL, 0 },
- { "no-dct-decimate", no_argument, NULL, 0 },
- { "aq-strength", required_argument, NULL, 0 },
- + { "aq-sensitivity", required_argument, NULL, 0 },
- + { "aq-ifactor", required_argument, NULL, 0 },
- + { "aq-pfactor", required_argument, NULL, 0 },
- + { "aq-bfactor", required_argument, NULL, 0 },
- { "aq-mode", required_argument, NULL, 0 },
- + { "aq-boundary", required_argument, NULL, 0 },
- { "fgo", required_argument, NULL, 0 },
- { "fade-compensate", required_argument, NULL, 0 },
- { "deadzone-inter", required_argument, NULL, 0 },
- diff -uNrp p/x264.h po/x264.h
- --- p/x264.h Thu Sep 22 22:18:23 2011
- +++ po/x264.h Fri Sep 23 01:45:21 2011
- @@ -42,6 +42,8 @@
- #include "x264_config.h"
- #define X264_BUILD 118
- +#define X264_SUB_BUILD 2 // OreAQ
- +#define X264_AQ_MODE_ORE05 0x00000004
- /* x264_t:
- * opaque handler for encoder */
- @@ -150,9 +152,8 @@ typedef struct
- #define X264_RC_ABR 2
- #define X264_QP_AUTO 0
- #define X264_AQ_NONE 0
- -#define X264_AQ_VARIANCE 1
- -#define X264_AQ_AUTOVARIANCE 2
- -#define X264_AQ_AUTOVARIANCE_MOD 3
- +#define X264_AQ_ORE 1
- +#define X264_AQ_MIXORE 2
- #define X264_B_ADAPT_NONE 0
- #define X264_B_ADAPT_FAST 1
- #define X264_B_ADAPT_TRELLIS 2
- @@ -390,6 +391,13 @@ typedef struct x264_param_t
- int i_aq_mode; /* psy adaptive QP. (X264_AQ_*) */
- float f_aq_strength;
- + float f_aq_strengths[2][4]; /* Up{ Bright, Middle, Dark, M.Dark }, Down{ Bright, Middle, Dark, Other stuff } */
- + float f_aq_sensitivity;
- + float f_aq_ifactor[2]; /* { Up, Down } */
- + float f_aq_pfactor[2]; /* { Up, Down } */
- + float f_aq_bfactor[2]; /* { Up, Down } */
- + int b_aq_boundary;
- + int i_aq_boundary[3];
- float f_fade_compensate; /* Give more bits to fades. */
- int b_mb_tree; /* Macroblock-tree ratecontrol. */
- int i_lookahead;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement