From 2b19b2dcbae11860e7723bf0447e2da67ea68c4f Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 26 Jun 2009 14:40:31 +0000 Subject: fbdev: remove pointless () git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29394 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_fbdev.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'libvo/vo_fbdev.c') diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c index 5f621967cf..6c40e3840f 100644 --- a/libvo/vo_fbdev.c +++ b/libvo/vo_fbdev.c @@ -610,8 +610,8 @@ static struct fb_cmap *make_directcolor_cmap(struct fb_var_screeninfo *var) bcols = 1 << var->blue.length; /* Make our palette the length of the deepest color */ - cols = (rcols > gcols ? rcols : gcols); - cols = (cols > bcols ? cols : bcols); + cols = rcols > gcols ? rcols : gcols; + cols = cols > bcols ? cols : bcols; red = malloc(cols * sizeof(red[0])); if (!red) { @@ -763,7 +763,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, mp_msg(MSGT_VO, MSGL_ERR, "-fbmode can only be used with -vm\n"); return 1; } - if (vm && (parse_fbmode_cfg(fb_mode_cfgfile) < 0)) + if (vm && parse_fbmode_cfg(fb_mode_cfgfile) < 0) return 1; if (d_width && (fs || vm)) { out_width = d_width; @@ -1095,19 +1095,19 @@ static int preinit(const char *vo_subdevice) } } if (!pre_init_err) - return pre_init_err = (fb_preinit(0) ? 0 : -1); + return pre_init_err = fb_preinit(0) ? 0 : -1; return -1; } static uint32_t get_image(mp_image_t *mpi) { if (!IMGFMT_IS_BGR(mpi->imgfmt) || - (IMGFMT_BGR_DEPTH(mpi->imgfmt) != fb_bpp) || - ((mpi->type != MP_IMGTYPE_STATIC) && (mpi->type != MP_IMGTYPE_TEMP)) || + IMGFMT_BGR_DEPTH(mpi->imgfmt) != fb_bpp || + (mpi->type != MP_IMGTYPE_STATIC && mpi->type != MP_IMGTYPE_TEMP) || (mpi->flags & MP_IMGFLAG_PLANAR) || (mpi->flags & MP_IMGFLAG_YUV) || - (mpi->width != in_width) || - (mpi->height != in_height) + mpi->width != in_width || + mpi->height != in_height ) return VO_FALSE; @@ -1123,7 +1123,7 @@ static int control(uint32_t request, void *data, ...) case VOCTRL_GET_IMAGE: return get_image(data); case VOCTRL_QUERY_FORMAT: - return query_format(*((uint32_t*)data)); + return query_format(*(uint32_t*)data); } #ifdef CONFIG_VIDIX -- cgit v1.2.3 From 96de64de92ca6e0ccb10cbb4ae96126ed8790d8e Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 26 Jun 2009 14:43:03 +0000 Subject: Remove useless casts git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29395 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_fbdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libvo/vo_fbdev.c') diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c index 6c40e3840f..f854b64ecc 100644 --- a/libvo/vo_fbdev.c +++ b/libvo/vo_fbdev.c @@ -185,7 +185,7 @@ static int parse_fbmode_cfg(char *cfgfile) return -1; } - if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) { + if ((line = malloc(MAX_LINE_LEN + 1)) == NULL) { mp_msg(MSGT_VO, MSGL_V, "can't get memory for 'line': %s\n", strerror(errno)); return -2; } @@ -212,7 +212,7 @@ static int parse_fbmode_cfg(char *cfgfile) if (!validate_mode(mode)) goto err_out_not_valid; loop_enter: - if (!(fb_modes = (fb_mode_t *) + if (!(fb_modes = realloc(fb_modes, sizeof(fb_mode_t) * (nr_modes + 1)))) { mp_msg(MSGT_VO, MSGL_V, "can't realloc 'fb_modes' (nr_modes = %d):" " %s\n", nr_modes, strerror(errno)); @@ -949,8 +949,8 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, int x_offset = 0, y_offset = 0; geometry(&x_offset, &y_offset, &out_width, &out_height, fb_xres, fb_yres); - frame_buffer = (uint8_t *) mmap(0, fb_size, PROT_READ | PROT_WRITE, - MAP_SHARED, fb_dev_fd, 0); + frame_buffer = mmap(0, fb_size, PROT_READ | PROT_WRITE, + MAP_SHARED, fb_dev_fd, 0); if (frame_buffer == (uint8_t *) -1) { mp_msg(MSGT_VO, MSGL_ERR, "Can't mmap %s: %s\n", fb_dev_name, strerror(errno)); return 1; -- cgit v1.2.3 From e56dbbfd3ca602169f38669a48c554a46c1202a0 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 26 Jun 2009 15:14:48 +0000 Subject: Use FFALIGN and FFMAX3 git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29396 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_fbdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libvo/vo_fbdev.c') diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c index f854b64ecc..11b16d7a02 100644 --- a/libvo/vo_fbdev.c +++ b/libvo/vo_fbdev.c @@ -46,6 +46,7 @@ #endif #include "aspect.h" #include "mp_msg.h" +#include "libavutil/common.h" static const vo_info_t info = { "Framebuffer Device", @@ -491,7 +492,7 @@ static fb_mode_t *find_best_mode(int xres, int yres, range_t *hfreq, static void set_bpp(struct fb_var_screeninfo *p, int bpp) { - p->bits_per_pixel = (bpp + 1) & ~1; + p->bits_per_pixel = FFALIGN(bpp, 2); p->red.msb_right = p->green.msb_right = p->blue.msb_right = p->transp.msb_right = 0; p->transp.offset = p->transp.length = 0; p->blue.offset = 0; @@ -610,8 +611,7 @@ static struct fb_cmap *make_directcolor_cmap(struct fb_var_screeninfo *var) bcols = 1 << var->blue.length; /* Make our palette the length of the deepest color */ - cols = rcols > gcols ? rcols : gcols; - cols = cols > bcols ? cols : bcols; + cols = FFMAX3(rcols, gcols, bcols); red = malloc(cols * sizeof(red[0])); if (!red) { -- cgit v1.2.3 From b3e157882801d7a6a78f4d6674f1a798c079cee7 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 26 Jun 2009 15:22:15 +0000 Subject: Use a single err_out in fb_preinit, also fixes a leak when vo_dbpp has an unexpected value. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29397 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_fbdev.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'libvo/vo_fbdev.c') diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c index 11b16d7a02..eb7ad56ef6 100644 --- a/libvo/vo_fbdev.c +++ b/libvo/vo_fbdev.c @@ -673,6 +673,8 @@ static int fb_preinit(int reset) if (fb_preinit_done) return fb_works; + fb_dev_fd = fb_tty_fd = -1; + if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER"))) fb_dev_name = strdup("/dev/fb0"); mp_msg(MSGT_VO, MSGL_V, "using %s\n", fb_dev_name); @@ -683,7 +685,7 @@ static int fb_preinit(int reset) } if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) { mp_msg(MSGT_VO, MSGL_ERR, "Can't get VSCREENINFO: %s\n", strerror(errno)); - goto err_out_fd; + goto err_out; } fb_orig_vinfo = fb_vinfo; @@ -696,13 +698,13 @@ static int fb_preinit(int reset) if (fb_bpp == 8 && !vo_dbpp) { mp_msg(MSGT_VO, MSGL_ERR, "8 bpp output is not supported.\n"); - goto err_out_tty_fd; + goto err_out; } if (vo_dbpp) { if (vo_dbpp != 15 && vo_dbpp != 16 && vo_dbpp != 24 && vo_dbpp != 32) { mp_msg(MSGT_VO, MSGL_ERR, "can't switch to %d bpp\n", vo_dbpp); - goto err_out_fd; + goto err_out; } fb_bpp = vo_dbpp; } @@ -713,13 +715,13 @@ static int fb_preinit(int reset) fb_preinit_done = 1; fb_works = 1; return 1; -err_out_tty_fd: +err_out: + if (fb_tty_fd != -1) close(fb_tty_fd); fb_tty_fd = -1; -err_out_fd: + if (fb_dev_fd != -1) close(fb_dev_fd); fb_dev_fd = -1; -err_out: fb_preinit_done = 1; fb_works = 0; return 0; -- cgit v1.2.3 From 83ed88fb96dfb000381609d8f08aacbc6e5966ff Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 26 Jun 2009 15:28:30 +0000 Subject: 10l, use fopen directly instead of open + fdopen git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29398 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_fbdev.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'libvo/vo_fbdev.c') diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c index eb7ad56ef6..0d64702587 100644 --- a/libvo/vo_fbdev.c +++ b/libvo/vo_fbdev.c @@ -749,7 +749,6 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, struct fb_cmap *cmap; int vm = flags & VOFLAG_MODESWITCHING; int zoom = flags & VOFLAG_SWSCALE; - int vt_fd; fs = flags & VOFLAG_FULLSCREEN; @@ -970,12 +969,8 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, if (fs || vm) memset(frame_buffer, '\0', fb_line_len * fb_yres); } - if (vt_doit && (vt_fd = open("/dev/tty", O_WRONLY)) == -1) { - mp_msg(MSGT_VO, MSGL_ERR, "can't open /dev/tty: %s\n", strerror(errno)); - vt_doit = 0; - } - if (vt_doit && !(vt_fp = fdopen(vt_fd, "w"))) { - mp_msg(MSGT_VO, MSGL_ERR, "can't fdopen /dev/tty: %s\n", strerror(errno)); + if (vt_doit && !(vt_fp = fopen("/dev/tty", "w"))) { + mp_msg(MSGT_VO, MSGL_ERR, "can't fopen /dev/tty: %s\n", strerror(errno)); vt_doit = 0; } -- cgit v1.2.3 From fc24a623a20f61693c7a70f173bb00519ffc72db Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 26 Jun 2009 15:38:40 +0000 Subject: Get rid of completely pointless vt_doit variable git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29399 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_fbdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'libvo/vo_fbdev.c') diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c index 0d64702587..9e8d79d995 100644 --- a/libvo/vo_fbdev.c +++ b/libvo/vo_fbdev.c @@ -556,7 +556,6 @@ static fb_mode_t *fb_mode = NULL; /* vt related variables */ static FILE *vt_fp = NULL; -static int vt_doit = 1; /* vo_fbdev related variables */ static int fb_dev_fd; @@ -969,12 +968,10 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, if (fs || vm) memset(frame_buffer, '\0', fb_line_len * fb_yres); } - if (vt_doit && !(vt_fp = fopen("/dev/tty", "w"))) { + if (!(vt_fp = fopen("/dev/tty", "w"))) { mp_msg(MSGT_VO, MSGL_ERR, "can't fopen /dev/tty: %s\n", strerror(errno)); - vt_doit = 0; } - if (vt_doit) vt_set_textarea(last_row, fb_yres); return 0; @@ -1059,7 +1056,6 @@ static void uninit(void) if (ioctl(fb_tty_fd, KDSETMODE, KD_TEXT) < 0) mp_msg(MSGT_VO, MSGL_WARN, "Can't restore text mode: %s\n", strerror(errno)); } - if (vt_doit) vt_set_textarea(0, fb_orig_vinfo.yres); close(fb_tty_fd); close(fb_dev_fd); -- cgit v1.2.3 From 158aca92aec4a76825973714c92f3b3d458e7813 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 26 Jun 2009 15:39:35 +0000 Subject: Fix indentation broken in last patch git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29400 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_fbdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libvo/vo_fbdev.c') diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c index 9e8d79d995..128a2aac26 100644 --- a/libvo/vo_fbdev.c +++ b/libvo/vo_fbdev.c @@ -972,7 +972,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, mp_msg(MSGT_VO, MSGL_ERR, "can't fopen /dev/tty: %s\n", strerror(errno)); } - vt_set_textarea(last_row, fb_yres); + vt_set_textarea(last_row, fb_yres); return 0; } @@ -1056,7 +1056,7 @@ static void uninit(void) if (ioctl(fb_tty_fd, KDSETMODE, KD_TEXT) < 0) mp_msg(MSGT_VO, MSGL_WARN, "Can't restore text mode: %s\n", strerror(errno)); } - vt_set_textarea(0, fb_orig_vinfo.yres); + vt_set_textarea(0, fb_orig_vinfo.yres); close(fb_tty_fd); close(fb_dev_fd); if (frame_buffer) -- cgit v1.2.3 From 32a7d61acc6df033b55a341b38afd5d709e37882 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 26 Jun 2009 15:41:34 +0000 Subject: Close /dev/tty again on uninit. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29401 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_fbdev.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libvo/vo_fbdev.c') diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c index 128a2aac26..8c668fe8b4 100644 --- a/libvo/vo_fbdev.c +++ b/libvo/vo_fbdev.c @@ -1057,6 +1057,8 @@ static void uninit(void) mp_msg(MSGT_VO, MSGL_WARN, "Can't restore text mode: %s\n", strerror(errno)); } vt_set_textarea(0, fb_orig_vinfo.yres); + if (vt_fp) + fclose(vt_fp); close(fb_tty_fd); close(fb_dev_fd); if (frame_buffer) -- cgit v1.2.3 From 95dcb653798ef9b070d58e8958830bee3ddeca72 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 26 Jun 2009 16:20:15 +0000 Subject: Use memcpy_pic2 instead of reimplementing it. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29402 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_fbdev.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'libvo/vo_fbdev.c') diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c index 8c668fe8b4..24870a3c96 100644 --- a/libvo/vo_fbdev.c +++ b/libvo/vo_fbdev.c @@ -1011,17 +1011,11 @@ static int draw_frame(uint8_t *src[]) static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) { - uint8_t *d, *s; + uint8_t *d; d = center + fb_line_len * y + fb_pixel_size * x; - s = src[0]; - while (h) { - fast_memcpy(d, s, w * fb_pixel_size); - d += fb_line_len; - s += stride[0]; - h--; - } + memcpy_pic2(d, src[0], w * fb_pixel_size, h, fb_line_len, stride[0], 1); return 0; } -- cgit v1.2.3