Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: webrtc/test/testsupport/jpeg_frame_writer.cc

Issue 3004603002: Update jpeg writer to compile on iOS and document it better (Closed)
Patch Set: Rename jpeg_frame_writer_dummy.cc to jpeg_frame_writer_ios.cc Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 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
(...skipping 17 matching lines...) Expand all
28 28
29 namespace webrtc { 29 namespace webrtc {
30 namespace test { 30 namespace test {
31 31
32 JpegFrameWriter::JpegFrameWriter(const std::string &output_filename) 32 JpegFrameWriter::JpegFrameWriter(const std::string &output_filename)
33 : frame_written_(false), 33 : frame_written_(false),
34 output_filename_(output_filename), 34 output_filename_(output_filename),
35 output_file_(nullptr) {} 35 output_file_(nullptr) {}
36 36
37 bool JpegFrameWriter::WriteFrame(const VideoFrame& input_frame, int quality) { 37 bool JpegFrameWriter::WriteFrame(const VideoFrame& input_frame, int quality) {
38 RTC_CHECK(!frame_written_) << "Only a single frame can be saved to Jpeg."; 38 if (frame_written_) {
39 LOG(LS_ERROR) << "Only a single frame can be saved to Jpeg.";
40 return false;
41 }
39 const int kColorPlanes = 3; // R, G and B. 42 const int kColorPlanes = 3; // R, G and B.
40 size_t rgb_len = input_frame.height() * input_frame.width() * kColorPlanes; 43 size_t rgb_len = input_frame.height() * input_frame.width() * kColorPlanes;
41 std::unique_ptr<uint8_t[]> rgb_buf(new uint8_t[rgb_len]); 44 std::unique_ptr<uint8_t[]> rgb_buf(new uint8_t[rgb_len]);
42 45
43 // kRGB24 actually corresponds to FourCC 24BG which is 24-bit BGR. 46 // kRGB24 actually corresponds to FourCC 24BG which is 24-bit BGR.
44 if (ConvertFromI420(input_frame, VideoType::kRGB24, 0, rgb_buf.get()) < 0) { 47 if (ConvertFromI420(input_frame, VideoType::kRGB24, 0, rgb_buf.get()) < 0) {
45 LOG(LS_ERROR) << "Could not convert input frame to RGB."; 48 LOG(LS_ERROR) << "Could not convert input frame to RGB.";
46 return false; 49 return false;
47 } 50 }
48 output_file_ = fopen(output_filename_.c_str(), "wb"); 51 output_file_ = fopen(output_filename_.c_str(), "wb");
(...skipping 29 matching lines...) Expand all
78 jpeg_finish_compress(&cinfo); 81 jpeg_finish_compress(&cinfo);
79 jpeg_destroy_compress(&cinfo); 82 jpeg_destroy_compress(&cinfo);
80 fclose(output_file_); 83 fclose(output_file_);
81 84
82 frame_written_ = true; 85 frame_written_ = true;
83 return true; 86 return true;
84 } 87 }
85 88
86 } // namespace test 89 } // namespace test
87 } // namespace webrtc 90 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/testsupport/frame_writer.h ('k') | webrtc/test/testsupport/jpeg_frame_writer_ios.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698