| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. | 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 dest->y, dest->y_stride, | 79 dest->y, dest->y_stride, |
| 80 dest->u, dest->u_stride, | 80 dest->u, dest->u_stride, |
| 81 dest->v, dest->v_stride, | 81 dest->v, dest->v_stride, |
| 82 dest->w, rows); | 82 dest->w, rows); |
| 83 dest->y += rows * dest->y_stride; | 83 dest->y += rows * dest->y_stride; |
| 84 dest->u += ((rows + 1) >> 1) * dest->u_stride; | 84 dest->u += ((rows + 1) >> 1) * dest->u_stride; |
| 85 dest->v += ((rows + 1) >> 1) * dest->v_stride; | 85 dest->v += ((rows + 1) >> 1) * dest->v_stride; |
| 86 dest->h -= rows; | 86 dest->h -= rows; |
| 87 } | 87 } |
| 88 | 88 |
| 89 static void JpegI411ToI420(void* opaque, | |
| 90 const uint8* const* data, | |
| 91 const int* strides, | |
| 92 int rows) { | |
| 93 I420Buffers* dest = (I420Buffers*)(opaque); | |
| 94 I411ToI420(data[0], strides[0], | |
| 95 data[1], strides[1], | |
| 96 data[2], strides[2], | |
| 97 dest->y, dest->y_stride, | |
| 98 dest->u, dest->u_stride, | |
| 99 dest->v, dest->v_stride, | |
| 100 dest->w, rows); | |
| 101 dest->y += rows * dest->y_stride; | |
| 102 dest->u += ((rows + 1) >> 1) * dest->u_stride; | |
| 103 dest->v += ((rows + 1) >> 1) * dest->v_stride; | |
| 104 dest->h -= rows; | |
| 105 } | |
| 106 | |
| 107 static void JpegI400ToI420(void* opaque, | 89 static void JpegI400ToI420(void* opaque, |
| 108 const uint8* const* data, | 90 const uint8* const* data, |
| 109 const int* strides, | 91 const int* strides, |
| 110 int rows) { | 92 int rows) { |
| 111 I420Buffers* dest = (I420Buffers*)(opaque); | 93 I420Buffers* dest = (I420Buffers*)(opaque); |
| 112 I400ToI420(data[0], strides[0], | 94 I400ToI420(data[0], strides[0], |
| 113 dest->y, dest->y_stride, | 95 dest->y, dest->y_stride, |
| 114 dest->u, dest->u_stride, | 96 dest->u, dest->u_stride, |
| 115 dest->v, dest->v_stride, | 97 dest->v, dest->v_stride, |
| 116 dest->w, rows); | 98 dest->w, rows); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } else if (mjpeg_decoder.GetColorSpace() == | 168 } else if (mjpeg_decoder.GetColorSpace() == |
| 187 MJpegDecoder::kColorSpaceYCbCr && | 169 MJpegDecoder::kColorSpaceYCbCr && |
| 188 mjpeg_decoder.GetNumComponents() == 3 && | 170 mjpeg_decoder.GetNumComponents() == 3 && |
| 189 mjpeg_decoder.GetVertSampFactor(0) == 1 && | 171 mjpeg_decoder.GetVertSampFactor(0) == 1 && |
| 190 mjpeg_decoder.GetHorizSampFactor(0) == 1 && | 172 mjpeg_decoder.GetHorizSampFactor(0) == 1 && |
| 191 mjpeg_decoder.GetVertSampFactor(1) == 1 && | 173 mjpeg_decoder.GetVertSampFactor(1) == 1 && |
| 192 mjpeg_decoder.GetHorizSampFactor(1) == 1 && | 174 mjpeg_decoder.GetHorizSampFactor(1) == 1 && |
| 193 mjpeg_decoder.GetVertSampFactor(2) == 1 && | 175 mjpeg_decoder.GetVertSampFactor(2) == 1 && |
| 194 mjpeg_decoder.GetHorizSampFactor(2) == 1) { | 176 mjpeg_decoder.GetHorizSampFactor(2) == 1) { |
| 195 ret = mjpeg_decoder.DecodeToCallback(&JpegI444ToI420, &bufs, dw, dh); | 177 ret = mjpeg_decoder.DecodeToCallback(&JpegI444ToI420, &bufs, dw, dh); |
| 196 // YUV411 | |
| 197 } else if (mjpeg_decoder.GetColorSpace() == | |
| 198 MJpegDecoder::kColorSpaceYCbCr && | |
| 199 mjpeg_decoder.GetNumComponents() == 3 && | |
| 200 mjpeg_decoder.GetVertSampFactor(0) == 1 && | |
| 201 mjpeg_decoder.GetHorizSampFactor(0) == 4 && | |
| 202 mjpeg_decoder.GetVertSampFactor(1) == 1 && | |
| 203 mjpeg_decoder.GetHorizSampFactor(1) == 1 && | |
| 204 mjpeg_decoder.GetVertSampFactor(2) == 1 && | |
| 205 mjpeg_decoder.GetHorizSampFactor(2) == 1) { | |
| 206 ret = mjpeg_decoder.DecodeToCallback(&JpegI411ToI420, &bufs, dw, dh); | |
| 207 // YUV400 | 178 // YUV400 |
| 208 } else if (mjpeg_decoder.GetColorSpace() == | 179 } else if (mjpeg_decoder.GetColorSpace() == |
| 209 MJpegDecoder::kColorSpaceGrayscale && | 180 MJpegDecoder::kColorSpaceGrayscale && |
| 210 mjpeg_decoder.GetNumComponents() == 1 && | 181 mjpeg_decoder.GetNumComponents() == 1 && |
| 211 mjpeg_decoder.GetVertSampFactor(0) == 1 && | 182 mjpeg_decoder.GetVertSampFactor(0) == 1 && |
| 212 mjpeg_decoder.GetHorizSampFactor(0) == 1) { | 183 mjpeg_decoder.GetHorizSampFactor(0) == 1) { |
| 213 ret = mjpeg_decoder.DecodeToCallback(&JpegI400ToI420, &bufs, dw, dh); | 184 ret = mjpeg_decoder.DecodeToCallback(&JpegI400ToI420, &bufs, dw, dh); |
| 214 } else { | 185 } else { |
| 215 // TODO(fbarchard): Implement conversion for any other colorspace/sample | 186 // TODO(fbarchard): Implement conversion for any other colorspace/sample |
| 216 // factors that occur in practice. 411 is supported by libjpeg | 187 // factors that occur in practice. |
| 217 // ERROR: Unable to convert MJPEG frame because format is not supported | 188 // ERROR: Unable to convert MJPEG frame because format is not supported |
| 218 mjpeg_decoder.UnloadFrame(); | 189 mjpeg_decoder.UnloadFrame(); |
| 219 return 1; | 190 return 1; |
| 220 } | 191 } |
| 221 } | 192 } |
| 222 return ret ? 0 : 1; | 193 return ret ? 0 : 1; |
| 223 } | 194 } |
| 224 | 195 |
| 225 #ifdef HAVE_JPEG | 196 #ifdef HAVE_JPEG |
| 226 struct ARGBBuffers { | 197 struct ARGBBuffers { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 ARGBBuffers* dest = (ARGBBuffers*)(opaque); | 236 ARGBBuffers* dest = (ARGBBuffers*)(opaque); |
| 266 I444ToARGB(data[0], strides[0], | 237 I444ToARGB(data[0], strides[0], |
| 267 data[1], strides[1], | 238 data[1], strides[1], |
| 268 data[2], strides[2], | 239 data[2], strides[2], |
| 269 dest->argb, dest->argb_stride, | 240 dest->argb, dest->argb_stride, |
| 270 dest->w, rows); | 241 dest->w, rows); |
| 271 dest->argb += rows * dest->argb_stride; | 242 dest->argb += rows * dest->argb_stride; |
| 272 dest->h -= rows; | 243 dest->h -= rows; |
| 273 } | 244 } |
| 274 | 245 |
| 275 static void JpegI411ToARGB(void* opaque, | |
| 276 const uint8* const* data, | |
| 277 const int* strides, | |
| 278 int rows) { | |
| 279 ARGBBuffers* dest = (ARGBBuffers*)(opaque); | |
| 280 I411ToARGB(data[0], strides[0], | |
| 281 data[1], strides[1], | |
| 282 data[2], strides[2], | |
| 283 dest->argb, dest->argb_stride, | |
| 284 dest->w, rows); | |
| 285 dest->argb += rows * dest->argb_stride; | |
| 286 dest->h -= rows; | |
| 287 } | |
| 288 | |
| 289 static void JpegI400ToARGB(void* opaque, | 246 static void JpegI400ToARGB(void* opaque, |
| 290 const uint8* const* data, | 247 const uint8* const* data, |
| 291 const int* strides, | 248 const int* strides, |
| 292 int rows) { | 249 int rows) { |
| 293 ARGBBuffers* dest = (ARGBBuffers*)(opaque); | 250 ARGBBuffers* dest = (ARGBBuffers*)(opaque); |
| 294 I400ToARGB(data[0], strides[0], | 251 I400ToARGB(data[0], strides[0], |
| 295 dest->argb, dest->argb_stride, | 252 dest->argb, dest->argb_stride, |
| 296 dest->w, rows); | 253 dest->w, rows); |
| 297 dest->argb += rows * dest->argb_stride; | 254 dest->argb += rows * dest->argb_stride; |
| 298 dest->h -= rows; | 255 dest->h -= rows; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 } else if (mjpeg_decoder.GetColorSpace() == | 305 } else if (mjpeg_decoder.GetColorSpace() == |
| 349 MJpegDecoder::kColorSpaceYCbCr && | 306 MJpegDecoder::kColorSpaceYCbCr && |
| 350 mjpeg_decoder.GetNumComponents() == 3 && | 307 mjpeg_decoder.GetNumComponents() == 3 && |
| 351 mjpeg_decoder.GetVertSampFactor(0) == 1 && | 308 mjpeg_decoder.GetVertSampFactor(0) == 1 && |
| 352 mjpeg_decoder.GetHorizSampFactor(0) == 1 && | 309 mjpeg_decoder.GetHorizSampFactor(0) == 1 && |
| 353 mjpeg_decoder.GetVertSampFactor(1) == 1 && | 310 mjpeg_decoder.GetVertSampFactor(1) == 1 && |
| 354 mjpeg_decoder.GetHorizSampFactor(1) == 1 && | 311 mjpeg_decoder.GetHorizSampFactor(1) == 1 && |
| 355 mjpeg_decoder.GetVertSampFactor(2) == 1 && | 312 mjpeg_decoder.GetVertSampFactor(2) == 1 && |
| 356 mjpeg_decoder.GetHorizSampFactor(2) == 1) { | 313 mjpeg_decoder.GetHorizSampFactor(2) == 1) { |
| 357 ret = mjpeg_decoder.DecodeToCallback(&JpegI444ToARGB, &bufs, dw, dh); | 314 ret = mjpeg_decoder.DecodeToCallback(&JpegI444ToARGB, &bufs, dw, dh); |
| 358 // YUV411 | |
| 359 } else if (mjpeg_decoder.GetColorSpace() == | |
| 360 MJpegDecoder::kColorSpaceYCbCr && | |
| 361 mjpeg_decoder.GetNumComponents() == 3 && | |
| 362 mjpeg_decoder.GetVertSampFactor(0) == 1 && | |
| 363 mjpeg_decoder.GetHorizSampFactor(0) == 4 && | |
| 364 mjpeg_decoder.GetVertSampFactor(1) == 1 && | |
| 365 mjpeg_decoder.GetHorizSampFactor(1) == 1 && | |
| 366 mjpeg_decoder.GetVertSampFactor(2) == 1 && | |
| 367 mjpeg_decoder.GetHorizSampFactor(2) == 1) { | |
| 368 ret = mjpeg_decoder.DecodeToCallback(&JpegI411ToARGB, &bufs, dw, dh); | |
| 369 // YUV400 | 315 // YUV400 |
| 370 } else if (mjpeg_decoder.GetColorSpace() == | 316 } else if (mjpeg_decoder.GetColorSpace() == |
| 371 MJpegDecoder::kColorSpaceGrayscale && | 317 MJpegDecoder::kColorSpaceGrayscale && |
| 372 mjpeg_decoder.GetNumComponents() == 1 && | 318 mjpeg_decoder.GetNumComponents() == 1 && |
| 373 mjpeg_decoder.GetVertSampFactor(0) == 1 && | 319 mjpeg_decoder.GetVertSampFactor(0) == 1 && |
| 374 mjpeg_decoder.GetHorizSampFactor(0) == 1) { | 320 mjpeg_decoder.GetHorizSampFactor(0) == 1) { |
| 375 ret = mjpeg_decoder.DecodeToCallback(&JpegI400ToARGB, &bufs, dw, dh); | 321 ret = mjpeg_decoder.DecodeToCallback(&JpegI400ToARGB, &bufs, dw, dh); |
| 376 } else { | 322 } else { |
| 377 // TODO(fbarchard): Implement conversion for any other colorspace/sample | 323 // TODO(fbarchard): Implement conversion for any other colorspace/sample |
| 378 // factors that occur in practice. 411 is supported by libjpeg | 324 // factors that occur in practice. |
| 379 // ERROR: Unable to convert MJPEG frame because format is not supported | 325 // ERROR: Unable to convert MJPEG frame because format is not supported |
| 380 mjpeg_decoder.UnloadFrame(); | 326 mjpeg_decoder.UnloadFrame(); |
| 381 return 1; | 327 return 1; |
| 382 } | 328 } |
| 383 } | 329 } |
| 384 return ret ? 0 : 1; | 330 return ret ? 0 : 1; |
| 385 } | 331 } |
| 386 #endif | 332 #endif |
| 387 | 333 |
| 388 #endif | 334 #endif |
| 389 | 335 |
| 390 #ifdef __cplusplus | 336 #ifdef __cplusplus |
| 391 } // extern "C" | 337 } // extern "C" |
| 392 } // namespace libyuv | 338 } // namespace libyuv |
| 393 #endif | 339 #endif |
| OLD | NEW |