<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Nov 12, 2013 at 5:49 AM, <span dir="ltr"><<a href="mailto:shazeb@multicorewareinc.com" target="_blank">shazeb@multicorewareinc.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Shazeb Nawaz Khan <<a href="mailto:shazeb@multicorewareinc.com">shazeb@multicorewareinc.com</a>><br>
# Date 1384256247 -19800<br>
# Tue Nov 12 17:07:27 2013 +0530<br>
# Node ID 21596a519ba8cc521dbc81f693c867cbca03fd3f<br>
# Parent e7319fd46128b3bfcc826ea9be02896b316ed966<br>
Pulling x264 weight decision into/for x265 lookahead<br>
<br>
diff -r e7319fd46128 -r 21596a519ba8 source/encoder/slicetype.cpp<br>
--- a/source/encoder/slicetype.cpp Tue Nov 12 17:06:03 2013 +0530<br>
+++ b/source/encoder/slicetype.cpp Tue Nov 12 17:07:27 2013 +0530<br>
@@ -45,6 +45,14 @@<br>
<br>
using namespace x265;<br>
<br>
+#define SET_WEIGHT( w, b, s, d, o )\<br>
+{\<br>
+ (w).inputWeight = (s);\<br>
+ (w).log2WeightDenom = (d);\<br>
+ (w).inputOffset = (o);\<br>
+ (w).bPresentFlag = b;\<br>
+}<br>
+<br>
static inline int16_t median(int16_t a, int16_t b, int16_t c)<br>
{<br>
int16_t t = (a - b) & ((a - b) >> 31);<br>
@@ -190,16 +198,329 @@<br>
return pic->m_lowres.satdCost;<br>
}<br>
<br>
+/* makes a non-h265 weight (i.e. fix7), into an h265 weight */<br>
+static void x265_weight_get_h265( int weight_nonh264, int offset, wpScalingParam *w )<br></blockquote><div><br></div><div>this should be made into a wpScalingParam method.. something like setFromWeightAndOffset()</div><div>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+{<br>
+ w->inputOffset = offset;<br>
+ w->log2WeightDenom = 7;<br>
+ w->inputWeight = weight_nonh264;<br>
+ while( w->log2WeightDenom > 0 && (w->inputWeight > 127) )<br>
+ {<br>
+ w->log2WeightDenom--;<br>
+ w->inputWeight >>= 1;<br>
+ }<br>
+ w->inputWeight = X265_MIN( w->inputWeight, 127 );<br>
+}<br>
+<br>
+pixel* Lookahead::x265_weight_cost_init_luma( int b, int p0, pixel *dest )<br></blockquote><div><br></div><div>weightCostInit()</div><div><br></div><div>white-space</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+{<br>
+ Lowres *fenc, *ref;<br>
+ fenc = frames[b];<br>
+ ref = frames[p0];<br>
+ int ref0_distance = b - p0 - 1;<br>
+ /* Note: this will never run during lookahead as weights_analyse is only called if no<br>
+ * motion search has been done. */<br>
+ if( fenc->lowresMvs[0][ref0_distance][0].x != 0x7FFF )<br>
+ {<br>
+ int i_stride = fenc->lumaStride;<br>
+ int i_lines = fenc->lines;<br>
+ int i_width = fenc->width;<br>
+ int i_mb_xy = 0;<br>
+ pixel *p = dest;<br>
+<br>
+ for( int y = 0; y < i_lines; y += 8, p += i_stride*8 )<br>
+ for( int x = 0; x < i_width; x += 8, i_mb_xy++ )<br>
+ {<br>
+ int mvx = fenc->lowresMvs[0][ref0_distance][i_mb_xy].x;<br>
+ int mvy = fenc->lowresMvs[0][ref0_distance][i_mb_xy].y;<br>
+ mvx;mvy;<br>
+ //h->mc.mc_luma( p+x, i_stride, ref->lowresPlane, i_stride,<br>
+ // mvx+(x<<2), mvy+(y<<2), 8, 8, x264_weight_none );<br>
+ }<br>
+ x265_emms();<br>
+ return dest;<br>
+ }<br>
+ x265_emms();<br>
+ return ref->lowresPlane[0];<br>
+}<br></blockquote><div><br></div><div>this whole function is not used for lookahead and should be removed, not to mention it is unfinished</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+static void mc_weight( pixel *dst, intptr_t i_dst_stride, pixel *src, intptr_t i_src_stride,<br>
+ const wpScalingParam *weight, int i_width, int i_height )<br></blockquote><div><br></div><div>white-space, do not copy i_ prefixes from x264</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+{<br>
+ int offset = weight->inputOffset << (g_bitDepth - 8);<br></blockquote><div><br></div><div>use X265_DEPTH, not g_bitDepth</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ int scale = weight->inputWeight;<br>
+ int denom = weight->log2WeightDenom;<br>
+ int corection = (IF_INTERNAL_PREC - X265_DEPTH);<br></blockquote><div><br></div><div>correction</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ if( denom >= 1 )<br></blockquote><div><br></div><div>white-space.. please run uncrustify on the file before re-submitting</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ {<br>
+ primitives.weightpUniPixel(src, dst, i_src_stride, i_dst_stride, i_width, i_height, scale, (1<<(denom - 1 + corection)), (denom + corection), offset);<br>
+ }<br>
+ else<br>
+ {<br>
+ primitives.weightpUniPixel(src, dst, i_src_stride, i_dst_stride, i_width, i_height, scale, 0 + corection, 0 + corection, offset);<br>
+ }<br>
+}<br>
+<br>
+unsigned int Lookahead::x265_weight_cost_luma( int b, pixel *src, wpScalingParam *w )<br></blockquote><div><br></div><div>weightCostLuma()</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+{<br>
+ Lowres *fenc = frames[b];<br>
+ unsigned int cost = 0;<br>
+ int i_stride = fenc->lumaStride;<br>
+ int i_lines = fenc->lines;<br>
+ int i_width = fenc->width;<br></blockquote><div><br></div><div>no i_ prefixes</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ pixel *fenc_plane = fenc->lowresPlane[0];<br>
+ ALIGN_VAR_16( pixel, buf[8*8]);<br>
+ int pixoff = 0;<br>
+ int i_mb = 0;<br>
+<br>
+ if( w )<br>
+ {<br>
+ for( int y = 0; y < i_lines; y += 8, pixoff = y*i_stride )<br>
+ for( int x = 0; x < i_width; x += 8, i_mb++, pixoff += 8)<br>
+ {<br>
+ // TO DO prepare full weighted plane<br>
+ mc_weight(buf, 8, &src[pixoff], i_stride, w, 8, 8);<br>
+ int cmp = primitives.satd[LUMA_8x8]( buf, 8, &fenc_plane[pixoff], i_stride );<br>
+ cost += X265_MIN( cmp, fenc->intraCost[i_mb] );<br>
+ }<br>
+ }<br>
+ else<br>
+ for( int y = 0; y < i_lines; y += 8, pixoff = y*i_stride )<br>
+ for( int x = 0; x < i_width; x += 8, i_mb++, pixoff += 8 )<br>
+ {<br>
+ int cmp = primitives.satd[LUMA_8x8]( &src[pixoff], i_stride, &fenc_plane[pixoff], i_stride );<br>
+ cost += X265_MIN( cmp, fenc->intraCost[i_mb] );<br>
+ }<br>
+ x265_emms();<br>
+ return cost;<br>
+}<br></blockquote><div><br></div><div>this function is also not used, and should be removed</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+void Lookahead::weightsAnalyse(int b, int p0, int b_lookahead, wpScalingParam* w)<br>
+{<br></blockquote><div><br></div><div>remove b_lookahead, assume it is always 1, simplify the code below.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ //int i_delta_index = b - p0 - 1;<br></blockquote><div><br></div><div>remove</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ Lowres *fenc, *ref;<br>
+ fenc = frames[b];<br>
+ ref = frames[p0];<br>
+ /* epsilon is chosen to require at least a numerator of 127 (with denominator = 128) */<br>
+ const float epsilon = 1.f/128.f;<br>
+ wpScalingParam *weights = w;<br></blockquote><div><br></div><div>yuck, just rename function argument</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ SET_WEIGHT( weights[0], 0, 1, 0, 0 );<br></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ //SET_WEIGHT( weights[1], 0, 1, 0, 0 );<br>
+ //SET_WEIGHT( weights[2], 0, 1, 0, 0 );<br></blockquote><div><br></div><div>remove these two</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ float guess_scale[3];<br>
+ float fenc_mean[3];<br>
+ float ref_mean[3];<br>
+ for( int plane = 0; plane <= 2*!b_lookahead; plane++ )<br>
+ {<br>
+ float fenc_var = (float) fenc->wp_ssd[plane] + !ref->wp_ssd[plane];<br>
+ float ref_var = (float) ref->wp_ssd[plane] + !ref->wp_ssd[plane];<br>
+ guess_scale[plane] = sqrtf( fenc_var / ref_var );<br>
+ fenc_mean[plane] = (float)fenc->wp_sum[plane] / ((fenc->lines>>(plane?1:0)) * (fenc->width>>(plane?1:0))) /*/ (1 << (BIT_DEPTH - 8))*/;<br>
+ ref_mean[plane] = (float) ref->wp_sum[plane] / ((fenc->lines>>(plane?1:0)) * (fenc->width>>(plane?1:0))) /*/ (1 << (BIT_DEPTH - 8))*/;<br>
+ }<br>
+<br>
+ //int chroma_denom = 7;<br>
+ //if( !b_lookahead )<br>
+ //{<br>
+ // /* make sure both our scale factors fit */<br>
+ // while( chroma_denom > 0 )<br>
+ // {<br>
+ // float thresh = 127.f / (1<<chroma_denom);<br>
+ // if( guess_scale[1] < thresh && guess_scale[2] < thresh )<br>
+ // break;<br>
+ // chroma_denom--;<br>
+ // }<br>
+ //}<br></blockquote><div><br></div><div>bye</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ /* Don't check chroma in lookahead, or if there wasn't a luma weight. */<br>
+ for( int plane = 0; plane <= 2 && !( plane && ( /*!weights[0].weightfn*/ !fenc->isWeighted || b_lookahead ) ); plane++ )<br>
+ {<br>
+ int minoff, minscale, mindenom;<br>
+ unsigned int minscore = 0, origscore = 1;<br>
+ origscore;<br>
+ int found;<br>
+<br>
+ //early termination<br>
+ if( fabsf( ref_mean[plane] - fenc_mean[plane] ) < 0.5f && fabsf( 1.f - guess_scale[plane] ) < epsilon )<br>
+ {<br>
+ SET_WEIGHT( weights[plane], 0, 1, 0, 0 );<br>
+ //printf("\nEarly\n");<br>
+ continue;<br>
+ }<br>
+<br>
+ if( plane )<br>
+ {<br>
+ //weights[plane].i_denom = chroma_denom;<br>
+ //weights[plane].i_scale = x264_clip3( round( guess_scale[plane] * (1<<chroma_denom) ), 0, 255 );<br>
+ //if( weights[plane].i_scale > 127 )<br>
+ //{<br>
+ // weights[1].weightfn = weights[2].weightfn = NULL;<br>
+ // break;<br>
+ //}<br>
+ }<br>
+ else<br>
+ x265_weight_get_h265( (int)( guess_scale[plane] * 128 + 0.5), 0, &weights[plane] );<br>
+<br>
+ found = 0;<br>
+ mindenom = weights[plane].log2WeightDenom;<br>
+ minscale = weights[plane].inputWeight;<br>
+ minoff = 0;<br>
+<br>
+ pixel *mcbuf = NULL;<br>
+ mcbuf;<br>
+ if( !plane )<br>
+ {<br>
+ if( !fenc->bIntraCalculated )<br>
+ {<br>
+ estimateFrameCost(b,b,b,0);<br>
+ }<br>
+ mcbuf = x265_weight_cost_init_luma( b, p0, NULL );<br>
+ origscore = minscore = x265_weight_cost_luma( b, mcbuf, NULL );<br>
+ }<br>
+ else<br>
+ {<br>
+ //if( CHROMA444 )<br>
+ //{<br>
+ // mcbuf = x264_weight_cost_init_chroma444( h, fenc, ref, h->mb.p_weight_buf[0], plane );<br>
+ // origscore = minscore = x264_weight_cost_chroma444( h, fenc, mcbuf, NULL, plane );<br>
+ //}<br>
+ //else<br>
+ //{<br>
+ //pixel *dstu = h->mb.p_weight_buf[0];<br>
+ //pixel *dstv = h->mb.p_weight_buf[0]+fenc->i_stride[1]*fenc->i_lines[1];<br>
+ //if( !chroma_initted++ )<br>
+ // x264_weight_cost_init_chroma( h, fenc, ref, dstu, dstv );<br>
+ //mcbuf = plane == 1 ? dstu : dstv;<br>
+ //origscore = minscore = x264_weight_cost_chroma( h, fenc, mcbuf, NULL );<br>
+ //}<br></blockquote><div>remove </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ }<br>
+<br>
+ if( !minscore )<br>
+ continue;<br>
+<br>
+ /* Picked somewhat arbitrarily */<br>
+ static const uint8_t weight_check_distance[][2] =<br>
+ {<br>
+ {0,0},{0,0},{0,1},{0,1},<br>
+ {0,1},{0,1},{0,1},{1,1},<br>
+ {1,1},{2,1},{2,1},{4,2}<br>
+ };<br>
+ int scale_dist = b_lookahead ? 0 : weight_check_distance[cfg->param.subpelRefine][0];<br>
+ int offset_dist = b_lookahead ? 0 : weight_check_distance[cfg->param.subpelRefine][1];<br></blockquote><div><br></div><div>this all goes away</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ int start_scale = Clip3( 0, 127, minscale - scale_dist );<br>
+ int end_scale = Clip3( 0, 127, minscale + scale_dist );<br>
+ unsigned int s=0;<br>
+ for( int i_scale = start_scale; i_scale <= end_scale; i_scale++ )<br>
+ {<br>
+ int cur_scale = i_scale;<br>
+ int cur_offset = (int) (fenc_mean[plane] - ref_mean[plane] * cur_scale / (1 << mindenom) + 0.5f * b_lookahead);<br>
+ if( cur_offset < - 128 || cur_offset > 127 )<br>
+ {<br>
+ /* Rescale considering the constraints on cur_offset. We do it in this order<br>
+ * because scale has a much wider range than offset (because of denom), so<br>
+ * it should almost never need to be clamped. */<br>
+ cur_offset = Clip3( -128, 127, cur_offset );<br>
+ cur_scale = (int) ((1 << mindenom) * (fenc_mean[plane] - cur_offset) / ref_mean[plane] + 0.5f);<br>
+ cur_scale = Clip3( 0, 127, cur_scale );<br>
+ }<br>
+ int start_offset = Clip3( -128, 127, cur_offset - offset_dist );<br>
+ int end_offset = Clip3( -128, 127, cur_offset + offset_dist );<br>
+ for( int i_off = start_offset; i_off <= end_offset; i_off++ )<br>
+ {<br>
+ SET_WEIGHT( weights[plane], 1, cur_scale, mindenom, i_off );<br>
+ //unsigned int s;<br>
+ //if( plane )<br>
+ //{<br>
+ // //if( CHROMA444 )<br>
+ // // s = x264_weight_cost_chroma444( h, fenc, mcbuf, &weights[plane], plane );<br>
+ // //else<br>
+ // s = x264_weight_cost_chroma( h, fenc, mcbuf, &weights[plane] );<br>
+ //}<br>
+ //else<br>
+ {<br>
+ s = x265_weight_cost_luma( b, mcbuf, &weights[plane] );<br>
+ }<br>
+ COPY4_IF_LT( minscore, s, minscale, cur_scale, minoff, i_off, found, 1 );<br>
+<br>
+ // Don't check any more offsets if the previous one had a lower cost than the current one<br>
+ if( minoff == start_offset && i_off != start_offset )<br>
+ break;<br>
+ }<br>
+ }<br>
+ x265_emms();<br>
+<br>
+ /* Use a smaller denominator if possible */<br>
+ if( !plane )<br>
+ {<br>
+ while( mindenom > 0 && !(minscale&1) )<br>
+ {<br>
+ mindenom--;<br>
+ minscale >>= 1;<br>
+ }<br>
+ }<br>
+<br>
+ /* FIXME: More analysis can be done here on SAD vs. SATD termination. */<br>
+ /* 0.2% termination derived experimentally to avoid weird weights in frames that are mostly intra. */<br>
+ if( !found || (minscale == 1 << mindenom && minoff == 0) || (float)minscore / origscore > 0.998f )<br>
+ {<br>
+ SET_WEIGHT( weights[plane], 0, 1, 0, 0 );<br>
+ continue;<br>
+ }<br>
+ else<br>
+ {<br>
+ SET_WEIGHT( weights[plane], 1, minscale, mindenom, minoff );<br>
+ }<br>
+<br>
+ //if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_FAKE && weights[0].weightfn && !plane )<br>
+ // fenc->f_weighted_cost_delta[i_delta_index] = (float)minscore / origscore;<br>
+ }<br>
+<br>
+ ///* Optimize and unify denominator */<br>
+ //if( weights[1].weightfn || weights[2].weightfn )<br>
+ //{<br>
+ // int denom = weights[1].weightfn ? weights[1].i_denom : weights[2].i_denom;<br>
+ // int both_weighted = weights[1].weightfn && weights[2].weightfn;<br>
+ // /* If only one plane is weighted, the other has an implicit scale of 1<<denom.<br>
+ // * With denom==7, this comes out to 128, which is invalid, so don't allow that. */<br>
+ // while( (!both_weighted && denom==7) ||<br>
+ // (denom > 0 && !(weights[1].weightfn && (weights[1].i_scale&1))<br>
+ // && !(weights[2].weightfn && (weights[2].i_scale&1))) )<br>
+ // {<br>
+ // denom--;<br>
+ // for( int i = 1; i <= 2; i++ )<br>
+ // if( weights[i].weightfn )<br>
+ // {<br>
+ // weights[i].i_scale >>= 1;<br>
+ // weights[i].i_denom = denom;<br>
+ // }<br>
+ // }<br>
+ //}<br>
+ //for( int i = 1; i <= 2; i++ )<br>
+ // if( weights[i].weightfn )<br>
+ // h->mc.weight_cache( h, &weights[i] );<br>
+<br>
+ //if( weights[0].weightfn && b_lookahead )<br>
+ //{<br>
+ // //scale lowres in lookahead for slicetype_frame_cost<br>
+ // pixel *src = ref->buffer_lowres[0];<br>
+ // pixel *dst = h->mb.p_weight_buf[0];<br>
+ // int width = ref->i_width_lowres + PADH*2;<br>
+ // int height = ref->i_lines_lowres + PADV*2;<br>
+ // x264_weight_scale_plane( h, dst, ref->i_stride_lowres, src, ref->i_stride_lowres,<br>
+ // width, height, &weights[0] );<br>
+ // fenc->weighted[0] = h->mb.p_weight_buf[0] + PADH + ref->i_stride_lowres * PADV;<br>
+ //}<br></blockquote><div><br></div><div>remove; we should never have commented code blocks</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+}<br>
+<br>
#define NUM_CUS (widthInCU > 2 && heightInCU > 2 ? (widthInCU - 2) * (heightInCU - 2) : widthInCU * heightInCU)<br>
<br>
int Lookahead::estimateFrameCost(int p0, int p1, int b, bool bIntraPenalty)<br>
{<br>
int score = 0;<br>
Lowres *fenc = frames[b];<br>
-<br>
- curb = b;<br>
- curp0 = p0;<br>
- curp1 = p1;<br>
+ wpScalingParam wp;<br>
+ wp.bPresentFlag = false;<br>
<br>
if (fenc->costEst[b - p0][p1 - b] >= 0 && fenc->rowSatds[b - p0][p1 - b][0] != -1)<br>
score = fenc->costEst[b - p0][p1 - b];<br>
@@ -209,9 +530,23 @@<br>
bDoSearch[0] = b != p0 && fenc->lowresMvs[0][b - p0 - 1][0].x == 0x7FFF;<br>
bDoSearch[1] = b != p1 && fenc->lowresMvs[1][p1 - b - 1][0].x == 0x7FFF;<br>
<br>
- if (bDoSearch[0]) fenc->lowresMvs[0][b - p0 - 1][0].x = 0;<br>
+ if (bDoSearch[0])<br>
+ {<br>
+ if( cfg->param.bEnableWeightedPred && b==p1)<br></blockquote><div><br></div><div>white-space, I'll quit commenting on this</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ {<br>
+ wp.bPresentFlag = false;<br>
+ wp.inputWeight = 0;<br></blockquote><div><br></div><div>this re-initialization is unnecessary</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ weightsAnalyse(b, p0, 1, &wp);<br>
+ }<br>
+ bDoSearch[0] = b != p0 && fenc->lowresMvs[0][b - p0 - 1][0].x == 0x7FFF;<br>
+ bDoSearch[1] = b != p1 && fenc->lowresMvs[1][p1 - b - 1][0].x == 0x7FFF;<br></blockquote><div><br></div><div>these two lines are out-of-place, probably need to be deleted</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ fenc->lowresMvs[0][b - p0 - 1][0].x = 0;<br>
+ }<br>
if (bDoSearch[1]) fenc->lowresMvs[1][p1 - b - 1][0].x = 0;<br>
<br>
+ curb = b;<br>
+ curp0 = p0;<br>
+ curp1 = p1;<br></blockquote><div><br></div><div>these look unused</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
fenc->costEst[b - p0][p1 - b] = 0;<br>
fenc->costEstAq[b - p0][p1 - b] = 0;<br>
// TODO: use lowres MVs as motion candidates in full-res search<br>
@@ -572,6 +907,15 @@<br>
brefs++;<br>
} */<br>
<br>
+ ///* Analyse for weighted P frames */<br>
+ //if (/*!h->param.rc.b_stat_read &&*/ frames[bframes]->sliceType == X265_TYPE_P && cfg->param.bEnableWeightedPred<br>
+ // /*&& h->param.analyse.i_weighted_pred >= X264_WEIGHTP_SIMPLE*/)<br>
+ //{<br>
+ // x265_emms();<br>
+ // //x264_weights_analyse(h, h->lookahead->next.list[bframes], h->lookahead->last_nonb, 0);<br>
+ // weightsAnalyse(bframes, 0, 1);<br>
+ //}<br>
+<br></blockquote><div><br></div><div>this will not be called from here, please remove</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
/* calculate the frame costs ahead of time for x264_rc_analyse_slice while we still have lowres */<br>
if (cfg->param.rc.rateControlMode != X265_RC_CQP)<br>
{<br>
@@ -613,14 +957,6 @@<br>
} */<br>
}<br>
<br>
- /* Analyse for weighted P frames<br>
- if (!h->param.rc.b_stat_read && h->lookahead->next.list[bframes]->i_type == X264_TYPE_P<br>
- && h->param.analyse.i_weighted_pred >= X264_WEIGHTP_SIMPLE)<br>
- {<br>
- x265_emms();<br>
- x264_weights_analyse(h, h->lookahead->next.list[bframes], h->lookahead->last_nonb, 0);<br>
- }*/<br>
-<br>
/* dequeue all frames from inputQueue that are about to be enqueued<br>
* in the output queue. The order is important because TComPic can<br>
* only be in one list at a time */<br>
diff -r e7319fd46128 -r 21596a519ba8 source/encoder/slicetype.h<br>
--- a/source/encoder/slicetype.h Tue Nov 12 17:06:03 2013 +0530<br>
+++ b/source/encoder/slicetype.h Tue Nov 12 17:07:27 2013 +0530<br>
@@ -47,11 +47,13 @@<br>
int costIntra; // Estimated Intra cost for all CUs in a row<br>
int costIntraAq; // Estimated weighted Aq Intra cost for all CUs in a row<br>
int intraMbs; // Number of Intra CUs<br>
+ TEncCfg *cfg;<br>
<br>
Lowres** frames;<br>
int widthInCU;<br>
int heightInCU;<br>
int merange;<br>
+ Lowres *weightedRef;<br>
<br>
LookaheadRow()<br>
{<br>
@@ -82,6 +84,9 @@<br>
int widthInCU; // width of lowres frame in downscale CUs<br>
int heightInCU; // height of lowres frame in downscale CUs<br>
<br>
+ Lowres *weightedRef;<br>
+ int numWRefs;<br>
+<br>
PicList inputQueue; // input pictures in order received<br>
PicList outputQueue; // pictures to be encoded, in encode order<br>
<br>
@@ -110,6 +115,11 @@<br>
int slicetypePathCost(char *path, int threshold);<br>
<br>
void processRow(int row);<br>
+<br>
+ void weightsAnalyse(int b, int p0, int b_lookahead, wpScalingParam *w);<br>
+ unsigned int x265_weight_cost_luma( int b, pixel *src, wpScalingParam *w );<br>
+ pixel* x265_weight_cost_init_luma( int b, int p0, pixel *dest );<br>
+ int x265_weight_slice_header_cost(wpScalingParam *w, int b_chroma );<br>
};<br>
}<br>
<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Steve Borho
</div></div>