From b77955312f8ae8b92044934394eac2cb229eb1f7 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Wed, 28 Nov 2012 12:06:34 +0000 Subject: [PATCH] FPlay: let's type something git-svn-id: svn://kolibrios.org@3068 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/media/Fplay/audio.c | 248 ++++++----- programs/media/Fplay/fplay.c | 276 ++++++------ programs/media/Fplay/fplay.h | 29 +- programs/media/Fplay/pixlib2.c | 203 +++++---- programs/media/Fplay/sound.h | 1 + programs/media/Fplay/system.h | 14 +- programs/media/Fplay/utils.c | 4 +- programs/media/Fplay/video.c | 215 ++++++--- programs/media/Fplay/winlib/alevel.raw | Bin 0 -> 4796 bytes programs/media/Fplay/winlib/button.c | 420 +++++++++++++++--- programs/media/Fplay/winlib/caption.c | 51 ++- programs/media/Fplay/winlib/caption_body.raw | Bin 0 -> 116 bytes programs/media/Fplay/winlib/caption_left.raw | Bin 0 -> 928 bytes programs/media/Fplay/winlib/caption_right.raw | Bin 0 -> 928 bytes programs/media/Fplay/winlib/close_button.raw | 1 + .../Fplay/winlib/close_button_pressed.raw | 1 + programs/media/Fplay/winlib/control.h | 51 ++- programs/media/Fplay/winlib/cptleft.raw | Bin 768 -> 768 bytes programs/media/Fplay/winlib/cptright.raw | Bin 768 -> 768 bytes programs/media/Fplay/winlib/fontlib.c | 150 +++++++ programs/media/Fplay/winlib/frame.c | 5 +- programs/media/Fplay/winlib/minimize_btn.raw | 1 + .../Fplay/winlib/minimize_btn_pressed.raw | 1 + programs/media/Fplay/winlib/panel.c | 114 ++++- programs/media/Fplay/winlib/panel.raw | Bin 220 -> 220 bytes programs/media/Fplay/winlib/panelleft.raw | Bin 3520 -> 1760 bytes programs/media/Fplay/winlib/panelright.raw | Bin 3520 -> 1760 bytes programs/media/Fplay/winlib/pbar.raw | Bin 0 -> 40 bytes programs/media/Fplay/winlib/prg_level.raw | Bin 0 -> 40 bytes programs/media/Fplay/winlib/res2.asm | 26 +- programs/media/Fplay/winlib/slider.raw | 1 + programs/media/Fplay/winlib/stopbtn.raw | Bin 0 -> 2304 bytes programs/media/Fplay/winlib/stopbtnp.raw | Bin 0 -> 2304 bytes programs/media/Fplay/winlib/vol_level.raw | Bin 0 -> 3840 bytes programs/media/Fplay/winlib/vol_slider.raw | Bin 0 -> 1920 bytes programs/media/Fplay/winlib/window.c | 22 +- programs/media/Fplay/winlib/winlib.h | 17 +- 37 files changed, 1324 insertions(+), 527 deletions(-) create mode 100644 programs/media/Fplay/winlib/alevel.raw create mode 100644 programs/media/Fplay/winlib/caption_body.raw create mode 100644 programs/media/Fplay/winlib/caption_left.raw create mode 100644 programs/media/Fplay/winlib/caption_right.raw create mode 100644 programs/media/Fplay/winlib/close_button.raw create mode 100644 programs/media/Fplay/winlib/close_button_pressed.raw create mode 100644 programs/media/Fplay/winlib/fontlib.c create mode 100644 programs/media/Fplay/winlib/minimize_btn.raw create mode 100644 programs/media/Fplay/winlib/minimize_btn_pressed.raw create mode 100644 programs/media/Fplay/winlib/pbar.raw create mode 100644 programs/media/Fplay/winlib/prg_level.raw create mode 100644 programs/media/Fplay/winlib/slider.raw create mode 100644 programs/media/Fplay/winlib/stopbtn.raw create mode 100644 programs/media/Fplay/winlib/stopbtnp.raw create mode 100644 programs/media/Fplay/winlib/vol_level.raw create mode 100644 programs/media/Fplay/winlib/vol_slider.raw diff --git a/programs/media/Fplay/audio.c b/programs/media/Fplay/audio.c index 93dc329f58..348d9666c7 100644 --- a/programs/media/Fplay/audio.c +++ b/programs/media/Fplay/audio.c @@ -14,8 +14,13 @@ astream_t astream; extern uint8_t *decoder_buffer; +int resampler_size; +volatile int sound_level_0; +volatile int sound_level_1; -extern volatile enum player_state player_state; +volatile enum player_state player_state; +volatile enum player_state decoder_state; +volatile enum player_state sound_state; extern volatile uint32_t driver_lock; @@ -46,7 +51,7 @@ int init_audio(int format) mutex_unlock(&driver_lock); - printf("sound version 0x%x\n", version); +// printf("sound version 0x%x\n", version); if( (SOUND_VERSION>(version&0xFFFF)) || (SOUND_VERSION<(version >> 16))) @@ -67,6 +72,11 @@ exit_whith_error: return 0; }; +void set_audio_volume(int left, int right) +{ + SetVolume(hBuff, left, right); +}; + static uint64_t samples_lost; static double audio_delta; static double last_time_stamp; @@ -89,7 +99,7 @@ int decode_audio(AVCodecContext *ctx, queue_t *qa) int data_size=0; if( astream.count > AVCODEC_MAX_AUDIO_FRAME_SIZE*7) - return 1; + return -1; if( get_packet(qa, &pkt) == 0 ) return 0; @@ -111,9 +121,9 @@ int decode_audio(AVCodecContext *ctx, queue_t *qa) // { // if (pkt.pts != AV_NOPTS_VALUE) // audio_base = get_audio_base() * pkt.pts; -// printf("audio base %f\n", audio_base); +// printf("audio base %f\n", audio_base); // }; - + pkt_tmp.data += len; pkt_tmp.size -= len; @@ -161,8 +171,16 @@ static void sync_audio(SNDBUF hbuff, int buffsize) mutex_lock(&astream.lock); { + if(astream.count < buffsize) + { + memset(astream.buffer+astream.count, + 0, buffsize-astream.count); + astream.count = buffsize; + }; + SetBuffer(hbuff, astream.buffer, offset, buffsize); samples_written+= buffsize/4; + astream.count -= buffsize; if(astream.count) memcpy(astream.buffer, astream.buffer+buffsize, astream.count); @@ -174,7 +192,6 @@ static void sync_audio(SNDBUF hbuff, int buffsize) }; - int audio_thread(void *param) { SND_EVENT evnt; @@ -192,7 +209,7 @@ int audio_thread(void *param) goto exit_whith_error; }; - SetVolume(hBuff,-1000,-1000); + SetVolume(hBuff,-1875,-1875); if((err = GetBufferSize(hBuff, &buffsize)) != 0) { @@ -200,139 +217,130 @@ int audio_thread(void *param) goto exit_whith_error; }; - buffsize = buffsize/2; + resampler_size = buffsize = buffsize/2; samples = buffsize/4; - while( (astream.count < buffsize*2) && - (player_state != CLOSED) ) - yield(); - - mutex_lock(&astream.lock); - { - SetBuffer(hBuff, astream.buffer, 0, buffsize); - samples_written+= buffsize/4; - astream.count -= buffsize; - if(astream.count) - memcpy(astream.buffer, astream.buffer+buffsize, astream.count); - mutex_unlock(&astream.lock); - }; - while( player_state != CLOSED) { uint32_t offset; double event_stamp, wait_stamp; int too_late = 0; - if((player_state == PAUSE) || - (player_state == PLAY_INIT) ) + switch(sound_state) { - if( active ) - { - StopBuffer(hBuff); - active = 0; - }; - delay(1); - continue; - } - else if(player_state == REWIND) - { - if( active ) - { - StopBuffer(hBuff); - active = 0; - }; - mutex_lock(&astream.lock); - astream.count = 0; - mutex_unlock(&astream.lock); - delay(1); - continue; - } - else if(player_state == PAUSE_2_PLAY) - { -// SetTimeBase(hBuff, audio_base); - GetTimeStamp(hBuff, &last_time_stamp); -// printf("last_time_stamp %f\n", last_time_stamp); - - if((err = PlayBuffer(hBuff, 0)) !=0 ) - { - errstr = "Cannot play buffer\n\r"; - goto exit_whith_error; - }; - active = 1; - sync_audio(hBuff, buffsize); - player_state = PLAY; - printf("render: set audio latency to %f\n", audio_delta); - } - else if(player_state == REWIND_2_PLAY) - { - while( (astream.count < buffsize*2) && - (player_state != CLOSED) ) - yield(); + case PREPARE: - SetTimeBase(hBuff, audio_base); - GetTimeStamp(hBuff, &last_time_stamp); - printf("last audio time stamp %f\n", last_time_stamp); - - if((err = PlayBuffer(hBuff, 0)) !=0 ) - { - errstr = "Cannot play buffer\n\r"; - goto exit_whith_error; - }; - active = 1; - sync_audio(hBuff, buffsize); - player_state = PLAY; - printf("render: set audio latency to %f\n", audio_delta); - }; + mutex_lock(&astream.lock); + if(astream.count < buffsize*2) + { + memset(astream.buffer+astream.count, + 0, buffsize*2-astream.count); + astream.count = buffsize*2; + }; - GetNotify(&evnt); + SetBuffer(hBuff, astream.buffer, 0, buffsize*2); + astream.count -= buffsize*2; + if(astream.count) + memcpy(astream.buffer, astream.buffer+buffsize*2, astream.count); + mutex_unlock(&astream.lock); - if(evnt.code != 0xFF000001) - { - printf("invalid event code %d\n\r", evnt.code); - continue; - } + SetTimeBase(hBuff, audio_base); - if(evnt.stream != hBuff) - { - printf("invalid stream %x hBuff= %x\n\r", - evnt.stream, hBuff); - continue; - }; + case PAUSE_2_PLAY: + GetTimeStamp(hBuff, &last_time_stamp); +// printf("last audio time stamp %f\n", last_time_stamp); - GetTimeStamp(hBuff, &event_stamp); + if((err = PlayBuffer(hBuff, 0)) !=0 ) + { + errstr = "Cannot play buffer\n\r"; + goto exit_whith_error; + }; + active = 1; + sync_audio(hBuff, buffsize); + sound_state = PLAY; +// printf("render: set audio latency to %f\n", audio_delta); - offset = evnt.offset; + /* breaktrough */ - while( (astream.count < buffsize) && - (player_state != CLOSED) ) - { - yield(); - GetTimeStamp(hBuff, &wait_stamp); - if( (wait_stamp - event_stamp) > - samples*1500/sample_rate ) - { - samples_lost+= samples; - audio_delta = (double)samples_lost*1000/sample_rate; -// printf("audio delta %f\n", audio_delta); - too_late = 1; + case PLAY: + GetNotify(&evnt); + + if(evnt.code != 0xFF000001) + { + printf("invalid event code %d\n\r", evnt.code); + continue; + } + + if(evnt.stream != hBuff) + { + printf("invalid stream %x hBuff= %x\n\r", + evnt.stream, hBuff); + continue; + }; + + offset = evnt.offset; + + mutex_lock(&astream.lock); + if(astream.count < buffsize) + { + memset(astream.buffer+astream.count, + 0, buffsize-astream.count); + astream.count = buffsize; + }; + + SetBuffer(hBuff, astream.buffer, offset, buffsize); + + { + double val = 0; + int16_t *src = (int16_t*)astream.buffer; + int samples = buffsize/2; + int i; + + for(i = 0, val = 0; i < samples/2; i++, src++) + if(val < abs(*src)) + val= abs(*src); // * *src; + + sound_level_0 = val; //sqrt(val / (samples/2)); + + for(i = 0, val = 0; i < samples/2; i++, src++) + if(val < abs(*src)) + val= abs(*src); // * *src; + + sound_level_1 = val; //sqrt(val / (samples/2)); + + // printf("%d\n", sound_level); + }; + + samples_written+= buffsize/4; + + astream.count -= buffsize; + if(astream.count) + memcpy(astream.buffer, astream.buffer+buffsize, astream.count); + mutex_unlock(&astream.lock); break; - } - }; - if((too_late == 1) || (player_state == CLOSED)) - { - too_late = 0; - continue; - }; + case PLAY_2_STOP: + if( active ) + { + ResetBuffer(hBuff, SND_RESET_ALL); + audio_base = -1.0; + active = 0; + } + sound_state = STOP; + break; - mutex_lock(&astream.lock); - SetBuffer(hBuff, astream.buffer, offset, buffsize); - samples_written+= buffsize/4; - astream.count -= buffsize; - if(astream.count) - memcpy(astream.buffer, astream.buffer+buffsize, astream.count); - mutex_unlock(&astream.lock); + case PLAY_2_PAUSE: + if( active ) + { + StopBuffer(hBuff); + }; + sound_state = PAUSE; + + case PAUSE: + case STOP: + delay(1); + }; } StopBuffer(hBuff); diff --git a/programs/media/Fplay/fplay.c b/programs/media/Fplay/fplay.c index 6bfb4e6307..68e0cf4719 100644 --- a/programs/media/Fplay/fplay.c +++ b/programs/media/Fplay/fplay.c @@ -15,7 +15,9 @@ #include "sound.h" #include "fplay.h" -volatile enum player_state player_state; +volatile enum player_state player_state = STOP; +volatile enum player_state decoder_state = PREPARE; +volatile enum player_state sound_state = STOP; uint32_t win_width, win_height; @@ -33,6 +35,8 @@ int audioStream; int have_sound = 0; uint8_t *decoder_buffer; +extern int resampler_size; + extern int sample_rate; char *movie_file; @@ -58,7 +62,7 @@ int main( int argc, char *argv[]) { int i; - if(argc < 2) { + if(argc < 2) { printf("Please provide a movie file\n"); return -1; } @@ -66,7 +70,7 @@ int main( int argc, char *argv[]) movie_file = argv[1]; /* register all codecs, demux and protocols */ -// av_log_set_level(AV_LOG_INFO); + av_log_set_level(AV_LOG_FATAL); avcodec_register_all(); avdevice_register_all(); @@ -93,7 +97,7 @@ int main( int argc, char *argv[]) // stream_duration = 1000.0 * pFormatCtx->duration * av_q2d(AV_TIME_BASE_Q); stream_duration = pFormatCtx->duration; - + printf("duration %f\n", (double)stream_duration); // Find the first video stream videoStream=-1; @@ -112,7 +116,7 @@ int main( int argc, char *argv[]) // pFormatCtx->streams[i]->duration * // av_q2d(pFormatCtx->streams[i]->time_base); stream_duration = pFormatCtx->streams[i]->duration; - + } if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO && audioStream < 0) @@ -133,9 +137,7 @@ int main( int argc, char *argv[]) return -1; // Didn't find a video stream } - player_state = PLAY_INIT; - - // __asm__ __volatile__("int3"); + // __asm__ __volatile__("int3"); // Get a pointer to the codec context for the video stream pCodecCtx=pFormatCtx->streams[videoStream]->codec; @@ -232,153 +234,177 @@ int main( int argc, char *argv[]) } +static int load_frame() +{ + AVPacket packet; + int err; + + err = av_read_frame(pFormatCtx, &packet); + if( err == 0) + { + if(packet.stream_index==videoStream) + put_packet(&q_video, &packet); + else if( (packet.stream_index == audioStream) && + (have_sound != 0) ) + { + put_packet(&q_audio, &packet); + if(audio_base == -1.0) + { + if (packet.pts != AV_NOPTS_VALUE) + audio_base = get_audio_base() * packet.pts; +// printf("audio base %f\n", audio_base); + }; + } + else av_free_packet(&packet); + } + else if (err != AVERROR_EOF) + printf("av_read_frame: error %x\n", err); + + return err; +} + + + static int fill_queue() { - int eof = 0; + int err = 0; AVPacket packet; - while( !eof) - { - int err; - // __asm__ __volatile__("int3"); - if(q_video.size+q_audio.size < 2*1024*1024) - { - err = av_read_frame(pFormatCtx, &packet); - if( err < 0) - { - eof = 1; - if (err != AVERROR_EOF) - printf("av_read_frame: error %x\n", err); - break; - } - if(packet.stream_index==videoStream) - { - put_packet(&q_video, &packet); - } - else if( (packet.stream_index == audioStream) && - (have_sound != 0) ) - { - put_packet(&q_audio, &packet); - if(audio_base == -1.0) - { - if (packet.dts != AV_NOPTS_VALUE) - audio_base = get_audio_base() * packet.dts; -// printf("audio base %f\n", audio_base); - }; - } - else - { - av_free_packet(&packet); - }; - } - else break; - }; + while( (q_video.size+q_audio.size < 2*1024*1024) && + !err ) + err = load_frame(); - return eof; + return err; }; +static void flush_all() +{ + AVPacket packet; + + avcodec_flush_buffers(pCodecCtx); + avcodec_flush_buffers(aCodecCtx); + while( get_packet(&q_video, &packet) != 0) + av_free_packet(&packet); + + while( get_packet(&q_audio, &packet)!= 0) + av_free_packet(&packet); + + flush_video(); + + astream.count = 0; +}; + void decoder() { int eof; AVPacket packet; int ret; + int64_t min_pos, max_pos; - eof = fill_queue(); - - while( player_state != CLOSED && !eof) + while( player_state != CLOSED ) { int err; // __asm__ __volatile__("int3"); - if( player_state == PAUSE ) + switch(decoder_state) { - delay(1); - continue; - }; + case PREPARE: + eof = fill_queue(); - if( player_state == REWIND ) - { - // int64_t timestamp = 0; - // int stream_index = av_find_default_stream_index(pFormatCtx); + do + { + if( (q_video.size+q_audio.size < 4*1024*1024) && + (eof == 0) ) + { + eof = load_frame(); + } + decode_video(pCodecCtx, &q_video); + ret = decode_audio(aCodecCtx, &q_audio); + }while(astream.count < resampler_size*2 && + ret == 1); - // __asm__ __volatile__("int3"); + sound_state = PREPARE; + decoder_state = PLAY; + player_state = PLAY; - if (pFormatCtx->start_time != AV_NOPTS_VALUE) - rewind_pos += pFormatCtx->start_time; + case PLAY: + if( (q_video.size+q_audio.size < 4*1024*1024) && + (eof == 0) ) + { + eof = load_frame(); + if(eof) printf("eof\n"); + } + ret = decode_video(pCodecCtx, &q_video); + ret|= decode_audio(aCodecCtx, &q_audio); - printf("rewind %8"PRId64"\n", rewind_pos); - - ret = avformat_seek_file(pFormatCtx, -1, INT64_MIN, - rewind_pos, INT64_MAX, 0); -// ret = avformat_seek_file(pFormatCtx, -1, 0, -// 0, INT64_MAX, 0); + if( eof && !ret) + { + decoder_state = STOP; +// printf("stop decoder\n"); + }; + + case STOP: + delay(1); + break; + + case PLAY_2_STOP: + while(sound_state != STOP) + delay(1); + + flush_all(); + + if (pFormatCtx->start_time != AV_NOPTS_VALUE) + rewind_pos = pFormatCtx->start_time; + else + rewind_pos = 0; + + ret = avformat_seek_file(pFormatCtx, -1, INT64_MIN, + rewind_pos, INT64_MAX, 0); + + decoder_state = STOP; + break; + + case REWIND: + while(sound_state != STOP) + yield(); + + flush_all(); + int opts = 0; + if(rewind_pos < 0) + { + rewind_pos = -rewind_pos; + opts = AVSEEK_FLAG_BACKWARD; + }; + + if (pFormatCtx->start_time != AV_NOPTS_VALUE) + rewind_pos += pFormatCtx->start_time; + +// printf("rewind %8"PRId64"\n", rewind_pos); + min_pos = rewind_pos - 1000000; + max_pos = rewind_pos + 1000000; + + ret = avformat_seek_file(pFormatCtx, -1, INT64_MIN, + rewind_pos, INT64_MAX, 0); + +// ret = avformat_seek_file(pFormatCtx, -1, min_pos, +// rewind_pos, max_pos, opts); // __asm__ __volatile__("int3"); - if (ret < 0) - { - printf("could not seek to position %f\n", - (double)rewind_pos / AV_TIME_BASE); - } - else - { - avcodec_flush_buffers(pCodecCtx); - avcodec_flush_buffers(aCodecCtx); + if (ret < 0) + { + printf("could not seek to position %f\n", + (double)rewind_pos / AV_TIME_BASE); + } - while( get_packet(&q_video, &packet) != 0) - av_free_packet(&packet); - - while( get_packet(&q_audio, &packet)!= 0) - av_free_packet(&packet); - audio_base = -1.0; - - // __asm__ __volatile__("int3"); - - eof = fill_queue(); - }; - yield(); - - flush_video(); - - player_state = REWIND_2_PLAY; - printf("restart\n"); - continue; - }; - - if(q_video.size+q_audio.size < 4*1024*1024) - { - err = av_read_frame(pFormatCtx, &packet); - if( err < 0) - { - eof = 1; - if (err != AVERROR_EOF) - printf("av_read_frame: error %x\n", err); - continue; - } - if(packet.stream_index==videoStream) - { - put_packet(&q_video, &packet); - } - else if( (packet.stream_index == audioStream) && - (have_sound != 0) ) - { - put_packet(&q_audio, &packet); - } - else - { - av_free_packet(&packet); - }; - decode_video(pCodecCtx, &q_video); - decode_audio(aCodecCtx, &q_audio); - continue; - }; - decode_video(pCodecCtx, &q_video); - decode_audio(aCodecCtx, &q_audio); - delay(1); +// printf("restart\n"); + decoder_state = PREPARE; + break; + } }; ret = 1; diff --git a/programs/media/Fplay/fplay.h b/programs/media/Fplay/fplay.h index e7d9f725c6..52d49e5fad 100644 --- a/programs/media/Fplay/fplay.h +++ b/programs/media/Fplay/fplay.h @@ -39,10 +39,10 @@ struct render uint32_t layout; bitmap_t bitmap[4]; bitmap_t *last_bitmap; - + uint32_t ctx_format; int target; - + window_t *win; enum{ EMPTY, INIT }state; @@ -52,13 +52,25 @@ struct render }; enum player_state -{ CLOSED=0,PLAY_INIT, - STOP, PAUSE, PLAY, REWIND, - PAUSE_2_PLAY, REWIND_2_PLAY +{ + CLOSED = 0, + PREPARE, + STOP, + PAUSE, + PLAY, + REWIND, + PLAY_2_STOP, + PLAY_2_PAUSE, + PAUSE_2_PLAY, + REWIND_2_PLAY, }; -#define ID_PLAY 100 -#define ID_PROGRESS 101 +#define ID_PLAY 100 +#define ID_STOP 101 +#define ID_PROGRESS 102 +#define ID_VOL_LEVEL 103 +#define ID_VOL_CTRL 104 + typedef struct { volatile uint32_t lock; @@ -112,6 +124,7 @@ void render_draw_client(render_t *render); int init_audio(int format); int audio_thread(void *param); +void set_audio_volume(int left, int right); int init_video(AVCodecContext *ctx); int video_thread(void *param); @@ -178,4 +191,4 @@ int resize_bitmap(bitmap_t *bitmap); int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y, int w, int h); - +int init_fontlib(); diff --git a/programs/media/Fplay/pixlib2.c b/programs/media/Fplay/pixlib2.c index 3785f644b5..01f199446f 100644 --- a/programs/media/Fplay/pixlib2.c +++ b/programs/media/Fplay/pixlib2.c @@ -1,29 +1,71 @@ #include -#include -#include -#include +//#include +//#include +//#include #include -#include +//#include #include "../winlib/winlib.h" -#include "fplay.h" +//#include "fplay.h" +#include "system.h" + +typedef struct +{ + uint32_t width; + uint32_t height; + uint32_t pitch; + uint32_t handle; + uint8_t *data; +}bitmap_t; + #define DISPLAY_VERSION 0x0200 /* 2.00 */ #define SRV_GETVERSION 0 #define SRV_GET_CAPS 3 -#define SRV_CREATE_SURFACE 10 -#define SRV_LOCK_SURFACE 12 - -#define SRV_BLIT_VIDEO 20 +#define SRV_CREATE_SURFACE 10 +#define SRV_DESTROY_SURFACE 11 +#define SRV_LOCK_SURFACE 12 +#define SRV_UNLOCK_SURFACE 13 +#define SRV_RESIZE_SURFACE 14 +#define SRV_BLIT_BITMAP 15 +#define SRV_BLIT_TEXTURE 16 +#define SRV_BLIT_VIDEO 17 #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) -//void InitPixlib(uint32_t flags); + +#define HW_BIT_BLIT (1<<0) /* BGRX blitter */ +#define HW_TEX_BLIT (1<<1) /* stretch blit */ +#define HW_VID_BLIT (1<<2) /* planar and packed video */ + +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); + + static uint32_t service; static uint32_t blit_caps; +static uint32_t screen_width; +static uint32_t screen_height; + +typedef struct +{ + unsigned handle; + unsigned io_code; + void *input; + int inp_size; + void *output; + int out_size; +}ioctl_t; + + typedef struct { @@ -38,6 +80,17 @@ typedef struct }; }hwcaps_t; +static inline uint32_t GetScreenSize() +{ + uint32_t retval; + + __asm__ __volatile__( + "int $0x40" + :"=a"(retval) + :"a"(61), "b"(1)); + return retval; +} + static uint32_t get_service(char *name) { uint32_t retval = 0; @@ -68,11 +121,16 @@ static int call_service(ioctl_t *io) uint32_t InitPixlib(uint32_t caps) { uint32_t api_version; - hwcaps_t hwcaps; - ioctl_t io; + uint32_t screensize; + hwcaps_t hwcaps; + ioctl_t io; // __asm__ __volatile__("int3"); + screensize = GetScreenSize(); + screen_width = screensize >> 16; + screen_height = screensize & 0xFFFF; + service = get_service("DISPLAY"); if(service == 0) goto fail; @@ -153,8 +211,8 @@ int create_bitmap(bitmap_t *bitmap) io_10.width = bitmap->width; io_10.height = bitmap->height; - io_10.max_width = 0; - io_10.max_height = 0; + io_10.max_width = screen_width; + io_10.max_height = screen_height; io_10.format = 0; io.handle = service; @@ -201,22 +259,19 @@ int create_bitmap(bitmap_t *bitmap) int lock_bitmap(bitmap_t *bitmap) { // __asm__ __volatile__("int3"); + int err = 0; if( blit_caps & HW_BIT_BLIT ) { - struct __attribute__((packed)) /* SRV_CREATE_SURFACE */ + struct __attribute__((packed)) /* SRV_LOCK_SURFACE */ { - uint32_t handle; // ignored - void *data; // ignored - - uint32_t width; - uint32_t height; - uint32_t pitch; // ignored + uint32_t handle; + void *data; + uint32_t pitch; }io_12; ioctl_t io; - int err; io_12.handle = bitmap->handle; io_12.pitch = 0; @@ -225,7 +280,7 @@ int lock_bitmap(bitmap_t *bitmap) io.handle = service; io.io_code = SRV_LOCK_SURFACE; io.input = &io_12; - io.inp_size = BUFFER_SIZE(5); + io.inp_size = BUFFER_SIZE(3); io.output = NULL; io.out_size = 0; @@ -236,33 +291,16 @@ int lock_bitmap(bitmap_t *bitmap) 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; - int dsty; - int w; - int h; - - int srcx; - int srcy; - int srcw; - int srch; - - unsigned char *bitmap; - int stride; + return err; }; int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y, int w, int h) { + int err; if( blit_caps & HW_BIT_BLIT ) { @@ -280,22 +318,21 @@ int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y, int src_y; uint32_t w; uint32_t h; - }io_20; + }io_15; ioctl_t io; - int err; - io_20.handle = bitmap->handle; - io_20.dst_x = dst_x; - io_20.dst_y = dst_y; - io_20.src_x = 0; - io_20.src_y = 0; - io_20.w = w; - io_20.h = h; + io_15.handle = bitmap->handle; + io_15.dst_x = dst_x; + io_15.dst_y = dst_y; + io_15.src_x = 0; + io_15.src_y = 0; + io_15.w = w; + io_15.h = h; io.handle = service; - io.io_code = SRV_BLIT_VIDEO; - io.input = &io_20; + io.io_code = SRV_BLIT_BITMAP; + io.input = &io_15; io.inp_size = BUFFER_SIZE(7); io.output = NULL; io.out_size = 0; @@ -303,17 +340,10 @@ int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y, // printf("do blit %x pitch %d\n",bitmap->handle, // bitmap->pitch); err = call_service(&io); - if (call_service(&io)==0) - { - //bitmap->data = NULL; Not now, Serge -// printf("blit done\n"); -// delay(1); - return 0; - }; return err; }; - volatile struct blit_call bc; + struct blit_call bc; bc.dstx = dst_x; bc.dsty = dst_y; @@ -328,32 +358,49 @@ int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y, __asm__ __volatile__( "int $0x40" - ::"a"(73),"b"(0x00),"c"(&bc) + :"=a"(err) + :"a"(73),"b"(0x00),"c"(&bc) :"memory"); - - return 0; + + return err; }; - -static inline void* user_realloc(void *mem, size_t size) -{ - void *val; - __asm__ __volatile__( - "int $0x40" - :"=a"(val) - :"a"(68),"b"(20),"c"(size),"d"(mem) - :"memory"); - - return val; -} - int resize_bitmap(bitmap_t *bitmap) { // __asm__ __volatile__("int3"); if( blit_caps & HW_BIT_BLIT ) { - /* work in progress */ + struct __attribute__((packed)) + { + uint32_t handle; + char *data; + uint32_t new_w; + uint32_t new_h; + uint32_t pitch; + }io_14; + + ioctl_t io; + int err; + + io_14.handle = bitmap->handle; + io_14.new_w = bitmap->width; + io_14.new_h = bitmap->height; + + io.handle = service; + io.io_code = SRV_RESIZE_SURFACE; + io.input = &io_14; + io.inp_size = BUFFER_SIZE(5); + io.output = NULL; + io.out_size = 0; + + err = call_service(&io); + if(err==0) + { + bitmap->pitch = io_14.pitch; + bitmap->data = io_14.data; + }; + return err; }; uint32_t size; diff --git a/programs/media/Fplay/sound.h b/programs/media/Fplay/sound.h index fbbeabd2e1..1ef9973592 100644 --- a/programs/media/Fplay/sound.h +++ b/programs/media/Fplay/sound.h @@ -74,6 +74,7 @@ extern "C" #define SND_SETTIMEBASE 18 #define SND_GETTIMESTAMP 19 +#define SND_RESET_ALL 3 #define PLAY_SYNC 0x80000000 diff --git a/programs/media/Fplay/system.h b/programs/media/Fplay/system.h index f2437c0388..6ea887fd92 100644 --- a/programs/media/Fplay/system.h +++ b/programs/media/Fplay/system.h @@ -264,6 +264,18 @@ uint32_t set_cursor(uint32_t cursor) return old; } +static inline +int destroy_cursor(uint32_t cursor) +{ + int ret; + __asm__ __volatile__( + "int $0x40" + :"=a"(ret) + :"a"(37), "b"(6), "c"(cursor) + :"memory"); + return ret; +}; + static inline void get_proc_info(char *info) { __asm__ __volatile__( @@ -279,7 +291,7 @@ void* user_realloc(void *mem, size_t size) __asm__ __volatile__( "int $0x40" :"=a"(val) - :"a"(68),"b"(12),"c"(size),"d"(mem) + :"a"(68),"b"(20),"c"(size),"d"(mem) :"memory"); return val; diff --git a/programs/media/Fplay/utils.c b/programs/media/Fplay/utils.c index 9e5b55f3a5..7f9b183fa6 100644 --- a/programs/media/Fplay/utils.c +++ b/programs/media/Fplay/utils.c @@ -46,8 +46,8 @@ int put_packet(queue_t *q, AVPacket *pkt) AVPacketList *q_pkt; /* duplicate the packet */ - if (av_dup_packet(pkt) < 0) - return -1; +// if (av_dup_packet(pkt) < 0) +// return -1; q_pkt = av_malloc(sizeof(AVPacketList)); if (!q_pkt) diff --git a/programs/media/Fplay/video.c b/programs/media/Fplay/video.c index 1006a5dbd8..70c3699627 100644 --- a/programs/media/Fplay/video.c +++ b/programs/media/Fplay/video.c @@ -8,8 +8,7 @@ #include "../winlib/winlib.h" #include "sound.h" #include "fplay.h" - -#define CAPTION_HEIGHT 24 +#include extern int res_pause_btn[]; extern int res_pause_btn_pressed[]; @@ -18,6 +17,8 @@ extern int res_play_btn[]; extern int res_play_btn_pressed[]; extern int64_t stream_duration; +extern volatile int sound_level_0; +extern volatile int sound_level_1; typedef struct { @@ -27,6 +28,7 @@ typedef struct }vframe_t; vframe_t frames[4]; +volatile int frames_count = 0; struct SwsContext *cvt_ctx = NULL; @@ -50,10 +52,11 @@ void flush_video() int i; for(i = 0; i < 4; i++) - { + { frames[i].pts = 0; frames[i].ready = 0; }; + frames_count = 0; vfx = 0; dfx = 0; }; @@ -65,16 +68,12 @@ int init_video(AVCodecContext *ctx) width = ctx->width; height = ctx->height; - - printf("w = %d h = %d\n\r", width, height); + printf("w = %d h = %d\n\r", ctx->width, ctx->height); // __asm__ __volatile__("int3"); main_render = create_render(ctx->width, ctx->height, ctx->pix_fmt, HW_BIT_BLIT|HW_TEX_BLIT); -// render = create_render(ctx->width, ctx->height, -// ctx->pix_fmt, 0); -// if( main_render == NULL) { printf("Cannot create render\n\r"); @@ -121,11 +120,12 @@ int decode_video(AVCodecContext *ctx, queue_t *qv) double current_clock; if(frames[dfx].ready != 0 ) - return 1; + return -1; if( get_packet(qv, &pkt) == 0 ) return 0; +/* current_clock = -90.0 + get_master_clock(); if( pkt.dts == AV_NOPTS_VALUE && @@ -135,10 +135,10 @@ int decode_video(AVCodecContext *ctx, queue_t *qv) pts= pkt.dts; else pts= 0; - - - pts *= av_q2d(video_time_base)*1000.0; + + pts *= av_q2d(video_time_base)*1000.0; +*/ if( 1 /*pts > current_clock*/) { frameFinished = 0; @@ -181,6 +181,7 @@ int decode_video(AVCodecContext *ctx, queue_t *qv) dfx++; dfx&= 3; + frames_count++; }; }; av_free_packet(&pkt); @@ -189,10 +190,35 @@ int decode_video(AVCodecContext *ctx, queue_t *qv) } extern volatile enum player_state player_state; +extern volatile enum player_state decoder_state; +extern volatile enum player_state sound_state; + //rect_t win_rect; extern int64_t rewind_pos; +static void player_stop() +{ + window_t *win; + + win = main_render->win; + + rewind_pos = 0; + + win->panel.play_btn->img_default = res_play_btn; + win->panel.play_btn->img_hilite = res_play_btn; + win->panel.play_btn->img_pressed = res_play_btn_pressed; + win->panel.prg->current = rewind_pos; + + send_message(&win->panel.ctrl, MSG_PAINT, 0, 0); + player_state = STOP; + decoder_state = PLAY_2_STOP; + sound_state = PLAY_2_STOP; + render_draw_client(main_render); +// printf("stop player\n"); + +}; + int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) { window_t *win; @@ -211,13 +237,15 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) break; case MSG_LBTNDOWN: + if(player_state == PAUSE) { win->panel.play_btn->img_default = res_pause_btn; win->panel.play_btn->img_hilite = res_pause_btn; win->panel.play_btn->img_pressed = res_pause_btn_pressed; - send_message(win->panel.play_btn, MSG_PAINT, 0, 0); - player_state = PAUSE_2_PLAY; + send_message(&win->panel.play_btn->ctrl, MSG_PAINT, 0, 0); + player_state = PLAY; + sound_state = PAUSE_2_PLAY; } else if(player_state == PLAY) @@ -225,8 +253,9 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) win->panel.play_btn->img_default = res_play_btn; win->panel.play_btn->img_hilite = res_play_btn; win->panel.play_btn->img_pressed = res_play_btn_pressed; - send_message(win->panel.play_btn, MSG_PAINT, 0, 0); + send_message(&win->panel.play_btn->ctrl, MSG_PAINT, 0, 0); player_state = PAUSE; + sound_state = PLAY_2_PAUSE; } break; @@ -239,7 +268,8 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) win->panel.play_btn->img_default = res_pause_btn; win->panel.play_btn->img_hilite = res_pause_btn; win->panel.play_btn->img_pressed = res_pause_btn_pressed; - player_state = PAUSE_2_PLAY; + player_state = PLAY; + sound_state = PAUSE_2_PLAY; } else if(player_state == PLAY) { @@ -247,24 +277,66 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) win->panel.play_btn->img_hilite = res_play_btn; win->panel.play_btn->img_pressed = res_play_btn_pressed; player_state = PAUSE; + sound_state = PLAY_2_PAUSE; + } + else if(player_state == STOP) + { + win->panel.play_btn->img_default = res_pause_btn; + win->panel.play_btn->img_hilite = res_pause_btn; + win->panel.play_btn->img_pressed = res_pause_btn_pressed; + rewind_pos = 0; + send_message(&win->panel.ctrl, MSG_PAINT, 0, 0); + player_state = PLAY; + decoder_state = PREPARE; } break; - case 101: //ID_PROGRESS: + case ID_STOP: + player_stop(); + break; + + case ID_PROGRESS: if(player_state != REWIND) { progress_t *prg = (progress_t*)arg2; - - rewind_pos = (int64_t)prg->pos * - (prg->max - prg->min)/prg->ctrl.w; - -// printf("progress action %f\n", (double)rewind_pos); - player_state = REWIND; - main_render->win->panel.prg->current = rewind_pos; - send_message(&main_render->win->panel.ctrl, MSG_PAINT, 0, 0); + + rewind_pos = (prg->max - prg->min)*prg->pos/prg->ctrl.w; + +// printf("progress action pos: %d time: %f\n", prg->pos, (double)rewind_pos); + player_state = REWIND; + decoder_state = REWIND; + sound_state = PLAY_2_STOP; + if(rewind_pos < prg->current) + { + prg->current = rewind_pos; + rewind_pos = -rewind_pos; + } + else + prg->current = rewind_pos; + + win->panel.play_btn->img_default = res_pause_btn; + win->panel.play_btn->img_hilite = res_pause_btn; + win->panel.play_btn->img_pressed = res_pause_btn_pressed; + send_message(&prg->ctrl, MSG_PAINT, 0, 0); }; break; - + + case ID_VOL_CTRL: + { + slider_t *sld = (slider_t*)arg2; + int peak; + int level; + + peak = sld->min + sld->pos * (sld->max - sld->min)/(96); +// level = (log2(peak+16384)*10000.0)/15 - 10000; + level = peak; + +// printf("level %d\n", level); + set_audio_volume(level, level); + send_message(&sld->ctrl, MSG_PAINT, 0, 0); + win->panel.lvl->vol = level; + } + default: break; } @@ -280,8 +352,11 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) void render_time(render_t *render) { - double ctime; /* milliseconds */ - double fdelay; /* milliseconds */ + progress_t *prg = main_render->win->panel.prg; + level_t *lvl = main_render->win->panel.lvl; + + double ctime; /* milliseconds */ + double fdelay; /* milliseconds */ //again: @@ -290,12 +365,23 @@ void render_time(render_t *render) render->win->win_command = WIN_CLOSED; return; } + else if(player_state == REWIND) + { + yield(); + return; + } + else if (decoder_state == STOP && frames_count == 0 && + player_state != STOP) + { + player_stop(); + } else if(player_state != PLAY) { yield(); return; }; + #ifdef VERSION_A if(frames[vfx].ready == 1 ) { @@ -324,8 +410,16 @@ void render_time(render_t *render) // sys_time*10, frames[vfx].pts, ctime, fdelay); main_render->draw(main_render, &frames[vfx].picture); - main_render->win->panel.prg->current = frames[vfx].pts*1000; - send_message(&render->win->panel.prg->ctrl, MSG_PAINT, 0, 0); + prg->current = frames[vfx].pts*1000; +// printf("current %f\n", prg->current); + lvl->current = vfx & 1 ? sound_level_1 : sound_level_0; + + send_message(&prg->ctrl, PRG_PROGRESS, 0, 0); + + if(main_render->win->panel.layout) + send_message(&lvl->ctrl, MSG_PAINT, 0, 0); + + frames_count--; frames[vfx].ready = 0; vfx++; vfx&= 3; @@ -396,8 +490,6 @@ void render_time(render_t *render) } - - extern char *movie_file; int video_thread(void *param) @@ -407,7 +499,7 @@ int video_thread(void *param) init_winlib(); MainWindow = create_window(movie_file,0, - 10,10,width,height+29+55,MainWindowProc); + 10,10,width,height+CAPTION_HEIGHT+PANEL_HEIGHT,MainWindowProc); MainWindow->panel.prg->max = stream_duration; // printf("MainWindow %x\n", MainWindow); @@ -417,11 +509,12 @@ int video_thread(void *param) show_window(MainWindow, NORMAL); render_draw_client(main_render); - player_state = PAUSE_2_PLAY; + player_state = PLAY; run_render(MainWindow, main_render); -// printf("exit thread\n"); + fini_winlib(); + player_state = CLOSED; return 0; }; @@ -473,6 +566,8 @@ int render_set_size(render_t *render, int width, int height) render->rcvideo.r = width; render->rcvideo.b = height; +// printf("render width %d height %d\n",width, height); + if( render->win_height > height ) { int yoffs; @@ -561,9 +656,12 @@ void render_adjust_size(render_t *render, window_t *win) uint32_t s, sw, sh; uint8_t state; - right = win->w; - bottom = win->h-CAPTION_HEIGHT-55; + bottom = win->h-CAPTION_HEIGHT-PANEL_HEIGHT; + + // printf("window width %d height %d\n", + // right, bottom); + render->win_state = win->win_state; if(render->win_state == MINIMIZED) @@ -579,25 +677,19 @@ void render_adjust_size(render_t *render, window_t *win) new_w = bottom*render->ctx_width/render->ctx_height; new_h = right*render->ctx_height/render->ctx_width; -// printf("new_w %d new_h %d\n", new_w, new_h); - - s = right * bottom; - sw = right * new_h; - sh = bottom * new_w; - - if( abs(s-sw) > abs(s-sh)) - new_h = bottom; - else - new_w = right; - - if(new_w < 64) + if(new_w > right) { - new_w = 64; - new_h = 64*render->ctx_height/render->ctx_width; + new_w = right; + new_h = right*render->ctx_height/render->ctx_width; + }; + if(new_h > bottom) + { + new_h = bottom; + new_w = bottom*render->ctx_width/render->ctx_height; }; render->win_width = win->w; - render->win_height = win->h-CAPTION_HEIGHT-55; + render->win_height = win->h-CAPTION_HEIGHT-PANEL_HEIGHT; render_set_size(render, new_w, new_h); }; @@ -620,8 +712,8 @@ void draw_hw_picture(render_t *render, AVPicture *picture) } else { - dst_width = render->win_width; - dst_height = render->win_height; + dst_width = render->rcvideo.r; + dst_height = render->rcvideo.b; }; cvt_ctx = sws_getCachedContext(cvt_ctx, @@ -639,7 +731,7 @@ void draw_hw_picture(render_t *render, AVPicture *picture) ret = lock_bitmap(bitmap); if( ret != 0) { - printf("Cannot lock the bitmap!\n"); + printf("Cannot lock bitmap!\n"); return ; } @@ -661,12 +753,13 @@ void draw_hw_picture(render_t *render, AVPicture *picture) blit_bitmap(bitmap, render->rcvideo.l, CAPTION_HEIGHT+render->rcvideo.t, render->rcvideo.r, render->rcvideo.b); + render->last_bitmap = bitmap; // printf("blit_bitmap\n"); - render->target++; - render->target&= 3; +// render->target++; +// render->target&= 3; } void draw_sw_picture(render_t *render, AVPicture *picture) @@ -715,14 +808,18 @@ void render_draw_client(render_t *render) render->win_state == ROLLED) return; - if((player_state == PAUSE) || - (player_state == PLAY_INIT) ) + if(player_state == PAUSE) { if(frames[vfx].ready == 1 ) main_render->draw(main_render, &frames[vfx].picture); else draw_bar(0, CAPTION_HEIGHT, render->win_width, render->rcvideo.b, 0); + } + else if( player_state == STOP ) + { + draw_bar(0, CAPTION_HEIGHT, render->win_width, + render->rcvideo.b, 0); }; if(render->layout & HAS_TOP) diff --git a/programs/media/Fplay/winlib/alevel.raw b/programs/media/Fplay/winlib/alevel.raw new file mode 100644 index 0000000000000000000000000000000000000000..bda9169bac8c0fbca557e50789fb44282a8ad4a9 GIT binary patch literal 4796 zcmeI0OK1~O6o&Jhq?shmYhFpPAVsMtVku%!sfrcG2U;<7DFs0SB8bZD6e;LRl&(rq zgb)y<3vm;uVi&q9B2ok?bfXoDSQSCK@WJmt4PG<4D1~WgLI~d~!zFzG&6#sfKA%Uv zO+y^$yY@gkU_#qxLf>mb87v`Fw4j_Ihb^RwJ1BwOuE!CWK$xbz~wU{MxPqa{+pB^W*1f zt(Td0P;+=rUif>DZO_qi)Zw}Q9tU3sT{Y}xTD7y9Co`kZ5ILmIr4YXr7v4kDA=YBw zI(O|>dd-vBYI_8|po@&{nwBc195pRA9ut|{HO#Mpmj4_ZN@7-|6jem z^ocH|#?<7T~WXSPySYw>-qJLjkY%Bg>P$7{~sG4iOsuL&dYF2)+r?i<%4 zn?{|P-EPllwfRgnw;*$RC*K3L`7CLjy+=Eob9^}t1 #include +#include #include "winlib.h" +extern int res_level[]; +extern int res_slider[]; +extern int res_vol_slider[]; +extern int res_progress_bar[]; +extern int res_prg_level[]; extern ctrl_t *mouse_capture; uint32_t main_cursor; @@ -11,6 +17,39 @@ uint32_t main_cursor; static int button_proc(ctrl_t *btn, uint32_t msg, uint32_t arg1, uint32_t arg2); static int spinbtn_proc(ctrl_t *btn, uint32_t msg, uint32_t arg1, uint32_t arg2); +ctrl_t *create_control(size_t size, int id, int x, int y, + int w, int h, ctrl_t *parent) +{ + + ctrl_t *ctrl; + + if( !parent ) + return NULL; + + ctrl = (ctrl_t*)malloc(size); + + link_initialize(&ctrl->link); + list_initialize(&ctrl->child); + + ctrl->parent = parent; + + ctrl->ctx = parent->ctx; + ctrl->id = id; + + ctrl->rc.l = x; + ctrl->rc.t = y ; + + ctrl->rc.r = x + w; + ctrl->rc.b = y + h; + + ctrl->w = w; + ctrl->h = h; + + list_append(&ctrl->link, &parent->child); + + return ctrl; +}; + button_t *create_button(char *caption, int id, int x, int y, int w, int h, ctrl_t *parent) @@ -21,29 +60,9 @@ button_t *create_button(char *caption, int id, int x, int y, if( !parent ) return NULL; - btn = (button_t*)malloc(sizeof(button_t)); - - link_initialize(&btn->link); - list_initialize(&btn->child); - - btn->handler = button_proc; - btn->parent = parent; - - btn->ctx = parent->ctx; - btn->id = id; - btn->style = 0; - - btn->rc.l = x; - btn->rc.t = y ; - - btn->rc.r = x + w; - btn->rc.b = y + h; - - btn->w = w; - btn->h = h; - + btn = (button_t*)create_control(sizeof(button_t), id, x, y, w, h, parent); + btn->ctrl.handler = button_proc; btn->state = 0; - btn->caption = caption; if( !caption ) @@ -62,8 +81,6 @@ button_t *create_button(char *caption, int id, int x, int y, btn->img_hilite = NULL; btn->img_pressed = NULL; - list_append(&btn->link, &parent->child); - return btn; }; @@ -108,10 +125,10 @@ int draw_button_cairo(button_t *btn) int i, j; int x, y; - ctx = btn->ctx; + ctx = btn->ctrl.ctx; - x = btn->rc.l - ctx->offset_x; - y = btn->rc.t - ctx->offset_y; + x = btn->ctrl.rc.l - ctx->offset_x; + y = btn->ctrl.rc.t - ctx->offset_y; pixmap = ctx->pixmap; @@ -124,12 +141,12 @@ int draw_button_cairo(button_t *btn) else if(btn->state & bHighlight) src = btn->img_hilite; - for(i=0; i < btn->h ;i++) + for(i=0; i < btn->ctrl.h ;i++) { - for(j=0; jw; j++) + for(j = 0; j < btn->ctrl.w; j++) pixmap[j] = src[j]; pixmap+= ctx->stride/4; - src+=btn->w; + src+= btn->ctrl.w; }; return 0; @@ -163,14 +180,14 @@ int button_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) case MSG_MOUSEENTER: // printf("mouse enter\n"); btn->state|= bHighlight; - send_message(btn, MSG_PAINT, 0, 0); + send_message(&btn->ctrl, MSG_PAINT, 0, 0); break; case MSG_MOUSELEAVE: // printf("mouse leave\n"); if( (ctrl_t*)btn != mouse_capture) { btn->state &= ~bHighlight; - send_message(btn, MSG_PAINT, 0, 0); + send_message(&btn->ctrl, MSG_PAINT, 0, 0); }; break; @@ -179,7 +196,7 @@ int button_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) // printf("push button\n"); capture_mouse((ctrl_t*)btn); btn->state|= bPressed; - send_message(btn, MSG_PAINT, 0, 0); + send_message(&btn->ctrl, MSG_PAINT, 0, 0); break; case MSG_LBTNUP: @@ -193,16 +210,16 @@ int button_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) x = ((pos_t)arg2).x; y = ((pos_t)arg2).y; - if( pt_in_rect( &btn->rc, x, y) ) + if( pt_in_rect( &btn->ctrl.rc, x, y) ) state = bHighlight; else state = 0; if(action) - send_message(btn->parent,MSG_COMMAND,btn->id,(int)btn); + send_message(btn->ctrl.parent,MSG_COMMAND,btn->ctrl.id,(int)btn); btn->state = state; - send_message(btn, MSG_PAINT, 0, 0); + send_message(&btn->ctrl, MSG_PAINT, 0, 0); break; case MSG_MOUSEMOVE: @@ -216,7 +233,7 @@ int button_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) if( ! (btn->state & bHighlight)) { btn->state|= bHighlight; - send_message(btn, MSG_PAINT, 0, 0); + send_message(&btn->ctrl, MSG_PAINT, 0, 0); }; if( (ctrl_t*)btn != mouse_capture) @@ -227,45 +244,63 @@ int button_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) old_state = btn->state; - if( pt_in_rect(&btn->rc, x, y) ) + if( pt_in_rect(&btn->ctrl.rc, x, y) ) btn->state |= bPressed; else btn->state &= ~bPressed; if( old_state ^ btn->state) - send_message(btn, MSG_PAINT, 0, 0); + send_message(&btn->ctrl, MSG_PAINT, 0, 0); } return 0; }; -int draw_progress(progress_t *prg) +int draw_progress(progress_t *prg, int background) { - int *pixmap, src; + int *pixmap, *src; ctx_t *ctx; int i, j; int x, y; - int len; + int len = prg->ctrl.w; ctx = prg->ctrl.ctx; x = prg->ctrl.rc.l - ctx->offset_x; y = prg->ctrl.rc.t - ctx->offset_y; + if( background ) + { + src = res_progress_bar; + + pixmap = ctx->pixmap; + pixmap+= y * ctx->stride/4 + x; + + for(i=0; i < 10; i++) + { + for(j = 0; j < len; j++) + pixmap[j] = *src; + + pixmap+= ctx->stride/4; + src++; + }; + }; + len = prg->current*prg->ctrl.w/(prg->max - prg->min); + + src = res_prg_level; + pixmap = ctx->pixmap; - - pixmap+= y*ctx->stride/4 + x; - - src = 0x32ebfb; //btn->img_default; + pixmap+= y*ctx->stride/4 + x; for(i=0; i < prg->ctrl.h ;i++) { for(j=0; j < len; j++) - pixmap[j] = src; + pixmap[j] = *src; pixmap+= ctx->stride/4; + src++; }; return 0; @@ -276,19 +311,24 @@ int prg_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) { progress_t *prg = (progress_t*)ctrl; int pos; - + switch( msg ) { case MSG_PAINT: - draw_progress(prg); + draw_progress(prg, 1); update_rect(ctrl); break; - + case MSG_LBTNDOWN: prg->pos = ((pos_t)arg2).x - ctrl->rc.l; send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); break; - + + case PRG_PROGRESS: + draw_progress(prg, 0); + update_rect(ctrl); + break; + default: break; } @@ -305,33 +345,273 @@ progress_t *create_progress(char *caption, int id, int x, int y, if( !parent ) return NULL; - prg = (progress_t*)malloc(sizeof(progress_t)); - - link_initialize(&prg->ctrl.link); - list_initialize(&prg->ctrl.child); + prg = (progress_t*)create_control(sizeof(progress_t), id, x, y, w, h, parent); prg->ctrl.handler = prg_proc; - prg->ctrl.parent = parent; - - prg->ctrl.ctx = parent->ctx; - prg->ctrl.id = id; - - prg->ctrl.rc.l = x; - prg->ctrl.rc.t = y ; - - prg->ctrl.rc.r = x + w; - prg->ctrl.rc.b = y + h; - - prg->ctrl.w = w; - prg->ctrl.h = h; prg->min = 0; prg->max = 1; prg->current = 0; prg->pos = 0; - list_append(&prg->ctrl.link, &parent->child); - return prg; }; +int draw_level(level_t *lvl) +{ + int *pixmap, *src; + ctx_t *ctx; + int i, j; + int x, y; + + int len; + double level; + + ctx = lvl->ctrl.ctx; + + x = lvl->ctrl.rc.l - ctx->offset_x; + y = lvl->ctrl.rc.t - ctx->offset_y; + + level = (log2(lvl->current+1)-7)*12 + lvl->vol/50 ; + + len = level; + + if(len < 0) + len = 0; + if(len > 96) + len = 96; + + pixmap = ctx->pixmap; + + pixmap+= y*ctx->stride/4 + x; + +// for(i=0; i < prg->ctrl.h ;i++) +// { +// for(j=0; j < len; j++) +// pixmap[j] = src; +// pixmap+= ctx->stride/4; +// }; + + src = lvl->img_level; + + for(i=0; i < 10; i++) + { + for(j = 0; j < 96; j++) + pixmap[j] = 0xFF1C1C1C; + pixmap+= ctx->stride/4; + }; + + pixmap = ctx->pixmap; + pixmap+= y*ctx->stride/4 + x; + + for(i=0; i < 10; i++) + { + for(j = 0; j < len; j++) + pixmap[j] = src[j]; + pixmap+= ctx->stride/4; + src+= 96; + }; + + return 0; +}; + + +int lvl_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) +{ + level_t *lvl = (level_t*)ctrl; +// int pos; + + switch( msg ) + { + case MSG_PAINT: + if(lvl->visible) + { + draw_level(lvl); + update_rect(ctrl); + }; + break; + +// case MSG_LBTNDOWN: +// prg->pos = ((pos_t)arg2).x - ctrl->rc.l; +// send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); +// break; + + default: + break; + } + return 0; +}; + +level_t *create_level(char *caption, int id, int x, int y, + int w, int h, ctrl_t *parent) +{ + level_t *lvl; + + if( !parent ) + return NULL; + + lvl = (level_t*)create_control(sizeof(level_t), id, x, y, w, h, parent); + lvl->ctrl.handler = lvl_proc; + + lvl->min = 0; + lvl->max = 1; + lvl->current = 0; + lvl->pos = 0; + lvl->visible = 0; + lvl->img_level = res_level; + + return lvl; +}; + + +int draw_slider(slider_t *sld) +{ + int *pixmap, *src; + ctx_t *ctx; + int i, j; + int x, y; + + int32_t len; + double level; + + ctx = sld->ctrl.ctx; + + x = sld->ctrl.rc.l - ctx->offset_x; + y = sld->ctrl.rc.t - ctx->offset_y; + + + len = 96 + 12; + + pixmap = ctx->pixmap; + pixmap+= y*ctx->stride/4 + x; + + for(i=0; i < 11; i++) + { + for(j = 0; j < len; j++) + pixmap[j] = 0xFF1C1C1C; + pixmap+= ctx->stride/4; + }; + + pixmap = ctx->pixmap; + pixmap+= (y+4)*ctx->stride/4 + x + 6; + + src = sld->img_vol_slider; + + for(i = 0; i < 4; i++) + { + for(j = 0; j < 96; j++) + pixmap[j] = src[j]; + pixmap+= ctx->stride/4; + src+= 96; + }; + + pixmap = ctx->pixmap; + pixmap+= y*ctx->stride/4 + x + sld->pos; + + src = res_slider; + + for(i = 0; i < 11; i++) + { + for(j = 0; j < 12; j++) + pixmap[j] = src[j]; + pixmap+= ctx->stride/4; + src+= 12; + }; + + return 0; +}; + + +int sld_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) +{ + slider_t *sld = (slider_t*)ctrl; + int pos; + + switch( msg ) + { + case MSG_PAINT: + draw_slider(sld); + update_rect(ctrl); + break; + + case MSG_LBTNDOWN: + capture_mouse(ctrl); + sld->mode = 1; + + pos = ((pos_t)arg2).x - ctrl->rc.l - 6; + if( pos < 0 ) + pos = 0; + else if(pos > 96) + pos = 96; + if( sld->pos != pos) + { + sld->pos = pos; + send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); + }; + break; + + case MSG_LBTNUP: + if(sld->mode) + { + release_mouse(); + sld->mode = 0; + }; + break; + + case MSG_MOUSEMOVE: + if(sld->mode) + { + pos = ((pos_t)arg2).x - ctrl->rc.l - 6; + if( pos < 0 ) + pos = 0; + else if(pos > 96) + pos = 96; + if( sld->pos != pos) + { + sld->pos = pos; +// printf("slider pos %d\n", sld->pos); + send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); + } + }; + break; + + case MSG_MOUSEENTER: + panel_set_layout(ctrl->parent, 1); +// printf("level on\n"); + break; + + case MSG_MOUSELEAVE: + panel_set_layout(ctrl->parent, 0); +// printf("level off\n"); + break; + + + default: + break; + } + return 0; +}; + + +slider_t *create_slider(char *caption, int id, int x, int y, + int w, int h, ctrl_t *parent) +{ + + slider_t *sld; + + if( !parent ) + return NULL; + + sld = (slider_t*)create_control(sizeof(slider_t), id, x, y, w, h, parent); + sld->ctrl.handler = sld_proc; + + sld->min = -5000; + sld->max = 0; + sld->current = 0; + sld->pos = 60; + sld->mode = 0; + sld->img_vol_slider = res_vol_slider; + + return sld; +}; + diff --git a/programs/media/Fplay/winlib/caption.c b/programs/media/Fplay/winlib/caption.c index 0a1859a987..4424f4c884 100644 --- a/programs/media/Fplay/winlib/caption.c +++ b/programs/media/Fplay/winlib/caption.c @@ -5,7 +5,6 @@ #include #include "winlib.h" -#define CAPTION_HEIGHT 24 #define CAPTION_CORNER_W 8 extern int res_caption_left[]; @@ -20,6 +19,8 @@ extern int res_minimize_btn[]; extern int res_minimize_btn_hl[]; extern int res_minimize_btn_pressed[]; +extern uint32_t main_cursor; + void update_caption_size(window_t *win); int caption_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2); @@ -38,6 +39,8 @@ int init_caption(window_t *win) cpt->ctrl.handler = caption_proc; cpt->ctrl.parent = (ctrl_t*)win; + cpt->text = win->caption_txt; + ctx->pixmap = user_alloc(1920*CAPTION_HEIGHT*4); if(!ctx->pixmap) { @@ -102,16 +105,26 @@ void update_caption_size(window_t *win) cpt->ctrl.h = CAPTION_HEIGHT; win->client.t = CAPTION_HEIGHT; - cpt->close_btn->rc.l = win->w - 25; - cpt->close_btn->rc.r = cpt->close_btn->rc.l + - cpt->close_btn->w; + cpt->close_btn->ctrl.rc.l = win->w - 25; + cpt->close_btn->ctrl.rc.r = cpt->close_btn->ctrl.rc.l + + cpt->close_btn->ctrl.w; - cpt->minimize_btn->rc.l = win->w - 25 - 16 - 5; - cpt->minimize_btn->rc.r = cpt->minimize_btn->rc.l + - cpt->minimize_btn->w; + cpt->minimize_btn->ctrl.rc.l = win->w - 25 - 16 - 5; + cpt->minimize_btn->ctrl.rc.r = cpt->minimize_btn->ctrl.rc.l + + cpt->minimize_btn->ctrl.w; }; +typedef struct +{ + uint32_t width; + uint32_t height; + uint32_t pitch; + uint32_t handle; + uint8_t *data; +}bitmap_t; + +extern int win_font; void draw_caption(caption_t *cpt) { @@ -157,6 +170,13 @@ void draw_caption(caption_t *cpt) src+= CAPTION_CORNER_W; }; + bitmap_t bitmap; + + bitmap.data = cpt->ctx.pixmap; + bitmap.pitch = cpt->ctx.stride; + + draw_text(&bitmap, win_font, cpt->text, 8, 18, 0xFFFFFFFF); + ctrl_t *child; child = (ctrl_t*)cpt->ctrl.child.next; @@ -193,18 +213,19 @@ int caption_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) send_message(child, msg, 0, arg2); else send_message(win->child_over, MSG_MOUSELEAVE, 0, arg2); - } - else if( child ) - send_message(child, MSG_MOUSEENTER, 0, arg2); + }; win->child_over = child; if( child ) + { + send_message(child, MSG_MOUSEENTER, 0, arg2); send_message(child,msg,0,arg2); - // else if(main_cursor != 0) - // { - // set_cursor(0); - // main_cursor = 0; - // } + } + else if(main_cursor != 0) + { + set_cursor(0); + main_cursor = 0; + } break; diff --git a/programs/media/Fplay/winlib/caption_body.raw b/programs/media/Fplay/winlib/caption_body.raw new file mode 100644 index 0000000000000000000000000000000000000000..dd7fbc2aa79293c15fc0d7846f2ce8ba15cef705 GIT binary patch literal 116 zcmZQzVEDgd?ZW?4`#S#DSC#%RFUtR4oR|GSKRf+@PDaZAjFg1`sR=RvlVT(P$47L-_hEPENrNw`5yp}9yihe literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/caption_left.raw b/programs/media/Fplay/winlib/caption_left.raw new file mode 100644 index 0000000000000000000000000000000000000000..c596475b75d3326dbe86f1b25b8b1822f93247e3 GIT binary patch literal 928 zcmeH@PfNmZ9LD!1d=WvHE>ZLcD=D!uvSFsqKXaSY={9w#Q)^mGG*ToAvM91c2eCtk zs6+4VY5Rd9ME4FI9{BQnzRz=bD2f6#C5OWSThpF>kNx|eiTB|nzTRH&`8ptfHfz<( z_!vE7IJm`AzlXc4OWbr@6F##1hwBcyt#dRRH8g5EjLI?TJt@lQ_u9BH4H(rDs---1 zO+_iM5Z*qkpwl$auvpphi#ZvZnn6L9NWWPvz&zDaE#{yp5^~uTav2edlq6hNMbvc- z#e5d3Wcg_Ua*9VrnF27O=K7|IerPxAz_I_t*ECo1KBJZ{T3Ang9R* literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/caption_right.raw b/programs/media/Fplay/winlib/caption_right.raw new file mode 100644 index 0000000000000000000000000000000000000000..a28b5e6215240a99bb57f2f00fc95ae3e97f2501 GIT binary patch literal 928 zcmeH^%Sr-a7>2zGFCu8uCW;PNNr{z_4rc0j7-z=O8RwvrI%=uKh(?M;K^8@}Xd$*} z5w+;v-e&%V6w(C*EnfKGdA|39|93bXa9D9Voh0`BJs&Sae7-*8ZS;Vf(R%|NSJL$7^?`>QU-mS^9y@09Wi3|&RFlt;Zhandler( (ctrl_t*)(ctrl), \ diff --git a/programs/media/Fplay/winlib/cptleft.raw b/programs/media/Fplay/winlib/cptleft.raw index 08b9ca05c58ecf0ac7a420d4b805c7315b06d60a..2d217a8a6d0564193207d6b7147623c75e5de058 100644 GIT binary patch delta 136 zcmYk!y9vM`6h`4oio1wl=W779uyg>ibP~-BPLc`#aD_mMuR3rRFP>uz`s}?a=L}{B u5glLi-a~7RQVLpY=)E7(jWH0lR>T+)LV$Dbkf%}#DJ96mTKo6R`+5P|D>6?2 delta 136 zcmYk!yA8k~5Cc$@;ub-o<2L|MP%;2w8psSxlATzB$`Pj&vGgj-9yF-q%ibGvPNbAT yL=Zx-Q?Iq)oP$ydIcL;b(OP3?r?qCK6oe4qy@$1yolhwxVvPJ@jKR;-@9PChK}7BV diff --git a/programs/media/Fplay/winlib/cptright.raw b/programs/media/Fplay/winlib/cptright.raw index b80e7af40e12d732f610100cda89083e3c3bb30e..f8a81df431a3d7861fd4838e068089e7fd4b9140 100644 GIT binary patch delta 66 zcmZo*YhY7gU|{$U!fb48|LyJV|4*JgnISPT5soJ+NN~XT6CGq&K +#include +#include +#include +#include +#include "font_droid.h" +#include +#include FT_FREETYPE_H + +typedef unsigned int color_t; + +typedef struct +{ + uint32_t width; + uint32_t height; + uint32_t pitch; + uint32_t handle; + uint8_t *data; +}bitmap_t; + + +void my_draw_bitmap(bitmap_t *win, FT_Bitmap *bitmap, int dstx, int dsty, int col) +{ + uint8_t *dst; + uint8_t *src, *tmpsrc; + + uint32_t *tmpdst; + int i, j; + + dst = win->data + dsty * win->pitch + dstx*4; + src = bitmap->buffer; + + for( i = 0; i < bitmap->rows; i++ ) + { + tmpdst = (uint32_t*)dst; + tmpsrc = src; + + dst+= win->pitch; + src+= bitmap->pitch; + + for( j = 0; j < bitmap->width; j++) + { + int a = *tmpsrc++; + int sr, sg, sb; + int dr, dg, db; + + if( a != 0) a++; + + db = *tmpdst & 0xFF; + dg = (*tmpdst >> 8) & 0xFF; + dr = (*tmpdst >> 16) &0xFF; + + sb = col & 0xFF; + sg = (col >> 8) & 0xFF; + sr = (col >> 16) &0xFF; + + db = (a*sb + db*(256-a))/256; + dg = (a*sg + dg*(256-a))/256; + dr = (a*sr + dr*(256-a))/256; + + *tmpdst++ = 0xFF000000|(dr<<16)|(dg<<8)|db; + }; + } +}; + + +int draw_text(bitmap_t * winbitmap, FT_Face face, char *text, int x, int y, int color) +{ + FT_UInt glyph_index; + FT_Bool use_kerning = 0; + FT_UInt previous; + + char ch; + int err = 0; + + use_kerning = FT_HAS_KERNING( face ); + previous = 0; + + x <<= 6; + + while( ch = *text++ ) + { + glyph_index = FT_Get_Char_Index( face, ch ); + + if ( use_kerning && previous && glyph_index ) + { + FT_Vector delta; + FT_Get_Kerning( face, previous, glyph_index, FT_KERNING_DEFAULT, &delta ); + x += delta.x ; + } + + err = FT_Load_Glyph( face, glyph_index, FT_LOAD_DEFAULT ); + if ( err ) + continue; + + err = FT_Render_Glyph( face->glyph, FT_RENDER_MODE_NORMAL ); + if ( err ) + continue; + + my_draw_bitmap(winbitmap, &face->glyph->bitmap, (x >> 6) + face->glyph->bitmap_left, + y - face->glyph->bitmap_top, color); + + x += face->glyph->advance.x; + previous = glyph_index; + }; + + return err; +}; + +int init_fontlib() +{ + int err; + + static FT_Library library; + FT_Face face = NULL; + + err = FT_Init_FreeType( &library ); + if ( err ) + { + printf("an error occurred during FreeType initialization\n"); + goto done; + } + + err = FT_New_Face( library, "/hd0/1/istokweb.ttf", 0, &face ); + +// err = FT_New_Memory_Face( library, pdf_font_DroidSans, 139280, 0, &face ); + if ( err == FT_Err_Unknown_File_Format ) + { + printf("font format is unsupported\n"); + goto done; + + } + else if ( err ) + { + printf("font file could not be read or broken\n"); + goto done; + + } + + err = FT_Set_Char_Size( face, 0, 12*64, 96, 96 ); +// err = FT_Set_Pixel_Sizes( face, 0, 100 ); + +done: + + return (int)face; +}; + +// draw_text(face,"/hd0/1/demo", 10, 80, 0x00000000); + diff --git a/programs/media/Fplay/winlib/frame.c b/programs/media/Fplay/winlib/frame.c index c648933b47..f2ee779974 100644 --- a/programs/media/Fplay/winlib/frame.c +++ b/programs/media/Fplay/winlib/frame.c @@ -5,7 +5,6 @@ #include #include "winlib.h" -#define CAPTION_HEIGHT 29 #define CAPTION_CORNER_W 8 #define FRAME_WIDTH 7 @@ -271,8 +270,8 @@ int frame_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) w = nrc.r - nrc.l; h = nrc.b - nrc.t; - if(w < 150) - w = 150; + if(w <310) + w = 310; if(h < 120) h = 120; diff --git a/programs/media/Fplay/winlib/minimize_btn.raw b/programs/media/Fplay/winlib/minimize_btn.raw new file mode 100644 index 0000000000..1ae3710801 --- /dev/null +++ b/programs/media/Fplay/winlib/minimize_btn.raw @@ -0,0 +1 @@ +okhokhokhokhniflgdjebhc_hb_hc_jeblgdnifokhokhokhokhlhdlhdlhdidafa]d_[d_[d_[d_[d_[d_[d_[fa]idalhdlhdlhdhdahdae`\a[Wa[Wa[Wa[Wa[Wa[Wa[Wa[Wa[Wa[Wa[We`\hdahdae`]b]Y]WS]WS]WS]WS]WS]WS]WS]WS]WS]WS]WS]WS]WSb]Ye`]`[X[UQZTPZTPZTPZTPZTPZTPZTPZTPZTPZTPZTPZTPZTP[UQ`[X[VRVPLVPLVPLVPLVPLVPLVPLVPLVPLVPLVPLVPLVPLVPLVPL[VRUOLRLHRLHRLHRLHRLHRLHRLHRLHRLHRLHRLHRLHRLHRLHRLHUOLPJFOIEOIEOIEOIEOIEOIEOIEOIEOIEOIEOIEOIEOIEOIEOIEPJF70+70+70+70+70+70+70+70+70+70+70+70+70+70+70+70+70+81,70+70+70+70+70+70+70+70+70+70+70+70+70+70+70+81,:3/70+70+70+70+70+70+70+70+70+70+70+70+70+70+70+:3/=6270+70+70+70+70+70+70+70+70+70+70+70+70+70+70+=62?9592-70+70+70+70+92-?95A;7=7270+70+70+70+=72A;7A;7A;7<6170+70+70+70+70+70+70+70+70+70+70+<61A;7A;7A;7A;7A;7=7292-70+70+70+70+70+70+70+92-=72A;7A;7A;7A;7A;7A;7A;7?95=62:3/81,70+81,:3/=62?95A;7A;7A;7A;7 \ No newline at end of file diff --git a/programs/media/Fplay/winlib/minimize_btn_pressed.raw b/programs/media/Fplay/winlib/minimize_btn_pressed.raw new file mode 100644 index 0000000000..b506725150 --- /dev/null +++ b/programs/media/Fplay/winlib/minimize_btn_pressed.raw @@ -0,0 +1 @@ +okhokhokhokhniflgdjebhc_hb_hc_jeblgdnifokhokhokhokhlhdlhdlhdidafa]d_[d_[d_[d_[d_[d_[d_[fa]idalhdlhdlhdhdahdae`\a[Wa[Wa[Wa[Wa[Wa[Wa[Wa[Wa[Wa[Wa[We`\hdahdae`]b]Y]WS]WS]WS]WS]WS]WS]WS]WS]WS]WS]WS]WS]WSb]Ye`]`[X[UQZTPZTPZTPZTPZTPZTPZTPZTPZTPZTPZTPZTPZTP[UQ`[X[VRVPLVPLVPLVPLVPLVPLVPLVPLVPLVPLVPLVPLVPLVPLVPL[VRUOLRLHRLHRLHRLHRLHRLHRLHRLHRLHRLHRLHRLHRLHRLHRLHUOLPJFOIEOIEOIEOIEOIEOIEOIEOIEOIEOIEOIEOIEOIEOIEOIEPJF70+70+70+70+70+70+70+70+70+70+70+70+70+70+70+70+70+81,70+70+70+70+70+70+70+70+70+70+70+70+70+70+70+81,:3/70+70+70+70+70+70+70+70+70+70+70+70+70+70+70+:3/=6270+70+70+70+70+70+70+70+70+70+70+70+70+70+70+=62?9592-70+70+70+70+70+70+70+70+70+70+70+70+70+92-?95A;7=7270+70+70+70+70+70+=72A;7A;7A;7<6170+70+70+70+70+70+70+70+70+70+70+<61A;7A;7A;7A;7A;7=7292-70+70+70+70+70+70+70+92-=72A;7A;7A;7A;7A;7A;7A;7?95=62:3/81,70+81,:3/=62?95A;7A;7A;7A;7 \ No newline at end of file diff --git a/programs/media/Fplay/winlib/panel.c b/programs/media/Fplay/winlib/panel.c index f56ff27cfe..6deda08d91 100644 --- a/programs/media/Fplay/winlib/panel.c +++ b/programs/media/Fplay/winlib/panel.c @@ -4,11 +4,14 @@ #include #include "winlib.h" -#define PANEL_HEIGHT 55 -#define PANEL_CORNER_W 16 +#define PANEL_CORNER_W 8 #define FRAME_WIDTH 7 -#define ID_PLAY 100 +#define ID_PLAY 100 +#define ID_STOP 101 +#define ID_PROGRESS 102 +#define ID_VOL_LEVEL 103 +#define ID_VOL_CTRL 104 extern uint32_t main_cursor; @@ -22,6 +25,9 @@ extern int res_play_btn_pressed[]; extern int res_pause_btn[]; extern int res_pause_btn_pressed[]; +extern int res_stop_btn[]; +extern int res_stop_btn_pressed[]; + //extern int res_minimize_btn[]; //extern int res_minimize_btn_hl[]; //extern int res_minimize_btn_pressed[]; @@ -34,6 +40,8 @@ int init_panel(window_t *win) { button_t *btn; progress_t *prg; + level_t *lvl; + slider_t *sld; panel_t *panel = &win->panel; ctx_t *ctx = &panel->ctx; @@ -44,6 +52,8 @@ int init_panel(window_t *win) panel->ctrl.handler = panel_proc; panel->ctrl.parent = (ctrl_t*)win; + panel->layout = 0; + ctx->pixmap = user_alloc(1920*PANEL_HEIGHT*4); if(!ctx->pixmap) { @@ -63,9 +73,23 @@ int init_panel(window_t *win) btn->img_hilite = res_pause_btn; btn->img_pressed = res_pause_btn_pressed; - prg = create_progress(NULL,101,0,4,0,8,&panel->ctrl); + btn = create_button(NULL, ID_STOP,0,19,24,24,&panel->ctrl); + panel->stop_btn = btn; + + btn->img_default = res_stop_btn; + btn->img_hilite = res_stop_btn; + btn->img_pressed = res_stop_btn_pressed; + + prg = create_progress(NULL,ID_PROGRESS,0,4,0,10,&panel->ctrl); panel->prg = prg; + lvl = create_level(NULL, ID_VOL_LEVEL, 0, 20, 96, 10, &panel->ctrl); + lvl->vol = -1875; + panel->lvl = lvl; + + sld = create_slider(NULL, ID_VOL_CTRL, 0, 20, 96+12, 12, &panel->ctrl); + panel->sld = sld; + // btn = create_button(NULL, ID_MINIMIZE,0,5,16,18,(ctrl_t*)cpt); // cpt->minimize_btn = btn; @@ -73,11 +97,60 @@ int init_panel(window_t *win) // btn->img_hilite = res_minimize_btn_hl; // btn->img_pressed = res_minimize_btn_pressed; + + update_panel_size(win); return 1; }; + +static void panel_update_layout(panel_t *panel) +{ + progress_t *prg = panel->prg; + level_t *lvl = panel->lvl; + + if(panel->layout == 0) + { + prg->ctrl.rc.l = panel->ctrl.rc.l; + prg->ctrl.rc.t = panel->ctrl.rc.t+7; + prg->ctrl.rc.r = panel->ctrl.rc.r; + prg->ctrl.rc.b = prg->ctrl.rc.t + prg->ctrl.h; + prg->ctrl.w = prg->ctrl.rc.r - prg->ctrl.rc.l; + + lvl->ctrl.rc.l = panel->ctrl.rc.l; + lvl->ctrl.rc.t = panel->ctrl.rc.t+7; + lvl->ctrl.rc.r = panel->lvl->ctrl.rc.l + panel->lvl->ctrl.w; + lvl->ctrl.rc.b = panel->lvl->ctrl.rc.t + panel->lvl->ctrl.h; + } + else + { + lvl->ctrl.rc.l = panel->ctrl.rc.l; + lvl->ctrl.rc.t = panel->ctrl.rc.t+7; + lvl->ctrl.rc.r = lvl->ctrl.rc.l + lvl->ctrl.w; + lvl->ctrl.rc.b = lvl->ctrl.rc.t + lvl->ctrl.h; + + prg->ctrl.rc.l = lvl->ctrl.rc.r; + prg->ctrl.rc.t = panel->ctrl.rc.t+7; + prg->ctrl.rc.r = panel->ctrl.rc.r; + prg->ctrl.rc.b = prg->ctrl.rc.t + prg->ctrl.h; + prg->ctrl.w = prg->ctrl.rc.r - prg->ctrl.rc.l; + }; +}; + +void panel_set_layout(panel_t *panel, int layout) +{ + panel->layout = layout; + panel->lvl->visible = layout; + + panel_update_layout(panel); + + send_message(&panel->prg->ctrl, MSG_PAINT, 0, 0); + + if(layout) + send_message(&panel->lvl->ctrl, MSG_PAINT, 0, 0); +}; + void update_panel_size(window_t *win) { panel_t *panel = &win->panel; @@ -115,25 +188,22 @@ void update_panel_size(window_t *win) panel->ctrl.h = PANEL_HEIGHT; win->client.b = win->h-PANEL_HEIGHT; - panel->play_btn->rc.l = win->w/2 - 16; - panel->play_btn->rc.t = panel->ctrl.rc.t+19; - panel->play_btn->rc.r = panel->play_btn->rc.l + panel->play_btn->w; - panel->play_btn->rc.b = panel->play_btn->rc.t + panel->play_btn->h; + panel->play_btn->ctrl.rc.l = win->w/2 - 16; + panel->play_btn->ctrl.rc.t = panel->ctrl.rc.t+19; + panel->play_btn->ctrl.rc.r = panel->play_btn->ctrl.rc.l + panel->play_btn->ctrl.w; + panel->play_btn->ctrl.rc.b = panel->play_btn->ctrl.rc.t + panel->play_btn->ctrl.h; - panel->prg->ctrl.rc.l = 8; - panel->prg->ctrl.rc.t = panel->ctrl.rc.t+7; - panel->prg->ctrl.rc.r = panel->ctrl.rc.r-8; - panel->prg->ctrl.rc.b = panel->prg->ctrl.rc.t+8; - panel->prg->ctrl.w = panel->prg->ctrl.rc.r - - panel->prg->ctrl.rc.l; + panel->stop_btn->ctrl.rc.l = win->w/2 - 44; + panel->stop_btn->ctrl.rc.t = panel->ctrl.rc.t+23; + panel->stop_btn->ctrl.rc.r = panel->stop_btn->ctrl.rc.l + panel->stop_btn->ctrl.w; + panel->stop_btn->ctrl.rc.b = panel->stop_btn->ctrl.rc.t + panel->stop_btn->ctrl.h; - panel->prg->ctrl.h = panel->prg->ctrl.rc.b - - panel->prg->ctrl.rc.t; - -// cpt->minimize_btn->rc.l = win->w - 25 - 16 - 5; -// cpt->minimize_btn->rc.r = cpt->minimize_btn->rc.l + -// cpt->minimize_btn->w; + panel->sld->ctrl.rc.l = panel->ctrl.rc.l; + panel->sld->ctrl.rc.t = panel->ctrl.rc.t+28; + panel->sld->ctrl.rc.r = panel->sld->ctrl.rc.l + panel->sld->ctrl.w; + panel->sld->ctrl.rc.b = panel->sld->ctrl.rc.t + panel->sld->ctrl.h; + panel_update_layout(panel); }; @@ -234,7 +304,9 @@ int panel_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) switch((short)arg1) { case ID_PLAY: - case 101: + case ID_STOP: + case ID_PROGRESS: + case ID_VOL_CTRL: win = get_parent_window(ctrl); send_message(win, msg, arg1, arg2); break; diff --git a/programs/media/Fplay/winlib/panel.raw b/programs/media/Fplay/winlib/panel.raw index 678ae0bbaba03e12b23da8ff19fc4ea26ff23754..de8555c9418550055ad70757713e49a5de0e132d 100644 GIT binary patch literal 220 YcmWFx4E!Gm#4<86!v-508~+Dk06E1^It|r1}h$w9}S<;^f8)0M$3oM@)27aAf|o*sUa5w07J5D ARsaA1 literal 3520 zcmeHJyADJ^6s6Fh@#>IJsYIgD_y>C5q4qTrwVzNZ{m4n; zeAjiw`BB`0dwxL>i2K`eY0TwEQ3S_vpsMO4|4@D=NrEiPcHn;hEWagR)<5#VnLqC4 zrGKP`o+|`M*by+{Ys~=@qiXJ2k!$&o|ZCiE^b99H}IHD*Dp+UXL(K}aj^E_i1 rhR;8cAJQ~M9LFpzyq{%RP*v4VXZ6-qT=^8IX+q!k=(-L~)3CH&BZ}C! diff --git a/programs/media/Fplay/winlib/panelright.raw b/programs/media/Fplay/winlib/panelright.raw index 54efe900493788bb0da31312870ffb5173f6917f..3d8a2ff3ded8f5c61cbdbf741794505bc9a945d3 100644 GIT binary patch literal 1760 zcmWFx4E!HR0hW=G`Hv0j=;-`6Ha5m82U0&OKN>!x>0>m1U@JRD%ZJhO5mrBd$_Pp@ E00VGrRsaA1 literal 3520 zcmeH~Jqm;{5QVj{Q5*j{6|}Mv!N$frXzw|!J&j=PB`hqx&s#>wk}YDgHoNRbc*JD< zV4Qi8*!Mm94=Rph+)-WEAl+e!`4-+V4DfPYSLvNt{!tWxmt|S!TvitmZ`(FJ&y(gL z;vL6<@B4qlhhYd_R6m-l)}LqTp8A(0i89Z7$23g@L4YjFl=-Tvz^f<)JosKmY2VG)>R*ciXnN_7B@T<2b&}(^-f3 zrfIOQs}i5*Im)tp{xcB2EDQF1e_3OBU5#DW;W!Sk>*`q+8-@YXG+~}+Y}>}rb9?|I CM%cFi diff --git a/programs/media/Fplay/winlib/pbar.raw b/programs/media/Fplay/winlib/pbar.raw new file mode 100644 index 0000000000000000000000000000000000000000..673aadd3ea9d75735fa8d0783b1af4bc8687f02a GIT binary patch literal 40 gcmZQzVE8X8DvE(cL`42`b94U}78d@mp`q~~0OpAdKmY&$ literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/prg_level.raw b/programs/media/Fplay/winlib/prg_level.raw new file mode 100644 index 0000000000000000000000000000000000000000..64a9bea2f1f2490d80357fc10495abdf20e19259 GIT binary patch literal 40 pcmZQzVEBLbfX@HluZ`gN-bs%C*SE3$zqo|;|Bhzn|JgnQ{{j507`Olc literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/res2.asm b/programs/media/Fplay/winlib/res2.asm index e82afa624e..b1fc8613bd 100644 --- a/programs/media/Fplay/winlib/res2.asm +++ b/programs/media/Fplay/winlib/res2.asm @@ -25,14 +25,26 @@ public _res_play_btn_pressed public _res_pause_btn public _res_pause_btn_pressed +public _res_stop_btn +public _res_stop_btn_pressed + public _res_cursor_ns public _res_cursor_we public _res_cursor_nwse public _res_cursor_nesw -section '.rdata' data readable align 16 +;public _res_logo +public _res_level +public _res_slider +public _res_vol_slider + +public _res_progress_bar +public _res_prg_level + + +section '.rdata' data readable align 16 _res_caption_left: file 'cptleft.raw' _res_caption_right: file 'cptright.raw' @@ -54,6 +66,9 @@ _res_play_btn_pressed: file 'playbp.raw' _res_pause_btn: file 'pausebtn.raw' _res_pause_btn_pressed: file 'pausebp.raw' +_res_stop_btn: file 'stopbtn.raw' +_res_stop_btn_pressed: file 'stopbtnp.raw' + _res_minimize_btn: file 'minbn.raw' _res_minimize_btn_hl: file 'minbhl.raw' @@ -63,3 +78,12 @@ _res_cursor_ns: file 'size_ns.cur' _res_cursor_we: file 'size_we.cur' _res_cursor_nwse: file 'size_nwse.cur' _res_cursor_nesw: file 'size_nesw.cur' + +;_res_logo: file 'logo.raw' + +_res_level: file 'vol_level.raw' +_res_vol_slider: file 'vol_slider.raw' +_res_slider: file 'slider.raw' + +_res_progress_bar: file 'pbar.raw' +_res_prg_level: file 'prg_level.raw' diff --git a/programs/media/Fplay/winlib/slider.raw b/programs/media/Fplay/winlib/slider.raw new file mode 100644 index 0000000000..e7fbaccb79 --- /dev/null +++ b/programs/media/Fplay/winlib/slider.raw @@ -0,0 +1 @@ +\\\gggsss...444:::AAA!!!000...((()))---333```___333 \ No newline at end of file diff --git a/programs/media/Fplay/winlib/stopbtn.raw b/programs/media/Fplay/winlib/stopbtn.raw new file mode 100644 index 0000000000000000000000000000000000000000..2c7871dae562656f6c9697f73220b46b5cffa8ab GIT binary patch literal 2304 zcmb`INp3Ph428oy&+|Ob2n09c1RQ`REZM>t*l-tad%@7b>E zX0s{H7gniMB%Mx6I2;zg-!C5@A8PCqiG&mi1!*)IFXP|gMx)Uu9=Pny0)fEuTQC@u zd_Mo{9JyRhd_JGX!?Dxp$ZEBc&1NIp?N)8QUdwPeRQ_JypR{B$8O5a*_%4@A#RmVC zk;k;MzRE!@sRP>KJe$pAKA)>C77KCBzTr0>kF_7fquH%HIl)D1xm;H5qtQq(V$CL# ziD0&8#Rm;=q8H>Sl}ev-SY49Iq_o>@_3d`Mg7td6mu5a-6K6GGzPuX93-@BNDD`?> zYiM<3KFRAEb;xG3Pha9{wVKW{8mI#~m~r-@P)K$0o_E!1RsGNBv)pdCZ|!h6s2~2s zVexoe@u&&-rYRDM=p3_02Q|e1e!t7(@%YxR*Q@&BPaNkUl}af-dBA7h;SWAJ(abx1 ziFt>Axm?r_f8sF1XI5Q&^Z6@2Tr3BDGQQxWjXgc5m#&7N_!}J2^O);A1@7JxJZGPL|6!x~qN1AMI8LxWn7@wK`z zm;HYKiETN!r);*+f>v)1!*W+*44aj^&M@7T`_RsZ%@p5JZ{hc^2~wf?II`_N-a5g)6{@yKp17o~0-mQ^o(?>P4z>*?tk3&N9Q{ z&n0wLTQ;82AqU>WAs8151p`}}E}c%>`bP0xF2CIzI2ZK< z{pIp?PNh=mjSqu-^ZEQoz+%1p!>0#S2l7ON9;fcSSC7a){LAHH9*@UI-0ydDI-TD5 zXi#5x)C4{(#^e;ne?Fh)^?HTI?RIfl!G*m$D=u)&!KTR90EV=lXo;`vzg_S1HW}g z(O2A$tXC)}|EYP_^R4OI!aKfU6XWqXIA`u;&WKvE&)0I9nrE%*LLbiO^MEal)oNuu zP$zOBS64$U|A}w0c`ldB54JSc>viybpu>9Vg^nNO$a$%*{9Y^;wie>~PinT=Z0w!n z{@=o2j2<<1=kP&Jc%v76X4seS!C@_D a$M5}q|5u))ba;<9a)&*gPJdko_Wl7eA21C7 literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/vol_level.raw b/programs/media/Fplay/winlib/vol_level.raw new file mode 100644 index 0000000000000000000000000000000000000000..4752a5ac67a0c72ac062b555af5118c7eff1a27d GIT binary patch literal 3840 zcmeH}F$%*l3`KQ<4#jjRGPql^h29~9=L|`qz5kFSbWke`57AT;=#oEt$V1!X6MrHS z`X+=R%v`>~|MT%)@1j|zSp0+Ae9$VQIZY4iuj645(JPV`KbS&^ZeTE&&qXgret@|c}$||JKO)@HXoNUi{{$( O#lPp2vS?zoyXOy=57iO? literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/vol_slider.raw b/programs/media/Fplay/winlib/vol_slider.raw new file mode 100644 index 0000000000000000000000000000000000000000..990d1fbb0914daa120d682fc7222e360dd056e7d GIT binary patch literal 1920 zcmeIyI|=|H3`J4Dhzf!z*aU3tbpM-sGm|}xRf=0A