HACK! added a hack to support mpeg2 video format
authorChandramohan C <chandramohan.c@ti.com>
Fri, 6 Sep 2013 08:32:53 +0000 (08:32 +0000)
committerChandramohan <a0131763@ti.com>
Fri, 6 Sep 2013 08:33:11 +0000 (14:03 +0530)
Padded width and height are same as width and height for mpeg2 format
this is a hack to support it and only 720p video is tested.

demux.c cleaned up and moved generic include headers to demux.h

Signed-off-by: Chandramohan C <chandramohan.c@ti.com>
util/demux.c
util/demux.h
viddec3test.c

index 4e36f1a41d66c8309e38fbc819c86b8325c8af6e..c043848e8ed60e43324bb60e736aec915b14a27a 100644 (file)
 #include "config.h"
 #endif
 
-#include <libavformat/avformat.h>
-#include <libavcodec/avcodec.h>
 
+#include "demux.h"
 #include "util.h"
 
-struct demux {
-       AVFormatContext *afc;
-       AVStream *st;
-       AVCodecContext *cc;
-       AVBitStreamFilterContext *bsf;
-};
-
 static AVFormatContext *
 open_file(const char *filename)
 {
@@ -89,7 +81,7 @@ static struct demux * open_stream(const char * filename, int *width, int *height
        AVBitStreamFilterContext *bsf = NULL;
        struct demux *demux;
 
-       if (cc->codec_id != CODEC_ID_H264) {
+       if ((cc->codec_id != CODEC_ID_H264) &&  (cc->codec_id != CODEC_ID_MPEG2VIDEO)){
                ERROR("could not open '%s': unsupported codec %d", filename, cc->codec_id);
                return NULL;
        }
index 56538494ec009816837435dccd515c8c5db257bc..cec9a611c029a14226527ac43726e07c068f9625 100644 (file)
 #ifndef __DEMUX_H__
 #define __DEMUX_H__
 
-struct demux;
+#include <libavformat/avformat.h>
+#include <libavcodec/avcodec.h>
 
+
+struct demux {
+    AVFormatContext *afc;
+    AVStream *st;
+    AVCodecContext *cc;
+    AVBitStreamFilterContext *bsf;
+};
 struct demux * demux_init(const char * filename, int *width, int *height);
 int demux_read(struct demux *demux, char *input, int size);
 int demux_rewind(struct demux *demux);
index 630674218fac8193ee50fd29ce78eb140b1b986b..53004f1d7d54c45bf07293dce2f055066b1b1ecd 100644 (file)
@@ -157,8 +157,16 @@ decoder_open(int argc, char **argv)
        /* calculate output buffer parameters: */
        width  = ALIGN2 (width, 4);        /* round up to macroblocks */
        height = ALIGN2 (height, 4);       /* round up to macroblocks */
-       padded_width  = ALIGN2 (width + (2*PADX), 7);
-       padded_height = height + 4*PADY;
+
+       if (decoder->demux->cc->codec_id == CODEC_ID_MPEG2VIDEO) {
+                padded_width = width;
+                padded_height= height;
+        }
+        else {
+                padded_width  = ALIGN2 (width + (2*PADX), 7);
+                padded_height = height + 4*PADY;
+        }
+
        decoder->num_outBuf   = MIN(16, 32768 / ((width/16) * (height/16))) + 3;
        decoder->padded_width = padded_width;
        decoder->padded_height = padded_height;
@@ -221,8 +229,14 @@ decoder_open(int argc, char **argv)
        decoder->params->numOutputDataUnits = 0;
        decoder->params->errorInfoMode    = IVIDEO_ERRORINFO_OFF;
 
-        decoder->codec = VIDDEC3_create(decoder->engine,
+       if (decoder->demux->cc->codec_id == CODEC_ID_MPEG2VIDEO) {
+            decoder->codec = VIDDEC3_create(decoder->engine,
+                                        "ivahd_mpeg2vdec", decoder->params);
+        }
+        else if (decoder->demux->cc->codec_id == CODEC_ID_H264) {
+            decoder->codec = VIDDEC3_create(decoder->engine,
                                         "ivahd_h264dec", decoder->params);
+        }
 
        if (!decoder->codec) {
                ERROR("%p: could not create codec", decoder);