Mercurial > libavcodec.hg
annotate rectangle.h @ 12372:914f484bb476 libavcodec
Remove use of the deprecated function avcodec_check_dimensions(), use
av_check_image_size() instead.
author | stefano |
---|---|
date | Fri, 06 Aug 2010 09:37:04 +0000 |
parents | 7dd2a45249a9 |
children |
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 /** |
11644
7dd2a45249a9
Remove explicit filename from Doxygen @file commands.
diego
parents:
11280
diff
changeset
|
23 * @file |
6020 | 24 * useful rectangle filling function |
1168 | 25 * @author Michael Niedermayer <michaelni@gmx.at> |
26 */ | |
27 | |
7760 | 28 #ifndef AVCODEC_RECTANGLE_H |
29 #define AVCODEC_RECTANGLE_H | |
1168 | 30 |
8648 | 31 #include <assert.h> |
32 #include "config.h" | |
6763 | 33 #include "libavutil/common.h" |
8648 | 34 #include "dsputil.h" |
4277
113f3b395bac
Making rem6 and div6 globally visible and thus adding prefixes.
takis
parents:
4276
diff
changeset
|
35 |
1168 | 36 /** |
37 * fill a rectangle. | |
2392 | 38 * @param h height of the rectangle, should be a constant |
39 * @param w width of the rectangle, should be a constant | |
11279 | 40 * @param size the size of val (1, 2 or 4), should be a constant |
1168 | 41 */ |
4283
d6f83e2f8804
rename always_inline to av_always_inline and move to common.h
mru
parents:
4277
diff
changeset
|
42 static av_always_inline void fill_rectangle(void *vp, int w, int h, int stride, uint32_t val, int size){ |
1187 | 43 uint8_t *p= (uint8_t*)vp; |
11279 | 44 assert(size==1 || size==2 || size==4); |
3315 | 45 assert(w<=4); |
2967 | 46 |
1168 | 47 w *= size; |
48 stride *= size; | |
2967 | 49 |
2962 | 50 assert((((long)vp)&(FFMIN(w, STRIDE_ALIGN)-1)) == 0); |
2669 | 51 assert((stride&(w-1))==0); |
3315 | 52 if(w==2){ |
53 const uint16_t v= size==4 ? val : val*0x0101; | |
54 *(uint16_t*)(p + 0*stride)= v; | |
55 if(h==1) return; | |
56 *(uint16_t*)(p + 1*stride)= v; | |
57 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
|
58 *(uint16_t*)(p + 2*stride)= v; |
3315 | 59 *(uint16_t*)(p + 3*stride)= v; |
60 }else if(w==4){ | |
11276 | 61 const uint32_t v= size==4 ? val : size==2 ? val*0x00010001 : val*0x01010101; |
3315 | 62 *(uint32_t*)(p + 0*stride)= v; |
63 if(h==1) return; | |
64 *(uint32_t*)(p + 1*stride)= v; | |
65 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
|
66 *(uint32_t*)(p + 2*stride)= v; |
3315 | 67 *(uint32_t*)(p + 3*stride)= v; |
68 }else if(w==8){ | |
69 //gcc can't optimize 64bit math on x86_32 | |
8590 | 70 #if HAVE_FAST_64BIT |
11276 | 71 const uint64_t v= size==2 ? val*0x0001000100010001ULL : val*0x0100000001ULL; |
3315 | 72 *(uint64_t*)(p + 0*stride)= v; |
73 if(h==1) return; | |
74 *(uint64_t*)(p + 1*stride)= v; | |
75 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
|
76 *(uint64_t*)(p + 2*stride)= v; |
3315 | 77 *(uint64_t*)(p + 3*stride)= v; |
78 }else if(w==16){ | |
79 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
|
80 *(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
|
81 *(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
|
82 *(uint64_t*)(p + 0+1*stride)= v; |
3315 | 83 *(uint64_t*)(p + 8+1*stride)= v; |
84 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
|
85 *(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
|
86 *(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
|
87 *(uint64_t*)(p + 0+3*stride)= v; |
3315 | 88 *(uint64_t*)(p + 8+3*stride)= v; |
89 #else | |
11280 | 90 const uint32_t v= size==2 ? val*0x00010001 : val; |
11276 | 91 *(uint32_t*)(p + 0+0*stride)= v; |
92 *(uint32_t*)(p + 4+0*stride)= v; | |
3315 | 93 if(h==1) return; |
11276 | 94 *(uint32_t*)(p + 0+1*stride)= v; |
95 *(uint32_t*)(p + 4+1*stride)= v; | |
3315 | 96 if(h==2) return; |
11276 | 97 *(uint32_t*)(p + 0+2*stride)= v; |
98 *(uint32_t*)(p + 4+2*stride)= v; | |
99 *(uint32_t*)(p + 0+3*stride)= v; | |
100 *(uint32_t*)(p + 4+3*stride)= v; | |
3315 | 101 }else if(w==16){ |
11278
bd5ea8e6f1d3
Try to fix 100l compilation failure on some systems.
michael
parents:
11276
diff
changeset
|
102 *(uint32_t*)(p + 0+0*stride)= val; |
bd5ea8e6f1d3
Try to fix 100l compilation failure on some systems.
michael
parents:
11276
diff
changeset
|
103 *(uint32_t*)(p + 4+0*stride)= val; |
bd5ea8e6f1d3
Try to fix 100l compilation failure on some systems.
michael
parents:
11276
diff
changeset
|
104 *(uint32_t*)(p + 8+0*stride)= val; |
bd5ea8e6f1d3
Try to fix 100l compilation failure on some systems.
michael
parents:
11276
diff
changeset
|
105 *(uint32_t*)(p +12+0*stride)= val; |
bd5ea8e6f1d3
Try to fix 100l compilation failure on some systems.
michael
parents:
11276
diff
changeset
|
106 *(uint32_t*)(p + 0+1*stride)= val; |
bd5ea8e6f1d3
Try to fix 100l compilation failure on some systems.
michael
parents:
11276
diff
changeset
|
107 *(uint32_t*)(p + 4+1*stride)= val; |
bd5ea8e6f1d3
Try to fix 100l compilation failure on some systems.
michael
parents:
11276
diff
changeset
|
108 *(uint32_t*)(p + 8+1*stride)= val; |
bd5ea8e6f1d3
Try to fix 100l compilation failure on some systems.
michael
parents:
11276
diff
changeset
|
109 *(uint32_t*)(p +12+1*stride)= val; |
3315 | 110 if(h==2) return; |
11278
bd5ea8e6f1d3
Try to fix 100l compilation failure on some systems.
michael
parents:
11276
diff
changeset
|
111 *(uint32_t*)(p + 0+2*stride)= val; |
bd5ea8e6f1d3
Try to fix 100l compilation failure on some systems.
michael
parents:
11276
diff
changeset
|
112 *(uint32_t*)(p + 4+2*stride)= val; |
bd5ea8e6f1d3
Try to fix 100l compilation failure on some systems.
michael
parents:
11276
diff
changeset
|
113 *(uint32_t*)(p + 8+2*stride)= val; |
bd5ea8e6f1d3
Try to fix 100l compilation failure on some systems.
michael
parents:
11276
diff
changeset
|
114 *(uint32_t*)(p +12+2*stride)= val; |
bd5ea8e6f1d3
Try to fix 100l compilation failure on some systems.
michael
parents:
11276
diff
changeset
|
115 *(uint32_t*)(p + 0+3*stride)= val; |
bd5ea8e6f1d3
Try to fix 100l compilation failure on some systems.
michael
parents:
11276
diff
changeset
|
116 *(uint32_t*)(p + 4+3*stride)= val; |
bd5ea8e6f1d3
Try to fix 100l compilation failure on some systems.
michael
parents:
11276
diff
changeset
|
117 *(uint32_t*)(p + 8+3*stride)= val; |
bd5ea8e6f1d3
Try to fix 100l compilation failure on some systems.
michael
parents:
11276
diff
changeset
|
118 *(uint32_t*)(p +12+3*stride)= val; |
3315 | 119 #endif |
1168 | 120 }else |
121 assert(0); | |
3315 | 122 assert(h==4); |
1168 | 123 } |
124 | |
7760 | 125 #endif /* AVCODEC_RECTANGLE_H */ |