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

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

Issue 181493009: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 9 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/video_reader.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
11 #include "tools_common.h" 11 #include <math.h>
12
13 #include <stdarg.h> 12 #include <stdarg.h>
14 #include <stdio.h> 13 #include <stdio.h>
15 #include <stdlib.h> 14 #include <stdlib.h>
16 #include <string.h> 15 #include <string.h>
17 16
17 #include "./tools_common.h"
18
18 #if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER 19 #if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER
19 #include "vpx/vp8cx.h" 20 #include "vpx/vp8cx.h"
20 #endif 21 #endif
21 22
22 #if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER 23 #if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER
23 #include "vpx/vp8dx.h" 24 #include "vpx/vp8dx.h"
24 #endif 25 #endif
25 26
26 #if defined(_WIN32) || defined(__OS2__) 27 #if defined(_WIN32) || defined(__OS2__)
27 #include <io.h> 28 #include <io.h>
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 71
71 void die_codec(vpx_codec_ctx_t *ctx, const char *s) { 72 void die_codec(vpx_codec_ctx_t *ctx, const char *s) {
72 const char *detail = vpx_codec_error_detail(ctx); 73 const char *detail = vpx_codec_error_detail(ctx);
73 74
74 printf("%s: %s\n", s, vpx_codec_error(ctx)); 75 printf("%s: %s\n", s, vpx_codec_error(ctx));
75 if (detail) 76 if (detail)
76 printf(" %s\n", detail); 77 printf(" %s\n", detail);
77 exit(EXIT_FAILURE); 78 exit(EXIT_FAILURE);
78 } 79 }
79 80
80 uint16_t mem_get_le16(const void *data) {
81 uint16_t val;
82 const uint8_t *mem = (const uint8_t*)data;
83
84 val = mem[1] << 8;
85 val |= mem[0];
86 return val;
87 }
88
89 uint32_t mem_get_le32(const void *data) {
90 uint32_t val;
91 const uint8_t *mem = (const uint8_t*)data;
92
93 val = mem[3] << 24;
94 val |= mem[2] << 16;
95 val |= mem[1] << 8;
96 val |= mem[0];
97 return val;
98 }
99
100 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) {
101 FILE *f = input_ctx->file; 82 FILE *f = input_ctx->file;
102 struct FileTypeDetectionBuffer *detect = &input_ctx->detect; 83 struct FileTypeDetectionBuffer *detect = &input_ctx->detect;
103 int plane = 0; 84 int plane = 0;
104 int shortread = 0; 85 int shortread = 0;
105 86
106 for (plane = 0; plane < 3; ++plane) { 87 for (plane = 0; plane < 3; ++plane) {
107 uint8_t *ptr; 88 uint8_t *ptr;
108 const int w = (plane ? (1 + yuv_frame->d_w) / 2 : yuv_frame->d_w); 89 const int w = (plane ? (1 + yuv_frame->d_w) / 2 : yuv_frame->d_w);
109 const int h = (plane ? (1 + yuv_frame->d_h) / 2 : yuv_frame->d_h); 90 const int h = (plane ? (1 + yuv_frame->d_h) / 2 : yuv_frame->d_h);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 for (y = 0; y < h; ++y) { 247 for (y = 0; y < h; ++y) {
267 if (fread(buf, 1, w, file) != w) 248 if (fread(buf, 1, w, file) != w)
268 return 0; 249 return 0;
269 buf += stride; 250 buf += stride;
270 } 251 }
271 } 252 }
272 253
273 return 1; 254 return 1;
274 } 255 }
275 256
257 // TODO(dkovalev) change sse_to_psnr signature: double -> int64_t
258 double sse_to_psnr(double samples, double peak, double sse) {
259 static const double kMaxPSNR = 100.0;
260
261 if (sse > 0.0) {
262 const double psnr = 10.0 * log10(samples * peak * peak / sse);
263 return psnr > kMaxPSNR ? kMaxPSNR : psnr;
264 } else {
265 return kMaxPSNR;
266 }
267 }
OLDNEW
« no previous file with comments | « source/libvpx/tools_common.h ('k') | source/libvpx/video_reader.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698