Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: source/libvpx/tools_common.c

Issue 394353005: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/tools_common.h ('k') | source/libvpx/vp8/common/arm/neon/bilinearpredict_neon.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 87
87 for (plane = 0; plane < 3; ++plane) { 88 for (plane = 0; plane < 3; ++plane) {
88 uint8_t *ptr; 89 uint8_t *ptr;
89 const int w = (plane ? (1 + yuv_frame->d_w) / 2 : yuv_frame->d_w); 90 const int w = vpx_img_plane_width(yuv_frame, plane);
90 const int h = (plane ? (1 + yuv_frame->d_h) / 2 : yuv_frame->d_h); 91 const int h = vpx_img_plane_height(yuv_frame, plane);
91 int r; 92 int r;
92 93
93 /* 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
94 * 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
95 * the data on disk. 96 * the data on disk.
96 */ 97 */
97 switch (plane) { 98 switch (plane) {
98 case 1: 99 case 1:
99 ptr = yuv_frame->planes[ 100 ptr = yuv_frame->planes[
100 yuv_frame->fmt == VPX_IMG_FMT_YV12 ? VPX_PLANE_V : VPX_PLANE_U]; 101 yuv_frame->fmt == VPX_IMG_FMT_YV12 ? VPX_PLANE_V : VPX_PLANE_U];
101 break; 102 break;
102 case 2: 103 case 2:
103 ptr = yuv_frame->planes[ 104 ptr = yuv_frame->planes[
104 yuv_frame->fmt == VPX_IMG_FMT_YV12 ? VPX_PLANE_U : VPX_PLANE_V]; 105 yuv_frame->fmt == VPX_IMG_FMT_YV12 ? VPX_PLANE_U : VPX_PLANE_V];
105 break; 106 break;
106 default: 107 default:
107 ptr = yuv_frame->planes[plane]; 108 ptr = yuv_frame->planes[plane];
108 } 109 }
109 110
110 for (r = 0; r < h; ++r) { 111 for (r = 0; r < h; ++r) {
111 size_t needed = w; 112 size_t needed = w * bytespp;
112 size_t buf_position = 0; 113 size_t buf_position = 0;
113 const size_t left = detect->buf_read - detect->position; 114 const size_t left = detect->buf_read - detect->position;
114 if (left > 0) { 115 if (left > 0) {
115 const size_t more = (left < needed) ? left : needed; 116 const size_t more = (left < needed) ? left : needed;
116 memcpy(ptr, detect->buf + detect->position, more); 117 memcpy(ptr, detect->buf + detect->position, more);
117 buf_position = more; 118 buf_position = more;
118 needed -= more; 119 needed -= more;
119 detect->position += more; 120 detect->position += more;
120 } 121 }
121 if (needed > 0) { 122 if (needed > 0) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 double sse_to_psnr(double samples, double peak, double sse) { 259 double sse_to_psnr(double samples, double peak, double sse) {
259 static const double kMaxPSNR = 100.0; 260 static const double kMaxPSNR = 100.0;
260 261
261 if (sse > 0.0) { 262 if (sse > 0.0) {
262 const double psnr = 10.0 * log10(samples * peak * peak / sse); 263 const double psnr = 10.0 * log10(samples * peak * peak / sse);
263 return psnr > kMaxPSNR ? kMaxPSNR : psnr; 264 return psnr > kMaxPSNR ? kMaxPSNR : psnr;
264 } else { 265 } else {
265 return kMaxPSNR; 266 return kMaxPSNR;
266 } 267 }
267 } 268 }
OLDNEW
« no previous file with comments | « source/libvpx/tools_common.h ('k') | source/libvpx/vp8/common/arm/neon/bilinearpredict_neon.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698