| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 if (detail) | 76 if (detail) |
| 77 printf(" %s\n", detail); | 77 printf(" %s\n", detail); |
| 78 exit(EXIT_FAILURE); | 78 exit(EXIT_FAILURE); |
| 79 } | 79 } |
| 80 | 80 |
| 81 int read_yuv_frame(struct VpxInputContext *input_ctx, vpx_image_t *yuv_frame) { | 81 int read_yuv_frame(struct VpxInputContext *input_ctx, vpx_image_t *yuv_frame) { |
| 82 FILE *f = input_ctx->file; | 82 FILE *f = input_ctx->file; |
| 83 struct FileTypeDetectionBuffer *detect = &input_ctx->detect; | 83 struct FileTypeDetectionBuffer *detect = &input_ctx->detect; |
| 84 int plane = 0; | 84 int plane = 0; |
| 85 int shortread = 0; | 85 int shortread = 0; |
| 86 const int bytespp = (yuv_frame->fmt & VPX_IMG_FMT_HIGH) ? 2 : 1; | 86 const int bytespp = (yuv_frame->fmt & VPX_IMG_FMT_HIGHBITDEPTH) ? 2 : 1; |
| 87 | 87 |
| 88 for (plane = 0; plane < 3; ++plane) { | 88 for (plane = 0; plane < 3; ++plane) { |
| 89 uint8_t *ptr; | 89 uint8_t *ptr; |
| 90 const int w = vpx_img_plane_width(yuv_frame, plane); | 90 const int w = vpx_img_plane_width(yuv_frame, plane); |
| 91 const int h = vpx_img_plane_height(yuv_frame, plane); | 91 const int h = vpx_img_plane_height(yuv_frame, plane); |
| 92 int r; | 92 int r; |
| 93 | 93 |
| 94 /* Determine the correct plane based on the image format. The for-loop | 94 /* Determine the correct plane based on the image format. The for-loop |
| 95 * always counts in Y,U,V order, but this may not match the order of | 95 * always counts in Y,U,V order, but this may not match the order of |
| 96 * the data on disk. | 96 * the data on disk. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 } | 236 } |
| 237 | 237 |
| 238 int vpx_img_read(vpx_image_t *img, FILE *file) { | 238 int vpx_img_read(vpx_image_t *img, FILE *file) { |
| 239 int plane; | 239 int plane; |
| 240 | 240 |
| 241 for (plane = 0; plane < 3; ++plane) { | 241 for (plane = 0; plane < 3; ++plane) { |
| 242 unsigned char *buf = img->planes[plane]; | 242 unsigned char *buf = img->planes[plane]; |
| 243 const int stride = img->stride[plane]; | 243 const int stride = img->stride[plane]; |
| 244 const int w = vpx_img_plane_width(img, plane); | 244 const int w = vpx_img_plane_width(img, plane) * |
| 245 ((img->fmt & VPX_IMG_FMT_HIGHBITDEPTH) ? 2 : 1); |
| 245 const int h = vpx_img_plane_height(img, plane); | 246 const int h = vpx_img_plane_height(img, plane); |
| 246 int y; | 247 int y; |
| 247 | 248 |
| 248 for (y = 0; y < h; ++y) { | 249 for (y = 0; y < h; ++y) { |
| 249 if (fread(buf, 1, w, file) != (size_t)w) | 250 if (fread(buf, 1, w, file) != (size_t)w) |
| 250 return 0; | 251 return 0; |
| 251 buf += stride; | 252 buf += stride; |
| 252 } | 253 } |
| 253 } | 254 } |
| 254 | 255 |
| 255 return 1; | 256 return 1; |
| 256 } | 257 } |
| 257 | 258 |
| 258 // TODO(dkovalev) change sse_to_psnr signature: double -> int64_t | 259 // TODO(dkovalev) change sse_to_psnr signature: double -> int64_t |
| 259 double sse_to_psnr(double samples, double peak, double sse) { | 260 double sse_to_psnr(double samples, double peak, double sse) { |
| 260 static const double kMaxPSNR = 100.0; | 261 static const double kMaxPSNR = 100.0; |
| 261 | 262 |
| 262 if (sse > 0.0) { | 263 if (sse > 0.0) { |
| 263 const double psnr = 10.0 * log10(samples * peak * peak / sse); | 264 const double psnr = 10.0 * log10(samples * peak * peak / sse); |
| 264 return psnr > kMaxPSNR ? kMaxPSNR : psnr; | 265 return psnr > kMaxPSNR ? kMaxPSNR : psnr; |
| 265 } else { | 266 } else { |
| 266 return kMaxPSNR; | 267 return kMaxPSNR; |
| 267 } | 268 } |
| 268 } | 269 } |
| OLD | NEW |