diff --git a/programs/media/Fplay/audio.c b/programs/media/Fplay/audio.c index dbe9769e4c..746dc7269f 100644 --- a/programs/media/Fplay/audio.c +++ b/programs/media/Fplay/audio.c @@ -6,6 +6,7 @@ #include #include +#include #include "sound.h" #include "fplay.h" @@ -78,8 +79,6 @@ int decode_audio(AVCodecContext *ctx, queue_t *qa) AVPacket pkt; AVPacket pkt_tmp; - uint8_t *audio_data; - int audio_size; int len; int data_size=0; diff --git a/programs/media/Fplay/fplay.c b/programs/media/Fplay/fplay.c index 7c7fcaadfd..527eed3c98 100644 --- a/programs/media/Fplay/fplay.c +++ b/programs/media/Fplay/fplay.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "sound.h" #include "fplay.h" @@ -51,6 +52,8 @@ int main( int argc, char *argv[]) movie_file = argv[1]; /* register all codecs, demux and protocols */ +// av_log_set_level(AV_LOG_INFO); + avcodec_register_all(); avdevice_register_all(); av_register_all(); @@ -61,7 +64,7 @@ int main( int argc, char *argv[]) return -1; // Couldn't open file }; - printf("%s\n\r", __FUNCTION__); +// printf("%s\n\r", __FUNCTION__); // Retrieve stream information if(avformat_find_stream_info(pFormatCtx, NULL)<0) @@ -72,7 +75,7 @@ int main( int argc, char *argv[]) // __asm__ __volatile__("int3"); - // dump_format(pFormatCtx, 0, argv[1], 0); +// dump_format(pFormatCtx, 0, argv[1], 0); // Find the first video stream videoStream=-1; @@ -207,7 +210,7 @@ void decoder() // __asm__ __volatile__("int3"); - if(q_video.size+q_audio.size < 16*1024*1024) + if(q_video.size+q_audio.size < 12*1024*1024) { err = av_read_frame(pFormatCtx, &packet); if( err < 0) @@ -241,7 +244,7 @@ void decoder() ret = 1; - while(status != 0 && ret) + while( (status != 0) && ret) { ret = decode_video(pCodecCtx, &q_video); ret |= decode_audio(aCodecCtx, &q_audio); @@ -250,6 +253,6 @@ void decoder() delay(50); status = 0; printf("status = 0\n"); - delay(200); + delay(300); }; diff --git a/programs/media/Fplay/fplay.h b/programs/media/Fplay/fplay.h index 4b6ea297a6..c6f3dfab58 100644 --- a/programs/media/Fplay/fplay.h +++ b/programs/media/Fplay/fplay.h @@ -5,14 +5,6 @@ typedef unsigned int color_t; typedef unsigned int count_t; -typedef struct -{ - int left; - int top; - int right; - int bottom; -}rect_t; - typedef struct { uint32_t width; @@ -24,6 +16,11 @@ typedef struct typedef struct render render_t; +#define HAS_LEFT (1<<0) +#define HAS_TOP (1<<1) +#define HAS_RIGHT (1<<2) +#define HAS_BOTTOM (1<<3) + struct render { uint32_t caps; @@ -32,14 +29,22 @@ struct render uint32_t win_width; uint32_t win_height; + rect_t rc_client; + rect_t rcvideo; + rect_t rcleft; + rect_t rctop; + rect_t rcright; + rect_t rcbottom; + + uint32_t layout; bitmap_t bitmap[4]; uint32_t ctx_format; int target; + + window_t *win; enum{ EMPTY, INIT }state; - enum{ - NORMAL, MINIMIZED, ROLLED - }win_state; + enum win_state win_state; void (*draw)(render_t *render, AVPicture *picture); }; @@ -90,7 +95,10 @@ render_t *create_render(uint32_t width, uint32_t height, uint32_t ctx_format, uint32_t flags); int init_render(render_t *render, int width, int height); -void render_adjust_size(render_t *render); +void render_adjust_size(render_t *render, window_t *win); +int render_set_size(render_t *render, int width, int height); +void render_draw_client(render_t *render); + int init_audio(int format); int audio_thread(void *param); @@ -120,16 +128,6 @@ static inline void GetNotify(void *event) ::"a"(68),"b"(14),"c"(event)); } -static inline uint32_t check_os_event() -{ - uint32_t val; - __asm__ __volatile__( - "int $0x40" - :"=a"(val) - :"a"(11)); - return val; -}; - static inline uint32_t get_os_button() { uint32_t val; @@ -154,48 +152,8 @@ static inline void delay(uint32_t time) ::"a"(5), "b"(time)); }; -static inline draw_bitmap(void *bitmap, int x, int y, int w, int h) -{ - __asm__ __volatile__( - "int $0x40" - ::"a"(7), "b"(bitmap), - "c"((w << 16) | h), - "d"((x << 16) | y)); -} - -static inline void BeginDraw(void) -{ - __asm__ __volatile__( - "int $0x40" ::"a"(12),"b"(1)); -}; - -static inline void EndDraw(void) -{ - __asm__ __volatile__( - "int $0x40" ::"a"(12),"b"(2)); -}; -static inline void DrawWindow(int x, int y, int w, int h, char *name, - color_t workcolor, uint32_t style) -{ - - __asm__ __volatile__( - "int $0x40" - ::"a"(0), - "b"((x << 16) | (w & 0xFFFF)), - "c"((y << 16) | (h & 0xFFFF)), - "d"((style << 24) | (workcolor & 0xFFFFFF)), - "D"(name)); -}; - -static inline void get_proc_info(char *info) -{ - __asm__ __volatile__( - "int $0x40" - ::"a"(9), "b"(info), "c"(-1) - :"memory"); -} #define HW_BIT_BLIT (1<<0) /* BGRX blitter */ #define HW_TEX_BLIT (1<<1) /* stretch blit */ @@ -204,6 +162,7 @@ static inline void get_proc_info(char *info) uint32_t InitPixlib(uint32_t flags); int create_bitmap(bitmap_t *bitmap); +int lock_bitmap(bitmap_t *bitmap); int resize_bitmap(bitmap_t *bitmap); int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y, int w, int h); diff --git a/programs/media/Fplay/pixlib2.c b/programs/media/Fplay/pixlib2.c index 83af10cd87..688b7fa19b 100644 --- a/programs/media/Fplay/pixlib2.c +++ b/programs/media/Fplay/pixlib2.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "fplay.h" #define DISPLAY_VERSION 0x0200 /* 2.00 */ @@ -12,6 +13,8 @@ #define SRV_GET_CAPS 3 #define SRV_CREATE_SURFACE 10 +#define SRV_LOCK_SURFACE 12 + #define SRV_BLIT_VIDEO 20 #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) @@ -195,6 +198,52 @@ int create_bitmap(bitmap_t *bitmap) return -1; }; +int lock_bitmap(bitmap_t *bitmap) +{ + // __asm__ __volatile__("int3"); + + if( blit_caps & HW_BIT_BLIT ) + { + struct __attribute__((packed)) /* SRV_CREATE_SURFACE */ + { + uint32_t handle; // ignored + void *data; // ignored + + uint32_t width; + uint32_t height; + uint32_t pitch; // ignored + + }io_12; + + ioctl_t io; + int err; + + io_12.handle = bitmap->handle; + io_12.pitch = 0; + io_12.data = 0; + + io.handle = service; + io.io_code = SRV_LOCK_SURFACE; + io.input = &io_12; + io.inp_size = BUFFER_SIZE(5); + io.output = NULL; + io.out_size = 0; + + err = call_service(&io); + if(err==0) + { + bitmap->pitch = io_12.pitch; + bitmap->data = io_12.data; +// printf("Lock hardware surface %x pitch %d, buffer %x\n", +// bitmap->handle, bitmap->pitch, bitmap->data); + return 0; + }; + return err; + }; + + return 0; +}; + struct blit_call { int dstx; @@ -280,6 +329,8 @@ int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y, __asm__ __volatile__( "int $0x40" ::"a"(73),"b"(0),"c"(&bc)); + + return 0; }; diff --git a/programs/media/Fplay/system.h b/programs/media/Fplay/system.h new file mode 100644 index 0000000000..50522a4813 --- /dev/null +++ b/programs/media/Fplay/system.h @@ -0,0 +1,311 @@ + +#include +#include +#include + +#ifdef CONFIG_DEBUF + #define DBG(format,...) printf(format,##__VA_ARGS__) +#else + #define DBG(format,...) +#endif + +typedef unsigned int color_t; + +typedef union __attribute__((packed)) +{ + uint32_t val; + struct + { + short x; + short y; + }; +}pos_t; + +typedef union __attribute__((packed)) +{ + uint32_t val; + struct + { + uint8_t state; + uint8_t code; + uint16_t ctrl_key; + }; +}oskey_t; + +static inline +void BeginDraw(void) +{ + __asm__ __volatile__( + "int $0x40" ::"a"(12),"b"(1)); +}; + +static inline +void EndDraw(void) +{ + __asm__ __volatile__( + "int $0x40" ::"a"(12),"b"(2)); +}; + +static inline void DrawWindow(int x, int y, int w, int h, char *name, + color_t workcolor, uint32_t style) +{ + + __asm__ __volatile__( + "int $0x40" + ::"a"(0), + "b"((x << 16) | (w & 0xFFFF)), + "c"((y << 16) | (h & 0xFFFF)), + "d"((style << 24) | (workcolor & 0xFFFFFF)), + "D"(name)); +}; + +static inline +pos_t get_mouse_pos(void) +{ + pos_t val; + + __asm__ __volatile__( + "int $0x40 \n\t" + "rol $16, %%eax" + :"=eax"(val) + :"a"(37),"b"(1)); + return val; +} + +static inline +pos_t get_cursor_pos(void) +{ + pos_t val; + + __asm__ __volatile__( + "int $0x40 \n\t" + "rol $16, %%eax" + :"=eax"(val) + :"a"(37),"b"(0)); + return val; +} + +static inline +uint32_t get_mouse_buttons(void) +{ + uint32_t val; + + __asm__ __volatile__( + "int $0x40" + :"=a"(val) + :"a"(37),"b"(2)); + return val; +}; + +static inline +uint32_t get_mouse_wheels(void) +{ + uint32_t val; + + __asm__ __volatile__( + "int $0x40 \n\t" + "rol $16, %%eax" + :"=a"(val) + :"a"(37),"b"(7)); + return val; +}; + +static inline +uint32_t wait_for_event(uint32_t time) +{ + uint32_t val; + __asm__ __volatile__( + "int $0x40" + :"=a"(val) + :"a"(23), "b"(time)); + return val; +}; + +static inline uint32_t check_os_event() +{ + uint32_t val; + __asm__ __volatile__( + "int $0x40" + :"=a"(val) + :"a"(11)); + return val; +}; + +static inline +uint32_t get_tick_count(void) +{ + uint32_t val; + __asm__ __volatile__( + "int $0x40" + :"=eax"(val) + :"a"(26),"b"(9)); + return val; +}; + +static inline +oskey_t get_key(void) +{ + oskey_t val; + __asm__ __volatile__( + "int $0x40" + :"=eax"(val) + :"a"(2)); + return val; +} + +static inline +void draw_line(int xs, int ys, int xe, int ye, color_t color) +{ + __asm__ __volatile__( + "int $0x40" + ::"a"(38), "d"(color), + "b"((xs << 16) | xe), + "c"((ys << 16) | ye)); +} + + + +static inline +void draw_bar(int x, int y, int w, int h, color_t color) +{ + __asm__ __volatile__( + "int $0x40" + ::"a"(13), "d"(color), + "b"((x << 16) | w), + "c"((y << 16) | h)); +} + +static inline +void draw_bitmap(void *bitmap, int x, int y, int w, int h) +{ + __asm__ __volatile__( + "int $0x40" + ::"a"(7), "b"(bitmap), + "c"((w << 16) | h), + "d"((x << 16) | y)); +} + +static inline +void draw_text(const char *text, int x, int y, int len, color_t color) +{ + __asm__ __volatile__( + "int $0x40" + ::"a"(4),"d"(text), + "b"((x << 16) | y), + "S"(len),"c"(color)); +} + +static inline +void *user_alloc(size_t size) +{ + void *val; + __asm__ __volatile__( + "int $0x40" + :"=eax"(val) + :"a"(68),"b"(12),"c"(size)); + return val; +} + +static inline +int user_free(void *mem) +{ + int val; + __asm__ __volatile__( + "int $0x40" + :"=eax"(val) + :"a"(68),"b"(12),"c"(mem)); + return val; +} + +static inline +int *user_unmap(void *base, size_t offset, size_t size) +{ + void *val; + __asm__ __volatile__( + "int $0x40" + :"=eax"(val) + :"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size)); + return val; +} + +/* +extern inline +void exit(int status) __attribute__((noreturn)) ; + +extern inline +void exit(int status) +{ + __asm__ __volatile__( + "int $0x40" + ::"a"(-1)); + for(;;); +} +*/ + +static inline +uint32_t load_cursor(void *path, uint32_t flags) +{ + uint32_t val; + __asm__ __volatile__( + "int $0x40" + :"=eax"(val) + :"a"(37), "b"(4), "c"(path), "d"(flags)); + return val; +} + +static inline +uint32_t set_cursor(uint32_t cursor) +{ + uint32_t old; + __asm__ __volatile__( + "int $0x40" + :"=eax"(old) + :"a"(37), "b"(5), "c"(cursor)); + return old; +} + +static inline void get_proc_info(char *info) +{ + __asm__ __volatile__( + "int $0x40" + : + :"a"(9), "b"(info), "c"(-1)); +} + +static inline +void* user_realloc(void *mem, size_t size) +{ + void *val; + __asm__ __volatile__( + "int $0x40" + :"=eax"(val) + :"a"(68),"b"(12),"c"(size),"d"(mem) + :"memory"); + + return val; +} + +void *load_file(const char *path, size_t *len); + +void *get_resource(void *data, uint32_t id); + +struct blit_call +{ + int dstx; + int dsty; + int w; + int h; + + int srcx; + int srcy; + int srcw; + int srch; + + unsigned char *bitmap; + int stride; +}; + +void Blit(void *bitmap, int dst_x, int dst_y, + int src_x, int src_y, int w, int h, + int src_w, int src_h, int stride); + diff --git a/programs/media/Fplay/utils.c b/programs/media/Fplay/utils.c index 747cf61860..1e7f8311ee 100644 --- a/programs/media/Fplay/utils.c +++ b/programs/media/Fplay/utils.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "fplay.h" extern uint32_t hw2d ; diff --git a/programs/media/Fplay/video.c b/programs/media/Fplay/video.c index a07898ff2b..256c19bf20 100644 --- a/programs/media/Fplay/video.c +++ b/programs/media/Fplay/video.c @@ -3,6 +3,9 @@ #include #include #include +#include +#include "system.h" +#include #include "sound.h" #include "fplay.h" @@ -21,7 +24,7 @@ struct SwsContext *cvt_ctx = NULL; int vfx = 0; int dfx = 0; -render_t *render; +render_t *main_render; int width; int height; @@ -43,11 +46,14 @@ int init_video(AVCodecContext *ctx) printf("w = %d h = %d\n\r", width, height); -// __asm__ __volatile__("int3"); +// __asm__ __volatile__("int3"); - render = create_render(ctx->width, ctx->height, + main_render = create_render(ctx->width, ctx->height, ctx->pix_fmt, HW_BIT_BLIT|HW_TEX_BLIT); - if( render == NULL) +// render = create_render(ctx->width, ctx->height, +// ctx->pix_fmt, 0); +// + if( main_render == NULL) { printf("Cannot create render\n\r"); return 0; @@ -85,14 +91,11 @@ int init_video(AVCodecContext *ctx) return 1; }; -int frameFinished=0; -static int frame_count; - int decode_video(AVCodecContext *ctx, queue_t *qv) { AVPacket pkt; double pts; - double av_time; + int frameFinished; if(frames[dfx].ready != 0 ) return 1; @@ -130,7 +133,8 @@ int decode_video(AVCodecContext *ctx, queue_t *qv) dst_pic = &frames[dfx].picture; - av_image_copy(dst_pic->data, dst_pic->linesize, Frame->data, + av_image_copy(dst_pic->data, dst_pic->linesize, + (const uint8_t**)Frame->data, Frame->linesize, ctx->pix_fmt, ctx->width, ctx->height); frames[dfx].pts = pts*1000.0; @@ -147,102 +151,116 @@ int decode_video(AVCodecContext *ctx, queue_t *qv) extern volatile uint32_t status; rect_t win_rect; -int check_events() + +int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) { - int ev; + window_t *win; - ev = check_os_event(); + win = (window_t*)ctrl; - switch(ev) + switch(msg) { - case 1: - render_adjust_size(render); - BeginDraw(); - DrawWindow(0,0,0,0, NULL, 0x000000,0x73); - EndDraw(); + case MSG_SIZE: + //printf("MSG_SIZE\n"); + render_adjust_size(main_render, win); break; - case 3: - if(get_os_button()==1) - status = 0; + case MSG_DRAW_CLIENT: + render_draw_client(main_render); break; + + case MSG_COMMAND: + switch((short)arg1) + { + case ID_CLOSE: + exit(0); + }; + break; + + default: + def_window_proc(ctrl,msg,arg1,arg2); }; - return 1; -} + return 0; +}; +void render_time(render_t *render) +{ + double ctime; + double fdelay; + + if(status == 0) + { + render->win->win_command = WIN_CLOSED; + return; + }; + + if(frames[vfx].ready == 1 ) + { + ctime = get_master_clock(); + fdelay = (frames[vfx].pts - ctime); + +// printf("pts %f time %f delay %f\n", +// frames[vfx].pts, ctime, fdelay); + + if(fdelay < 0.0 ) + { + int next_vfx; + fdelay = 0; + next_vfx = (vfx+1) & 3; + if( frames[next_vfx].ready == 1 ) + { + if(frames[next_vfx].pts <= ctime) + { + frames[vfx].ready = 0; // skip this frame + vfx++; + vfx&= 3; + } + else + { + if( (frames[next_vfx].pts - ctime) < + ( ctime - frames[vfx].pts) ) + { + frames[vfx].ready = 0; // skip this frame + vfx++; + vfx&= 3; + fdelay = (frames[next_vfx].pts - ctime); + } + } + }; + }; + + if(fdelay > 10.0) + { + delay( (uint32_t)(fdelay/10.0)); + }; + + main_render->draw(main_render, &frames[vfx].picture); + frames[vfx].ready = 0; + vfx++; + vfx&= 3; + }; +} extern char *movie_file; int video_thread(void *param) { - rect_t rc; - AVCodecContext *ctx = param; + window_t *MainWindow; - BeginDraw(); - DrawWindow(10, 10, width+9, height+26, movie_file, 0x000000,0x73); - EndDraw(); + init_winlib(); - render_adjust_size(render); + MainWindow = create_window(movie_file,0, + 10,10,width+14,height+29,MainWindowProc); - while( status != 0) - { - double ctime; - double fdelay; +// printf("MainWindow %x\n", MainWindow); - check_events(); + main_render->win = MainWindow; - if(frames[vfx].ready == 1 ) - { - ctime = get_master_clock(); - fdelay = (frames[vfx].pts - ctime); + show_window(MainWindow, NORMAL); + run_render(MainWindow, main_render); -// printf("pts %f time %f delay %f\n", -// frames[vfx].pts, ctime, fdelay); - - if(fdelay < 0.0 ) - { - int next_vfx; - fdelay = 0; - next_vfx = (vfx+1) & 3; - if( frames[next_vfx].ready == 1 ) - { - if(frames[next_vfx].pts <= ctime) - { - frames[vfx].ready = 0; // skip this frame - vfx++; - vfx&= 3; - } - else - { - if( (frames[next_vfx].pts - ctime) < - ( ctime - frames[vfx].pts) ) - { - frames[vfx].ready = 0; // skip this frame - vfx++; - vfx&= 3; - fdelay = (frames[next_vfx].pts - ctime); - } - } - }; - }; - - if(fdelay > 10.0) - { - delay( (uint32_t)(fdelay/10.0)); - }; - -// blit_bitmap(&frames[vfx].bitmap, 5, 22, width, height); -// frames[vfx].frame->linesize[0]); - render->draw(render, &frames[vfx].picture); - frames[vfx].ready = 0; - vfx++; - vfx&= 3; - } - else - { - yield(); - }; - }; +// printf("exit thread\n"); + status = 0; return 0; }; @@ -253,10 +271,12 @@ void draw_sw_picture(render_t *render, AVPicture *picture); render_t *create_render(uint32_t width, uint32_t height, uint32_t ctx_format, uint32_t flags) { - render_t *ren; + render_t *render; - render = (render_t*)malloc(sizeof(*ren)); - memset(ren, 0, sizeof(*ren)); +// __asm__ __volatile__("int3"); + + render = (render_t*)malloc(sizeof(render_t)); + memset(render, 0, sizeof(render_t)); render->ctx_width = width; render->ctx_height = height; @@ -285,11 +305,51 @@ int render_set_size(render_t *render, int width, int height) { int i; - render->win_width = width; - render->win_height = height; - render->win_state = NORMAL; + render->layout = 0; + render->rcvideo.l = 0; + render->rcvideo.t = 0; + render->rcvideo.r = width; + render->rcvideo.b = height; -// printf("%s %dx%d\n",__FUNCTION__, width, height); + if( render->win_height > height ) + { + int yoffs; + yoffs = (render->win_height-height)/2; + if(yoffs) + { + render->rctop.t = 0; + render->rctop.b = yoffs; + render->rcvideo.t = yoffs; + render->layout |= HAS_TOP; + } + + yoffs = render->win_height-(render->rcvideo.t+render->rcvideo.b); + if(yoffs) + { + render->rcbottom.t = render->rcvideo.t+render->rcvideo.b; + render->rcbottom.b = yoffs; + render->layout |= HAS_BOTTOM; + } + } + + if( render->win_width > width ) + { + int xoffs; + xoffs = (render->win_width-width)/2; + if(xoffs) + { + render->rcleft.r = xoffs; + render->rcvideo.l = xoffs; + render->layout |= HAS_LEFT; + } + xoffs = render->win_width-(render->rcvideo.l+render->rcvideo.r); + if(xoffs) + { + render->rcright.l = render->rcvideo.l+render->rcvideo.r; + render->rcright.r = xoffs; + render->layout |= HAS_RIGHT; + } + }; if(render->state == EMPTY) { @@ -333,31 +393,22 @@ int render_set_size(render_t *render, int width, int height) return 0; }; -void render_adjust_size(render_t *render) +void render_adjust_size(render_t *render, window_t *win) { - char proc_info[1024]; - uint32_t right, bottom, new_w, new_h; uint32_t s, sw, sh; uint8_t state; - get_proc_info(proc_info); - right = *(uint32_t*)(proc_info+62)+1; - bottom = *(uint32_t*)(proc_info+66)+1; - state = *(uint8_t*)(proc_info+70); + right = win->w; + bottom = win->h-29; + render->win_state = win->win_state; - if(state & 2) - { render->win_state = MINIMIZED; + if(render->win_state == MINIMIZED) return; - } - if(state & 4) - { - render->win_state = ROLLED; - return; - }; - render->win_state = NORMAL; + if(render->win_state == ROLLED) + return; if( right == render->win_width && bottom == render->win_height) @@ -366,7 +417,6 @@ void render_adjust_size(render_t *render) new_w = bottom*render->ctx_width/render->ctx_height; new_h = right*render->ctx_height/render->ctx_width; -// printf("right %d bottom %d\n", right, bottom); // printf("new_w %d new_h %d\n", new_w, new_h); s = right * bottom; @@ -383,22 +433,21 @@ void render_adjust_size(render_t *render) new_w = 64; new_h = 64*render->ctx_height/render->ctx_width; }; - __asm__ __volatile__( - "int $0x40" - ::"a"(67), "b"(-1), "c"(-1), - "d"(new_w+9),"S"(new_h+26) - :"memory" ); - render_set_size(render, new_w, new_h); + render->win_width = win->w; + render->win_height = win->h-29; + render_set_size(render, new_w, new_h); }; void draw_hw_picture(render_t *render, AVPicture *picture) { int dst_width, dst_height; - uint8_t *data[4]; + bitmap_t *bitmap; + uint8_t *data[4]; int linesize[4]; + int ret; - if(render->win_state != NORMAL) + if(render->win_state == ROLLED) return; if(render->caps & HW_TEX_BLIT) @@ -421,26 +470,37 @@ void draw_hw_picture(render_t *render, AVPicture *picture) printf("Cannot initialize the conversion context!\n"); return ; }; -// printf("sws_getCachedContext\n"); - data[0] = render->bitmap[render->target].data; - data[1] = render->bitmap[render->target].data+1; - data[2] = render->bitmap[render->target].data+2; - data[3] = render->bitmap[render->target].data+3; - linesize[0] = render->bitmap[render->target].pitch; - linesize[1] = render->bitmap[render->target].pitch; - linesize[2] = render->bitmap[render->target].pitch; - linesize[3] = render->bitmap[render->target].pitch; + bitmap = &render->bitmap[render->target]; + + ret = lock_bitmap(bitmap); + if( ret != 0) + { + printf("Cannot lock the bitmap!\n"); + return ; + } + +// printf("sws_getCachedContext\n"); + data[0] = bitmap->data; + data[1] = bitmap->data+1; + data[2] = bitmap->data+2; + data[3] = bitmap->data+3; + + linesize[0] = bitmap->pitch; + linesize[1] = bitmap->pitch; + linesize[2] = bitmap->pitch; + linesize[3] = bitmap->pitch; sws_scale(cvt_ctx, (const uint8_t* const *)picture->data, picture->linesize, 0, render->ctx_height, data, linesize); // printf("sws_scale\n"); - blit_bitmap(&render->bitmap[render->target], 5, 22, - render->win_width, render->win_height); + blit_bitmap(bitmap, render->rcvideo.l, + 29+render->rcvideo.t, + render->rcvideo.r, render->rcvideo.b); // printf("blit_bitmap\n"); - delay(2); + render->target++; render->target&= 3; } @@ -450,13 +510,14 @@ void draw_sw_picture(render_t *render, AVPicture *picture) uint8_t *data[4]; int linesize[4]; - if(render->win_state != NORMAL) + if(render->win_state == MINIMIZED || + render->win_state == ROLLED) return; cvt_ctx = sws_getCachedContext(cvt_ctx, render->ctx_width, render->ctx_height, render->ctx_format, - render->win_width, render->win_height, + render->rcvideo.r, render->rcvideo.b, PIX_FMT_BGRA, SWS_FAST_BILINEAR, NULL, NULL, NULL); if(cvt_ctx == NULL) { @@ -478,12 +539,31 @@ void draw_sw_picture(render_t *render, AVPicture *picture) sws_scale(cvt_ctx, (const uint8_t* const *)picture->data, picture->linesize, 0, render->ctx_height, data, linesize); - blit_bitmap(&render->bitmap[0], 5, 22, - render->win_width, render->win_height); + blit_bitmap(&render->bitmap[0], render->rcvideo.l, + render->rcvideo.t+29, + render->rcvideo.r, render->rcvideo.b); +} + +void render_draw_client(render_t *render) +{ + if(render->win_state == MINIMIZED || + render->win_state == ROLLED) + return; + + if(render->layout & HAS_TOP) + draw_bar(0, 29, render->win_width, + render->rctop.b, 0); + if(render->layout & HAS_LEFT) + draw_bar(0, render->rcvideo.t+29, render->rcleft.r, + render->rcvideo.b, 0); + if(render->layout & HAS_RIGHT) + draw_bar(render->rcright.l, render->rcvideo.t+29, + render->rcright.r, render->rcvideo.b, 0); + if(render->layout & HAS_BOTTOM) + draw_bar(0, render->rcbottom.t+29, + render->win_width, render->rcbottom.b, 0); } - -