aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGou, Hongmei2017-02-01 23:56:55 -0600
committerKarthik Ramanan2017-02-14 05:07:16 -0600
commite797c1d832cc8ee1dd66d1683991cb6d7316ed63 (patch)
treec5a1a6c944c13bfb2deda91b464f913a3b837103
parentbd51fbfbf288da80d1a83cad4c03be3e7f0d8c40 (diff)
downloadgst-plugin-ducati-e797c1d832cc8ee1dd66d1683991cb6d7316ed63.tar.gz
gst-plugin-ducati-e797c1d832cc8ee1dd66d1683991cb6d7316ed63.tar.xz
gst-plugin-ducati-e797c1d832cc8ee1dd66d1683991cb6d7316ed63.zip
gstducati: add JPEG Encoder
Signed-off-by: Hongmei Gou <h-gou@ti.com>
-rw-r--r--src/Makefile.am2
-rw-r--r--src/gstducati.c5
-rw-r--r--src/gstducatijpegenc.c170
-rw-r--r--src/gstducatijpegenc.h54
4 files changed, 230 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 14afd19..c33adbb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,6 +10,7 @@ noinst_HEADERS = \
10 gstducatividdec.h \ 10 gstducatividdec.h \
11 gstducatih264enc.h \ 11 gstducatih264enc.h \
12 gstducatimpeg4enc.h \ 12 gstducatimpeg4enc.h \
13 gstducatijpegenc.h \
13 gstducatividenc.h \ 14 gstducatividenc.h \
14 gstducatibufferpriv.h \ 15 gstducatibufferpriv.h \
15 gstducati.h 16 gstducati.h
@@ -24,6 +25,7 @@ libgstducati_la_SOURCES = \
24 gstducatividdec.c \ 25 gstducatividdec.c \
25 gstducatih264enc.c \ 26 gstducatih264enc.c \
26 gstducatimpeg4enc.c \ 27 gstducatimpeg4enc.c \
28 gstducatijpegenc.c \
27 gstducatividenc.c \ 29 gstducatividenc.c \
28 gstducatibufferpriv.c \ 30 gstducatibufferpriv.c \
29 gstducati.c \ 31 gstducati.c \
diff --git a/src/gstducati.c b/src/gstducati.c
index 2a38e79..3e63b72 100644
--- a/src/gstducati.c
+++ b/src/gstducati.c
@@ -30,6 +30,7 @@
30 30
31#include "gstducatih264enc.h" 31#include "gstducatih264enc.h"
32#include "gstducatimpeg4enc.h" 32#include "gstducatimpeg4enc.h"
33#include "gstducatijpegenc.h"
33 34
34 35
35GST_DEBUG_CATEGORY (gst_ducati_debug); 36GST_DEBUG_CATEGORY (gst_ducati_debug);
@@ -83,7 +84,9 @@ plugin_init (GstPlugin * plugin)
83 gst_element_register (plugin, "ducatih264enc", GST_RANK_PRIMARY + 1, 84 gst_element_register (plugin, "ducatih264enc", GST_RANK_PRIMARY + 1,
84 GST_TYPE_DUCATIH264ENC) && 85 GST_TYPE_DUCATIH264ENC) &&
85 gst_element_register (plugin, "ducatimpeg4enc", GST_RANK_PRIMARY + 1, 86 gst_element_register (plugin, "ducatimpeg4enc", GST_RANK_PRIMARY + 1,
86 GST_TYPE_DUCATIMPEG4ENC); 87 GST_TYPE_DUCATIMPEG4ENC) &&
88 gst_element_register (plugin, "ducatijpegenc", GST_RANK_PRIMARY + 1,
89 GST_TYPE_DUCATIJPEGENC);
87} 90}
88 91
89/* PACKAGE: this is usually set by autotools depending on some _INIT macro 92/* PACKAGE: this is usually set by autotools depending on some _INIT macro
diff --git a/src/gstducatijpegenc.c b/src/gstducatijpegenc.c
new file mode 100644
index 0000000..7b2d44f
--- /dev/null
+++ b/src/gstducatijpegenc.c
@@ -0,0 +1,170 @@
1/* GStreamer
2 * Copyright (c) 2017, Texas Instruments Incorporated
3 * Copyright (c) 2011, Collabora Ltd.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
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 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 *
20 * Author: Alessandro Decina <alessandro.decina@collabora.com>
21 * ti <ti@ti.com>
22 */
23
24#ifdef HAVE_CONFIG_H
25#include "config.h"
26#endif
27
28#include "gstducati.h"
29#include "gstducatijpegenc.h"
30
31#include <string.h>
32
33#include <math.h>
34
35#define GST_CAT_DEFAULT gst_ducati_debug
36
37enum
38{
39 LAST_SIGNAL
40};
41
42static gboolean gst_ducati_jpegenc_allocate_params (GstDucatiVidEnc *
43 self, gint params_sz, gint dynparams_sz, gint status_sz, gint inargs_sz,
44 gint outargs_sz);
45static gboolean gst_ducati_jpegenc_configure (GstDucatiVidEnc * self);
46
47
48static GstStaticPadTemplate gst_ducati_jpegenc_sink_template =
49GST_STATIC_PAD_TEMPLATE ("sink",
50 GST_PAD_SINK,
51 GST_PAD_ALWAYS,
52 GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("NV12"))
53 );
54
55static GstStaticPadTemplate gst_ducati_jpegenc_src_template =
56GST_STATIC_PAD_TEMPLATE ("src",
57 GST_PAD_SRC,
58 GST_PAD_ALWAYS,
59 GST_STATIC_CAPS ("image/jpeg, "
60 "parsed = (boolean)true, "
61 "width = (int)[ 32, 4096 ], "
62 "height = (int)[ 32, 4096 ], "
63 "framerate = (fraction)[ 0, max ];")
64 );
65
66#define parent_class gst_ducati_jpegenc_parent_class
67G_DEFINE_TYPE (GstDucatiJPEGEnc, gst_ducati_jpegenc, GST_TYPE_DUCATIVIDENC);
68
69static void
70gst_ducati_jpegenc_class_init (GstDucatiJPEGEncClass * klass)
71{
72 GstDucatiVidEncClass *videnc_class;
73 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
74
75 videnc_class = GST_DUCATIVIDENC_CLASS (klass);
76
77 gst_element_class_add_pad_template (element_class,
78 gst_static_pad_template_get (&gst_ducati_jpegenc_src_template));
79 gst_element_class_add_pad_template (element_class,
80 gst_static_pad_template_get (&gst_ducati_jpegenc_sink_template));
81
82 gst_element_class_set_metadata (element_class, "JPEG Encoder",
83 "Codec/Encoder/Video",
84 "Encode raw video into JPEG stream",
85 "ti <ti@ti.com>");
86
87 GST_DUCATIVIDENC_CLASS (element_class)->codec_name = "ivahd_jpegvenc";
88
89 videnc_class->allocate_params = gst_ducati_jpegenc_allocate_params;
90 videnc_class->configure = gst_ducati_jpegenc_configure;
91}
92
93static void
94gst_ducati_jpegenc_init (GstDucatiJPEGEnc * self)
95{
96 GST_DEBUG ("gst_ducati_jpegenc_init");
97}
98
99static gboolean
100gst_ducati_jpegenc_configure (GstDucatiVidEnc * videnc)
101{
102 GstDucatiJPEGEnc *self = GST_DUCATIJPEGENC (videnc);
103 IJPEGVENC_Params *params;
104 IJPEGVENC_DynamicParams *dynParams;
105 const GstVideoCodecState *state;
106 GstCaps *caps;
107 const char *s;
108 gboolean ret = TRUE;
109
110 if (!GST_DUCATIVIDENC_CLASS (parent_class)->configure (videnc))
111 return FALSE;
112
113 params = (IJPEGVENC_Params *) videnc->params;
114
115 params->maxThumbnailHSizeApp0 = 4096;
116 params->maxThumbnailHSizeApp1 = 4096;
117 params->maxThumbnailVSizeApp0 = 4096;
118 params->maxThumbnailVSizeApp1 = 4096;
119 params->debugTraceLevel = 0;
120
121 params->lastNFramesToLog = 0;
122 params->Markerposition = 0;
123
124 params->rateControlParams.VBRDuration = 8;
125 params->rateControlParams.VBRsensitivity = 0;
126 params->rateControlParams.vbvUseLevelThQ5 = 0;
127
128 params->rateControlParams.rateControlParamsPreset = 1;
129 params->rateControlParams.rcAlgo = 0;
130 params->rateControlParams.qpMaxI = 51;
131 params->rateControlParams.qpMinI = 1;
132 params->rateControlParams.qpI = -1;
133 params->rateControlParams.initialBufferLevel = 10000000;
134 params->rateControlParams.HRDBufferSize = 10000000;
135 params->rateControlParams.discardSavedBits = 0;
136
137 videnc->params->rateControlPreset = 4;
138 videnc->params->maxBitRate = 7500000;
139 videnc->params->minBitRate = 4500000;
140
141 dynParams = (IJPEGVENC_DynamicParams *) videnc->dynParams;
142
143 dynParams->restartInterval = 0;
144 dynParams->qualityFactor = 50;
145 dynParams->quantTable = NULL;
146
147 dynParams->enablePrivacyMasking = 0;
148
149 state = videnc->input_state;
150 caps = gst_caps_new_simple ("image/jpeg",
151 "parsed", G_TYPE_BOOLEAN, TRUE,
152 "width", G_TYPE_INT, videnc->rect.w,
153 "height", G_TYPE_INT, videnc->rect.h,
154 "framerate", GST_TYPE_FRACTION, GST_VIDEO_INFO_FPS_N (&state->info), GST_VIDEO_INFO_FPS_D (&state->info),
155 NULL);
156 ret = gst_pad_set_caps (GST_VIDEO_ENCODER_SRC_PAD (self), caps);
157
158 return ret;
159}
160
161static gboolean
162gst_ducati_jpegenc_allocate_params (GstDucatiVidEnc *
163 videnc, gint params_sz, gint dynparams_sz, gint status_sz, gint inargs_sz,
164 gint outargs_sz)
165{
166 return GST_DUCATIVIDENC_CLASS (parent_class)->allocate_params (videnc,
167 sizeof (IVIDENC2_Params), sizeof (IVIDENC2_DynamicParams),
168 sizeof (IVIDENC2_Status), sizeof (IVIDENC2_InArgs),
169 sizeof (IVIDENC2_OutArgs));
170}
diff --git a/src/gstducatijpegenc.h b/src/gstducatijpegenc.h
new file mode 100644
index 0000000..8f9ce0f
--- /dev/null
+++ b/src/gstducatijpegenc.h
@@ -0,0 +1,54 @@
1/*
2 * GStreamer
3 * Copyright (c) 2017, Texas Instruments Incorporated
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#ifndef __GST_DUCATIJPEGENC_H__
21#define __GST_DUCATIJPEGENC_H__
22
23#include <ti/sdo/codecs/jpegvenc/ijpegenc.h>
24#include "gstducatividenc.h"
25
26#define GST_TYPE_DUCATIJPEGENC \
27 (gst_ducati_jpegenc_get_type())
28#define GST_DUCATIJPEGENC(obj) \
29 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DUCATIJPEGENC,GstDucatiJPEGEnc))
30#define GST_DUCATIJPEGENC_CLASS(klass) \
31 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DUCATIJPEGENC,GstDucatiJPEGEncClass))
32#define GST_IS_DUCATIJPEGENC(obj) \
33 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DUCATIJPEGENC))
34#define GST_IS_DUCATIJPEGENC_CLASS(obj) \
35 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DUCATIJPEGENC))
36#define GST_DUCATIJPEGENC_GET_CLASS(obj) \
37 (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_DUCATIJPEGENC, GstDucatiJPEGEncClass))
38
39typedef struct _GstDucatiJPEGEnc GstDucatiJPEGEnc;
40typedef struct _GstDucatiJPEGEncClass GstDucatiJPEGEncClass;
41
42struct _GstDucatiJPEGEnc
43{
44 GstDucatiVidEnc parent;
45};
46
47struct _GstDucatiJPEGEncClass
48{
49 GstDucatiVidEncClass parent_class;
50};
51
52GType gst_ducati_jpegenc_get_type (void);
53
54#endif