omxvideodec: support interlace-mode=interleaved input
[platform/upstream/gstreamer.git] / omx / gstomxmpeg4videodec.c
1 /*
2  * Copyright (C) 2011, Hewlett-Packard Development Company, L.P.
3  *   Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>, Collabora Ltd.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation
8  * version 2.1 of the License.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
18  *
19  */
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include <gst/gst.h>
26
27 #include "gstomxmpeg4videodec.h"
28
29 GST_DEBUG_CATEGORY_STATIC (gst_omx_mpeg4_video_dec_debug_category);
30 #define GST_CAT_DEFAULT gst_omx_mpeg4_video_dec_debug_category
31
32 /* prototypes */
33 static gboolean gst_omx_mpeg4_video_dec_is_format_change (GstOMXVideoDec * dec,
34     GstOMXPort * port, GstVideoCodecState * state);
35 static gboolean gst_omx_mpeg4_video_dec_set_format (GstOMXVideoDec * dec,
36     GstOMXPort * port, GstVideoCodecState * state);
37
38 enum
39 {
40   PROP_0
41 };
42
43 /* class initialization */
44
45 #define DEBUG_INIT \
46   GST_DEBUG_CATEGORY_INIT (gst_omx_mpeg4_video_dec_debug_category, "omxmpeg4videodec", 0, \
47       "debug category for gst-omx video decoder base class");
48
49 G_DEFINE_TYPE_WITH_CODE (GstOMXMPEG4VideoDec, gst_omx_mpeg4_video_dec,
50     GST_TYPE_OMX_VIDEO_DEC, DEBUG_INIT);
51
52
53 static void
54 gst_omx_mpeg4_video_dec_class_init (GstOMXMPEG4VideoDecClass * klass)
55 {
56   GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
57   GstOMXVideoDecClass *videodec_class = GST_OMX_VIDEO_DEC_CLASS (klass);
58
59   videodec_class->is_format_change =
60       GST_DEBUG_FUNCPTR (gst_omx_mpeg4_video_dec_is_format_change);
61   videodec_class->set_format =
62       GST_DEBUG_FUNCPTR (gst_omx_mpeg4_video_dec_set_format);
63
64   videodec_class->cdata.default_sink_template_caps = "video/mpeg, "
65       "mpegversion=(int) 4, "
66       "systemstream=(boolean) false, "
67       "parsed=(boolean) true, " "width=(int) [1,MAX], " "height=(int) [1,MAX]";
68
69   gst_element_class_set_static_metadata (element_class,
70       "OpenMAX MPEG4 Video Decoder",
71       "Codec/Decoder/Video/Hardware",
72       "Decode MPEG4 video streams",
73       "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
74
75   gst_omx_set_default_role (&videodec_class->cdata, "video_decoder.mpeg4");
76 }
77
78 static void
79 gst_omx_mpeg4_video_dec_init (GstOMXMPEG4VideoDec * self)
80 {
81 }
82
83 static gboolean
84 gst_omx_mpeg4_video_dec_is_format_change (GstOMXVideoDec * dec,
85     GstOMXPort * port, GstVideoCodecState * state)
86 {
87   return FALSE;
88 }
89
90 static gboolean
91 gst_omx_mpeg4_video_dec_set_format (GstOMXVideoDec * dec, GstOMXPort * port,
92     GstVideoCodecState * state)
93 {
94   gboolean ret;
95   OMX_PARAM_PORTDEFINITIONTYPE port_def;
96
97   gst_omx_port_get_port_definition (port, &port_def);
98   port_def.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4;
99   ret = gst_omx_port_update_port_definition (port, &port_def) == OMX_ErrorNone;
100
101   return ret;
102 }