media: venus: helpers: Fix ALIGN() of non power of two
authorRikard Falkeborn <rikard.falkeborn@gmail.com>
Sat, 12 Sep 2020 19:03:01 +0000 (20:03 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 9 Jun 2023 12:42:28 +0000 (13:42 +0100)
commit927e78ac8bc58155316cf6f46026e1912bbbbcfc
treeca234299ef9342f35828c35a6cb137d749ec21cc
parent751be5c63f542b794328c9b1c8fd4a934c24fdeb
media: venus: helpers: Fix ALIGN() of non power of two

ALIGN() expects its second argument to be a power of 2, otherwise
incorrect results are produced for some inputs. The output can be
both larger or smaller than what is expected.

For example, ALIGN(304, 192) equals 320 instead of 384, and
ALIGN(65, 192) equals 256 instead of 192.

However, nestling two ALIGN() as is done in this case seem to only
produce results equal to or bigger than the expected result if ALIGN()
had handled non powers of two, and that in turn results in framesizes
that are either the correct size or too large.

Fortunately, since 192 * 4 / 3 equals 256, it turns out that one ALIGN()
is sufficient.

Fixes: ab1eda449c6e ("media: venus: vdec: handle 10bit bitstreams")
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/qcom/venus/helpers.c