static void event_loop(VideoState *cur_stream)

{

    SDL_Event event;

    double incr, pos, frac;



    for (;;) {

        double x;

        refresh_loop_wait_event(cur_stream, &event);

        switch (event.type) {

        case SDL_KEYDOWN:

            if (exit_on_keydown) {

                do_exit(cur_stream);

                break;

            }

            switch (event.key.keysym.sym) {

            case SDLK_ESCAPE:

            case SDLK_q:

                do_exit(cur_stream);

                break;

            case SDLK_f:

                toggle_full_screen(cur_stream);

                cur_stream->force_refresh = 1;

                break;

            case SDLK_p:

            case SDLK_SPACE:

                toggle_pause(cur_stream);

                break;

            case SDLK_s: // S: Step to next frame

                step_to_next_frame(cur_stream);

                break;

            case SDLK_a:

                stream_cycle_channel(cur_stream, AVMEDIA_TYPE_AUDIO);

                break;

            case SDLK_v:

                stream_cycle_channel(cur_stream, AVMEDIA_TYPE_VIDEO);

                break;

            case SDLK_t:

                stream_cycle_channel(cur_stream, AVMEDIA_TYPE_SUBTITLE);

                break;

            case SDLK_w:

                toggle_audio_display(cur_stream);

                break;

            case SDLK_PAGEUP:

                incr = 600.0;

                goto do_seek;

            case SDLK_PAGEDOWN:

                incr = -600.0;

                goto do_seek;

            case SDLK_LEFT:

                incr = -10.0;

                goto do_seek;

            case SDLK_RIGHT:

                incr = 10.0;

                goto do_seek;

            case SDLK_UP:

                incr = 60.0;

                goto do_seek;

            case SDLK_DOWN:

                incr = -60.0;

            do_seek:

                    if (seek_by_bytes) {

                        if (cur_stream->video_stream >= 0 && cur_stream->video_current_pos >= 0) {

                            pos = cur_stream->video_current_pos;

                        } else if (cur_stream->audio_stream >= 0 && cur_stream->audio_pkt.pos >= 0) {

                            pos = cur_stream->audio_pkt.pos;

                        } else

                            pos = avio_tell(cur_stream->ic->pb);

                        if (cur_stream->ic->bit_rate)

                            incr *= cur_stream->ic->bit_rate / 8.0;

                        else

                            incr *= 180000.0;

                        pos += incr;

                        stream_seek(cur_stream, pos, incr, 1);

                    } else {

                        pos = get_master_clock(cur_stream);

                        if (isnan(pos))

                            pos = (double)cur_stream->seek_pos / AV_TIME_BASE;

                        pos += incr;

                        if (cur_stream->ic->start_time != AV_NOPTS_VALUE && pos < cur_stream->ic->start_time / (double)AV_TIME_BASE)

                            pos = cur_stream->ic->start_time / (double)AV_TIME_BASE;

                        stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE), (int64_t)(incr * AV_TIME_BASE), 0);

                    }

                break;

            default:

                break;

            }

            break;

        case SDL_VIDEOEXPOSE:

            cur_stream->force_refresh = 1;

            break;

        case SDL_MOUSEBUTTONDOWN:

            if (exit_on_mousedown) {

                do_exit(cur_stream);

                break;

            }

        case SDL_MOUSEMOTION:

            if (cursor_hidden) {

                SDL_ShowCursor(1);

                cursor_hidden = 0;

            }

            cursor_last_shown = av_gettime();

            if (event.type == SDL_MOUSEBUTTONDOWN) {

                x = event.button.x;

            } else {

                if (event.motion.state != SDL_PRESSED)

                    break;

                x = event.motion.x;

            }

                if (seek_by_bytes || cur_stream->ic->duration <= 0) {

                    uint64_t size =  avio_size(cur_stream->ic->pb);

                    stream_seek(cur_stream, size*x/cur_stream->width, 0, 1);

                } else {

                    int64_t ts;

                    int ns, hh, mm, ss;

                    int tns, thh, tmm, tss;

                    tns  = cur_stream->ic->duration / 1000000LL;

                    thh  = tns / 3600;

                    tmm  = (tns % 3600) / 60;

                    tss  = (tns % 60);

                    frac = x / cur_stream->width;

                    ns   = frac * tns;

                    hh   = ns / 3600;

                    mm   = (ns % 3600) / 60;

                    ss   = (ns % 60);

                    fprintf(stderr, "Seek to %2.0f%% (%2d:%02d:%02d) of total duration (%2d:%02d:%02d)       \n", frac*100,

                            hh, mm, ss, thh, tmm, tss);

                    ts = frac * cur_stream->ic->duration;

                    if (cur_stream->ic->start_time != AV_NOPTS_VALUE)

                        ts += cur_stream->ic->start_time;

                    stream_seek(cur_stream, ts, 0, 0);

                }

            break;

        case SDL_VIDEORESIZE:

                screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 0,

                                          SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL);

                screen_width  = cur_stream->width  = event.resize.w;

                screen_height = cur_stream->height = event.resize.h;

                cur_stream->force_refresh = 1;

            break;

        case SDL_QUIT:

        case FF_QUIT_EVENT:

            do_exit(cur_stream);

            break;

        case FF_ALLOC_EVENT:

            alloc_picture(event.user.data1);

            break;

        default:

            break;

        }

    }

}

