bool video_pixel_frame_scale(const void *data,
                             unsigned width, unsigned height,
                             size_t pitch)
{
    video_pixel_scaler_t *scaler = scaler_get_ptr();

    RARCH_PERFORMANCE_INIT(video_frame_conv);

    if (!data)
        return false;
    if (video_driver_get_pixel_format() != RETRO_PIXEL_FORMAT_0RGB1555)
        return false;
    if (data == RETRO_HW_FRAME_BUFFER_VALID)
        return false;

    RARCH_PERFORMANCE_START(video_frame_conv);

    scaler->scaler->in_width      = width;
    scaler->scaler->in_height     = height;
    scaler->scaler->out_width     = width;
    scaler->scaler->out_height    = height;
    scaler->scaler->in_stride     = pitch;
    scaler->scaler->out_stride    = width * sizeof(uint16_t);

    scaler_ctx_scale(scaler->scaler, scaler->scaler_out, data);

    RARCH_PERFORMANCE_STOP(video_frame_conv);

    return true;
}
Пример #2
0
/**
 * video_frame:
 * @data                 : pointer to data of the video frame.
 * @width                : width of the video frame.
 * @height               : height of the video frame.
 * @pitch                : pitch of the video frame.
 *
 * Video frame render callback function.
 **/
static void video_frame(const void *data, unsigned width,
      unsigned height, size_t pitch)
{
   unsigned output_width  = 0;
   unsigned output_height = 0;
   unsigned  output_pitch = 0;
   const char *msg        = NULL;
   driver_t  *driver      = driver_get_ptr();
   global_t  *global      = global_get_ptr();
   settings_t *settings   = config_get_ptr();
   const video_driver_t *video = 
      driver ? (const video_driver_t*)driver->video : NULL;

   if (!driver->video_active)
      return;

   if (video_pixel_frame_scale(data, width, height, pitch))
   {
      video_pixel_scaler_t *scaler = scaler_get_ptr();

      data                        = scaler->scaler_out;
      pitch                       = scaler->scaler->out_stride;
   }

   video_driver_cached_frame_set(data, width, height, pitch);

   /* Slightly messy code,
    * but we really need to do processing before blocking on VSync
    * for best possible scheduling.
    */
   if ((!video_driver_frame_filter_alive()
            || !settings->video.post_filter_record || !data
            || global->record.gpu_buffer)
      )
      recording_dump_frame(data, width, height, pitch);

   msg                = rarch_main_msg_queue_pull();

   *driver->current_msg = 0;

   if (msg)
      strlcpy(driver->current_msg, msg, sizeof(driver->current_msg));

   if (video_driver_frame_filter(data, width, height, pitch,
            &output_width, &output_height, &output_pitch))
   {
      data   = video_driver_frame_filter_get_buf_ptr();
      width  = output_width;
      height = output_height;
      pitch  = output_pitch;
   }

   if (!video->frame(driver->video_data, data, width, height, pitch, driver->current_msg))
      driver->video_active = false;
}