Skip to content

Commit

Permalink
changed: only init libavfilter after first decoded frame
Browse files Browse the repository at this point in the history
src buffer needs some parameters from the movie to init
  • Loading branch information
elupus committed Jun 21, 2011
1 parent ad392e9 commit cde7873
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
30 changes: 15 additions & 15 deletions xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
Expand Up @@ -354,28 +354,17 @@ void CDVDVideoCodecFFmpeg::SetDropState(bool bDrop)
unsigned int CDVDVideoCodecFFmpeg::SetFilters(unsigned int flags) unsigned int CDVDVideoCodecFFmpeg::SetFilters(unsigned int flags)
{ {
if(m_pHardware) if(m_pHardware)
return false; return 0;


CStdString filters;
if(flags & FILTER_DEINTERLACE_YADIF) if(flags & FILTER_DEINTERLACE_YADIF)
{ {
if(flags & FILTER_DEINTERLACE_HALFED) if(flags & FILTER_DEINTERLACE_HALFED)
filters = "yadif=0:-1"; m_filters_next = "yadif=0:-1";
else else
filters = "yadif=1:-1"; m_filters_next = "yadif=1:-1";
flags &= ~FILTER_DEINTERLACE_ANY | FILTER_DEINTERLACE_YADIF; flags &= ~FILTER_DEINTERLACE_ANY | FILTER_DEINTERLACE_YADIF;
} }


if (!m_filters.Equals(filters))
{
m_filters = filters;

if(FilterOpen(filters.c_str()) < 0)
{
FilterClose();
return 0;
}
}
return flags; return flags;
} }


Expand Down Expand Up @@ -523,6 +512,14 @@ int CDVDVideoCodecFFmpeg::Decode(BYTE* pData, int iSize, double dts, double pts)
} }
} }


// try to setup new filters
if (!m_filters.Equals(m_filters_next))
{
m_filters = m_filters_next;
if(FilterOpen(m_filters) < 0)
FilterClose();
}

int result; int result;
if(m_pHardware) if(m_pHardware)
result = m_pHardware->Decode(m_pCodecContext, m_pFrame); result = m_pHardware->Decode(m_pCodecContext, m_pFrame);
Expand Down Expand Up @@ -552,6 +549,8 @@ void CDVDVideoCodecFFmpeg::Reset()
m_dllAvUtil.av_free(m_pConvertFrame); m_dllAvUtil.av_free(m_pConvertFrame);
m_pConvertFrame = NULL; m_pConvertFrame = NULL;
} }
m_filters = "";
FilterClose();
} }


bool CDVDVideoCodecFFmpeg::GetPictureCommon(DVDVideoPicture* pDvdVideoPicture) bool CDVDVideoCodecFFmpeg::GetPictureCommon(DVDVideoPicture* pDvdVideoPicture)
Expand Down Expand Up @@ -679,7 +678,8 @@ int CDVDVideoCodecFFmpeg::FilterOpen(const CStdString& filters)
if (m_pFilterGraph) if (m_pFilterGraph)
FilterClose(); FilterClose();


m_filters = filters; if (filters.IsEmpty())
return 0;


if (!(m_pFilterGraph = m_dllAvFilter.avfilter_graph_alloc())) if (!(m_pFilterGraph = m_dllAvFilter.avfilter_graph_alloc()))
{ {
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
Expand Up @@ -86,6 +86,7 @@ class CDVDVideoCodecFFmpeg : public CDVDVideoCodec


AVPicture* m_pConvertFrame; AVPicture* m_pConvertFrame;
CStdString m_filters; CStdString m_filters;
CStdString m_filters_next;
AVFilterGraph* m_pFilterGraph; AVFilterGraph* m_pFilterGraph;
AVFilterContext* m_pFilterIn; AVFilterContext* m_pFilterIn;
AVFilterContext* m_pFilterOut; AVFilterContext* m_pFilterOut;
Expand Down

0 comments on commit cde7873

Please sign in to comment.