Home | History | Annotate | Download | only in src

Lines Matching refs:img

18 static vpx_image_t *img_alloc_helper(vpx_image_t *img, vpx_img_fmt_t fmt,
100 if (!img) {
101 img = (vpx_image_t *)calloc(1, sizeof(vpx_image_t));
103 if (!img) goto fail;
105 img->self_allocd = 1;
107 memset(img, 0, sizeof(vpx_image_t));
110 img->img_data = img_data;
128 img->img_data = (uint8_t *)vpx_memalign(buf_align, (size_t)alloc_size);
129 img->img_data_owner = 1;
132 if (!img->img_data) goto fail;
134 img->fmt = fmt;
135 img->bit_depth = (fmt & VPX_IMG_FMT_HIGHBITDEPTH) ? 16 : 8;
136 img->w = w;
137 img->h = h;
138 img->x_chroma_shift = xcs;
139 img->y_chroma_shift = ycs;
140 img->bps = bps;
143 img->stride[VPX_PLANE_Y] = img->stride[VPX_PLANE_ALPHA] = stride_in_bytes;
144 img->stride[VPX_PLANE_U] = img->stride[VPX_PLANE_V] = stride_in_bytes >> xcs;
147 if (!vpx_img_set_rect(img, 0, 0, d_w, d_h)) return img;
150 vpx_img_free(img);
154 vpx_image_t *vpx_img_alloc(vpx_image_t *img, vpx_img_fmt_t fmt,
157 return img_alloc_helper(img, fmt, d_w, d_h, align, align, NULL);
160 vpx_image_t *vpx_img_wrap(vpx_image_t *img, vpx_img_fmt_t fmt, unsigned int d_w,
165 return img_alloc_helper(img, fmt, d_w, d_h, 1, stride_align, img_data);
168 int vpx_img_set_rect(vpx_image_t *img, unsigned int x, unsigned int y,
172 if (x + w <= img->w && y + h <= img->h) {
173 img->d_w = w;
174 img->d_h = h;
177 if (!(img->fmt & VPX_IMG_FMT_PLANAR)) {
178 img->planes[VPX_PLANE_PACKED] =
179 img->img_data + x * img->bps / 8 + y * img->stride[VPX_PLANE_PACKED];
182 (img->fmt & VPX_IMG_FMT_HIGHBITDEPTH) ? 2 : 1;
183 data = img->img_data;
185 if (img->fmt & VPX_IMG_FMT_HAS_ALPHA) {
186 img->planes[VPX_PLANE_ALPHA] =
187 data + x * bytes_per_sample + y * img->stride[VPX_PLANE_ALPHA];
188 data += img->h * img->stride[VPX_PLANE_ALPHA];
191 img->planes[VPX_PLANE_Y] =
192 data + x * bytes_per_sample + y * img->stride[VPX_PLANE_Y];
193 data += img->h * img->stride[VPX_PLANE_Y];
195 if (!(img->fmt & VPX_IMG_FMT_UV_FLIP)) {
196 img->planes[VPX_PLANE_U] =
197 data + (x >> img->x_chroma_shift) * bytes_per_sample +
198 (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_U];
199 data += (img->h >> img->y_chroma_shift) * img->stride[VPX_PLANE_U];
200 img->planes[VPX_PLANE_V] =
201 data + (x >> img->x_chroma_shift) * bytes_per_sample +
202 (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_V];
204 img->planes[VPX_PLANE_V] =
205 data + (x >> img->x_chroma_shift) * bytes_per_sample +
206 (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_V];
207 data += (img->h >> img->y_chroma_shift) * img->stride[VPX_PLANE_V];
208 img->planes[VPX_PLANE_U] =
209 data + (x >> img->x_chroma_shift) * bytes_per_sample +
210 (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_U];
218 void vpx_img_flip(vpx_image_t *img) {
225 img->planes[VPX_PLANE_Y] += (signed)(img->d_h - 1) * img->stride[VPX_PLANE_Y];
226 img->stride[VPX_PLANE_Y] = -img->stride[VPX_PLANE_Y];
228 img->planes[VPX_PLANE_U] += (signed)((img->d_h >> img->y_chroma_shift) - 1) *
229 img->stride[VPX_PLANE_U];
230 img->stride[VPX_PLANE_U] = -img->stride[VPX_PLANE_U];
232 img->planes[VPX_PLANE_V] += (signed)((img->d_h >> img->y_chroma_shift) - 1) *
233 img->stride[VPX_PLANE_V];
234 img->stride[VPX_PLANE_V] = -img->stride[VPX_PLANE_V];
236 img->planes[VPX_PLANE_ALPHA] +=
237 (signed)(img->d_h - 1) * img->stride[VPX_PLANE_ALPHA];
238 img->stride[VPX_PLANE_ALPHA] = -img->stride[VPX_PLANE_ALPHA];
241 void vpx_img_free(vpx_image_t *img) {
242 if (img) {
243 if (img->img_data && img->img_data_owner) vpx_free(img->img_data);
245 if (img->self_allocd) free(img);