static void flash_8 (FlashPrivate *priv, float rate, VisVideo *dest, VisVideo *src1, VisVideo *src2)
{
    if (rate < 0.5)
        visual_mem_copy (visual_video_get_pixels (dest), visual_video_get_pixels (src1), visual_video_get_size (src1));
    else
        visual_mem_copy (visual_video_get_pixels (dest), visual_video_get_pixels (src2), visual_video_get_size (src2));
}
const VisPluginInfo *get_plugin_info (void)
{
	static VisMorphPlugin morph = {
		.apply = lv_morph_alpha_apply,
		.vidoptions.depth =
			VISUAL_VIDEO_DEPTH_8BIT  |
			VISUAL_VIDEO_DEPTH_16BIT |
			VISUAL_VIDEO_DEPTH_24BIT |
			VISUAL_VIDEO_DEPTH_32BIT
	};

	static VisPluginInfo info = {
		.type     = VISUAL_PLUGIN_TYPE_MORPH,

		.plugname = "alphablend",
		.name     = "alphablend morph",
		.author   = "Dennis Smit <*****@*****.**>",
		.version  = "0.1",
		.about    = N_("An alphablend morph plugin"),
		.help     = N_("This morph plugin morphs between two video sources using the alphablend method"),
		.license  = VISUAL_PLUGIN_LICENSE_LGPL,

		.init     = lv_morph_alpha_init,
		.cleanup  = lv_morph_alpha_cleanup,

		.plugin   = &morph
	};

	return &info;
}

static int lv_morph_alpha_init (VisPluginData *plugin)
{
#if ENABLE_NLS
    bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
#endif

	return TRUE;
}

static void lv_morph_alpha_cleanup (VisPluginData *plugin)
{
    /* nothing to do */
}

