OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC 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 <stdio.h> | 11 #include <stdio.h> |
12 #include <stdlib.h> | 12 #include <stdlib.h> |
13 | 13 |
| 14 #include <memory> |
14 #include <string> | 15 #include <string> |
15 | 16 |
16 #include "webrtc/base/scoped_ptr.h" | |
17 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 17 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
18 #include "webrtc/tools/frame_editing/frame_editing_lib.h" | 18 #include "webrtc/tools/frame_editing/frame_editing_lib.h" |
19 #include "webrtc/typedefs.h" | 19 #include "webrtc/typedefs.h" |
20 | 20 |
21 using std::string; | 21 using std::string; |
22 | 22 |
23 namespace webrtc { | 23 namespace webrtc { |
24 | 24 |
25 int EditFrames(const string& in_path, int width, int height, | 25 int EditFrames(const string& in_path, int width, int height, |
26 int first_frame_to_process, int interval, | 26 int first_frame_to_process, int interval, |
27 int last_frame_to_process, const string& out_path) { | 27 int last_frame_to_process, const string& out_path) { |
28 if (last_frame_to_process < first_frame_to_process) { | 28 if (last_frame_to_process < first_frame_to_process) { |
29 fprintf(stderr, "The set of frames to cut is empty! (l < f)\n"); | 29 fprintf(stderr, "The set of frames to cut is empty! (l < f)\n"); |
30 return -10; | 30 return -10; |
31 } | 31 } |
32 | 32 |
33 FILE* in_fid = fopen(in_path.c_str() , "rb"); | 33 FILE* in_fid = fopen(in_path.c_str() , "rb"); |
34 if (!in_fid) { | 34 if (!in_fid) { |
35 fprintf(stderr, "Could not read input file: %s.\n", in_path.c_str()); | 35 fprintf(stderr, "Could not read input file: %s.\n", in_path.c_str()); |
36 return -11; | 36 return -11; |
37 } | 37 } |
38 | 38 |
39 // Frame size of I420. | 39 // Frame size of I420. |
40 size_t frame_length = CalcBufferSize(kI420, width, height); | 40 size_t frame_length = CalcBufferSize(kI420, width, height); |
41 | 41 |
42 rtc::scoped_ptr<uint8_t[]> temp_buffer(new uint8_t[frame_length]); | 42 std::unique_ptr<uint8_t[]> temp_buffer(new uint8_t[frame_length]); |
43 | 43 |
44 FILE* out_fid = fopen(out_path.c_str(), "wb"); | 44 FILE* out_fid = fopen(out_path.c_str(), "wb"); |
45 | 45 |
46 if (!out_fid) { | 46 if (!out_fid) { |
47 fprintf(stderr, "Could not open output file: %s.\n", out_path.c_str()); | 47 fprintf(stderr, "Could not open output file: %s.\n", out_path.c_str()); |
48 fclose(in_fid); | 48 fclose(in_fid); |
49 return -12; | 49 return -12; |
50 } | 50 } |
51 | 51 |
52 int num_frames_read = 0; | 52 int num_frames_read = 0; |
(...skipping 27 matching lines...) Expand all Loading... |
80 if (num_bytes_read > 0 && num_bytes_read < frame_length) { | 80 if (num_bytes_read > 0 && num_bytes_read < frame_length) { |
81 printf("Frame to small! Last frame truncated.\n"); | 81 printf("Frame to small! Last frame truncated.\n"); |
82 } | 82 } |
83 fclose(in_fid); | 83 fclose(in_fid); |
84 fclose(out_fid); | 84 fclose(out_fid); |
85 | 85 |
86 printf("Done editing!\n"); | 86 printf("Done editing!\n"); |
87 return 0; | 87 return 0; |
88 } | 88 } |
89 } // namespace webrtc | 89 } // namespace webrtc |
OLD | NEW |