get_format should not be set after calling avcodec_open2()

This commit is contained in:
King_DuckZ 2021-11-01 16:23:12 +01:00
parent ab145e2bb0
commit 2b035ddf49
2 changed files with 5 additions and 3 deletions

View file

@ -27,9 +27,7 @@ Decoder AVCodec::make_decoder (unsigned int width, unsigned int height, ::AVPixe
context->width = width;
context->height = height;
if (::avcodec_open2(context.get(), codec, nullptr) < 0)
throw std::runtime_error("Could not open codec");
context->codec = codec;
return {std::move(context), dst_format};
}

View file

@ -36,8 +36,12 @@ Decoder::Decoder (UniqueAVCodecContext&& context, ::AVPixelFormat dst_format) :
m_dst_format(dst_format)
{
assert(not m_context->opaque);
assert(m_context->codec);
m_context->opaque = this;
m_context->get_format = &get_favourite_format_ifp;
if (::avcodec_open2(m_context.get(), m_context->codec, nullptr) < 0)
throw std::runtime_error("Could not open codec");
}
Decoder::~Decoder() noexcept = default;