Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Small fixes for decoder
  • Loading branch information
alexp-sssup committed Aug 10, 2010
1 parent ec0f87c commit 4dc2b3f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions decoder.cpp
Expand Up @@ -65,6 +65,8 @@ bool FFMpegVideoDecoder::fillDataAndCheckValidity()
{
frameRate=codecContext->time_base.den;
frameRate/=codecContext->time_base.num;
if(videoCodec==H264) //H264 has half ticks (usually?)
frameRate/=2;
}
else if(frameRate==0)
return false;
Expand All @@ -77,12 +79,13 @@ bool FFMpegVideoDecoder::fillDataAndCheckValidity()
return true;
}

FFMpegVideoDecoder::FFMpegVideoDecoder(LS_VIDEO_CODEC codecId, uint8_t* initdata, uint32_t datalen, float frameRateHint):curBuffer(0),codecContext(NULL),
FFMpegVideoDecoder::FFMpegVideoDecoder(LS_VIDEO_CODEC codecId, uint8_t* initdata, uint32_t datalen, double frameRateHint):curBuffer(0),codecContext(NULL),
mutex("VideoDecoder"),initialized(false)
{
//The tag is the header, initialize decoding
codecContext=avcodec_alloc_context();
AVCodec* codec=NULL;
videoCodec=codecId;
if(codecId==H264)
{
//TODO: serialize access to avcodec_open
Expand Down Expand Up @@ -145,7 +148,7 @@ void FFMpegVideoDecoder::skipUntil(uint32_t time)
while(1)
{
if(buffers.isEmpty())
return;
break;
if(buffers.front().time>=time)
break;
discardFrame();
Expand Down
7 changes: 4 additions & 3 deletions decoder.h
Expand Up @@ -55,7 +55,7 @@ class Decoder
virtual ~Decoder(){}
bool isValid() const
{
return status==VALID;
return status>=VALID;
}
virtual void setFlushing()=0;
void waitFlushed()
Expand All @@ -73,6 +73,7 @@ class VideoDecoder: public Decoder
uint32_t frameHeight;
bool setSize(uint32_t w, uint32_t h);
bool resizeIfNeeded(TextureBuffer& tex);
LS_VIDEO_CODEC videoCodec;
public:
VideoDecoder():resizeGLBuffers(false),frameWidth(0),frameHeight(0),frameRate(0){}
virtual ~VideoDecoder(){}
Expand All @@ -90,7 +91,7 @@ class VideoDecoder: public Decoder
{
return frameHeight;
}
float frameRate;
double frameRate;
};

class NullVideoDecoder: public VideoDecoder
Expand Down Expand Up @@ -146,7 +147,7 @@ class FFMpegVideoDecoder: public VideoDecoder
void setSize(uint32_t w, uint32_t h);
bool fillDataAndCheckValidity();
public:
FFMpegVideoDecoder(LS_VIDEO_CODEC codec, uint8_t* initdata, uint32_t datalen, float frameRateHint);
FFMpegVideoDecoder(LS_VIDEO_CODEC codec, uint8_t* initdata, uint32_t datalen, double frameRateHint);
~FFMpegVideoDecoder();
bool decodeData(uint8_t* data, uint32_t datalen, uint32_t time);
bool discardFrame();
Expand Down

0 comments on commit 4dc2b3f

Please sign in to comment.