~ubuntu-branches/debian/experimental/gpac/experimental

« back to all changes in this revision

Viewing changes to src/utils/color.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2014-02-22 18:15:00 UTC
  • mfrom: (1.2.2) (3.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20140222181500-b4phupo05gjpmopa
Tags: 0.5.0+svn5104~dfsg1-1
* New  upstream version 0.5.0+svn5104~dfsg1:
  - src/utils/sha1.c is relicensed under LGPLv2.1, Closes: #730759
* Don't install modules in multi-arch directories, Closes: #730497
* Add libusb-1.0.0-dev headers because libfreenect requires this
* Fix install rule
* Follow upstream soname bump
  - Drop the symbols file for now until it has been revised thourougly
* Let binaries produce the correct svn revision
* Refresh patches
* Patch and build against libav10, Closes: #739321
* Bump standards version, no changes necessary

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
        }
110
110
}
111
111
 
 
112
static void gf_yuv_10_load_lines_planar(unsigned char *dst, s32 dststride, unsigned char *_y_src, unsigned char *_u_src, unsigned char *_v_src, s32 y_stride, s32 uv_stride, s32 width)
 
113
{
 
114
        u32 hw, x;
 
115
        unsigned char *dst2 = (unsigned char *) dst + dststride;
 
116
        unsigned short *y_src2 = (unsigned short *) (_y_src + y_stride);
 
117
        unsigned short *y_src = (unsigned short *)_y_src;
 
118
        unsigned short *u_src = (unsigned short *)_u_src;
 
119
        unsigned short *v_src = (unsigned short *)_v_src;
 
120
 
 
121
 
 
122
        hw = width / 2;
 
123
        for (x = 0; x < hw; x++) {
 
124
                s32 u, v;
 
125
                s32 b_u, g_uv, r_v, rgb_y;
 
126
 
 
127
                u = u_src[x] >> 2;
 
128
                v = v_src[x] >> 2;
 
129
 
 
130
                b_u = B_U[u];
 
131
                g_uv = G_U[u] + G_V[v];
 
132
                r_v = R_V[v];
 
133
 
 
134
                rgb_y = RGB_Y[*y_src >> 2];
 
135
                dst[0] = col_clip( (rgb_y + r_v) >> SCALEBITS_OUT);
 
136
                dst[1] = col_clip( (rgb_y - g_uv) >> SCALEBITS_OUT);
 
137
                dst[2] = col_clip( (rgb_y + b_u) >> SCALEBITS_OUT);
 
138
                dst[3] = 0xFF;
 
139
                y_src++;
 
140
 
 
141
                rgb_y = RGB_Y[*y_src >> 2];
 
142
                dst[4] = col_clip( (rgb_y + r_v) >> SCALEBITS_OUT);
 
143
                dst[5] = col_clip( (rgb_y - g_uv) >> SCALEBITS_OUT);
 
144
                dst[6] = col_clip( (rgb_y + b_u) >> SCALEBITS_OUT);
 
145
                dst[7] = 0xFF;
 
146
                y_src++;
 
147
 
 
148
                rgb_y = RGB_Y[*y_src2 >> 2];
 
149
                dst2[0] = col_clip( (rgb_y + r_v) >> SCALEBITS_OUT);
 
150
                dst2[1] = col_clip( (rgb_y - g_uv) >> SCALEBITS_OUT);
 
151
                dst2[2] = col_clip( (rgb_y + b_u) >> SCALEBITS_OUT);
 
152
                dst2[3] = 0xFF;
 
153
                y_src2++;
 
154
 
 
155
                rgb_y = RGB_Y[*y_src2 >> 2];
 
156
                dst2[4] = col_clip( (rgb_y + r_v) >> SCALEBITS_OUT);
 
157
                dst2[5] = col_clip( (rgb_y - g_uv) >> SCALEBITS_OUT);
 
158
                dst2[6] = col_clip( (rgb_y + b_u) >> SCALEBITS_OUT);
 
159
                dst2[7] = 0xFF;
 
160
                y_src2++;
 
161
 
 
162
                dst += 8;
 
163
                dst2 += 8;
 
164
        }
 
165
}
 
166
 
 
167
 
112
168
static void gf_yuv_load_lines_packed(unsigned char *dst, s32 dststride, unsigned char *y_src, unsigned char *u_src, unsigned char * v_src, s32 width)
113
169
{
114
170
        u32 hw, x;
744
800
 
745
801
static void load_line_bgr_32(u8 *src_bits, u32 x_offset, u32 y_offset, u32 y_pitch, u32 width, u32 height, u8 *dst_bits)
746
802
{
 
803
        u32 i;
747
804
        src_bits += x_offset*4 + y_offset*y_pitch;
748
 
        memcpy(dst_bits, src_bits, sizeof(char)*4*width);
 
805
        for (i=0; i<width; i++) {
 
806
                dst_bits[2] = *src_bits++;
 
807
                dst_bits[1] = *src_bits++;
 
808
                dst_bits[0] = *src_bits++;
 
809
                dst_bits[3] = *src_bits++;
 
810
                dst_bits += 4;
 
811
        }
749
812
}
750
813
 
751
 
static void load_line_yv12(char *src_bits, u32 x_offset, u32 y_offset, u32 y_pitch, u32 width, u32 height, u8 *dst_bits)
 
814
static void load_line_yv12(char *src_bits, u32 x_offset, u32 y_offset, u32 y_pitch, u32 width, u32 height, u8 *dst_bits, u8 *pU, u8 *pV)
752
815
{
753
 
        u8 *pY, *pU, *pV;
 
816
        u8 *pY;
754
817
        pY = (u8 *)src_bits;
755
 
        pU = (u8 *)src_bits + y_pitch*height;
756
 
        pV = (u8 *)src_bits + 5*y_pitch*height/4;
 
818
        if (!pU) {
 
819
                pU = (u8 *)src_bits + y_pitch*height;
 
820
                pV = (u8 *)src_bits + 5*y_pitch*height/4;
 
821
        }
 
822
 
757
823
        pY += x_offset + y_offset*y_pitch;
758
824
        pU += x_offset/2 + y_offset*y_pitch/4;
759
825
        pV += x_offset/2 + y_offset*y_pitch/4;
760
826
        gf_yuv_load_lines_planar((unsigned char*)dst_bits, 4*width, pY, pU, pV, y_pitch, y_pitch/2, width);
761
827
}
762
828
 
763
 
static void load_line_yuva(char *src_bits, u32 x_offset, u32 y_offset, u32 y_pitch, u32 width, u32 height, u8 *dst_bits)
764
 
{
765
 
        u8 *pY, *pU, *pV, *pA;
 
829
static void load_line_yv12_10(char *src_bits, u32 x_offset, u32 y_offset, u32 y_pitch, u32 width, u32 height, u8 *dst_bits, u8 *pU, u8 *pV)
 
830
{
 
831
        u8 *pY;
 
832
        pY = (u8 *)src_bits;
 
833
        if (!pU) {
 
834
                pU = (u8 *)src_bits + y_pitch*height;
 
835
                pV = (u8 *)src_bits + 5*y_pitch*height/4;
 
836
        }
 
837
 
 
838
        pY += x_offset + y_offset*y_pitch;
 
839
        pU += x_offset/2 + y_offset*y_pitch/4;
 
840
        pV += x_offset/2 + y_offset*y_pitch/4;
 
841
        gf_yuv_10_load_lines_planar((unsigned char*)dst_bits, 4*width, pY, pU, pV, y_pitch, y_pitch/2, width);
 
842
}
 
843
 
 
844
static void load_line_yuva(char *src_bits, u32 x_offset, u32 y_offset, u32 y_pitch, u32 width, u32 height, u8 *dst_bits, u8 *pU, u8 *pV, u8 *pA)
 
845
{
 
846
        u8 *pY;
766
847
        pY = (u8*)src_bits;
767
 
        pU = (u8*)src_bits + y_pitch*height;
768
 
        pV = (u8*)src_bits + 5*y_pitch*height/4;
769
 
        pA = (u8*)src_bits + 3*y_pitch*height/2;
 
848
        if (!pU) {
 
849
                pU = (u8*)src_bits + y_pitch*height;
 
850
                pV = (u8*)src_bits + 5*y_pitch*height/4;
 
851
                pA = (u8*)src_bits + 3*y_pitch*height/2;
 
852
        }
770
853
 
771
854
        pY += x_offset + y_offset*y_pitch;
772
855
        pU += x_offset/2 + y_offset*y_pitch/4;
905
988
                yuv2rgb_init();
906
989
                yuv_planar_type = 1;
907
990
                break;
 
991
        case GF_PIXEL_YV12_10:
 
992
                yuv2rgb_init();
 
993
                yuv_planar_type = 3;
 
994
                break;
908
995
        case GF_PIXEL_NV21:
909
996
                load_line = load_line_YUV420SP;
910
997
                break;
1029
1116
                                                the_row --;
1030
1117
                                                if (flip) the_row = src->height-2 - the_row;
1031
1118
                                                if (yuv_planar_type==1) {
1032
 
                                                        load_line_yv12(src->video_buffer, x_off, the_row, src->pitch_y, src_w, src->height, tmp);
 
1119
                                                        load_line_yv12(src->video_buffer, x_off, the_row, src->pitch_y, src_w, src->height, tmp, src->u_ptr, src->v_ptr);
 
1120
                                                } else if (yuv_planar_type==3) {
 
1121
                                                        load_line_yv12_10(src->video_buffer, x_off, the_row, src->pitch_y, src_w, src->height, tmp, src->u_ptr, src->v_ptr);
1033
1122
                                                } else {
1034
 
                                                        load_line_yuva(src->video_buffer, x_off, the_row, src->pitch_y, src_w, src->height, tmp);
 
1123
                                                        load_line_yuva(src->video_buffer, x_off, the_row, src->pitch_y, src_w, src->height, tmp, src->u_ptr, src->v_ptr, src->a_ptr);
1035
1124
                                                }
1036
1125
                                                the_row = src_row - 1;
1037
1126
 
1063
1152
                                } else {
1064
1153
                                        if (flip) the_row = src->height-2 - the_row;
1065
1154
                                        if (yuv_planar_type==1) {
1066
 
                                                load_line_yv12(src->video_buffer, x_off, the_row, src->pitch_y, src_w, src->height, tmp);
 
1155
                                                load_line_yv12(src->video_buffer, x_off, the_row, src->pitch_y, src_w, src->height, tmp, src->u_ptr, src->v_ptr);
 
1156
                                        } else if (yuv_planar_type==3) {
 
1157
                                                load_line_yv12_10(src->video_buffer, x_off, the_row, src->pitch_y, src_w, src->height, tmp, src->u_ptr, src->v_ptr);
1067
1158
                                        } else {
1068
 
                                                load_line_yuva(src->video_buffer, x_off, the_row, src->pitch_y, src_w, src->height, tmp);
 
1159
                                                load_line_yuva(src->video_buffer, x_off, the_row, src->pitch_y, src_w, src->height, tmp, src->u_ptr, src->v_ptr, src->a_ptr);
1069
1160
                                        }
1070
1161
                                        yuv_init = 1;
1071
1162
                                        rows = flip ? tmp + src_w * 4 : tmp;