static void gst_goom_init (GstGoom * goom) { /* create the sink and src pads */ goom->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink"); gst_pad_set_chain_function (goom->sinkpad, GST_DEBUG_FUNCPTR (gst_goom_chain)); gst_pad_set_event_function (goom->sinkpad, GST_DEBUG_FUNCPTR (gst_goom_sink_event)); gst_pad_set_setcaps_function (goom->sinkpad, GST_DEBUG_FUNCPTR (gst_goom_sink_setcaps)); gst_element_add_pad (GST_ELEMENT (goom), goom->sinkpad); goom->srcpad = gst_pad_new_from_static_template (&src_template, "src"); gst_pad_set_setcaps_function (goom->srcpad, GST_DEBUG_FUNCPTR (gst_goom_src_setcaps)); gst_pad_set_event_function (goom->srcpad, GST_DEBUG_FUNCPTR (gst_goom_src_event)); gst_pad_set_query_function (goom->srcpad, GST_DEBUG_FUNCPTR (gst_goom_src_query)); gst_element_add_pad (GST_ELEMENT (goom), goom->srcpad); goom->adapter = gst_adapter_new (); goom->width = DEFAULT_WIDTH; goom->height = DEFAULT_HEIGHT; goom->fps_n = DEFAULT_FPS_N; /* desired frame rate */ goom->fps_d = DEFAULT_FPS_D; /* desired frame rate */ goom->channels = 0; goom->rate = 0; goom->duration = 0; goom->plugin = goom_init (goom->width, goom->height); }
static int PyGoom_init(PyGoomObject *self, PyObject *args, PyObject *kwds) { PyObject *exportfile = NULL, *songtitle = NULL, *tmp; char *mmapfile = NULL; static char *kwlist[] = { "width", "height", "export", "songtitle", "fxmode", NULL }; if (debug >= 1) { printf("PyGoom_init\n"); fflush(stdout); } if (!PyArg_ParseTupleAndKeywords(args, kwds, "iiO|Si", kwlist, &self->width, &self->height, &exportfile, &songtitle, &self->fxmode)) { return -1; } if (exportfile) { tmp = self->exportfile; Py_INCREF(exportfile); self->exportfile = exportfile; Py_XDECREF(tmp); } if (songtitle) { tmp = self->songtitle; Py_INCREF(songtitle); self->songtitle = songtitle; Py_XDECREF(tmp); } self->goominfo = goom_init(self->width, self->height); self->surface = SDL_CreateRGBSurface(0, self->width, self->height, 32, 0, 0, 0, 0); if (! self->surface) { PyErr_SetString(PyExc_ValueError, "Cannot create surface"); return -1; } mmapfile = PyString_AsString(self->exportfile); if (strcmp(mmapfile, "") != 0) { self->mmap_fd = open(mmapfile, O_RDONLY); if (self->mmap_fd < 0) { PyErr_Format(PyExc_IOError, "export file '%s' not found", mmapfile); return -1; } self->mmap_area = mmap(0, sizeof(data_t), PROT_READ, MAP_SHARED, self->mmap_fd, 0); if (! self->mmap_area) { PyErr_Format(PyExc_IOError, "export file '%s' cannot be mapped", mmapfile); return -1; } if (debug >= 1) { printf("sizeof(data_t)=%u sizeof(gint16)=%u\n", (unsigned)sizeof(data_t), (unsigned)sizeof(gint16)); printf("nch=%d, bs=%d, count=%llu\n", self->mmap_area->nch, self->mmap_area->bs, self->mmap_area->count); } self->mmap_area = mremap(self->mmap_area, sizeof(data_t), sizeof(data_t) + self->mmap_area->bs, 0); if (! self->mmap_area) { PyErr_Format(PyExc_IOError, "export file '%s' cannot be re-mapped", mmapfile); return -1; } } return 0; }
/***************************************************************************** * Thread: *****************************************************************************/ static void *Thread( void *p_thread_data ) { goom_thread_t *p_thread = (goom_thread_t*)p_thread_data; date_t i_pts; int16_t p_data[2][512]; int i_data = 0, i_count = 0; PluginInfo *p_plugin_info; int canc = vlc_savecancel (); p_plugin_info = goom_init( p_thread->i_width, p_thread->i_height ); for( ;; ) { uint32_t *plane; picture_t *p_pic; /* FIXME the way the update is done is not really good. * Supurious wake up from p_thread->wait will make it generates a frame * without using new samples (probably rare as we should not be waiting * samples). * The frame rate at which the video is generated is not well controlled * nor the time at which each frame is displayed (not smooth) */ /* goom_update is damn slow, so just copy data and release the lock */ vlc_mutex_lock( &p_thread->lock ); if( !p_thread->b_exit && FillBuffer( (int16_t *)p_data, &i_data, &i_pts, &p_thread->date, p_thread ) != VLC_SUCCESS ) vlc_cond_wait( &p_thread->wait, &p_thread->lock ); bool b_exit = p_thread->b_exit; vlc_mutex_unlock( &p_thread->lock ); if( b_exit ) break; /* Speed selection */ if( p_thread->i_speed && (++i_count % (p_thread->i_speed+1)) ) continue; /* Frame dropping if necessary */ if( date_Get( &i_pts ) + GOOM_DELAY <= mdate() ) continue; plane = goom_update( p_plugin_info, p_data, 0, 0.0, NULL, NULL ); p_pic = vout_GetPicture( p_thread->p_vout ); if( unlikely(p_pic == NULL) ) continue; memcpy( p_pic->p[0].p_pixels, plane, p_thread->i_width * p_thread->i_height * 4 ); p_pic->date = date_Get( &i_pts ) + GOOM_DELAY; vout_PutPicture( p_thread->p_vout, p_pic ); } goom_close( p_plugin_info ); vlc_restorecancel (canc); return NULL; }
static void gst_goom2k1_init (GstGoom2k1 * goom) { goom->width = DEFAULT_WIDTH; goom->height = DEFAULT_HEIGHT; goom->channels = 0; goom_init (&(goom->goomdata), goom->width, goom->height); }
VideoVisualGoom::VideoVisualGoom(AudioPlayer *audio, MythRender *render, bool hd) : VideoVisual(audio, render), m_buffer(nullptr), m_surface(0), m_hd(hd) { int max_width = m_hd ? 1200 : 600; int max_height = m_hd ? 800 : 400; MythMainWindow *mw = GetMythMainWindow(); QSize sz = mw ? mw->GetUIScreenRect().size() : QSize(600, 400); int width = (sz.width() > max_width) ? max_width : sz.width(); int height = (sz.height() > max_height) ? max_height : sz.height(); m_area = QRect(0, 0, width, height); goom_init(width, height, 0); LOG(VB_GENERAL, LOG_INFO, QString("Initialised Goom (%1x%2)") .arg(width).arg(height)); }
const VisPluginInfo *get_plugin_info (void) { static VisActorPlugin actor = { .requisition = lv_goom_requisition, .palette = lv_goom_palette, .render = lv_goom_render, .vidoptions.depth = VISUAL_VIDEO_DEPTH_32BIT }; static VisPluginInfo info = { .type = VISUAL_PLUGIN_TYPE_ACTOR, .plugname = "goom2k4", .name = "libvisual goom2k4 plugin", .author = "Dennis Smit <*****@*****.**>, goom2k4 by: Jean-Christophe Hoelt <*****@*****.**>", .version = "0.1", .about = N_("Libvisual goom2k4 plugin"), .help = N_("This plugin adds support for the supercool goom2k4 plugin that is simply awesome"), .license = VISUAL_PLUGIN_LICENSE_LGPL, .init = lv_goom_init, .cleanup = lv_goom_cleanup, .events = lv_goom_events, .plugin = VISUAL_OBJECT (&actor) }; return &info; } static int lv_goom_init (VisPluginData *plugin) { GoomPrivate *priv; #if ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); #endif priv = visual_mem_new0 (GoomPrivate, 1); visual_object_set_private (VISUAL_OBJECT (plugin), priv); priv->goominfo = goom_init (128, 128); priv->pcmbuf1 = visual_buffer_new (); priv->pcmbuf2 = visual_buffer_new (); return 0; }
// our main method for processing images // should return a surface no matter what in the future static PyObject* pygoom_process(PyObject *self, PyObject *args) { if (init == 0) { if (data_import_init() == 0) { goomInfo = goom_init(width, height); init = 1; } else { data_import_clean(); return RAISE(PyExc_ValueError, "Error initializing mmap"); } } if (mmap_area->count > counter || mmap_area->count < counter) { counter = mmap_area->count; #ifdef USE_FASTMEMCPY fast_memcpy(data, mmap_area + sizeof(data_t), 2048); #else memcpy(data, mmap_area + sizeof(data_t), 2048); #endif #ifdef VERBOSE printf ("goomInfo=%p, data=%p, FXMODE=%d, fps=%.1f, songtitle=%s, message=%s\n", goomInfo, data, FXMODE, fps, songtitle, message); #endif render_data = goom_update(goomInfo, data, FXMODE, fps, songtitle, message); if (!render_data) { data_import_clean(); return RAISE(PyExc_ValueError, "Goom didn't give any result!"); } if (!surf) { return RAISE(PyExc_ValueError, "Resolution not set"); } #ifdef USE_FASTMEMCPY fast_memcpy(surf->pixels, render_data, width * height * sizeof(uint32_t)); #else memcpy(surf->pixels, render_data, width * height * sizeof(uint32_t)); #endif } return Py_BuildValue("O", PySurface_New(surf)); }
//-- Create ------------------------------------------------------------------- // Called once when the visualisation is created by XBMC. Do any setup here. //----------------------------------------------------------------------------- extern "C" void Create(void* pd3dDevice, int iPosX, int iPosY, int iWidth, int iHeight, const char* szVisualisationName, float fPixelRatio, const char *szSubModuleName) { strcpy(g_visName, szVisualisationName); m_vecSettings.clear(); m_uiVisElements = 0; /** Initialise Goom */ if (g_goom) { goom_close( g_goom ); g_goom = NULL; } g_goom = goom_init(g_tex_width, g_tex_height); if (!g_goom) return; g_goom_buffer = (unsigned char*)malloc(g_tex_width * g_tex_height * 4); goom_set_screenbuffer( g_goom, g_goom_buffer ); memset( g_audio_data, 0, sizeof(g_audio_data) ); g_window_width = iWidth; g_window_height = iHeight; g_window_xpos = iPosX; g_window_ypos = iPosY; #ifdef _WIN32 #ifndef _MINGW g_configFile = string(getenv("XBMC_PROFILE_USERDATA")) + "\\" + CONFIG_FILE; std::string presetsDir = string(getenv("XBMC_HOME")) + "\\" + PRESETS_DIR; #endif #else g_configFile = _P(CONFIG_FILE); std::string presetsDir = _P(PRESETS_DIR); #endif }
// our main method for processing images // should return a surface no matter what in the future static PyObject* pympav_process() { if(!sharedfile) { RAISE(PyExc_ValueError, "Export file not set"); } if (init == 0) { if (data_import_init() == 0) { goom_init(width, height, cinema); goom_setAsmUse(1); init = 1; } else { data_import_clean(); RAISE(PyExc_ValueError, "Error initializing mmap"); } } // This probably needs to be cleaned up if(mmap_area->count > counter) { //printf("Missed %i sound updates", mmap_area->count-counter); counter = mmap_area->count; memcpy( data, ((void *)mmap_area) + sizeof( data_t ), 2048 ); render_data = goom_update( data, 0, FXMODE, NULL, NULL); if(!render_data) { data_import_clean(); RAISE(PyExc_ValueError, "Goom didn't give any result!"); } } if(pysurf) { memcpy( pysurf->surf->pixels, render_data, width * height * sizeof(uint32_t) ); return (PySurfaceObject*)pysurf; } RETURN_NONE; }
/***************************************************************************** * Thread: *****************************************************************************/ static void* Thread( vlc_object_t *p_this ) { goom_thread_t *p_thread = (goom_thread_t*)p_this; int width, height, speed; date_t i_pts; int16_t p_data[2][512]; int i_data = 0, i_count = 0; PluginInfo *p_plugin_info; int canc = vlc_savecancel (); width = var_GetInteger( p_this, "goom-width" ); height = var_GetInteger( p_this, "goom-height" ); speed = var_CreateGetInteger( p_thread, "goom-speed" ); speed = MAX_SPEED - speed; if( speed < 0 ) speed = 0; p_plugin_info = goom_init( width, height ); while( vlc_object_alive (p_thread) ) { uint32_t *plane; picture_t *p_pic; /* goom_update is damn slow, so just copy data and release the lock */ vlc_mutex_lock( &p_thread->lock ); if( FillBuffer( (int16_t *)p_data, &i_data, &i_pts, &p_thread->date, p_thread ) != VLC_SUCCESS ) vlc_cond_wait( &p_thread->wait, &p_thread->lock ); vlc_mutex_unlock( &p_thread->lock ); /* Speed selection */ if( speed && (++i_count % (speed+1)) ) continue; /* Frame dropping if necessary */ if( date_Get( &i_pts ) + GOOM_DELAY <= mdate() ) continue; plane = goom_update( p_plugin_info, p_data, 0, 0.0, p_thread->psz_title, NULL ); free( p_thread->psz_title ); p_thread->psz_title = NULL; while( !( p_pic = vout_GetPicture( p_thread->p_vout ) ) && vlc_object_alive (p_thread) ) { msleep( VOUT_OUTMEM_SLEEP ); } if( p_pic == NULL ) break; memcpy( p_pic->p[0].p_pixels, plane, width * height * 4 ); p_pic->date = date_Get( &i_pts ) + GOOM_DELAY; vout_PutPicture( p_thread->p_vout, p_pic ); } goom_close( p_plugin_info ); vlc_restorecancel (canc); return NULL; }
/***************************************************************************** * Thread: *****************************************************************************/ static void Thread( vlc_object_t *p_this ) { goom_thread_t *p_thread = (goom_thread_t*)p_this; vlc_value_t width, height, speed; audio_date_t i_pts; int16_t p_data[2][512]; int i_data = 0, i_count = 0; PluginInfo *p_plugin_info; var_Get( p_this, "goom-width", &width ); var_Get( p_this, "goom-height", &height ); var_Create( p_thread, "goom-speed", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); var_Get( p_thread, "goom-speed", &speed ); speed.i_int = MAX_SPEED - speed.i_int; if( speed.i_int < 0 ) speed.i_int = 0; p_plugin_info = goom_init( width.i_int, height.i_int ); while( !p_thread->b_die ) { uint32_t *plane; picture_t *p_pic; /* goom_update is damn slow, so just copy data and release the lock */ vlc_mutex_lock( &p_thread->lock ); if( FillBuffer( (int16_t *)p_data, &i_data, &i_pts, &p_thread->date, p_thread ) != VLC_SUCCESS ) vlc_cond_wait( &p_thread->wait, &p_thread->lock ); vlc_mutex_unlock( &p_thread->lock ); /* Speed selection */ if( speed.i_int && (++i_count % (speed.i_int+1)) ) continue; /* Frame dropping if necessary */ if( aout_DateGet( &i_pts ) + GOOM_DELAY <= mdate() ) continue; plane = goom_update( p_plugin_info, p_data, 0, 0.0, p_thread->psz_title, NULL ); if( p_thread->psz_title ) { free( p_thread->psz_title ); p_thread->psz_title = NULL; } while( !( p_pic = vout_CreatePicture( p_thread->p_vout, 0, 0, 0 ) ) && !p_thread->b_die ) { msleep( VOUT_OUTMEM_SLEEP ); } if( p_pic == NULL ) break; memcpy( p_pic->p[0].p_pixels, plane, width.i_int * height.i_int * 4 ); vout_DatePicture( p_thread->p_vout, p_pic, aout_DateGet( &i_pts ) + GOOM_DELAY ); vout_DisplayPicture( p_thread->p_vout, p_pic ); } goom_close( p_plugin_info ); }