static void event_loop(VideoState *cur_stream)

{

    SDL_Event event;

    double incr, pos, frac;



    for (;;) {

        double x;

        refresh_loop_wait_event(cur_stream, &event);

        switch (event.type) {

        case SDL_KEYDOWN:

            if (exit_on_keydown) {

                do_exit(cur_stream);

                break;

            }

            switch (event.key.keysym.sym) {

            case SDLK_ESCAPE:

            case SDLK_q:

                do_exit(cur_stream);

                break;

            case SDLK_f:

                toggle_full_screen(cur_stream);

                cur_stream->force_refresh = 1;

                break;

            case SDLK_p:

            case SDLK_SPACE:

                toggle_pause(cur_stream);

                break;

            case SDLK_s: 

                step_to_next_frame(cur_stream);

                break;

            case SDLK_a:

                stream_cycle_channel(cur_stream, AVMEDIA_TYPE_AUDIO);

                break;

            case SDLK_v:

                stream_cycle_channel(cur_stream, AVMEDIA_TYPE_VIDEO);

                break;

            case SDLK_t:

                stream_cycle_channel(cur_stream, AVMEDIA_TYPE_SUBTITLE);

                break;

            case SDLK_w:

                toggle_audio_display(cur_stream);

                break;

            case SDLK_PAGEUP:

                incr = 600.0;

                goto do_seek;

            case SDLK_PAGEDOWN:

                incr = -600.0;

                goto do_seek;

            case SDLK_LEFT:

                incr = -10.0;

                goto do_seek;

            case SDLK_RIGHT:

                incr = 10.0;

                goto do_seek;

            case SDLK_UP:

                incr = 60.0;

                goto do_seek;

            case SDLK_DOWN:

                incr = -60.0;

            do_seek:

                    if (seek_by_bytes) {

                        if (cur_stream->video_stream >= 0 && cur_stream->video_current_pos >= 0) {

                            pos = cur_stream->video_current_pos;

                        } else if (cur_stream->audio_stream >= 0 && cur_stream->audio_pkt.pos >= 0) {

                            pos = cur_stream->audio_pkt.pos;

                        } else

                            pos = avio_tell(cur_stream->ic->pb);

                        if (cur_stream->ic->bit_rate)

                            incr *= cur_stream->ic->bit_rate / 8.0;

                        else

                            incr *= 180000.0;

                        pos += incr;

                        stream_seek(cur_stream, pos, incr, 1);

                    } else {

                        pos = get_master_clock(cur_stream);

                        if (isnan(pos))

                            pos = (double)cur_stream->seek_pos / AV_TIME_BASE;

                        pos += incr;

                        if (cur_stream->ic->start_time != AV_NOPTS_VALUE && pos < cur_stream->ic->start_time / (double)AV_TIME_BASE)

                            pos = cur_stream->ic->start_time / (double)AV_TIME_BASE;

                        stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE), (int64_t)(incr * AV_TIME_BASE), 0);

                    }

                break;

            default:

                break;

            }

            break;

        case SDL_VIDEOEXPOSE:

            cur_stream->force_refresh = 1;

            break;

        case SDL_MOUSEBUTTONDOWN:

            if (exit_on_mousedown) {

                do_exit(cur_stream);

                break;

            }

        case SDL_MOUSEMOTION:

            if (cursor_hidden) {

                SDL_ShowCursor(1);

                cursor_hidden = 0;

            }

            cursor_last_shown = av_gettime();

            if (event.type == SDL_MOUSEBUTTONDOWN) {

                x = event.button.x;

            } else {

                if (event.motion.state != SDL_PRESSED)

                    break;

                x = event.motion.x;

            }

                if (seek_by_bytes || cur_stream->ic->duration <= 0) {

                    uint64_t size =  avio_size(cur_stream->ic->pb);

                    stream_seek(cur_stream, size*x/cur_stream->width, 0, 1);

                } else {

                    int64_t ts;

                    int ns, hh, mm, ss;

                    int tns, thh, tmm, tss;

                    tns  = cur_stream->ic->duration / 1000000LL;

                    thh  = tns / 3600;

                    tmm  = (tns % 3600) / 60;

                    tss  = (tns % 60);

                    frac = x / cur_stream->width;

                    ns   = frac * tns;

                    hh   = ns / 3600;

                    mm   = (ns % 3600) / 60;

                    ss   = (ns % 60);

                    fprintf(stderr, "Seek to %2.0f%% (%2d:%02d:%02d) of total duration (%2d:%02d:%02d)       \n", frac*100,

                            hh, mm, ss, thh, tmm, tss);

                    ts = frac * cur_stream->ic->duration;

                    if (cur_stream->ic->start_time != AV_NOPTS_VALUE)

                        ts += cur_stream->ic->start_time;

                    stream_seek(cur_stream, ts, 0, 0);

                }

            break;

        case SDL_VIDEORESIZE:

                screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 0,

                                          SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL);

                screen_width  = cur_stream->width  = event.resize.w;

                screen_height = cur_stream->height = event.resize.h;

                cur_stream->force_refresh = 1;

            break;

        case SDL_QUIT:

        case FF_QUIT_EVENT:

            do_exit(cur_stream);

            break;

        case FF_ALLOC_EVENT:

            alloc_picture(event.user.data1);

            break;

        default:

            break;

        }

    }

}

                screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 0,                 screen_width  = cur_stream->width  = event.resize.w;                 screen_height = cur_stream->height = event.resize.h;
