Exemplo n.º 1
0
static void AA_ResizeHandler(aa_context *context)
{
	aa_resize(context);
	local_this->hidden->x_ratio = ((double)aa_imgwidth(context)) / ((double)local_this->screen->w);
	local_this->hidden->y_ratio = ((double)aa_imgheight(context)) / ((double)local_this->screen->h);

	fastscale (local_this->hidden->buffer, aa_image(context), local_this->hidden->w, aa_imgwidth (context), local_this->hidden->h, aa_imgheight (context));
	aa_renderpalette(context, local_this->hidden->palette, local_this->hidden->rparams, 0, 0, aa_scrwidth(context), aa_scrheight(context));
	aa_flush(context);
}
Exemplo n.º 2
0
void AaScreen::show() {
    int c;
    // make screen_buffer RGBA to grey
    uint8_t *aa_buf = (uint8_t*)aa_image(ascii_context);
    uint32_t *rgb_buf = (uint32_t*) screen_buffer;

    for(c = 0; c < geo.pixelsize; c++)
        aa_buf[c] = .30 * rgba_to_r(rgb_buf[c])
                    + .59 * rgba_to_g(rgb_buf[c])
                    + .11 * rgba_to_b(rgb_buf[c]);


    aa_render(ascii_context, ascii_rndparms, 0, 0, geo.w, geo.h);
    aa_flush(ascii_context);

}
Exemplo n.º 3
0
Arquivo: aa.c Projeto: forthyen/SDesk
/*****************************************************************************
 * Init: initialize aa video thread output method
 *****************************************************************************/
static int Init( vout_thread_t *p_vout )
{
    int i_index;
    picture_t *p_pic = NULL;

    I_OUTPUTPICTURES = 0;

    p_vout->output.i_chroma = VLC_FOURCC('R','G','B','2');
    p_vout->output.i_width = p_vout->p_sys->i_width;
    p_vout->output.i_height = p_vout->p_sys->i_height;
    p_vout->output.i_aspect = p_vout->p_sys->i_width
                               * VOUT_ASPECT_FACTOR / p_vout->p_sys->i_height;
    p_vout->output.pf_setpalette = SetPalette;

    /* Find an empty picture slot */
    for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
    {
        if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
        {
            p_pic = p_vout->p_picture + i_index;
            break;
        }
    }

    if( p_pic == NULL )
    {
        return -1;
    }

    /* Allocate the picture */
    p_pic->p->p_pixels = aa_image( p_vout->p_sys->aa_context );
    p_pic->p->i_lines = p_vout->p_sys->i_height;
    p_pic->p->i_visible_lines = p_vout->p_sys->i_height;
    p_pic->p->i_pitch = p_vout->p_sys->i_width;
    p_pic->p->i_pixel_pitch = 1;
    p_pic->p->i_visible_pitch = p_vout->p_sys->i_width;
    p_pic->i_planes = 1;

    p_pic->i_status = DESTROYED_PICTURE;
    p_pic->i_type   = DIRECT_PICTURE;

    PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
    I_OUTPUTPICTURES++;

    return 0;
}
Exemplo n.º 4
0
static void 
initialize (void)
{
  int i;
  context = aa_autoinit (&aa_defparams);
  if (context == NULL)
    {
      printf ("Failed to initialize aalib\n");
      exit (1);
    }
  aa_autoinitkbd(context, 0);
  params = aa_getrenderparams ();
  bitmap = aa_image (context);
  for (i = 0; i < 256; i++)
    aa_setpalette (palette, i, pal[i * 3] * 4,
		   pal[i * 3 + 1] * 4,
		   pal[i * 3 + 2] * 4);
  aa_hidecursor (context);
}
Exemplo n.º 5
0
SDL_Surface *AA_SetVideoMode(_THIS, SDL_Surface *current,
				int width, int height, int bpp, Uint32 flags)
{
	int mode;

	if ( AA_buffer ) {
		SDL_free( AA_buffer );
	}

	AA_buffer = SDL_malloc(width * height);
	if ( ! AA_buffer ) {
		SDL_SetError("Couldn't allocate buffer for requested mode");
		return(NULL);
	}

/* 	printf("Setting mode %dx%d\n", width, height); */

	SDL_memset(aa_image(AA_context), 0, aa_imgwidth(AA_context) * aa_imgheight(AA_context));
	SDL_memset(AA_buffer, 0, width * height);

	/* Allocate the new pixel format for the screen */
	if ( ! SDL_ReallocFormat(current, 8, 0, 0, 0, 0) ) {
		return(NULL);
	}

	/* Set up the new mode framebuffer */
	current->flags = SDL_FULLSCREEN;
	AA_w = current->w = width;
	AA_h = current->h = height;
	current->pitch = current->w;
	current->pixels = AA_buffer;

	AA_x_ratio = ((double)aa_imgwidth(AA_context)) / ((double)width);
	AA_y_ratio = ((double)aa_imgheight(AA_context)) / ((double)height);

	/* Set the blit function */
	this->UpdateRects = AA_DirectUpdate;

	/* We're done */
	return(current);
}
Exemplo n.º 6
0
Arquivo: aa.c Projeto: chouquette/vlc
/**
 * Return a pool of direct buffers
 */
