Mercurial > libavcodec.hg
comparison h264.c @ 6020:c531defb03ee libavcodec
Make fill_rectangle() available for other decoders
author | kostya |
---|---|
date | Sat, 15 Dec 2007 06:06:16 +0000 |
parents | 42de24a34fd2 |
children | fc51a6ffa64f |
comparison
equal
deleted
inserted
replaced
6019:42de24a34fd2 | 6020:c531defb03ee |
---|---|
30 #include "mpegvideo.h" | 30 #include "mpegvideo.h" |
31 #include "h264.h" | 31 #include "h264.h" |
32 #include "h264data.h" | 32 #include "h264data.h" |
33 #include "h264_parser.h" | 33 #include "h264_parser.h" |
34 #include "golomb.h" | 34 #include "golomb.h" |
35 #include "rectangle.h" | |
35 | 36 |
36 #include "cabac.h" | 37 #include "cabac.h" |
37 | 38 |
38 //#undef NDEBUG | 39 //#undef NDEBUG |
39 #include <assert.h> | 40 #include <assert.h> |
72 | 73 |
73 const uint8_t ff_div6[52]={ | 74 const uint8_t ff_div6[52]={ |
74 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, | 75 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, |
75 }; | 76 }; |
76 | 77 |
77 | |
78 /** | |
79 * fill a rectangle. | |
80 * @param h height of the rectangle, should be a constant | |
81 * @param w width of the rectangle, should be a constant | |
82 * @param size the size of val (1 or 4), should be a constant | |
83 */ | |
84 static av_always_inline void fill_rectangle(void *vp, int w, int h, int stride, uint32_t val, int size){ | |
85 uint8_t *p= (uint8_t*)vp; | |
86 assert(size==1 || size==4); | |
87 assert(w<=4); | |
88 | |
89 w *= size; | |
90 stride *= size; | |
91 | |
92 assert((((long)vp)&(FFMIN(w, STRIDE_ALIGN)-1)) == 0); | |
93 assert((stride&(w-1))==0); | |
94 if(w==2){ | |
95 const uint16_t v= size==4 ? val : val*0x0101; | |
96 *(uint16_t*)(p + 0*stride)= v; | |
97 if(h==1) return; | |
98 *(uint16_t*)(p + 1*stride)= v; | |
99 if(h==2) return; | |
100 *(uint16_t*)(p + 2*stride)= v; | |
101 *(uint16_t*)(p + 3*stride)= v; | |
102 }else if(w==4){ | |
103 const uint32_t v= size==4 ? val : val*0x01010101; | |
104 *(uint32_t*)(p + 0*stride)= v; | |
105 if(h==1) return; | |
106 *(uint32_t*)(p + 1*stride)= v; | |
107 if(h==2) return; | |
108 *(uint32_t*)(p + 2*stride)= v; | |
109 *(uint32_t*)(p + 3*stride)= v; | |
110 }else if(w==8){ | |
111 //gcc can't optimize 64bit math on x86_32 | |
112 #if defined(ARCH_X86_64) || (defined(MP_WORDSIZE) && MP_WORDSIZE >= 64) | |
113 const uint64_t v= val*0x0100000001ULL; | |
114 *(uint64_t*)(p + 0*stride)= v; | |
115 if(h==1) return; | |
116 *(uint64_t*)(p + 1*stride)= v; | |
117 if(h==2) return; | |
118 *(uint64_t*)(p + 2*stride)= v; | |
119 *(uint64_t*)(p + 3*stride)= v; | |
120 }else if(w==16){ | |
121 const uint64_t v= val*0x0100000001ULL; | |
122 *(uint64_t*)(p + 0+0*stride)= v; | |
123 *(uint64_t*)(p + 8+0*stride)= v; | |
124 *(uint64_t*)(p + 0+1*stride)= v; | |
125 *(uint64_t*)(p + 8+1*stride)= v; | |
126 if(h==2) return; | |
127 *(uint64_t*)(p + 0+2*stride)= v; | |
128 *(uint64_t*)(p + 8+2*stride)= v; | |
129 *(uint64_t*)(p + 0+3*stride)= v; | |
130 *(uint64_t*)(p + 8+3*stride)= v; | |
131 #else | |
132 *(uint32_t*)(p + 0+0*stride)= val; | |
133 *(uint32_t*)(p + 4+0*stride)= val; | |
134 if(h==1) return; | |
135 *(uint32_t*)(p + 0+1*stride)= val; | |
136 *(uint32_t*)(p + 4+1*stride)= val; | |
137 if(h==2) return; | |
138 *(uint32_t*)(p + 0+2*stride)= val; | |
139 *(uint32_t*)(p + 4+2*stride)= val; | |
140 *(uint32_t*)(p + 0+3*stride)= val; | |
141 *(uint32_t*)(p + 4+3*stride)= val; | |
142 }else if(w==16){ | |
143 *(uint32_t*)(p + 0+0*stride)= val; | |
144 *(uint32_t*)(p + 4+0*stride)= val; | |
145 *(uint32_t*)(p + 8+0*stride)= val; | |
146 *(uint32_t*)(p +12+0*stride)= val; | |
147 *(uint32_t*)(p + 0+1*stride)= val; | |
148 *(uint32_t*)(p + 4+1*stride)= val; | |
149 *(uint32_t*)(p + 8+1*stride)= val; | |
150 *(uint32_t*)(p +12+1*stride)= val; | |
151 if(h==2) return; | |
152 *(uint32_t*)(p + 0+2*stride)= val; | |
153 *(uint32_t*)(p + 4+2*stride)= val; | |
154 *(uint32_t*)(p + 8+2*stride)= val; | |
155 *(uint32_t*)(p +12+2*stride)= val; | |
156 *(uint32_t*)(p + 0+3*stride)= val; | |
157 *(uint32_t*)(p + 4+3*stride)= val; | |
158 *(uint32_t*)(p + 8+3*stride)= val; | |
159 *(uint32_t*)(p +12+3*stride)= val; | |
160 #endif | |
161 }else | |
162 assert(0); | |
163 assert(h==4); | |
164 } | |
165 | 78 |
166 static void fill_caches(H264Context *h, int mb_type, int for_deblock){ | 79 static void fill_caches(H264Context *h, int mb_type, int for_deblock){ |
167 MpegEncContext * const s = &h->s; | 80 MpegEncContext * const s = &h->s; |
168 const int mb_xy= s->mb_x + s->mb_y*s->mb_stride; | 81 const int mb_xy= s->mb_x + s->mb_y*s->mb_stride; |
169 int topleft_xy, top_xy, topright_xy, left_xy[2]; | 82 int topleft_xy, top_xy, topright_xy, left_xy[2]; |