Subversion Repositories Kolibri OS

Rev

Rev 6117 | Rev 6121 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6117 Rev 6118
Line 10... Line 10...
10
#include "winlib/winlib.h"
10
#include "winlib/winlib.h"
11
#include "fplay.h"
11
#include "fplay.h"
Line 12... Line 12...
12
 
12
 
13
int fplay_blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,int w, int h);
-
 
Line 14... Line 13...
14
void draw_va_picture(render_t *render, AVPicture *picture);
13
int fplay_blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,int w, int h);
15
 
14
 
Line 16... Line 15...
16
extern int res_pause_btn[];
15
extern int res_pause_btn[];
Line 34... Line 33...
34
volatile int      frames_count = 0;
33
volatile int      frames_count = 0;
35
 
34
 
Line 36... Line 35...
36
struct SwsContext *cvt_ctx = NULL;
35
struct SwsContext *cvt_ctx = NULL;
Line 37... Line -...
37
 
-
 
38
int vfx    = 0;
-
 
Line 39... Line 36...
39
int dfx    = 0;
36
 
Line 40... Line 37...
40
 
37
 
41
render_t   *main_render;
38
render_t   *main_render;
Line 47... Line 44...
47
AVFrame  *Frame;
44
AVFrame  *Frame;
48
 
45
 
Line 49... Line 46...
49
void get_client_rect(rect_t *rc);
46
void get_client_rect(rect_t *rc);
Line 50... Line 47...
50
 
47
 
51
void flush_video()
48
void flush_video(vst_t *vst)
52
{
49
{
Line 53... Line 50...
53
    int i;
50
    int i;
54
 
51
 
55
    for(i = 0; i < 4; i++)
52
    for(i = 0; i < 4; i++)
56
    {
53
    {
57
        frames[i].pts    = 0;
54
        frames[i].pts    = 0;
-
 
55
        frames[i].ready  = 0;
-
 
56
    };
58
        frames[i].ready  = 0;
57
    vst->vfx = 0;
59
    };
-
 
60
    frames_count = 0;
-
 
61
    vfx    = 0;
58
    vst->dfx = 0;
Line 62... Line 59...
62
    dfx    = 0;
59
    frames_count = 0;
63
};
60
};
64
 
61
 
Line 104... Line 101...
104
    double     pts;
101
    double     pts;
105
    int frameFinished;
102
    int frameFinished;
106
    double current_clock;
103
    double current_clock;
107
 
104
 
Line 108... Line 105...
108
    if(frames[dfx].ready != 0 )
105
    if(frames[vst->dfx].ready != 0 )
109
        return -1;
106
        return -1;
Line 110... Line 107...
110
 
107
 
111
    if( get_packet(&vst->q_video, &pkt) == 0 )
108
    if( get_packet(&vst->q_video, &pkt) == 0 )
Line 149... Line 146...
149
                pts= 0;
146
                pts = 0;
150
 
147
 
Line 151... Line 148...
151
            pts *= av_q2d(video_time_base);
148
            pts *= av_q2d(video_time_base);
Line 152... Line 149...
152
 
149
 
Line 153... Line 150...
153
            dst_pic = &frames[dfx].picture;
150
            dst_pic = &frames[vst->dfx].picture;
154
 
151
 
155
            av_image_copy(dst_pic->data, dst_pic->linesize,
152
            av_image_copy(dst_pic->data, dst_pic->linesize,
Line 156... Line 153...
156
                      (const uint8_t**)Frame->data,
153
                      (const uint8_t**)Frame->data,
Line 157... Line 154...
157
                      Frame->linesize, vst->vCtx->pix_fmt, vst->vCtx->width, vst->vCtx->height);
154
                      Frame->linesize, vst->vCtx->pix_fmt, vst->vCtx->width, vst->vCtx->height);
Line 158... Line -...
158
 
-
 
159
            frames[dfx].pts = pts*1000.0;
155
 
160
 
156
            frames[vst->dfx].pts = pts*1000.0;
161
            frames[dfx].ready = 1;
157
 
162
 
158
            frames[vst->dfx].ready = 1;
Line 163... Line 159...
163
            dfx++;
159
 
