| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 // This is an example demonstrating how to implement a multi-layer VPx | 11 // This is an example demonstrating how to implement a multi-layer VPx |
| 12 // encoding scheme based on temporal scalability for video applications | 12 // encoding scheme based on temporal scalability for video applications |
| 13 // that benefit from a scalable bitstream. | 13 // that benefit from a scalable bitstream. |
| 14 | 14 |
| 15 #include <assert.h> | 15 #include <assert.h> |
| 16 #include <math.h> | 16 #include <math.h> |
| 17 #include <stdio.h> | 17 #include <stdio.h> |
| 18 #include <stdlib.h> | 18 #include <stdlib.h> |
| 19 #include <string.h> | 19 #include <string.h> |
| 20 | 20 |
| 21 #define VPX_CODEC_DISABLE_COMPAT 1 | |
| 22 #include "./vpx_config.h" | 21 #include "./vpx_config.h" |
| 23 #include "vpx_ports/vpx_timer.h" | 22 #include "vpx_ports/vpx_timer.h" |
| 24 #include "vpx/vp8cx.h" | 23 #include "vpx/vp8cx.h" |
| 25 #include "vpx/vpx_encoder.h" | 24 #include "vpx/vpx_encoder.h" |
| 26 | 25 |
| 27 #include "./tools_common.h" | 26 #include "./tools_common.h" |
| 28 #include "./video_writer.h" | 27 #include "./video_writer.h" |
| 29 | 28 |
| 30 static const char *exec_name; | 29 static const char *exec_name; |
| 31 | 30 |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0)) | 579 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0)) |
| 581 die_codec(&codec, "Failed to initialize encoder"); | 580 die_codec(&codec, "Failed to initialize encoder"); |
| 582 | 581 |
| 583 if (strncmp(encoder->name, "vp8", 3) == 0) { | 582 if (strncmp(encoder->name, "vp8", 3) == 0) { |
| 584 vpx_codec_control(&codec, VP8E_SET_CPUUSED, -speed); | 583 vpx_codec_control(&codec, VP8E_SET_CPUUSED, -speed); |
| 585 vpx_codec_control(&codec, VP8E_SET_NOISE_SENSITIVITY, kDenoiserOnYOnly); | 584 vpx_codec_control(&codec, VP8E_SET_NOISE_SENSITIVITY, kDenoiserOnYOnly); |
| 586 } else if (strncmp(encoder->name, "vp9", 3) == 0) { | 585 } else if (strncmp(encoder->name, "vp9", 3) == 0) { |
| 587 vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed); | 586 vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed); |
| 588 vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3); | 587 vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3); |
| 589 vpx_codec_control(&codec, VP9E_SET_FRAME_PERIODIC_BOOST, 0); | 588 vpx_codec_control(&codec, VP9E_SET_FRAME_PERIODIC_BOOST, 0); |
| 590 vpx_codec_control(&codec, VP8E_SET_NOISE_SENSITIVITY, 0); | 589 vpx_codec_control(&codec, VP9E_SET_NOISE_SENSITIVITY, 0); |
| 591 if (vpx_codec_control(&codec, VP9E_SET_SVC, 1)) { | 590 if (vpx_codec_control(&codec, VP9E_SET_SVC, 1)) { |
| 592 die_codec(&codec, "Failed to set SVC"); | 591 die_codec(&codec, "Failed to set SVC"); |
| 593 } | 592 } |
| 594 } | 593 } |
| 595 vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 1); | 594 vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 1); |
| 596 vpx_codec_control(&codec, VP8E_SET_TOKEN_PARTITIONS, 1); | 595 vpx_codec_control(&codec, VP8E_SET_TOKEN_PARTITIONS, 1); |
| 597 // This controls the maximum target size of the key frame. | 596 // This controls the maximum target size of the key frame. |
| 598 // For generating smaller key frames, use a smaller max_intra_size_pct | 597 // For generating smaller key frames, use a smaller max_intra_size_pct |
| 599 // value, like 100 or 200. | 598 // value, like 100 or 200. |
| 600 { | 599 { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 if (vpx_codec_destroy(&codec)) | 669 if (vpx_codec_destroy(&codec)) |
| 671 die_codec(&codec, "Failed to destroy codec"); | 670 die_codec(&codec, "Failed to destroy codec"); |
| 672 | 671 |
| 673 // Try to rewrite the output file headers with the actual frame count. | 672 // Try to rewrite the output file headers with the actual frame count. |
| 674 for (i = 0; i < cfg.ts_number_layers; ++i) | 673 for (i = 0; i < cfg.ts_number_layers; ++i) |
| 675 vpx_video_writer_close(outfile[i]); | 674 vpx_video_writer_close(outfile[i]); |
| 676 | 675 |
| 677 vpx_img_free(&raw); | 676 vpx_img_free(&raw); |
| 678 return EXIT_SUCCESS; | 677 return EXIT_SUCCESS; |
| 679 } | 678 } |
| OLD | NEW |