diff options
author | Christian Gmeiner <christian.gmeiner@gmail.com> | 2010-06-29 17:44:28 +0200 |
---|---|---|
committer | Christian Gmeiner <christian.gmeiner@gmail.com> | 2010-06-29 17:44:28 +0200 |
commit | 3ae36c76928283a0ae21d8a78ab556a4d2daaf36 (patch) | |
tree | 37121d0a9ee476379dcc678dd71a70e679c6413b | |
parent | d51aa28273b2a32ecd7e23d0d851ddec5f03578d (diff) | |
download | vdr-plugin-dxr3-3ae36c76928283a0ae21d8a78ab556a4d2daaf36.tar.gz vdr-plugin-dxr3-3ae36c76928283a0ae21d8a78ab556a4d2daaf36.tar.bz2 |
extend decoder to handle mpeg2 video codec
-rw-r--r-- | decoder.c | 19 | ||||
-rw-r--r-- | decoder.h | 2 |
2 files changed, 19 insertions, 2 deletions
@@ -42,15 +42,22 @@ cDecoder::cDecoder() : rbuf(50000), ac3dtsDecoder(&rbuf) avcodec_init(); avcodec_register_all(); - // look for decoder + // look for audio decoder audio = avcodec_find_decoder(CODEC_ID_MP3); - if (!audio) { esyslog("[dxr3-decoder] no suitable audio codec found."); esyslog("[dxr3-decoder] check your ffmpeg installation."); exit(-1); } + // look for video codec + video = avcodec_find_decoder(CODEC_ID_MPEG2VIDEO); + if (!video) { + esyslog("[dxr3-decoder] no suitable video codec found."); + esyslog("[dxr3-decoder] check your ffmpeg installation."); + exit(-1); + } + // create a new codec context contextAudio = avcodec_alloc_context(); int ret = avcodec_open(contextAudio, audio); @@ -60,6 +67,13 @@ cDecoder::cDecoder() : rbuf(50000), ac3dtsDecoder(&rbuf) exit(-1); } + contextVideo = avcodec_alloc_context(); + ret = avcodec_open(contextVideo, video); + if (ret < 0) { + esyslog("[dxr3-decoder] failed to open codec %s.", video->name); + exit(-1); + } + lastBitrate = 0xff; // init with an invalid value - see checkMpegAudioHdr; } @@ -69,6 +83,7 @@ cDecoder::~cDecoder() { // close codec, if it is open avcodec_close(contextAudio); + avcodec_close(contextVideo); } // ================================== @@ -63,7 +63,9 @@ private: int calcFrameSize(const uint8_t *header); AVCodec *audio; + AVCodec *video; AVCodecContext *contextAudio; + AVCodecContext *contextVideo; AVPacket avpkt; cRingBufferFrame rbuf; |