Line 390... Line 386...
390
void render_time(render_t *render)
386
void render_time(render_t *render)
391
{
387
{
392
    progress_t  *prg = main_render->win->panel.prg;
388
    progress_t *prg = main_render->win->panel.prg;
393
    level_t     *lvl = main_render->win->panel.lvl;
389
    level_t    *lvl = main_render->win->panel.lvl;
394
 
-
 
-
 
390
    vst_t      *vst = main_render->vst;
395
    double      ctime;            /*    milliseconds    */
391
    double      ctime;            /*    milliseconds    */
396
    double      fdelay;           /*    milliseconds    */
392
    double      fdelay;           /*    milliseconds    */
Line 397... Line 393...
397
 
393
 
Line 419... Line 415...
419
    };
415
    };
420
 
416
 
Line 421... Line 417...
421
 
417
 
422
#ifdef VERSION_A
418
#ifdef VERSION_A
423
    if(frames[vfx].ready == 1 )
419
    if(frames[vst->vfx].ready == 1 )
424
    {
420
    {
Line 425... Line 421...
425
        int sys_time;
421
        int sys_time;
426
 
422
 
Line 427... Line 423...
427
        ctime = get_master_clock();
423
        ctime = get_master_clock();
428
        fdelay = (frames[vfx].pts - ctime);
424
        fdelay = (frames[vst->vfx].pts - ctime);
Line 429... Line 425...
429
 
425
 
Line 436... Line 432...
436
        //    return;
432
        //    return;
437
        };
433
        };
438
#if 0
434
#if 0
439
        ctime = get_master_clock();
435
        ctime = get_master_clock();
440
        fdelay = (frames[vfx].pts - ctime);
436
        fdelay = (frames[vst->vfx].pts - ctime);
441
 
437
 
Line 442... Line 438...
442
//        while(fdelay > 0)
438
//        while(fdelay > 0)
443
//        {
439
//        {
444
//            yield();
440
//            yield();
445
//            ctime = get_master_clock();
441
//            ctime = get_master_clock();
Line 456... Line 452...
456
                frames[vfx].pts, ctime, fdelay);
452
                frames[vfx].pts, ctime, fdelay);
457
        printf("video cache %d audio cache %d\n", q_video.size/1024, q_audio.size/1024);
453
        printf("video cache %d audio cache %d\n", q_video.size/1024, q_audio.size/1024);
458
#endif
454
#endif
459
 
455
 
Line 460... Line 456...
460
        main_render->draw(main_render, &frames[vfx].picture);
456
        main_render->draw(main_render, &frames[vst->vfx].picture);
461
        if(main_render->win->win_state != FULLSCREEN)
457
        if(main_render->win->win_state != FULLSCREEN)
462
        {
458
        {
463
            prg->current = frames[vfx].pts*1000;
459
            prg->current = frames[vst->vfx].pts*1000;
464
//        printf("current %f\n", prg->current);
460
//        printf("current %f\n", prg->current);
465
            lvl->current = vfx & 1 ? sound_level_1 : sound_level_0;
461
            lvl->current = vst->vfx & 1 ? sound_level_1 : sound_level_0;
Line 466... Line 462...
466
 
462
 
Line 467... Line 463...
467
            send_message(&prg->ctrl, PRG_PROGRESS, 0, 0);
463
            send_message(&prg->ctrl, PRG_PROGRESS, 0, 0);
468
 
464
 
469
            if(main_render->win->panel.layout)
465
            if(main_render->win->panel.layout)
Line 470... Line 466...
470
                send_message(&lvl->ctrl, MSG_PAINT, 0, 0);
466
                send_message(&lvl->ctrl, MSG_PAINT, 0, 0);
471
        }
467
        }
472
 
-
 
473
        frames_count--;
468
 
474
        frames[vfx].ready = 0;
469
        frames_count--;
475
        vfx++;
470
        frames[vst->vfx].ready = 0;
Line 476... Line 471...
476
        vfx&= 3;
471
        vst->vfx = (vst->vfx + 1) & 3;
Line 477... Line 472...
477
    }
472
    }
478
    else delay(1);
473
    else delay(1);
479
 
474
 
480
#else
475
#else
Line 481... Line 476...
481
 
476
 
482
    if(frames[vfx].ready == 1 )
477
    if(frames[vfx].ready == 1 )