static void lv_morph_alpha_apply (VisPluginData *plugin, float progress, VisAudio *audio, VisVideo *dest, VisVideo *src1, VisVideo *src2)
{
	alpha_blend_buffer (visual_video_get_pixels (dest),
	                    visual_video_get_pixels (src1),
	                    visual_video_get_pixels (src2),
	                    visual_video_get_size (dest),
	                    visual_video_get_depth (dest),
	                    progress);
}
Beispiel #3
0
static int render_now(LVAVSPipelineContainer *container, VisVideo *video, VisAudio *audio, int s)
{
    LVAVSPipeline *pipeline = LVAVS_PIPELINE_ELEMENT(container)->pipeline;

    int i;
    int count = visual_list_count(container->members);
    for(i = 0; i < count; i++) {
        LVAVSPipelineElement *element = visual_list_get(container->members, i);
        VisVideo *tmpvid;

        if(s) {
            pipeline->framebuffer = visual_video_get_pixels(pipeline->dummy_vid);
            pipeline->fbout = visual_video_get_pixels(video);
        } else {
            pipeline->fbout = visual_video_get_pixels(pipeline->dummy_vid);
            pipeline->framebuffer = visual_video_get_pixels(video);
        }

        switch (element->type) {
            case LVAVS_PIPELINE_ELEMENT_TYPE_ACTOR:

                visual_actor_set_video (element->data.actor, video);
                visual_actor_run (element->data.actor, audio);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_TRANSFORM:

                visual_transform_set_video (element->data.transform, video);
                visual_transform_run (element->data.transform, audio);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_CONTAINER:

                pipeline_container_run (LVAVS_PIPELINE_CONTAINER (element), video, audio);

                break;

            default:

                break;
        }

        if(pipeline->swap&1) {
            s^=1;
            pipeline->swap = 0;
        }

    }

    return s;
}
Beispiel #4
0
int visual_video_allocate_buffer (VisVideo *video)
{
	visual_return_val_if_fail (video != NULL, -VISUAL_ERROR_VIDEO_NULL);
	visual_return_val_if_fail (video->buffer != NULL, -VISUAL_ERROR_VIDEO_BUFFER_NULL);

	if (visual_video_get_pixels (video) != NULL) {
		if (visual_buffer_get_allocated (video->buffer)) {
			visual_video_free_buffer (video);
		} else {
			visual_log (VISUAL_LOG_ERROR, _("Trying to allocate an screen buffer on "
					"a VisVideo structure which points to an external screen buffer"));

			return -VISUAL_ERROR_VIDEO_HAS_PIXELS;
		}
	}

	if (visual_video_get_size (video) == 0) {
		visual_buffer_set_data (video->buffer, NULL);

		return VISUAL_OK;
	}

	visual_buffer_set_destroyer (video->buffer, visual_buffer_destroyer_free);
	visual_buffer_set_size (video->buffer, visual_video_get_size (video));
	visual_buffer_allocate_data (video->buffer);

	video->pixel_rows = visual_mem_new0 (void *, video->height);
	precompute_row_table (video);

	return VISUAL_OK;
}
static int act_infinite_render (VisPluginData *plugin, VisVideo *video, VisAudio *audio)
{
	VisBuffer *buffer;
	InfinitePrivate *priv;

	visual_return_val_if_fail (plugin != NULL, -1);
	visual_return_val_if_fail (video != NULL, -1);
	visual_return_val_if_fail (audio != NULL, -1);

	priv = visual_object_get_private (VISUAL_OBJECT (plugin));

	buffer = visual_buffer_new ();

	visual_buffer_set_data_pair (buffer, priv->pcm_data[0], sizeof (float) * 512);
	visual_audio_get_sample (audio, buffer, VISUAL_AUDIO_CHANNEL_LEFT);

	visual_buffer_set_data_pair (buffer, priv->pcm_data[1], sizeof (float) * 512);
	visual_audio_get_sample (audio, buffer, VISUAL_AUDIO_CHANNEL_LEFT);

	_inf_renderer (priv);
	_inf_display (priv, (uint8_t *) visual_video_get_pixels (video), video->pitch);

	visual_buffer_free (buffer);

	return 0;
}
VISUAL_C_LINKAGE
int lv_gforce_render (VisPluginData *plugin, VisVideo *video, VisAudio *audio)
{
    GForcePrivate *priv = (GForcePrivate *) visual_object_get_private (VISUAL_OBJECT (plugin));
    VisBuffer pcmbuf;
    VisBuffer freqbuf;
    int i;
    long time;
    float gSoundBuf[SND_BUF_SIZE];
    float gFFTBuf[FFT_BUF_SIZE];

    visual_buffer_set_data_pair (&pcmbuf, gSoundBuf, sizeof (gSoundBuf));
    visual_audio_get_sample_mixed_simple (audio, &pcmbuf, 2,
                                          VISUAL_AUDIO_CHANNEL_LEFT,
                                          VISUAL_AUDIO_CHANNEL_RIGHT);

    visual_buffer_set_data_pair (&freqbuf, gFFTBuf, sizeof (gFFTBuf));

    visual_audio_get_spectrum_for_sample_multiplied (&freqbuf, &pcmbuf, TRUE, 3.0);

    // Increase volume
    for (i = 0; i < SND_BUF_SIZE; i++)
        gSoundBuf[i] *= 32768;

    // Set the video buffer
    priv->gGF->SetOutVideoBuffer ((unsigned char *) visual_video_get_pixels (video));

    time = EgOSUtils::CurTimeMS ();
    priv->gGF->RecordSample (time, gSoundBuf, .000043, NUMSAMPLES, gFFTBuf, 1, FFT_BUF_SIZE);

    return 0;
}
static void act_bumpscope_render (VisPluginData *plugin, VisVideo *video, VisAudio *audio)
{
	BumpscopePrivate *priv = visual_plugin_get_private (plugin);
	priv->video = video;

	visual_audio_get_sample_mixed_simple (audio, priv->pcmbuf, 2,
			VISUAL_AUDIO_CHANNEL_LEFT,
			VISUAL_AUDIO_CHANNEL_RIGHT);

	__bumpscope_render_pcm (priv, visual_buffer_get_data (priv->pcmbuf));

	visual_mem_copy (visual_video_get_pixels (video), priv->rgb_buf2, visual_video_get_size (video));

	priv->colorupdate++;

	/* Let's not overload the color selector */
	if (priv->colorupdate > 1)
		priv->colorupdate = 0;

	if (priv->colorchanged == TRUE && priv->colorupdate == 0) {
		/* I couldn't hold myself */
		visual_param_set_value_color (
			visual_param_list_get (
				visual_plugin_get_params (plugin), "color"), &priv->color);
	}
}
static void have_data (GstElement *sink, GstBuffer *buffer, gpointer data)
{
	VisVideo *video = data;
	uint32_t *dest = visual_video_get_pixels (video);
	uint32_t *src = (uint32_t *) GST_BUFFER_DATA (buffer);

	visual_mem_copy (dest, src, GST_BUFFER_SIZE (buffer));
}
static void flash_24 (FlashPrivate *priv, float rate, VisVideo *dest, VisVideo *src1, VisVideo *src2)
{
    uint8_t *scrbuf;
    uint8_t *destbuf = visual_video_get_pixels (dest);
    int size;
    int i;

    if (rate < 0.5) {
        scrbuf = visual_video_get_pixels (src1);
        size = visual_video_get_size (src1);
    } else {
        scrbuf = visual_video_get_pixels (src2);
        size = visual_video_get_size (src2);
    }

    for (i = 0; i < size; i++)
        destbuf[i] = priv->replacetable[scrbuf[i]];
}
Beispiel #10
0
static void precompute_row_table (VisVideo *video)
{
	uint8_t **table, *row;
	int y;

	visual_return_if_fail (video->pixel_rows != NULL);

	table = (uint8_t **) video->pixel_rows;
	row = (uint8_t *) visual_video_get_pixels (video);

	for (y = 0; y < video->height; y++, row += video->pitch)
		*table++ = row;
}
static int lv_goom_render (VisPluginData *plugin, VisVideo *video, VisAudio *audio)
{
	GoomPrivate *priv = visual_object_get_private (VISUAL_OBJECT (plugin));
	VisSongInfo *songinfo;
	short pcmdata[2][512];
	float fpcmdata[2][512];
	uint32_t *buf;
	uint8_t *vidbuf = visual_video_get_pixels (video);
	int showinfo = TRUE;
	int i;

	visual_buffer_set_data_pair (priv->pcmbuf1, fpcmdata[0], sizeof (float) * 512);
	visual_audio_get_sample (audio, priv->pcmbuf1, VISUAL_AUDIO_CHANNEL_LEFT);

	visual_buffer_set_data_pair (priv->pcmbuf2, fpcmdata[1], sizeof (float) * 512);
	visual_audio_get_sample (audio, priv->pcmbuf2, VISUAL_AUDIO_CHANNEL_RIGHT);

	for (i = 0; i < 512; i++) {
		pcmdata[0][i] = fpcmdata[0][i] * 32767;
		pcmdata[1][i] = fpcmdata[1][i] * 32767;
	}

	/* Retrieve the songinfo */
	songinfo = VISUAL_ACTOR_PLUGIN (visual_plugin_get_specific (plugin))->songinfo;

	/* FIXME goom should support setting a pointer, so we don't need that final visual_mem_copy */
	if (songinfo != NULL && visual_songinfo_get_age (songinfo) <= 1 && showinfo == TRUE) {
	    VisSongInfoType songinfo_type = visual_songinfo_get_type (songinfo);

		if (songinfo_type == VISUAL_SONGINFO_TYPE_SIMPLE)
		    buf = goom_update (priv->goominfo, pcmdata, 0, 0, visual_songinfo_get_simple_name (songinfo), NULL);
		else if (songinfo_type == VISUAL_SONGINFO_TYPE_ADVANCED)
		    buf = goom_update (priv->goominfo, pcmdata, 0, 0, visual_songinfo_get_song (songinfo), NULL);
		else
			buf = goom_update (priv->goominfo, pcmdata, 0, 0, NULL, NULL);
	}
	else
		buf = goom_update (priv->goominfo, pcmdata, 0, 0, NULL, NULL);

	visual_mem_copy_pitch (vidbuf, buf, video->pitch,
			video->width * video->bpp,
			video->width * video->bpp,
			video->height);

	return 0;
}
static int act_jakdaw_render (VisPluginData *plugin, VisVideo *video, VisAudio *audio)
{
	JakdawPrivate *priv = visual_object_get_private (VISUAL_OBJECT (plugin));
	uint32_t *vscr = visual_video_get_pixels (video);

	visual_audio_get_sample_mixed_simple (audio, priv->pcmbuf, 2,
			VISUAL_AUDIO_CHANNEL_LEFT,
			VISUAL_AUDIO_CHANNEL_RIGHT);

	visual_audio_get_spectrum_for_sample (priv->freqbuf, priv->pcmbuf, TRUE);

	_jakdaw_feedback_render (priv, vscr);
	_jakdaw_plotter_draw (priv,
			visual_buffer_get_data (priv->pcmbuf),
			visual_buffer_get_data (priv->freqbuf), vscr);

	return 0;
}
Beispiel #13
0
void do_alpha (VisVideo *vid, uint8_t rate)
{
	int i;
	uint32_t *ptr = visual_video_get_pixels(vid); //vid->pixels;
	union {
		uint32_t c32;
		uint8_t c8[4];
	} col;

	for (i = 0; i < vid->width * vid->height; i++) {
		col.c32 = ptr[i];
	
		col.c8[3] = rate;
		
//		if (col.c8[0] > 140) {
//			col.c8[3] = rate - (200 - col.c8[0]);
//		}
		ptr[i] = col.c32;
	}
}
Beispiel #14
0
int visual_video_free_buffer (VisVideo *video)
{
	visual_return_val_if_fail (video != NULL, -VISUAL_ERROR_VIDEO_NULL);
	visual_return_val_if_fail (visual_video_get_pixels (video) != NULL, -VISUAL_ERROR_VIDEO_PIXELS_NULL);

	if (video->pixel_rows != NULL)
		visual_mem_free (video->pixel_rows);

	if (visual_buffer_get_allocated (video->buffer)) {

		visual_buffer_destroy_content (video->buffer);

	} else {
		return -VISUAL_ERROR_VIDEO_NO_ALLOCATED;
	}

	video->pixel_rows = NULL;
	visual_buffer_set_data_pair (video->buffer, NULL, 0);

	return VISUAL_OK;
}
Beispiel #15
0
int pipeline_container_run (LVAVSPipelineContainer *container, VisVideo *video, VisAudio *audio)
{
    int i, s = 0;
    VisListEntry *le = NULL;
    LVAVSPipelineElement *element;
    VisBuffer pcmbuf1;
    VisBuffer pcmbuf2;
    VisBuffer spmbuf1;
    VisBuffer spmbuf2;
    VisBuffer tmp;
    int *fbout;
    int *framebuffer;
    LVAVSPipeline *pipeline = LVAVS_PIPELINE_ELEMENT(container)->pipeline;
    int w = video->width, h = video->height;

    if(video->width != pipeline->dummy_vid->width || video->height != pipeline->dummy_vid->height || video->depth != pipeline->dummy_vid->depth) {

        if(pipeline->dummy_vid)
            visual_object_unref(VISUAL_OBJECT(pipeline->dummy_vid));

        if(pipeline->last_vid)
            visual_object_unref(VISUAL_OBJECT(pipeline->last_vid));
    
        pipeline->dummy_vid = visual_video_scale_depth_new(video, video->width, video->height, video->depth, VISUAL_VIDEO_COMPOSITE_TYPE_SRC);

        pipeline->last_vid = visual_video_scale_depth_new(video, video->width, video->height, video->depth, VISUAL_VIDEO_COMPOSITE_TYPE_SRC);
        
        for(i = 0; i < 16; i++) {
            VisVideo *vid = pipeline->buffers[i];
            if(vid)
                visual_object_unref(VISUAL_OBJECT(vid));
            vid = visual_video_scale_depth_new(video, video->width, video->height, video->depth, VISUAL_VIDEO_COMPOSITE_TYPE_NONE);
            pipeline->buffers[i] = vid;
        }
    }

    visual_video_blit_overlay(video, pipeline->last_vid, 0, 0, 0.5);
      
    fbout = visual_video_get_pixels(video);
    framebuffer = visual_video_get_pixels(pipeline->dummy_vid);

    int is_preinit = pipeline->isBeat;//(pipeline->isBeat&0x80000000);

/*    if(pipeline->isBeat && beat_render)
    fake_enabled = beat_render_frames;
*/
    s = render_now(container, video, audio, s);

    if(!is_preinit)
    {
        int x = video->width * video->height;
        int *tfb=framebuffer;
        int *o = fbout;
        int use_blendin=blendin(pipeline->blendmode);
        if(use_blendin == 10 && pipeline->use_inblendval >= 255)
            use_blendin=1;

        switch (use_blendin)
        {
            case 1:
                visual_mem_copy(o, tfb, w*h*sizeof(int));
            break;
            case 2:
                mmx_avgblend_block(o,tfb,x);
            break;
            case 3:
                while(x--)
                {
                    *o=BLEND_MAX(*o, *tfb++);
                    o++;
                }
            break;
            case 4:
            //mmx_addblend_block(pipeline->blendtable, o, tfb, x);
            break;
            case 5:
                while(x--)
                {
                    *o=BLEND_SUB(*o,*tfb++);
                    o++;
                }
            break;
            case 6:
                while(x--)
                {
                    *o=BLEND_SUB(*tfb++, *o);
                    o++;
                }
            break;
            case 7:
            {
                int y=h/2;
                while(x-- > 0)
                {
                    visual_mem_copy(o,tfb,w*sizeof(int));
                    tfb+=w*2;
                    o+=w*2;
                }
            break;
            }
            case 8:
            {
                int r = 0;
                int y = h;
                while(y-- > 0)
                {
                    int *out, *in;
                    int x=w/2;
                    out=o+r;
                    in=tfb+r;
                    r^=1;
                    while(x-- > 0)
                    {
                        *out=*in;
                        out+=2;
                        in+=2;
                    }
                    o+=w;
                    tfb+=w;
                }
            break;
            }
            case 9:
                while(x--)
                {
                    *o=*o^*tfb++;
                    o++;
                }
            break;
            case 10:
                mmx_adjblend_block(pipeline->blendtable,o,tfb,o,x,pipeline->use_inblendval);
            break;
            case 11:
                mmx_mulblend_block(pipeline->blendtable, o,tfb,x);
            break;
            case 13:
                while(x--)
                {
                    *o=BLEND_MIN(*o,*tfb++);
                    o++;
                }
            break;
            case 12:
    /*
                                    {
                                            int *buf=(int*)getGlobalBuffer(w,h,bufferin,0);
                                            if (!buf) break;
                                            while (x--)
                                            {
                                                    *o=BLEND_ADJ(*tfb++,*o, depthof(*buf, ininvert));
                                                    o++;
                                                    buf++;
                                            }
                                    }
    */
            break;
            default:
            break;
        }
    }
    int x;
    int line_blend_mode_save=pipeline->blendmode;
    //if(!is_preinit) pipeline->blendmode = 0;

    s = render_now(container, video, audio, s);
    //if(!is_preinit) pipeline->blendmode = line_blend_mode_save;

    if(!is_preinit)
    {
        if(s) visual_mem_copy(framebuffer, fbout, w*h*sizeof(int));

        int *tfb=s?fbout:framebuffer;
        int *o=framebuffer;
        x=w*h;
        int use_blendout=blendout(pipeline->blendmode);
        int use_outblendval = 100;
        if(use_blendout == 10 && use_outblendval >= 255)
            use_blendout=1;
        switch(use_blendout)
        {
            case 1:
                visual_mem_copy(o,tfb,x*sizeof(int));
            break;
            case 2:
                mmx_avgblend_block(o,tfb,x);
            break;
            case 3:
                while(x--)
                {
                    *o=BLEND_MAX(*o, *tfb++);
                    o++;
                }
            break;
            case 4:
                mmx_addblend_block(o, tfb, x);
            break;
            case 5:
                while(x--)
                {
                    *o = BLEND_SUB(*o, *tfb++);
                    o++;
                }
            break;
            case 6:
                while(x--)
                {
                    *o=BLEND_SUB(*tfb++, *o);
                    o++;
                }
            break;
            case 7:
            {
                int y=h/2;
                while(y-- > 0)
                {
                    visual_mem_copy(o, tfb, w*sizeof(int));
                    tfb+=w*2;
                    o+=w*2;
                }
            }
            break;
            case 8:
            {
                int r = 0;
                int y = h;
                while(y-- > 0)
                {
                    int *out, *in;
                    int x=w/2;
                    out=o+r;
                    in=tfb+r;
                    r^=1;
                    while(x-- > 0)
                    {
                        *out=*in;
                        out+=2;
                        in+=2;
                    }
                    o+=w;
                    tfb+=2;
                }
            }
            case 9:
                while(x--)
                {
                    *o=*o^*tfb++;
                    o++;
                }
            break;
            case 10:
                mmx_adjblend_block(pipeline->blendtable,o, tfb, o, x, use_outblendval);
            break;
            case 11:
                mmx_mulblend_block(pipeline->blendtable, o, tfb, x);
            break;
            case 13:
                while(x--)
                {
                    *o=BLEND_MIN(*o, *tfb++);
                    o++;
                }
            break;
            case 12:
            {
                //uint32_t *buf = buffer[bufferout]
            }
            break;
            default:
            break;
        }
    } 

    // Save state for next frame.
    visual_video_blit_overlay(pipeline->last_vid, video, 0, 0, 0);
    return VISUAL_OK;
}
Beispiel #16
0
void
upload_gl_texture (VisVideo *image)
{
  glTexImage2D(GL_TEXTURE_2D, 0, 3, visual_video_get_width (image), visual_video_get_height (image),
               0, GL_RGB, GL_UNSIGNED_BYTE, visual_video_get_pixels (image));
}
Beispiel #17
0
int visual_bin_switch_actor (VisBin *bin, VisActor *actor)
{
	VisVideo *privvid;

	visual_log_return_val_if_fail (bin != NULL, -1);
	visual_log_return_val_if_fail (actor != NULL, -1);

	/* Set the new actor */
	bin->actmorph = actor;

	visual_log (VISUAL_LOG_DEBUG, "entering...");
	
	/* Free the private video */
	if (bin->privvid != NULL) {
		visual_object_unref (VISUAL_OBJECT (bin->privvid));
		
		bin->privvid = NULL;
	}

	visual_log (VISUAL_LOG_INFO, _("depth of the main actor: %d"), bin->actor->video->depth);

	/* Starting the morph, but first check if we don't have anything todo with openGL */
	if (bin->morphstyle == VISUAL_SWITCH_STYLE_MORPH &&
			bin->actor->video->depth != VISUAL_VIDEO_DEPTH_GL &&
			bin->actmorph->video->depth != VISUAL_VIDEO_DEPTH_GL &&
			bin->depthfromGL != TRUE) {

		if (bin->morph != NULL && bin->morph->plugin != NULL) {
			visual_morph_set_rate (bin->morph, 0);
		
			visual_morph_set_video (bin->morph, bin->actvideo);

			if (bin->morphautomatic == TRUE)
				visual_morph_set_mode (bin->morph, bin->morphmode);
			else
				visual_morph_set_mode (bin->morph, VISUAL_MORPH_MODE_SET);
			
			visual_morph_set_time (bin->morph, &bin->morphtime);
			visual_morph_set_steps (bin->morph, bin->morphsteps);
		}

		bin->morphrate = 0;
		bin->morphstepsdone = 0;

		visual_log (VISUAL_LOG_DEBUG, "phase 1");
		/* Allocate a private video for the main actor, so the morph
		 * can draw to the framebuffer */
		privvid = visual_video_new ();

		visual_log (VISUAL_LOG_DEBUG, "actvideo->depth %d actmorph->video->depth %d",
				bin->actvideo->depth, bin->actmorph->video->depth);

		visual_log (VISUAL_LOG_DEBUG, "phase 2");
		visual_video_clone (privvid, bin->actvideo);
		visual_log (VISUAL_LOG_DEBUG, "phase 3 pitch privvid %d actvideo %d", privvid->pitch, bin->actvideo->pitch);

		visual_video_allocate_buffer (privvid);

		visual_log (VISUAL_LOG_DEBUG, "phase 4");
		/* Initial privvid initialize */
	
		visual_log (VISUAL_LOG_DEBUG, "actmorph->video->depth %d %p", bin->actmorph->video->depth,
				visual_video_get_pixels (bin->actvideo));
		
		if (visual_video_get_pixels (bin->actvideo) != NULL && visual_video_get_pixels (privvid) != NULL)
			visual_mem_copy (visual_video_get_pixels (privvid), visual_video_get_pixels (bin->actvideo),
					visual_video_get_size (privvid));
		else if (visual_video_get_pixels (privvid) != NULL)
			visual_mem_set (visual_video_get_pixels (privvid), 0, visual_video_get_size (privvid));

		visual_actor_set_video (bin->actor, privvid);
		bin->privvid = privvid;
	} else {
		visual_log (VISUAL_LOG_DEBUG, "Pointer actvideo->pixels %p", visual_video_get_pixels (bin->actvideo));
		if (bin->actor->video->depth != VISUAL_VIDEO_DEPTH_GL &&
				visual_video_get_pixels (bin->actvideo) != NULL) {
			visual_mem_set (visual_video_get_pixels (bin->actvideo), 0, visual_video_get_size (bin->actvideo));
		}
	}

	visual_log (VISUAL_LOG_DEBUG, "Leaving, actor->video->depth: %d actmorph->video->depth: %d",
			bin->actor->video->depth, bin->actmorph->video->depth);

	bin->morphing = TRUE;

	return 0;
}
Beispiel #18
0
static int load_uncompressed (FILE *fp, VisVideo *video, int depth)
{
	uint8_t *data;
	int i;
	int pad;

	pad = (4 - (video->pitch & 3)) & 3;
	data = (uint8_t *) visual_video_get_pixels (video) + (video->height * video->pitch);

	switch (depth) {
		case 24:
		case 8:
			while (data > (uint8_t *) visual_video_get_pixels (video)) {
				data -= video->pitch;

				if (fread (data, video->pitch, 1, fp) != 1)
					goto err;

				if (pad)
					fseek (fp, pad, SEEK_CUR);
			}
			break;

		case 4:
			while (data > (uint8_t *) visual_video_get_pixels (video)) {
				/* Unpack 4 bpp pixels aka 2 pixels per byte */
				uint8_t *col = data - video->pitch;
				uint8_t *end = (uint8_t *) ((int)data & ~1);
				data = col;

				while (col < end) {
					uint8_t p = fgetc (fp);
					*col++ = p >> 4;
					*col++ = p & 0xf;
				}

				if (video->pitch & 1)
					*col++ = fgetc (fp) >> 4;

				if (pad)
					fseek (fp, pad, SEEK_CUR);
			}
			break;

		case 1:
			while (data > (uint8_t *) visual_video_get_pixels (video)) {
				/* Unpack 1 bpp pixels aka 8 pixels per byte */
				uint8_t *col = data - video->pitch;
				uint8_t *end = (uint8_t *) ((int)data & ~7);
				data = col;

				while (col < end) {
					uint8_t p = fgetc (fp);
					for (i=0; i < 8; i++) {
						*col++ = p >> 7;
						p <<= 1;
					}
				}

				if (video->pitch & 7) {
					uint8_t p = fgetc (fp);
					uint8_t count = video->pitch & 7;
					for (i=0; i < count; i++) {
						*col++ = p >> 7;
						p <<= 1;
					}
				}

				if (pad)
					fseek (fp, pad, SEEK_CUR);
			}
			break;
	}