示例#1
0
	root::root(player* player, movie_def_impl* def)	:
		m_def(def),
		m_movie(NULL),
		m_viewport_x0(0),
		m_viewport_y0(0),
		m_viewport_width(1),
		m_viewport_height(1),
		m_pixel_scale(1.0f),
		m_background_color(0, 0, 0, 255),
		m_mouse_x(0),
		m_mouse_y(0),
		m_mouse_buttons(0),
		m_userdata(NULL),
		m_on_event_load_called(false),
		m_shift_key_state(false),
		m_current_active_entity(NULL),

		// the first time we needs do advance() and
		// then display() certainly
		m_time_remainder(1.0f),

		m_frame_time(1.0f),
		m_player(player)
	{
		assert(m_def != NULL);
		set_display_viewport(0, 0, (int) m_def->get_width_pixels(), (int) m_def->get_height_pixels());
		m_frame_time = 1.0f / get_frame_rate();
		player->set_root(this);
	}
示例#2
0
文件: main.cpp 项目: ChunhuiWu/vsxu
 void run()
 {
 	if (drive->get() == 0)
   current_frame = (int)(engine->vtime * get_frame_rate());
   else
   current_frame = (int)(time->get() * get_frame_rate());
   if (current_frame != previous_frame) {
     //printf("r-");
     bitm.data=(long unsigned int*)get_frame_data(current_frame);
     bitm.timestamp++;
     previous_frame = current_frame;
    // printf("t-");
   }
   if (bitm.valid && bitm_timestamp != bitm.timestamp)
   {
     bitm_timestamp = bitm.timestamp;
     result1->set(bitm);
     loading_done = true;
   }
   if (current_frame>num_frames) current_frame=0;
 }
示例#3
0
static int create_ffaudiofileformats(JNIEnv *env, AVFormatContext *format_context, jobjectArray *array, jstring url) {
    int res = 0;
    jlong duration_in_microseconds = -1;
    jfloat frame_rate = -1;
    jobject vbr = NULL;
    jboolean big_endian = 1;
    jobject audio_format = NULL;
    jint frame_size = -1;
    jint sample_size = -1;
    int audio_stream_count = 0;
    int audio_stream_number = 0;

    // count possible audio streams
    int i;
    for (i=0; i<format_context->nb_streams; i++) {
        AVStream* stream = format_context->streams[i];
        if (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
            audio_stream_count++;
        }
    }

#ifdef DEBUG
    fprintf(stderr, "Found %i audio streams.\n", audio_stream_count);
#endif

    // are there any audio streams at all?
    if (audio_stream_count == 0) {
        throwUnsupportedAudioFileExceptionIfError(env, -1, "Failed to find audio stream");
        goto bail;
    }

    // create output array
    *array = (*env)->NewObjectArray(env, audio_stream_count, (*env)->FindClass(env, "javax/sound/sampled/AudioFileFormat"), NULL);
    if (array == NULL) {
        goto bail;
    }

#ifdef DEBUG
    fprintf(stderr, "Created audio file format array.\n");
#endif

    // iterate over audio streams
    for (i=0; i<format_context->nb_streams; i++) {
        AVStream* stream = format_context->streams[i];
        if (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
            /*
            res = ff_open_stream(env, stream);
            if (res) {
                goto bail;
            }
            */

            // create object
            duration_in_microseconds = duration(format_context, stream);
            frame_rate = get_frame_rate(stream, duration_in_microseconds);
            big_endian = ff_big_endian(stream->codecpar->codec_id);
            if (is_pcm(stream->codecpar->codec_id)) {
                frame_size = (stream->codecpar->bits_per_coded_sample / 8) * stream->codecpar->channels;
            }
            // TODO: Support VBR.

            sample_size = stream->codecpar->bits_per_raw_sample
                ? stream->codecpar->bits_per_raw_sample
                : stream->codecpar->bits_per_coded_sample;

            #ifdef DEBUG
                fprintf(stderr, "stream->codecpar->bits_per_coded_sample: %i\n", stream->codecpar->bits_per_coded_sample);
                fprintf(stderr, "stream->codecpar->bits_per_raw_sample  : %i\n", stream->codecpar->bits_per_raw_sample);
                fprintf(stderr, "stream->codecpar->bit_rate             : %i\n", stream->codecpar->bit_rate);
                fprintf(stderr, "format_context->packet_size         : %i\n", format_context->packet_size);
                fprintf(stderr, "frames     : %" PRId64 "\n", stream->nb_frames);
                fprintf(stderr, "sample_rate: %i\n", stream->codecpar->sample_rate);
                fprintf(stderr, "sampleSize : %i\n", stream->codecpar->bits_per_coded_sample);
                fprintf(stderr, "channels   : %i\n", stream->codecpar->channels);
                fprintf(stderr, "frame_size : %i\n", (int)frame_size);
                fprintf(stderr, "codec_id   : %i\n", stream->codecpar->codec_id);
                fprintf(stderr, "duration   : %" PRId64 "\n", (int64_t)duration_in_microseconds);
                fprintf(stderr, "frame_rate : %f\n", frame_rate);
                if (big_endian) {
                    fprintf(stderr, "big_endian  : true\n");
                } else {
                    fprintf(stderr, "big_endian  : false\n");
                }
            #endif
            audio_format = create_ffaudiofileformat(env, url,
                                                           stream->codecpar->codec_id,
                                                           (jfloat)stream->codecpar->sample_rate,
                                                           sample_size,
                                                           stream->codecpar->channels,
                                                           frame_size,
                                                           frame_rate,
                                                           big_endian,
                                                           duration_in_microseconds,
                                                           stream->codecpar->bit_rate,
                                                           vbr);

            (*env)->SetObjectArrayElement(env, *array, audio_stream_number, audio_format);
            audio_stream_number++;

            // clean up
            /*
            if (stream && stream->codec) {
                avcodec_close(stream->codec);
            }
            */
        }
    }

bail:
    return res;
}