Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions src/stream/FFmpegStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1669,6 +1669,7 @@ void FFmpegStream::ParsePacket(AVPacket* pkt)

if (parser->second->m_parserCtx &&
parser->second->m_parserCtx->parser &&
parser->second->m_codecCtx &&
!st->codecpar->extradata)
{
FFmpegExtraData retExtraData = GetPacketExtradata(pkt, st->codecpar);
Expand All @@ -1677,29 +1678,31 @@ void FFmpegStream::ParsePacket(AVPacket* pkt)
st->codecpar->extradata_size = retExtraData.GetSize();
st->codecpar->extradata = retExtraData.TakeData();

if (parser->second->m_parserCtx->parser->parser_parse)
parser->second->m_codecCtx->extradata = st->codecpar->extradata;
parser->second->m_codecCtx->extradata_size = st->codecpar->extradata_size;
uint8_t* outbufptr;
int bufSize;
parser->second->m_parserCtx->flags |= PARSER_FLAG_COMPLETE_FRAMES;
int ret = av_parser_parse2(parser->second->m_parserCtx, parser->second->m_codecCtx,
&outbufptr, &bufSize, pkt->data, pkt->size,
pkt->pts, pkt->dts, pkt->pos);
parser->second->m_codecCtx->extradata = nullptr;
parser->second->m_codecCtx->extradata_size = 0;

if (ret < 0)
{
parser->second->m_codecCtx->extradata = st->codecpar->extradata;
parser->second->m_codecCtx->extradata_size = st->codecpar->extradata_size;
const uint8_t* outbufptr;
int bufSize;
parser->second->m_parserCtx->flags |= PARSER_FLAG_COMPLETE_FRAMES;
parser->second->m_parserCtx->parser->parser_parse(parser->second->m_parserCtx,
parser->second->m_codecCtx,
&outbufptr, &bufSize,
pkt->data, pkt->size);
parser->second->m_codecCtx->extradata = nullptr;
parser->second->m_codecCtx->extradata_size = 0;

if (parser->second->m_parserCtx->width != 0)
{
st->codecpar->width = parser->second->m_parserCtx->width;
st->codecpar->height = parser->second->m_parserCtx->height;
}
else
{
Log(LOGLEVEL_ERROR, "CDVDDemuxFFmpeg::ParsePacket() invalid width/height");
}
Log(LOGLEVEL_ERROR, "%s - error parsing packet: %d", __FUNCTION__, ret);
return;
}

if (parser->second->m_parserCtx->width != 0)
{
st->codecpar->width = parser->second->m_parserCtx->width;
st->codecpar->height = parser->second->m_parserCtx->height;
}
else
{
Log(LOGLEVEL_ERROR, "CDVDDemuxFFmpeg::ParsePacket() invalid width/height");
}
}
}
Expand Down
Loading