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
30 30
31The following calculation is used for the conversion:31The following calculation is used for the conversion:
32 32
33 r = clipz((y-oy)*cy + crv*(v-128))33 r = clipz((y - oy) * cy + crv * (v - 128))
34 g = clipz((y-oy)*cy + cgv*(v-128) + cgu*(u-128))34 g = clipz((y - oy) * cy + cgv * (v - 128) + cgu * (u - 128))
35 b = clipz((y-oy)*cy + cbu*(u-128))35 b = clipz((y - oy) * cy + cbu * (u - 128))
36 36
37y,u,v are prescaled by a factor of 4 i.e. left-shifted to gain precision.37y, u, v are prescaled by a factor of 4 i.e. left-shifted to gain precision.
38 38
39 39
40New factorization to eliminate the truncation error which was40New factorization to eliminate the truncation error which was
@@ -47,7 +47,7 @@ occurring due to the byteop3p. · 6 unmodified lines
472) Scale operands up by a factor of 4 not 8 because Blackfin472) Scale operands up by a factor of 4 not 8 because Blackfin
48 multiplies include a shift.48 multiplies include a shift.
49 49
503) Compute into the accumulators cy*yx0, cy*yx1.503) Compute into the accumulators cy * yx0, cy * yx1.
51 51
524) Compute each of the linear equations:524) Compute each of the linear equations:
53 r = clipz((y - oy) * cy + crv * (v - 128))53 r = clipz((y - oy) * cy + crv * (v - 128))
@@ -73,7 +73,7 @@ occurring due to the byteop3p. · 19 unmodified lines
73 73
74Where coeffs have the following layout in memory.74Where coeffs have the following layout in memory.
75 75
76uint32_t oy,oc,zero,cy,crv,rmask,cbu,bmask,cgu,cgv;76uint32_t oy, oc, zero, cy, crv, rmask, cbu, bmask, cgu, cgv;
77 77
78coeffs is a pointer to oy.78coeffs is a pointer to oy.
79 79
libswscale/bfin/swscale_bfin.c+26−22
@@ -27,32 +27,34 @@ · 26 unmodified lines
27#include <assert.h>27#include <assert.h>
28#include "config.h"28#include "config.h"
29#include <unistd.h>29#include <unistd.h>
30
30#include "libswscale/rgb2rgb.h"31#include "libswscale/rgb2rgb.h"
31#include "libswscale/swscale.h"32#include "libswscale/swscale.h"
32#include "libswscale/swscale_internal.h"33#include "libswscale/swscale_internal.h"
33 34
34#if defined (__FDPIC__) && CONFIG_SRAM35#if defined (__FDPIC__) && CONFIG_SRAM
35#define L1CODE __attribute__ ((l1_text))36#define L1CODE __attribute__((l1_text))
36#else37#else
37#define L1CODE38#define L1CODE
38#endif39#endif
39 40
40int ff_bfin_uyvytoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,41int ff_bfin_uyvytoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
41 int width, int height,42 uint8_t *vdst, int width, int height,
42 int lumStride, int chromStride, int srcStride) L1CODE;43 int lumStride, int chromStride, int srcStride) L1CODE;
43 44
44int ff_bfin_yuyvtoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,45int ff_bfin_yuyvtoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
45 int width, int height,46 uint8_t *vdst, int width, int height,
46 int lumStride, int chromStride, int srcStride) L1CODE;47 int lumStride, int chromStride, int srcStride) L1CODE;
47 48
48static int uyvytoyv12_unscaled(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,49static int uyvytoyv12_unscaled(SwsContext *c, uint8_t *src[], int srcStride[],
49 int srcSliceH, uint8_t* dst[], int dstStride[])50 int srcSliceY, int srcSliceH, uint8_t *dst[],
51 int dstStride[])
50{52{
51 uint8_t *dsty = dst[0] + dstStride[0]*srcSliceY;53 uint8_t *dsty = dst[0] + dstStride[0] * srcSliceY;
52 uint8_t *dstu = dst[1] + dstStride[1]*srcSliceY/2;54 uint8_t *dstu = dst[1] + dstStride[1] * srcSliceY / 2;
53 uint8_t *dstv = dst[2] + dstStride[2]*srcSliceY/2;55 uint8_t *dstv = dst[2] + dstStride[2] * srcSliceY / 2;
54 uint8_t *ip = src[0] + srcStride[0]*srcSliceY;56 uint8_t *ip = src[0] + srcStride[0] * srcSliceY;
55 int w = dstStride[0];57 int w = dstStride[0];
56 58
57 ff_bfin_uyvytoyv12(ip, dsty, dstu, dstv, w, srcSliceH,59 ff_bfin_uyvytoyv12(ip, dsty, dstu, dstv, w, srcSliceH,
58 dstStride[0], dstStride[1], srcStride[0]);60 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
60 return srcSliceH;62 return srcSliceH;
61}63}
62 64
63static int yuyvtoyv12_unscaled(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,65static int yuyvtoyv12_unscaled(SwsContext *c, uint8_t *src[], int srcStride[],
64 int srcSliceH, uint8_t* dst[], int dstStride[])66 int srcSliceY, int srcSliceH, uint8_t *dst[],
67 int dstStride[])
65{68{
66 uint8_t *dsty = dst[0] + dstStride[0]*srcSliceY;69 uint8_t *dsty = dst[0] + dstStride[0] * srcSliceY;
67 uint8_t *dstu = dst[1] + dstStride[1]*srcSliceY/2;70 uint8_t *dstu = dst[1] + dstStride[1] * srcSliceY / 2;
68 uint8_t *dstv = dst[2] + dstStride[2]*srcSliceY/2;71 uint8_t *dstv = dst[2] + dstStride[2] * srcSliceY / 2;
69 uint8_t *ip = src[0] + srcStride[0]*srcSliceY;72 uint8_t *ip = src[0] + srcStride[0] * srcSliceY;
70 int w = dstStride[0];73 int w = dstStride[0];
71 74
72 ff_bfin_yuyvtoyv12(ip, dsty, dstu, dstv, w, srcSliceH,75 ff_bfin_yuyvtoyv12(ip, dsty, dstu, dstv, w, srcSliceH,
73 dstStride[0], dstStride[1], srcStride[0]);76 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
75 return srcSliceH;78 return srcSliceH;
76}79}
77 80
78
79void ff_bfin_get_unscaled_swscale(SwsContext *c)81void ff_bfin_get_unscaled_swscale(SwsContext *c)
80{82{
81 if (c->dstFormat == PIX_FMT_YUV420P && c->srcFormat == PIX_FMT_UYVY422) {83 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");
83 c->swScale = uyvytoyv12_unscaled;86 c->swScale = uyvytoyv12_unscaled;
84 }87 }
85 if (c->dstFormat == PIX_FMT_YUV420P && c->srcFormat == PIX_FMT_YUYV422) {88 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");
87 c->swScale = yuyvtoyv12_unscaled;91 c->swScale = yuyvtoyv12_unscaled;
88 }92 }
89}93}
libswscale/bfin/yuv2rgb_bfin.c+46−45
@@ -26,14 +26,15 @@ · 25 unmodified lines
26#include <string.h>26#include <string.h>
27#include <inttypes.h>27#include <inttypes.h>
28#include <assert.h>28#include <assert.h>
29#include "config.h"
30#include <unistd.h>29#include <unistd.h>
30
31#include "config.h"
31#include "libswscale/rgb2rgb.h"32#include "libswscale/rgb2rgb.h"
32#include "libswscale/swscale.h"33#include "libswscale/swscale.h"
33#include "libswscale/swscale_internal.h"34#include "libswscale/swscale_internal.h"
34 35
35#if defined(__FDPIC__) && CONFIG_SRAM36#if defined(__FDPIC__) && CONFIG_SRAM
36#define L1CODE __attribute__ ((l1_text))37#define L1CODE __attribute__((l1_text))
37#else38#else
38#define L1CODE39#define L1CODE
39#endif40#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
47void ff_bfin_yuv2rgb24_line(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,48void ff_bfin_yuv2rgb24_line(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
48 int w, uint32_t *coeffs) L1CODE;49 int w, uint32_t *coeffs) L1CODE;
49 50
50typedef void (* ltransform)(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,51typedef void (*ltransform)(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
51 int w, uint32_t *coeffs);52 int w, uint32_t *coeffs);
52
53 53
54static void bfin_prepare_coefficients(SwsContext *c, int rgb, int masks)54static void bfin_prepare_coefficients(SwsContext *c, int rgb, int masks)
55{55{
56 int oy;56 int oy;
57 oy = c->yOffset&0xffff;57 oy = c->yOffset & 0xffff;
58 oy = oy >> 3; // keep everything U8.0 for offset calculation58 oy = oy >> 3; // keep everything U8.0 for offset calculation
59 59
60 c->oc = 128*0x01010101U;60 c->oc = 128 * 0x01010101U;
61 c->oy = oy*0x01010101U;61 c->oy = oy * 0x01010101U;
62 62
63 /* copy 64bit vector coeffs down to 32bit vector coeffs */63 /* copy 64bit vector coeffs down to 32bit vector coeffs */
64 c->cy = c->yCoeff;64 c->cy = c->yCoeff;
65 c->zero = 0;65 c->zero = 0;
66 66
67 if (rgb) {67 if (rgb) {
@@ -76,7 +76,6 @@ static void bfin_prepare_coefficients(SwsContext *c, int rgb, int masks) · 8 unmodified lines
76 c->cgv = c->ugCoeff;76 c->cgv = c->ugCoeff;
77 }77 }
78 78
79
80 if (masks == 555) {79 if (masks == 555) {
81 c->rmask = 0x001f * 0x00010001U;80 c->rmask = 0x001f * 0x00010001U;
82 c->gmask = 0x03e0 * 0x00010001U;81 c->gmask = 0x03e0 * 0x00010001U;
@@ -88,27 +87,25 @@ static void bfin_prepare_coefficients(SwsContext *c, int rgb, int masks) · 5 unmodified lines
88 }87 }
89}88}
90 89
91static int core_yuv420_rgb(SwsContext *c,90static int core_yuv420_rgb(SwsContext *c, uint8_t **in, int *instrides,
92 uint8_t **in, int *instrides,91 int srcSliceY, int srcSliceH, uint8_t **oplanes,
93 int srcSliceY, int srcSliceH,92 int *outstrides, ltransform lcscf,
94 uint8_t **oplanes, int *outstrides,93 int rgb, int masks)
95 ltransform lcscf, int rgb, int masks)
96{94{
97 uint8_t *py,*pu,*pv,*op;95 uint8_t *py, *pu, *pv, *op;
98 int w = instrides[0];96 int w = instrides[0];
99 int h2 = srcSliceH>>1;97 int h2 = srcSliceH >> 1;
100 int i;98 int i;
101 99
102 bfin_prepare_coefficients(c, rgb, masks);100 bfin_prepare_coefficients(c, rgb, masks);
103 101
104 py = in[0];102 py = in[0];
105 pu = in[1+(1^rgb)];103 pu = in[1 + (1 ^ rgb)];
106 pv = in[1+(0^rgb)];104 pv = in[1 + (0 ^ rgb)];
107
108 op = oplanes[0] + srcSliceY*outstrides[0];
109 105
110 for (i=0;i<h2;i++) {106 op = oplanes[0] + srcSliceY * outstrides[0];
111 107
108 for (i = 0; i < h2; i++) {
112 lcscf(py, pu, pv, op, w, &c->oy);109 lcscf(py, pu, pv, op, w, &c->oy);
113 110
114 py += instrides[0];111 py += instrides[0];
@@ -125,9 +122,7 @@ static int core_yuv420_rgb(SwsContext *c, · 10 unmodified lines
125 return srcSliceH;122 return srcSliceH;
126}123}
127 124
128 125static int bfin_yuv420_rgb555(SwsContext *c, uint8_t **in, int *instrides,
129static int bfin_yuv420_rgb555(SwsContext *c,
130 uint8_t **in, int *instrides,
131 int srcSliceY, int srcSliceH,126 int srcSliceY, int srcSliceH,
132 uint8_t **oplanes, int *outstrides)127 uint8_t **oplanes, int *outstrides)
133{128{
@@ -135,8 +130,7 @@ static int bfin_yuv420_rgb555(SwsContext *c, · 1 unmodified line
135 outstrides, ff_bfin_yuv2rgb555_line, 1, 555);130 outstrides, ff_bfin_yuv2rgb555_line, 1, 555);
136}131}
137 132
138static int bfin_yuv420_bgr555(SwsContext *c,133static int bfin_yuv420_bgr555(SwsContext *c, uint8_t **in, int *instrides,
139 uint8_t **in, int *instrides,
140 int srcSliceY, int srcSliceH,134 int srcSliceY, int srcSliceH,
141 uint8_t **oplanes, int *outstrides)135 uint8_t **oplanes, int *outstrides)
142{136{
@@ -144,8 +138,7 @@ static int bfin_yuv420_bgr555(SwsContext *c, · 1 unmodified line
144 outstrides, ff_bfin_yuv2rgb555_line, 0, 555);138 outstrides, ff_bfin_yuv2rgb555_line, 0, 555);
145}139}
146 140
147static int bfin_yuv420_rgb24(SwsContext *c,141static int bfin_yuv420_rgb24(SwsContext *c, uint8_t **in, int *instrides,
148 uint8_t **in, int *instrides,
149 int srcSliceY, int srcSliceH,142 int srcSliceY, int srcSliceH,
150 uint8_t **oplanes, int *outstrides)143 uint8_t **oplanes, int *outstrides)
151{144{
@@ -153,8 +146,7 @@ static int bfin_yuv420_rgb24(SwsContext *c, · 1 unmodified line
153 outstrides, ff_bfin_yuv2rgb24_line, 1, 888);146 outstrides, ff_bfin_yuv2rgb24_line, 1, 888);
154}147}
155 148
156static int bfin_yuv420_bgr24(SwsContext *c,149static int bfin_yuv420_bgr24(SwsContext *c, uint8_t **in, int *instrides,
157 uint8_t **in, int *instrides,
158 int srcSliceY, int srcSliceH,150 int srcSliceY, int srcSliceH,
159 uint8_t **oplanes, int *outstrides)151 uint8_t **oplanes, int *outstrides)
160{152{
@@ -162,8 +154,7 @@ static int bfin_yuv420_bgr24(SwsContext *c, · 1 unmodified line
162 outstrides, ff_bfin_yuv2rgb24_line, 0, 888);154 outstrides, ff_bfin_yuv2rgb24_line, 0, 888);
163}155}
164 156
165static int bfin_yuv420_rgb565(SwsContext *c,157static int bfin_yuv420_rgb565(SwsContext *c, uint8_t **in, int *instrides,
166 uint8_t **in, int *instrides,
167 int srcSliceY, int srcSliceH,158 int srcSliceY, int srcSliceH,
168 uint8_t **oplanes, int *outstrides)159 uint8_t **oplanes, int *outstrides)
169{160{
@@ -171,8 +162,7 @@ static int bfin_yuv420_rgb565(SwsContext *c, · 1 unmodified line
171 outstrides, ff_bfin_yuv2rgb565_line, 1, 565);162 outstrides, ff_bfin_yuv2rgb565_line, 1, 565);
172}163}
173 164
174static int bfin_yuv420_bgr565(SwsContext *c,165static int bfin_yuv420_bgr565(SwsContext *c, uint8_t **in, int *instrides,
175 uint8_t **in, int *instrides,
176 int srcSliceY, int srcSliceH,166 int srcSliceY, int srcSliceH,
177 uint8_t **oplanes, int *outstrides)167 uint8_t **oplanes, int *outstrides)
178{168{
@@ -180,24 +170,35 @@ static int bfin_yuv420_bgr565(SwsContext *c, · 1 unmodified line
180 outstrides, ff_bfin_yuv2rgb565_line, 0, 565);170 outstrides, ff_bfin_yuv2rgb565_line, 0, 565);
181}171}
182 172
183
184SwsFunc ff_yuv2rgb_get_func_ptr_bfin(SwsContext *c)173SwsFunc ff_yuv2rgb_get_func_ptr_bfin(SwsContext *c)
185{174{
186 SwsFunc f;175 SwsFunc f;
187 176
188 switch(c->dstFormat) {177 switch (c->dstFormat) {
189 case PIX_FMT_RGB555: f = bfin_yuv420_rgb555; break;178 case PIX_FMT_RGB555:
190 case PIX_FMT_BGR555: f = bfin_yuv420_bgr555; break;179 f = bfin_yuv420_rgb555;
191 case PIX_FMT_RGB565: f = bfin_yuv420_rgb565; break;180 break;
192 case PIX_FMT_BGR565: f = bfin_yuv420_bgr565; break;181 case PIX_FMT_BGR555:
193 case PIX_FMT_RGB24: f = bfin_yuv420_rgb24; break;182 f = bfin_yuv420_bgr555;
194 case PIX_FMT_BGR24: f = bfin_yuv420_bgr24; break;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;
195 default:196 default:
196 return 0;197 return 0;
197 }198 }
198 199
199 av_log(c, AV_LOG_INFO, "BlackFin accelerated color space converter %s\n",200 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));
201 202
202 return f;203 return f;
203}204}

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