Line 483... Line 478...
483
    {
478
    {
484
        ctime = get_master_clock();
479
        ctime = get_master_clock();
485
        fdelay = (frames[vfx].pts - ctime);
480
        fdelay = (frames[vst->vfx].pts - ctime);
486
 
481
 
487
//            printf("pts %f time %f delay %f\n",
482
//            printf("pts %f time %f delay %f\n",
488
//                    frames[vfx].pts, ctime, fdelay);
483
//                    frames[vfx].pts, ctime, fdelay);
489
 
484
 
490
        if(fdelay < 0.0 )
485
        if(fdelay < 0.0 )
491
        {
486
        {
492
            int  next_vfx;
487
            int  next_vfx;
493
            fdelay = 0;
-
 
494
            next_vfx = (vfx+1) & 3;
488
            fdelay = 0;
495
            if( frames[next_vfx].ready == 1 )
489
            next_vfx = (vst->vfx+1) & 3;
496
            {
490
            if( frames[next_vfx].ready == 1 )
497
                if(frames[next_vfx].pts <= ctime)
491
            {
498
                {
492
                if(frames[next_vfx].pts <= ctime)
499
                    frames[vfx].ready = 0;                  // skip this frame
493
                {
500
                    vfx++;
494
                    frames[vst->vfx].ready = 0;                  // skip this frame
501
                    vfx&= 3;
495
                    vst->vfx = (vst->vfx + 1) & 3;
502
                }
-
 
503
                else
496
                }
504
                {
497
                else
505
                    if( (frames[next_vfx].pts - ctime) <
498
                {
506
                        ( ctime - frames[vfx].pts) )
499
                    if( (frames[next_vfx].pts - ctime) <
507
                    {
500
                        ( ctime - frames[vst->vfx].pts) )
508
                        frames[vfx].ready = 0;                  // skip this frame
501
                    {
Line 509... Line 502...
509
                        vfx++;
502
                        frames[vst->vfx].ready = 0;                  // skip this frame
510
                        vfx&= 3;
503
                        vst->vfx = (vst->vfx + 1) & 3;
511
                        fdelay = (frames[next_vfx].pts - ctime);
504
                        fdelay = (frames[next_vfx].pts - ctime);
512
                    }
505
                    }
513
                }
506
                }
514
            };
507
            };
515
        };
508
        };
Line 516... Line 509...
516
 
509
 
517
        if(fdelay > 10.0)
510
        if(fdelay > 10.0)
Line 518... Line 511...
518
        {
511
        {
519
           int val = fdelay;
512
           int val = fdelay;
Line 520... Line 513...
520
           printf("pts %f time %f delay %d\n",
513
           printf("pts %f time %f delay %d\n",
521
                   frames[vfx].pts, ctime, val);
514
                   frames[vst->vfx].pts, ctime, val);
522
           delay(val/10);
515
           delay(val/10);
523
        };
516
        };
524
 
-
 
525
        ctime = get_master_clock();
517
 
526
        fdelay = (frames[vfx].pts - ctime);
518
        ctime = get_master_clock();
527
 
519
        fdelay = (frames[vst->vfx].pts - ctime);
528
        printf("pts %f time %f delay %f\n",
520
 
Line 529... Line 521...
529
                frames[vfx].pts, ctime, fdelay);
521
        printf("pts %f time %f delay %f\n",
Line 953... Line 945...
953
}
945
}
954
 
946
 
Line 955... Line 947...
955
void render_draw_client(render_t *render)
947
void render_draw_client(render_t *render)
956
{
948
{
-
 
949
    vst_t *vst = render->vst;
957
    int y;
950
    int y;
Line 958... Line 951...
958
 
951
 
959
    if(render->win_state == MINIMIZED ||
952
    if(render->win_state == MINIMIZED ||
960
       render->win_state == ROLLED )
953
       render->win_state == ROLLED )
Line 965... Line 958...
965
        y = CAPTION_HEIGHT;
958
        y = CAPTION_HEIGHT;
966
 
959
 
Line 967... Line 960...
967
    if(player_state == PAUSE)
960
    if(player_state == PAUSE)
968
    {
961
    {
969
         if(frames[vfx].ready == 1 )
962
         if(frames[vst->vfx].ready == 1 )
970
            main_render->draw(main_render, &frames[vfx].picture);
963
            main_render->draw(main_render, &frames[vst->vfx].picture);
971
         else
964
         else
972
            draw_bar(0, y, render->win_width,
965
            draw_bar(0, y, render->win_width,
973
                 render->rcvideo.b, 0);
966
                 render->rcvideo.b, 0);
974
    }
967
    }
975
    else if( player_state == STOP )
968
    else if( player_state == STOP )