comparison pixdesc.h @ 9528:dad1c3ed61f1 libavcodec

Implement a write_line() function.
author stefano
date Tue, 21 Apr 2009 19:15:21 +0000
parents e806d2145e72
children e885f6298a7a
comparison
equal deleted inserted replaced
9527:b687da895962 9528:dad1c3ed61f1
135 p+= step; 135 p+= step;
136 *dst++= val; 136 *dst++= val;
137 } 137 }
138 } 138 }
139 } 139 }
140
141 /**
142 * Writes the values from src to the pixel format component c of an
143 * image line.
144 *
145 * @param src array containing the values to write
146 * @param data the array containing the pointers to the planes of the
147 * image to write into. It is supposed to be zeroed.
148 * @param linesizes the array containing the linesizes of the image
149 * @param desc the pixel format descriptor for the image
150 * @param x the horizontal coordinate of the first pixel to write
151 * @param y the vertical coordinate of the first pixel to write
152 * @param w the width of the line to write, that is the number of
153 * values to write to the image line
154 */
155 static inline void write_line(const uint16_t *src, uint8_t *data[4], const int linesize[4],
156 const AVPixFmtDescriptor *desc, int x, int y, int c, int w)
157 {
158 AVComponentDescriptor comp = desc->comp[c];
159 int plane = comp.plane;
160 int depth = comp.depth_minus1+1;
161 int step = comp.step_minus1+1;
162 int flags = desc->flags;
163
164 if (flags & PIX_FMT_BITSTREAM) {
165 int skip = x*step + comp.offset_plus1-1;
166 uint8_t *p = data[plane] + y*linesize[plane] + (skip>>3);
167 int shift = 8 - depth - (skip&7);
168
169 while (w--) {
170 *p |= *src++ << shift;
171 shift -= step;
172 p -= shift>>3;
173 shift &= 7;
174 }
175 } else {
176 int shift = comp.shift;
177 uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1;
178
179 while (w--) {
180 if (flags & PIX_FMT_BE) {
181 uint16_t val = AV_RB16(p) | (*src++<<shift);
182 AV_WB16(p, val);
183 } else {
184 uint16_t val = AV_RL16(p) | (*src++<<shift);
185 AV_WL16(p, val);
186 }
187 p+= step;
188 }
189 }
190 }