| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |