2 * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
5 * Blackfin Video Color Space Converters Operations
6 * convert I420 YV12 to RGB in various formats,
8 * This file is part of FFmpeg.
10 * FFmpeg is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * FFmpeg is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with FFmpeg; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
37 #include "swscale_internal.h"
40 #define L1CODE __attribute__ ((l1_text))
45 extern void ff_bfin_yuv2rgb555_line (uint8_t *Y
, uint8_t *U
, uint8_t *V
, uint8_t *out
,
46 int w
, uint32_t *coeffs
) L1CODE
;
48 extern void ff_bfin_yuv2rgb565_line (uint8_t *Y
, uint8_t *U
, uint8_t *V
, uint8_t *out
,
49 int w
, uint32_t *coeffs
) L1CODE
;
51 extern void ff_bfin_yuv2rgb24_line (uint8_t *Y
, uint8_t *U
, uint8_t *V
, uint8_t *out
,
52 int w
, uint32_t *coeffs
) L1CODE
;
54 typedef void (* ltransform_t
)(uint8_t *Y
, uint8_t *U
, uint8_t *V
, uint8_t *out
,
55 int w
, uint32_t *coeffs
);
58 static void bfin_prepare_coefficients (SwsContext
*c
, int rgb
, int masks
)
61 oy
= c
->yOffset
&0xffff;
62 oy
= oy
>> 3; // keep everything U8.0 for offset calculation
64 c
->oc
= 128*0x01010101U
;
65 c
->oy
= oy
*0x01010101U
;
67 /* copy 64bit vector coeffs down to 32bit vector coeffs */
85 c
->rmask
= 0x001f * 0x00010001U
;
86 c
->gmask
= 0x03e0 * 0x00010001U
;
87 c
->bmask
= 0x7c00 * 0x00010001U
;
88 } else if (masks
== 565) {
89 c
->rmask
= 0x001f * 0x00010001U
;
90 c
->gmask
= 0x07e0 * 0x00010001U
;
91 c
->bmask
= 0xf800 * 0x00010001U
;
95 static int core_yuv420_rgb (SwsContext
*c
,
96 uint8_t **in
, int *instrides
,
97 int srcSliceY
, int srcSliceH
,
98 uint8_t **oplanes
, int *outstrides
,
99 ltransform_t lcscf
, int rgb
, int masks
)
101 uint8_t *py
,*pu
,*pv
,*op
;
102 int w
= instrides
[0];
103 int h2
= srcSliceH
>>1;
106 bfin_prepare_coefficients (c
, rgb
, masks
);
112 op
= oplanes
[0] + srcSliceY
*outstrides
[0];
116 lcscf (py
, pu
, pv
, op
, w
, &c
->oy
);
121 lcscf (py
, pu
, pv
, op
, w
, &c
->oy
);
133 static int bfin_yuv420_rgb555 (SwsContext
*c
,
134 uint8_t **in
, int *instrides
,
135 int srcSliceY
, int srcSliceH
,
136 uint8_t **oplanes
, int *outstrides
)
138 return core_yuv420_rgb (c
, in
, instrides
, srcSliceY
, srcSliceH
, oplanes
, outstrides
,
139 ff_bfin_yuv2rgb555_line
, 1, 555);
142 static int bfin_yuv420_bgr555 (SwsContext
*c
,
143 uint8_t **in
, int *instrides
,
144 int srcSliceY
, int srcSliceH
,
145 uint8_t **oplanes
, int *outstrides
)
147 return core_yuv420_rgb (c
, in
, instrides
, srcSliceY
, srcSliceH
, oplanes
, outstrides
,
148 ff_bfin_yuv2rgb555_line
, 0, 555);
151 static int bfin_yuv420_rgb24 (SwsContext
*c
,
152 uint8_t **in
, int *instrides
,
153 int srcSliceY
, int srcSliceH
,
154 uint8_t **oplanes
, int *outstrides
)
156 return core_yuv420_rgb (c
, in
, instrides
, srcSliceY
, srcSliceH
, oplanes
, outstrides
,
157 ff_bfin_yuv2rgb24_line
, 1, 888);
160 static int bfin_yuv420_bgr24 (SwsContext
*c
,
161 uint8_t **in
, int *instrides
,
162 int srcSliceY
, int srcSliceH
,
163 uint8_t **oplanes
, int *outstrides
)
165 return core_yuv420_rgb (c
, in
, instrides
, srcSliceY
, srcSliceH
, oplanes
, outstrides
,
166 ff_bfin_yuv2rgb24_line
, 0, 888);
169 static int bfin_yuv420_rgb565 (SwsContext
*c
,
170 uint8_t **in
, int *instrides
,
171 int srcSliceY
, int srcSliceH
,
172 uint8_t **oplanes
, int *outstrides
)
174 return core_yuv420_rgb (c
, in
, instrides
, srcSliceY
, srcSliceH
, oplanes
, outstrides
,
175 ff_bfin_yuv2rgb565_line
, 1, 565);
178 static int bfin_yuv420_bgr565 (SwsContext
*c
,
179 uint8_t **in
, int *instrides
,
180 int srcSliceY
, int srcSliceH
,
181 uint8_t **oplanes
, int *outstrides
)
183 return core_yuv420_rgb (c
, in
, instrides
, srcSliceY
, srcSliceH
, oplanes
, outstrides
,
184 ff_bfin_yuv2rgb565_line
, 0, 565);
188 SwsFunc
ff_bfin_yuv2rgb_get_func_ptr (SwsContext
*c
)
192 switch(c
->dstFormat
) {
193 case PIX_FMT_RGB555
: f
= bfin_yuv420_rgb555
; break;
194 case PIX_FMT_BGR555
: f
= bfin_yuv420_bgr555
; break;
195 case PIX_FMT_RGB565
: f
= bfin_yuv420_rgb565
; break;
196 case PIX_FMT_BGR565
: f
= bfin_yuv420_bgr565
; break;
197 case PIX_FMT_RGB24
: f
= bfin_yuv420_rgb24
; break;
198 case PIX_FMT_BGR24
: f
= bfin_yuv420_bgr24
; break;
203 av_log(c
, AV_LOG_INFO
, "BlackFin Accelerated Color Space Converter %s\n",
204 sws_format_name (c
->dstFormat
));