History

swscale: K&R formatting cosmetics for Blackfin code

Also prettyprint some comments in Assembly code.

Diego Biurrun committed 14 years ago

Commit 148bc231 parent 3f57bde3 files · +78 −73Browse files

Unified · Split

3 files
  1. libswscale/bfin/internal_bfin.S +6 −6
  2. libswscale/bfin/swscale_bfin.c +26 −22
  3. libswscale/bfin/yuv2rgb_bfin.c +46 −45
libswscale/bfin/internal_bfin.S+6−6
@@ -30,11 +30,11 @@ and converts it to RGB565. R:5 bits, G:6 bits, B:5 bits.. packed into shorts. · 29 unmodified lines
3030
3131 The following calculation is used for the conversion:
3232
33− r = clipz((y-oy)*cy + crv*(v-128))
34− g = clipz((y-oy)*cy + cgv*(v-128) + cgu*(u-128))
35− b = clipz((y-oy)*cy + cbu*(u-128))
33+ r = clipz((y - oy) * cy + crv * (v - 128))
34+ g = clipz((y - oy) * cy + cgv * (v - 128) + cgu * (u - 128))
35+ b = clipz((y - oy) * cy + cbu * (u - 128))
3636
37−y,u,v are prescaled by a factor of 4 i.e. left-shifted to gain precision.
37+y, u, v are prescaled by a factor of 4 i.e. left-shifted to gain precision.
3838
3939
4040 New factorization to eliminate the truncation error which was
@@ -47,7 +47,7 @@ occurring due to the byteop3p. · 6 unmodified lines
4747 2) Scale operands up by a factor of 4 not 8 because Blackfin
4848 multiplies include a shift.
4949
50−3) Compute into the accumulators cy*yx0, cy*yx1.
50+3) Compute into the accumulators cy * yx0, cy * yx1.
5151
5252 4) Compute each of the linear equations:
5353 r = clipz((y - oy) * cy + crv * (v - 128))
@@ -73,7 +73,7 @@ occurring due to the byteop3p. · 19 unmodified lines
7373
7474 Where coeffs have the following layout in memory.
7575
76−uint32_t oy,oc,zero,cy,crv,rmask,cbu,bmask,cgu,cgv;
76+uint32_t oy, oc, zero, cy, crv, rmask, cbu, bmask, cgu, cgv;
7777
7878 coeffs is a pointer to oy.
7979
libswscale/bfin/swscale_bfin.c+26−22
@@ -27,32 +27,34 @@ · 26 unmodified lines
2727 #include <assert.h>
2828 #include "config.h"
2929 #include <unistd.h>
30+
3031 #include "libswscale/rgb2rgb.h"
3132 #include "libswscale/swscale.h"
3233 #include "libswscale/swscale_internal.h"
3334
3435 #if defined (__FDPIC__) && CONFIG_SRAM
35−#define L1CODE __attribute__ ((l1_text))
36+#define L1CODE __attribute__((l1_text))
3637 #else
3738 #define L1CODE
3839 #endif
3940
40−int ff_bfin_uyvytoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
41− int width, int height,
41+int ff_bfin_uyvytoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
42+ uint8_t *vdst, int width, int height,
4243 int lumStride, int chromStride, int srcStride) L1CODE;
4344
44−int ff_bfin_yuyvtoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
45− int width, int height,
45+int ff_bfin_yuyvtoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
46+ uint8_t *vdst, int width, int height,
4647 int lumStride, int chromStride, int srcStride) L1CODE;
4748
48−static int uyvytoyv12_unscaled(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
49− int srcSliceH, uint8_t* dst[], int dstStride[])
49+static int uyvytoyv12_unscaled(SwsContext *c, uint8_t *src[], int srcStride[],
50+ int srcSliceY, int srcSliceH, uint8_t *dst[],
51+ int dstStride[])
5052 {
51− uint8_t *dsty = dst[0] + dstStride[0]*srcSliceY;
52− uint8_t *dstu = dst[1] + dstStride[1]*srcSliceY/2;
53− uint8_t *dstv = dst[2] + dstStride[2]*srcSliceY/2;
54− uint8_t *ip = src[0] + srcStride[0]*srcSliceY;
55− int w = dstStride[0];
53+ uint8_t *dsty = dst[0] + dstStride[0] * srcSliceY;
54+ uint8_t *dstu = dst[1] + dstStride[1] * srcSliceY / 2;
55+ uint8_t *dstv = dst[2] + dstStride[2] * srcSliceY / 2;
56+ uint8_t *ip = src[0] + srcStride[0] * srcSliceY;
57+ int w = dstStride[0];
5658
5759 ff_bfin_uyvytoyv12(ip, dsty, dstu, dstv, w, srcSliceH,
5860 dstStride[0], dstStride[1], srcStride[0]);
@@ -60,14 +62,15 @@ static int uyvytoyv12_unscaled(SwsContext *c, uint8_t* src[], int srcStride[], i · 1 unmodified line
6062 return srcSliceH;
6163 }
6264
63−static int yuyvtoyv12_unscaled(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
64− int srcSliceH, uint8_t* dst[], int dstStride[])
65+static int yuyvtoyv12_unscaled(SwsContext *c, uint8_t *src[], int srcStride[],
66+ int srcSliceY, int srcSliceH, uint8_t *dst[],
67+ int dstStride[])
6568 {
66− uint8_t *dsty = dst[0] + dstStride[0]*srcSliceY;
67− uint8_t *dstu = dst[1] + dstStride[1]*srcSliceY/2;
68− uint8_t *dstv = dst[2] + dstStride[2]*srcSliceY/2;
69− uint8_t *ip = src[0] + srcStride[0]*srcSliceY;
70− int w = dstStride[0];
69+ uint8_t *dsty = dst[0] + dstStride[0] * srcSliceY;
70+ uint8_t *dstu = dst[1] + dstStride[1] * srcSliceY / 2;
71+ uint8_t *dstv = dst[2] + dstStride[2] * srcSliceY / 2;
72+ uint8_t *ip = src[0] + srcStride[0] * srcSliceY;
73+ int w = dstStride[0];
7174
7275 ff_bfin_yuyvtoyv12(ip, dsty, dstu, dstv, w, srcSliceH,
7376 dstStride[0], dstStride[1], srcStride[0]);
@@ -75,15 +78,16 @@ static int yuyvtoyv12_unscaled(SwsContext *c, uint8_t* src[], int srcStride[], i · 1 unmodified line
7578 return srcSliceH;
7679 }
7780
78−
7981 void ff_bfin_get_unscaled_swscale(SwsContext *c)
8082 {
8183 if (c->dstFormat == PIX_FMT_YUV420P && c->srcFormat == PIX_FMT_UYVY422) {
82− av_log (NULL, AV_LOG_VERBOSE, "selecting Blackfin optimized uyvytoyv12_unscaled\n");
84+ av_log(NULL, AV_LOG_VERBOSE,
85+ "selecting Blackfin optimized uyvytoyv12_unscaled\n");
8386 c->swScale = uyvytoyv12_unscaled;
8487 }
8588 if (c->dstFormat == PIX_FMT_YUV420P && c->srcFormat == PIX_FMT_YUYV422) {
86− av_log (NULL, AV_LOG_VERBOSE, "selecting Blackfin optimized yuyvtoyv12_unscaled\n");
89+ av_log(NULL, AV_LOG_VERBOSE,
90+ "selecting Blackfin optimized yuyvtoyv12_unscaled\n");
8791 c->swScale = yuyvtoyv12_unscaled;
8892 }
8993 }
libswscale/bfin/yuv2rgb_bfin.c+46−45
@@ -26,14 +26,15 @@ · 25 unmodified lines
2626 #include <string.h>
2727 #include <inttypes.h>
2828 #include <assert.h>
29−#include "config.h"
3029 #include <unistd.h>
30+
31+#include "config.h"
3132 #include "libswscale/rgb2rgb.h"
3233 #include "libswscale/swscale.h"
3334 #include "libswscale/swscale_internal.h"
3435
3536 #if defined(__FDPIC__) && CONFIG_SRAM
36−#define L1CODE __attribute__ ((l1_text))
37+#define L1CODE __attribute__((l1_text))
3738 #else
3839 #define L1CODE
3940 #endif
@@ -47,21 +48,20 @@ void ff_bfin_yuv2rgb565_line(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out, · 7 unmodified lines
4748 void ff_bfin_yuv2rgb24_line(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
4849 int w, uint32_t *coeffs) L1CODE;
4950
50−typedef void (* ltransform)(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
51− int w, uint32_t *coeffs);
52−
51+typedef void (*ltransform)(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
52+ int w, uint32_t *coeffs);
5353
5454 static void bfin_prepare_coefficients(SwsContext *c, int rgb, int masks)
5555 {
5656 int oy;
57− oy = c->yOffset&0xffff;
58− oy = oy >> 3; // keep everything U8.0 for offset calculation
57+ oy = c->yOffset & 0xffff;
58+ oy = oy >> 3; // keep everything U8.0 for offset calculation
5959
60− c->oc = 128*0x01010101U;
61− c->oy = oy*0x01010101U;
60+ c->oc = 128 * 0x01010101U;
61+ c->oy = oy * 0x01010101U;
6262
6363 /* copy 64bit vector coeffs down to 32bit vector coeffs */
64− c->cy = c->yCoeff;
64+ c->cy = c->yCoeff;
6565 c->zero = 0;
6666
6767 if (rgb) {
@@ -76,7 +76,6 @@ static void bfin_prepare_coefficients(SwsContext *c, int rgb, int masks) · 8 unmodified lines
7676 c->cgv = c->ugCoeff;
7777 }
7878
79−
8079 if (masks == 555) {
8180 c->rmask = 0x001f * 0x00010001U;
8281 c->gmask = 0x03e0 * 0x00010001U;
@@ -88,27 +87,25 @@ static void bfin_prepare_coefficients(SwsContext *c, int rgb, int masks) · 5 unmodified lines
8887 }
8988 }
9089
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)
90+static int core_yuv420_rgb(SwsContext *c, uint8_t **in, int *instrides,
91+ int srcSliceY, int srcSliceH, uint8_t **oplanes,
92+ int *outstrides, ltransform lcscf,
93+ int rgb, int masks)
9694 {
97− uint8_t *py,*pu,*pv,*op;
95+ uint8_t *py, *pu, *pv, *op;
9896 int w = instrides[0];
99− int h2 = srcSliceH>>1;
97+ int h2 = srcSliceH >> 1;
10098 int i;
10199
102100 bfin_prepare_coefficients(c, rgb, masks);
103101
104102 py = in[0];
105− pu = in[1+(1^rgb)];
106− pv = in[1+(0^rgb)];
107−
108− op = oplanes[0] + srcSliceY*outstrides[0];
103+ pu = in[1 + (1 ^ rgb)];
104+ pv = in[1 + (0 ^ rgb)];
109105
110− for (i=0;i<h2;i++) {
106+ op = oplanes[0] + srcSliceY * outstrides[0];
111107
108+ for (i = 0; i < h2; i++) {
112109 lcscf(py, pu, pv, op, w, &c->oy);
113110
114111 py += instrides[0];
@@ -125,9 +122,7 @@ static int core_yuv420_rgb(SwsContext *c, · 10 unmodified lines
125122 return srcSliceH;
126123 }
127124
128−
129−static int bfin_yuv420_rgb555(SwsContext *c,
130− uint8_t **in, int *instrides,
125+static int bfin_yuv420_rgb555(SwsContext *c, uint8_t **in, int *instrides,
131126 int srcSliceY, int srcSliceH,
132127 uint8_t **oplanes, int *outstrides)
133128 {
@@ -135,8 +130,7 @@ static int bfin_yuv420_rgb555(SwsContext *c, · 1 unmodified line
135130 outstrides, ff_bfin_yuv2rgb555_line, 1, 555);
136131 }
137132
138−static int bfin_yuv420_bgr555(SwsContext *c,
139− uint8_t **in, int *instrides,
133+static int bfin_yuv420_bgr555(SwsContext *c, uint8_t **in, int *instrides,
140134 int srcSliceY, int srcSliceH,
141135 uint8_t **oplanes, int *outstrides)
142136 {
@@ -144,8 +138,7 @@ static int bfin_yuv420_bgr555(SwsContext *c, · 1 unmodified line
144138 outstrides, ff_bfin_yuv2rgb555_line, 0, 555);
145139 }
146140
147−static int bfin_yuv420_rgb24(SwsContext *c,
148− uint8_t **in, int *instrides,
141+static int bfin_yuv420_rgb24(SwsContext *c, uint8_t **in, int *instrides,
149142 int srcSliceY, int srcSliceH,
150143 uint8_t **oplanes, int *outstrides)
151144 {
@@ -153,8 +146,7 @@ static int bfin_yuv420_rgb24(SwsContext *c, · 1 unmodified line
153146 outstrides, ff_bfin_yuv2rgb24_line, 1, 888);
154147 }
155148
156−static int bfin_yuv420_bgr24(SwsContext *c,
157− uint8_t **in, int *instrides,
149+static int bfin_yuv420_bgr24(SwsContext *c, uint8_t **in, int *instrides,
158150 int srcSliceY, int srcSliceH,
159151 uint8_t **oplanes, int *outstrides)
160152 {
@@ -162,8 +154,7 @@ static int bfin_yuv420_bgr24(SwsContext *c, · 1 unmodified line
162154 outstrides, ff_bfin_yuv2rgb24_line, 0, 888);
163155 }
164156
165−static int bfin_yuv420_rgb565(SwsContext *c,
166− uint8_t **in, int *instrides,
157+static int bfin_yuv420_rgb565(SwsContext *c, uint8_t **in, int *instrides,
167158 int srcSliceY, int srcSliceH,
168159 uint8_t **oplanes, int *outstrides)
169160 {
@@ -171,8 +162,7 @@ static int bfin_yuv420_rgb565(SwsContext *c, · 1 unmodified line
171162 outstrides, ff_bfin_yuv2rgb565_line, 1, 565);
172163 }
173164
174−static int bfin_yuv420_bgr565(SwsContext *c,
175− uint8_t **in, int *instrides,
165+static int bfin_yuv420_bgr565(SwsContext *c, uint8_t **in, int *instrides,
176166 int srcSliceY, int srcSliceH,
177167 uint8_t **oplanes, int *outstrides)
178168 {
@@ -180,24 +170,35 @@ static int bfin_yuv420_bgr565(SwsContext *c, · 1 unmodified line
180170 outstrides, ff_bfin_yuv2rgb565_line, 0, 565);
181171 }
182172
183−
184173 SwsFunc ff_yuv2rgb_get_func_ptr_bfin(SwsContext *c)
185174 {
186175 SwsFunc f;
187176
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;
177+ switch (c->dstFormat) {
178+ case PIX_FMT_RGB555:
179+ f = bfin_yuv420_rgb555;
180+ break;
181+ case PIX_FMT_BGR555:
182+ f = bfin_yuv420_bgr555;
183+ break;
184+ case PIX_FMT_RGB565:
185+ f = bfin_yuv420_rgb565;
186+ break;
187+ case PIX_FMT_BGR565:
188+ f = bfin_yuv420_bgr565;
189+ break;
190+ case PIX_FMT_RGB24:
191+ f = bfin_yuv420_rgb24;
192+ break;
193+ case PIX_FMT_BGR24:
194+ f = bfin_yuv420_bgr24;
195+ break;
195196 default:
196197 return 0;
197198 }
198199
199200 av_log(c, AV_LOG_INFO, "BlackFin accelerated color space converter %s\n",
200− sws_format_name (c->dstFormat));
201+ sws_format_name(c->dstFormat));
201202
202203 return f;
203204 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t