Correct computation of bytes per pixel from bits per pixel
PATCH 1/1 Correct computation of bytes per pixel from bits per pixel
Signed-off-by BALATON Zoltan <[email protected]>
--- console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
console.c +2 -2
@@ -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) {
Signature · 1 line
1.7.10
Can you use this free space to provide a scenario where the missing round-up caused a problem?
Quoted 11 lines · BALATON Zoltan
Signed-off-by BALATON Zoltan <[email protected]>--- console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)console.c +0
-0
console.c PixelFormat · line 1616
Quoted 6 lines
console.c +1
-1@@ -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.
console.c PixelFormat qemu_default_pixelformat(int bpp) · line 1667
Quoted 12 lines
console.c +0
-0pf.depth = bpp ==32 ?24 : bpp;switch (bpp) {console.c +1
-1@@ -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
On 21 August 2012 22:32, BALATON Zoltan <[email protected]> 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.
Quoted 10 lines
Signed-off-by BALATON Zoltan <[email protected]>--- console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)console.c +0
-0
console.c PixelFormat qemu_different_endianness_pixelformat(int · line 1616
Quoted 6 lines
console.c +1
-1@@ -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