Commit c125059f authored by Wim Taymans's avatar Wim Taymans
Browse files

Added the excellent mpeg2dec decoder. Not 100% optimized but allready very fast.

Original commit message from CVS:
Added the excellent mpeg2dec decoder. Not 100% optimized but allready
very fast.
More cleanup.
parent dbe262df
......@@ -432,6 +432,7 @@ plugins/mpeg2/ac3parse/Makefile
# cheap trick to build . first...
SUBDIRS = . types meta elements xml
SUBDIRS = . types meta elements
......@@ -15,7 +15,9 @@
pthread_key_t _cothread_key = -1;
cothread_state *cothread_create(cothread_context *ctx) {
cothread_create (cothread_context *ctx)
cothread_state *s;
DEBUG("cothread: pthread_self() %ld\n",pthread_self());
......@@ -50,25 +52,32 @@ cothread_state *cothread_create(cothread_context *ctx) {
return s;
void cothread_setfunc(cothread_state *thread,cothread_func func,int argc,char **argv) {
cothread_setfunc (cothread_state *thread,
cothread_func func,
int argc,
char **argv)
thread->func = func;
thread->argc = argc;
thread->argv = argv;
thread->pc = (int *)func;
cothread_context *cothread_init() {
cothread_init (void)
cothread_context *ctx = (cothread_context *)malloc(sizeof(cothread_context));
if (_cothread_key == -1) {
if (pthread_key_create(&_cothread_key,NULL) != 0) {
if (pthread_key_create (&_cothread_key,NULL) != 0) {
perror ("pthread_key_create");
return NULL;
pthread_setspecific (_cothread_key,ctx);
memset (ctx->threads,0,sizeof(ctx->threads));
ctx->threads[0] = (cothread_state *)malloc(sizeof(cothread_state));
ctx->threads[0]->ctx = ctx;
......@@ -89,12 +98,16 @@ cothread_context *cothread_init() {
return ctx;
cothread_state *cothread_main(cothread_context *ctx) {
// fprintf(stderr,"returning %p, the 0th cothread\n",ctx->threads[0]);
cothread_main(cothread_context *ctx)
DEBUG(stderr,"returning %p, the 0th cothread\n",ctx->threads[0]);
return ctx->threads[0];
void cothread_stub() {
cothread_stub (void)
cothread_context *ctx = pthread_getspecific(_cothread_key);
register cothread_state *thread = ctx->threads[ctx->current];
......@@ -109,7 +122,9 @@ void cothread_stub() {
//printf("uh, yeah, we shouldn't be here, but we should deal anyway\n");
void cothread_switch(cothread_state *thread) {
cothread_switch (cothread_state *thread)
cothread_context *ctx;
cothread_state *current;
int enter;
......@@ -12,10 +12,10 @@
#define CURRENT_STACK_FRAME ({ char __csf; &__csf; })
typedef struct _cothread_state cothread_state;
typedef struct _cothread_context cothread_context;
typedef struct _cothread_state cothread_state;
typedef struct _cothread_context cothread_context;
typedef int (*cothread_func)(int argc,char **argv);
typedef int (*cothread_func) (int argc,char **argv);
......@@ -40,10 +40,11 @@ struct _cothread_context {
int current;
cothread_context *cothread_init();
cothread_state *cothread_create(cothread_context *ctx);
void cothread_setfunc(cothread_state *thread,cothread_func func,int argc,char **argv);
void cothread_switch(cothread_state *thread);
cothread_state *cothread_main(cothread_context *ctx);
cothread_context* cothread_init();
cothread_state* cothread_create (cothread_context *ctx);
void cothread_setfunc (cothread_state *thread, cothread_func func,
int argc, char **argv);
void cothread_switch (cothread_state *thread);
cothread_state* cothread_main (cothread_context *ctx);
#endif /* __COTHREAD_H__ */
......@@ -29,33 +29,35 @@ extern gint _gst_trace_on;
* Initializes the GStreamer library, setting up internal path lists,
* registering built-in elements, and loading standard plugins.
void gst_init(int *argc,char **argv[]) {
gst_init (int *argc, char **argv[])
GstTrace *gst_trace;
if (!g_thread_supported()) g_thread_init (NULL);
if (!g_thread_supported ()) g_thread_init (NULL);
gtk_init (argc,argv);
_gst_cpu_initialize ();
_gst_type_initialize ();
_gst_plugin_initialize ();
_gst_buffer_initialize ();
/* register some standard builtin types */
gst_elementfactory_register (gst_elementfactory_new ("bin",
gst_bin_get_type (), &gst_bin_details));
gst_elementfactory_register (gst_elementfactory_new ("pipeline",
gst_pipeline_get_type (), &gst_pipeline_details));
gst_elementfactory_register (gst_elementfactory_new("thread",
gst_thread_get_type (), &gst_thread_details));
_gst_trace_on = 0;
if (_gst_trace_on) {
gst_trace = gst_trace_new("gst.trace",1024);
gst_trace = gst_trace_new ("gst.trace",1024);
gst_trace_set_default (gst_trace);
......@@ -64,8 +66,10 @@ void gst_init(int *argc,char **argv[]) {
* Enter the main GStreamer processing loop
void gst_main() {
gst_main (void)
gtk_main ();
......@@ -73,6 +77,8 @@ void gst_main() {
* Exits the main GStreamer processing loop
void gst_main_quit() {
gst_main_quit (void)
gtk_main_quit ();
......@@ -51,8 +51,8 @@
/* initialize GST */
void gst_init(int *argc,char **argv[]);
void gst_main();
void gst_main_quit();
void gst_main (void);
void gst_main_quit (void);
/* debugging */
#ifndef DEBUG
This diff is collapsed.
......@@ -34,7 +34,6 @@ extern "C" {
extern GstElementDetails gst_bin_details;
#define GST_TYPE_BIN \
#define GST_BIN(obj) \
......@@ -68,42 +67,41 @@ struct _GstBin {
struct _GstBinClass {
GstElementClass parent_class;
void (*object_added) (GstObject *object,GstObject *child);
void (*object_added) (GstObject *object, GstObject *child);
/* change the state of elements of the given type */
gboolean (*change_state_type) (GstBin *bin,
GstElementState state,
GtkType type);
gboolean (*change_state_type) (GstBin *bin,
GstElementState state,
GtkType type);
/* create a plan for the execution of the bin */
void (*create_plan) (GstBin *bin);
void (*create_plan) (GstBin *bin);
/* run a full iteration of operation */
void (*iterate) (GstBin *bin);
void (*iterate) (GstBin *bin);
GtkType gst_bin_get_type(void);
GstElement *gst_bin_new(gchar *name);
#define gst_bin_destroy(bin) gst_object_destroy(GST_OBJECT(bin))
GtkType gst_bin_get_type (void);
GstElement* gst_bin_new (gchar *name);
#define gst_bin_destroy(bin) gst_object_destroy(GST_OBJECT(bin))
/* add and remove elements from the bin */
void gst_bin_add(GstBin *bin,GstElement *element);
void gst_bin_remove(GstBin *bin,GstElement *element);
void gst_bin_add (GstBin *bin, GstElement *element);
void gst_bin_remove (GstBin *bin, GstElement *element);
/* retrieve a single element or the while list of children */
GstElement *gst_bin_get_by_name(GstBin *bin,gchar *name);
GList *gst_bin_get_list(GstBin *bin);
/* retrieve a single element or the list of children */
GstElement* gst_bin_get_by_name (GstBin *bin, gchar *name);
GList* gst_bin_get_list (GstBin *bin);
/* set the state for only elements of the given type */
gboolean gst_bin_set_state_type(GstBin *bin,
GstElementState state,
GtkType type);
void gst_bin_create_plan (GstBin *bin);
gboolean gst_bin_set_state_type (GstBin *bin,
GstElementState state,
GtkType type);
void gst_bin_iterate(GstBin *bin);
void gst_bin_create_plan(GstBin *bin);
void gst_bin_iterate (GstBin *bin);
// hack FIXME
void gst_bin_use_cothreads(GstBin *bin, gboolean enabled);
void gst_bin_use_cothreads (GstBin *bin, gboolean enabled);
#ifdef __cplusplus
......@@ -108,31 +108,30 @@ struct _GstBuffer {
/* initialisation */
void _gst_buffer_initialize();
void _gst_buffer_initialize (void);
/* creating a new buffer from scratch */
GstBuffer *gst_buffer_new();
GstBuffer *gst_buffer_new_from_pool(GstBufferPool *pool);
GstBuffer* gst_buffer_new (void);
GstBuffer* gst_buffer_new_from_pool (GstBufferPool *pool);
/* creating a subbuffer */
GstBuffer *gst_buffer_create_sub(GstBuffer *parent,guint32 offset,guint32 size);
GstBuffer* gst_buffer_create_sub (GstBuffer *parent, guint32 offset, guint32 size);
/* adding data to a buffer */
GstBuffer *gst_buffer_append(GstBuffer *buffer, GstBuffer *append);
GstBuffer* gst_buffer_append (GstBuffer *buffer, GstBuffer *append);
/* refcounting */
void gst_buffer_ref(GstBuffer *buffer);
void gst_buffer_ref_by_count(GstBuffer *buffer,int count);
void gst_buffer_unref(GstBuffer *buffer);
void gst_buffer_ref (GstBuffer *buffer);
void gst_buffer_ref_by_count (GstBuffer *buffer, int count);
void gst_buffer_unref (GstBuffer *buffer);
/* destroying the buffer */
void gst_buffer_destroy(GstBuffer *buffer);
void gst_buffer_destroy (GstBuffer *buffer);
/* add, retrieve, and remove metadata from the buffer */
void gst_buffer_add_meta(GstBuffer *buffer,GstMeta *meta);
GstMeta *gst_buffer_get_first_meta(GstBuffer *buffer);
GSList *gst_buffer_get_metas(GstBuffer *buffer);
void gst_buffer_remove_meta(GstBuffer *buffer,GstMeta *meta);
void gst_buffer_add_meta (GstBuffer *buffer, GstMeta *meta);
void gst_buffer_remove_meta (GstBuffer *buffer, GstMeta *meta);
GstMeta* gst_buffer_get_first_meta (GstBuffer *buffer);
GSList* gst_buffer_get_metas (GstBuffer *buffer);
#ifdef __cplusplus
......@@ -33,8 +33,8 @@ extern "C" {
typedef struct _GstBufferPool GstBufferPool;
typedef GstBuffer *(*GstBufferPoolCreateFunction) (GstBufferPool *pool, gpointer user_data);
typedef void (*GstBufferPoolDestroyFunction) (GstBufferPool *pool, GstBuffer *buffer, gpointer user_data);
typedef GstBuffer* (*GstBufferPoolCreateFunction) (GstBufferPool *pool, gpointer user_data);
typedef void (*GstBufferPoolDestroyFunction) (GstBufferPool *pool, GstBuffer *buffer, gpointer user_data);
struct _GstBufferPool {
/* will be called when a new buffer is to be created */
......@@ -47,18 +47,22 @@ struct _GstBufferPool {
/* creating a new buffer pool from scratch */
GstBufferPool *gst_buffer_pool_new();
GstBufferPool* gst_buffer_pool_new (void);
/* creating a buffer from the pool */
GstBuffer *gst_buffer_pool_new_buffer(GstBufferPool *pool);
void gst_buffer_pool_destroy_buffer(GstBufferPool *pool, GstBuffer *buffer);
GstBuffer* gst_buffer_pool_new_buffer (GstBufferPool *pool);
void gst_buffer_pool_destroy_buffer (GstBufferPool *pool, GstBuffer *buffer);
/* setting create and destroy functions */
void gst_buffer_pool_set_create_function(GstBufferPool *pool, GstBufferPoolCreateFunction create, gpointer user_data);
void gst_buffer_pool_set_destroy_function(GstBufferPool *pool, GstBufferPoolDestroyFunction destroy, gpointer user_data);
void gst_buffer_pool_set_create_function (GstBufferPool *pool,
GstBufferPoolCreateFunction create,
gpointer user_data);
void gst_buffer_pool_set_destroy_function (GstBufferPool *pool,
GstBufferPoolDestroyFunction destroy,
gpointer user_data);
/* destroying the buffer pool */
void gst_buffer_pool_destroy(GstBufferPool *pool);
void gst_buffer_pool_destroy (GstBufferPool *pool);
#ifdef __cplusplus
......@@ -48,14 +48,14 @@ struct _GstClock {
GMutex *lock;
GstClock *gst_clock_new(gchar *name);
GstClock *gst_clock_get_system(void);
GstClock* gst_clock_new (gchar *name);
GstClock* gst_clock_get_system (void);
void gst_clock_register(GstClock *clock, GstObject *obj);
void gst_clock_set(GstClock *clock, GstClockTime time);
void gst_clock_reset(GstClock *clock);
void gst_clock_wait(GstClock *clock, GstClockTime time, GstObject *obj);
GstClockTimeDiff gst_clock_current_diff(GstClock *clock, GstClockTime time);
void gst_clock_register (GstClock *clock, GstObject *obj);
void gst_clock_set (GstClock *clock, GstClockTime time);
void gst_clock_reset (GstClock *clock);
void gst_clock_wait (GstClock *clock, GstClockTime time, GstObject *obj);
GstClockTimeDiff gst_clock_current_diff (GstClock *clock, GstClockTime time);
#ifdef __cplusplus
......@@ -55,11 +55,10 @@ struct _GstConnectionClass {
void (*push) (GstConnection *connection);
GtkType gst_connection_get_type(void);
GstElement *gst_connection_new(gchar *name);
void gst_connection_push(GstConnection *connection);
GtkType gst_connection_get_type (void);
GstElement* gst_connection_new (gchar *name);
void gst_connection_push (GstConnection *connection);
#ifdef __cplusplus
......@@ -28,8 +28,8 @@ typedef enum {
GST_CPU_FLAG_SSE = (1<<1),
} GstCPUFlags;
void _gst_cpu_initialize();
void _gst_cpu_initialize (void);
GstCPUFlags gst_cpu_get_flags();
GstCPUFlags gst_cpu_get_flags (void);
#endif /* __GST_CPU_H__ */
......@@ -129,8 +129,8 @@ struct _GstElementClass {
GstElementStateReturn (*change_state) (GstElement *element);
/* create or read XML representation of self */
xmlNodePtr (*save_thyself)(GstElement *element,xmlNodePtr parent);
void (*restore_thyself)(GstElement *element, xmlNodePtr self, GHashTable *elements);
xmlNodePtr (*save_thyself) (GstElement *element, xmlNodePtr parent);
void (*restore_thyself) (GstElement *element, xmlNodePtr self, GHashTable *elements);
struct _GstElementDetails {
......@@ -52,8 +52,8 @@ struct _GstFilterClass {
GstElementClass parent_class;
GtkType gst_filter_get_type(void);
GstElement *gst_filter_new(gchar *name);
GtkType gst_filter_get_type (void);
GstElement* gst_filter_new (gchar *name);
#ifdef __cplusplus
......@@ -69,12 +69,12 @@ struct _GstMeta {
GstMeta *gst_meta_new_size(gint size);
#define gst_meta_new(type) (type *)gst_meta_new_size(sizeof(type))
GstMeta* gst_meta_new_size (gint size);
#define gst_meta_new(type) (type *)gst_meta_new_size(sizeof(type))
/* refcounting */
void gst_meta_ref(GstMeta *meta);
void gst_meta_unref(GstMeta *meta);
void gst_meta_ref (GstMeta *meta);
void gst_meta_unref (GstMeta *meta);
#ifdef __cplusplus
......@@ -90,24 +90,21 @@ struct _GstObjectClass {
/* normal GtkObject stuff */
GtkType gst_object_get_type(void);
GstObject* gst_object_new(void);
GtkType gst_object_get_type (void);
GstObject* gst_object_new (void);
/* parentage routines */
void gst_object_set_parent(GstObject *object,GstObject *parent);
GstObject *gst_object_get_parent(GstObject *object);
void gst_object_unparent(GstObject *object);
void gst_object_set_parent (GstObject *object,GstObject *parent);
GstObject* gst_object_get_parent (GstObject *object);
void gst_object_unparent (GstObject *object);
/* refcounting */
//void gst_object_ref(GstObject *object);
#define gst_object_ref(object) gtk_object_ref(GTK_OBJECT(object));
//void gst_object_unref(GstObject *object);
#define gst_object_unref(object) gtk_object_unref(GTK_OBJECT(object));
//void gst_object_sink(GstObject *object);
#define gst_object_sink(object) gtk_object_sink(GTK_OBJECT(object));
#define gst_object_ref(object) gtk_object_ref(GTK_OBJECT(object));
#define gst_object_unref(object) gtk_object_unref(GTK_OBJECT(object));
#define gst_object_sink(object) gtk_object_sink(GTK_OBJECT(object));
/* destroying an object */
#define gst_object_destroy(object) gtk_object_destroy(GTK_OBJECT(object))
#define gst_object_destroy(object) gtk_object_destroy(GTK_OBJECT(object))
#ifdef __cplusplus
......@@ -57,16 +57,16 @@ struct _GstPipelineClass {
GstBinClass parent_class;
GtkType gst_pipeline_get_type(void);
GstElement *gst_pipeline_new(guchar *name);
#define gst_pipeline_destroy(pipeline) gst_object_destroy(GST_OBJECT(pipeline))
GtkType gst_pipeline_get_type (void);
GstElement* gst_pipeline_new (guchar *name);
#define gst_pipeline_destroy(pipeline) gst_object_destroy(GST_OBJECT(pipeline))
gboolean gst_pipeline_autoplug(GstPipeline *pipeline);
void gst_pipeline_add_src (GstPipeline *pipeline, GstElement *src);
void gst_pipeline_add_sink (GstPipeline *pipeline, GstElement *sink);
void gst_pipeline_add_src(GstPipeline *pipeline, GstElement *src);
void gst_pipeline_add_sink(GstPipeline *pipeline, GstElement *sink);
gboolean gst_pipeline_autoplug (GstPipeline *pipeline);
void gst_pipeline_iterate(GstPipeline *pipeline);
void gst_pipeline_iterate (GstPipeline *pipeline);
#ifdef __cplusplus
......@@ -27,8 +27,8 @@
#include <gst/gsttype.h>
#include <gst/gstelement.h>
typedef struct _GstPlugin GstPlugin;
typedef struct _GstPluginElement GstPluginElement;
typedef struct _GstPlugin GstPlugin;
typedef struct _GstPluginElement GstPluginElement;
struct _GstPlugin {
gchar *name; /* name of the plugin */
......@@ -42,28 +42,29 @@ struct _GstPlugin {
typedef GstPlugin * (*GstPluginInitFunc) (GModule *module);
typedef GstPlugin* (*GstPluginInitFunc) (GModule *module);
GstPlugin *gst_plugin_new(gchar *name);
void gst_plugin_set_longname(GstPlugin *plugin,gchar *longname);
void _gst_plugin_initialize (void);
void _gst_plugin_initialize();
void gst_plugin_load_all();
gboolean gst_plugin_load(gchar *name);
gboolean gst_library_load(gchar *name);
gboolean gst_plugin_load_absolute(gchar *name);
GstPlugin* gst_plugin_new (gchar *name);
void gst_plugin_add_factory(GstPlugin *plugin,GstElementFactory *factory);
void gst_plugin_add_type(GstPlugin *plugin,GstTypeFactory *factory);
void gst_plugin_load_all (void);
gboolean gst_plugin_load (gchar *name);
gboolean gst_library_load (gchar *name);
gboolean gst_plugin_load_absolute (gchar *name);
GstPlugin *gst_plugin_find(const gchar *name);
GList *gst_plugin_get_list();
GstElementFactory *gst_plugin_find_elementfactory(gchar *name);
void gst_plugin_set_longname (GstPlugin *plugin, gchar *longname);
void gst_plugin_add_factory (GstPlugin *plugin, GstElementFactory *factory);
void gst_plugin_add_type (GstPlugin *plugin, GstTypeFactory *factory);
GstElementFactory *gst_plugin_load_elementfactory(gchar *name);
void gst_plugin_load_typefactory(gchar *mime);
GstPlugin* gst_plugin_find (const gchar *name);
GList* gst_plugin_get_list (void);
GstElementFactory* gst_plugin_find_elementfactory (gchar *name);
xmlNodePtr gst_plugin_save_thyself(xmlNodePtr parent);
void gst_plugin_load_thyself(xmlNodePtr parent);
GstElementFactory* gst_plugin_load_elementfactory (gchar *name);
void gst_plugin_load_typefactory (gchar *mime);
xmlNodePtr gst_plugin_save_thyself (xmlNodePtr parent);
void gst_plugin_load_thyself (xmlNodePtr parent);
#endif /* __GST_PLUGIN_H__ */
......@@ -41,8 +41,8 @@ extern "C" {
#define GST_IS_SINK_CLASS(obj) \
typedef struct _GstSink GstSink;
typedef struct _GstSinkClass GstSinkClass;
typedef struct _GstSink GstSink;
typedef struct _GstSinkClass GstSinkClass;
struct _GstSink {
GstElement element;
......@@ -52,8 +52,8 @@ struct _GstSinkClass {
GstElementClass parent_class;
GtkType gst_sink_get_type(void);
GstObject *gst_sink_new(gchar *name);
GtkType gst_sink_get_type (void);
GstObject* gst_sink_new (gchar *name);
#ifdef __cplusplus
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment