Update video_coding/codecs to new VideoFrameBuffer interface
This is a follow-up cleanup for CL https://codereview.webrtc.org/2847383002/. Bug: webrtc:7632 Change-Id: I47861d779968f2fee94db9c017102a8e87e67fb7 Reviewed-on: https://chromium-review.googlesource.com/524163 Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Cr-Commit-Position: refs/heads/master@{#18477}
This commit is contained in:
committed by
Commit Bot
parent
9932e255ea
commit
20ebf4ede8
@ -134,7 +134,7 @@ int H264DecoderImpl::AVGetBuffer2(
|
||||
decoder->pool_.CreateBuffer(width, height);
|
||||
|
||||
int y_size = width * height;
|
||||
int uv_size = ((width + 1) / 2) * ((height + 1) / 2);
|
||||
int uv_size = frame_buffer->ChromaWidth() * frame_buffer->ChromaHeight();
|
||||
// DCHECK that we have a continuous buffer as is required.
|
||||
RTC_DCHECK_EQ(frame_buffer->DataU(), frame_buffer->DataY() + y_size);
|
||||
RTC_DCHECK_EQ(frame_buffer->DataV(), frame_buffer->DataU() + uv_size);
|
||||
@ -349,12 +349,11 @@ int32_t H264DecoderImpl::Decode(const EncodedImage& input_image,
|
||||
VideoFrame* video_frame = static_cast<VideoFrame*>(
|
||||
av_buffer_get_opaque(av_frame_->buf[0]));
|
||||
RTC_DCHECK(video_frame);
|
||||
RTC_CHECK_EQ(av_frame_->data[kYPlaneIndex],
|
||||
video_frame->video_frame_buffer()->DataY());
|
||||
RTC_CHECK_EQ(av_frame_->data[kUPlaneIndex],
|
||||
video_frame->video_frame_buffer()->DataU());
|
||||
RTC_CHECK_EQ(av_frame_->data[kVPlaneIndex],
|
||||
video_frame->video_frame_buffer()->DataV());
|
||||
rtc::scoped_refptr<webrtc::I420BufferInterface> i420_buffer =
|
||||
video_frame->video_frame_buffer()->GetI420();
|
||||
RTC_CHECK_EQ(av_frame_->data[kYPlaneIndex], i420_buffer->DataY());
|
||||
RTC_CHECK_EQ(av_frame_->data[kUPlaneIndex], i420_buffer->DataU());
|
||||
RTC_CHECK_EQ(av_frame_->data[kVPlaneIndex], i420_buffer->DataV());
|
||||
video_frame->set_timestamp(input_image._timeStamp);
|
||||
|
||||
rtc::Optional<uint8_t> qp;
|
||||
@ -369,15 +368,15 @@ int32_t H264DecoderImpl::Decode(const EncodedImage& input_image,
|
||||
// The decoded image may be larger than what is supposed to be visible, see
|
||||
// |AVGetBuffer2|'s use of |avcodec_align_dimensions|. This crops the image
|
||||
// without copying the underlying buffer.
|
||||
rtc::scoped_refptr<VideoFrameBuffer> buf = video_frame->video_frame_buffer();
|
||||
if (av_frame_->width != buf->width() || av_frame_->height != buf->height()) {
|
||||
if (av_frame_->width != i420_buffer->width() ||
|
||||
av_frame_->height != i420_buffer->height()) {
|
||||
rtc::scoped_refptr<VideoFrameBuffer> cropped_buf(
|
||||
new rtc::RefCountedObject<WrappedI420Buffer>(
|
||||
av_frame_->width, av_frame_->height,
|
||||
buf->DataY(), buf->StrideY(),
|
||||
buf->DataU(), buf->StrideU(),
|
||||
buf->DataV(), buf->StrideV(),
|
||||
rtc::KeepRefUntilDone(buf)));
|
||||
i420_buffer->DataY(), i420_buffer->StrideY(),
|
||||
i420_buffer->DataU(), i420_buffer->StrideU(),
|
||||
i420_buffer->DataV(), i420_buffer->StrideV(),
|
||||
rtc::KeepRefUntilDone(i420_buffer)));
|
||||
VideoFrame cropped_frame(
|
||||
cropped_buf, video_frame->timestamp(), video_frame->render_time_ms(),
|
||||
video_frame->rotation());
|
||||
|
||||
@ -332,8 +332,8 @@ int32_t H264EncoderImpl::Encode(const VideoFrame& input_frame,
|
||||
// (If every frame is a key frame we get lag/delays.)
|
||||
openh264_encoder_->ForceIntraFrame(true);
|
||||
}
|
||||
rtc::scoped_refptr<const VideoFrameBuffer> frame_buffer =
|
||||
input_frame.video_frame_buffer();
|
||||
rtc::scoped_refptr<const I420BufferInterface> frame_buffer =
|
||||
input_frame.video_frame_buffer()->ToI420();
|
||||
// EncodeFrame input.
|
||||
SSourcePicture picture;
|
||||
memset(&picture, 0, sizeof(SSourcePicture));
|
||||
|
||||
Reference in New Issue
Block a user