comparison libvo/vo_fbdev.c @ 29354:80ff0cd8f427

Use FFALIGN and FFMAX3
author reimar
date Fri, 26 Jun 2009 15:14:48 +0000
parents 22db6af09a1d
children 288044ae1f9a
comparison
equal deleted inserted replaced
29353:22db6af09a1d 29354:80ff0cd8f427
44 #ifdef CONFIG_VIDIX 44 #ifdef CONFIG_VIDIX
45 #include "vosub_vidix.h" 45 #include "vosub_vidix.h"
46 #endif 46 #endif
47 #include "aspect.h" 47 #include "aspect.h"
48 #include "mp_msg.h" 48 #include "mp_msg.h"
49 #include "libavutil/common.h"
49 50
50 static const vo_info_t info = { 51 static const vo_info_t info = {
51 "Framebuffer Device", 52 "Framebuffer Device",
52 "fbdev", 53 "fbdev",
53 "Szabolcs Berecz <szabi@inf.elte.hu>", 54 "Szabolcs Berecz <szabi@inf.elte.hu>",
489 return best; 490 return best;
490 } 491 }
491 492
492 static void set_bpp(struct fb_var_screeninfo *p, int bpp) 493 static void set_bpp(struct fb_var_screeninfo *p, int bpp)
493 { 494 {
494 p->bits_per_pixel = (bpp + 1) & ~1; 495 p->bits_per_pixel = FFALIGN(bpp, 2);
495 p->red.msb_right = p->green.msb_right = p->blue.msb_right = p->transp.msb_right = 0; 496 p->red.msb_right = p->green.msb_right = p->blue.msb_right = p->transp.msb_right = 0;
496 p->transp.offset = p->transp.length = 0; 497 p->transp.offset = p->transp.length = 0;
497 p->blue.offset = 0; 498 p->blue.offset = 0;
498 switch (bpp) { 499 switch (bpp) {
499 case 32: 500 case 32:
608 rcols = 1 << var->red.length; 609 rcols = 1 << var->red.length;
609 gcols = 1 << var->green.length; 610 gcols = 1 << var->green.length;
610 bcols = 1 << var->blue.length; 611 bcols = 1 << var->blue.length;
611 612
612 /* Make our palette the length of the deepest color */ 613 /* Make our palette the length of the deepest color */
613 cols = rcols > gcols ? rcols : gcols; 614 cols = FFMAX3(rcols, gcols, bcols);
614 cols = cols > bcols ? cols : bcols;
615 615
616 red = malloc(cols * sizeof(red[0])); 616 red = malloc(cols * sizeof(red[0]));
617 if (!red) { 617 if (!red) {
618 mp_msg(MSGT_VO, MSGL_V, "Can't allocate red palette with %d entries.\n", cols); 618 mp_msg(MSGT_VO, MSGL_V, "Can't allocate red palette with %d entries.\n", cols);
619 return NULL; 619 return NULL;