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

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

Issue 1721353002: Replace scoped_ptr with unique_ptr in webrtc/modules/video_coding/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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 */
11 11
12 #include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_decoder.h" 12 #include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_decoder.h"
13 13
14 #if defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) 14 #if defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
15 15
16 #include <memory>
17
16 #include "libyuv/convert.h" 18 #include "libyuv/convert.h"
17 #include "webrtc/base/checks.h" 19 #include "webrtc/base/checks.h"
18 #include "webrtc/base/logging.h" 20 #include "webrtc/base/logging.h"
19 #include "webrtc/common_video/include/video_frame_buffer.h" 21 #include "webrtc/common_video/include/video_frame_buffer.h"
20 #include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.h" 22 #include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.h"
21 #include "webrtc/video_frame.h" 23 #include "webrtc/video_frame.h"
22 24
23 namespace internal { 25 namespace internal {
24 26
25 // Convenience function for creating a dictionary. 27 // Convenience function for creating a dictionary.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 80
79 // This is the callback function that VideoToolbox calls when decode is 81 // This is the callback function that VideoToolbox calls when decode is
80 // complete. 82 // complete.
81 void VTDecompressionOutputCallback(void* decoder, 83 void VTDecompressionOutputCallback(void* decoder,
82 void* params, 84 void* params,
83 OSStatus status, 85 OSStatus status,
84 VTDecodeInfoFlags info_flags, 86 VTDecodeInfoFlags info_flags,
85 CVImageBufferRef image_buffer, 87 CVImageBufferRef image_buffer,
86 CMTime timestamp, 88 CMTime timestamp,
87 CMTime duration) { 89 CMTime duration) {
88 rtc::scoped_ptr<FrameDecodeParams> decode_params( 90 std::unique_ptr<FrameDecodeParams> decode_params(
89 reinterpret_cast<FrameDecodeParams*>(params)); 91 reinterpret_cast<FrameDecodeParams*>(params));
90 if (status != noErr) { 92 if (status != noErr) {
91 LOG(LS_ERROR) << "Failed to decode frame. Status: " << status; 93 LOG(LS_ERROR) << "Failed to decode frame. Status: " << status;
92 return; 94 return;
93 } 95 }
94 // TODO(tkchin): Handle CVO properly. 96 // TODO(tkchin): Handle CVO properly.
95 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer = 97 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer =
96 VideoFrameBufferForPixelBuffer(image_buffer); 98 VideoFrameBufferForPixelBuffer(image_buffer);
97 webrtc::VideoFrame decoded_frame(buffer, decode_params->timestamp, 0, 99 webrtc::VideoFrame decoded_frame(buffer, decode_params->timestamp, 0,
98 webrtc::kVideoRotation_0); 100 webrtc::kVideoRotation_0);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 RTC_DCHECK(sample_buffer); 137 RTC_DCHECK(sample_buffer);
136 // Check if the video format has changed, and reinitialize decoder if needed. 138 // Check if the video format has changed, and reinitialize decoder if needed.
137 CMVideoFormatDescriptionRef description = 139 CMVideoFormatDescriptionRef description =
138 CMSampleBufferGetFormatDescription(sample_buffer); 140 CMSampleBufferGetFormatDescription(sample_buffer);
139 if (!CMFormatDescriptionEqual(description, video_format_)) { 141 if (!CMFormatDescriptionEqual(description, video_format_)) {
140 SetVideoFormat(description); 142 SetVideoFormat(description);
141 ResetDecompressionSession(); 143 ResetDecompressionSession();
142 } 144 }
143 VTDecodeFrameFlags decode_flags = 145 VTDecodeFrameFlags decode_flags =
144 kVTDecodeFrame_EnableAsynchronousDecompression; 146 kVTDecodeFrame_EnableAsynchronousDecompression;
145 rtc::scoped_ptr<internal::FrameDecodeParams> frame_decode_params; 147 std::unique_ptr<internal::FrameDecodeParams> frame_decode_params;
146 frame_decode_params.reset( 148 frame_decode_params.reset(
147 new internal::FrameDecodeParams(callback_, input_image._timeStamp)); 149 new internal::FrameDecodeParams(callback_, input_image._timeStamp));
148 OSStatus status = VTDecompressionSessionDecodeFrame( 150 OSStatus status = VTDecompressionSessionDecodeFrame(
149 decompression_session_, sample_buffer, decode_flags, 151 decompression_session_, sample_buffer, decode_flags,
150 frame_decode_params.release(), nullptr); 152 frame_decode_params.release(), nullptr);
151 CFRelease(sample_buffer); 153 CFRelease(sample_buffer);
152 if (status != noErr) { 154 if (status != noErr) {
153 LOG(LS_ERROR) << "Failed to decode frame with code: " << status; 155 LOG(LS_ERROR) << "Failed to decode frame with code: " << status;
154 return WEBRTC_VIDEO_CODEC_ERROR; 156 return WEBRTC_VIDEO_CODEC_ERROR;
155 } 157 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 262 }
261 } 263 }
262 264
263 const char* H264VideoToolboxDecoder::ImplementationName() const { 265 const char* H264VideoToolboxDecoder::ImplementationName() const {
264 return "VideoToolbox"; 266 return "VideoToolbox";
265 } 267 }
266 268
267 } // namespace webrtc 269 } // namespace webrtc
268 270
269 #endif // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) 271 #endif // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698