Commit 560473e0 authored by Philippe Gorley's avatar Philippe Gorley Committed by Philippe Gorley

decoder: properly initialize frames

MediaFrame doesn't have a ptr_ or allocated_ fields, so casting it
to VideoFrame and calling VideoFrame::copyFrom causes an invalid read.

Change-Id: Icb1a0a20be04d212357f5eb53d09ed08ab58cde3
parent 58f5a174
......@@ -333,7 +333,9 @@ MediaDecoder::decode(AVPacket& packet)
return ret == AVERROR_EOF ? Status::Success : Status::DecodeError;
}
auto f = std::make_shared<MediaFrame>();
auto f = (inputDecoder_->type == AVMEDIA_TYPE_VIDEO)
? std::static_pointer_cast<MediaFrame>(std::make_shared<VideoFrame>())
: std::static_pointer_cast<MediaFrame>(std::make_shared<AudioFrame>());
auto frame = f->pointer();
ret = avcodec_receive_frame(decoderCtx_, frame);
if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment