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

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

Issue 11974002: libvpx: Pull from upstream (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 11 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/vpx_scale/yv12config.h ('k') | no next file » | 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 "vpx_config.h" 11 #include "vpx_config.h"
12 12
13 #if defined(_WIN32) || !CONFIG_OS_SUPPORT 13 #if defined(_WIN32) || !CONFIG_OS_SUPPORT
14 #define USE_POSIX_MMAP 0 14 #define USE_POSIX_MMAP 0
15 #else 15 #else
16 #define USE_POSIX_MMAP 1 16 #define USE_POSIX_MMAP 1
17 #endif 17 #endif
18 18
19 #include <stdio.h> 19 #include <stdio.h>
20 #include <stdlib.h> 20 #include <stdlib.h>
21 #include <stdarg.h> 21 #include <stdarg.h>
22 #include <string.h> 22 #include <string.h>
23 #include <limits.h> 23 #include <limits.h>
24 #include <assert.h> 24 #include <assert.h>
25 #include "vpx/vpx_encoder.h" 25 #include "vpx/vpx_encoder.h"
26 #if CONFIG_DECODERS
26 #include "vpx/vpx_decoder.h" 27 #include "vpx/vpx_decoder.h"
28 #endif
27 #if USE_POSIX_MMAP 29 #if USE_POSIX_MMAP
28 #include <sys/types.h> 30 #include <sys/types.h>
29 #include <sys/stat.h> 31 #include <sys/stat.h>
30 #include <sys/mman.h> 32 #include <sys/mman.h>
31 #include <fcntl.h> 33 #include <fcntl.h>
32 #include <unistd.h> 34 #include <unistd.h>
33 #endif 35 #endif
34 36
35 #if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER 37 #if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER
36 #include "vpx/vp8cx.h" 38 #include "vpx/vp8cx.h"
(...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2167 for (i = 0; i < stream->config.arg_ctrl_cnt; i++) { 2169 for (i = 0; i < stream->config.arg_ctrl_cnt; i++) {
2168 int ctrl = stream->config.arg_ctrls[i][0]; 2170 int ctrl = stream->config.arg_ctrls[i][0];
2169 int value = stream->config.arg_ctrls[i][1]; 2171 int value = stream->config.arg_ctrls[i][1];
2170 if (vpx_codec_control_(&stream->encoder, ctrl, value)) 2172 if (vpx_codec_control_(&stream->encoder, ctrl, value))
2171 fprintf(stderr, "Error: Tried to set control %d = %d\n", 2173 fprintf(stderr, "Error: Tried to set control %d = %d\n",
2172 ctrl, value); 2174 ctrl, value);
2173 2175
2174 ctx_exit_on_error(&stream->encoder, "Failed to control codec"); 2176 ctx_exit_on_error(&stream->encoder, "Failed to control codec");
2175 } 2177 }
2176 2178
2179 #if CONFIG_DECODERS
2177 if (global->test_decode) { 2180 if (global->test_decode) {
2178 int width, height; 2181 int width, height;
2179 2182
2180 vpx_codec_dec_init(&stream->decoder, global->codec->dx_iface(), NULL, 0); 2183 vpx_codec_dec_init(&stream->decoder, global->codec->dx_iface(), NULL, 0);
2181 2184
2182 width = (stream->config.cfg.g_w + 15) & ~15; 2185 width = (stream->config.cfg.g_w + 15) & ~15;
2183 height = (stream->config.cfg.g_h + 15) & ~15; 2186 height = (stream->config.cfg.g_h + 15) & ~15;
2184 vpx_img_alloc(&stream->ref_enc.img, VPX_IMG_FMT_I420, width, height, 1); 2187 vpx_img_alloc(&stream->ref_enc.img, VPX_IMG_FMT_I420, width, height, 1);
2185 vpx_img_alloc(&stream->ref_dec.img, VPX_IMG_FMT_I420, width, height, 1); 2188 vpx_img_alloc(&stream->ref_dec.img, VPX_IMG_FMT_I420, width, height, 1);
2186 stream->ref_enc.frame_type = VP8_LAST_FRAME; 2189 stream->ref_enc.frame_type = VP8_LAST_FRAME;
2187 stream->ref_dec.frame_type = VP8_LAST_FRAME; 2190 stream->ref_dec.frame_type = VP8_LAST_FRAME;
2188 } 2191 }
2192 #endif
2189 } 2193 }
2190 2194
2191 2195
2192 static void encode_frame(struct stream_state *stream, 2196 static void encode_frame(struct stream_state *stream,
2193 struct global_config *global, 2197 struct global_config *global,
2194 struct vpx_image *img, 2198 struct vpx_image *img,
2195 unsigned int frames_in) { 2199 unsigned int frames_in) {
2196 vpx_codec_pts_t frame_start, next_frame_start; 2200 vpx_codec_pts_t frame_start, next_frame_start;
2197 struct vpx_codec_enc_cfg *cfg = &stream->config.cfg; 2201 struct vpx_codec_enc_cfg *cfg = &stream->config.cfg;
2198 struct vpx_usec_timer timer; 2202 struct vpx_usec_timer timer;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2271 fseeko(stream->file, currpos, SEEK_SET); 2275 fseeko(stream->file, currpos, SEEK_SET);
2272 } 2276 }
2273 } 2277 }
2274 2278
2275 (void) fwrite(pkt->data.frame.buf, 1, pkt->data.frame.sz, 2279 (void) fwrite(pkt->data.frame.buf, 1, pkt->data.frame.sz,
2276 stream->file); 2280 stream->file);
2277 } 2281 }
2278 stream->nbytes += pkt->data.raw.sz; 2282 stream->nbytes += pkt->data.raw.sz;
2279 2283
2280 *got_data = 1; 2284 *got_data = 1;
2285 #if CONFIG_DECODERS
2281 if (global->test_decode) { 2286 if (global->test_decode) {
2282 vpx_codec_decode(&stream->decoder, pkt->data.frame.buf, 2287 vpx_codec_decode(&stream->decoder, pkt->data.frame.buf,
2283 pkt->data.frame.sz, NULL, 0); 2288 pkt->data.frame.sz, NULL, 0);
2284 ctx_exit_on_error(&stream->decoder, "Failed to decode frame"); 2289 ctx_exit_on_error(&stream->decoder, "Failed to decode frame");
2285 } 2290 }
2291 #endif
2286 break; 2292 break;
2287 case VPX_CODEC_STATS_PKT: 2293 case VPX_CODEC_STATS_PKT:
2288 stream->frames_out++; 2294 stream->frames_out++;
2289 fprintf(stderr, " %6luS", 2295 if (!global->quiet)
2290 (unsigned long)pkt->data.twopass_stats.sz); 2296 fprintf(stderr, " %6luS",
2297 (unsigned long)pkt->data.twopass_stats.sz);
2291 stats_write(&stream->stats, 2298 stats_write(&stream->stats,
2292 pkt->data.twopass_stats.buf, 2299 pkt->data.twopass_stats.buf,
2293 pkt->data.twopass_stats.sz); 2300 pkt->data.twopass_stats.sz);
2294 stream->nbytes += pkt->data.raw.sz; 2301 stream->nbytes += pkt->data.raw.sz;
2295 break; 2302 break;
2296 case VPX_CODEC_PSNR_PKT: 2303 case VPX_CODEC_PSNR_PKT:
2297 2304
2298 if (global->show_psnr) { 2305 if (global->show_psnr) {
2299 int i; 2306 int i;
2300 2307
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 } 2601 }
2595 fclose(f); 2602 fclose(f);
2596 }); 2603 });
2597 #endif 2604 #endif
2598 2605
2599 vpx_img_free(&raw); 2606 vpx_img_free(&raw);
2600 free(argv); 2607 free(argv);
2601 free(streams); 2608 free(streams);
2602 return EXIT_SUCCESS; 2609 return EXIT_SUCCESS;
2603 } 2610 }
OLDNEW
« no previous file with comments | « source/libvpx/vpx_scale/yv12config.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698