Changeset 2edcd5be1ce653a36cce752dc4704a0edf92a311

Show
Ignore:
Timestamp:
22/01/05 21:35:24 (4 years ago)
Author:
Gildas Bazin <gbazin@videolan.org>
git-committer:
Gildas Bazin <gbazin@videolan.org> 1106426124 +0000
git-parent:

[e8e8633f716bc2126688aefddc4fdac16bee734a]

git-author:
Gildas Bazin <gbazin@videolan.org> 1106426124 +0000
Message:

* modules/video_filter/blend.c: chroma fixes for the YUY2 blending.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/video_filter/blend.c

    rb61d41e r2edcd5b  
    513513    uint8_t *p_trans; 
    514514    int i_x, i_y, i_pix_pitch, i_trans; 
     515    vlc_bool_t b_even = !((i_x_offset + p_filter->fmt_out.video.i_x_offset)%2); 
    515516 
    516517    i_pix_pitch = 2; 
     
    542543              p_src->p[A_PLANE].i_pitch * p_filter->fmt_in.video.i_y_offset; 
    543544 
     545    i_width = (i_width >> 1) << 1; /* Needs to be a multiple of 2 */ 
     546 
    544547#define MAX_TRANS 255 
    545548#define TRANS_BITS  8 
     
    552555    { 
    553556        /* Draw until we reach the end of the line */ 
    554         for( i_x = 0; i_x < i_width; i_x += 2
     557        for( i_x = 0; i_x < i_width; i_x++, b_even = !b_even
    555558        { 
    556559            i_trans = ( p_trans[i_x] * i_alpha ) / 255; 
     
    563566                /* Completely opaque. Completely overwrite underlying pixel */ 
    564567                p_dst[i_x * 2]     = p_src2_y[i_x]; 
    565                 p_dst[i_x * 2 + 1] = p_src2_u[i_x]; 
    566                 p_dst[i_x * 2 + 3] = p_src2_v[i_x]; 
     568 
     569                if( b_even ) 
     570                { 
     571                    p_dst[i_x * 2 + 1] = p_src2_u[i_x]; 
     572                    p_dst[i_x * 2 + 3] = p_src2_v[i_x]; 
     573                } 
    567574            } 
    568575            else 
     
    572579                    (uint16_t)p_src1[i_x * 2] * (MAX_TRANS - i_trans) ) 
    573580                    >> TRANS_BITS; 
    574                 p_dst[i_x * 2 + 1] = ( (uint16_t)p_src2_u[i_x] * i_trans + 
    575                     (uint16_t)p_src1[i_x * 2 + 1] * (MAX_TRANS - i_trans) ) 
    576                     >> TRANS_BITS; 
    577                 p_dst[i_x * 2 + 3] = ( (uint16_t)p_src2_v[i_x] * i_trans + 
    578                     (uint16_t)p_src1[i_x * 2 + 3] * (MAX_TRANS - i_trans) ) 
    579                     >> TRANS_BITS; 
    580             } 
    581  
    582             i_trans = ( p_trans[i_x+1] * i_alpha ) / 255; 
    583             if( !i_trans ) 
    584             { 
    585                 /* Completely transparent. Don't change pixel */ 
    586             } 
    587             else if( i_trans == MAX_TRANS ) 
    588             { 
    589                 /* Completely opaque. Completely overwrite underlying pixel */ 
    590                 p_dst[i_x * 2 + 2] = p_src2_y[i_x + 1]; 
    591             } 
    592             else 
    593             { 
    594                 /* Blending */ 
    595                 p_dst[i_x * 2 + 2] = ( (uint16_t)p_src2_y[i_x+1] * i_trans + 
    596                     (uint16_t)p_src1[i_x * 2 + 2] * (MAX_TRANS - i_trans) ) 
    597                     >> TRANS_BITS; 
     581 
     582                if( b_even ) 
     583                { 
     584                    p_dst[i_x * 2 + 1] = ( (uint16_t)p_src2_u[i_x] * i_trans + 
     585                        (uint16_t)p_src1[i_x * 2 + 1] * (MAX_TRANS - i_trans) ) 
     586                        >> TRANS_BITS; 
     587                    p_dst[i_x * 2 + 3] = ( (uint16_t)p_src2_v[i_x] * i_trans + 
     588                        (uint16_t)p_src1[i_x * 2 + 3] * (MAX_TRANS - i_trans) ) 
     589                        >> TRANS_BITS; 
     590                } 
    598591            } 
    599592        } 
     
    721714    uint8_t *p_src1, *p_src2, *p_dst; 
    722715    int i_x, i_y, i_pix_pitch, i_trans; 
     716    vlc_bool_t b_even = !((i_x_offset + p_filter->fmt_out.video.i_x_offset)%2); 
    723717 
    724718    i_pix_pitch = 2; 
     
    737731             i_src2_pitch * p_filter->fmt_in.video.i_y_offset; 
    738732 
     733    i_width = (i_width >> 1) << 1; /* Needs to be a multiple of 2 */ 
     734 
    739735#define MAX_TRANS 255 
    740736#define TRANS_BITS  8 
     
    747743    { 
    748744        /* Draw until we reach the end of the line */ 
    749         for( i_x = 0; i_x < i_width; i_x += 2
     745        for( i_x = 0; i_x < i_width; i_x++, b_even = !b_even
    750746        { 
    751747            i_trans = ( p_pal[p_trans[i_x]][3] * i_alpha ) / 255; 
     
    757753            { 
    758754                /* Completely opaque. Completely overwrite underlying pixel */ 
    759         /* NOTE: YUVP is actually YVUP */ 
    760755                p_dst[i_x * 2]     = p_pal[p_src2[i_x]][0]; 
    761                 p_dst[i_x * 2 + 1] = p_pal[p_src2[i_x]][2]; 
    762                 p_dst[i_x * 2 + 3] = p_pal[p_src2[i_x]][1]; 
     756 
     757                if( b_even ) 
     758                { 
     759                    p_dst[i_x * 2 + 1] = p_pal[p_src2[i_x]][1]; 
     760                    p_dst[i_x * 2 + 3] = p_pal[p_src2[i_x]][2]; 
     761                } 
    763762            } 
    764763            else 
    765764            { 
    766765                /* Blending */ 
    767         /* NOTE: YUVP is actually YVUP */ 
    768766                p_dst[i_x * 2]     = ( (uint16_t)p_pal[p_src2[i_x]][0] * 
    769767                    i_trans + (uint16_t)p_src1[i_x * 2] * 
    770768                    (MAX_TRANS - i_trans) ) >> TRANS_BITS; 
    771                 p_dst[i_x * 2 + 1] = ( (uint16_t)p_pal[p_src2[i_x]][2] * 
    772                     i_trans + (uint16_t)p_src1[i_x * 2 + 1] * 
    773                     (MAX_TRANS - i_trans) ) >> TRANS_BITS; 
    774                 p_dst[i_x * 2 + 3] = ( (uint16_t)p_pal[p_src2[i_x]][1] * 
    775                     i_trans + (uint16_t)p_src1[i_x * 2 + 3] * 
    776                     (MAX_TRANS - i_trans) ) >> TRANS_BITS; 
    777             } 
    778  
    779             i_trans = ( p_pal[p_trans[i_x+1]][3] * i_alpha ) / 255; 
    780             if( !i_trans ) 
    781             { 
    782                 /* Completely transparent. Don't change pixel */ 
    783             } 
    784             else if( i_trans == MAX_TRANS ) 
    785             { 
    786                 /* Completely opaque. Completely overwrite underlying pixel */ 
    787                 p_dst[i_x * 2 + 2] = p_pal[p_src2[i_x + 1]][0]; 
    788             } 
    789             else 
    790             { 
    791                 /* Blending */ 
    792                 p_dst[i_x * 2 + 2] = ( (uint16_t)p_pal[p_src2[i_x+1]][0] * 
    793                     i_trans + (uint16_t)p_src1[i_x * 2 + 2] * 
    794                     (MAX_TRANS - i_trans) ) >> TRANS_BITS; 
     769 
     770                if( b_even ) 
     771                { 
     772                    p_dst[i_x * 2 + 1] = ( (uint16_t)p_pal[p_src2[i_x]][1] * 
     773                        i_trans + (uint16_t)p_src1[i_x * 2 + 1] * 
     774                        (MAX_TRANS - i_trans) ) >> TRANS_BITS; 
     775                    p_dst[i_x * 2 + 3] = ( (uint16_t)p_pal[p_src2[i_x]][2] * 
     776                        i_trans + (uint16_t)p_src1[i_x * 2 + 3] * 
     777                        (MAX_TRANS - i_trans) ) >> TRANS_BITS; 
     778                } 
    795779            } 
    796780        }