From ffc375869b1c4f3f5f44d9151b60c8ffeffe769d Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Tue, 22 Oct 2013 01:14:58 +0200 Subject: [PATCH] raspi: add support for MPEG2 TODO: check if the MPEG2 license is present (and warn if not) --- raspi/avdec.cpp | 18 ++++++++++++++++++ raspi/avdec.h | 1 + raspi/video.cpp | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/raspi/avdec.cpp b/raspi/avdec.cpp index 28868ba..f851f7e 100644 --- a/raspi/avdec.cpp +++ b/raspi/avdec.cpp @@ -60,6 +60,7 @@ static AVRational omx_timebase = {1,1000000}; static struct codecs_t codecs; static struct omx_pipeline_t omxpipe; +static OMX_VIDEO_CODINGTYPE vcodectype; extern cDemux *audioDemux; extern cDemux *videoDemux; @@ -269,6 +270,22 @@ int AVDec::pig(int x, int y, int w, int h) return -1; } +int AVDec::set_videoformat(int format) +{ + lt_info("AVDec::set_videoformat(%d)\n", format); + switch (format) { + case 0: + vcodectype = OMX_VIDEO_CodingMPEG2; + break; + case 1: + vcodectype = OMX_VIDEO_CodingAVC; + break; + default: + return -1; + } + return 0; +} + typedef struct { Dec *d; bool audio; @@ -463,6 +480,7 @@ void vDec::run() hal_set_threadname("hal:vdec"); lt_info("====================== start video decoder thread ================================\n"); int ret = 0; + codecs.vcodec.vcodectype = vcodectype; codec_new_channel(&codecs.vcodec); codecs.vcodec.first_packet = 1; codecs.vcodec.is_running = 1; diff --git a/raspi/avdec.h b/raspi/avdec.h index 2c4f5d4..8063604 100644 --- a/raspi/avdec.h +++ b/raspi/avdec.h @@ -32,4 +32,5 @@ public: int show_picture(const char *filename); int set_aspect(int aspect, int mode); int pig(int x, int y, int w, int h); + int set_videoformat(int format); }; diff --git a/raspi/video.cpp b/raspi/video.cpp index 92d3585..f95317c 100644 --- a/raspi/video.cpp +++ b/raspi/video.cpp @@ -175,7 +175,7 @@ void cVideo::SetSyncMode(AVSYNC_TYPE) int cVideo::SetStreamType(VIDEO_FORMAT v) { v_format = v; - return 0; + return avdec->set_videoformat(v); } bool cVideo::GetScreenImage(unsigned char * &data, int &xres, int &yres, bool get_video, bool get_osd, bool scale_to_video)