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

Side by Side Diff: webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.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) 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 av_frame->data[kUPlaneIndex] = frame_buffer->MutableDataU(); 149 av_frame->data[kUPlaneIndex] = frame_buffer->MutableDataU();
150 av_frame->linesize[kUPlaneIndex] = frame_buffer->StrideU(); 150 av_frame->linesize[kUPlaneIndex] = frame_buffer->StrideU();
151 av_frame->data[kVPlaneIndex] = frame_buffer->MutableDataV(); 151 av_frame->data[kVPlaneIndex] = frame_buffer->MutableDataV();
152 av_frame->linesize[kVPlaneIndex] = frame_buffer->StrideV(); 152 av_frame->linesize[kVPlaneIndex] = frame_buffer->StrideV();
153 RTC_DCHECK_EQ(av_frame->extended_data, av_frame->data); 153 RTC_DCHECK_EQ(av_frame->extended_data, av_frame->data);
154 154
155 // Create a VideoFrame object, to keep a reference to the buffer. 155 // Create a VideoFrame object, to keep a reference to the buffer.
156 // TODO(nisse): The VideoFrame's timestamp and rotation info is not used. 156 // TODO(nisse): The VideoFrame's timestamp and rotation info is not used.
157 // Refactor to do not use a VideoFrame object at all. 157 // Refactor to do not use a VideoFrame object at all.
158 av_frame->buf[0] = av_buffer_create( 158 av_frame->buf[0] = av_buffer_create(
159 av_frame->data[kYPlaneIndex], 159 av_frame->data[kYPlaneIndex], total_size, AVFreeBuffer2,
160 total_size, 160 static_cast<void*>(new VideoFrame(
161 AVFreeBuffer2, 161 frame_buffer, 0 /* timestamp */, 0 /* render_time_ms */,
162 static_cast<void*>(new VideoFrame(frame_buffer, 162 kVideoRotation_0, VideoContentType::kDefault)),
163 0 /* timestamp */,
164 0 /* render_time_ms */,
165 kVideoRotation_0)),
166 0); 163 0);
167 RTC_CHECK(av_frame->buf[0]); 164 RTC_CHECK(av_frame->buf[0]);
168 return 0; 165 return 0;
169 } 166 }
170 167
171 void H264DecoderImpl::AVFreeBuffer2(void* opaque, uint8_t* data) { 168 void H264DecoderImpl::AVFreeBuffer2(void* opaque, uint8_t* data) {
172 // The buffer pool recycles the buffer used by |video_frame| when there are no 169 // The buffer pool recycles the buffer used by |video_frame| when there are no
173 // more references to it. |video_frame| is a thin buffer holder and is not 170 // more references to it. |video_frame| is a thin buffer holder and is not
174 // recycled. 171 // recycled.
175 VideoFrame* video_frame = static_cast<VideoFrame*>(opaque); 172 VideoFrame* video_frame = static_cast<VideoFrame*>(opaque);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 if (av_frame_->width != buf->width() || av_frame_->height != buf->height()) { 370 if (av_frame_->width != buf->width() || av_frame_->height != buf->height()) {
374 rtc::scoped_refptr<VideoFrameBuffer> cropped_buf( 371 rtc::scoped_refptr<VideoFrameBuffer> cropped_buf(
375 new rtc::RefCountedObject<WrappedI420Buffer>( 372 new rtc::RefCountedObject<WrappedI420Buffer>(
376 av_frame_->width, av_frame_->height, 373 av_frame_->width, av_frame_->height,
377 buf->DataY(), buf->StrideY(), 374 buf->DataY(), buf->StrideY(),
378 buf->DataU(), buf->StrideU(), 375 buf->DataU(), buf->StrideU(),
379 buf->DataV(), buf->StrideV(), 376 buf->DataV(), buf->StrideV(),
380 rtc::KeepRefUntilDone(buf))); 377 rtc::KeepRefUntilDone(buf)));
381 VideoFrame cropped_frame( 378 VideoFrame cropped_frame(
382 cropped_buf, video_frame->timestamp(), video_frame->render_time_ms(), 379 cropped_buf, video_frame->timestamp(), video_frame->render_time_ms(),
383 video_frame->rotation()); 380 video_frame->rotation(), video_frame->content_type());
384 // TODO(nisse): Timestamp and rotation are all zero here. Change decoder 381 // TODO(nisse): Timestamp and rotation are all zero here. Change decoder
385 // interface to pass a VideoFrameBuffer instead of a VideoFrame? 382 // interface to pass a VideoFrameBuffer instead of a VideoFrame?
386 decoded_image_callback_->Decoded(cropped_frame, rtc::Optional<int32_t>(), 383 decoded_image_callback_->Decoded(cropped_frame, rtc::Optional<int32_t>(),
387 qp); 384 qp);
388 } else { 385 } else {
389 // Return decoded frame. 386 // Return decoded frame.
390 decoded_image_callback_->Decoded(*video_frame, rtc::Optional<int32_t>(), 387 decoded_image_callback_->Decoded(*video_frame, rtc::Optional<int32_t>(),
391 qp); 388 qp);
392 } 389 }
393 // Stop referencing it, possibly freeing |video_frame|. 390 // Stop referencing it, possibly freeing |video_frame|.
(...skipping 23 matching lines...) Expand all
417 void H264DecoderImpl::ReportError() { 414 void H264DecoderImpl::ReportError() {
418 if (has_reported_error_) 415 if (has_reported_error_)
419 return; 416 return;
420 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.H264DecoderImpl.Event", 417 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.H264DecoderImpl.Event",
421 kH264DecoderEventError, 418 kH264DecoderEventError,
422 kH264DecoderEventMax); 419 kH264DecoderEventMax);
423 has_reported_error_ = true; 420 has_reported_error_ = true;
424 } 421 }
425 422
426 } // namespace webrtc 423 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698