Index: libvo/vosub_vidix.c =================================================================== --- libvo/vosub_vidix.c (revision 24573) +++ libvo/vosub_vidix.c (working copy) @@ -22,6 +22,7 @@ #include #include #include +#include #include "config.h" #include "mp_msg.h" @@ -49,9 +50,14 @@ static vidix_playback_t vidix_play; static vidix_fourcc_t vidix_fourcc; static vo_functions_t * vo_server; +static vo_functions_t vo_local; static vidix_yuv_t dstrides; /*static uint32_t (*server_control)(uint32_t request, void *data, ...);*/ +static pthread_mutex_t vidix_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t vidix_cond = PTHREAD_COND_INITIALIZER; +static pthread_t vidix_thread; + int vidix_start(void) { int err; @@ -241,10 +247,38 @@ return 0; } +static uint8_t *vds_image[3]; +static int vds_stride[3], vds_w, vds_h, vds_x, vds_y; + +static void vidix_task() +{ + pthread_mutex_lock(&vidix_mutex); + pthread_cond_signal(&vidix_cond); + + for(;;) { + pthread_cond_wait(&vidix_cond, &vidix_mutex); + if (!vds_image[0]) break; + vo_local.draw_slice(vds_image, vds_stride, vds_w, vds_h, vds_x, vds_y); + vds_image[0] = NULL; + } +} + uint32_t vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) { - mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SUB_VIDIX_DummyVidixdrawsliceWasCalled); - return -1; + pthread_mutex_lock(&vidix_mutex); + vds_image[0] = image[0]; + vds_image[1] = image[1]; + vds_image[2] = image[2]; + vds_stride[0] = stride[0]; + vds_stride[1] = stride[1]; + vds_stride[2] = stride[2]; + vds_w = w; + vds_h = h; + vds_x = x; + vds_y = y; + pthread_cond_signal(&vidix_cond); + pthread_mutex_unlock(&vidix_mutex); + return 0; } static uint32_t vidix_draw_image(mp_image_t *mpi){ @@ -279,7 +313,7 @@ static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) { uint32_t apitch,bespitch; - void *lvo_mem; + char *lvo_mem; lvo_mem = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; apitch = vidix_play.dest.pitch.y-1; switch(vidix_play.fourcc){ @@ -557,11 +591,17 @@ is_422_planes_eq = sstride == dstrides.y; if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV) - vo_server->draw_slice = vidix_draw_slice_420; + vo_local.draw_slice = vidix_draw_slice_420; else if (src_format == IMGFMT_YVU9 || src_format == IMGFMT_IF09) - vo_server->draw_slice = vidix_draw_slice_410; - else vo_server->draw_slice = vidix_draw_slice_packed; + vo_local.draw_slice = vidix_draw_slice_410; + else vo_local.draw_slice = vidix_draw_slice_packed; } + if (!vidix_thread) { + pthread_mutex_lock(&vidix_mutex); + pthread_create(&vidix_thread, NULL, vidix_task, NULL); + pthread_cond_wait(&vidix_cond, &vidix_mutex); + pthread_mutex_unlock(&vidix_mutex); + } return 0; }