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

Side by Side Diff: source/libvpx/examples/twopass_encoder.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/examples/simple_encoder.c ('k') | source/libvpx/examples/vp8cx_set_ref.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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, info.frame_width, 162 if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, info.frame_width,
163 info.frame_height, 1)) { 163 info.frame_height, 1)) {
164 die("Failed to allocate image", info.frame_width, info.frame_height); 164 die("Failed to allocate image", info.frame_width, info.frame_height);
165 } 165 }
166 166
167 writer = vpx_video_writer_open(outfile_arg, kContainerIVF, &info); 167 writer = vpx_video_writer_open(outfile_arg, kContainerIVF, &info);
168 if (!writer) 168 if (!writer)
169 die("Failed to open %s for writing", outfile_arg); 169 die("Failed to open %s for writing", outfile_arg);
170 170
171 printf("Using %s\n", vpx_codec_iface_name(encoder->interface())); 171 printf("Using %s\n", vpx_codec_iface_name(encoder->codec_interface()));
172 172
173 res = vpx_codec_enc_config_default(encoder->interface(), &cfg, 0); 173 res = vpx_codec_enc_config_default(encoder->codec_interface(), &cfg, 0);
174 if (res) 174 if (res)
175 die_codec(&codec, "Failed to get default codec config."); 175 die_codec(&codec, "Failed to get default codec config.");
176 176
177 cfg.g_w = info.frame_width; 177 cfg.g_w = info.frame_width;
178 cfg.g_h = info.frame_height; 178 cfg.g_h = info.frame_height;
179 cfg.g_timebase.num = info.time_base.numerator; 179 cfg.g_timebase.num = info.time_base.numerator;
180 cfg.g_timebase.den = info.time_base.denominator; 180 cfg.g_timebase.den = info.time_base.denominator;
181 cfg.rc_target_bitrate = bitrate; 181 cfg.rc_target_bitrate = bitrate;
182 182
183 for (pass = 0; pass < 2; ++pass) { 183 for (pass = 0; pass < 2; ++pass) {
184 int frame_count = 0; 184 int frame_count = 0;
185 185
186 if (pass == 0) { 186 if (pass == 0) {
187 cfg.g_pass = VPX_RC_FIRST_PASS; 187 cfg.g_pass = VPX_RC_FIRST_PASS;
188 } else { 188 } else {
189 cfg.g_pass = VPX_RC_LAST_PASS; 189 cfg.g_pass = VPX_RC_LAST_PASS;
190 cfg.rc_twopass_stats_in = stats; 190 cfg.rc_twopass_stats_in = stats;
191 } 191 }
192 192
193 if (!(infile = fopen(infile_arg, "rb"))) 193 if (!(infile = fopen(infile_arg, "rb")))
194 die("Failed to open %s for reading", infile_arg); 194 die("Failed to open %s for reading", infile_arg);
195 195
196 if (vpx_codec_enc_init(&codec, encoder->interface(), &cfg, 0)) 196 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
197 die_codec(&codec, "Failed to initialize encoder"); 197 die_codec(&codec, "Failed to initialize encoder");
198 198
199 while (vpx_img_read(&raw, infile)) { 199 while (vpx_img_read(&raw, infile)) {
200 ++frame_count; 200 ++frame_count;
201 201
202 if (pass == 0) { 202 if (pass == 0) {
203 get_frame_stats(&codec, &raw, frame_count, 1, 0, VPX_DL_BEST_QUALITY, 203 get_frame_stats(&codec, &raw, frame_count, 1, 0, VPX_DL_BEST_QUALITY,
204 &stats); 204 &stats);
205 } else { 205 } else {
206 encode_frame(&codec, &raw, frame_count, 1, 0, VPX_DL_BEST_QUALITY, 206 encode_frame(&codec, &raw, frame_count, 1, 0, VPX_DL_BEST_QUALITY,
(...skipping 14 matching lines...) Expand all
221 die_codec(&codec, "Failed to destroy codec."); 221 die_codec(&codec, "Failed to destroy codec.");
222 } 222 }
223 223
224 vpx_img_free(&raw); 224 vpx_img_free(&raw);
225 free(stats.buf); 225 free(stats.buf);
226 226
227 vpx_video_writer_close(writer); 227 vpx_video_writer_close(writer);
228 228
229 return EXIT_SUCCESS; 229 return EXIT_SUCCESS;
230 } 230 }
OLDNEW
« no previous file with comments | « source/libvpx/examples/simple_encoder.c ('k') | source/libvpx/examples/vp8cx_set_ref.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698