Re: [PATCH v1] [media] v4l2-common: fix aligned value calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Sakari,

Thank you for your answer.
You're right: the modification that I proposed, is not correct (I misunderstood 
the aim of the function); the current clamp_align() is correct and doesn't need 
any modification.
Thus, the patch that I sent, must be ignored.
Sorry for the disruption.

Regards,
Jean-Christophe.


On 12/16/2016 02:56 PM, Sakari Ailus wrote:
> Hi Jean-Christophe,
>
> On Fri, Dec 16, 2016 at 02:32:15PM +0100, Jean-Christophe Trotin wrote:
>> Correct the calculation of the rounding to nearest aligned value in
>> the clamp_align() function. For example, clamp_align(1277, 1, 9600, 2)
>> returns 1276, while it should return 1280.
>
> Why should the function return 1280 instead of 1276, which is closer to
> 1277?
>
>>
>> Signed-off-by: Jean-Christophe Trotin <jean-christophe.trotin@xxxxxx>
>> ---
>>  drivers/media/v4l2-core/v4l2-common.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
>> index 57cfe26a..2970ce7 100644
>> --- a/drivers/media/v4l2-core/v4l2-common.c
>> +++ b/drivers/media/v4l2-core/v4l2-common.c
>> @@ -315,7 +315,7 @@ static unsigned int clamp_align(unsigned int x, unsigned int min,
>>
>>  	/* Round to nearest aligned value */
>>  	if (align)
>> -		x = (x + (1 << (align - 1))) & mask;
>> +		x = (x + ((1 << align) - 1)) & mask;
>>
>>  	return x;
>>  }
>--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux