Changeset 1104 for trunk


Ignore:
Timestamp:
03/26/11 21:40:07 (2 years ago)
Author:
reyalP
Message:

histogram fixes from philmoz in http://chdk.setepontos.com/index.php?topic=650.msg63231#msg63231

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/histogram.c

    r1024 r1104  
    6161} 
    6262 
     63// Define how many viewport blocks to step in each loop iteration. Each block is 6 bytes (UYVYYY) or 4 image pixels 
     64#define HISTO_STEP_SIZE 6 
     65 
    6366void histogram_process() 
    6467{ 
     
    6669    int i, hi, c; 
    6770    int y, v, u; 
    68         static int x, img_offset; 
     71        static int x; 
    6972    static int viewport_size; 
    7073    unsigned int histo_fill[5]; 
     
    7780                  img = vid_get_viewport_fb(); 
    7881                    } 
    79                         img_offset = vid_get_viewport_image_offset();           // offset into viewport for when image size != viewport size (e.g. 16:9 image on 4:3 LCD) 
     82                        img += vid_get_viewport_image_offset();         // offset into viewport for when image size != viewport size (e.g. 16:9 image on 4:3 LCD) 
    8083            viewport_size = vid_get_viewport_height() * vid_get_viewport_buffer_width(); 
    8184            for (c=0; c<5; ++c) { 
     
    9295        case 2: 
    9396        case 3: 
    94                         x = 0; 
    95             for (i=(histogram_stage-1)*6; i<viewport_size*3; i+=6*3*2) { 
    96                 y = img[img_offset+i+1]; 
    97                 u = *(signed char*)(&img[img_offset+i]); 
     97                        x = 0;  // count how many blocks we have done on the current row (to skip unused buffer space at end of each row) 
     98            for (i=(histogram_stage-1)*6; i<viewport_size*3; i+=HISTO_STEP_SIZE*6) { 
     99                y = img[i+1]; 
     100                u = *(signed char*)(&img[i]); 
    98101                if (u&0x00000080) u|=0xFFFFFF00; 
    99                 v = *(signed char*)(&img[img_offset+i+2]); 
     102                v = *(signed char*)(&img[i+2]); 
    100103                if (v&0x00000080) v|=0xFFFFFF00; 
    101104 
     
    110113 
    111114                                // Handle case where viewport memory buffer is wider than the actual buffer. 
    112                                 x++; 
     115                                x += HISTO_STEP_SIZE * 2;       // viewport width is measured in blocks of three bytes each even though the data is stored in six byte chunks ! 
    113116                                if (x == vid_get_viewport_width()) 
    114117                                { 
Note: See TracChangeset for help on using the changeset viewer.