Mercurial > libavcodec.hg
annotate rectangle.h @ 6404:a0a1db4738dd libavcodec
simplify
author | lorenm |
---|---|
date | Tue, 26 Feb 2008 07:35:56 +0000 |
parents | c531defb03ee |
children | b495c754c3e1 |
rev | line source |
---|---|
1168 | 1 /* |
6020 | 2 * rectangle filling function |
1168 | 3 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> |
4 * | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3927
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3927
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3927
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
1168 | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3927
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
1168 | 11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3927
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
1168 | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3927
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
3029
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
1168 | 20 */ |
2967 | 21 |
1168 | 22 /** |
6020 | 23 * @file rectangle.h |
24 * useful rectangle filling function | |
1168 | 25 * @author Michael Niedermayer <michaelni@gmx.at> |
26 */ | |
27 | |
6020 | 28 #ifndef FFMPEG_RECTANGLE_H |
29 #define FFMPEG_RECTANGLE_H | |
1168 | 30 |
6020 | 31 #include "common.h" |
4277
113f3b395bac
Making rem6 and div6 globally visible and thus adding prefixes.
takis
parents:
4276
diff
changeset
|
32 |
1168 | 33 /** |
34 * fill a rectangle. | |
2392 | 35 * @param h height of the rectangle, should be a constant |
36 * @param w width of the rectangle, should be a constant | |
1168 | 37 * @param size the size of val (1 or 4), should be a constant |
38 */ | |
4283
d6f83e2f8804
rename always_inline to av_always_inline and move to common.h
mru
parents:
4277
diff
changeset
|
39 static av_always_inline void fill_rectangle(void *vp, int w, int h, int stride, uint32_t val, int size){ |
1187 | 40 uint8_t *p= (uint8_t*)vp; |
1168 | 41 assert(size==1 || size==4); |
3315 | 42 assert(w<=4); |
2967 | 43 |
1168 | 44 w *= size; |
45 stride *= size; | |
2967 | 46 |
2962 | 47 assert((((long)vp)&(FFMIN(w, STRIDE_ALIGN)-1)) == 0); |
2669 | 48 assert((stride&(w-1))==0); |
3315 | 49 if(w==2){ |
50 const uint16_t v= size==4 ? val : val*0x0101; | |
51 *(uint16_t*)(p + 0*stride)= v; | |
52 if(h==1) return; | |
53 *(uint16_t*)(p + 1*stride)= v; | |
54 if(h==2) return; | |
5545
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
55 *(uint16_t*)(p + 2*stride)= v; |
3315 | 56 *(uint16_t*)(p + 3*stride)= v; |
57 }else if(w==4){ | |
58 const uint32_t v= size==4 ? val : val*0x01010101; | |
59 *(uint32_t*)(p + 0*stride)= v; | |
60 if(h==1) return; | |
61 *(uint32_t*)(p + 1*stride)= v; | |
62 if(h==2) return; | |
5545
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
63 *(uint32_t*)(p + 2*stride)= v; |
3315 | 64 *(uint32_t*)(p + 3*stride)= v; |
65 }else if(w==8){ | |
66 //gcc can't optimize 64bit math on x86_32 | |
67 #if defined(ARCH_X86_64) || (defined(MP_WORDSIZE) && MP_WORDSIZE >= 64) | |
68 const uint64_t v= val*0x0100000001ULL; | |
69 *(uint64_t*)(p + 0*stride)= v; | |
70 if(h==1) return; | |
71 *(uint64_t*)(p + 1*stride)= v; | |
72 if(h==2) return; | |
5545
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
73 *(uint64_t*)(p + 2*stride)= v; |
3315 | 74 *(uint64_t*)(p + 3*stride)= v; |
75 }else if(w==16){ | |
76 const uint64_t v= val*0x0100000001ULL; | |
5545
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
77 *(uint64_t*)(p + 0+0*stride)= v; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
78 *(uint64_t*)(p + 8+0*stride)= v; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
79 *(uint64_t*)(p + 0+1*stride)= v; |
3315 | 80 *(uint64_t*)(p + 8+1*stride)= v; |
81 if(h==2) return; | |
5545
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
82 *(uint64_t*)(p + 0+2*stride)= v; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
83 *(uint64_t*)(p + 8+2*stride)= v; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
84 *(uint64_t*)(p + 0+3*stride)= v; |
3315 | 85 *(uint64_t*)(p + 8+3*stride)= v; |
86 #else | |
5545
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
87 *(uint32_t*)(p + 0+0*stride)= val; |
3315 | 88 *(uint32_t*)(p + 4+0*stride)= val; |
89 if(h==1) return; | |
5545
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
90 *(uint32_t*)(p + 0+1*stride)= val; |
3315 | 91 *(uint32_t*)(p + 4+1*stride)= val; |
92 if(h==2) return; | |
5545
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
93 *(uint32_t*)(p + 0+2*stride)= val; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
94 *(uint32_t*)(p + 4+2*stride)= val; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
95 *(uint32_t*)(p + 0+3*stride)= val; |
3315 | 96 *(uint32_t*)(p + 4+3*stride)= val; |
97 }else if(w==16){ | |
5545
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
98 *(uint32_t*)(p + 0+0*stride)= val; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
99 *(uint32_t*)(p + 4+0*stride)= val; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
100 *(uint32_t*)(p + 8+0*stride)= val; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
101 *(uint32_t*)(p +12+0*stride)= val; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
102 *(uint32_t*)(p + 0+1*stride)= val; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
103 *(uint32_t*)(p + 4+1*stride)= val; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
104 *(uint32_t*)(p + 8+1*stride)= val; |
3315 | 105 *(uint32_t*)(p +12+1*stride)= val; |
106 if(h==2) return; | |
5545
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
107 *(uint32_t*)(p + 0+2*stride)= val; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
108 *(uint32_t*)(p + 4+2*stride)= val; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
109 *(uint32_t*)(p + 8+2*stride)= val; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
110 *(uint32_t*)(p +12+2*stride)= val; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
111 *(uint32_t*)(p + 0+3*stride)= val; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
112 *(uint32_t*)(p + 4+3*stride)= val; |
397cb90b66d0
Statements like a = b = c = d = e; store from right-to-left, so if
gpoirier
parents:
5528
diff
changeset
|
113 *(uint32_t*)(p + 8+3*stride)= val; |
3315 | 114 *(uint32_t*)(p +12+3*stride)= val; |
115 #endif | |
1168 | 116 }else |
117 assert(0); | |
3315 | 118 assert(h==4); |
1168 | 119 } |
120 | |
6020 | 121 #endif /* FFMPEG_RECTANGLE_H */ |