Home | History | Annotate | Download | only in src

Lines Matching full:img

16 static vpx_image_t *img_alloc_helper(vpx_image_t  *img,
104 if (!img)
106 img = (vpx_image_t *)calloc(1, sizeof(vpx_image_t));
108 if (!img)
111 img->self_allocd = 1;
115 memset(img, 0, sizeof(vpx_image_t));
118 img->img_data = img_data;
122 img->img_data = malloc((fmt & VPX_IMG_FMT_PLANAR) ? h * w * bps / 8 : h * s);
123 img->img_data_owner = 1;
126 if (!img->img_data)
129 img->fmt = fmt;
130 img->w = w;
131 img->h = h;
132 img->x_chroma_shift = xcs;
133 img->y_chroma_shift = ycs;
134 img->bps = bps;
137 img->stride[VPX_PLANE_Y] = img->stride[VPX_PLANE_ALPHA] = s;
138 img->stride[VPX_PLANE_U] = img->stride[VPX_PLANE_V] = s >> xcs;
141 if (!vpx_img_set_rect(img, 0, 0, d_w, d_h))
142 return img;
145 vpx_img_free(img);
149 vpx_image_t *vpx_img_alloc(vpx_image_t *img,
155 return img_alloc_helper(img, fmt, d_w, d_h, stride_align, NULL);
158 vpx_image_t *vpx_img_wrap(vpx_image_t *img,
165 return img_alloc_helper(img, fmt, d_w, d_h, stride_align, img_data);
168 int vpx_img_set_rect(vpx_image_t *img,
176 if (x + w <= img->w && y + h <= img->h)
178 img->d_w = w;
179 img->d_h = h;
182 if (!(img->fmt & VPX_IMG_FMT_PLANAR))
184 img->planes[VPX_PLANE_PACKED] =
185 img->img_data + x * img->bps / 8 + y * img->stride[VPX_PLANE_PACKED];
189 data = img->img_data;
191 if (img->fmt & VPX_IMG_FMT_HAS_ALPHA)
193 img->planes[VPX_PLANE_ALPHA] =
194 data + x + y * img->stride[VPX_PLANE_ALPHA];
195 data += img->h * img->stride[VPX_PLANE_ALPHA];
198 img->planes[VPX_PLANE_Y] = data + x + y * img->stride[VPX_PLANE_Y];
199 data += img->h * img->stride[VPX_PLANE_Y];
201 if (!(img->fmt & VPX_IMG_FMT_UV_FLIP))
203 img->planes[VPX_PLANE_U] = data
204 + (x >> img->x_chroma_shift)
205 + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_U];
206 data += (img->h >> img->y_chroma_shift) * img->stride[VPX_PLANE_U];
207 img->planes[VPX_PLANE_V] = data
208 + (x >> img->x_chroma_shift)
209 + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_V];
213 img->planes[VPX_PLANE_V] = data
214 + (x >> img->x_chroma_shift)
215 + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_V];
216 data += (img->h >> img->y_chroma_shift) * img->stride[VPX_PLANE_V];
217 img->planes[VPX_PLANE_U] = data
218 + (x >> img->x_chroma_shift)
219 + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_U];
229 void vpx_img_flip(vpx_image_t *img)
237 img->planes[VPX_PLANE_Y] += (signed)(img->d_h - 1) * img->stride[VPX_PLANE_Y];
238 img->stride[VPX_PLANE_Y] = -img->stride[VPX_PLANE_Y];
240 img->planes[VPX_PLANE_U] += (signed)((img->d_h >> img->y_chroma_shift) - 1)
241 * img->stride[VPX_PLANE_U];
242 img->stride[VPX_PLANE_U] = -img->stride[VPX_PLANE_U];
244 img->planes[VPX_PLANE_V] += (signed)((img->d_h >> img->y_chroma_shift) - 1)
245 * img->stride[VPX_PLANE_V];
246 img->stride[VPX_PLANE_V] = -img->stride[VPX_PLANE_V];
248 img->planes[VPX_PLANE_ALPHA] += (signed)(img->d_h - 1) * img->stride[VPX_PLANE_ALPHA];
249 img->stride[VPX_PLANE_ALPHA] = -img->stride[VPX_PLANE_ALPHA];
252 void vpx_img_free(vpx_image_t *img)
254 if (img)
256 if (img->img_data && img->img_data_owner)
257 free(img->img_data);
259 if (img->self_allocd)
260 free(img);