Better rendering
authorlekernel <sebastien.bourdeauducq@lekernel.net>
Tue, 16 Feb 2010 16:37:19 +0000 (17:37 +0100)
committerlekernel <sebastien.bourdeauducq@lekernel.net>
Tue, 16 Feb 2010 16:37:19 +0000 (17:37 +0100)
software/demo/apipe.c
software/demo/renderer.c
software/demo/renderer.h
software/demo/rpipe.c
software/demo/rpipe.h
software/demo/wave.c

index 67674fb..5fcc52c 100644 (file)
@@ -49,6 +49,8 @@ static struct rpipe_frame frame2 __attribute__((aligned(8)));
 static int frame1_free;
 static int frame2_free;
 
+static unsigned int all_frames;
+
 static struct rpipe_frame *alloc_rpipe_frame()
 {
        if(frame1_free) return &frame1;
@@ -81,6 +83,7 @@ void apipe_init()
        eval_ready = 1;
        frame1_free = 1;
        frame2_free = 1;
+       all_frames = 0;
        printf("API: analysis pipeline ready\n");
 }
 
@@ -139,11 +142,22 @@ static void pvv_callback(struct pfpu_td *td)
 static void pfv_callback(struct pfpu_td *td)
 {
        struct rpipe_frame *rpipe_frame;
+       int brightness256, brightness64, frame_mod;
 
        rpipe_frame = (struct rpipe_frame *)td->user;
 
-       // XXX HACK try to make picture less dark
-       rpipe_frame->brightness = 62; //63.0f*eval_read_pfv(eval, pfv_decay);
+       brightness256 = 257.0f*eval_read_pfv(eval, pfv_decay);
+       brightness64 = brightness256 >> 2;
+       brightness256 &= 3;
+       frame_mod = rpipe_frame->framenr & 3;
+       if((brightness256 == 1) && (frame_mod == 0))
+               brightness64++;
+       if((brightness256 == 2) && ((frame_mod == 0)||(frame_mod == 2)))
+               brightness64++;
+       if((brightness256 == 3) && (frame_mod != 3))
+               brightness64++;
+       if(brightness64 > 63) brightness64 = 63;
+       rpipe_frame->brightness = brightness64;
 
        rpipe_frame->wave_mode = eval_read_pfv(eval, pfv_wave_mode);
        rpipe_frame->wave_scale = eval_read_pfv(eval, pfv_wave_scale);
@@ -215,6 +229,7 @@ static void analyzer_bottom_half()
 
        rpipe_frame->time = time;
        rpipe_frame->treb = ftreb;
+       rpipe_frame->framenr = all_frames++;
 
        eval_pfv_fill_td(eval, &pfpu_td, pfv_callback, rpipe_frame);
        pfpu_submit_task(&pfpu_td);
index 4f1d3bc..e7ea41c 100644 (file)
@@ -27,9 +27,9 @@
 #include "apipe.h"
 #include "renderer.h"
 
-unsigned int renderer_hmeshlast;
-unsigned int renderer_vmeshlast;
-unsigned int renderer_texsize;
+int renderer_hmeshlast;
+int renderer_vmeshlast;
+int renderer_texsize;
 
 void renderer_init()
 {
index 175c7ae..5b81033 100644 (file)
@@ -18,9 +18,9 @@
 #ifndef __RENDERER_H
 #define __RENDERER_H
 
-extern unsigned int renderer_hmeshlast;
-extern unsigned int renderer_vmeshlast;
-extern unsigned int renderer_texsize;
+extern int renderer_hmeshlast;
+extern int renderer_vmeshlast;
+extern int renderer_texsize;
 
 void renderer_init();
 int renderer_start(char *preset_code);
index 12b1b34..f96dc79 100644 (file)
@@ -202,8 +202,8 @@ static int wave_mode_5(struct wave_vertex *vertices)
                x0 = 2.0*s1*s2;
                y0 = s1*s1 - s2*s2;
 
-               vertices[i].x = (float)vga_hres*((x0*cos_rot - y0*sin_rot)*bh_frame->wave_scale*0.5 + bh_frame->wave_x);
-               vertices[i].y = (float)vga_vres*((x0*sin_rot + y0*cos_rot)*bh_frame->wave_scale*0.5 + bh_frame->wave_y);
+               vertices[i].x = (float)renderer_texsize*((x0*cos_rot - y0*sin_rot)*bh_frame->wave_scale*0.5 + bh_frame->wave_x);
+               vertices[i].y = (float)renderer_texsize*((x0*sin_rot + y0*cos_rot)*bh_frame->wave_scale*0.5 + bh_frame->wave_y);
        }
 
        return nvertices;
@@ -240,7 +240,7 @@ static void rpipe_draw_waves()
        params.wave_r = bh_frame->wave_r;
        params.wave_g = bh_frame->wave_g;
        params.wave_b = bh_frame->wave_b;
-       params.wave_a = bh_frame->wave_a+10; // XXX HACK try to make picture less dark
+       params.wave_a = bh_frame->wave_a;
        
        params.treb = bh_frame->treb;
 
index a09a105..8377774 100644 (file)
@@ -38,6 +38,7 @@ struct rpipe_frame {
        float wave_r, wave_b, wave_g, wave_a;
        float treb;
        float time;
+       unsigned int framenr;
        unsigned int nsamples; /* < audio samples */
        short *samples;
        rpipe_callback callback;
index 4b11b45..981970a 100644 (file)
@@ -86,7 +86,11 @@ void wave_draw(unsigned short *framebuffer, unsigned int hres, unsigned int vres
        if(b > 31) b = 31;
 
        ctx.color = MAKERGB565(r, g, b);
-       ctx.alpha = 64.0*wave_o; /* line drawing code treats >= 64 as 64, no need to clamp */
+       /*
+        * HACK: Boost wave opacity (80 instead of 64).
+        * Line drawing code treats >= 64 as 64, no need to clamp
+        */
+       ctx.alpha = 80.0*wave_o;
 
        // Original code:
        // glLineStipple(2, 0xAAAA);