void event_loop(void)

{

    SDL_Event event;

    double incr, pos, frac;



    for(;;) {

        SDL_WaitEvent(&event);

        switch(event.type) {

        case SDL_KEYDOWN:

            switch(event.key.keysym.sym) {

            case SDLK_ESCAPE:

            case SDLK_q:

                do_exit();

                break;

            case SDLK_f:

                toggle_full_screen();

                break;

            case SDLK_p:

            case SDLK_SPACE:

                toggle_pause();

                break;

            case SDLK_s: //S: Step to next frame

                step_to_next_frame();

                break;

            case SDLK_a:

                if (cur_stream) 

                    stream_cycle_channel(cur_stream, CODEC_TYPE_AUDIO);

                break;

            case SDLK_v:

                if (cur_stream) 

                    stream_cycle_channel(cur_stream, CODEC_TYPE_VIDEO);

                break;

            case SDLK_w:

                toggle_audio_display();

                break;

            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 (cur_stream) {

                    pos = get_master_clock(cur_stream);

printf("%f %f %d %d %d %d\n", (float)pos, (float)incr, cur_stream->av_sync_type == AV_SYNC_VIDEO_MASTER, 

cur_stream->av_sync_type == AV_SYNC_AUDIO_MASTER, cur_stream->video_st, cur_stream->audio_st);

                    pos += incr;

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

                }

                break;

            default:

                break;

            }

            break;

        case SDL_MOUSEBUTTONDOWN:

	    if (cur_stream) {

		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 = (double)event.button.x/(double)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);

		stream_seek(cur_stream, (int64_t)(cur_stream->ic->start_time+frac*cur_stream->ic->duration));

	    }

	    break;

        case SDL_VIDEORESIZE:

            if (cur_stream) {

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

                                          SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL);

                cur_stream->width = event.resize.w;

                cur_stream->height = event.resize.h;

            }

            break;

        case SDL_QUIT:

        case FF_QUIT_EVENT:

            do_exit();

            break;

        case FF_ALLOC_EVENT:

            alloc_picture(event.user.data1);

            break;

        case FF_REFRESH_EVENT:

            video_refresh_timer(event.user.data1);

            break;

        default:

            break;

        }

    }

}

void event_loop(void)

{

    SDL_Event event;

    double incr, pos, frac;



    for(;;) {

        SDL_WaitEvent(&event);

        switch(event.type) {

        case SDL_KEYDOWN:

            switch(event.key.keysym.sym) {

            case SDLK_ESCAPE:

            case SDLK_q:

                do_exit();

                break;

            case SDLK_f:

                toggle_full_screen();

                break;

            case SDLK_p:

            case SDLK_SPACE:

                toggle_pause();

                break;

            case SDLK_s: 

                step_to_next_frame();

                break;

            case SDLK_a:

                if (cur_stream) 

                    stream_cycle_channel(cur_stream, CODEC_TYPE_AUDIO);

                break;

            case SDLK_v:

                if (cur_stream) 

                    stream_cycle_channel(cur_stream, CODEC_TYPE_VIDEO);

                break;

            case SDLK_w:

                toggle_audio_display();

                break;

            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 (cur_stream) {

                    pos = get_master_clock(cur_stream);

printf("%f %f %d %d %d %d\n", (float)pos, (float)incr, cur_stream->av_sync_type == AV_SYNC_VIDEO_MASTER, 

cur_stream->av_sync_type == AV_SYNC_AUDIO_MASTER, cur_stream->video_st, cur_stream->audio_st);

                    pos += incr;

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

                }

                break;

            default:

                break;

            }

            break;

        case SDL_MOUSEBUTTONDOWN:

	    if (cur_stream) {

		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 = (double)event.button.x/(double)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);

		stream_seek(cur_stream, (int64_t)(cur_stream->ic->start_time+frac*cur_stream->ic->duration));

	    }

	    break;

        case SDL_VIDEORESIZE:

            if (cur_stream) {

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

                                          SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL);

                cur_stream->width = event.resize.w;

                cur_stream->height = event.resize.h;

            }

            break;

        case SDL_QUIT:

        case FF_QUIT_EVENT:

            do_exit();

            break;

        case FF_ALLOC_EVENT:

            alloc_picture(event.user.data1);

            break;

        case FF_REFRESH_EVENT:

            video_refresh_timer(event.user.data1);

            break;

        default:

            break;

        }

    }

}

void FUNC_0(void)