static void FUNC_0(VideoState *VAR_0)

{

    SDL_Event event;

    double VAR_1, VAR_2, VAR_3;



    for (;;) {

        double VAR_4;

        refresh_loop_wait_event(VAR_0, &event);

        switch (event.type) {

        case SDL_KEYDOWN:

            if (exit_on_keydown) {

                do_exit(VAR_0);

                break;

            }

            switch (event.key.keysym.sym) {

            case SDLK_ESCAPE:

            case SDLK_q:

                do_exit(VAR_0);

                break;

            case SDLK_f:

                toggle_full_screen(VAR_0);

                VAR_0->force_refresh = 1;

                break;

            case SDLK_p:

            case SDLK_SPACE:

                toggle_pause(VAR_0);

                break;

            case SDLK_s: 

                step_to_next_frame(VAR_0);

                break;

            case SDLK_a:

                stream_cycle_channel(VAR_0, AVMEDIA_TYPE_AUDIO);

                break;

            case SDLK_v:

                stream_cycle_channel(VAR_0, AVMEDIA_TYPE_VIDEO);

                break;

            case SDLK_t:

                stream_cycle_channel(VAR_0, AVMEDIA_TYPE_SUBTITLE);

                break;

            case SDLK_w:

                toggle_audio_display(VAR_0);

                break;

            case SDLK_PAGEUP:

                VAR_1 = 600.0;

                goto do_seek;

            case SDLK_PAGEDOWN:

                VAR_1 = -600.0;

                goto do_seek;

            case SDLK_LEFT:

                VAR_1 = -10.0;

                goto do_seek;

            case SDLK_RIGHT:

                VAR_1 = 10.0;

                goto do_seek;

            case SDLK_UP:

                VAR_1 = 60.0;

                goto do_seek;

            case SDLK_DOWN:

                VAR_1 = -60.0;

            do_seek:

                    if (seek_by_bytes) {

                        if (VAR_0->video_stream >= 0 && VAR_0->video_current_pos >= 0) {

                            VAR_2 = VAR_0->video_current_pos;

                        } else if (VAR_0->audio_stream >= 0 && VAR_0->audio_pkt.VAR_2 >= 0) {

                            VAR_2 = VAR_0->audio_pkt.VAR_2;

                        } else

                            VAR_2 = avio_tell(VAR_0->ic->pb);

                        if (VAR_0->ic->bit_rate)

                            VAR_1 *= VAR_0->ic->bit_rate / 8.0;

                        else

                            VAR_1 *= 180000.0;

                        VAR_2 += VAR_1;

                        stream_seek(VAR_0, VAR_2, VAR_1, 1);

                    } else {

                        VAR_2 = get_master_clock(VAR_0);

                        if (isnan(VAR_2))

                            VAR_2 = (double)VAR_0->seek_pos / AV_TIME_BASE;

                        VAR_2 += VAR_1;

                        if (VAR_0->ic->start_time != AV_NOPTS_VALUE && VAR_2 < VAR_0->ic->start_time / (double)AV_TIME_BASE)

                            VAR_2 = VAR_0->ic->start_time / (double)AV_TIME_BASE;

                        stream_seek(VAR_0, (int64_t)(VAR_2 * AV_TIME_BASE), (int64_t)(VAR_1 * AV_TIME_BASE), 0);

                    }

                break;

            default:

                break;

            }

            break;

        case SDL_VIDEOEXPOSE:

            VAR_0->force_refresh = 1;

            break;

        case SDL_MOUSEBUTTONDOWN:

            if (exit_on_mousedown) {

                do_exit(VAR_0);

                break;

            }

        case SDL_MOUSEMOTION:

            if (cursor_hidden) {

                SDL_ShowCursor(1);

                cursor_hidden = 0;

            }

            cursor_last_shown = av_gettime();

            if (event.type == SDL_MOUSEBUTTONDOWN) {

                VAR_4 = event.button.VAR_4;

            } else {

                if (event.motion.state != SDL_PRESSED)

                    break;

                VAR_4 = event.motion.VAR_4;

            }

                if (seek_by_bytes || VAR_0->ic->duration <= 0) {

                    uint64_t size =  avio_size(VAR_0->ic->pb);

                    stream_seek(VAR_0, size*VAR_4/VAR_0->width, 0, 1);

                } else {

                    int64_t ts;

                    int VAR_5, VAR_6, VAR_7, VAR_8;

                    int VAR_9, VAR_10, VAR_11, VAR_12;

                    VAR_9  = VAR_0->ic->duration / 1000000LL;

                    VAR_10  = VAR_9 / 3600;

                    VAR_11  = (VAR_9 % 3600) / 60;

                    VAR_12  = (VAR_9 % 60);

                    VAR_3 = VAR_4 / VAR_0->width;

                    VAR_5   = VAR_3 * VAR_9;

                    VAR_6   = VAR_5 / 3600;

                    VAR_7   = (VAR_5 % 3600) / 60;

                    VAR_8   = (VAR_5 % 60);

                    fprintf(stderr, "Seek to %2.0f%% (%2d:%02d:%02d) of total duration (%2d:%02d:%02d)       \n", VAR_3*100,

                            VAR_6, VAR_7, VAR_8, VAR_10, VAR_11, VAR_12);

                    ts = VAR_3 * VAR_0->ic->duration;

                    if (VAR_0->ic->start_time != AV_NOPTS_VALUE)

                        ts += VAR_0->ic->start_time;

                    stream_seek(VAR_0, ts, 0, 0);

                }

            break;

        case SDL_VIDEORESIZE:

                screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 0,

                                          SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL);

                screen_width  = VAR_0->width  = event.resize.w;

                screen_height = VAR_0->height = event.resize.h;

                VAR_0->force_refresh = 1;

            break;

        case SDL_QUIT:

        case FF_QUIT_EVENT:

            do_exit(VAR_0);

            break;

        case FF_ALLOC_EVENT:

            alloc_picture(event.user.data1);

            break;

        default:

            break;

        }

    }

}

