From 6ee4bfccdb8da2c775a411a6279ef5def3c2f72d Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 25 Jul 2002 13:12:23 +0000 Subject: eq reworked git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6787 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/dec_video.c | 16 +++-- libmpcodecs/vf_vo.c | 4 +- libvo/vo_xv.c | 94 ++++++++++++++++++++++++++- libvo/vo_xvidix.c | 29 +++++++-- libvo/vosub_vidix.c | 165 +++++++++++++++++++++++------------------------- mplayer.c | 64 +++++++++++++++---- 6 files changed, 258 insertions(+), 114 deletions(-) diff --git a/libmpcodecs/dec_video.c b/libmpcodecs/dec_video.c index 32302757f9..7a264504ce 100644 --- a/libmpcodecs/dec_video.c +++ b/libmpcodecs/dec_video.c @@ -77,10 +77,11 @@ void set_video_quality(sh_video_t *sh_video,int quality){ int set_video_colors(sh_video_t *sh_video,char *item,int value) { vf_instance_t* vf=sh_video->vfilter; - + + mp_dbg(MSGT_DECVIDEO,MSGL_V,"set video colors %s=%d \n", item, value); if (vf) { - int ret = vf->control(vf, VFCTRL_SET_EQUALIZER, item, (int *)value); + int ret = vf->control(vf, VFCTRL_SET_EQUALIZER, item, (int *)value); if (ret == CONTROL_TRUE) return(1); } @@ -92,9 +93,14 @@ int set_video_colors(sh_video_t *sh_video,char *item,int value) int get_video_colors(sh_video_t *sh_video,char *item,int *value) { vf_instance_t* vf=sh_video->vfilter; - - if (vf->control(vf, VFCTRL_GET_EQUALIZER, item, value) == CONTROL_TRUE) - return 1; + + mp_dbg(MSGT_DECVIDEO,MSGL_V,"get video colors %s \n", item); + if (vf) + { + int ret = vf->control(vf, VFCTRL_GET_EQUALIZER, item, value); + if (ret == CONTROL_TRUE) + return(1); + } /* try software control */ if(mpvdec) return mpvdec->control(sh_video,VDCTRL_GET_EQUALIZER, item, value); return 0; diff --git a/libmpcodecs/vf_vo.c b/libmpcodecs/vf_vo.c index 9189010f6e..e82b85b668 100644 --- a/libmpcodecs/vf_vo.c +++ b/libmpcodecs/vf_vo.c @@ -70,13 +70,13 @@ static int control(struct vf_instance_s* vf, int request, void* data, ...) case VFCTRL_GET_EQUALIZER: { va_list ap; - int value; + int *value; if(!vo_config_count) return CONTROL_FALSE; // vo not configured? va_start(ap, data); value = va_arg(ap, int); va_end(ap); - return((video_out->control(VOCTRL_GET_EQUALIZER, data, (int *)value) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE); + return((video_out->control(VOCTRL_GET_EQUALIZER, data, value) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE); } } // return video_out->control(request,data); diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c index 0683e37074..2de8412789 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -144,8 +144,8 @@ static int xv_set_eq(char *name, int value, int use_reset) mp_dbg(MSGT_VO, MSGL_V, "xv_set_eq called! (%s, %d, %d)\n", name, value, use_reset); - /* get available attributes */ - attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany); + /* get available attributes */ + attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany); /* first pass try reset */ if(use_reset) { @@ -226,6 +226,85 @@ static int xv_set_eq(char *name, int value, int use_reset) return(VO_FALSE); } +static int xv_get_eq(char *name, int *value) +{ + XvAttribute *attributes; + int howmany, xv_min, xv_max, xv_atom; + static int was_reset = 0; + + *value = 0; + + /* get available attributes */ + attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany); + for (i = 0; i < howmany && attributes; i++) + { + if (attributes[i].flags & XvGettable) + { + xv_min = attributes[i].min_value; + xv_max = attributes[i].max_value; + xv_atom = XInternAtom(mDisplay, attributes[i].name, True); +/* since we have SET_DEFAULTS first in our list, we can check if it's available + then trigger it if it's ok so that the other values are at default upon query */ + if (xv_atom != None) + { + int val, port_value, port_min, port_max, port_mid; + + XvGetPortAttribute(mDisplay, xv_port, xv_atom, &port_value); + + port_min = xv_min; + port_max = xv_max; + port_mid = (port_min + port_max) / 2; + + val = ((port_value - port_mid)*2000)/(port_max-port_min); + + if(!strcmp(attributes[i].name,"XV_BRIGHTNESS") && + (!strcasecmp(name, "brightness"))) + *value = val; + else + if(!strcmp(attributes[i].name,"XV_CONTRAST") && + (!strcasecmp(name, "contrast"))) + *value = val; + else + if(!strcmp(attributes[i].name,"XV_SATURATION") && + (!strcasecmp(name, "saturation"))) + *value = val; + else + if(!strcmp(attributes[i].name,"XV_HUE") && + (!strcasecmp(name, "hue"))) + /* nasty nvidia detect */ + { + if (port_min == 0 && port_max == 360) + { + if (port_value > port_mid-1) + val = (port_value - port_max + 1) * 1000 / port_mid; + else + val = port_value * 1000 / port_mid; + } + *value = val; + } + else + /* Note: since 22.01.2002 GATOS supports these attrs for radeons (NK) */ + if(!strcmp(attributes[i].name,"XV_RED_INTENSITY") && + (!strcasecmp(name, "red_intensity"))) + *value = val; + else + if(!strcmp(attributes[i].name,"XV_GREEN_INTENSITY") && + (!strcasecmp(name, "green_intensity"))) + *value = val; + else + if(!strcmp(attributes[i].name,"XV_BLUE_INTENSITY") && + (!strcasecmp(name, "blue_intensity"))) + *value = val; + else continue; + + mp_dbg(MSGT_VO, MSGL_V, "xv_get_eq called! (%s, %d)\n", name, *value); + return(VO_TRUE); + } + } + } + return(VO_FALSE); +} + /* * connect to server, create and map window, * allocate colors and (shared) memory @@ -829,6 +908,17 @@ static uint32_t control(uint32_t request, void *data, ...) return(xv_set_eq(data, value, 0)); } + case VOCTRL_GET_EQUALIZER: + { + va_list ap; + int *value; + + va_start(ap, data); + value = va_arg(ap, int); + va_end(ap); + + return(xv_get_eq(data, value)); + } } return VO_NOTIMPL; } diff --git a/libvo/vo_xvidix.c b/libvo/vo_xvidix.c index 0127a78a76..89a2a3deff 100644 --- a/libvo/vo_xvidix.c +++ b/libvo/vo_xvidix.c @@ -174,13 +174,6 @@ static void set_window(int force_update,const vo_tune_info_t *info) mp_msg(MSGT_VO, MSGL_V, "[xvidix] window properties: pos: %dx%d, size: %dx%d\n", vo_dx, vo_dy, window_width, window_height); - - { // á.c.s. technologies (C) Pontscho - vidix_video_eq_t eq; - vo_vaa_t vo_vaa; - if ( vidix_control( VOCTRL_QUERY_VAA,&vo_vaa) != VO_NOTIMPL ) - if ( vo_vaa.get_video_eq && vo_vaa.get_video_eq( &eq ) == 0 ) set_video_eq( eq.cap ); - } /* mDrawColorKey: */ @@ -455,6 +448,28 @@ static uint32_t control(uint32_t request, void *data, ...) set_window( 0,&vtune ); } return VO_TRUE; + case VOCTRL_SET_EQUALIZER: + { + va_list ap; + int value; + + va_start(ap, data); + value = va_arg(ap, int); + va_end(ap); + + return vidix_control(request, data, (int *)value); + } + case VOCTRL_GET_EQUALIZER: + { + va_list ap; + int *value; + + va_start(ap, data); + value = va_arg(ap, int); + va_end(ap); + + return vidix_control(request, data, value); + } } return vidix_control(request, data); // return VO_NOTIMPL; diff --git a/libvo/vosub_vidix.c b/libvo/vosub_vidix.c index 7b3f30a224..efbdff9788 100644 --- a/libvo/vosub_vidix.c +++ b/libvo/vosub_vidix.c @@ -59,20 +59,6 @@ static int vidix_get_oem_fx(vidix_oem_fx_t *info); static int vidix_set_oem_fx(const vidix_oem_fx_t *info); static int vidix_set_deint(const vidix_deinterlace_t *info); -static void vidix_query_vaa(vo_vaa_t *vaa) -{ - memset(vaa,0,sizeof(vo_vaa_t)); - vaa->query_bes_da=vidix_get_bes_da; - vaa->get_video_eq=vidix_get_video_eq; - vaa->set_video_eq=vidix_set_video_eq; - vaa->get_num_fx=vidix_get_num_fx; - vaa->get_oem_fx=vidix_get_oem_fx; - vaa->set_oem_fx=vidix_set_oem_fx; - vaa->set_deint=vidix_set_deint; -} - -static vidix_video_eq_t vid_eq; - int vidix_start(void) { int err; @@ -82,39 +68,6 @@ int vidix_start(void) return -1; } video_on=1; - if (vidix_cap.flags & FLAG_EQUALIZER) - { - if(verbose > 1) - { - printf("vosub_vidix: vo_gamma_brightness=%i\n" - "vosub_vidix: vo_gamma_saturation=%i\n" - "vosub_vidix: vo_gamma_contrast=%i\n" - "vosub_vidix: vo_gamma_hue=%i\n" - "vosub_vidix: vo_gamma_red_intensity=%i\n" - "vosub_vidix: vo_gamma_green_intensity=%i\n" - "vosub_vidix: vo_gamma_blue_intensity=%i\n" - ,vo_gamma_brightness - ,vo_gamma_saturation - ,vo_gamma_contrast - ,vo_gamma_hue - ,vo_gamma_red_intensity - ,vo_gamma_green_intensity - ,vo_gamma_blue_intensity); - } - /* To use full set of vid_eq.cap */ - if(vidix_get_video_eq(&vid_eq) == 0) - { - vid_eq.brightness = vo_gamma_brightness; - vid_eq.saturation = vo_gamma_saturation; - vid_eq.contrast = vo_gamma_contrast; - vid_eq.hue = vo_gamma_hue; - vid_eq.red_intensity = vo_gamma_red_intensity; - vid_eq.green_intensity = vo_gamma_green_intensity; - vid_eq.blue_intensity = vo_gamma_blue_intensity; - vid_eq.flags = VEQ_FLG_ITU_R_BT_601; - vidix_set_video_eq(&vid_eq); - } - } return 0; } @@ -138,15 +91,6 @@ void vidix_term( void ) // ((vo_functions_t *)vo_server)->control=server_control; } -static uint32_t vidix_draw_slice_swYV12(uint8_t *image[], int stride[], int w,int h,int x,int y) -{ - uint8_t *dest; - dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; - dest += dstrides.y*y + x; - yv12toyuy2(image[0], image[1], image[2], dest, w, h, stride[0], stride[1],dstrides.y); - return 0; -} - static uint32_t vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y) { uint8_t *src; @@ -363,17 +307,6 @@ void vidix_flip_page(void) } } -static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) -{ - UNUSED(x0); - UNUSED(y0); - UNUSED(w); - UNUSED(h); - UNUSED(src); - UNUSED(srca); - UNUSED(stride); -} - static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) { uint32_t apitch,bespitch; @@ -420,7 +353,7 @@ static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned vo_draw_alpha_rgb15(w,h,src,srca,stride,lvo_mem+y0*bespitch+2*x0,bespitch); break; default: - draw_alpha_null(x0,y0,w,h,src,srca,stride); + return; } } @@ -437,22 +370,7 @@ uint32_t vidix_query_fourcc(uint32_t format) vidix_fourcc.fourcc = format; vdlQueryFourcc(vidix_handler,&vidix_fourcc); if (vidix_fourcc.depth == VID_DEPTH_NONE) - { - if(format == IMGFMT_YV12) - { - vidix_fourcc.fourcc = IMGFMT_YUY2; - vdlQueryFourcc(vidix_handler,&vidix_fourcc); - if (vidix_fourcc.depth == VID_DEPTH_NONE) return 0; - else - { - vo_server->draw_slice = vidix_draw_slice_swYV12; - forced_fourcc=IMGFMT_YUY2; - printf("vosub_vidix: WARNING!!! Using YV12 to YUY2 SW convertion\n"); - return VFCAP_CSP_SUPPORTED|VFCAP_HWSCALE_UP|VFCAP_HWSCALE_DOWN; - } - } return 0; - } return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_HWSCALE_UP|VFCAP_HWSCALE_DOWN|VFCAP_OSD; } @@ -753,9 +671,6 @@ static uint32_t vidix_get_image(mp_image_t *mpi) uint32_t vidix_control(uint32_t request, void *data, ...) { switch (request) { - case VOCTRL_QUERY_VAA: - vidix_query_vaa((vo_vaa_t*)data); - return VO_TRUE; case VOCTRL_QUERY_FORMAT: return vidix_query_fourcc(*((uint32_t*)data)); case VOCTRL_GET_IMAGE: @@ -769,6 +684,81 @@ uint32_t vidix_control(uint32_t request, void *data, ...) case VOCTRL_GET_NUM_FRAMES: *(uint32_t *)data = vidix_play.num_frames; return VO_TRUE; + case VOCTRL_SET_EQUALIZER: + { + va_list ap; + int value; + vidix_video_eq_t info; + + if(!video_on) return VO_FALSE; + va_start(ap, data); + value = va_arg(ap, int); + va_end(ap); + + /* vidix eq ranges are -1000..1000 */ + if (!strcasecmp(data, "brightness")) + { + info.brightness = value*10; + info.cap |= VEQ_CAP_BRIGHTNESS; + } + else if (!strcasecmp(data, "contrast")) + { + info.contrast = value*10; + info.cap |= VEQ_CAP_CONTRAST; + } + else if (!strcasecmp(data, "saturation")) + { + info.saturation = value*10; + info.cap |= VEQ_CAP_SATURATION; + } + else if (!strcasecmp(data, "hue")) + { + info.hue = value*10; + info.cap |= VEQ_CAP_HUE; + } + + if (vdlPlaybackSetEq(vidix_handler, &info) == 0) + return VO_TRUE; + return VO_FALSE; + } + case VOCTRL_GET_EQUALIZER: + { + va_list ap; + int *value; + vidix_video_eq_t info; + + if(!video_on) return VO_FALSE; + if (vdlPlaybackSetEq(vidix_handler, &info) != 0) + return VO_FALSE; + + va_start(ap, data); + value = va_arg(ap, int); + va_end(ap); + + /* vidix eq ranges are -1000..1000 */ + if (!strcasecmp(data, "brightness")) + { + if (info.cap & VEQ_CAP_BRIGHTNESS) + *value = info.brightness/10; + } + else if (!strcasecmp(data, "contrast")) + { + if (info.cap & VEQ_CAP_CONTRAST) + *value = info.contrast/10; + } + else if (!strcasecmp(data, "saturation")) + { + if (info.cap & VEQ_CAP_SATURATION) + *value = info.saturation/10; + } + else if (!strcasecmp(data, "hue")) + { + if (info.cap & VEQ_CAP_HUE) + *value = info.hue/10; + } + + return VO_TRUE; + } } return VO_NOTIMPL; // WARNING: we drop extra parameters (...) here! @@ -798,7 +788,8 @@ int vidix_preinit(const char *drvname,void *server) printf("vosub_vidix: Couldn't get capability: %s\n",strerror(err)); return -1; } - printf("vosub_vidix: Using: %s by %s\n",vidix_cap.name,vidix_cap.author); + printf("VIDIX: Description: %s\n", vidix_cap.name); + printf("VIDIX: Author: %s\n", vidix_cap.author); /* we are able to tune up this stuff depend on fourcc format */ ((vo_functions_t *)server)->draw_slice=vidix_draw_slice; ((vo_functions_t *)server)->draw_frame=vidix_draw_frame; diff --git a/mplayer.c b/mplayer.c index 16523ef0ae..2c606e7ecd 100644 --- a/mplayer.c +++ b/mplayer.c @@ -270,10 +270,10 @@ static stream_t* stream=NULL; char* current_module=NULL; // for debugging -int vo_gamma_brightness = 0; -int vo_gamma_contrast = 0; -int vo_gamma_saturation = 0; -int vo_gamma_hue = 0; +int vo_gamma_brightness = 1000; +int vo_gamma_contrast = 1000; +int vo_gamma_saturation = 1000; +int vo_gamma_hue = 1000; // --- @@ -1331,11 +1331,17 @@ if(auto_quality>0){ // ========== Init display (sh_video->disp_w*sh_video->disp_h/out_fmt) ============ current_module="init_vo"; - /* set defaults */ - set_video_colors(sh_video, "brightness", vo_gamma_brightness); - set_video_colors(sh_video, "contrast", vo_gamma_contrast); - set_video_colors(sh_video, "saturation", vo_gamma_saturation); - set_video_colors(sh_video, "hue", vo_gamma_hue); + if (sh_video) + { + if (vo_gamma_brightness != 1000) + set_video_colors(sh_video, "brightness", vo_gamma_brightness); + if (vo_gamma_contrast != 1000) + set_video_colors(sh_video, "contrast", vo_gamma_contrast); + if (vo_gamma_saturation != 1000) + set_video_colors(sh_video, "saturation", vo_gamma_saturation); + if (vo_gamma_hue != 1000) + set_video_colors(sh_video, "hue", vo_gamma_hue); + } if(vo_flags & 0x08 && vo_spudec) spudec_set_hw_spu(vo_spudec,video_out); @@ -2392,7 +2398,16 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still) } break; case MP_CMD_BRIGHTNESS : { int v = cmd->args[0].v.i, abs = cmd->args[1].v.i; - + + if (!sh_video) + break; + + if (vo_gamma_brightness == 1000) + { + vo_gamma_brightness = 0; + get_video_colors(sh_video, "brightness", &vo_gamma_brightness); + } + if (abs) vo_gamma_brightness = v; else @@ -2415,6 +2430,15 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still) } break; case MP_CMD_CONTRAST : { int v = cmd->args[0].v.i, abs = cmd->args[1].v.i; + + if (!sh_video) + break; + + if (vo_gamma_contrast == 1000) + { + vo_gamma_contrast = 0; + get_video_colors(sh_video, "contrast", &vo_gamma_contrast); + } if (abs) vo_gamma_contrast = v; @@ -2438,7 +2462,16 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still) } break; case MP_CMD_SATURATION : { int v = cmd->args[0].v.i, abs = cmd->args[1].v.i; - + + if (!sh_video) + break; + + if (vo_gamma_saturation == 1000) + { + vo_gamma_saturation = 0; + get_video_colors(sh_video, "saturation", &vo_gamma_saturation); + } + if (abs) vo_gamma_saturation = v; else @@ -2461,6 +2494,15 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still) } break; case MP_CMD_HUE : { int v = cmd->args[0].v.i, abs = cmd->args[1].v.i; + + if (!sh_video) + break; + + if (vo_gamma_hue == 1000) + { + vo_gamma_hue = 0; + get_video_colors(sh_video, "hue", &vo_gamma_hue); + } if (abs) vo_gamma_hue = v; -- cgit v1.2.3