2003-04-21 21:54:27 +00:00
|
|
|
/* GStreamer divx encoder plugin
|
|
|
|
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include "gstdivxenc.h"
|
|
|
|
#include <gst/video/video.h>
|
|
|
|
#include <encore2.h>
|
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ I420, YUY2, YV12, YVYU, UYVY }")
|
2004-03-15 19:32:27 +00:00
|
|
|
/* FIXME: 15/16/24/32bpp RGB */
|
2004-03-14 20:47:18 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("video/x-divx, "
|
2004-03-15 19:32:27 +00:00
|
|
|
"divxversion = (int) 5, "
|
|
|
|
"width = (int) [ 16, 4096 ], "
|
2005-12-19 14:40:22 +00:00
|
|
|
"height = (int) [ 16, 4096 ], " "framerate = (fraction) [0/1, MAX]")
|
2004-03-14 20:47:18 +00:00
|
|
|
);
|
2003-04-21 21:54:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* DivxEnc signals and args */
|
2004-03-14 20:47:18 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-04-21 21:54:27 +00:00
|
|
|
FRAME_ENCODED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-04-21 21:54:27 +00:00
|
|
|
ARG_0,
|
|
|
|
ARG_BITRATE,
|
|
|
|
ARG_MAXKEYINTERVAL,
|
2003-05-30 21:44:53 +00:00
|
|
|
ARG_BUFSIZE,
|
|
|
|
ARG_QUALITY
|
2003-04-21 21:54:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
static void gst_divxenc_class_init (GstDivxEncClass * klass);
|
|
|
|
static void gst_divxenc_base_init (GstDivxEncClass * klass);
|
|
|
|
static void gst_divxenc_init (GstDivxEnc * divxenc);
|
|
|
|
static void gst_divxenc_dispose (GObject * object);
|
2005-12-19 14:40:22 +00:00
|
|
|
static GstFlowReturn gst_divxenc_chain (GstPad * pad, GstBuffer * buf);
|
|
|
|
static gboolean gst_divxenc_setcaps (GstPad * pad, GstCaps * caps);
|
2003-04-21 21:54:27 +00:00
|
|
|
|
|
|
|
/* properties */
|
2004-03-14 20:47:18 +00:00
|
|
|
static void gst_divxenc_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_divxenc_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
2003-04-21 21:54:27 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
static guint gst_divxenc_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
|
2010-03-25 21:48:09 +00:00
|
|
|
static const gchar *
|
2003-05-30 21:44:53 +00:00
|
|
|
gst_divxenc_error (int errorcode)
|
|
|
|
{
|
2010-03-25 21:48:09 +00:00
|
|
|
const gchar *error;
|
2003-05-30 21:44:53 +00:00
|
|
|
|
|
|
|
switch (errorcode) {
|
|
|
|
case ENC_BUFFER:
|
|
|
|
error = "Invalid buffer";
|
|
|
|
break;
|
|
|
|
case ENC_FAIL:
|
|
|
|
error = "Operation failed";
|
|
|
|
break;
|
|
|
|
case ENC_OK:
|
|
|
|
error = "No error";
|
|
|
|
break;
|
|
|
|
case ENC_MEMORY:
|
|
|
|
error = "Bad memory location";
|
|
|
|
break;
|
|
|
|
case ENC_BAD_FORMAT:
|
|
|
|
error = "Invalid format";
|
|
|
|
break;
|
|
|
|
case ENC_INTERNAL:
|
|
|
|
error = "Internal error";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = "Unknown error";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-21 21:54:27 +00:00
|
|
|
GType
|
2004-03-14 20:47:18 +00:00
|
|
|
gst_divxenc_get_type (void)
|
2003-04-21 21:54:27 +00:00
|
|
|
{
|
|
|
|
static GType divxenc_type = 0;
|
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
if (!divxenc_type) {
|
2003-04-21 21:54:27 +00:00
|
|
|
static const GTypeInfo divxenc_info = {
|
2004-03-14 20:47:18 +00:00
|
|
|
sizeof (GstDivxEncClass),
|
2003-11-02 20:37:50 +00:00
|
|
|
(GBaseInitFunc) gst_divxenc_base_init,
|
2003-04-21 21:54:27 +00:00
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_divxenc_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 20:47:18 +00:00
|
|
|
sizeof (GstDivxEnc),
|
2003-04-21 21:54:27 +00:00
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_divxenc_init,
|
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
divxenc_type = g_type_register_static (GST_TYPE_ELEMENT,
|
2004-03-15 19:32:27 +00:00
|
|
|
"GstDivxEnc", &divxenc_info, 0);
|
2003-04-21 21:54:27 +00:00
|
|
|
}
|
|
|
|
return divxenc_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-02 20:37:50 +00:00
|
|
|
static void
|
2004-03-14 20:47:18 +00:00
|
|
|
gst_divxenc_base_init (GstDivxEncClass * klass)
|
2003-11-02 20:37:50 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
2011-11-28 13:08:27 +00:00
|
|
|
gst_element_class_add_static_pad_template (element_class,
|
|
|
|
&sink_template);
|
|
|
|
gst_element_class_add_static_pad_template (element_class, &src_template);
|
2003-11-02 20:37:50 +00:00
|
|
|
|
2010-03-18 16:30:26 +00:00
|
|
|
gst_element_class_set_details_simple (element_class,
|
|
|
|
"Divx4linux video encoder", "Codec/Encoder/Video",
|
|
|
|
"Divx encoder based on divxencore",
|
|
|
|
"Ronald Bultje <rbultje@ronald.bitfreak.net>");
|
2003-11-02 20:37:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-21 21:54:27 +00:00
|
|
|
static void
|
2004-03-14 20:47:18 +00:00
|
|
|
gst_divxenc_class_init (GstDivxEncClass * klass)
|
2003-04-21 21:54:27 +00:00
|
|
|
{
|
2005-12-19 14:40:22 +00:00
|
|
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2005-12-19 14:40:22 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2005-12-19 14:40:22 +00:00
|
|
|
gobject_class->set_property = gst_divxenc_set_property;
|
|
|
|
gobject_class->get_property = gst_divxenc_get_property;
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
|
|
|
|
g_param_spec_ulong ("bitrate", "Bitrate",
|
2010-10-19 13:23:23 +00:00
|
|
|
"Target video bitrate", 0, G_MAXULONG, 0,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAXKEYINTERVAL,
|
2010-10-19 13:23:23 +00:00
|
|
|
g_param_spec_int ("max-key-interval", "Max. Key Interval",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Maximum number of frames between two keyframes",
|
2010-10-19 13:23:23 +00:00
|
|
|
-1, G_MAXINT, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFSIZE,
|
2010-10-19 13:23:23 +00:00
|
|
|
g_param_spec_ulong ("buffer-size", "Buffer Size",
|
|
|
|
"Size of the video buffers", 0, G_MAXULONG, 0,
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
2003-05-30 21:44:53 +00:00
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUALITY,
|
|
|
|
g_param_spec_int ("quality", "Quality",
|
2010-10-19 13:23:23 +00:00
|
|
|
"Amount of Motion Estimation", 1, 5, 3,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2003-04-22 14:55:12 +00:00
|
|
|
gobject_class->dispose = gst_divxenc_dispose;
|
|
|
|
|
2003-04-21 21:54:27 +00:00
|
|
|
gst_divxenc_signals[FRAME_ENCODED] =
|
2004-03-14 20:47:18 +00:00
|
|
|
g_signal_new ("frame-encoded", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GstDivxEncClass, frame_encoded),
|
|
|
|
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2003-04-21 21:54:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2004-03-14 20:47:18 +00:00
|
|
|
gst_divxenc_init (GstDivxEnc * divxenc)
|
2003-04-21 21:54:27 +00:00
|
|
|
{
|
|
|
|
/* create the sink pad */
|
2007-06-22 10:46:33 +00:00
|
|
|
divxenc->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
|
2004-03-14 20:47:18 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (divxenc), divxenc->sinkpad);
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
gst_pad_set_chain_function (divxenc->sinkpad, gst_divxenc_chain);
|
2005-12-19 14:40:22 +00:00
|
|
|
gst_pad_set_setcaps_function (divxenc->sinkpad, gst_divxenc_setcaps);
|
2003-04-21 21:54:27 +00:00
|
|
|
|
|
|
|
/* create the src pad */
|
2007-06-22 10:46:33 +00:00
|
|
|
divxenc->srcpad = gst_pad_new_from_static_template (&src_template, "src");
|
2005-12-19 14:40:22 +00:00
|
|
|
gst_pad_use_fixed_caps (divxenc->srcpad);
|
2004-03-14 20:47:18 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (divxenc), divxenc->srcpad);
|
2003-04-21 21:54:27 +00:00
|
|
|
|
|
|
|
/* bitrate, etc. */
|
2003-05-30 21:44:53 +00:00
|
|
|
divxenc->width = divxenc->height = divxenc->csp = divxenc->bitcnt = -1;
|
2003-04-21 21:54:27 +00:00
|
|
|
divxenc->bitrate = 512 * 1024;
|
2004-03-15 19:32:27 +00:00
|
|
|
divxenc->max_key_interval = -1; /* default - 2*fps */
|
2003-04-21 21:54:27 +00:00
|
|
|
divxenc->buffer_size = 512 * 1024;
|
2003-05-30 21:44:53 +00:00
|
|
|
divxenc->quality = 3;
|
2003-04-21 21:54:27 +00:00
|
|
|
|
|
|
|
/* set divx handle to NULL */
|
|
|
|
divxenc->handle = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 20:47:18 +00:00
|
|
|
gst_divxenc_setup (GstDivxEnc * divxenc)
|
2003-04-21 21:54:27 +00:00
|
|
|
{
|
2003-06-01 13:20:37 +00:00
|
|
|
void *handle = NULL;
|
2003-05-30 21:44:53 +00:00
|
|
|
SETTINGS output;
|
|
|
|
DivXBitmapInfoHeader input;
|
2003-04-21 21:54:27 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* set it up */
|
2004-03-14 20:47:18 +00:00
|
|
|
memset (&input, 0, sizeof (DivXBitmapInfoHeader));
|
|
|
|
input.biSize = sizeof (DivXBitmapInfoHeader);
|
2003-05-30 21:44:53 +00:00
|
|
|
input.biWidth = divxenc->width;
|
|
|
|
input.biHeight = divxenc->height;
|
|
|
|
input.biBitCount = divxenc->bitcnt;
|
|
|
|
input.biCompression = divxenc->csp;
|
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
memset (&output, 0, sizeof (SETTINGS));
|
2003-09-30 20:10:05 +00:00
|
|
|
output.vbr_mode = RCMODE_VBV_1PASS;
|
2003-05-30 21:44:53 +00:00
|
|
|
output.bitrate = divxenc->bitrate;
|
|
|
|
output.quantizer = 0;
|
2003-09-30 20:10:05 +00:00
|
|
|
output.use_bidirect = 1;
|
2003-05-30 21:44:53 +00:00
|
|
|
output.input_clock = 0;
|
|
|
|
output.input_frame_period = 1000000;
|
2005-12-19 14:40:22 +00:00
|
|
|
output.internal_timescale = (divxenc->fps_n / divxenc->fps_d) * 1000000; /* FIX? */
|
2003-05-30 21:44:53 +00:00
|
|
|
output.max_key_interval = (divxenc->max_key_interval == -1) ?
|
2004-03-14 20:47:18 +00:00
|
|
|
150 : divxenc->max_key_interval;
|
2003-09-30 20:10:05 +00:00
|
|
|
output.key_frame_threshold = 50;
|
2003-05-30 21:44:53 +00:00
|
|
|
output.vbv_bitrate = 0;
|
|
|
|
output.vbv_size = 0;
|
|
|
|
output.vbv_occupancy = 0;
|
|
|
|
output.complexity_modulation = 0;
|
|
|
|
output.deinterlace = 0;
|
|
|
|
output.quality = divxenc->quality;
|
|
|
|
output.data_partitioning = 0;
|
2003-09-30 20:10:05 +00:00
|
|
|
output.quarter_pel = 1;
|
2004-03-14 20:47:18 +00:00
|
|
|
output.use_gmc = 1;
|
2003-05-30 21:44:53 +00:00
|
|
|
output.psychovisual = 0;
|
|
|
|
output.pv_strength_frame = 0;
|
|
|
|
output.pv_strength_MB = 0;
|
|
|
|
output.interlace_mode = 0;
|
|
|
|
output.enable_crop = 0;
|
|
|
|
output.enable_resize = 0;
|
2003-09-30 20:10:05 +00:00
|
|
|
output.temporal_enable = 1;
|
|
|
|
output.spatial_passes = 3;
|
|
|
|
output.spatial_level = 1.0;
|
|
|
|
output.temporal_level = 1.0;
|
2003-05-30 21:44:53 +00:00
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
if ((ret = encore (&handle, ENC_OPT_INIT, &input, &output))) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (divxenc, LIBRARY, SETTINGS, (NULL),
|
2004-03-15 19:32:27 +00:00
|
|
|
("Error setting up divx encoder: %s (%d)",
|
|
|
|
gst_divxenc_error (ret), ret));
|
2003-04-21 21:54:27 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-05-30 21:44:53 +00:00
|
|
|
divxenc->handle = handle;
|
|
|
|
|
|
|
|
/* set buffer size to theoretical limit (see docs on divx.com) */
|
|
|
|
divxenc->buffer_size = 6 * divxenc->width * divxenc->height;
|
2003-04-21 21:54:27 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-22 14:55:12 +00:00
|
|
|
static void
|
2004-03-14 20:47:18 +00:00
|
|
|
gst_divxenc_unset (GstDivxEnc * divxenc)
|
2003-04-22 14:55:12 +00:00
|
|
|
{
|
2003-05-30 21:44:53 +00:00
|
|
|
if (divxenc->handle) {
|
2004-03-14 20:47:18 +00:00
|
|
|
encore (divxenc->handle, ENC_OPT_RELEASE, NULL, NULL);
|
2003-05-30 21:44:53 +00:00
|
|
|
divxenc->handle = NULL;
|
|
|
|
}
|
2003-04-22 14:55:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2004-03-14 20:47:18 +00:00
|
|
|
gst_divxenc_dispose (GObject * object)
|
2003-04-22 14:55:12 +00:00
|
|
|
{
|
2004-03-14 20:47:18 +00:00
|
|
|
GstDivxEnc *divxenc = GST_DIVXENC (object);
|
2003-04-22 14:55:12 +00:00
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
gst_divxenc_unset (divxenc);
|
Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, o...
Original commit message from CVS:
* ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose),
(gst_alsa_finalize):
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init),
(gst_cdaudio_finalize):
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init),
(cdparanoia_finalize):
* ext/divx/gstdivxdec.c: (gst_divxdec_dispose):
* ext/divx/gstdivxenc.c: (gst_divxenc_dispose):
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_finalize):
* ext/flac/gstflacdec.c: (gst_flacdec_class_init),
(gst_flacdec_finalize):
* ext/flac/gstflacenc.c: (gst_flacenc_class_init),
(gst_flacenc_finalize):
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init),
(gst_gnomevfssink_finalize):
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init),
(gst_gnomevfssrc_finalize):
* ext/libfame/gstlibfame.c: (gst_fameenc_class_init),
(gst_fameenc_finalize):
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_finalize):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize),
(gst_sdlvideosink_class_init):
* ext/sndfile/gstsf.c: (gst_sf_dispose):
* gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose):
* gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose):
* gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose):
* gst-libs/gst/xwindowlistener/xwindowlistener.c:
(gst_x_window_listener_dispose):
* gst/audioscale/gstaudioscale.c:
* gst/playondemand/gstplayondemand.c: (play_on_demand_class_init),
(play_on_demand_finalize):
* gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_chain):
* sys/cdrom/gstcdplayer.c: (cdplayer_class_init),
(cdplayer_finalize):
* sys/glsink/glimagesink.c: (gst_glimagesink_finalize),
(gst_glimagesink_class_init):
* sys/oss/gstosselement.c: (gst_osselement_class_init),
(gst_osselement_finalize):
* sys/oss/gstosssink.c: (gst_osssink_dispose):
* sys/oss/gstosssrc.c: (gst_osssrc_dispose):
* sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose):
Fixes a bunch of problems with finalize and dispose functions,
either assumptions that dispose is only called once, or not calling
the parent class dispose/finalize function
2004-11-01 14:43:38 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
2003-04-22 14:55:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-19 14:40:22 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_divxenc_chain (GstPad * pad, GstBuffer * buf)
|
2003-04-21 21:54:27 +00:00
|
|
|
{
|
|
|
|
GstDivxEnc *divxenc;
|
|
|
|
GstBuffer *outbuf;
|
|
|
|
ENC_FRAME xframe;
|
|
|
|
ENC_RESULT xres;
|
2005-12-19 14:40:22 +00:00
|
|
|
int res;
|
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2005-12-19 14:40:22 +00:00
|
|
|
divxenc = GST_DIVXENC (gst_pad_get_parent (pad));
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
outbuf = gst_buffer_new_and_alloc (divxenc->buffer_size);
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
|
2003-04-21 21:54:27 +00:00
|
|
|
|
|
|
|
/* encode and so ... */
|
2004-03-14 20:47:18 +00:00
|
|
|
xframe.image = GST_BUFFER_DATA (buf);
|
|
|
|
xframe.bitstream = (void *) GST_BUFFER_DATA (outbuf);
|
2005-12-19 14:40:22 +00:00
|
|
|
xframe.length = GST_BUFFER_SIZE (outbuf); /* GST_BUFFER_MAXSIZE */
|
2003-05-30 21:44:53 +00:00
|
|
|
xframe.produce_empty_frame = 0;
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2005-12-19 14:40:22 +00:00
|
|
|
if ((res = encore (divxenc->handle, ENC_OPT_ENCODE, &xframe, &xres))) {
|
|
|
|
goto not_encoding;
|
2003-04-21 21:54:27 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
GST_BUFFER_SIZE (outbuf) = xframe.length;
|
2003-04-21 21:54:27 +00:00
|
|
|
|
|
|
|
/* go out, multiply! */
|
2005-12-19 14:40:22 +00:00
|
|
|
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (divxenc->srcpad));
|
|
|
|
gst_pad_push (divxenc->srcpad, outbuf);
|
2003-04-21 21:54:27 +00:00
|
|
|
|
|
|
|
/* proclaim destiny */
|
2004-03-14 20:47:18 +00:00
|
|
|
g_signal_emit (G_OBJECT (divxenc), gst_divxenc_signals[FRAME_ENCODED], 0);
|
2003-04-21 21:54:27 +00:00
|
|
|
|
|
|
|
/* until the final judgement */
|
2005-12-19 14:40:22 +00:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
not_encoding:
|
|
|
|
|
|
|
|
GST_ELEMENT_ERROR (divxenc, LIBRARY, ENCODE, (NULL),
|
|
|
|
("Error encoding divx frame: %s (%d)", gst_divxenc_error (res), res));
|
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
gst_buffer_unref (outbuf);
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
done:
|
2004-03-14 20:47:18 +00:00
|
|
|
gst_buffer_unref (buf);
|
2005-12-19 14:40:22 +00:00
|
|
|
gst_object_unref (divxenc);
|
|
|
|
return ret;
|
|
|
|
|
2003-04-21 21:54:27 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
/* FIXME: moving broken bits here for others to fix */
|
|
|
|
/* someone fix RGB please */
|
|
|
|
/*
|
|
|
|
case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
|
|
|
|
gst_caps_get_int (caps, "depth", &d);
|
|
|
|
switch (d) {
|
2005-12-19 14:40:22 +00:00
|
|
|
case 24:
|
|
|
|
divx_cs = 0;
|
|
|
|
bitcnt = 24;
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
divx_cs = 0;
|
|
|
|
bitcnt = 32;
|
|
|
|
break;
|
2004-03-14 20:47:18 +00:00
|
|
|
*/
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2005-12-19 14:40:22 +00:00
|
|
|
static gboolean
|
|
|
|
gst_divxenc_setcaps (GstPad * pad, GstCaps * caps)
|
2003-04-21 21:54:27 +00:00
|
|
|
{
|
|
|
|
GstDivxEnc *divxenc;
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
GstStructure *structure = gst_caps_get_structure (caps, 0);
|
2004-03-14 20:47:18 +00:00
|
|
|
gint w, h;
|
2005-12-19 14:40:22 +00:00
|
|
|
const GValue *fps;
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
guint32 fourcc;
|
|
|
|
guint32 divx_cs;
|
|
|
|
gint bitcnt = 0;
|
2005-12-19 14:40:22 +00:00
|
|
|
gboolean ret = FALSE;
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
divxenc = GST_DIVXENC (gst_pad_get_parent (pad));
|
2003-04-21 21:54:27 +00:00
|
|
|
|
|
|
|
/* if there's something old around, remove it */
|
2004-03-14 20:47:18 +00:00
|
|
|
gst_divxenc_unset (divxenc);
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
gst_structure_get_int (structure, "width", &w);
|
|
|
|
gst_structure_get_int (structure, "height", &h);
|
|
|
|
gst_structure_get_fourcc (structure, "format", &fourcc);
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
|
2005-12-19 14:40:22 +00:00
|
|
|
fps = gst_structure_get_value (structure, "framerate");
|
|
|
|
if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) {
|
|
|
|
divxenc->fps_n = gst_value_get_fraction_numerator (fps);
|
|
|
|
divxenc->fps_d = gst_value_get_fraction_denominator (fps);
|
|
|
|
} else {
|
|
|
|
divxenc->fps_n = -1;
|
|
|
|
}
|
|
|
|
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
switch (fourcc) {
|
2004-03-14 20:47:18 +00:00
|
|
|
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
|
|
|
|
divx_cs = GST_MAKE_FOURCC ('I', '4', '2', '0');
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
break;
|
2004-03-14 20:47:18 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
|
|
|
|
divx_cs = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
break;
|
2004-03-14 20:47:18 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
|
|
|
|
divx_cs = GST_MAKE_FOURCC ('Y', 'V', '1', '2');
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
break;
|
2004-03-14 20:47:18 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
|
|
|
|
divx_cs = GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U');
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
break;
|
2004-03-14 20:47:18 +00:00
|
|
|
case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
|
|
|
|
divx_cs = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
break;
|
|
|
|
default:
|
2005-12-19 14:40:22 +00:00
|
|
|
ret = FALSE;
|
|
|
|
goto done;
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
}
|
2003-07-06 20:49:52 +00:00
|
|
|
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
divxenc->csp = divx_cs;
|
|
|
|
divxenc->bitcnt = bitcnt;
|
|
|
|
divxenc->width = w;
|
|
|
|
divxenc->height = h;
|
|
|
|
|
|
|
|
/* try it */
|
2004-03-14 20:47:18 +00:00
|
|
|
if (gst_divxenc_setup (divxenc)) {
|
2005-12-19 14:40:22 +00:00
|
|
|
GstCaps *new_caps = NULL;
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
|
|
|
|
new_caps = gst_caps_new_simple ("video/x-divx",
|
2004-03-15 19:32:27 +00:00
|
|
|
"divxversion", G_TYPE_INT, 5,
|
|
|
|
"width", G_TYPE_INT, w,
|
2005-12-19 14:40:22 +00:00
|
|
|
"height", G_TYPE_INT, h,
|
|
|
|
"framerate", GST_TYPE_FRACTION, divxenc->fps_n, divxenc->fps_d, NULL);
|
|
|
|
|
|
|
|
if (new_caps) {
|
|
|
|
|
|
|
|
if (!gst_pad_set_caps (divxenc->srcpad, new_caps)) {
|
|
|
|
gst_divxenc_unset (divxenc);
|
|
|
|
ret = FALSE;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
gst_caps_unref (new_caps);
|
|
|
|
ret = TRUE;
|
|
|
|
goto done;
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
|
2003-07-06 20:49:52 +00:00
|
|
|
}
|
2003-04-21 21:54:27 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we got here - it's not good */
|
2005-12-19 14:40:22 +00:00
|
|
|
|
|
|
|
ret = FALSE;
|
|
|
|
|
|
|
|
done:
|
|
|
|
gst_object_unref (divxenc);
|
|
|
|
return ret;
|
2003-04-21 21:54:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2004-03-14 20:47:18 +00:00
|
|
|
gst_divxenc_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec)
|
2003-04-21 21:54:27 +00:00
|
|
|
{
|
2005-12-19 14:40:22 +00:00
|
|
|
GstDivxEnc *divxenc = GST_DIVXENC (object);
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2005-12-19 14:40:22 +00:00
|
|
|
GST_OBJECT_LOCK (divxenc);
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2003-04-22 14:55:12 +00:00
|
|
|
switch (prop_id) {
|
2003-04-21 21:54:27 +00:00
|
|
|
case ARG_BITRATE:
|
2004-03-14 20:47:18 +00:00
|
|
|
divxenc->bitrate = g_value_get_ulong (value);
|
2003-04-21 21:54:27 +00:00
|
|
|
break;
|
|
|
|
case ARG_MAXKEYINTERVAL:
|
2004-03-14 20:47:18 +00:00
|
|
|
divxenc->max_key_interval = g_value_get_int (value);
|
2003-04-21 21:54:27 +00:00
|
|
|
break;
|
2003-05-30 21:44:53 +00:00
|
|
|
case ARG_QUALITY:
|
2004-03-14 20:47:18 +00:00
|
|
|
divxenc->quality = g_value_get_int (value);
|
2003-05-30 21:44:53 +00:00
|
|
|
break;
|
2003-04-21 21:54:27 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2005-12-19 14:40:22 +00:00
|
|
|
|
|
|
|
GST_OBJECT_UNLOCK (divxenc);
|
2003-04-21 21:54:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2004-03-14 20:47:18 +00:00
|
|
|
gst_divxenc_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec)
|
2003-04-21 21:54:27 +00:00
|
|
|
{
|
2005-12-19 14:40:22 +00:00
|
|
|
GstDivxEnc *divxenc = GST_DIVXENC (object);
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2005-12-19 14:40:22 +00:00
|
|
|
GST_OBJECT_LOCK (divxenc);
|
2003-04-21 21:54:27 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_BITRATE:
|
2004-03-14 20:47:18 +00:00
|
|
|
g_value_set_ulong (value, divxenc->bitrate);
|
2003-04-21 21:54:27 +00:00
|
|
|
break;
|
|
|
|
case ARG_BUFSIZE:
|
2004-03-14 20:47:18 +00:00
|
|
|
g_value_set_ulong (value, divxenc->buffer_size);
|
2003-04-21 21:54:27 +00:00
|
|
|
break;
|
|
|
|
case ARG_MAXKEYINTERVAL:
|
2004-03-14 20:47:18 +00:00
|
|
|
g_value_set_int (value, divxenc->max_key_interval);
|
2003-04-21 21:54:27 +00:00
|
|
|
break;
|
2003-05-30 21:44:53 +00:00
|
|
|
case ARG_QUALITY:
|
2004-03-14 20:47:18 +00:00
|
|
|
g_value_set_int (value, divxenc->quality);
|
2003-05-30 21:44:53 +00:00
|
|
|
break;
|
2003-04-21 21:54:27 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-12-19 14:40:22 +00:00
|
|
|
GST_OBJECT_UNLOCK (divxenc);
|
|
|
|
}
|
2003-04-21 21:54:27 +00:00
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 20:47:18 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2003-04-21 21:54:27 +00:00
|
|
|
{
|
2003-05-30 21:44:53 +00:00
|
|
|
int lib_version;
|
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
lib_version = encore (NULL, ENC_OPT_VERSION, 0, 0);
|
2003-05-30 21:44:53 +00:00
|
|
|
if (lib_version != ENCORE_VERSION) {
|
2004-03-14 20:47:18 +00:00
|
|
|
g_warning ("Version mismatch! This plugin was compiled for "
|
2004-03-15 19:32:27 +00:00
|
|
|
"DivX version %d, while your library has version %d!",
|
|
|
|
ENCORE_VERSION, lib_version);
|
2003-04-21 21:54:27 +00:00
|
|
|
return FALSE;
|
2003-11-02 20:37:50 +00:00
|
|
|
}
|
2003-04-21 21:54:27 +00:00
|
|
|
|
2003-11-02 20:37:50 +00:00
|
|
|
/* create an elementfactory for the v4lmjpegsrcparse element */
|
2004-03-14 20:47:18 +00:00
|
|
|
return gst_element_register (plugin, "divxenc",
|
2004-05-12 10:19:19 +00:00
|
|
|
GST_RANK_NONE, GST_TYPE_DIVXENC);
|
2003-04-21 21:54:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-14 20:47:18 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"divxenc",
|
|
|
|
"DivX encoder",
|
|
|
|
plugin_init,
|
|
|
|
"5.03", GST_LICENSE_UNKNOWN, "divx4linux", "http://www.divx.com/");
|