11,6 → 11,8 |
#include "winlib/winlib.h" |
#include "fplay.h" |
|
int fplay_blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,int w, int h); |
|
extern int res_pause_btn[]; |
extern int res_pause_btn_pressed[]; |
|
21,6 → 23,14 |
extern volatile int sound_level_0; |
extern volatile int sound_level_1; |
|
typedef struct |
{ |
AVPicture picture; |
double pts; |
volatile int ready; |
}vframe_t; |
|
vframe_t frames[4]; |
volatile int frames_count = 0; |
|
struct SwsContext *cvt_ctx = NULL; |
42,8 → 52,8 |
|
for(i = 0; i < 4; i++) |
{ |
vst->vframe[i].pts = 0; |
vst->vframe[i].ready = 0; |
frames[i].pts = 0; |
frames[i].ready = 0; |
}; |
vst->vfx = 0; |
vst->dfx = 0; |
64,6 → 74,22 |
return 0; |
}; |
|
for( i=0; i < 4; i++) |
{ |
int ret; |
|
ret = avpicture_alloc(&frames[i].picture, vst->vCtx->pix_fmt, |
vst->vCtx->width, vst->vCtx->height); |
if ( ret != 0 ) |
{ |
printf("Cannot alloc video buffer\n\r"); |
return 0; |
}; |
|
frames[i].pts = 0; |
frames[i].ready = 0; |
}; |
|
create_thread(video_thread, vst, 1024*1024); |
|
delay(50); |
77,7 → 103,7 |
int frameFinished; |
double current_clock; |
|
if(vst->vframe[vst->dfx].ready != 0 ) |
if(frames[vst->dfx].ready != 0 ) |
return -1; |
|
if( get_packet(&vst->q_video, &pkt) == 0 ) |
122,17 → 148,16 |
|
pts *= av_q2d(video_time_base); |
|
dst_pic = &vst->vframe[vst->dfx].picture; |
dst_pic = &frames[vst->dfx].picture; |
|
if(vst->hwdec == 0) |
av_image_copy(dst_pic->data, dst_pic->linesize, |
(const uint8_t**)Frame->data, |
Frame->linesize, vst->vCtx->pix_fmt, vst->vCtx->width, vst->vCtx->height); |
else |
va_convert_picture(vst, vst->vCtx->width, vst->vCtx->height, dst_pic); |
|
vst->vframe[vst->dfx].pts = pts*1000.0; |
vst->vframe[vst->dfx].ready = 1; |
frames[vst->dfx].pts = pts*1000.0; |
|
frames[vst->dfx].ready = 1; |
|
vst->dfx = (vst->dfx + 1) & 3; |
frames_count++; |
}; |
392,12 → 417,12 |
|
|
#ifdef VERSION_A |
if(vst->vframe[vst->vfx].ready == 1 ) |
if(frames[vst->vfx].ready == 1 ) |
{ |
int sys_time; |
|
ctime = get_master_clock(); |
fdelay = (vst->vframe[vst->vfx].pts - ctime); |
fdelay = (frames[vst->vfx].pts - ctime); |
|
// printf("pts %f time %f delay %f\n", |
// frames[vfx].pts, ctime, fdelay); |
409,7 → 434,7 |
}; |
#if 0 |
ctime = get_master_clock(); |
fdelay = (vst->vframe[vst->vfx].pts - ctime); |
fdelay = (frames[vst->vfx].pts - ctime); |
|
// while(fdelay > 0) |
// { |
425,14 → 450,14 |
// sys_time*10, frames[vfx].pts, ctime, fdelay); |
|
printf("pts %f time %f delay %f\n", |
vst->vframe[vst->vfx].pts, ctime, fdelay); |
frames[vfx].pts, ctime, fdelay); |
printf("video cache %d audio cache %d\n", q_video.size/1024, q_audio.size/1024); |
#endif |
|
main_render->draw(main_render, &vst->vframe[vst->vfx].picture); |
main_render->draw(main_render, &frames[vst->vfx].picture); |
if(main_render->win->win_state != FULLSCREEN) |
{ |
prg->current = vst->vframe[vst->vfx].pts*1000; |
prg->current = frames[vst->vfx].pts*1000; |
// printf("current %f\n", prg->current); |
lvl->current = vst->vfx & 1 ? sound_level_1 : sound_level_0; |
|
443,7 → 468,7 |
} |
|
frames_count--; |
vst->vframe[vst->vfx].ready = 0; |
frames[vst->vfx].ready = 0; |
vst->vfx = (vst->vfx + 1) & 3; |
} |
else delay(1); |
450,10 → 475,10 |
|
#else |
|
if(vst->vframe[vfx].ready == 1 ) |
if(frames[vfx].ready == 1 ) |
{ |
ctime = get_master_clock(); |
fdelay = (vst->vrame[vst->vfx].pts - ctime); |
fdelay = (frames[vst->vfx].pts - ctime); |
|
// printf("pts %f time %f delay %f\n", |
// frames[vfx].pts, ctime, fdelay); |
463,21 → 488,21 |
int next_vfx; |
fdelay = 0; |
next_vfx = (vst->vfx+1) & 3; |
if( vst->vrame[next_vfx].ready == 1 ) |
if( frames[next_vfx].ready == 1 ) |
{ |
if(vst->vrame[next_vfx].pts <= ctime) |
if(frames[next_vfx].pts <= ctime) |
{ |
vst->vrame[vst->vfx].ready = 0; // skip this frame |
frames[vst->vfx].ready = 0; // skip this frame |
vst->vfx = (vst->vfx + 1) & 3; |
} |
else |
{ |
if( (vst->vrame[next_vfx].pts - ctime) < |
if( (frames[next_vfx].pts - ctime) < |
( ctime - frames[vst->vfx].pts) ) |
{ |
vst->vrame[vst->vfx].ready = 0; // skip this frame |
frames[vst->vfx].ready = 0; // skip this frame |
vst->vfx = (vst->vfx + 1) & 3; |
fdelay = (vst->vrame[next_vfx].pts - ctime); |
fdelay = (frames[next_vfx].pts - ctime); |
} |
} |
}; |
487,20 → 512,20 |
{ |
int val = fdelay; |
printf("pts %f time %f delay %d\n", |
vst->vrame[vst->vfx].pts, ctime, val); |
frames[vst->vfx].pts, ctime, val); |
delay(val/10); |
}; |
|
ctime = get_master_clock(); |
fdelay = (vst->vrame[vst->vfx].pts - ctime); |
fdelay = (frames[vst->vfx].pts - ctime); |
|
printf("pts %f time %f delay %f\n", |
vst->vrame[vst->vfx].pts, ctime, fdelay); |
frames[vst->vfx].pts, ctime, fdelay); |
|
main_render->draw(main_render, &vst->vrame[vfx].picture); |
main_render->win->panel.prg->current = vst->vrame[vfx].pts; |
main_render->draw(main_render, &frames[vfx].picture); |
main_render->win->panel.prg->current = frames[vfx].pts; |
// send_message(&render->win->panel.prg->ctrl, MSG_PAINT, 0, 0); |
vst->vrame[vst->vfx].ready = 0; |
frames[vst->vfx].ready = 0; |
vst->vfx = (vst->vfx + 1) & 3; |
} |
else yield(); |
792,7 → 817,6 |
uint32_t bitmap_pitch; |
uint8_t *data[4]; |
int linesize[4]; |
enum AVPixelFormat format; |
|
if(render->win->win_state == MINIMIZED || |
render->win->win_state == ROLLED) |
809,9 → 833,8 |
dst_height = render->rcvideo.b; |
}; |
|
format = render->vst->hwdec == 0 ? render->ctx_format : AV_PIX_FMT_BGRA |
cvt_ctx = sws_getCachedContext(cvt_ctx, |
render->ctx_width, render->ctx_height, format, |
render->ctx_width, render->ctx_height, render->ctx_format, |
dst_width, dst_height, AV_PIX_FMT_BGRA, |
SWS_FAST_BILINEAR, NULL, NULL, NULL); |
if(cvt_ctx == NULL) |
937,8 → 960,8 |
|
if(player_state == PAUSE) |
{ |
if(vst->vframe[vst->vfx].ready == 1 ) |
main_render->draw(main_render, &vst->vframe[vst->vfx].picture); |
if(frames[vst->vfx].ready == 1 ) |
main_render->draw(main_render, &frames[vst->vfx].picture); |
else |
draw_bar(0, y, render->win_width, |
render->rcvideo.b, 0); |