diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-04-26 18:06:00 +0300 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-04-26 18:06:00 +0300 |
commit | 837c48ddeef9066f16c119f3cac412d37a25766a (patch) | |
tree | 61b95ec92e22522c8ccd07cd213f66dd56c1c197 /libvo | |
parent | e913d6c5dabcf342d8c1a7070382d712fc354948 (diff) | |
parent | 7bf961b1a3bbea070f40247417965493965729e1 (diff) | |
download | mpv-837c48ddeef9066f16c119f3cac412d37a25766a.tar.bz2 mpv-837c48ddeef9066f16c119f3cac412d37a25766a.tar.xz |
Merge svn changes up to r31020
Diffstat (limited to 'libvo')
-rw-r--r-- | libvo/gl_common.c | 14 | ||||
-rw-r--r-- | libvo/gl_common.h | 1 | ||||
-rw-r--r-- | libvo/vo_corevideo.m | 45 | ||||
-rw-r--r-- | libvo/vo_gl.c | 3 | ||||
-rw-r--r-- | libvo/vo_gl2.c | 39 |
5 files changed, 63 insertions, 39 deletions
diff --git a/libvo/gl_common.c b/libvo/gl_common.c index bdc501998e..bb2e7ce10c 100644 --- a/libvo/gl_common.c +++ b/libvo/gl_common.c @@ -1381,6 +1381,20 @@ static void glSetupYUVFragprog(gl_conversion_params_t *params) { } /** + * \brief detect the best YUV->RGB conversion method available + */ +int glAutodetectYUVConversion(void) { + const char *extensions = mpglGetString(GL_EXTENSIONS); + if (strstr(extensions, "GL_ARB_fragment_program")) + return YUV_CONVERSION_FRAGMENT; + if (strstr(extensions, "GL_ATI_text_fragment_shader")) + return YUV_CONVERSION_TEXT_FRAGMENT; + if (strstr(extensions, "GL_ATI_fragment_shader")) + return YUV_CONVERSION_COMBINERS_ATI; + return YUV_CONVERSION_NONE; +} + +/** * \brief setup YUV->RGB conversion * \param parms struct containing parameters like conversion and scaler type, * brightness, ... diff --git a/libvo/gl_common.h b/libvo/gl_common.h index 82770908f8..91d3346b8b 100644 --- a/libvo/gl_common.h +++ b/libvo/gl_common.h @@ -347,6 +347,7 @@ typedef struct { float filter_strength; } gl_conversion_params_t; +int glAutodetectYUVConversion(void); void glSetupYUVConversion(gl_conversion_params_t *params); void glEnableYUVConversion(GLenum target, int type); void glDisableYUVConversion(GLenum target, int type); diff --git a/libvo/vo_corevideo.m b/libvo/vo_corevideo.m index be45813f8c..17086e7cb8 100644 --- a/libvo/vo_corevideo.m +++ b/libvo/vo_corevideo.m @@ -104,7 +104,11 @@ static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigne { switch (image_format) { - case IMGFMT_RGB32: + case IMGFMT_RGB24: + vo_draw_alpha_rgb24(w,h,src,srca,stride,image_data+3*(y0*image_width+x0),3*image_width); + break; + case IMGFMT_ARGB: + case IMGFMT_BGRA: vo_draw_alpha_rgb32(w,h,src,srca,stride,image_data+4*(y0*image_width+x0),4*image_width); break; case IMGFMT_YUY2: @@ -170,8 +174,11 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_ image_height = height; switch (image_format) { - case IMGFMT_BGR32: - case IMGFMT_RGB32: + case IMGFMT_RGB24: + image_depth = 24; + break; + case IMGFMT_ARGB: + case IMGFMT_BGRA: image_depth = 32; break; case IMGFMT_YUY2: @@ -287,35 +294,38 @@ static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) static int draw_frame(uint8_t *src[]) { - switch (image_format) - { - case IMGFMT_BGR32: - case IMGFMT_RGB32: - fast_memcpy(image_data, src[0], image_width*image_height*image_bytes); - break; + return 0; +} - case IMGFMT_YUY2: - memcpy_pic(image_data, src[0], image_width * 2, image_height, image_width * 2, image_width * 2); - break; - } +static uint32_t draw_image(mp_image_t *mpi) +{ + memcpy_pic(image_data, mpi->planes[0], image_width*image_bytes, image_height, image_width*image_bytes, mpi->stride[0]); return 0; } static int query_format(uint32_t format) { + const int supportflags = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; image_format = format; switch(format) { case IMGFMT_YUY2: pixelFormat = kYUVSPixelFormat; - return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; + return supportflags; + + case IMGFMT_RGB24: + pixelFormat = k24RGBPixelFormat; + return supportflags; - case IMGFMT_RGB32: - case IMGFMT_BGR32: + case IMGFMT_ARGB: pixelFormat = k32ARGBPixelFormat; - return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; + return supportflags; + + case IMGFMT_BGRA: + pixelFormat = k32BGRAPixelFormat; + return supportflags; } return 0; } @@ -405,6 +415,7 @@ static int control(uint32_t request, void *data) { switch (request) { + case VOCTRL_DRAW_IMAGE: return draw_image(data); case VOCTRL_PAUSE: return int_pause = 1; case VOCTRL_RESUME: return int_pause = 0; case VOCTRL_QUERY_FORMAT: return query_format(*((uint32_t*)data)); diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index 3ae3075e4a..b97b376bac 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -496,7 +496,8 @@ static void autodetectGlExtensions(void) { if (ati_hack == -1) ati_hack = ati_broken_pbo; if (force_pbo == -1) force_pbo = strstr(extensions, "_pixel_buffer_object") ? is_ati : 0; if (use_rectangle == -1) use_rectangle = strstr(extensions, "_texture_non_power_of_two") ? 0 : 0; - if (use_yuv == -1) use_yuv = strstr(extensions, "GL_ARB_fragment_program") ? 2 : 0; + if (use_yuv == -1) + use_yuv = glAutodetectYUVConversion(); if (is_ati && (lscale == 1 || lscale == 2 || cscale == 1 || cscale == 2)) mp_msg(MSGT_VO, MSGL_WARN, "[gl] Selected scaling mode may be broken on ATI cards.\n" "Tell _them_ to fix GL_REPEAT if you have issues.\n"); diff --git a/libvo/vo_gl2.c b/libvo/vo_gl2.c index e2cfcf2aff..dafaa1e60a 100644 --- a/libvo/vo_gl2.c +++ b/libvo/vo_gl2.c @@ -169,7 +169,6 @@ static int initTextures(void) GLfloat texpercx, texpercy; int s; int x=0, y=0; - GLint format=0; // textures smaller than 64x64 might not be supported s=64; @@ -183,37 +182,37 @@ static int initTextures(void) texture_height=s; if (!is_yuv) - gl_internal_format = getInternalFormat(); + gl_internal_format = getInternalFormat(); /* Test the max texture size */ do { + GLint w; glTexImage2D (GL_PROXY_TEXTURE_2D, 0, gl_internal_format, texture_width, texture_height, 0, gl_bitmap_format, gl_bitmap_type, NULL); glGetTexLevelParameteriv - (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &format); + (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w); - if (format != gl_internal_format) - { - mp_msg (MSGT_VO, MSGL_V, "[gl2] Needed texture [%dx%d] too big, trying ", - texture_height, texture_width); + if (w >= texture_width) + break; - if (texture_width > texture_height) - texture_width /= 2; - else - texture_height /= 2; + mp_msg (MSGT_VO, MSGL_V, "[gl2] Needed texture [%dx%d] too big, trying ", + texture_width, texture_height); - mp_msg (MSGT_VO, MSGL_V, "[%dx%d] !\n", texture_height, texture_width); + if (texture_width > texture_height) + texture_width /= 2; + else + texture_height /= 2; - if(texture_width < 64 || texture_height < 64) { - mp_msg (MSGT_VO, MSGL_FATAL, "[gl2] Give up .. usable texture size not avaiable, or texture config error !\n"); - return -1; - } + mp_msg (MSGT_VO, MSGL_V, "[%dx%d] !\n", texture_width, texture_height); + + if(texture_width < 64 || texture_height < 64) { + mp_msg (MSGT_VO, MSGL_FATAL, "[gl2] Give up .. usable texture size not avaiable, or texture config error !\n"); + return -1; } - } - while (format != gl_internal_format && texture_width > 1 && texture_height > 1); + } while (texture_width > 1 && texture_height > 1); #ifdef TEXTURE_WIDTH texture_width = TEXTURE_WIDTH; #endif @@ -865,7 +864,6 @@ static int preinit(const char *arg) } if(!init_mpglcontext(&glctx, gltype)) goto err_out; if (use_yuv == -1) { - const char *extensions; #ifdef CONFIG_GL_WIN32 if (config_w32(320, 200, 320, 200, VOFLAG_HIDDEN, "", 0) == -1) #else @@ -874,8 +872,7 @@ static int preinit(const char *arg) goto err_out; if (glctx.setGlWindow(&glctx) == SET_WINDOW_FAILED) goto err_out; - extensions = mpglGetString(GL_EXTENSIONS); - use_yuv = strstr(extensions, "GL_ARB_fragment_program") ? 2 : 0; + use_yuv = glAutodetectYUVConversion(); } return 0; |