# HG changeset patch # User reimar # Date 1346620623 0 # Node ID a0ff4fde7a486ccb66ee77708212d847dd4e4471 # Parent 638d1f3bd87f46bfbcc0204106b719fed04a4c94 Add helper function to reduce code duplication for selecting correct OSD drawing function. diff -r 638d1f3bd87f -r a0ff4fde7a48 sub/osd.c --- a/sub/osd.c Sat Sep 01 16:54:53 2012 +0000 +++ b/sub/osd.c Sun Sep 02 21:17:03 2012 +0000 @@ -27,6 +27,8 @@ #include "osd.h" #include "mp_msg.h" #include +#include +#include "libmpcodecs/img_format.h" #include "cpudetect.h" #if ARCH_X86 @@ -426,3 +428,34 @@ } return; } + +vo_draw_alpha_func vo_get_draw_alpha(unsigned fmt) { + if (IMGFMT_IS_RGB(fmt) || IMGFMT_IS_BGR(fmt)) { + switch (IMGFMT_RGB_DEPTH(fmt)) + { + case 12: + return vo_draw_alpha_rgb12; + case 15: + return vo_draw_alpha_rgb15; + case 16: + return vo_draw_alpha_rgb16; + case 24: + return vo_draw_alpha_rgb24; + case 32: + return vo_draw_alpha_rgb32; + } + return NULL; + } + switch (fmt) { + case IMGFMT_YV12: + case IMGFMT_I420: + case IMGFMT_IYUV: + return vo_draw_alpha_yv12; + case IMGFMT_YUY2: + case IMGFMT_YVYU: + return vo_draw_alpha_yuy2; + case IMGFMT_UYVY: + return vo_draw_alpha_uyvy; + } + return NULL; +} diff -r 638d1f3bd87f -r a0ff4fde7a48 sub/osd.h --- a/sub/osd.h Sat Sep 01 16:54:53 2012 +0000 +++ b/sub/osd.h Sun Sep 02 21:17:03 2012 +0000 @@ -24,6 +24,9 @@ void vo_draw_alpha_init(void); // build tables +typedef void (*vo_draw_alpha_func)(int, int, unsigned char *, unsigned char *, int, unsigned char *, int); +vo_draw_alpha_func vo_get_draw_alpha(unsigned fmt); + void vo_draw_alpha_yv12(int w, int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase, int dststride); void vo_draw_alpha_yuy2(int w, int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase, int dststride); void vo_draw_alpha_uyvy(int w, int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase, int dststride);