Ejemplo n.º 1
0
    void device_config::get_all_possible_requestes(std::vector<stream_request>(&stream_requests)[RS_STREAM_NATIVE_COUNT]) const
    {
        for (size_t i = 0; i < info.subdevice_modes.size(); i++)
        {
            stream_request request;
            auto mode = info.subdevice_modes[i];

            for (auto pad_crop : mode.pad_crop_options)
            {
                for (auto & unpacker : mode.pf.unpackers)
                {
                    auto selection = subdevice_mode_selection(mode, pad_crop, int(&unpacker - mode.pf.unpackers.data()));

                    request.enabled = true;
                    request.fps = selection.get_framerate();
                    request.height = selection.get_height();
                    request.width = selection.get_width();
                    auto outputs = selection.get_outputs();

                    for (auto output : outputs)
                    {
                        request.format = output.second;
                        for (auto output_format = static_cast<int>(RS_OUTPUT_BUFFER_FORMAT_CONTINUOUS); output_format < static_cast<int>(RS_OUTPUT_BUFFER_FORMAT_COUNT); output_format++)
                        {
                            request.output_format = static_cast<rs_output_buffer_format>(output_format);
                            stream_requests[output.first].push_back(request);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
 std::shared_ptr<stream_profile_interface> stream_profile_base::clone() const
 {
     auto res = std::make_shared<stream_profile_base>(get_backend_profile());
     res->set_unique_id(environment::get_instance().generate_stream_id());
     res->set_framerate(get_framerate());
     return res;
 }
Ejemplo n.º 3
0
int ThresholdMain::process_buffer(VFrame *frame,
	int64_t start_position,
	double frame_rate)
{
	load_configuration();

	int use_opengl = get_use_opengl() &&
		(!config.plot || !gui_open());

	read_frame(frame,
		0,
		get_source_position(),
		get_framerate(),
		use_opengl);

	if(use_opengl) return run_opengl();

	send_render_gui(frame);

	if(!threshold_engine)
		threshold_engine = new ThresholdEngine(this);
	threshold_engine->process_packages(frame);
	
	return 0;
}
Ejemplo n.º 4
0
int FlipMain::process_buffer(VFrame *frame,
		int64_t start_position,
		double frame_rate)
{
	int i, j, k, l;
	int w = frame->get_w();
	int h = frame->get_h();
	int colormodel = frame->get_color_model();

	load_configuration();

	read_frame(frame,
		0,
		get_source_position(),
		get_framerate(),
		get_use_opengl());



	if(get_use_opengl()) 
	{
		if(config.flip_vertical || config.flip_horizontal)
			return run_opengl();
		else
			return 0;
	}

	switch(colormodel)
	{
		case BC_RGB888:
		case BC_YUV888:
			FLIP_MACRO(unsigned char, 3);
			break;
		case BC_RGB_FLOAT:
			FLIP_MACRO(float, 3);
			break;
		case BC_RGB161616:
		case BC_YUV161616:
			FLIP_MACRO(uint16_t, 3);
			break;
		case BC_RGBA8888:
		case BC_YUVA8888:
			FLIP_MACRO(unsigned char, 4);
			break;
		case BC_RGBA_FLOAT:
			FLIP_MACRO(float, 4);
			break;
		case BC_RGBA16161616:
		case BC_YUVA16161616:
			FLIP_MACRO(uint16_t, 4);
			break;
	}
	return 0;
}
Ejemplo n.º 5
0
int UnsharpMain::process_buffer(VFrame *frame,
	int64_t start_position,
	double frame_rate)
{
	/*int need_reconfigure =*/ load_configuration();

	if(!engine) engine = new UnsharpEngine(this, 
		get_project_smp() + 1, get_project_smp() + 1);
	read_frame(frame, 0, get_source_position(), get_framerate());
	engine->do_unsharp(frame);
	return 0;
}
Ejemplo n.º 6
0
/*******************************************
  Restart emulation when loading a new game 
********************************************/
void reloadrom(void)
{
  /* Cartridge "Hot Swap" support (make sure system has already been inited once and use cartridges) */
  if ((config.hot_swap == 3) && ((system_hw != SYSTEM_MCD) || scd.cartridge.boot))
  {
    /* Only initialize cartridge hardware */
    if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
    {
      /* 16-bit cartridge */
      md_cart_init();
      md_cart_reset(1);
    }
    else
    {
      /* 8-bit cartridge */
      sms_cart_init();
      sms_cart_reset();
    }
  }

  /* Disc Swap support (automatically enabled if CD tray is open) */
  else if ((system_hw != SYSTEM_MCD) || (cdd.status != CD_OPEN))
  {
    /* Initialize audio emulation */
    interlaced = 0;
    audio_init(SAMPLERATE_48KHZ, get_framerate());
     
    /* Switch virtual system on */
    system_init();
    system_reset();

    /* Allow hot swap */
    config.hot_swap |= 2;
  }

  /* Auto-Load Backup RAM */
  slot_autoload(0,config.s_device);
            
  /* Auto-Load State */
  slot_autoload(config.s_default,config.s_device);

  /* Load Cheat file */
  CheatLoad();
}
Ejemplo n.º 7
0
int Color3WayMain::process_buffer(VFrame *frame,
	int64_t start_position,
	double frame_rate)
{
	need_reconfigure |= load_configuration();

	if(!engine) engine = new Color3WayEngine(this, 
//		1);
		PluginClient::smp + 1);

//printf("Color3WayMain::process_realtime 1 %d\n", need_reconfigure);
	if(need_reconfigure)
	{

		reconfigure();
		need_reconfigure = 0;
	}



	read_frame(frame,
		0,
		get_source_position(),
		get_framerate(),
		get_use_opengl());

	int aggregate_interpolate = 0;
	int aggregate_gamma = 0;
	get_aggregation(&aggregate_interpolate,
		&aggregate_gamma);



	engine->process_packages();


	return 0;
}
Ejemplo n.º 8
0
void gstreamer_previous_frame() {
	gboolean error;
	gint64 pos = gstreamer_get_position(&error);
	if (!error) {
		double rate;
		if (!get_framerate(&rate))
			return;
		printf("Position = %ld, Rate = %lf\n", pos, rate);
		pos -= ((gint64)GST_SECOND / rate) * 5;
		if (pos < 0)
			pos = 0;
		printf("Position = %ld\n", pos);
		if (gst_element_seek_simple(pipeline, GST_FORMAT_TIME,
		GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
		pos)) {
			printf("gstplay: Seek succeeded\n");
			pause_on_state_change_to_playing = TRUE;
			gstreamer_play();
		}
		else {
			printf("gstplay: Seek failed!.n");
		}
	}
}
Ejemplo n.º 9
0
int DeInterlaceMain::process_buffer(VFrame *frame,
	int64_t start_position,
	double frame_rate)
{
	changed_rows = frame->get_h();
	load_configuration();


	read_frame(frame, 
		0, 
		start_position, 
		frame_rate);

// Temp was used for adaptive deinterlacing where it took deinterlacing
// an entire frame to decide if the deinterlaced output should be used.
	temp = frame;

// 	if(!temp)
// 		temp = new VFrame(
// 			frame->get_w(),
// 			frame->get_h(),
// 			frame->get_color_model());
	if(!temp_prevframe)
		temp_prevframe = new VFrame(
			frame->get_w(),
			frame->get_h(),
			frame->get_color_model());

	switch(config.mode)
	{
		case DEINTERLACE_NONE:
//			output->copy_from(input);
			break;
		case DEINTERLACE_KEEP:
			deinterlace_top(frame, frame, config.dominance);
			break;
		case DEINTERLACE_AVG:
			deinterlace_avg(frame, frame);
			break;
		case DEINTERLACE_AVG_1F:
			deinterlace_avg_top(frame, frame, config.dominance);
			break;
		case DEINTERLACE_SWAP:
			deinterlace_swap(frame, frame, config.dominance);
			break;
		case DEINTERLACE_BOBWEAVE:
			if (get_source_position()==0)
				read_frame(temp_prevframe,0, get_source_position(), get_framerate());
			else 
				read_frame(temp_prevframe,0, get_source_position()-1, get_framerate());
			deinterlace_bobweave(frame, temp_prevframe, frame, config.dominance);
			break;
		case DEINTERLACE_TEMPORALSWAP:
			if (get_source_position()==0)
				read_frame(temp_prevframe,0, get_source_position(), get_framerate());
			else 
				read_frame(temp_prevframe,0, get_source_position()-1, get_framerate());
			deinterlace_temporalswap(frame, temp_prevframe, frame, config.dominance);
			break; 
	}
	send_render_gui(&changed_rows);
	return 0;
}
Ejemplo n.º 10
0
    std::shared_ptr<pipeline_profile> pipeline_config::resolve(std::shared_ptr<pipeline> pipe)
    {
        std::lock_guard<std::mutex> lock(_mtx);
        _resolved_profile.reset();
        auto requested_device = resolve_device_requests(pipe);

        std::vector<stream_profile> resolved_profiles;

        //if the user requested all streams, or if the requested device is from file and the user did not request any stream
        if (_enable_all_streams || (!_device_request.filename.empty() && _stream_requests.empty()))
        {
            if (!requested_device)
            {
                requested_device = get_first_or_default_device(pipe);
            }

            util::config config;
            config.enable_all(util::best_quality);
            _resolved_profile = std::make_shared<pipeline_profile>(requested_device, config, _device_request.record_output);
            return _resolved_profile;
        }
        else
        {
            util::config config;

            //If the user did not request anything, give it the default
            if (_stream_requests.empty())
            {
                if (!requested_device)
                {
                    requested_device = get_first_or_default_device(pipe);
                }

                auto default_profiles = get_default_configuration(requested_device);
                for (auto prof : default_profiles)
                {
                    auto p = dynamic_cast<video_stream_profile*>(prof.get());
                    if (!p)
                    {
                        LOG_ERROR("prof is not video_stream_profile");
                        throw std::logic_error("Failed to resolve request. internal error");
                    }
                    config.enable_stream(p->get_stream_type(), p->get_stream_index(), p->get_width(), p->get_height(), p->get_format(), p->get_framerate());
                }

                _resolved_profile = std::make_shared<pipeline_profile>(requested_device, config, _device_request.record_output);
                return _resolved_profile;
            }
            else
            {
                //User enabled some stream, enable only them   
                for(auto&& req : _stream_requests)
                {
                    auto r = req.second;
                    config.enable_stream(r.stream, r.stream_index, r.width, r.height, r.format, r.fps);
                }

                auto devs = pipe->get_context()->query_devices();
                if (devs.empty())
                {
                    auto dev = get_first_or_default_device(pipe);
                    _resolved_profile = std::make_shared<pipeline_profile>(dev, config, _device_request.record_output);
                    return _resolved_profile;
                }
                else
                {
                    for (auto dev_info : devs)
                    {
                        try
                        {
                            auto dev = dev_info->create_device();
                            _resolved_profile = std::make_shared<pipeline_profile>(dev, config, _device_request.record_output);
                            return _resolved_profile;
                        }
                        catch (...) {}
                    }
                }

                throw std::runtime_error("Failed to resolve request. No device found that satisfies all requirements");
            }
        }

        assert(0); //Unreachable code
    }
Ejemplo n.º 11
0
static void run_emulation(void)
{
  int sync;

  /* main emulation loop */
  while (1)
  {
    /* emulated system */
    if (system_hw == SYSTEM_MCD)
    {
      /* 16-bit hardware + CD */
      while (!ConfigRequested)
      {
        /* render frame */
        system_frame_scd(0);

        /* audio/video sync */
        sync = NO_SYNC;
        while (sync != (SYNC_VIDEO | SYNC_AUDIO))
        {
          /* update video */
          sync |= gx_video_Update();

          /* update audio */
          sync |= gx_audio_Update();
        }

        /* check interlaced mode change */
        if (bitmap.viewport.changed & 4)
        {
          /* VSYNC "original" mode */
          if (!config.render && config.vsync && (gc_pal == vdp_pal))
          {
            /* framerate has changed, reinitialize audio timings */
            audio_init(SAMPLERATE_48KHZ, get_framerate());
          }

          /* clear flag */
          bitmap.viewport.changed &= ~4;
        }
      }
    }
    else if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
    {
      /* 16-bit hardware */
      while (!ConfigRequested)
      {
        /* render frame */
        system_frame_gen(0);

        /* audio/video sync */
        sync = NO_SYNC;
        while (sync != (SYNC_VIDEO | SYNC_AUDIO))
        {
          /* update video */
          sync |= gx_video_Update();

          /* update audio */
          sync |= gx_audio_Update();
        }

        /* check interlaced mode change */
        if (bitmap.viewport.changed & 4)
        {
          /* VSYNC "original" mode */
          if (!config.render && config.vsync && (gc_pal == vdp_pal))
          {
            /* framerate has changed, reinitialize audio timings */
            audio_init(SAMPLERATE_48KHZ, get_framerate());
          }

          /* clear flag */
          bitmap.viewport.changed &= ~4;
        }
      }
    }
    else
    {
      /* 8-bit hardware */
      while (!ConfigRequested)
      {
        /* render frame */
        system_frame_sms(0);

        /* audio/video sync */
        sync = NO_SYNC;
        while (sync != (SYNC_VIDEO | SYNC_AUDIO))
        {
          /* update video */
          sync |= gx_video_Update();

          /* update audio */
          sync |= gx_audio_Update();
        }

        /* check interlaced mode change (PBC mode only) */
        if (bitmap.viewport.changed & 4)
        {
          /* "original" mode */
          if (!config.render && config.vsync && (gc_pal == vdp_pal))
          {
            /* framerate has changed, reinitialize audio timings */
            audio_init(SAMPLERATE_48KHZ, get_framerate());
          }

          /* clear flag */
          bitmap.viewport.changed &= ~4;
        }
      }
    }

    /* stop video & audio */
    gx_audio_Stop();
    gx_video_Stop();

#ifdef LOG_TIMING
    if (system_hw)
    {
      FILE *f;
      char filename[64];

      memset(filename, 0, 64);
      strcpy(filename,"timings-");
      if (!config.vsync || (config.tv_mode == !vdp_pal))
      {
        strcat(filename,"no_");
      }
      else
      {
        if (gc_pal)
        {
          strcat(filename,"50hz_");
        }
        else
        {
          strcat(filename,"60hz_");
        }
      }
      strcat(filename,"vsync-");
      if (vdp_pal)
      {
        strcat(filename,"pal-");
      }
      else
      {
        strcat(filename,"ntsc-");
      }
      if (config.render == 2)
      {
        strcat(filename,"prog.txt");
      }
      else
      {
        if (!config.render && !interlaced)
        {
          strcat(filename,"no_");
        }
        strcat(filename,"int.txt");
      }

      f = fopen(filename,"a");
      if (f != NULL)
      {
        int i;
        u32 min,max;
        double total = 0;
        double nsamples = 0;

        if (delta_time[LOGSIZE - 1] != 0)
        {
          frame_cnt = LOGSIZE;
        }

        min = max = delta_time[0];

        for (i=0; i<frame_cnt; i++)
        {
          fprintf(f,"%d ns - %d samples (%5.8f samples/sec)\n", delta_time[i], delta_samp[i], 1000000000.0*(double)delta_samp[i]/(double)delta_time[i]/4.0);
          total += delta_time[i];
          nsamples += delta_samp[i] / 4.0;
          if (min > delta_time[i]) min = delta_time[i];
          if (max < delta_time[i]) max = delta_time[i];
        }
        fprintf(f,"\n");
        fprintf(f,"min = %d ns\n", min);
        fprintf(f,"max = %d ns\n", max);
        fprintf(f,"avg = %8.5f ns (%5.8f samples/sec, %5.8f samples/frame)\n\n\n", total/(double)i, nsamples/total*1000000000.0, nsamples/(double)i);
        fclose(f);
      }
    }

    memset(delta_time,0,LOGSIZE);
    memset(delta_samp,0,LOGSIZE);
    frame_cnt = prevtime = 0;
#endif
    
    /* show menu */
    ConfigRequested = 0;
    mainmenu();

    /* restart video & audio */
    gx_video_Start();
    gx_audio_Start();
  }
}
Ejemplo n.º 12
0
int InterpolateVideo::load_configuration()
{
	KeyFrame *prev_keyframe, *next_keyframe;
	InterpolateVideoConfig old_config;
	old_config.copy_from(&config);

	next_keyframe = get_next_keyframe(get_source_position());
	prev_keyframe = get_prev_keyframe(get_source_position());
// Previous keyframe stays in config object.
	read_data(prev_keyframe);


	int64_t prev_position = edl_to_local(prev_keyframe->position);
	int64_t next_position = edl_to_local(next_keyframe->position);
	if(prev_position == 0 && next_position == 0)
	{
		next_position = prev_position = get_source_start();
	}
// printf("InterpolateVideo::load_configuration 1 %lld %lld %lld %lld\n",
// prev_keyframe->position,
// next_keyframe->position,
// prev_position,
// next_position);

// Get range to average in requested rate
	range_start = prev_position;
	range_end = next_position;


// Use keyframes to determine range
	if(config.use_keyframes)
	{
		active_input_rate = get_framerate();
// Between keyframe and edge of range or no keyframes
		if(range_start == range_end)
		{
// Between first keyframe and start of effect
			if(get_source_position() >= get_source_start() &&
				get_source_position() < range_start)
			{
				range_start = get_source_start();
			}
			else
// Between last keyframe and end of effect
			if(get_source_position() >= range_start &&
				get_source_position() < get_source_start() + get_total_len())
			{
// Last frame should be inclusive of current effect
				range_end = get_source_start() + get_total_len() - 1;
			}
			else
			{
// Should never get here
				;
			}
		}


// Make requested rate equal to input rate for this mode.

// Convert requested rate to input rate
// printf("InterpolateVideo::load_configuration 2 %lld %lld %f %f\n", 
// range_start, 
// range_end,
// get_framerate(),
// config.input_rate);
//		range_start = (int64_t)((double)range_start / get_framerate() * active_input_rate + 0.5);
//		range_end = (int64_t)((double)range_end / get_framerate() * active_input_rate + 0.5);
	}
	else
// Use frame rate
	{
		active_input_rate = config.input_rate;
// Convert to input frame rate
		range_start = (int64_t)(get_source_position() / 
			get_framerate() *
			active_input_rate);
		range_end = (int64_t)(get_source_position() / 
			get_framerate() *
			active_input_rate) + 1;
	}

// printf("InterpolateVideo::load_configuration 1 %lld %lld %lld %lld %lld %lld\n",
// prev_keyframe->position,
// next_keyframe->position,
// prev_position,
// next_position,
// range_start,
// range_end);


	return !config.equivalent(&old_config);
}
Ejemplo n.º 13
0
void FramerateCounter::show_fps(CL_GraphicContext &gc, CL_Font &fps_font)
{
	CL_String fps = cl_format("%1 fps", get_framerate());
	fps_font.draw_text(gc, gc.get_width() - 100, 30, fps);
}
Ejemplo n.º 14
0
int ColorBalanceMain::process_buffer(VFrame *frame,
	int64_t start_position,
	double frame_rate)
{
	need_reconfigure |= load_configuration();

//printf("ColorBalanceMain::process_realtime 1 %d\n", need_reconfigure);
	if(need_reconfigure)
	{
		if(!engine)
		{
			total_engines = PluginClient::smp + 1;
			engine = new ColorBalanceEngine*[total_engines];
			for(int i = 0; i < total_engines; i++)
			{
				engine[i] = new ColorBalanceEngine(this);
				engine[i]->start();
			}
		}

		reconfigure();
		need_reconfigure = 0;
	}

	frame->get_params()->update("COLORBALANCE_PRESERVE", config.preserve);
	frame->get_params()->update("COLORBALANCE_CYAN", calculate_transfer(config.cyan));
	frame->get_params()->update("COLORBALANCE_MAGENTA", calculate_transfer(config.magenta));
	frame->get_params()->update("COLORBALANCE_YELLOW", calculate_transfer(config.yellow));


	read_frame(frame,
		0,
		get_source_position(),
		get_framerate(),
		get_use_opengl());

	int aggregate_interpolate = 0;
	int aggregate_gamma = 0;
	get_aggregation(&aggregate_interpolate,
		&aggregate_gamma);

	if(!EQUIV(config.cyan, 0) || 
		!EQUIV(config.magenta, 0) || 
		!EQUIV(config.yellow, 0) ||
		(get_use_opengl() &&
			(aggregate_interpolate ||
			aggregate_gamma)))
	{
		if(get_use_opengl())
		{
//get_output()->dump_stacks();
// Aggregate
			if(next_effect_is("Histogram")) return 0;
			return run_opengl();
		}
	
		for(int i = 0; i < total_engines; i++)
		{
			engine[i]->start_process_frame(frame, 
				frame, 
				frame->get_h() * i / total_engines, 
				frame->get_h() * (i + 1) / total_engines);
		}

		for(int i = 0; i < total_engines; i++)
		{
			engine[i]->wait_process_frame();
		}
	}


	return 0;
}