@@ -73,9 +73,8 @@ static int RGBToGray(int64_t r, int64_t g, int64_t b) {
7373}
7474
7575static uint32_t ScaleDown (uint16_t a , uint16_t b , uint16_t c , uint16_t d ,
76- int rgb_bit_depth ,
76+ int bit_depth ,
7777 SharpYuvTransferFunctionType transfer_type ) {
78- const int bit_depth = rgb_bit_depth + GetPrecisionShift (rgb_bit_depth );
7978 const uint32_t A = SharpYuvGammaToLinear (a , bit_depth , transfer_type );
8079 const uint32_t B = SharpYuvGammaToLinear (b , bit_depth , transfer_type );
8180 const uint32_t C = SharpYuvGammaToLinear (c , bit_depth , transfer_type );
@@ -85,9 +84,8 @@ static uint32_t ScaleDown(uint16_t a, uint16_t b, uint16_t c, uint16_t d,
8584}
8685
8786static WEBP_INLINE void UpdateW (const fixed_y_t * src , fixed_y_t * dst , int w ,
88- int rgb_bit_depth ,
87+ int bit_depth ,
8988 SharpYuvTransferFunctionType transfer_type ) {
90- const int bit_depth = rgb_bit_depth + GetPrecisionShift (rgb_bit_depth );
9189 int i = 0 ;
9290 do {
9391 const uint32_t R =
@@ -102,19 +100,19 @@ static WEBP_INLINE void UpdateW(const fixed_y_t* src, fixed_y_t* dst, int w,
102100}
103101
104102static void UpdateChroma (const fixed_y_t * src1 , const fixed_y_t * src2 ,
105- fixed_t * dst , int uv_w , int rgb_bit_depth ,
103+ fixed_t * dst , int uv_w , int bit_depth ,
106104 SharpYuvTransferFunctionType transfer_type ) {
107105 int i = 0 ;
108106 do {
109107 const int r =
110108 ScaleDown (src1 [0 * uv_w + 0 ], src1 [0 * uv_w + 1 ], src2 [0 * uv_w + 0 ],
111- src2 [0 * uv_w + 1 ], rgb_bit_depth , transfer_type );
109+ src2 [0 * uv_w + 1 ], bit_depth , transfer_type );
112110 const int g =
113111 ScaleDown (src1 [2 * uv_w + 0 ], src1 [2 * uv_w + 1 ], src2 [2 * uv_w + 0 ],
114- src2 [2 * uv_w + 1 ], rgb_bit_depth , transfer_type );
112+ src2 [2 * uv_w + 1 ], bit_depth , transfer_type );
115113 const int b =
116114 ScaleDown (src1 [4 * uv_w + 0 ], src1 [4 * uv_w + 1 ], src2 [4 * uv_w + 0 ],
117- src2 [4 * uv_w + 1 ], rgb_bit_depth , transfer_type );
115+ src2 [4 * uv_w + 1 ], bit_depth , transfer_type );
118116 const int W = RGBToGray (r , g , b );
119117 dst [0 * uv_w ] = (fixed_t )(r - W );
120118 dst [1 * uv_w ] = (fixed_t )(g - W );
@@ -178,11 +176,10 @@ static void ImportOneRow(const uint8_t* const r_ptr, const uint8_t* const g_ptr,
178176static void InterpolateTwoRows (const fixed_y_t * const best_y ,
179177 const fixed_t * prev_uv , const fixed_t * cur_uv ,
180178 const fixed_t * next_uv , int w , fixed_y_t * out1 ,
181- fixed_y_t * out2 , int rgb_bit_depth ) {
179+ fixed_y_t * out2 , int bit_depth ) {
182180 const int uv_w = w >> 1 ;
183181 const int len = (w - 1 ) >> 1 ; // length to filter
184182 int k = 3 ;
185- const int bit_depth = rgb_bit_depth + GetPrecisionShift (rgb_bit_depth );
186183 while (k -- > 0 ) { // process each R/G/B segments in turn
187184 // special boundary case for i==0
188185 out1 [0 ] = Filter2 (cur_uv [0 ], prev_uv [0 ], best_y [0 ], bit_depth );
@@ -360,9 +357,9 @@ static int DoSharpArgbToYuv(const uint8_t* r_ptr, const uint8_t* g_ptr,
360357 StoreGray (src1 , best_y + 0 , w );
361358 StoreGray (src2 , best_y + w , w );
362359
363- UpdateW (src1 , target_y , w , rgb_bit_depth , transfer_type );
364- UpdateW (src2 , target_y + w , w , rgb_bit_depth , transfer_type );
365- UpdateChroma (src1 , src2 , target_uv , uv_w , rgb_bit_depth , transfer_type );
360+ UpdateW (src1 , target_y , w , y_bit_depth , transfer_type );
361+ UpdateW (src2 , target_y + w , w , y_bit_depth , transfer_type );
362+ UpdateChroma (src1 , src2 , target_uv , uv_w , y_bit_depth , transfer_type );
366363 memcpy (best_uv , target_uv , 3 * uv_w * sizeof (* best_uv ));
367364 best_y += 2 * w ;
368365 best_uv += 3 * uv_w ;
@@ -390,14 +387,14 @@ static int DoSharpArgbToYuv(const uint8_t* r_ptr, const uint8_t* g_ptr,
390387 {
391388 const fixed_t * const next_uv = cur_uv + ((j < h - 2 ) ? 3 * uv_w : 0 );
392389 InterpolateTwoRows (best_y , prev_uv , cur_uv , next_uv , w , src1 , src2 ,
393- rgb_bit_depth );
390+ y_bit_depth );
394391 prev_uv = cur_uv ;
395392 cur_uv = next_uv ;
396393 }
397394
398- UpdateW (src1 , best_rgb_y + 0 * w , w , rgb_bit_depth , transfer_type );
399- UpdateW (src2 , best_rgb_y + 1 * w , w , rgb_bit_depth , transfer_type );
400- UpdateChroma (src1 , src2 , best_rgb_uv , uv_w , rgb_bit_depth , transfer_type );
395+ UpdateW (src1 , best_rgb_y + 0 * w , w , y_bit_depth , transfer_type );
396+ UpdateW (src2 , best_rgb_y + 1 * w , w , y_bit_depth , transfer_type );
397+ UpdateChroma (src1 , src2 , best_rgb_uv , uv_w , y_bit_depth , transfer_type );
401398
402399 // update two rows of Y and one row of RGB
403400 diff_y_sum +=
0 commit comments