| OLD | NEW |
| 1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Use of this source code is governed by a BSD-style license | 3 // Use of this source code is governed by a BSD-style license |
| 4 // that can be found in the COPYING file in the root of the source | 4 // that can be found in the COPYING file in the root of the source |
| 5 // tree. An additional intellectual property rights grant can be found | 5 // tree. An additional intellectual property rights grant can be found |
| 6 // in the file PATENTS. All contributing project authors may | 6 // in the file PATENTS. All contributing project authors may |
| 7 // be found in the AUTHORS file in the root of the source tree. | 7 // be found in the AUTHORS file in the root of the source tree. |
| 8 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
| 9 // | 9 // |
| 10 // functions for sample output. | 10 // functions for sample output. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 dst + buf->stride, NULL, mb_w); | 112 dst + buf->stride, NULL, mb_w); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 return num_lines_out; | 115 return num_lines_out; |
| 116 } | 116 } |
| 117 | 117 |
| 118 #endif /* FANCY_UPSAMPLING */ | 118 #endif /* FANCY_UPSAMPLING */ |
| 119 | 119 |
| 120 //------------------------------------------------------------------------------ | 120 //------------------------------------------------------------------------------ |
| 121 | 121 |
| 122 static void FillAlphaPlane(uint8_t* dst, int w, int h, int stride) { |
| 123 int j; |
| 124 for (j = 0; j < h; ++j) { |
| 125 memset(dst, 0xff, w * sizeof(*dst)); |
| 126 dst += stride; |
| 127 } |
| 128 } |
| 129 |
| 122 static int EmitAlphaYUV(const VP8Io* const io, WebPDecParams* const p, | 130 static int EmitAlphaYUV(const VP8Io* const io, WebPDecParams* const p, |
| 123 int expected_num_lines_out) { | 131 int expected_num_lines_out) { |
| 124 const uint8_t* alpha = io->a; | 132 const uint8_t* alpha = io->a; |
| 125 const WebPYUVABuffer* const buf = &p->output->u.YUVA; | 133 const WebPYUVABuffer* const buf = &p->output->u.YUVA; |
| 126 const int mb_w = io->mb_w; | 134 const int mb_w = io->mb_w; |
| 127 const int mb_h = io->mb_h; | 135 const int mb_h = io->mb_h; |
| 128 uint8_t* dst = buf->a + io->mb_y * buf->a_stride; | 136 uint8_t* dst = buf->a + io->mb_y * buf->a_stride; |
| 129 int j; | 137 int j; |
| 130 (void)expected_num_lines_out; | 138 (void)expected_num_lines_out; |
| 131 assert(expected_num_lines_out == mb_h); | 139 assert(expected_num_lines_out == mb_h); |
| 132 if (alpha != NULL) { | 140 if (alpha != NULL) { |
| 133 for (j = 0; j < mb_h; ++j) { | 141 for (j = 0; j < mb_h; ++j) { |
| 134 memcpy(dst, alpha, mb_w * sizeof(*dst)); | 142 memcpy(dst, alpha, mb_w * sizeof(*dst)); |
| 135 alpha += io->width; | 143 alpha += io->width; |
| 136 dst += buf->a_stride; | 144 dst += buf->a_stride; |
| 137 } | 145 } |
| 138 } else if (buf->a != NULL) { | 146 } else if (buf->a != NULL) { |
| 139 // the user requested alpha, but there is none, set it to opaque. | 147 // the user requested alpha, but there is none, set it to opaque. |
| 140 for (j = 0; j < mb_h; ++j) { | 148 FillAlphaPlane(dst, mb_w, mb_h, buf->a_stride); |
| 141 memset(dst, 0xff, mb_w * sizeof(*dst)); | |
| 142 dst += buf->a_stride; | |
| 143 } | |
| 144 } | 149 } |
| 145 return 0; | 150 return 0; |
| 146 } | 151 } |
| 147 | 152 |
| 148 static int GetAlphaSourceRow(const VP8Io* const io, | 153 static int GetAlphaSourceRow(const VP8Io* const io, |
| 149 const uint8_t** alpha, int* const num_rows) { | 154 const uint8_t** alpha, int* const num_rows) { |
| 150 int start_y = io->mb_y; | 155 int start_y = io->mb_y; |
| 151 *num_rows = io->mb_h; | 156 *num_rows = io->mb_h; |
| 152 | 157 |
| 153 // Compensate for the 1-line delay of the fancy upscaler. | 158 // Compensate for the 1-line delay of the fancy upscaler. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 io->a, io->width, io->mb_w, mb_h, 0); | 267 io->a, io->width, io->mb_w, mb_h, 0); |
| 263 } | 268 } |
| 264 num_lines_out = Rescale(io->y, io->y_stride, mb_h, scaler); | 269 num_lines_out = Rescale(io->y, io->y_stride, mb_h, scaler); |
| 265 Rescale(io->u, io->uv_stride, uv_mb_h, &p->scaler_u); | 270 Rescale(io->u, io->uv_stride, uv_mb_h, &p->scaler_u); |
| 266 Rescale(io->v, io->uv_stride, uv_mb_h, &p->scaler_v); | 271 Rescale(io->v, io->uv_stride, uv_mb_h, &p->scaler_v); |
| 267 return num_lines_out; | 272 return num_lines_out; |
| 268 } | 273 } |
| 269 | 274 |
| 270 static int EmitRescaledAlphaYUV(const VP8Io* const io, WebPDecParams* const p, | 275 static int EmitRescaledAlphaYUV(const VP8Io* const io, WebPDecParams* const p, |
| 271 int expected_num_lines_out) { | 276 int expected_num_lines_out) { |
| 277 const WebPYUVABuffer* const buf = &p->output->u.YUVA; |
| 272 if (io->a != NULL) { | 278 if (io->a != NULL) { |
| 273 const WebPYUVABuffer* const buf = &p->output->u.YUVA; | |
| 274 uint8_t* dst_y = buf->y + p->last_y * buf->y_stride; | 279 uint8_t* dst_y = buf->y + p->last_y * buf->y_stride; |
| 275 const uint8_t* src_a = buf->a + p->last_y * buf->a_stride; | 280 const uint8_t* src_a = buf->a + p->last_y * buf->a_stride; |
| 276 const int num_lines_out = Rescale(io->a, io->width, io->mb_h, &p->scaler_a); | 281 const int num_lines_out = Rescale(io->a, io->width, io->mb_h, &p->scaler_a); |
| 277 (void)expected_num_lines_out; | 282 (void)expected_num_lines_out; |
| 278 assert(expected_num_lines_out == num_lines_out); | 283 assert(expected_num_lines_out == num_lines_out); |
| 279 if (num_lines_out > 0) { // unmultiply the Y | 284 if (num_lines_out > 0) { // unmultiply the Y |
| 280 WebPMultRows(dst_y, buf->y_stride, src_a, buf->a_stride, | 285 WebPMultRows(dst_y, buf->y_stride, src_a, buf->a_stride, |
| 281 p->scaler_a.dst_width, num_lines_out, 1); | 286 p->scaler_a.dst_width, num_lines_out, 1); |
| 282 } | 287 } |
| 288 } else if (buf->a != NULL) { |
| 289 // the user requested alpha, but there is none, set it to opaque. |
| 290 assert(p->last_y + expected_num_lines_out <= io->scaled_height); |
| 291 FillAlphaPlane(buf->a + p->last_y * buf->a_stride, |
| 292 io->scaled_width, expected_num_lines_out, buf->a_stride); |
| 283 } | 293 } |
| 284 return 0; | 294 return 0; |
| 285 } | 295 } |
| 286 | 296 |
| 287 static int InitYUVRescaler(const VP8Io* const io, WebPDecParams* const p) { | 297 static int InitYUVRescaler(const VP8Io* const io, WebPDecParams* const p) { |
| 288 const int has_alpha = WebPIsAlphaMode(p->output->colorspace); | 298 const int has_alpha = WebPIsAlphaMode(p->output->colorspace); |
| 289 const WebPYUVABuffer* const buf = &p->output->u.YUVA; | 299 const WebPYUVABuffer* const buf = &p->output->u.YUVA; |
| 290 const int out_width = io->scaled_width; | 300 const int out_width = io->scaled_width; |
| 291 const int out_height = io->scaled_height; | 301 const int out_height = io->scaled_height; |
| 292 const int uv_out_width = (out_width + 1) >> 1; | 302 const int uv_out_width = (out_width + 1) >> 1; |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 // Main entry point | 615 // Main entry point |
| 606 | 616 |
| 607 void WebPInitCustomIo(WebPDecParams* const params, VP8Io* const io) { | 617 void WebPInitCustomIo(WebPDecParams* const params, VP8Io* const io) { |
| 608 io->put = CustomPut; | 618 io->put = CustomPut; |
| 609 io->setup = CustomSetup; | 619 io->setup = CustomSetup; |
| 610 io->teardown = CustomTeardown; | 620 io->teardown = CustomTeardown; |
| 611 io->opaque = params; | 621 io->opaque = params; |
| 612 } | 622 } |
| 613 | 623 |
| 614 //------------------------------------------------------------------------------ | 624 //------------------------------------------------------------------------------ |
| OLD | NEW |