* [Qemu-devel] [PATCH] Correct computation of bytes per pixel from bits per pixel
@ 2012-08-21 21:32 BALATON Zoltan
2012-08-22 8:02 ` Jan Kiszka
2012-08-22 8:30 ` Peter Maydell
0 siblings, 2 replies; 3+ messages in thread
From: BALATON Zoltan @ 2012-08-21 21:32 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
console.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/console.c b/console.c
index 4525cc7..f698b77 100644
--- a/console.c
+++ b/console.c
@@ -1612,7 +1612,7 @@ PixelFormat qemu_different_endianness_pixelformat(int bpp)
memset(&pf, 0x00, sizeof(PixelFormat));
pf.bits_per_pixel = bpp;
- pf.bytes_per_pixel = bpp / 8;
+ pf.bytes_per_pixel = (bpp + 7) >> 3;
pf.depth = bpp == 32 ? 24 : bpp;
switch (bpp) {
@@ -1661,7 +1661,7 @@ PixelFormat qemu_default_pixelformat(int bpp)
memset(&pf, 0x00, sizeof(PixelFormat));
pf.bits_per_pixel = bpp;
- pf.bytes_per_pixel = bpp / 8;
+ pf.bytes_per_pixel = (bpp + 7) >> 3;
pf.depth = bpp == 32 ? 24 : bpp;
switch (bpp) {
--
1.7.10
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] Correct computation of bytes per pixel from bits per pixel
2012-08-21 21:32 [Qemu-devel] [PATCH] Correct computation of bytes per pixel from bits per pixel BALATON Zoltan
@ 2012-08-22 8:02 ` Jan Kiszka
2012-08-22 8:30 ` Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kiszka @ 2012-08-22 8:02 UTC (permalink / raw)
To: BALATON Zoltan; +Cc: qemu-trivial, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1194 bytes --]
Can you use this free space to provide a scenario where the missing
round-up caused a problem?
On 2012-08-21 23:32, BALATON Zoltan wrote:
>
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
> console.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/console.c b/console.c
> index 4525cc7..f698b77 100644
> --- a/console.c
> +++ b/console.c
> @@ -1612,7 +1612,7 @@ PixelFormat
> qemu_different_endianness_pixelformat(int bpp)
> memset(&pf, 0x00, sizeof(PixelFormat));
>
> pf.bits_per_pixel = bpp;
> - pf.bytes_per_pixel = bpp / 8;
> + pf.bytes_per_pixel = (bpp + 7) >> 3;
Compilers are smart enough to substitute such divisions by shift
operations but for humans the explicit form is easier to read. So please
keep it.
> pf.depth = bpp == 32 ? 24 : bpp;
>
> switch (bpp) {
> @@ -1661,7 +1661,7 @@ PixelFormat qemu_default_pixelformat(int bpp)
> memset(&pf, 0x00, sizeof(PixelFormat));
>
> pf.bits_per_pixel = bpp;
> - pf.bytes_per_pixel = bpp / 8;
> + pf.bytes_per_pixel = (bpp + 7) >> 3;
> pf.depth = bpp == 32 ? 24 : bpp;
>
> switch (bpp) {
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] Correct computation of bytes per pixel from bits per pixel
2012-08-21 21:32 [Qemu-devel] [PATCH] Correct computation of bytes per pixel from bits per pixel BALATON Zoltan
2012-08-22 8:02 ` Jan Kiszka
@ 2012-08-22 8:30 ` Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2012-08-22 8:30 UTC (permalink / raw)
To: BALATON Zoltan; +Cc: qemu-trivial, qemu-devel
On 21 August 2012 22:32, BALATON Zoltan <balaton@eik.bme.hu> wrote:
If you make the Subject "console: Correct computation of bytes per pixel
from bits per pixel" it's easier to tell what bit of qemu the patch
is dealing with.
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
> console.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/console.c b/console.c
> index 4525cc7..f698b77 100644
> --- a/console.c
> +++ b/console.c
> @@ -1612,7 +1612,7 @@ PixelFormat qemu_different_endianness_pixelformat(int
> bpp)
> memset(&pf, 0x00, sizeof(PixelFormat));
>
> pf.bits_per_pixel = bpp;
> - pf.bytes_per_pixel = bpp / 8;
> + pf.bytes_per_pixel = (bpp + 7) >> 3;
You could write this as
pf.bytes_per_pixel = DIV_ROUND_UP(bpp, 8);
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-08-22 8:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-21 21:32 [Qemu-devel] [PATCH] Correct computation of bytes per pixel from bits per pixel BALATON Zoltan
2012-08-22 8:02 ` Jan Kiszka
2012-08-22 8:30 ` Peter Maydell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.