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 <stefan@webrtc.org> Commit-Queue: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22729}
This commit is contained in:
@ -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<webrtc::I420Buffer> 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
|
||||
|
||||
@ -131,9 +131,6 @@ class I420Decoder : public VideoDecoder {
|
||||
uint16_t* width,
|
||||
uint16_t* height);
|
||||
|
||||
int _width;
|
||||
int _height;
|
||||
bool _inited;
|
||||
DecodedImageCallback* _decodeCompleteCallback;
|
||||
}; // class I420Decoder
|
||||
|
||||
|
||||
Reference in New Issue
Block a user