mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
ext/gdk_pixbuf/gstgdkpixbuf.c: Fix logic bug causing spurious errors.
Original commit message from CVS: * ext/gdk_pixbuf/gstgdkpixbuf.c: (gst_gdk_pixbuf_sink_link), (gst_gdk_pixbuf_chain): Fix logic bug causing spurious errors. * ext/jpeg/gstjpegdec.c: (gst_jpegdec_base_init), (gst_jpegdec_init), (gst_jpegdec_chain): Fix negotiation. * ext/jpeg/gstjpegenc.c: (gst_jpegenc_base_init), (gst_jpegenc_class_init), (gst_jpegenc_init), (gst_jpegenc_getcaps), (gst_jpegenc_link), (gst_jpegenc_resync), (gst_jpegenc_chain), (gst_jpegenc_set_property), (gst_jpegenc_get_property): Fix negotiation. Add some properties. * ext/jpeg/gstjpegenc.h: Fix negotiation.
This commit is contained in:
parent
b1c2fb3ab7
commit
f30ceaa645
5 changed files with 199 additions and 76 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2004-02-11 David Schleef <ds@schleef.org>
|
||||||
|
|
||||||
|
* ext/gdk_pixbuf/gstgdkpixbuf.c: (gst_gdk_pixbuf_sink_link),
|
||||||
|
(gst_gdk_pixbuf_chain): Fix logic bug causing spurious errors.
|
||||||
|
* ext/jpeg/gstjpegdec.c: (gst_jpegdec_base_init),
|
||||||
|
(gst_jpegdec_init), (gst_jpegdec_chain): Fix negotiation.
|
||||||
|
* ext/jpeg/gstjpegenc.c: (gst_jpegenc_base_init),
|
||||||
|
(gst_jpegenc_class_init), (gst_jpegenc_init),
|
||||||
|
(gst_jpegenc_getcaps), (gst_jpegenc_link), (gst_jpegenc_resync),
|
||||||
|
(gst_jpegenc_chain), (gst_jpegenc_set_property),
|
||||||
|
(gst_jpegenc_get_property): Fix negotiation. Add some properties.
|
||||||
|
* ext/jpeg/gstjpegenc.h: Fix negotiation.
|
||||||
|
|
||||||
2004-02-10 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
2004-02-10 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||||
|
|
||||||
* ext/mikmod/gstmikmod.c: (gst_mikmod_init),
|
* ext/mikmod/gstmikmod.c: (gst_mikmod_init),
|
||||||
|
|
|
@ -109,7 +109,7 @@ gst_gdk_pixbuf_sink_link (GstPad *pad, const GstCaps *caps)
|
||||||
g_return_val_if_fail (GST_IS_GDK_PIXBUF (filter),
|
g_return_val_if_fail (GST_IS_GDK_PIXBUF (filter),
|
||||||
GST_PAD_LINK_REFUSED);
|
GST_PAD_LINK_REFUSED);
|
||||||
|
|
||||||
filter->framerate = 0.0;
|
filter->framerate = 1.0;
|
||||||
gst_structure_get_double (gst_caps_get_structure (caps, 0), "framerate",
|
gst_structure_get_double (gst_caps_get_structure (caps, 0), "framerate",
|
||||||
&filter->framerate);
|
&filter->framerate);
|
||||||
|
|
||||||
|
@ -285,9 +285,9 @@ gst_gdk_pixbuf_chain (GstPad *pad, GstData *_data)
|
||||||
if (filter->pixbuf_loader != NULL) {
|
if (filter->pixbuf_loader != NULL) {
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
GError *error;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (gdk_pixbuf_loader_close (filter->pixbuf_loader, &error)) {
|
if (!gdk_pixbuf_loader_close (filter->pixbuf_loader, &error)) {
|
||||||
GST_ELEMENT_ERROR (filter, LIBRARY, SHUTDOWN, (NULL), (error->message));
|
GST_ELEMENT_ERROR (filter, LIBRARY, SHUTDOWN, (NULL), (error->message));
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
#include "gstjpegdec.h"
|
#include "gstjpegdec.h"
|
||||||
#include <gst/video/video.h>
|
#include <gst/video/video.h>
|
||||||
|
|
||||||
static GstPadTemplate *jpegdec_src_template, *jpegdec_sink_template;
|
|
||||||
|
|
||||||
/* elementfactory information */
|
/* elementfactory information */
|
||||||
GstElementDetails gst_jpegdec_details = {
|
GstElementDetails gst_jpegdec_details = {
|
||||||
"JPEG image decoder",
|
"JPEG image decoder",
|
||||||
|
@ -80,39 +78,35 @@ gst_jpegdec_get_type(void) {
|
||||||
return jpegdec_type;
|
return jpegdec_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstCaps*
|
static GstStaticPadTemplate gst_jpegdec_src_pad_template =
|
||||||
jpeg_caps_factory (void)
|
GST_STATIC_PAD_TEMPLATE (
|
||||||
{
|
"src",
|
||||||
return gst_caps_new_simple ("image/jpeg",
|
GST_PAD_SRC,
|
||||||
"width", GST_TYPE_INT_RANGE, 16, 4096,
|
GST_PAD_ALWAYS,
|
||||||
"height", GST_TYPE_INT_RANGE, 16, 4096,
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV("I420"))
|
||||||
"framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE,
|
);
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps*
|
static GstStaticPadTemplate gst_jpegdec_sink_pad_template =
|
||||||
raw_caps_factory (void)
|
GST_STATIC_PAD_TEMPLATE (
|
||||||
{
|
"sink",
|
||||||
return gst_caps_from_string (GST_VIDEO_CAPS_YUV ("I420"));
|
GST_PAD_SINK,
|
||||||
}
|
GST_PAD_ALWAYS,
|
||||||
|
GST_STATIC_CAPS ("image/jpeg, "
|
||||||
|
"width = (int) [ 16, 4096 ], "
|
||||||
|
"height = (int) [ 16, 4096 ], "
|
||||||
|
"framerate = (double) [ 1, MAX ]"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_jpegdec_base_init (gpointer g_class)
|
gst_jpegdec_base_init (gpointer g_class)
|
||||||
{
|
{
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||||
GstCaps *raw_caps, *jpeg_caps;
|
|
||||||
|
|
||||||
raw_caps = raw_caps_factory ();
|
gst_element_class_add_pad_template (element_class,
|
||||||
jpeg_caps = jpeg_caps_factory ();
|
gst_static_pad_template_get (&gst_jpegdec_src_pad_template));
|
||||||
|
gst_element_class_add_pad_template (element_class,
|
||||||
jpegdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
|
gst_static_pad_template_get (&gst_jpegdec_sink_pad_template));
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
jpeg_caps);
|
|
||||||
jpegdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
raw_caps);
|
|
||||||
gst_element_class_add_pad_template (element_class, jpegdec_sink_template);
|
|
||||||
gst_element_class_add_pad_template (element_class, jpegdec_src_template);
|
|
||||||
gst_element_class_set_details (element_class, &gst_jpegdec_details);
|
gst_element_class_set_details (element_class, &gst_jpegdec_details);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,11 +156,15 @@ gst_jpegdec_init (GstJpegDec *jpegdec)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("gst_jpegdec_init: initializing");
|
GST_DEBUG ("gst_jpegdec_init: initializing");
|
||||||
/* create the sink and src pads */
|
/* create the sink and src pads */
|
||||||
jpegdec->sinkpad = gst_pad_new_from_template (jpegdec_sink_template, "sink");
|
|
||||||
|
jpegdec->sinkpad = gst_pad_new_from_template (
|
||||||
|
gst_static_pad_template_get (&gst_jpegdec_sink_pad_template), "sink");
|
||||||
gst_element_add_pad(GST_ELEMENT(jpegdec),jpegdec->sinkpad);
|
gst_element_add_pad(GST_ELEMENT(jpegdec),jpegdec->sinkpad);
|
||||||
gst_pad_set_chain_function(jpegdec->sinkpad,gst_jpegdec_chain);
|
gst_pad_set_chain_function(jpegdec->sinkpad,gst_jpegdec_chain);
|
||||||
gst_pad_set_link_function(jpegdec->sinkpad, gst_jpegdec_link);
|
gst_pad_set_link_function(jpegdec->sinkpad, gst_jpegdec_link);
|
||||||
jpegdec->srcpad = gst_pad_new_from_template (jpegdec_src_template, "src");
|
|
||||||
|
jpegdec->srcpad = gst_pad_new_from_template (
|
||||||
|
gst_static_pad_template_get (&gst_jpegdec_src_pad_template), "src");
|
||||||
gst_pad_use_explicit_caps (jpegdec->srcpad);
|
gst_pad_use_explicit_caps (jpegdec->srcpad);
|
||||||
gst_element_add_pad(GST_ELEMENT(jpegdec),jpegdec->srcpad);
|
gst_element_add_pad(GST_ELEMENT(jpegdec),jpegdec->srcpad);
|
||||||
|
|
||||||
|
@ -404,19 +402,22 @@ gst_jpegdec_chain (GstPad *pad, GstData *_data)
|
||||||
outdata = GST_BUFFER_DATA(outbuf) = g_malloc(outsize);
|
outdata = GST_BUFFER_DATA(outbuf) = g_malloc(outsize);
|
||||||
GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf);
|
GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf);
|
||||||
|
|
||||||
if (jpegdec->height != height) {
|
if (jpegdec->height != height || jpegdec->line[0] == NULL) {
|
||||||
|
GstCaps *caps;
|
||||||
|
|
||||||
jpegdec->line[0] = g_realloc(jpegdec->line[0], height*sizeof(char*));
|
jpegdec->line[0] = g_realloc(jpegdec->line[0], height*sizeof(char*));
|
||||||
jpegdec->line[1] = g_realloc(jpegdec->line[1], height*sizeof(char*));
|
jpegdec->line[1] = g_realloc(jpegdec->line[1], height*sizeof(char*));
|
||||||
jpegdec->line[2] = g_realloc(jpegdec->line[2], height*sizeof(char*));
|
jpegdec->line[2] = g_realloc(jpegdec->line[2], height*sizeof(char*));
|
||||||
jpegdec->height = height;
|
jpegdec->height = height;
|
||||||
|
|
||||||
gst_pad_set_explicit_caps (jpegdec->srcpad,
|
caps = gst_caps_new_simple ("video/x-raw-yuv",
|
||||||
gst_caps_new_simple ("video/x-raw-yuv",
|
|
||||||
"format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I','4','2','0'),
|
"format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I','4','2','0'),
|
||||||
"width", G_TYPE_INT, width,
|
"width", G_TYPE_INT, width,
|
||||||
"height", G_TYPE_INT, height,
|
"height", G_TYPE_INT, height,
|
||||||
"framerate", G_TYPE_DOUBLE, jpegdec->fps,
|
"framerate", G_TYPE_DOUBLE, jpegdec->fps,
|
||||||
NULL));
|
NULL);
|
||||||
|
gst_pad_set_explicit_caps (jpegdec->srcpad, caps);
|
||||||
|
gst_caps_free (caps);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mind the swap, jpeglib outputs blue chroma first */
|
/* mind the swap, jpeglib outputs blue chroma first */
|
||||||
|
|
|
@ -43,6 +43,8 @@ enum {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ARG_0,
|
ARG_0,
|
||||||
|
ARG_QUALITY,
|
||||||
|
ARG_SMOOTHING,
|
||||||
/* FILL ME */
|
/* FILL ME */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,12 +54,14 @@ static void gst_jpegenc_init (GstJpegEnc *jpegenc);
|
||||||
|
|
||||||
static void gst_jpegenc_chain (GstPad *pad, GstData *_data);
|
static void gst_jpegenc_chain (GstPad *pad, GstData *_data);
|
||||||
static GstPadLinkReturn gst_jpegenc_link (GstPad *pad, const GstCaps *caps);
|
static GstPadLinkReturn gst_jpegenc_link (GstPad *pad, const GstCaps *caps);
|
||||||
|
static GstCaps * gst_jpegenc_getcaps (GstPad *pad);
|
||||||
|
|
||||||
static void gst_jpegenc_resync (GstJpegEnc *jpegenc);
|
static void gst_jpegenc_resync (GstJpegEnc *jpegenc);
|
||||||
|
static void gst_jpegenc_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec);
|
||||||
|
static void gst_jpegenc_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
static guint gst_jpegenc_signals[LAST_SIGNAL] = { 0 };
|
static guint gst_jpegenc_signals[LAST_SIGNAL] = { 0 };
|
||||||
static GstPadTemplate *jpegenc_src_template, *jpegenc_sink_template;
|
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_jpegenc_get_type (void)
|
gst_jpegenc_get_type (void)
|
||||||
|
@ -81,40 +85,35 @@ gst_jpegenc_get_type (void)
|
||||||
return jpegenc_type;
|
return jpegenc_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstCaps*
|
static GstStaticPadTemplate gst_jpegenc_sink_pad_template =
|
||||||
jpeg_caps_factory (void)
|
GST_STATIC_PAD_TEMPLATE (
|
||||||
{
|
"sink",
|
||||||
return gst_caps_new_simple ("video/x-jpeg",
|
GST_PAD_SINK,
|
||||||
"width", GST_TYPE_INT_RANGE, 16, 4096,
|
GST_PAD_ALWAYS,
|
||||||
"height", GST_TYPE_INT_RANGE, 16, 4096,
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV("I420"))
|
||||||
"framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE,
|
);
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps*
|
static GstStaticPadTemplate gst_jpegenc_src_pad_template =
|
||||||
raw_caps_factory (void)
|
GST_STATIC_PAD_TEMPLATE (
|
||||||
{
|
"src",
|
||||||
return gst_caps_from_string (GST_VIDEO_CAPS_YUV ("I420"));
|
GST_PAD_SRC,
|
||||||
}
|
GST_PAD_ALWAYS,
|
||||||
|
GST_STATIC_CAPS ("image/jpeg, "
|
||||||
|
"width = (int) [ 16, 4096 ], "
|
||||||
|
"height = (int) [ 16, 4096 ], "
|
||||||
|
"framerate = (double) [ 1, MAX ]"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_jpegenc_base_init (gpointer g_class)
|
gst_jpegenc_base_init (gpointer g_class)
|
||||||
{
|
{
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||||
GstCaps *raw_caps, *jpeg_caps;
|
|
||||||
|
|
||||||
raw_caps = raw_caps_factory ();
|
gst_element_class_add_pad_template (element_class,
|
||||||
jpeg_caps = jpeg_caps_factory ();
|
gst_static_pad_template_get (&gst_jpegenc_sink_pad_template));
|
||||||
|
gst_element_class_add_pad_template (element_class,
|
||||||
jpegenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
|
gst_static_pad_template_get (&gst_jpegenc_src_pad_template));
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
raw_caps);
|
|
||||||
jpegenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
jpeg_caps);
|
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class, jpegenc_sink_template);
|
|
||||||
gst_element_class_add_pad_template (element_class, jpegenc_src_template);
|
|
||||||
gst_element_class_set_details (element_class, &gst_jpegenc_details);
|
gst_element_class_set_details (element_class, &gst_jpegenc_details);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,6 +133,18 @@ gst_jpegenc_class_init (GstJpegEnc *klass)
|
||||||
G_STRUCT_OFFSET (GstJpegEncClass, frame_encoded), NULL, NULL,
|
G_STRUCT_OFFSET (GstJpegEncClass, frame_encoded), NULL, NULL,
|
||||||
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, ARG_QUALITY,
|
||||||
|
g_param_spec_int ("quality", "Quality", "Quality of encoding",
|
||||||
|
0, 100, 85, G_PARAM_READWRITE));
|
||||||
|
#if 0
|
||||||
|
/* disabled, since it doesn't seem to work */
|
||||||
|
g_object_class_install_property (gobject_class, ARG_SMOOTHING,
|
||||||
|
g_param_spec_int ("smoothing", "Smoothing", "Smoothing factor",
|
||||||
|
0, 100, 0, G_PARAM_READWRITE));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gobject_class->set_property = gst_jpegenc_set_property;
|
||||||
|
gobject_class->get_property = gst_jpegenc_get_property;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -158,11 +169,17 @@ static void
|
||||||
gst_jpegenc_init (GstJpegEnc *jpegenc)
|
gst_jpegenc_init (GstJpegEnc *jpegenc)
|
||||||
{
|
{
|
||||||
/* create the sink and src pads */
|
/* create the sink and src pads */
|
||||||
jpegenc->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
|
jpegenc->sinkpad = gst_pad_new_from_template (
|
||||||
gst_element_add_pad(GST_ELEMENT(jpegenc),jpegenc->sinkpad);
|
gst_static_pad_template_get (&gst_jpegenc_sink_pad_template), "sink");
|
||||||
gst_pad_set_chain_function(jpegenc->sinkpad,gst_jpegenc_chain);
|
gst_pad_set_chain_function(jpegenc->sinkpad,gst_jpegenc_chain);
|
||||||
|
gst_pad_set_getcaps_function(jpegenc->sinkpad, gst_jpegenc_getcaps);
|
||||||
|
gst_pad_set_link_function(jpegenc->sinkpad, gst_jpegenc_link);
|
||||||
|
gst_element_add_pad(GST_ELEMENT(jpegenc),jpegenc->sinkpad);
|
||||||
|
|
||||||
|
jpegenc->srcpad = gst_pad_new_from_template (
|
||||||
|
gst_static_pad_template_get (&gst_jpegenc_src_pad_template), "src");
|
||||||
|
gst_pad_set_getcaps_function(jpegenc->sinkpad, gst_jpegenc_getcaps);
|
||||||
gst_pad_set_link_function(jpegenc->sinkpad, gst_jpegenc_link);
|
gst_pad_set_link_function(jpegenc->sinkpad, gst_jpegenc_link);
|
||||||
jpegenc->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
|
||||||
gst_element_add_pad(GST_ELEMENT(jpegenc),jpegenc->srcpad);
|
gst_element_add_pad(GST_ELEMENT(jpegenc),jpegenc->srcpad);
|
||||||
|
|
||||||
/* reset the initial video state */
|
/* reset the initial video state */
|
||||||
|
@ -187,6 +204,35 @@ gst_jpegenc_init (GstJpegEnc *jpegenc)
|
||||||
jpegenc->jdest.term_destination = gst_jpegenc_term_destination;
|
jpegenc->jdest.term_destination = gst_jpegenc_term_destination;
|
||||||
jpegenc->cinfo.dest = &jpegenc->jdest;
|
jpegenc->cinfo.dest = &jpegenc->jdest;
|
||||||
|
|
||||||
|
jpegenc->quality = 85;
|
||||||
|
jpegenc->smoothing = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GstCaps *
|
||||||
|
gst_jpegenc_getcaps (GstPad *pad)
|
||||||
|
{
|
||||||
|
GstJpegEnc *jpegenc = GST_JPEGENC (gst_pad_get_parent (pad));
|
||||||
|
GstPad *otherpad;
|
||||||
|
GstCaps *caps;
|
||||||
|
const char *name;
|
||||||
|
int i;
|
||||||
|
GstStructure *structure;
|
||||||
|
|
||||||
|
otherpad = (pad == jpegenc->srcpad) ? jpegenc->sinkpad : jpegenc->srcpad;
|
||||||
|
caps = gst_pad_get_allowed_caps (otherpad);
|
||||||
|
if (pad == jpegenc->srcpad) {
|
||||||
|
name = "image/jpeg";
|
||||||
|
} else {
|
||||||
|
name = "video/x-raw-yuv";
|
||||||
|
}
|
||||||
|
for (i=0;i<gst_caps_get_size (caps); i++){
|
||||||
|
structure = gst_caps_get_structure (caps, i);
|
||||||
|
|
||||||
|
gst_structure_set_name (structure, name);
|
||||||
|
gst_structure_remove_field (structure, "format");
|
||||||
|
}
|
||||||
|
|
||||||
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstPadLinkReturn
|
static GstPadLinkReturn
|
||||||
|
@ -194,19 +240,32 @@ gst_jpegenc_link (GstPad *pad, const GstCaps *caps)
|
||||||
{
|
{
|
||||||
GstJpegEnc *jpegenc = GST_JPEGENC (gst_pad_get_parent (pad));
|
GstJpegEnc *jpegenc = GST_JPEGENC (gst_pad_get_parent (pad));
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
GstPadLinkReturn ret;
|
||||||
|
GstCaps *othercaps;
|
||||||
|
GstPad *otherpad;
|
||||||
|
|
||||||
|
otherpad = (pad == jpegenc->srcpad) ? jpegenc->sinkpad : jpegenc->srcpad;
|
||||||
|
|
||||||
structure = gst_caps_get_structure (caps, 0);
|
structure = gst_caps_get_structure (caps, 0);
|
||||||
gst_structure_get_double (structure, "framerate", &jpegenc->fps);
|
gst_structure_get_double (structure, "framerate", &jpegenc->fps);
|
||||||
gst_structure_get_int (structure, "width", &jpegenc->width);
|
gst_structure_get_int (structure, "width", &jpegenc->width);
|
||||||
gst_structure_get_int (structure, "height", &jpegenc->height);
|
gst_structure_get_int (structure, "height", &jpegenc->height);
|
||||||
|
|
||||||
caps = gst_caps_new_simple ("video/x-jpeg",
|
othercaps = gst_caps_copy (gst_pad_get_pad_template_caps (otherpad));
|
||||||
|
gst_caps_set_simple (othercaps,
|
||||||
"width", G_TYPE_INT, jpegenc->width,
|
"width", G_TYPE_INT, jpegenc->width,
|
||||||
"height", G_TYPE_INT, jpegenc->height,
|
"height", G_TYPE_INT, jpegenc->height,
|
||||||
"framerate", G_TYPE_DOUBLE, jpegenc->fps,
|
"framerate", G_TYPE_DOUBLE, jpegenc->fps,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
return gst_pad_try_set_caps (jpegenc->srcpad, caps);
|
ret = gst_pad_try_set_caps (jpegenc->srcpad, othercaps);
|
||||||
|
gst_caps_free(othercaps);
|
||||||
|
|
||||||
|
if (GST_PAD_LINK_SUCCESSFUL (ret)) {
|
||||||
|
gst_jpegenc_resync (jpegenc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -225,11 +284,11 @@ gst_jpegenc_resync (GstJpegEnc *jpegenc)
|
||||||
|
|
||||||
jpeg_set_defaults(&jpegenc->cinfo);
|
jpeg_set_defaults(&jpegenc->cinfo);
|
||||||
jpegenc->cinfo.dct_method = JDCT_FASTEST;
|
jpegenc->cinfo.dct_method = JDCT_FASTEST;
|
||||||
/*jpegenc->cinfo.dct_method = JDCT_DEFAULT; */
|
/*jpegenc->cinfo.dct_method = JDCT_DEFAULT;*/
|
||||||
/*jpegenc->cinfo.smoothing_factor = 10; */
|
/*jpegenc->cinfo.smoothing_factor = jpegenc->smoothing; */
|
||||||
jpeg_set_quality(&jpegenc->cinfo, 85, TRUE);
|
jpeg_set_quality(&jpegenc->cinfo, jpegenc->quality, TRUE);
|
||||||
|
|
||||||
/*
|
#if 0
|
||||||
switch (jpegenc->format) {
|
switch (jpegenc->format) {
|
||||||
case GST_COLORSPACE_RGB24:
|
case GST_COLORSPACE_RGB24:
|
||||||
size = 3;
|
size = 3;
|
||||||
|
@ -238,6 +297,7 @@ gst_jpegenc_resync (GstJpegEnc *jpegenc)
|
||||||
jpegenc->cinfo.raw_data_in = FALSE;
|
jpegenc->cinfo.raw_data_in = FALSE;
|
||||||
break;
|
break;
|
||||||
case GST_COLORSPACE_YUV420P:
|
case GST_COLORSPACE_YUV420P:
|
||||||
|
#endif
|
||||||
size = 2;
|
size = 2;
|
||||||
jpegenc->cinfo.raw_data_in = TRUE;
|
jpegenc->cinfo.raw_data_in = TRUE;
|
||||||
jpegenc->cinfo.in_color_space = JCS_YCbCr;
|
jpegenc->cinfo.in_color_space = JCS_YCbCr;
|
||||||
|
@ -256,6 +316,7 @@ gst_jpegenc_resync (GstJpegEnc *jpegenc)
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG ("gst_jpegenc_resync: setting format done");
|
GST_DEBUG ("gst_jpegenc_resync: setting format done");
|
||||||
|
#if 0
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("gst_jpegenc_resync: unsupported colorspace, using RGB\n");
|
printf("gst_jpegenc_resync: unsupported colorspace, using RGB\n");
|
||||||
|
@ -263,11 +324,11 @@ gst_jpegenc_resync (GstJpegEnc *jpegenc)
|
||||||
jpegenc->cinfo.in_color_space = JCS_RGB;
|
jpegenc->cinfo.in_color_space = JCS_RGB;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*/
|
#endif
|
||||||
jpegenc->bufsize = jpegenc->width*jpegenc->height*size;
|
jpegenc->bufsize = jpegenc->width*jpegenc->height*size;
|
||||||
jpegenc->row_stride = width * size;
|
|
||||||
|
|
||||||
jpeg_suppress_tables(&jpegenc->cinfo, TRUE);
|
jpeg_suppress_tables(&jpegenc->cinfo, TRUE);
|
||||||
|
//jpeg_suppress_tables(&jpegenc->cinfo, FALSE);
|
||||||
|
|
||||||
jpegenc->buffer = NULL;
|
jpegenc->buffer = NULL;
|
||||||
GST_DEBUG ("gst_jpegenc_resync: resync done");
|
GST_DEBUG ("gst_jpegenc_resync: resync done");
|
||||||
|
@ -315,6 +376,8 @@ gst_jpegenc_chain (GstPad *pad, GstData *_data)
|
||||||
jpegenc->jdest.next_output_byte = outdata;
|
jpegenc->jdest.next_output_byte = outdata;
|
||||||
jpegenc->jdest.free_in_buffer = outsize;
|
jpegenc->jdest.free_in_buffer = outsize;
|
||||||
|
|
||||||
|
jpegenc->cinfo.smoothing_factor = jpegenc->smoothing;
|
||||||
|
jpeg_set_quality(&jpegenc->cinfo, jpegenc->quality, TRUE);
|
||||||
jpeg_start_compress(&jpegenc->cinfo, TRUE);
|
jpeg_start_compress(&jpegenc->cinfo, TRUE);
|
||||||
|
|
||||||
width2 = width>>1;
|
width2 = width>>1;
|
||||||
|
@ -340,3 +403,47 @@ gst_jpegenc_chain (GstPad *pad, GstData *_data)
|
||||||
|
|
||||||
gst_buffer_unref(buf);
|
gst_buffer_unref(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_jpegenc_set_property (GObject * object, guint prop_id,
|
||||||
|
const GValue * value, GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
GstJpegEnc *jpegenc;
|
||||||
|
|
||||||
|
g_return_if_fail (GST_IS_JPEGENC (object));
|
||||||
|
jpegenc = GST_JPEGENC (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case ARG_QUALITY:
|
||||||
|
jpegenc->quality = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
case ARG_SMOOTHING:
|
||||||
|
jpegenc->smoothing = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_jpegenc_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
|
GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
GstJpegEnc *jpegenc;
|
||||||
|
|
||||||
|
g_return_if_fail (GST_IS_JPEGENC (object));
|
||||||
|
jpegenc = GST_JPEGENC (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case ARG_QUALITY:
|
||||||
|
g_value_set_int (value, jpegenc->quality);
|
||||||
|
break;
|
||||||
|
case ARG_SMOOTHING:
|
||||||
|
g_value_set_int (value, jpegenc->smoothing);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,8 @@ struct _GstJpegEnc {
|
||||||
struct jpeg_error_mgr jerr;
|
struct jpeg_error_mgr jerr;
|
||||||
struct jpeg_destination_mgr jdest;
|
struct jpeg_destination_mgr jdest;
|
||||||
|
|
||||||
|
int quality;
|
||||||
|
int smoothing;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstJpegEncClass {
|
struct _GstJpegEncClass {
|
||||||
|
|
Loading…
Reference in a new issue