From 98ee49d5fb03c6746de92ac4f275d7f4cc61052d Mon Sep 17 00:00:00 2001 From: philipel Date: Wed, 4 Apr 2018 11:49:49 +0200 Subject: [PATCH] Don't use the |codec_settings| parameter in I420Decoder::InitDecode. Bug: webrtc:9106 Change-Id: I05e69c0272f782d3811b4f294ac4669215112768 Reviewed-on: https://webrtc-review.googlesource.com/66721 Reviewed-by: Stefan Holmer Commit-Queue: Philip Eliasson Cr-Commit-Position: refs/heads/master@{#22729} --- modules/video_coding/codecs/i420/i420.cc | 31 ++++--------------- .../video_coding/codecs/i420/include/i420.h | 3 -- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/modules/video_coding/codecs/i420/i420.cc b/modules/video_coding/codecs/i420/i420.cc index 58ef32e2fc..b9565a5f3b 100644 --- a/modules/video_coding/codecs/i420/i420.cc +++ b/modules/video_coding/codecs/i420/i420.cc @@ -139,11 +139,7 @@ int I420Encoder::RegisterEncodeCompleteCallback( return WEBRTC_VIDEO_CODEC_OK; } -I420Decoder::I420Decoder() - : _width(0), - _height(0), - _inited(false), - _decodeCompleteCallback(NULL) {} +I420Decoder::I420Decoder() : _decodeCompleteCallback(NULL) {} I420Decoder::~I420Decoder() { Release(); @@ -151,14 +147,6 @@ I420Decoder::~I420Decoder() { int I420Decoder::InitDecode(const VideoCodec* codecSettings, int /*numberOfCores */) { - if (codecSettings == NULL) { - return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; - } else if (codecSettings->width < 1 || codecSettings->height < 1) { - return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; - } - _width = codecSettings->width; - _height = codecSettings->height; - _inited = true; return WEBRTC_VIDEO_CODEC_OK; } @@ -179,34 +167,28 @@ int I420Decoder::Decode(const EncodedImage& inputImage, if (inputImage._completeFrame == false) { return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; } - if (!_inited) { - return WEBRTC_VIDEO_CODEC_UNINITIALIZED; - } if (inputImage._length < kI420HeaderSize) { return WEBRTC_VIDEO_CODEC_ERROR; } const uint8_t* buffer = inputImage._buffer; uint16_t width, height; - buffer = ExtractHeader(buffer, &width, &height); - _width = width; - _height = height; // Verify that the available length is sufficient: size_t req_length = - CalcBufferSize(VideoType::kI420, _width, _height) + kI420HeaderSize; + CalcBufferSize(VideoType::kI420, width, height) + kI420HeaderSize; if (req_length > inputImage._length) { return WEBRTC_VIDEO_CODEC_ERROR; } // Set decoded image parameters. rtc::scoped_refptr frame_buffer = - I420Buffer::Create(_width, _height); + I420Buffer::Create(width, height); // Converting from raw buffer I420Buffer. - int y_stride = 16 * ((_width + 15) / 16); - int uv_stride = 16 * ((_width + 31) / 32); + int y_stride = 16 * ((width + 15) / 16); + int uv_stride = 16 * ((width + 31) / 32); int y_size = y_stride * height; int u_size = uv_stride * frame_buffer->ChromaHeight(); int ret = libyuv::I420Copy( @@ -214,7 +196,7 @@ int I420Decoder::Decode(const EncodedImage& inputImage, uv_stride, frame_buffer.get()->MutableDataY(), frame_buffer.get()->StrideY(), frame_buffer.get()->MutableDataU(), frame_buffer.get()->StrideU(), frame_buffer.get()->MutableDataV(), - frame_buffer.get()->StrideV(), _width, _height); + frame_buffer.get()->StrideV(), width, height); if (ret < 0) { return WEBRTC_VIDEO_CODEC_MEMORY; } @@ -243,7 +225,6 @@ int I420Decoder::RegisterDecodeCompleteCallback( } int I420Decoder::Release() { - _inited = false; return WEBRTC_VIDEO_CODEC_OK; } } // namespace webrtc diff --git a/modules/video_coding/codecs/i420/include/i420.h b/modules/video_coding/codecs/i420/include/i420.h index f3e8a3d9b8..e6bb46082c 100644 --- a/modules/video_coding/codecs/i420/include/i420.h +++ b/modules/video_coding/codecs/i420/include/i420.h @@ -131,9 +131,6 @@ class I420Decoder : public VideoDecoder { uint16_t* width, uint16_t* height); - int _width; - int _height; - bool _inited; DecodedImageCallback* _decodeCompleteCallback; }; // class I420Decoder