Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2010
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.17 KB | None | 0 0
  1. From: Dark Shikari <darkshikari@gmail.com>
  2. Subject: [PATCH] Add fade compensation function
  3.  
  4. common/common.c | 5 +++++
  5. encoder/encoder.c | 7 +++++++
  6. encoder/slicetype.c | 4 ++--
  7. x264.c | 3 +++
  8. x264.h | 1 +
  9. 5 files changed, 18 insertions(+), 2 deletions(-)
  10.  
  11. Index: common/common.c
  12. ===================================================================
  13. --- common/common_orig.c
  14. +++ common/common.c
  15. @@ -920,6 +920,8 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value )
  16. p->rc.i_aq_mode = atoi(value);
  17. OPT("aq-strength")
  18. p->rc.f_aq_strength = atof(value);
  19. + OPT("fade-compensate")
  20. + p->rc.f_fade_compensate = atof(value);
  21. OPT("pass")
  22. {
  23. int pass = x264_clip3( atoi(value), 0, 3 );
  24. @@ -1196,7 +1198,10 @@ char *x264_param2string( x264_param_t *p, int b_res )
  25. s += sprintf( s, " subme=%d", p->analyse.i_subpel_refine );
  26. s += sprintf( s, " psy=%d", p->analyse.b_psy );
  27. if( p->analyse.b_psy )
  28. + {
  29. + s += sprintf( s, " fade_compensate=%.2f", p->rc.f_fade_compensate );
  30. s += sprintf( s, " psy_rd=%.2f:%.2f", p->analyse.f_psy_rd, p->analyse.f_psy_trellis );
  31. + }
  32. s += sprintf( s, " mixed_ref=%d", p->analyse.b_mixed_references );
  33. s += sprintf( s, " me_range=%d", p->analyse.i_me_range );
  34. s += sprintf( s, " chroma_me=%d", p->analyse.b_chroma_me );
  35. Index: encoder/encoder.c
  36. ===================================================================
  37. --- encoder/encoder_orig.c
  38. +++ encoder/encoder.c
  39. @@ -686,10 +686,17 @@ static int x264_validate_parameters( x264_t *h )
  40. if( !h->param.b_cabac )
  41. h->param.analyse.i_trellis = 0;
  42. h->param.analyse.i_trellis = x264_clip3( h->param.analyse.i_trellis, 0, 2 );
  43. + if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_NONE )
  44. + h->param.rc.f_fade_compensate += 0.1;
  45. + if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_BLIND )
  46. + h->param.rc.f_fade_compensate = 0;
  47. + if( !h->param.rc.b_mb_tree )
  48. + h->param.rc.f_fade_compensate = 0;
  49. if( !h->param.analyse.b_psy )
  50. {
  51. h->param.analyse.f_psy_rd = 0;
  52. h->param.analyse.f_psy_trellis = 0;
  53. + h->param.rc.f_fade_compensate = 0;
  54. }
  55. if( !h->param.analyse.i_trellis )
  56. h->param.analyse.f_psy_trellis = 0;
  57. Index: encoder/slicetype.c
  58. ===================================================================
  59. --- encoder/slicetype_orig.c
  60. +++ encoder/slicetype.c
  61. @@ -205,7 +205,7 @@ void x264_weights_analyse( x264_t *h, x264_frame_t *fenc, x264_frame_t *ref, int
  62. else
  63. SET_WEIGHT( weights[0], 1, minscale, mindenom, minoff );
  64.  
  65. - if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_FAKE && weights[0].weightfn )
  66. + if( weights[0].weightfn )
  67. fenc->f_weighted_cost_delta[i_delta_index] = (float)minscore / origscore;
  68.  
  69. if( weights[0].weightfn && b_lookahead )
  70. @@ -630,7 +630,7 @@ static void x264_macroblock_tree_finish( x264_t *h, x264_frame_t *frame, int ref
  71. x264_emms();
  72. float weightdelta = 0.0;
  73. if( ref0_distance && frame->f_weighted_cost_delta[ref0_distance-1] > 0 )
  74. - weightdelta = (1.0 - frame->f_weighted_cost_delta[ref0_distance-1]);
  75. + weightdelta = (1.0 - frame->f_weighted_cost_delta[ref0_distance-1]) * 10.0f * h->param.rc.f_fade_compensate;
  76.  
  77. /* Allow the strength to be adjusted via qcompress, since the two
  78. * concepts are very similar. */
  79. Index: x264.c
  80. ===================================================================
  81. --- x264_orig.c
  82. +++ x264.c
  83. @@ -528,6 +528,8 @@ static void Help( x264_param_t *defaults, int longhelp )
  84. " - 2: Auto-variance AQ (experimental)\n", defaults->rc.i_aq_mode );
  85. H1( " --aq-strength <float> Reduces blocking and blurring in flat and\n"
  86. " textured areas. [%.1f]\n", defaults->rc.f_aq_strength );
  87. + H1( " --fade-compensate <float> Allocate more bits to fades [%.1f]\n", defaults->rc.f_fade_compensate );
  88. + H2( " Approximate sane range: 0.0 - 1.0\n" );
  89. H1( "\n" );
  90. H0( " -p, --pass <integer> Enable multipass ratecontrol\n"
  91. " - 1: First pass, creates stats file\n"
  92. @@ -811,6 +813,7 @@ static struct option long_options[] =
  93. { "no-dct-decimate", no_argument, NULL, 0 },
  94. { "aq-strength", required_argument, NULL, 0 },
  95. { "aq-mode", required_argument, NULL, 0 },
  96. + { "fade-compensate", required_argument, NULL, 0 },
  97. { "deadzone-inter", required_argument, NULL, '0' },
  98. { "deadzone-intra", required_argument, NULL, '0' },
  99. { "level", required_argument, NULL, 0 },
  100. Index: x264.h
  101. ===================================================================
  102. --- x264_orig.h
  103. +++ x264.h
  104. @@ -355,6 +355,7 @@ typedef struct x264_param_t
  105.  
  106. int i_aq_mode; /* psy adaptive QP. (X264_AQ_*) */
  107. float f_aq_strength;
  108. + float f_fade_compensate; /* Give more bits to fades. */
  109. int b_mb_tree; /* Macroblock-tree ratecontrol. */
  110. int i_lookahead;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement