Skip to content

Commit

Permalink
Fix use of deprecated functions/fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevcairiel committed Aug 23, 2022
1 parent a2ae7a2 commit 8e3fcaf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
4 changes: 2 additions & 2 deletions decoder/LAVVideo/decoders/avcodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1205,8 +1205,8 @@ STDMETHODIMP CDecAvcodec::DecodePacket(AVPacket *avpkt, REFERENCE_TIME rtStartIn
if (m_bFFReordering)
{
rtStart = m_pFrame->pts;
if (m_pFrame->pkt_duration)
rtStop = m_pFrame->pts + m_pFrame->pkt_duration;
if (m_pFrame->duration)
rtStop = m_pFrame->pts + m_pFrame->duration;
else
rtStop = AV_NOPTS_VALUE;
}
Expand Down
18 changes: 11 additions & 7 deletions decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ void CLAVSubtitleProvider::CloseDecoder()
av_parser_close(m_pParser);
m_pParser = nullptr;
}

av_packet_free(&m_pSubtitlePacket);
}

STDMETHODIMP CLAVSubtitleProvider::SetConsumer(ISubRenderConsumer *pConsumer)
Expand Down Expand Up @@ -246,6 +248,8 @@ STDMETHODIMP CLAVSubtitleProvider::Flush()
context.isMovable = true;
m_pLAVVideo->SetInDVDMenu(false);

av_packet_free(&m_pSubtitlePacket);

return S_OK;
}

Expand Down Expand Up @@ -278,8 +282,8 @@ STDMETHODIMP CLAVSubtitleProvider::Decode(BYTE *buf, int buflen, REFERENCE_TIME
{
ASSERT(m_pAVCtx);

AVPacket avpkt;
av_init_packet(&avpkt);
if (m_pSubtitlePacket == nullptr)
m_pSubtitlePacket = av_packet_alloc();

AVSubtitle sub;
memset(&sub, 0, sizeof(sub));
Expand Down Expand Up @@ -314,12 +318,12 @@ STDMETHODIMP CLAVSubtitleProvider::Decode(BYTE *buf, int buflen, REFERENCE_TIME
}

if (pOut_size > 0) {
avpkt.data = pOut;
avpkt.size = pOut_size;
avpkt.pts = rtStart;
avpkt.duration = 0;
m_pSubtitlePacket->data = pOut;
m_pSubtitlePacket->size = pOut_size;
m_pSubtitlePacket->pts = rtStart;
m_pSubtitlePacket->duration = 0;

int ret = avcodec_decode_subtitle2(m_pAVCtx, &sub, &got_sub, &avpkt);
int ret = avcodec_decode_subtitle2(m_pAVCtx, &sub, &got_sub, m_pSubtitlePacket);
if (ret < 0) {
DbgLog((LOG_TRACE, 50, L"CLAVSubtitleProvider::Decode - decoding failed despite successfull parsing"));
got_sub = 0;
Expand Down
2 changes: 2 additions & 0 deletions decoder/LAVVideo/subtitles/LAVSubtitleProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ class CLAVSubtitleProvider
ULONGLONG m_SubPicId = 0;
BOOL m_bComposit = TRUE;

AVPacket *m_pSubtitlePacket = nullptr;

std::list<CLAVSubRect *> m_SubFrames;

struct _AM_PROPERTY_SPHLI *m_pHLI = nullptr;
Expand Down
23 changes: 11 additions & 12 deletions demuxer/Demuxers/BDDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,12 @@ STDMETHODIMP CBDDemuxer::FillMVCExtensionQueue(REFERENCE_TIME rtBase)
int ret, count = 0;
bool found = (rtBase == Packet::INVALID_TIME);

AVPacket mvcPacket = {0};
av_init_packet(&mvcPacket);
AVPacket *pMVCPacket = av_packet_alloc();

while (count < MVC_DEMUX_COUNT)
{
ret = av_read_frame(m_MVCFormatContext, &mvcPacket);
av_packet_unref(pMVCPacket);
ret = av_read_frame(m_MVCFormatContext, pMVCPacket);

if (ret == AVERROR(EINTR) || ret == AVERROR(EAGAIN))
{
Expand All @@ -479,19 +479,18 @@ STDMETHODIMP CBDDemuxer::FillMVCExtensionQueue(REFERENCE_TIME rtBase)
DbgLog((LOG_TRACE, 10, L"EOF reading MVC extension data"));
break;
}
else if (mvcPacket.size <= 0 || mvcPacket.stream_index != m_MVCStreamIndex)
else if (pMVCPacket->size <= 0 || pMVCPacket->stream_index != m_MVCStreamIndex)
{
av_packet_unref(&mvcPacket);
continue;
}
else
{
AVStream *stream = m_MVCFormatContext->streams[mvcPacket.stream_index];
AVStream *stream = m_MVCFormatContext->streams[pMVCPacket->stream_index];

REFERENCE_TIME rtDTS =
m_lavfDemuxer->ConvertTimestampToRT(mvcPacket.dts, stream->time_base.num, stream->time_base.den);
m_lavfDemuxer->ConvertTimestampToRT(pMVCPacket->dts, stream->time_base.num, stream->time_base.den);
REFERENCE_TIME rtPTS =
m_lavfDemuxer->ConvertTimestampToRT(mvcPacket.pts, stream->time_base.num, stream->time_base.den);
m_lavfDemuxer->ConvertTimestampToRT(pMVCPacket->pts, stream->time_base.num, stream->time_base.den);

if (rtBase == Packet::INVALID_TIME || rtDTS == Packet::INVALID_TIME)
{
Expand All @@ -502,7 +501,6 @@ STDMETHODIMP CBDDemuxer::FillMVCExtensionQueue(REFERENCE_TIME rtBase)
DbgLog((LOG_TRACE, 10,
L"CBDDemuxer::FillMVCExtensionQueue(): Dropping MVC extension at %I64d, base is %I64d", rtDTS,
rtBase));
av_packet_unref(&mvcPacket);
continue;
}
else if (rtDTS == rtBase)
Expand All @@ -513,21 +511,22 @@ STDMETHODIMP CBDDemuxer::FillMVCExtensionQueue(REFERENCE_TIME rtBase)
Packet *pPacket = new Packet();
if (!pPacket)
{
av_packet_unref(&mvcPacket);
av_packet_free(&pMVCPacket);
return E_OUTOFMEMORY;
}

pPacket->SetPacket(&mvcPacket);
pPacket->SetPacket(pMVCPacket);
pPacket->rtDTS = rtDTS;
pPacket->rtPTS = rtPTS;

m_lavfDemuxer->QueueMVCExtension(pPacket);
av_packet_unref(&mvcPacket);

count++;
}
};

av_packet_free(&pMVCPacket);

if (found)
return S_OK;
else if (count > 0)
Expand Down

0 comments on commit 8e3fcaf

Please sign in to comment.