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 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 20 matching lines...) Expand all Loading... |
31 : width_(width), | 31 : width_(width), |
32 height_(height) { | 32 height_(height) { |
33 } | 33 } |
34 | 34 |
35 bool Converter::ConvertRGBAToI420Video(std::string frames_dir, | 35 bool Converter::ConvertRGBAToI420Video(std::string frames_dir, |
36 std::string output_file_name, | 36 std::string output_file_name, |
37 bool delete_frames) { | 37 bool delete_frames) { |
38 FILE* output_file = fopen(output_file_name.c_str(), "wb"); | 38 FILE* output_file = fopen(output_file_name.c_str(), "wb"); |
39 | 39 |
40 // Open output file in append mode. | 40 // Open output file in append mode. |
41 if (output_file == NULL) { | 41 if (output_file == nullptr) { |
42 fprintf(stderr, "Couldn't open input file for reading: %s\n", | 42 fprintf(stderr, "Couldn't open input file for reading: %s\n", |
43 output_file_name.c_str()); | 43 output_file_name.c_str()); |
44 return false; | 44 return false; |
45 } | 45 } |
46 | 46 |
47 int input_frame_size = InputFrameSize(); | 47 int input_frame_size = InputFrameSize(); |
48 uint8_t* rgba_buffer = new uint8_t[input_frame_size]; | 48 uint8_t* rgba_buffer = new uint8_t[input_frame_size]; |
49 int y_plane_size = YPlaneSize(); | 49 int y_plane_size = YPlaneSize(); |
50 uint8_t* dst_y = new uint8_t[y_plane_size]; | 50 uint8_t* dst_y = new uint8_t[y_plane_size]; |
51 int u_plane_size = UPlaneSize(); | 51 int u_plane_size = UPlaneSize(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 fprintf(stderr, "Number of bytes written (%d) doesn't match size of y plane" | 128 fprintf(stderr, "Number of bytes written (%d) doesn't match size of y plane" |
129 " (%d)\n", static_cast<int>(bytes_written), yuv_plane_size); | 129 " (%d)\n", static_cast<int>(bytes_written), yuv_plane_size); |
130 return false; | 130 return false; |
131 } | 131 } |
132 return true; | 132 return true; |
133 } | 133 } |
134 | 134 |
135 bool Converter::ReadRGBAFrame(const char* input_file_name, int input_frame_size, | 135 bool Converter::ReadRGBAFrame(const char* input_file_name, int input_frame_size, |
136 unsigned char* buffer) { | 136 unsigned char* buffer) { |
137 FILE* input_file = fopen(input_file_name, "rb"); | 137 FILE* input_file = fopen(input_file_name, "rb"); |
138 if (input_file == NULL) { | 138 if (input_file == nullptr) { |
139 fprintf(stderr, "Couldn't open input file for reading: %s\n", | 139 fprintf(stderr, "Couldn't open input file for reading: %s\n", |
140 input_file_name); | 140 input_file_name); |
141 return false; | 141 return false; |
142 } | 142 } |
143 | 143 |
144 size_t nbr_read = fread(buffer, 1, input_frame_size, input_file); | 144 size_t nbr_read = fread(buffer, 1, input_frame_size, input_file); |
145 fclose(input_file); | 145 fclose(input_file); |
146 | 146 |
147 if (nbr_read != static_cast<size_t>(input_frame_size)) { | 147 if (nbr_read != static_cast<size_t>(input_frame_size)) { |
148 fprintf(stderr, "Error reading from input file: %s\n", input_file_name); | 148 fprintf(stderr, "Error reading from input file: %s\n", input_file_name); |
(...skipping 18 matching lines...) Expand all Loading... |
167 std::stringstream tmp; | 167 std::stringstream tmp; |
168 | 168 |
169 // Zero-pad number to a string. | 169 // Zero-pad number to a string. |
170 tmp << std::setfill('0') << std::setw(width) << number; | 170 tmp << std::setfill('0') << std::setw(width) << number; |
171 | 171 |
172 return "frame_" + tmp.str(); | 172 return "frame_" + tmp.str(); |
173 } | 173 } |
174 | 174 |
175 } // namespace test | 175 } // namespace test |
176 } // namespace webrtc | 176 } // namespace webrtc |
OLD | NEW |