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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 200 |
201 if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, info.frame_width, | 201 if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, info.frame_width, |
202 info.frame_height, 1)) { | 202 info.frame_height, 1)) { |
203 die("Failed to allocate image."); | 203 die("Failed to allocate image."); |
204 } | 204 } |
205 | 205 |
206 keyframe_interval = strtol(keyframe_interval_arg, NULL, 0); | 206 keyframe_interval = strtol(keyframe_interval_arg, NULL, 0); |
207 if (keyframe_interval < 0) | 207 if (keyframe_interval < 0) |
208 die("Invalid keyframe interval value."); | 208 die("Invalid keyframe interval value."); |
209 | 209 |
210 printf("Using %s\n", vpx_codec_iface_name(encoder->interface())); | 210 printf("Using %s\n", vpx_codec_iface_name(encoder->codec_interface())); |
211 | 211 |
212 res = vpx_codec_enc_config_default(encoder->interface(), &cfg, 0); | 212 res = vpx_codec_enc_config_default(encoder->codec_interface(), &cfg, 0); |
213 if (res) | 213 if (res) |
214 die_codec(&codec, "Failed to get default codec config."); | 214 die_codec(&codec, "Failed to get default codec config."); |
215 | 215 |
216 cfg.g_w = info.frame_width; | 216 cfg.g_w = info.frame_width; |
217 cfg.g_h = info.frame_height; | 217 cfg.g_h = info.frame_height; |
218 cfg.g_timebase.num = info.time_base.numerator; | 218 cfg.g_timebase.num = info.time_base.numerator; |
219 cfg.g_timebase.den = info.time_base.denominator; | 219 cfg.g_timebase.den = info.time_base.denominator; |
220 cfg.rc_target_bitrate = bitrate; | 220 cfg.rc_target_bitrate = bitrate; |
221 cfg.g_error_resilient = argc > 7 ? strtol(argv[7], NULL, 0) : 0; | 221 cfg.g_error_resilient = argc > 7 ? strtol(argv[7], NULL, 0) : 0; |
222 | 222 |
223 writer = vpx_video_writer_open(outfile_arg, kContainerIVF, &info); | 223 writer = vpx_video_writer_open(outfile_arg, kContainerIVF, &info); |
224 if (!writer) | 224 if (!writer) |
225 die("Failed to open %s for writing.", outfile_arg); | 225 die("Failed to open %s for writing.", outfile_arg); |
226 | 226 |
227 if (!(infile = fopen(infile_arg, "rb"))) | 227 if (!(infile = fopen(infile_arg, "rb"))) |
228 die("Failed to open %s for reading.", infile_arg); | 228 die("Failed to open %s for reading.", infile_arg); |
229 | 229 |
230 if (vpx_codec_enc_init(&codec, encoder->interface(), &cfg, 0)) | 230 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0)) |
231 die_codec(&codec, "Failed to initialize encoder"); | 231 die_codec(&codec, "Failed to initialize encoder"); |
232 | 232 |
233 while (vpx_img_read(&raw, infile)) { | 233 while (vpx_img_read(&raw, infile)) { |
234 int flags = 0; | 234 int flags = 0; |
235 if (keyframe_interval > 0 && frame_count % keyframe_interval == 0) | 235 if (keyframe_interval > 0 && frame_count % keyframe_interval == 0) |
236 flags |= VPX_EFLAG_FORCE_KF; | 236 flags |= VPX_EFLAG_FORCE_KF; |
237 encode_frame(&codec, &raw, frame_count++, flags, writer); | 237 encode_frame(&codec, &raw, frame_count++, flags, writer); |
238 } | 238 } |
239 encode_frame(&codec, NULL, -1, 0, writer); // flush the encoder | 239 encode_frame(&codec, NULL, -1, 0, writer); // flush the encoder |
240 | 240 |
241 printf("\n"); | 241 printf("\n"); |
242 fclose(infile); | 242 fclose(infile); |
243 printf("Processed %d frames.\n", frame_count); | 243 printf("Processed %d frames.\n", frame_count); |
244 | 244 |
245 vpx_img_free(&raw); | 245 vpx_img_free(&raw); |
246 if (vpx_codec_destroy(&codec)) | 246 if (vpx_codec_destroy(&codec)) |
247 die_codec(&codec, "Failed to destroy codec."); | 247 die_codec(&codec, "Failed to destroy codec."); |
248 | 248 |
249 vpx_video_writer_close(writer); | 249 vpx_video_writer_close(writer); |
250 | 250 |
251 return EXIT_SUCCESS; | 251 return EXIT_SUCCESS; |
252 } | 252 } |
OLD | NEW |