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

Side by Side Diff: webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc

Issue 2765243002: Delete RawVideoType enum, use the VideoType enum instead. (Closed)
Patch Set: Define constant webrtc::kI420, for backwards compatibility. Created 3 years, 7 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 RTC_CHECK_LE(layerInfo.pNalLengthInByte[nal], 100 RTC_CHECK_LE(layerInfo.pNalLengthInByte[nal],
101 std::numeric_limits<size_t>::max() - required_size); 101 std::numeric_limits<size_t>::max() - required_size);
102 required_size += layerInfo.pNalLengthInByte[nal]; 102 required_size += layerInfo.pNalLengthInByte[nal];
103 } 103 }
104 } 104 }
105 if (encoded_image->_size < required_size) { 105 if (encoded_image->_size < required_size) {
106 // Increase buffer size. Allocate enough to hold an unencoded image, this 106 // Increase buffer size. Allocate enough to hold an unencoded image, this
107 // should be more than enough to hold any encoded data of future frames of 107 // should be more than enough to hold any encoded data of future frames of
108 // the same size (avoiding possible future reallocation due to variations in 108 // the same size (avoiding possible future reallocation due to variations in
109 // required size). 109 // required size).
110 encoded_image->_size = 110 encoded_image->_size = CalcBufferSize(
111 CalcBufferSize(kI420, frame_buffer.width(), frame_buffer.height()); 111 VideoType::kI420, frame_buffer.width(), frame_buffer.height());
112 if (encoded_image->_size < required_size) { 112 if (encoded_image->_size < required_size) {
113 // Encoded data > unencoded data. Allocate required bytes. 113 // Encoded data > unencoded data. Allocate required bytes.
114 LOG(LS_WARNING) << "Encoding produced more bytes than the original image " 114 LOG(LS_WARNING) << "Encoding produced more bytes than the original image "
115 << "data! Original bytes: " << encoded_image->_size 115 << "data! Original bytes: " << encoded_image->_size
116 << ", encoded bytes: " << required_size << "."; 116 << ", encoded bytes: " << required_size << ".";
117 encoded_image->_size = required_size; 117 encoded_image->_size = required_size;
118 } 118 }
119 encoded_image->_buffer = new uint8_t[encoded_image->_size]; 119 encoded_image->_buffer = new uint8_t[encoded_image->_size];
120 encoded_image_buffer->reset(encoded_image->_buffer); 120 encoded_image_buffer->reset(encoded_image->_buffer);
121 } 121 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 Release(); 247 Release();
248 ReportError(); 248 ReportError();
249 return WEBRTC_VIDEO_CODEC_ERROR; 249 return WEBRTC_VIDEO_CODEC_ERROR;
250 } 250 }
251 // TODO(pbos): Base init params on these values before submitting. 251 // TODO(pbos): Base init params on these values before submitting.
252 int video_format = EVideoFormatType::videoFormatI420; 252 int video_format = EVideoFormatType::videoFormatI420;
253 openh264_encoder_->SetOption(ENCODER_OPTION_DATAFORMAT, 253 openh264_encoder_->SetOption(ENCODER_OPTION_DATAFORMAT,
254 &video_format); 254 &video_format);
255 255
256 // Initialize encoded image. Default buffer size: size of unencoded data. 256 // Initialize encoded image. Default buffer size: size of unencoded data.
257 encoded_image_._size = 257 encoded_image_._size = CalcBufferSize(VideoType::kI420, codec_settings->width,
258 CalcBufferSize(kI420, codec_settings->width, codec_settings->height); 258 codec_settings->height);
259 encoded_image_._buffer = new uint8_t[encoded_image_._size]; 259 encoded_image_._buffer = new uint8_t[encoded_image_._size];
260 encoded_image_buffer_.reset(encoded_image_._buffer); 260 encoded_image_buffer_.reset(encoded_image_._buffer);
261 encoded_image_._completeFrame = true; 261 encoded_image_._completeFrame = true;
262 encoded_image_._encodedWidth = 0; 262 encoded_image_._encodedWidth = 0;
263 encoded_image_._encodedHeight = 0; 263 encoded_image_._encodedHeight = 0;
264 encoded_image_._length = 0; 264 encoded_image_._length = 0;
265 return WEBRTC_VIDEO_CODEC_OK; 265 return WEBRTC_VIDEO_CODEC_OK;
266 } 266 }
267 267
268 int32_t H264EncoderImpl::Release() { 268 int32_t H264EncoderImpl::Release() {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 497
498 int32_t H264EncoderImpl::SetPeriodicKeyFrames(bool enable) { 498 int32_t H264EncoderImpl::SetPeriodicKeyFrames(bool enable) {
499 return WEBRTC_VIDEO_CODEC_OK; 499 return WEBRTC_VIDEO_CODEC_OK;
500 } 500 }
501 501
502 VideoEncoder::ScalingSettings H264EncoderImpl::GetScalingSettings() const { 502 VideoEncoder::ScalingSettings H264EncoderImpl::GetScalingSettings() const {
503 return VideoEncoder::ScalingSettings(true); 503 return VideoEncoder::ScalingSettings(true);
504 } 504 }
505 505
506 } // namespace webrtc 506 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_capture/windows/sink_filter_ds.cc ('k') | webrtc/modules/video_coding/codecs/i420/i420.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698