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

Side by Side Diff: webrtc/modules/video_coding/generic_decoder.cc

Issue 2772033002: Add content type information to encoded images and corresponding rtp extension header (Closed)
Patch Set: Fix Mac CE Created 3 years, 8 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) 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
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 if (!decode_time_ms) { 80 if (!decode_time_ms) {
81 decode_time_ms = 81 decode_time_ms =
82 rtc::Optional<int32_t>(now_ms - frameInfo->decodeStartTimeMs); 82 rtc::Optional<int32_t>(now_ms - frameInfo->decodeStartTimeMs);
83 } 83 }
84 _timing->StopDecodeTimer(decodedImage.timestamp(), *decode_time_ms, now_ms, 84 _timing->StopDecodeTimer(decodedImage.timestamp(), *decode_time_ms, now_ms,
85 frameInfo->renderTimeMs); 85 frameInfo->renderTimeMs);
86 86
87 decodedImage.set_timestamp_us( 87 decodedImage.set_timestamp_us(
88 frameInfo->renderTimeMs * rtc::kNumMicrosecsPerMillisec); 88 frameInfo->renderTimeMs * rtc::kNumMicrosecsPerMillisec);
89 decodedImage.set_rotation(frameInfo->rotation); 89 decodedImage.set_rotation(frameInfo->rotation);
90 decodedImage.set_content_type(frameInfo->content_type);
90 _receiveCallback->FrameToRender(decodedImage, qp); 91 _receiveCallback->FrameToRender(decodedImage, qp);
91 } 92 }
92 93
93 int32_t VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame( 94 int32_t VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame(
94 const uint64_t pictureId) { 95 const uint64_t pictureId) {
95 return _receiveCallback->ReceivedDecodedReferenceFrame(pictureId); 96 return _receiveCallback->ReceivedDecodedReferenceFrame(pictureId);
96 } 97 }
97 98
98 int32_t VCMDecodedFrameCallback::ReceivedDecodedFrame( 99 int32_t VCMDecodedFrameCallback::ReceivedDecodedFrame(
99 const uint64_t pictureId) { 100 const uint64_t pictureId) {
(...skipping 24 matching lines...) Expand all
124 return VCM_OK; 125 return VCM_OK;
125 } 126 }
126 127
127 VCMGenericDecoder::VCMGenericDecoder(VideoDecoder* decoder, bool isExternal) 128 VCMGenericDecoder::VCMGenericDecoder(VideoDecoder* decoder, bool isExternal)
128 : _callback(NULL), 129 : _callback(NULL),
129 _frameInfos(), 130 _frameInfos(),
130 _nextFrameInfoIdx(0), 131 _nextFrameInfoIdx(0),
131 _decoder(decoder), 132 _decoder(decoder),
132 _codecType(kVideoCodecUnknown), 133 _codecType(kVideoCodecUnknown),
133 _isExternal(isExternal), 134 _isExternal(isExternal),
134 _keyFrameDecoded(false) {} 135 _keyFrameDecoded(false),
136 _last_keyframe_content_type(VideoContentType::kDefault) {}
135 137
136 VCMGenericDecoder::~VCMGenericDecoder() {} 138 VCMGenericDecoder::~VCMGenericDecoder() {}
137 139
138 int32_t VCMGenericDecoder::InitDecode(const VideoCodec* settings, 140 int32_t VCMGenericDecoder::InitDecode(const VideoCodec* settings,
139 int32_t numberOfCores) { 141 int32_t numberOfCores) {
140 TRACE_EVENT0("webrtc", "VCMGenericDecoder::InitDecode"); 142 TRACE_EVENT0("webrtc", "VCMGenericDecoder::InitDecode");
141 _codecType = settings->codecType; 143 _codecType = settings->codecType;
142 144
143 return _decoder->InitDecode(settings, numberOfCores); 145 return _decoder->InitDecode(settings, numberOfCores);
144 } 146 }
145 147
146 int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, int64_t nowMs) { 148 int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, int64_t nowMs) {
147 TRACE_EVENT1("webrtc", "VCMGenericDecoder::Decode", "timestamp", 149 TRACE_EVENT1("webrtc", "VCMGenericDecoder::Decode", "timestamp",
148 frame.EncodedImage()._timeStamp); 150 frame.EncodedImage()._timeStamp);
149 _frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs; 151 _frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs;
150 _frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs(); 152 _frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs();
151 _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation(); 153 _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation();
154 // Set correctly only for key frames. Thus, use latest key frame
155 // content type. If the corresponding key frame was lost, decode will fail
156 // and content type will be ignored.
157 if (frame.FrameType() == kVideoFrameKey) {
158 _frameInfos[_nextFrameInfoIdx].content_type = frame.contentType();
159 _last_keyframe_content_type = frame.contentType();
160 } else {
161 _frameInfos[_nextFrameInfoIdx].content_type = _last_keyframe_content_type;
162 }
152 _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]); 163 _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]);
153 164
154 _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength; 165 _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength;
155 const RTPFragmentationHeader dummy_header; 166 const RTPFragmentationHeader dummy_header;
156 int32_t ret = _decoder->Decode(frame.EncodedImage(), frame.MissingFrame(), 167 int32_t ret = _decoder->Decode(frame.EncodedImage(), frame.MissingFrame(),
157 &dummy_header, 168 &dummy_header,
158 frame.CodecSpecific(), frame.RenderTimeMs()); 169 frame.CodecSpecific(), frame.RenderTimeMs());
159 170
160 _callback->OnDecoderImplementationName(_decoder->ImplementationName()); 171 _callback->OnDecoderImplementationName(_decoder->ImplementationName());
161 if (ret < WEBRTC_VIDEO_CODEC_OK) { 172 if (ret < WEBRTC_VIDEO_CODEC_OK) {
(...skipping 21 matching lines...) Expand all
183 194
184 bool VCMGenericDecoder::External() const { 195 bool VCMGenericDecoder::External() const {
185 return _isExternal; 196 return _isExternal;
186 } 197 }
187 198
188 bool VCMGenericDecoder::PrefersLateDecoding() const { 199 bool VCMGenericDecoder::PrefersLateDecoding() const {
189 return _decoder->PrefersLateDecoding(); 200 return _decoder->PrefersLateDecoding();
190 } 201 }
191 202
192 } // namespace webrtc 203 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698