* [PATCH v1] [media] v4l2-common: fix aligned value calculation
@ 2016-12-16 13:32 Jean-Christophe Trotin
2016-12-16 13:56 ` Sakari Ailus
0 siblings, 1 reply; 3+ messages in thread
From: Jean-Christophe Trotin @ 2016-12-16 13:32 UTC (permalink / raw)
To: linux-media, Hans Verkuil
Cc: kernel, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet,
Jean-Christophe Trotin
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.
Signed-off-by: Jean-Christophe Trotin <jean-christophe.trotin@st.com>
---
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;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] [media] v4l2-common: fix aligned value calculation
2016-12-16 13:32 [PATCH v1] [media] v4l2-common: fix aligned value calculation Jean-Christophe Trotin
@ 2016-12-16 13:56 ` Sakari Ailus
2017-01-03 9:12 ` Jean Christophe TROTIN
0 siblings, 1 reply; 3+ messages in thread
From: Sakari Ailus @ 2016-12-16 13:56 UTC (permalink / raw)
To: Jean-Christophe Trotin
Cc: linux-media, Hans Verkuil, kernel, Benjamin Gaignard,
Yannick Fertre, Hugues Fruchet
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@st.com>
> ---
> 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;
> }
--
Regards,
Sakari Ailus
e-mail: sakari.ailus@iki.fi XMPP: sailus@retiisi.org.uk
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] [media] v4l2-common: fix aligned value calculation
2016-12-16 13:56 ` Sakari Ailus
@ 2017-01-03 9:12 ` Jean Christophe TROTIN
0 siblings, 0 replies; 3+ messages in thread
From: Jean Christophe TROTIN @ 2017-01-03 9:12 UTC (permalink / raw)
To: Sakari Ailus
Cc: linux-media, Hans Verkuil, kernel, Benjamin Gaignard,
Yannick FERTRE, Hugues FRUCHET
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@st.com>
>> ---
>> 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;
>> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-03 9:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-16 13:32 [PATCH v1] [media] v4l2-common: fix aligned value calculation Jean-Christophe Trotin
2016-12-16 13:56 ` Sakari Ailus
2017-01-03 9:12 ` Jean Christophe TROTIN
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).