2 * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
4 * Blackfin video color space converter operations
5 * convert I420 YV12 to RGB in various formats
7 * This file is part of FFmpeg.
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 #include "swscale_internal.h"
36 #define L1CODE __attribute__ ((l1_text))
41 void ff_bfin_yuv2rgb555_line (uint8_t *Y
, uint8_t *U
, uint8_t *V
, uint8_t *out
,
42 int w
, uint32_t *coeffs
) L1CODE
;
44 void ff_bfin_yuv2rgb565_line (uint8_t *Y
, uint8_t *U
, uint8_t *V
, uint8_t *out
,
45 int w
, uint32_t *coeffs
) L1CODE
;
47 void ff_bfin_yuv2rgb24_line (uint8_t *Y
, uint8_t *U
, uint8_t *V
, uint8_t *out
,
48 int w
, uint32_t *coeffs
) L1CODE
;
50 typedef void (* ltransform
)(uint8_t *Y
, uint8_t *U
, uint8_t *V
, uint8_t *out
,
51 int w
, uint32_t *coeffs
);
54 static void bfin_prepare_coefficients (SwsContext
*c
, int rgb
, int masks
)
57 oy
= c
->yOffset
&0xffff;
58 oy
= oy
>> 3; // keep everything U8.0 for offset calculation
60 c
->oc
= 128*0x01010101U
;
61 c
->oy
= oy
*0x01010101U
;
63 /* copy 64bit vector coeffs down to 32bit vector coeffs */
81 c
->rmask
= 0x001f * 0x00010001U
;
82 c
->gmask
= 0x03e0 * 0x00010001U
;
83 c
->bmask
= 0x7c00 * 0x00010001U
;
84 } else if (masks
== 565) {
85 c
->rmask
= 0x001f * 0x00010001U
;
86 c
->gmask
= 0x07e0 * 0x00010001U
;
87 c
->bmask
= 0xf800 * 0x00010001U
;
91 static int core_yuv420_rgb (SwsContext
*c
,
92 uint8_t **in
, int *instrides
,
93 int srcSliceY
, int srcSliceH
,
94 uint8_t **oplanes
, int *outstrides
,
95 ltransform lcscf
, int rgb
, int masks
)
97 uint8_t *py
,*pu
,*pv
,*op
;
99 int h2
= srcSliceH
>>1;
102 bfin_prepare_coefficients (c
, rgb
, masks
);
108 op
= oplanes
[0] + srcSliceY
*outstrides
[0];
112 lcscf (py
, pu
, pv
, op
, w
, &c
->oy
);
117 lcscf (py
, pu
, pv
, op
, w
, &c
->oy
);
129 static int bfin_yuv420_rgb555 (SwsContext
*c
,
130 uint8_t **in
, int *instrides
,
131 int srcSliceY
, int srcSliceH
,
132 uint8_t **oplanes
, int *outstrides
)
134 return core_yuv420_rgb (c
, in
, instrides
, srcSliceY
, srcSliceH
, oplanes
, outstrides
,
135 ff_bfin_yuv2rgb555_line
, 1, 555);
138 static int bfin_yuv420_bgr555 (SwsContext
*c
,
139 uint8_t **in
, int *instrides
,
140 int srcSliceY
, int srcSliceH
,
141 uint8_t **oplanes
, int *outstrides
)
143 return core_yuv420_rgb (c
, in
, instrides
, srcSliceY
, srcSliceH
, oplanes
, outstrides
,
144 ff_bfin_yuv2rgb555_line
, 0, 555);
147 static int bfin_yuv420_rgb24 (SwsContext
*c
,
148 uint8_t **in
, int *instrides
,
149 int srcSliceY
, int srcSliceH
,
150 uint8_t **oplanes
, int *outstrides
)
152 return core_yuv420_rgb (c
, in
, instrides
, srcSliceY
, srcSliceH
, oplanes
, outstrides
,
153 ff_bfin_yuv2rgb24_line
, 1, 888);
156 static int bfin_yuv420_bgr24 (SwsContext
*c
,
157 uint8_t **in
, int *instrides
,
158 int srcSliceY
, int srcSliceH
,
159 uint8_t **oplanes
, int *outstrides
)
161 return core_yuv420_rgb (c
, in
, instrides
, srcSliceY
, srcSliceH
, oplanes
, outstrides
,
162 ff_bfin_yuv2rgb24_line
, 0, 888);
165 static int bfin_yuv420_rgb565 (SwsContext
*c
,
166 uint8_t **in
, int *instrides
,
167 int srcSliceY
, int srcSliceH
,
168 uint8_t **oplanes
, int *outstrides
)
170 return core_yuv420_rgb (c
, in
, instrides
, srcSliceY
, srcSliceH
, oplanes
, outstrides
,
171 ff_bfin_yuv2rgb565_line
, 1, 565);
174 static int bfin_yuv420_bgr565 (SwsContext
*c
,
175 uint8_t **in
, int *instrides
,
176 int srcSliceY
, int srcSliceH
,
177 uint8_t **oplanes
, int *outstrides
)
179 return core_yuv420_rgb (c
, in
, instrides
, srcSliceY
, srcSliceH
, oplanes
, outstrides
,
180 ff_bfin_yuv2rgb565_line
, 0, 565);
184 SwsFunc
ff_bfin_yuv2rgb_get_func_ptr (SwsContext
*c
)
188 switch(c
->dstFormat
) {
189 case PIX_FMT_RGB555
: f
= bfin_yuv420_rgb555
; break;
190 case PIX_FMT_BGR555
: f
= bfin_yuv420_bgr555
; break;
191 case PIX_FMT_RGB565
: f
= bfin_yuv420_rgb565
; break;
192 case PIX_FMT_BGR565
: f
= bfin_yuv420_bgr565
; break;
193 case PIX_FMT_RGB24
: f
= bfin_yuv420_rgb24
; break;
194 case PIX_FMT_BGR24
: f
= bfin_yuv420_bgr24
; break;
199 av_log(c
, AV_LOG_INFO
, "BlackFin accelerated color space converter %s\n",
200 sws_format_name (c
->dstFormat
));