{

    SDL_Event event;

    double VAR_0, VAR_1, VAR_2;



    for(;;) {

        SDL_WaitEvent(&event);

        switch(event.type) {

        case SDL_KEYDOWN:

            switch(event.key.keysym.sym) {

            case SDLK_ESCAPE:

            case SDLK_q:

                do_exit();

                break;

            case SDLK_f:

                toggle_full_screen();

                break;

            case SDLK_p:

            case SDLK_SPACE:

                toggle_pause();

                break;

            case SDLK_s: 

                step_to_next_frame();

                break;

            case SDLK_a:

                if (cur_stream) 

                    stream_cycle_channel(cur_stream, CODEC_TYPE_AUDIO);

                break;

            case SDLK_v:

                if (cur_stream) 

                    stream_cycle_channel(cur_stream, CODEC_TYPE_VIDEO);

                break;

            case SDLK_w:

                toggle_audio_display();

                break;

            case SDLK_LEFT:

                VAR_0 = -10.0;

                goto do_seek;

            case SDLK_RIGHT:

                VAR_0 = 10.0;

                goto do_seek;

            case SDLK_UP:

                VAR_0 = 60.0;

                goto do_seek;

            case SDLK_DOWN:

                VAR_0 = -60.0;

            do_seek:

                if (cur_stream) {

                    VAR_1 = get_master_clock(cur_stream);

printf("%f %f %d %d %d %d\n", (float)VAR_1, (float)VAR_0, cur_stream->av_sync_type == AV_SYNC_VIDEO_MASTER, 

cur_stream->av_sync_type == AV_SYNC_AUDIO_MASTER, cur_stream->video_st, cur_stream->audio_st);

                    VAR_1 += VAR_0;

                    stream_seek(cur_stream, (int64_t)(VAR_1 * AV_TIME_BASE));

                }

                break;

            default:

                break;

            }

            break;

        case SDL_MOUSEBUTTONDOWN:

	    if (cur_stream) {

		int VAR_3, VAR_4, VAR_5, VAR_6;

		int VAR_7, VAR_8, VAR_9, VAR_10;

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

		VAR_8 = VAR_7/3600;

		VAR_9 = (VAR_7%3600)/60;

		VAR_10 = (VAR_7%60);

		VAR_2 = (double)event.button.x/(double)cur_stream->width;

		VAR_3 = VAR_2*VAR_7;

		VAR_4 = VAR_3/3600;

		VAR_5 = (VAR_3%3600)/60;

		VAR_6 = (VAR_3%60);

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

			VAR_4, VAR_5, VAR_6, VAR_8, VAR_9, VAR_10);

		stream_seek(cur_stream, (int64_t)(cur_stream->ic->start_time+VAR_2*cur_stream->ic->duration));

	    }

	    break;

        case SDL_VIDEORESIZE:

            if (cur_stream) {

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

                                          SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL);

                cur_stream->width = event.resize.w;

                cur_stream->height = event.resize.h;

            }

            break;

        case SDL_QUIT:

        case FF_QUIT_EVENT:

            do_exit();

            break;

        case FF_ALLOC_EVENT:

            alloc_picture(event.user.data1);

            break;

        case FF_REFRESH_EVENT:

            video_refresh_timer(event.user.data1);

            break;

        default:

            break;

        }

    }

}

void FUNC_0(void)
{ SDL_Event event; double VAR_0, VAR_1, VAR_2; for(;;) { SDL_WaitEvent(&event); switch(event.type) { case SDL_KEYDOWN:
switch(event.key.keysym.sym) { case SDLK_ESCAPE:
case SDLK_q:
do_exit(); break; case SDLK_f:
toggle_full_screen(); break; case SDLK_p:
case SDLK_SPACE:
toggle_pause(); break; case SDLK_s:
step_to_next_frame(); break; case SDLK_a:
if (cur_stream)
stream_cycle_channel(cur_stream, CODEC_TYPE_AUDIO); break; case SDLK_v:
if (cur_stream)
stream_cycle_channel(cur_stream, CODEC_TYPE_VIDEO); break; case SDLK_w:
toggle_audio_display(); break; case SDLK_LEFT:
VAR_0 = -10.0; goto do_seek; case SDLK_RIGHT:
VAR_0 = 10.0; goto do_seek; case SDLK_UP:
VAR_0 = 60.0; goto do_seek; case SDLK_DOWN:
VAR_0 = -60.0; do_seek:
if (cur_stream) { VAR_1 = get_master_clock(cur_stream); printf("%f %f %d %d %d %d\n", (float)VAR_1, (float)VAR_0, cur_stream->av_sync_type == AV_SYNC_VIDEO_MASTER,
cur_stream->av_sync_type == AV_SYNC_AUDIO_MASTER, cur_stream->video_st, cur_stream->audio_st); VAR_1 += VAR_0; stream_seek(cur_stream, (int64_t)(VAR_1 * AV_TIME_BASE)); } break; default:
break; } break; case SDL_MOUSEBUTTONDOWN:
if (cur_stream) { int VAR_3, VAR_4, VAR_5, VAR_6; int VAR_7, VAR_8, VAR_9, VAR_10; VAR_7 = cur_stream->ic->duration/1000000LL; VAR_8 = VAR_7/3600; VAR_9 = (VAR_7%3600)/60; VAR_10 = (VAR_7%60); VAR_2 = (double)event.button.x/(double)cur_stream->width; VAR_3 = VAR_2*VAR_7; VAR_4 = VAR_3/3600; VAR_5 = (VAR_3%3600)/60; VAR_6 = (VAR_3%60); fprintf(stderr, "Seek to %2.0f%% (%2d:%02d:%02d) of total duration (%2d:%02d:%02d)       \n", VAR_2*100,
VAR_4, VAR_5, VAR_6, VAR_8, VAR_9, VAR_10); stream_seek(cur_stream, (int64_t)(cur_stream->ic->start_time+VAR_2*cur_stream->ic->duration)); } break; case SDL_VIDEORESIZE:
if (cur_stream) { screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 0,
SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL); cur_stream->width = event.resize.w; cur_stream->height = event.resize.h; } break; case SDL_QUIT:
case FF_QUIT_EVENT:
do_exit(); break; case FF_ALLOC_EVENT:
alloc_picture(event.user.data1); break; case FF_REFRESH_EVENT:
video_refresh_timer(event.user.data1); break; default:
break; } } }