static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
{
    vout_display_sys_t *sys = vd->sys;
    VLC_UNUSED(count);

    if (!sys->pool) {
        picture_resource_t rsc;

        memset(&rsc, 0, sizeof(rsc));
        rsc.p[0].p_pixels = aa_image(sys->aa_context);
        rsc.p[0].i_pitch = aa_imgwidth(sys->aa_context);
        rsc.p[0].i_lines = aa_imgheight(sys->aa_context);

        picture_t *p_picture = picture_NewFromResource(&vd->fmt, &rsc);
        if (!p_picture)
            return NULL;

        sys->pool = picture_pool_New(1, &p_picture);
    }
    return sys->pool;
}
Exemplo n.º 7
0
static int aarenderer_open(int w, int h, int fs) {
    int   argc = 1;
    char *argv[] = { "foo", NULL };
    int i;
    if (!aa_parseoptions(NULL, NULL, &argc, argv) || argc != 1) {
        printf("%s\n", aa_help);
        return 0;
    }
    context = aa_autoinit(&aa_defparams);
    if (context == NULL) {
        printf("Can not intialize aalib\n");
        return 0;
    }

    bitmap = aa_image (context);
    params = aa_getrenderparams ();
    for (i = 0; i < 256; i++)
        aa_setpalette(palette, i, pal[i * 3] * 4, pal[i * 3 + 1] * 4, pal[i * 3 + 2] * 4);
    aa_hidecursor(context);
    return 1;
}
Exemplo n.º 8
0
static GstFlowReturn
gst_aasink_render (GstBaseSink * basesink, GstBuffer * buffer)
{
  GstAASink *aasink;

  aasink = GST_AASINK (basesink);

  GST_DEBUG ("render");

  gst_aasink_scale (aasink, GST_BUFFER_DATA (buffer),   /* src */
      aa_image (aasink->context),       /* dest */
      aasink->width,            /* sw */
      aasink->height,           /* sh */
      aa_imgwidth (aasink->context),    /* dw */
      aa_imgheight (aasink->context));  /* dh */

  aa_render (aasink->context, &aasink->ascii_parms,
      0, 0, aa_imgwidth (aasink->context), aa_imgheight (aasink->context));
  aa_flush (aasink->context);
  aa_getevent (aasink->context, FALSE);

  return GST_FLOW_OK;
}
Exemplo n.º 9
0
static void AA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
{
	int i;
	SDL_Rect *rect;

	fastscale (AA_buffer, aa_image(AA_context), AA_w, aa_imgwidth (AA_context), AA_h, aa_imgheight (AA_context));
#if 1
	aa_renderpalette(AA_context, AA_palette, AA_rparams, 0, 0, aa_scrwidth(AA_context), aa_scrheight(AA_context));
#else
	/* Render only the rectangles in the list */
	printf("Update rects : ");
	for ( i=0; i < numrects; ++i ) {
		rect = &rects[i];
		printf("(%d,%d-%d,%d)", rect->x, rect->y, rect->w, rect->h);
		aa_renderpalette(AA_context, AA_palette, AA_rparams, rect->x * AA_x_ratio, rect->y * AA_y_ratio, rect->w * AA_x_ratio, rect->h * AA_y_ratio);
	}
	printf("\n");
#endif
	SDL_mutexP(AA_mutex);
	aa_flush(AA_context);
	SDL_mutexV(AA_mutex);
	return;
}
Exemplo n.º 10
0
static GstFlowReturn
gst_aasink_show_frame (GstVideoSink * videosink, GstBuffer * buffer)
{
  GstAASink *aasink;
  GstVideoFrame frame;

  aasink = GST_AASINK (videosink);

  GST_DEBUG ("show frame");

  if (!gst_video_frame_map (&frame, &aasink->info, buffer, GST_MAP_READ))
    goto invalid_frame;

  gst_aasink_scale (aasink, GST_VIDEO_FRAME_PLANE_DATA (&frame, 0),     /* src */
      aa_image (aasink->context),       /* dest */
      GST_VIDEO_INFO_WIDTH (&aasink->info),     /* sw */
      GST_VIDEO_INFO_HEIGHT (&aasink->info),    /* sh */
      GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 0), /* ss */
      aa_imgwidth (aasink->context),    /* dw */
      aa_imgheight (aasink->context));  /* dh */

  aa_render (aasink->context, &aasink->ascii_parms,
      0, 0, aa_imgwidth (aasink->context), aa_imgheight (aasink->context));
  aa_flush (aasink->context);
  aa_getevent (aasink->context, FALSE);
  gst_video_frame_unmap (&frame);

  return GST_FLOW_OK;

  /* ERRORS */
invalid_frame:
  {
    GST_DEBUG_OBJECT (aasink, "invalid frame");
    return GST_FLOW_ERROR;
  }
}
static void
resize(void){
    /*
     * this function is called by aa lib if windows resizes
     * further during init, because here we have to calculate
     * a little bit
     */

    aa_resize(c);

    aspect_save_screenres(aa_imgwidth(c),aa_imgheight(c));
    image_height =  aa_imgheight(c); //src_height;
    image_width = aa_imgwidth(c); //src_width;

    aspect(&image_width,&image_height,A_ZOOM);

    image_x = (aa_imgwidth(c) - image_width) / 2;
    image_y = (aa_imgheight(c) - image_height) / 2;
    screen_w = image_width * aa_scrwidth(c) / aa_imgwidth(c);
    screen_h = image_height * aa_scrheight(c) / aa_imgheight(c);
    screen_x = (aa_scrwidth(c) - screen_w) / 2;
    screen_y = (aa_scrheight(c) - screen_h) / 2;

    if(sws) sws_freeContext(sws);
    sws = sws_getContextFromCmdLine(src_width,src_height,image_format,
				   image_width,image_height,IMGFMT_Y8);

    memset(image, 0, sizeof(image));
    image[0] = aa_image(c) + image_y * aa_imgwidth(c) + image_x;

    memset(image_stride, 0, sizeof(image_stride));
    image_stride[0] = aa_imgwidth(c);

    showosdmessage=0;

}