Lines Matching refs:picture
41 int WebPPictureAlloc(WebPPicture* picture) { in WebPPictureAlloc() argument
42 if (picture != NULL) { in WebPPictureAlloc()
43 const WebPEncCSP uv_csp = picture->colorspace & WEBP_CSP_UV_MASK; in WebPPictureAlloc()
44 const int has_alpha = picture->colorspace & WEBP_CSP_ALPHA_BIT; in WebPPictureAlloc()
45 const int width = picture->width; in WebPPictureAlloc()
46 const int height = picture->height; in WebPPictureAlloc()
48 if (!picture->use_argb) { in WebPPictureAlloc()
92 WebPPictureFree(picture); // erase previous buffer in WebPPictureAlloc()
97 picture->memory_ = (void*)mem; in WebPPictureAlloc()
98 picture->y_stride = y_stride; in WebPPictureAlloc()
99 picture->uv_stride = uv_stride; in WebPPictureAlloc()
100 picture->a_stride = a_stride; in WebPPictureAlloc()
101 picture->uv0_stride = uv0_stride; in WebPPictureAlloc()
103 picture->y = mem; in WebPPictureAlloc()
106 picture->u = mem; in WebPPictureAlloc()
108 picture->v = mem; in WebPPictureAlloc()
112 picture->a = mem; in WebPPictureAlloc()
116 picture->u0 = mem; in WebPPictureAlloc()
118 picture->v0 = mem; in WebPPictureAlloc()
128 WebPPictureFree(picture); // erase previous buffer in WebPPictureAlloc()
129 memory = WebPSafeMalloc(argb_size, sizeof(*picture->argb)); in WebPPictureAlloc()
133 picture->memory_argb_ = memory; in WebPPictureAlloc()
134 picture->argb = (uint32_t*)memory; in WebPPictureAlloc()
135 picture->argb_stride = width; in WebPPictureAlloc()
142 static void PictureResetARGB(WebPPicture* const picture) { in PictureResetARGB() argument
143 picture->memory_argb_ = NULL; in PictureResetARGB()
144 picture->argb = NULL; in PictureResetARGB()
145 picture->argb_stride = 0; in PictureResetARGB()
149 static void PictureResetYUVA(WebPPicture* const picture) { in PictureResetYUVA() argument
150 picture->memory_ = NULL; in PictureResetYUVA()
151 picture->y = picture->u = picture->v = picture->a = NULL; in PictureResetYUVA()
152 picture->u0 = picture->v0 = NULL; in PictureResetYUVA()
153 picture->y_stride = picture->uv_stride = 0; in PictureResetYUVA()
154 picture->a_stride = 0; in PictureResetYUVA()
155 picture->uv0_stride = 0; in PictureResetYUVA()
170 static int PictureAllocARGB(WebPPicture* const picture) { in PictureAllocARGB() argument
172 free(picture->memory_argb_); in PictureAllocARGB()
173 PictureResetARGB(picture); in PictureAllocARGB()
174 picture->use_argb = 1; in PictureAllocARGB()
175 WebPPictureGrabSpecs(picture, &tmp); in PictureAllocARGB()
177 return WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); in PictureAllocARGB()
179 picture->memory_argb_ = tmp.memory_argb_; in PictureAllocARGB()
180 picture->argb = tmp.argb; in PictureAllocARGB()
181 picture->argb_stride = tmp.argb_stride; in PictureAllocARGB()
186 void WebPPictureFree(WebPPicture* picture) { in WebPPictureFree() argument
187 if (picture != NULL) { in WebPPictureFree()
188 free(picture->memory_); in WebPPictureFree()
189 free(picture->memory_argb_); in WebPPictureFree()
190 PictureResetYUVA(picture); in WebPPictureFree()
191 PictureResetARGB(picture); in WebPPictureFree()
270 int WebPPictureIsView(const WebPPicture* picture) { in WebPPictureIsView() argument
271 if (picture == NULL) return 0; in WebPPictureIsView()
272 if (picture->use_argb) { in WebPPictureIsView()
273 return (picture->memory_argb_ == NULL); in WebPPictureIsView()
275 return (picture->memory_ == NULL); in WebPPictureIsView()
484 const WebPPicture* picture) { in WebPMemoryWrite() argument
485 WebPMemoryWriter* const w = (WebPMemoryWriter*)picture->custom_ptr; in WebPMemoryWrite()
533 int WebPPictureHasTransparency(const WebPPicture* picture) { in WebPPictureHasTransparency() argument
534 if (picture == NULL) return 0; in WebPPictureHasTransparency()
535 if (!picture->use_argb) { in WebPPictureHasTransparency()
536 return CheckNonOpaque(picture->a, picture->width, picture->height, in WebPPictureHasTransparency()
537 1, picture->a_stride); in WebPPictureHasTransparency()
540 const uint32_t* argb = picture->argb; in WebPPictureHasTransparency()
542 for (y = 0; y < picture->height; ++y) { in WebPPictureHasTransparency()
543 for (x = 0; x < picture->width; ++x) { in WebPPictureHasTransparency()
546 argb += picture->argb_stride; in WebPPictureHasTransparency()
563 const int dst = (x) + (y) * picture->uv_stride; \
567 picture->u[dst] = VP8RGBToU(r, g, b); \
568 picture->v[dst] = VP8RGBToV(r, g, b); \
573 const int dst = (x_out) + (y) * picture->uv0_stride; \
577 picture->u0[dst] = VP8RGBToU(r, g, b); \
578 picture->v0[dst] = VP8RGBToV(r, g, b); \
581 static void MakeGray(WebPPicture* const picture) { in MakeGray() argument
583 const int uv_width = HALVE(picture->width); in MakeGray()
584 const int uv_height = HALVE(picture->height); in MakeGray()
586 memset(picture->u + y * picture->uv_stride, 128, uv_width); in MakeGray()
587 memset(picture->v + y * picture->uv_stride, 128, uv_width); in MakeGray()
597 WebPPicture* const picture) { in ImportYUVAFromRGBA() argument
598 const WebPEncCSP uv_csp = picture->colorspace & WEBP_CSP_UV_MASK; in ImportYUVAFromRGBA()
600 const int width = picture->width; in ImportYUVAFromRGBA()
601 const int height = picture->height; in ImportYUVAFromRGBA()
604 picture->colorspace = uv_csp; in ImportYUVAFromRGBA()
605 picture->use_argb = 0; in ImportYUVAFromRGBA()
607 picture->colorspace |= WEBP_CSP_ALPHA_BIT; in ImportYUVAFromRGBA()
609 if (!WebPPictureAlloc(picture)) return 0; in ImportYUVAFromRGBA()
615 picture->y[x + y * picture->y_stride] = in ImportYUVAFromRGBA()
659 MakeGray(picture); in ImportYUVAFromRGBA()
666 picture->a[x + y * picture->a_stride] = in ImportYUVAFromRGBA()
674 static int Import(WebPPicture* const picture, in Import() argument
681 const int width = picture->width; in Import()
682 const int height = picture->height; in Import()
684 if (!picture->use_argb) { in Import()
686 picture); in Import()
689 picture->colorspace |= WEBP_CSP_ALPHA_BIT; in Import()
691 picture->colorspace &= ~WEBP_CSP_ALPHA_BIT; in Import()
693 if (!WebPPictureAlloc(picture)) return 0; in Import()
705 picture->argb[x + y * picture->argb_stride] = argb; in Import()
718 picture->argb[x + y * picture->argb_stride] = argb; in Import()
730 int WebPPictureImportRGB(WebPPicture* picture, in WebPPictureImportRGB() argument
732 return Import(picture, rgb, rgb_stride, 3, 0, 0); in WebPPictureImportRGB()
735 int WebPPictureImportBGR(WebPPicture* picture, in WebPPictureImportBGR() argument
737 return Import(picture, rgb, rgb_stride, 3, 1, 0); in WebPPictureImportBGR()
740 int WebPPictureImportRGBA(WebPPicture* picture, in WebPPictureImportRGBA() argument
742 return Import(picture, rgba, rgba_stride, 4, 0, 1); in WebPPictureImportRGBA()
745 int WebPPictureImportBGRA(WebPPicture* picture, in WebPPictureImportBGRA() argument
747 return Import(picture, rgba, rgba_stride, 4, 1, 1); in WebPPictureImportBGRA()
750 int WebPPictureImportRGBX(WebPPicture* picture, in WebPPictureImportRGBX() argument
752 return Import(picture, rgba, rgba_stride, 4, 0, 0); in WebPPictureImportRGBX()
755 int WebPPictureImportBGRX(WebPPicture* picture, in WebPPictureImportBGRX() argument
757 return Import(picture, rgba, rgba_stride, 4, 1, 0); in WebPPictureImportBGRX()
763 int WebPPictureYUVAToARGB(WebPPicture* picture) { in WebPPictureYUVAToARGB() argument
764 if (picture == NULL) return 0; in WebPPictureYUVAToARGB()
765 if (picture->memory_ == NULL || picture->y == NULL || in WebPPictureYUVAToARGB()
766 picture->u == NULL || picture->v == NULL) { in WebPPictureYUVAToARGB()
767 return WebPEncodingSetError(picture, VP8_ENC_ERROR_NULL_PARAMETER); in WebPPictureYUVAToARGB()
769 if ((picture->colorspace & WEBP_CSP_ALPHA_BIT) && picture->a == NULL) { in WebPPictureYUVAToARGB()
770 return WebPEncodingSetError(picture, VP8_ENC_ERROR_NULL_PARAMETER); in WebPPictureYUVAToARGB()
772 if ((picture->colorspace & WEBP_CSP_UV_MASK) != WEBP_YUV420) { in WebPPictureYUVAToARGB()
773 return WebPEncodingSetError(picture, VP8_ENC_ERROR_INVALID_CONFIGURATION); in WebPPictureYUVAToARGB()
776 if (!PictureAllocARGB(picture)) return 0; in WebPPictureYUVAToARGB()
781 const int width = picture->width; in WebPPictureYUVAToARGB()
782 const int height = picture->height; in WebPPictureYUVAToARGB()
783 const int argb_stride = 4 * picture->argb_stride; in WebPPictureYUVAToARGB()
784 uint8_t* dst = (uint8_t*)picture->argb; in WebPPictureYUVAToARGB()
785 const uint8_t *cur_u = picture->u, *cur_v = picture->v, *cur_y = picture->y; in WebPPictureYUVAToARGB()
790 cur_y += picture->y_stride; in WebPPictureYUVAToARGB()
796 cur_u += picture->uv_stride; in WebPPictureYUVAToARGB()
797 cur_v += picture->uv_stride; in WebPPictureYUVAToARGB()
798 upsample(cur_y, cur_y + picture->y_stride, top_u, top_v, cur_u, cur_v, in WebPPictureYUVAToARGB()
800 cur_y += 2 * picture->y_stride; in WebPPictureYUVAToARGB()
808 if (picture->colorspace & WEBP_CSP_ALPHA_BIT) { in WebPPictureYUVAToARGB()
810 uint32_t* const argb_dst = picture->argb + y * picture->argb_stride; in WebPPictureYUVAToARGB()
811 const uint8_t* const src = picture->a + y * picture->a_stride; in WebPPictureYUVAToARGB()
822 int WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace) { in WebPPictureARGBToYUVA() argument
823 if (picture == NULL) return 0; in WebPPictureARGBToYUVA()
824 if (picture->argb == NULL) { in WebPPictureARGBToYUVA()
825 return WebPEncodingSetError(picture, VP8_ENC_ERROR_NULL_PARAMETER); in WebPPictureARGBToYUVA()
827 const uint8_t* const argb = (const uint8_t*)picture->argb; in WebPPictureARGBToYUVA()
834 WebPPicture tmp = *picture; in WebPPictureARGBToYUVA()
838 if (!ImportYUVAFromRGBA(r, g, b, a, 4, 4 * picture->argb_stride, &tmp)) { in WebPPictureARGBToYUVA()
839 return WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); in WebPPictureARGBToYUVA()
842 tmp.argb = picture->argb; in WebPPictureARGBToYUVA()
843 tmp.argb_stride = picture->argb_stride; in WebPPictureARGBToYUVA()
844 tmp.memory_argb_ = picture->memory_argb_; in WebPPictureARGBToYUVA()
845 *picture = tmp; in WebPPictureARGBToYUVA()