get_format should not be set after calling avcodec_open2()
This commit is contained in:
parent
ab145e2bb0
commit
2b035ddf49
2 changed files with 5 additions and 3 deletions
|
@ -27,9 +27,7 @@ Decoder AVCodec::make_decoder (unsigned int width, unsigned int height, ::AVPixe
|
||||||
|
|
||||||
context->width = width;
|
context->width = width;
|
||||||
context->height = height;
|
context->height = height;
|
||||||
|
context->codec = codec;
|
||||||
if (::avcodec_open2(context.get(), codec, nullptr) < 0)
|
|
||||||
throw std::runtime_error("Could not open codec");
|
|
||||||
|
|
||||||
return {std::move(context), dst_format};
|
return {std::move(context), dst_format};
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,12 @@ Decoder::Decoder (UniqueAVCodecContext&& context, ::AVPixelFormat dst_format) :
|
||||||
m_dst_format(dst_format)
|
m_dst_format(dst_format)
|
||||||
{
|
{
|
||||||
assert(not m_context->opaque);
|
assert(not m_context->opaque);
|
||||||
|
assert(m_context->codec);
|
||||||
m_context->opaque = this;
|
m_context->opaque = this;
|
||||||
m_context->get_format = &get_favourite_format_ifp;
|
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;
|
Decoder::~Decoder() noexcept = default;
|
||||||
|
|
Loading…
Add table
Reference in a new issue