static void FUNC_0(VideoState *VAR_0)
{ SDL_Event event; double VAR_1, VAR_2, VAR_3; for (;;) { double VAR_4; refresh_loop_wait_event(VAR_0, &event); switch (event.type) { case SDL_KEYDOWN:
if (exit_on_keydown) { do_exit(VAR_0); break; } switch (event.key.keysym.sym) { case SDLK_ESCAPE:
case SDLK_q:
do_exit(VAR_0); break; case SDLK_f:
toggle_full_screen(VAR_0); VAR_0->force_refresh = 1; break; case SDLK_p:
case SDLK_SPACE:
toggle_pause(VAR_0); break; case SDLK_s:
step_to_next_frame(VAR_0); break; case SDLK_a:
stream_cycle_channel(VAR_0, AVMEDIA_TYPE_AUDIO); break; case SDLK_v:
stream_cycle_channel(VAR_0, AVMEDIA_TYPE_VIDEO); break; case SDLK_t:
stream_cycle_channel(VAR_0, AVMEDIA_TYPE_SUBTITLE); break; case SDLK_w:
toggle_audio_display(VAR_0); break; case SDLK_PAGEUP:
VAR_1 = 600.0; goto do_seek; case SDLK_PAGEDOWN:
VAR_1 = -600.0; goto do_seek; case SDLK_LEFT:
VAR_1 = -10.0; goto do_seek; case SDLK_RIGHT:
VAR_1 = 10.0; goto do_seek; case SDLK_UP:
VAR_1 = 60.0; goto do_seek; case SDLK_DOWN:
VAR_1 = -60.0; do_seek:
if (seek_by_bytes) { if (VAR_0->video_stream >= 0 && VAR_0->video_current_pos >= 0) { VAR_2 = VAR_0->video_current_pos; } else if (VAR_0->audio_stream >= 0 && VAR_0->audio_pkt.VAR_2 >= 0) { VAR_2 = VAR_0->audio_pkt.VAR_2; } else VAR_2 = avio_tell(VAR_0->ic->pb); if (VAR_0->ic->bit_rate)
VAR_1 *= VAR_0->ic->bit_rate / 8.0; else
VAR_1 *= 180000.0; VAR_2 += VAR_1; stream_seek(VAR_0, VAR_2, VAR_1, 1); } else { VAR_2 = get_master_clock(VAR_0); if (isnan(VAR_2))
VAR_2 = (double)VAR_0->seek_pos / AV_TIME_BASE; VAR_2 += VAR_1; if (VAR_0->ic->start_time != AV_NOPTS_VALUE && VAR_2 < VAR_0->ic->start_time / (double)AV_TIME_BASE)
VAR_2 = VAR_0->ic->start_time / (double)AV_TIME_BASE; stream_seek(VAR_0, (int64_t)(VAR_2 * AV_TIME_BASE), (int64_t)(VAR_1 * AV_TIME_BASE), 0); } break; default:
break; } break; case SDL_VIDEOEXPOSE:
VAR_0->force_refresh = 1; break; case SDL_MOUSEBUTTONDOWN:
if (exit_on_mousedown) { do_exit(VAR_0); break; } case SDL_MOUSEMOTION:
if (cursor_hidden) { SDL_ShowCursor(1); cursor_hidden = 0; } cursor_last_shown = av_gettime(); if (event.type == SDL_MOUSEBUTTONDOWN) { VAR_4 = event.button.VAR_4; } else { if (event.motion.state != SDL_PRESSED)
break; VAR_4 = event.motion.VAR_4; } if (seek_by_bytes || VAR_0->ic->duration <= 0) { uint64_t size =  avio_size(VAR_0->ic->pb); stream_seek(VAR_0, size*VAR_4/VAR_0->width, 0, 1); } else { int64_t ts; int VAR_5, VAR_6, VAR_7, VAR_8; int VAR_9, VAR_10, VAR_11, VAR_12; VAR_9  = VAR_0->ic->duration / 1000000LL; VAR_10  = VAR_9 / 3600; VAR_11  = (VAR_9 % 3600) / 60; VAR_12  = (VAR_9 % 60); VAR_3 = VAR_4 / VAR_0->width; VAR_5   = VAR_3 * VAR_9; VAR_6   = VAR_5 / 3600; VAR_7   = (VAR_5 % 3600) / 60; VAR_8   = (VAR_5 % 60); fprintf(stderr, "Seek to %2.0f%% (%2d:%02d:%02d) of total duration (%2d:%02d:%02d)       \n", VAR_3*100,
VAR_6, VAR_7, VAR_8, VAR_10, VAR_11, VAR_12); ts = VAR_3 * VAR_0->ic->duration; if (VAR_0->ic->start_time != AV_NOPTS_VALUE)
ts += VAR_0->ic->start_time; stream_seek(VAR_0, ts, 0, 0); } break; case SDL_VIDEORESIZE:
screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 0,
SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL); screen_width  = VAR_0->width  = event.resize.w; screen_height = VAR_0->height = event.resize.h; VAR_0->force_refresh = 1; break; case SDL_QUIT:
case FF_QUIT_EVENT:
do_exit(VAR_0); break; case FF_ALLOC_EVENT:
alloc_picture(event.user.data1); break; default:
break; } } }