// first frame because of M$ VC1 braindamage).
if ( !pv->video_codec_opened )
{
- pv->context->workaround_bugs = FF_BUG_AUTODETECT;
- pv->context->err_recognition = AV_EF_CRCCHECK;
- pv->context->error_concealment = FF_EC_GUESS_MVS|FF_EC_DEBLOCK;
-
if (setup_extradata(pv))
{
// we didn't find the headers needed to set up extradata.
return HB_WORK_OK;
}
+ hb_avcodec_free_context(&pv->context);
+ pv->context = avcodec_alloc_context3(pv->codec);
+
+ pv->context->workaround_bugs = FF_BUG_AUTODETECT;
+ pv->context->err_recognition = AV_EF_CRCCHECK;
+ pv->context->error_concealment = FF_EC_GUESS_MVS|FF_EC_DEBLOCK;
+
+
#ifdef USE_QSV
if (pv->qsv.decode &&
pv->qsv.config.io_pattern == MFX_IOPATTERN_OUT_OPAQUE_MEMORY)
if (pv->parser)
{
+ int codec_id = pv->context->codec_id;
len = av_parser_parse2(pv->parser, pv->context, &pout, &pout_len,
in->data + pos, in->size - pos,
pts, dts, 0 );
parser_dts = pv->parser->dts;
pts = AV_NOPTS_VALUE;
dts = AV_NOPTS_VALUE;
+
+ if (codec_id != pv->context->codec_id)
+ {
+ // The parser has decided to change the decoder underneath
+ // us. Update our context to match. This can happen
+ // for MPEG-1/2 video, perhaps others
+ pv->codec = avcodec_find_decoder(pv->context->codec_id);
+ }
}
else
{