From b69a5d17e266401901adf5e62ca7d4f4e94d82e0 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Thu, 5 Apr 2007 18:23:21 +0200 Subject: Added a new callback. This callback is called when a new entry is registered. The plan is register and call back a plugin loader function. --- src/xine-engine/configfile.c | 49 +++++++++++++++++++++++++++++++++----------- src/xine-engine/configfile.h | 19 ++++++++++++++++- 2 files changed, 55 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index 28b44fd51..c7cf30968 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -455,6 +455,8 @@ static void config_reset_value(cfg_entry_t *entry) { entry->num_value = 0; } +static void config_shallow_copy(xine_cfg_entry_t *dest, cfg_entry_t *src); + static cfg_entry_t *config_register_key (config_values_t *this, const char *key, int exp_level, @@ -488,6 +490,14 @@ static cfg_entry_t *config_register_key (config_values_t *this, entry->callback_data = cb_data; } + /* we created a new entry, call the callback */ + if (this->new_entry_cb) { + xine_cfg_entry_t cb_entry; + + config_shallow_copy(&cb_entry, entry); + this->new_entry_cb(this->new_entry_cbdata, &cb_entry); + } + return entry; } @@ -1186,6 +1196,19 @@ static void config_unregister_cb (config_values_t *this, const char *key) { } } +static void config_set_new_entry_callback (config_values_t *this, xine_config_cb_t new_entry_cb, void* cbdata) { + pthread_mutex_lock(&this->config_lock); + this->new_entry_cb = new_entry_cb; + this->new_entry_cbdata = cbdata; + pthread_mutex_unlock(&this->config_lock); +} + +static void config_unset_new_entry_callback (config_values_t *this) { + pthread_mutex_lock(&this->config_lock); + this->new_entry_cb = NULL; + this->new_entry_cbdata = NULL; + pthread_mutex_unlock(&this->config_lock); +} config_values_t *_x_config_init (void) { @@ -1212,18 +1235,20 @@ config_values_t *_x_config_init (void) { pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&this->config_lock, &attr); - this->register_string = config_register_string; - this->register_filename = config_register_filename; - this->register_range = config_register_range; - this->register_enum = config_register_enum; - this->register_num = config_register_num; - this->register_bool = config_register_bool; - this->update_num = config_update_num; - this->update_string = config_update_string; - this->parse_enum = config_parse_enum; - this->lookup_entry = config_lookup_entry; - this->unregister_callback = config_unregister_cb; - this->dispose = config_dispose; + this->register_string = config_register_string; + this->register_filename = config_register_filename; + this->register_range = config_register_range; + this->register_enum = config_register_enum; + this->register_num = config_register_num; + this->register_bool = config_register_bool; + this->update_num = config_update_num; + this->update_string = config_update_string; + this->parse_enum = config_parse_enum; + this->lookup_entry = config_lookup_entry; + this->unregister_callback = config_unregister_cb; + this->dispose = config_dispose; + this->set_new_entry_callback = config_set_new_entry_callback; + this->unset_new_entry_callback = config_unset_new_entry_callback; return this; } diff --git a/src/xine-engine/configfile.h b/src/xine-engine/configfile.h index 859214d1c..e98138fa3 100644 --- a/src/xine-engine/configfile.h +++ b/src/xine-engine/configfile.h @@ -50,6 +50,7 @@ extern "C" { typedef struct cfg_entry_s cfg_entry_t; typedef struct config_values_s config_values_t; + struct cfg_entry_s { cfg_entry_t *next; config_values_t *config; @@ -175,7 +176,7 @@ struct config_values_s { cfg_entry_t* (*lookup_entry) (config_values_t *self, const char *key); /* - * unregister callback function + * unregister entry callback function */ void (*unregister_callback) (config_values_t *self, const char *key); @@ -184,11 +185,27 @@ struct config_values_s { */ void (*dispose) (config_values_t *self); + /* + * callback called when a new config entry is registered + */ + void (*set_new_entry_callback) (config_values_t *self, xine_config_cb_t new_entry_cb, void *cb_data); + + /* + * unregister the callback + */ + void (*unset_new_entry_callback) (config_values_t *self); + /* * config values are stored here: */ cfg_entry_t *first, *last, *cur; + /* + * new entry callback + */ + xine_config_cb_t new_entry_cb; + void *new_entry_cbdata; + /* * mutex for modification to the config */ -- cgit v1.2.3 From 54ad01301df2b562e316a7910436ac1ff7494ac3 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Thu, 5 Apr 2007 19:00:10 +0200 Subject: Defined a callback for config entry registration. The next step is to add the entries to the node. --- src/xine-engine/load_plugins.c | 25 ++++++++++++++++++++++--- src/xine-engine/plugin_catalog.h | 1 + 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index d35eba736..320fc0dd2 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -338,6 +338,7 @@ static void _insert_node (xine_t *this, entry->file = file; entry->ref = 0; entry->priority = 0; /* default priority */ + entry->config_entry_list = NULL; switch (info->type & PLUGIN_TYPE_MASK){ @@ -694,6 +695,17 @@ static inline int _plugin_info_equal(const plugin_info_t *a, return 1; } +/* + * This callback is called by the config entry system when a plugin register a + * new config entry. + */ +static void _new_entry_cb (void *user_data, xine_cfg_entry_t *entry) { + plugin_node_t *node = (plugin_node_t *)user_data; + /* + printf("_new_entry_cb: key %s, plugin id: %s\n", entry->key, node->info->id); + */ +} + static int _load_plugin_class(xine_t *this, plugin_node_t *node, void *data) { @@ -721,9 +733,16 @@ static int _load_plugin_class(xine_t *this, if ((info = dlsym(node->file->lib_handle, "xine_plugin_info"))) { /* TODO: use sigsegv handler */ - while (info->type != PLUGIN_NONE){ - if (_plugin_info_equal(info, target)){ - if ((node->plugin_class = info->init(this, data))) { + while (info->type != PLUGIN_NONE) { + if (_plugin_info_equal(info, target)) { + config_values_t *config = this->config; + + /* the callback is called for each entry registered by this plugin */ + config->set_new_entry_callback(config, _new_entry_cb, node); + node->plugin_class = info->init(this, data); + config->unset_new_entry_callback(config); + + if (node->plugin_class) { inc_file_ref(node->file); return 1; } else { diff --git a/src/xine-engine/plugin_catalog.h b/src/xine-engine/plugin_catalog.h index 5bd1c4701..26905ebff 100644 --- a/src/xine-engine/plugin_catalog.h +++ b/src/xine-engine/plugin_catalog.h @@ -57,6 +57,7 @@ typedef struct { plugin_file_t *file; plugin_info_t *info; void *plugin_class; + xine_list_t *config_entry_list; int ref; /* count intances of plugins */ int priority; } plugin_node_t ; -- cgit v1.2.3 From 90ec5563d6d3ce1abd5fc52d4aee1b0ecf6c7516 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Thu, 5 Apr 2007 19:14:48 +0200 Subject: Filled the config entry list when the callback is called. --- src/xine-engine/load_plugins.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index 320fc0dd2..f4be27587 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -704,6 +704,12 @@ static void _new_entry_cb (void *user_data, xine_cfg_entry_t *entry) { /* printf("_new_entry_cb: key %s, plugin id: %s\n", entry->key, node->info->id); */ + if (!node->config_entry_list) { + node->config_entry_list = xine_list_new(); + } + + xine_list_push_back(node->config_entry_list, (void *)entry->key); + } static int _load_plugin_class(xine_t *this, @@ -2603,6 +2609,10 @@ static void dispose_plugin_list (xine_sarray_t *list) { /* free info structure and string copies */ free (node->info->id); free (node->info); + + if (node->config_entry_list) { + xine_list_delete(node->config_entry_list); + } free (node); } xine_sarray_delete(list); -- cgit v1.2.3 From 42cbd632976d2c9d5293ad03418dce3c7db2797d Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Fri, 6 Apr 2007 15:28:37 +0200 Subject: - Moved base64 stuff to xine-utils. - Added config entry serialization. - Added serialized config entries to the plugin cache. --HG-- rename : src/input/base64.c => src/xine-utils/base64.c rename : src/input/base64.h => src/xine-utils/base64.h --- src/input/Makefile.am | 2 +- src/input/base64.c | 135 ---------------------------- src/input/base64.h | 95 -------------------- src/xine-engine/configfile.c | 136 ++++++++++++++++++++++++++++ src/xine-engine/configfile.h | 15 ++++ src/xine-engine/load_plugins.c | 45 ++++++---- src/xine-utils/Makefile.am | 6 +- src/xine-utils/base64.c | 198 +++++++++++++++++++++++++++++++++++++++++ src/xine-utils/base64.h | 98 ++++++++++++++++++++ src/xine-utils/xineutils.h | 2 + 10 files changed, 483 insertions(+), 249 deletions(-) delete mode 100644 src/input/base64.c delete mode 100644 src/input/base64.h create mode 100644 src/xine-utils/base64.c create mode 100644 src/xine-utils/base64.h (limited to 'src') diff --git a/src/input/Makefile.am b/src/input/Makefile.am index 68adf84be..1b6378efc 100644 --- a/src/input/Makefile.am +++ b/src/input/Makefile.am @@ -126,7 +126,7 @@ xineplug_inp_rtsp_la_LIBADD = $(XINE_LIB) $(PTHREAD_LIBS) libreal/libreal.la lib xineplug_inp_rtsp_la_CFLAGS = $(VISIBILITY_FLAG) $(AM_CFLAGS) xineplug_inp_rtsp_la_LDFLAGS = -avoid-version -module -xineplug_inp_cdda_la_SOURCES = input_cdda.c media_helper.c sha1.c sha1.h base64.c base64.h +xineplug_inp_cdda_la_SOURCES = input_cdda.c media_helper.c sha1.c sha1.h xineplug_inp_cdda_la_LIBADD = $(XINE_LIB) xineplug_inp_cdda_la_CFLAGS = $(VISIBILITY_FLAG) $(AM_CFLAGS) xineplug_inp_cdda_la_LDFLAGS = -avoid-version -module diff --git a/src/input/base64.c b/src/input/base64.c deleted file mode 100644 index 0eccbe84e..000000000 --- a/src/input/base64.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2000 Robert Kaye - * - * This file is part of xine, a free video player. - * - * xine is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * xine 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - * - * Base64 encoding modified for Musicbrainz - * relicensed under the GNU General Public License for use in xine-lib - * - */ -/* -------------------------------------------------------------------------- - - MusicBrainz -- The Internet music metadatabase - - Copyright (C) 2000 Robert Kaye - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser 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 - - $Id: base64.c,v 1.2 2004/05/05 18:44:19 mroi Exp $ - -----------------------------------------------------------------------------*/ -/* - * Program: RFC-822 routines (originally from SMTP) - * - * Author: Mark Crispin - * Networks and Distributed Computing - * Computing & Communications - * University of Washington - * Administration Building, AG-44 - * Seattle, WA 98195 - * Internet: MRC@CAC.Washington.EDU - * - * Date: 27 July 1988 - * Last Edited: 10 September 1998 - * - * Sponsorship: The original version of this work was developed in the - * Symbolic Systems Resources Group of the Knowledge Systems - * Laboratory at Stanford University in 1987-88, and was funded - * by the Biomedical Research Technology Program of the National - * Institutes of Health under grant number RR-00785. - * - * Original version Copyright 1988 by The Leland Stanford Junior University - * Copyright 1998 by the University of Washington - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notices appear in all copies and that both the - * above copyright notices and this permission notice appear in supporting - * documentation, and that the name of the University of Washington or The - * Leland Stanford Junior University not be used in advertising or publicity - * pertaining to distribution of the software without specific, written prior - * permission. This software is made available "as is", and - * THE UNIVERSITY OF WASHINGTON AND THE LELAND STANFORD JUNIOR UNIVERSITY - * DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO THIS SOFTWARE, - * INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF - * WASHINGTON OR THE LELAND STANFORD JUNIOR UNIVERSITY BE LIABLE FOR ANY - * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, TORT (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#include -#include -#include -#include - -#include "base64.h" - - -/* NOTE: This is not true RFC822 anymore. The use of the characters - '/', '+', and '=' is no bueno when the ID will be used as part of a URL. - '_', '.', and '-' have been used instead -*/ - -/* Convert binary contents to BASE64 - * Accepts: source - * length of source - * pointer to return destination length - * Returns: destination as BASE64 - */ - -unsigned char *rfc822_binary (void *src,unsigned long srcl,unsigned long *len) -{ - unsigned char *ret,*d; - unsigned char *s = (unsigned char *) src; - char *v = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._"; - unsigned long i = ((srcl + 2) / 3) * 4; - *len = i += 2 * ((i / 60) + 1); - d = ret = (unsigned char *) malloc ((size_t) ++i); - for (i = 0; srcl; s += 3) { /* process tuplets */ - *d++ = v[s[0] >> 2]; /* byte 1: high 6 bits (1) */ - /* byte 2: low 2 bits (1), high 4 bits (2) */ - *d++ = v[((s[0] << 4) + (--srcl ? (s[1] >> 4) : 0)) & 0x3f]; - /* byte 3: low 4 bits (2), high 2 bits (3) */ - *d++ = srcl ? v[((s[1] << 2) + (--srcl ? (s[2] >> 6) : 0)) & 0x3f] : '-'; - /* byte 4: low 6 bits (3) */ - *d++ = srcl ? v[s[2] & 0x3f] : '-'; - if (srcl) srcl--; /* count third character if processed */ - if ((++i) == 15) { /* output 60 characters? */ - i = 0; /* restart line break count, insert CRLF */ - *d++ = '\015'; *d++ = '\012'; - } - } - *d = '\0'; /* tie off string */ - - return ret; /* return the resulting string */ -} diff --git a/src/input/base64.h b/src/input/base64.h deleted file mode 100644 index 72feef885..000000000 --- a/src/input/base64.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2000 Robert Kaye - * - * This file is part of xine, a free video player. - * - * xine is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * xine 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - * - * Base64 encoding modified for Musicbrainz - * relicensed under the GNU General Public License for use in xine-lib - * - */ -/* -------------------------------------------------------------------------- - - MusicBrainz -- The Internet music metadatabase - - Copyright (C) 2000 Robert Kaye - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser 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 - - $Id: base64.h,v 1.1 2004/05/05 09:11:39 hadess Exp $ - -----------------------------------------------------------------------------*/ -/* - * Program: RFC-822 routines (originally from SMTP) - * - * Author: Mark Crispin - * Networks and Distributed Computing - * Computing & Communications - * University of Washington - * Administration Building, AG-44 - * Seattle, WA 98195 - * Internet: MRC@CAC.Washington.EDU - * - * Date: 27 July 1988 - * Last Edited: 10 September 1998 - * - * Sponsorship: The original version of this work was developed in the - * Symbolic Systems Resources Group of the Knowledge Systems - * Laboratory at Stanford University in 1987-88, and was funded - * by the Biomedical Research Technology Program of the National - * Institutes of Health under grant number RR-00785. - * - * Original version Copyright 1988 by The Leland Stanford Junior University - * Copyright 1998 by the University of Washington - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notices appear in all copies and that both the - * above copyright notices and this permission notice appear in supporting - * documentation, and that the name of the University of Washington or The - * Leland Stanford Junior University not be used in advertising or publicity - * pertaining to distribution of the software without specific, written prior - * permission. This software is made available "as is", and - * THE UNIVERSITY OF WASHINGTON AND THE LELAND STANFORD JUNIOR UNIVERSITY - * DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO THIS SOFTWARE, - * INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF - * WASHINGTON OR THE LELAND STANFORD JUNIOR UNIVERSITY BE LIABLE FOR ANY - * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, TORT (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#ifndef BASE64_H -#define BASE64_H - -unsigned char *rfc822_binary (void *src,unsigned long srcl,unsigned long *len); - -#endif diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index c7cf30968..fce6e4a30 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -1210,6 +1210,139 @@ static void config_unset_new_entry_callback (config_values_t *this) { pthread_mutex_unlock(&this->config_lock); } +static void config_register_entry (config_values_t *this, cfg_entry_t* entry) { + /* FIXME: TODO */ +} + +static int put_int(uint8_t *buffer, int pos, int value) { + int32_t value_int32 = (int32_t)value; + + buffer[pos] = value_int32 & 0xFF; + buffer[pos + 1] = (value_int32 >> 8) & 0xFF; + buffer[pos + 2] = (value_int32 >> 16) & 0xFF; + buffer[pos + 3] = (value_int32 >> 24) & 0xFF; + + return 4; +} + +static int put_string(uint8_t *buffer, int pos, const char *value, int value_len) { + pos += put_int(buffer, pos, value_len); + memcpy(&buffer[pos], value, value_len); + + return 4 + value_len; +} + +static unsigned char* config_serialize_entry (config_values_t *this, const char *key) { + unsigned char *output = NULL; + cfg_entry_t *entry, *prev; + + pthread_mutex_lock(&this->config_lock); + config_lookup_entry_int(this, key, &entry, &prev); + + if (entry) { + /* now serialize this stuff + fields to serialize : + int type; + int range_min; + int range_max; + int exp_level; + char *key; + char *str_default; + char *description; + char *help; + char **enum_values; + */ + + int key_len = 0; + int str_default_len = 0; + int description_len = 0; + int help_len = 0; + + if (entry->key) + key_len = strlen(entry->key); + if (entry->str_default) + str_default_len = strlen(entry->str_default); + if (entry->description) + description_len = strlen(entry->description); + if (entry->help) + help_len = strlen(entry->help); + + // integers + // value: 4 bytes + unsigned long total_len = 4 * sizeof(int32_t); + + // strings (size + char buffer) + // length: 4 bytes + // buffer: length bytes + total_len += sizeof(int32_t) + key_len; + total_len += sizeof(int32_t) + str_default_len; + total_len += sizeof(int32_t) + description_len; + total_len += sizeof(int32_t) + help_len; + + /* enum values... */ + // value count: 4 bytes + // for each value: + // length: 4 bytes + // buffer: length bytes + int value_count = 0; + int value_len[10]; + total_len += sizeof(int32_t); /* value count */ + + char **cur_value = entry->enum_values; + if (cur_value) { + while (*cur_value && (value_count < (sizeof(value_len) / sizeof(int) ))) { + value_len[value_count] = strlen(*cur_value); + total_len += sizeof(int32_t) + value_len[value_count]; + value_count++; + cur_value++; + } + } + + /* Now we have the length needed to serialize the entry and the length of each string */ + uint8_t *buffer = malloc (total_len); + if (!buffer) return NULL; + + /* Let's go */ + int pos = 0; + + // the integers + pos += put_int(buffer, pos, entry->type); + pos += put_int(buffer, pos, entry->range_min); + pos += put_int(buffer, pos, entry->range_max); + pos += put_int(buffer, pos, entry->exp_level); + + // the strings + pos += put_string(buffer, pos, entry->key, key_len); + pos += put_string(buffer, pos, entry->str_default, str_default_len); + pos += put_string(buffer, pos, entry->description, description_len); + pos += put_string(buffer, pos, entry->help, help_len); + + // the enum stuff + pos += put_int(buffer, pos, value_count); + cur_value = entry->enum_values; + + int i; + for (i = 0; i < value_count; i++) { + pos += put_string(buffer, pos, *cur_value, value_len[i]); + cur_value++; + } + + // and now the output encoding + unsigned long output_len; + output = base64_encode (buffer, total_len, &output_len); + + free(buffer); + } + pthread_mutex_unlock(&this->config_lock); + + return output; +} + +static cfg_entry_t* config_deserialize_entry (config_values_t *this, const char *value) { + /* FIXME: TODO */ + return NULL; +} + config_values_t *_x_config_init (void) { #ifdef HAVE_IRIXAL @@ -1249,6 +1382,9 @@ config_values_t *_x_config_init (void) { this->dispose = config_dispose; this->set_new_entry_callback = config_set_new_entry_callback; this->unset_new_entry_callback = config_unset_new_entry_callback; + this->register_entry = config_register_entry; + this->serialize_entry = config_serialize_entry; + this->deserialize_entry = config_deserialize_entry; return this; } diff --git a/src/xine-engine/configfile.h b/src/xine-engine/configfile.h index e98138fa3..e1416432b 100644 --- a/src/xine-engine/configfile.h +++ b/src/xine-engine/configfile.h @@ -157,6 +157,8 @@ struct config_values_s { xine_config_cb_t changed_cb, void *cb_data); + void (*register_entry) (config_values_t *self, cfg_entry_t* entry); + /* convenience function to update range, enum, num and bool values */ void (*update_num) (config_values_t *self, const char *key, int value); @@ -195,6 +197,19 @@ struct config_values_s { */ void (*unset_new_entry_callback) (config_values_t *self); + /* + * serialize a config entry. + * return a base64 null terminated string. + */ + char* (*serialize_entry) (config_values_t *self, const char *key); + + /* + * deserialize a config entry. + * value is a base 64 encoded string + */ + cfg_entry_t* (*deserialize_entry) (config_values_t *self, const char *value); + + /* * config values are stored here: */ diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index f4be27587..b2d2f1d9d 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -701,15 +701,12 @@ static inline int _plugin_info_equal(const plugin_info_t *a, */ static void _new_entry_cb (void *user_data, xine_cfg_entry_t *entry) { plugin_node_t *node = (plugin_node_t *)user_data; - /* - printf("_new_entry_cb: key %s, plugin id: %s\n", entry->key, node->info->id); - */ + if (!node->config_entry_list) { node->config_entry_list = xine_list_new(); } xine_list_push_back(node->config_entry_list, (void *)entry->key); - } static int _load_plugin_class(xine_t *this, @@ -857,7 +854,7 @@ static void load_required_plugins(xine_t *this) { /* * save plugin list information to file (cached catalog) */ -static void save_plugin_list(FILE *fp, xine_sarray_t *list) { +static void save_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *list) { const plugin_node_t *node; const plugin_file_t *file; @@ -867,7 +864,6 @@ static void save_plugin_list(FILE *fp, xine_sarray_t *list) { const vo_info_t *vo_info; const ao_info_t *ao_info; const post_info_t *post_info; - int i; int list_id = 0; int list_size; @@ -884,9 +880,9 @@ static void save_plugin_list(FILE *fp, xine_sarray_t *list) { fprintf(fp, "api=%d\n", node->info->API ); fprintf(fp, "id=%s\n", node->info->id ); fprintf(fp, "version=%lu\n", (unsigned long) node->info->version ); - + switch (node->info->type & PLUGIN_TYPE_MASK){ - + case PLUGIN_VIDEO_OUT: vo_info = node->info->special_info; fprintf(fp, "visual_type=%d\n", vo_info->visual_type ); @@ -914,7 +910,7 @@ static void save_plugin_list(FILE *fp, xine_sarray_t *list) { demuxer_info = node->info->special_info; fprintf(fp, "demuxer_priority=%d\n", demuxer_info->priority); break; - + case PLUGIN_INPUT: input_info = node->info->special_info; fprintf(fp, "input_priority=%d\n", input_info->priority); @@ -922,10 +918,27 @@ static void save_plugin_list(FILE *fp, xine_sarray_t *list) { case PLUGIN_POST: post_info = node->info->special_info; - fprintf(fp, "post_type=%lu\n", (unsigned long)post_info->type); - break; - } - + fprintf(fp, "post_type=%lu\n", (unsigned long)post_info->type); + break; + } + + if (node->config_entry_list) + { + xine_list_iterator_t ite = xine_list_front(node->config_entry_list); + while (ite) { + char *key = xine_list_get_value(node->config_entry_list, ite); + + /* now get the representation of the config key */ + char *key_value = this->config->serialize_entry(this->config, key); + + printf(" config key: %s, serialization: %d bytes\n", key, strlen(key_value)); + fprintf(fp, "config_key=%s\n", key_value); + + free (key_value); + ite = xine_list_next(node->config_entry_list, ite); + } + } + fprintf(fp, "\n"); list_id++; } @@ -1120,7 +1133,7 @@ static void save_catalog (xine_t *this) { fprintf(fp, "cache_catalog_version=%d\n\n", CACHE_CATALOG_VERSION); for (i = 0; i < PLUGIN_TYPE_MAX; i++) { - save_plugin_list (fp, this->plugin_catalog->plugin_lists[i]); + save_plugin_list (this, fp, this->plugin_catalog->plugin_lists[i]); } fclose(fp); } @@ -1206,9 +1219,9 @@ void _x_scan_plugins (xine_t *this) { free(pluginpath); free(homedir); - save_catalog (this); - load_required_plugins (this); + + save_catalog (this); map_decoders (this); } diff --git a/src/xine-utils/Makefile.am b/src/xine-utils/Makefile.am index 95de06b9e..8bef77b4c 100644 --- a/src/xine-utils/Makefile.am +++ b/src/xine-utils/Makefile.am @@ -30,7 +30,8 @@ libxineutils_la_SOURCES = $(pppc_files) \ array.c \ sorted_array.c \ pool.c \ - ring_buffer.c + ring_buffer.c \ + base64.c xineinclude_HEADERS = \ attributes.h \ @@ -43,7 +44,8 @@ xineinclude_HEADERS = \ array.h \ sorted_array.h \ pool.h \ - ring_buffer.h + ring_buffer.h \ + base64.h noinst_HEADERS = ppcasm_string.h xine_check.h diff --git a/src/xine-utils/base64.c b/src/xine-utils/base64.c new file mode 100644 index 000000000..358cbbada --- /dev/null +++ b/src/xine-utils/base64.c @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2000 Robert Kaye + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * Base64 encoding modified for Musicbrainz + * relicensed under the GNU General Public License for use in xine-lib + * + */ +/* -------------------------------------------------------------------------- + + MusicBrainz -- The Internet music metadatabase + + Copyright (C) 2000 Robert Kaye + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser 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 + + $Id: base64.c,v 1.2 2004/05/05 18:44:19 mroi Exp $ + +----------------------------------------------------------------------------*/ +/* + * Program: RFC-822 routines (originally from SMTP) + * + * Author: Mark Crispin + * Networks and Distributed Computing + * Computing & Communications + * University of Washington + * Administration Building, AG-44 + * Seattle, WA 98195 + * Internet: MRC@CAC.Washington.EDU + * + * Date: 27 July 1988 + * Last Edited: 10 September 1998 + * + * Sponsorship: The original version of this work was developed in the + * Symbolic Systems Resources Group of the Knowledge Systems + * Laboratory at Stanford University in 1987-88, and was funded + * by the Biomedical Research Technology Program of the National + * Institutes of Health under grant number RR-00785. + * + * Original version Copyright 1988 by The Leland Stanford Junior University + * Copyright 1998 by the University of Washington + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notices appear in all copies and that both the + * above copyright notices and this permission notice appear in supporting + * documentation, and that the name of the University of Washington or The + * Leland Stanford Junior University not be used in advertising or publicity + * pertaining to distribution of the software without specific, written prior + * permission. This software is made available "as is", and + * THE UNIVERSITY OF WASHINGTON AND THE LELAND STANFORD JUNIOR UNIVERSITY + * DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO THIS SOFTWARE, + * INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF + * WASHINGTON OR THE LELAND STANFORD JUNIOR UNIVERSITY BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, TORT (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#include +#include +#include +#include + +#include "base64.h" + + +/* NOTE: This is not true RFC822 anymore. The use of the characters + '/', '+', and '=' is no bueno when the ID will be used as part of a URL. + '_', '.', and '-' have been used instead +*/ + +/* Convert binary contents to BASE64 + * Accepts: source + * length of source + * pointer to return destination length + * Returns: destination as BASE64 + */ + +unsigned char *rfc822_binary (void *src,unsigned long srcl,unsigned long *len) +{ + unsigned char *ret,*d; + unsigned char *s = (unsigned char *) src; + char *v = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._"; + unsigned long i = ((srcl + 2) / 3) * 4; + *len = i += 2 * ((i / 60) + 1); + d = ret = (unsigned char *) malloc ((size_t) ++i); + for (i = 0; srcl; s += 3) { /* process tuplets */ + *d++ = v[s[0] >> 2]; /* byte 1: high 6 bits (1) */ + /* byte 2: low 2 bits (1), high 4 bits (2) */ + *d++ = v[((s[0] << 4) + (--srcl ? (s[1] >> 4) : 0)) & 0x3f]; + /* byte 3: low 4 bits (2), high 2 bits (3) */ + *d++ = srcl ? v[((s[1] << 2) + (--srcl ? (s[2] >> 6) : 0)) & 0x3f] : '-'; + /* byte 4: low 6 bits (3) */ + *d++ = srcl ? v[s[2] & 0x3f] : '-'; + if (srcl) srcl--; /* count third character if processed */ + if ((++i) == 15) { /* output 60 characters? */ + i = 0; /* restart line break count, insert CRLF */ + *d++ = '\015'; *d++ = '\012'; + } + } + *d = '\0'; /* tie off string */ + + return ret; /* return the resulting string */ +} + +unsigned char *base64_encode (void *src,unsigned long srcl,unsigned long *len) +{ + unsigned char *ret,*d; + unsigned char *s = (unsigned char *) src; + char *v = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._"; + unsigned long i = ((srcl + 2) / 3) * 4; + *len = i; + d = ret = (unsigned char *) malloc ((size_t) ++i); + for (i = 0; srcl; s += 3) { /* process tuplets */ + *d++ = v[s[0] >> 2]; /* byte 1: high 6 bits (1) */ + /* byte 2: low 2 bits (1), high 4 bits (2) */ + *d++ = v[((s[0] << 4) + (--srcl ? (s[1] >> 4) : 0)) & 0x3f]; + /* byte 3: low 4 bits (2), high 2 bits (3) */ + *d++ = srcl ? v[((s[1] << 2) + (--srcl ? (s[2] >> 6) : 0)) & 0x3f] : '-'; + /* byte 4: low 6 bits (3) */ + *d++ = srcl ? v[s[2] & 0x3f] : '-'; + if (srcl) srcl--; /* count third character if processed */ + } + *d = '\0'; /* tie off string */ + + return ret; /* return the resulting string */ +} + +void *base64_decode (unsigned char *src,unsigned long srcl,unsigned long *len) +{ + void *ret; + unsigned char *d; + unsigned long i = ((srcl + 3) / 4) * 3; + *len = i; + d = ret = (void *) malloc ((size_t)i); + for (i = 0; srcl; src += 4) { /* process tuplets */ + unsigned char tuplet[4]; + int j; + + for (j = 0; j < 4; j += 1) { + if (srcl) { + if ((src[j] >= 'A') && (src[j] <= 'Z')) { + tuplet[j] = src[j] - 'A'; + } else if ((src[j] >= 'a') && (src[j] <= 'z')) { + tuplet[j] = src[j] - 'a' + 26; + } else if ((src[j] >= '0') && (src[j] <= '9')) { + tuplet[j] = src[j] - '0' + 52; + } else if (src[j] == '.') { + tuplet[j] = 62; + } else if (src[j] == '_') { + tuplet[j] = 63; + } else { + tuplet[j] = 64; + } + srcl--; + } else { + tuplet[j] = 64; + } + } + + *d++ = (tuplet[0] << 2) + ((tuplet[1] & 0x3f) >> 4); + *d++ = (tuplet[1] << 4) + ((tuplet[2] & 0x3f) >> 2); + *d++ = (tuplet[2] << 6) + (tuplet[3] & 0x3f); + } + + return ret; /* return the resulting string */ +} diff --git a/src/xine-utils/base64.h b/src/xine-utils/base64.h new file mode 100644 index 000000000..6a45aebc6 --- /dev/null +++ b/src/xine-utils/base64.h @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2000 Robert Kaye + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * Base64 encoding modified for Musicbrainz + * relicensed under the GNU General Public License for use in xine-lib + * + */ +/* -------------------------------------------------------------------------- + + MusicBrainz -- The Internet music metadatabase + + Copyright (C) 2000 Robert Kaye + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser 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 + + $Id: base64.h,v 1.1 2004/05/05 09:11:39 hadess Exp $ + +----------------------------------------------------------------------------*/ +/* + * Program: RFC-822 routines (originally from SMTP) + * + * Author: Mark Crispin + * Networks and Distributed Computing + * Computing & Communications + * University of Washington + * Administration Building, AG-44 + * Seattle, WA 98195 + * Internet: MRC@CAC.Washington.EDU + * + * Date: 27 July 1988 + * Last Edited: 10 September 1998 + * + * Sponsorship: The original version of this work was developed in the + * Symbolic Systems Resources Group of the Knowledge Systems + * Laboratory at Stanford University in 1987-88, and was funded + * by the Biomedical Research Technology Program of the National + * Institutes of Health under grant number RR-00785. + * + * Original version Copyright 1988 by The Leland Stanford Junior University + * Copyright 1998 by the University of Washington + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notices appear in all copies and that both the + * above copyright notices and this permission notice appear in supporting + * documentation, and that the name of the University of Washington or The + * Leland Stanford Junior University not be used in advertising or publicity + * pertaining to distribution of the software without specific, written prior + * permission. This software is made available "as is", and + * THE UNIVERSITY OF WASHINGTON AND THE LELAND STANFORD JUNIOR UNIVERSITY + * DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO THIS SOFTWARE, + * INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF + * WASHINGTON OR THE LELAND STANFORD JUNIOR UNIVERSITY BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, TORT (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifndef BASE64_H +#define BASE64_H + +unsigned char *rfc822_binary (void *src,unsigned long srcl,unsigned long *len); + +unsigned char *base64_encode (void *src,unsigned long srcl,unsigned long *len); +void *base64_decode (unsigned char *src,unsigned long srcl,unsigned long *len); + +#endif diff --git a/src/xine-utils/xineutils.h b/src/xine-utils/xineutils.h index 03c5f689a..9985c133b 100644 --- a/src/xine-utils/xineutils.h +++ b/src/xine-utils/xineutils.h @@ -46,6 +46,7 @@ extern "C" { # include "list.h" # include "array.h" # include "sorted_array.h" +# include "base64.h" #else # ifdef WIN32 # include @@ -61,6 +62,7 @@ extern "C" { # include # include # include +# include #endif #include -- cgit v1.2.3 From 0ce330ec329e1d15a49ae5c5ea4741bcfbf924d3 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Tue, 10 Apr 2007 18:45:53 +0200 Subject: Config entry deserialization. --- src/xine-engine/configfile.c | 228 ++++++++++++++++++++++++++++++++++------- src/xine-engine/configfile.h | 5 +- src/xine-engine/load_plugins.c | 73 ++++++++----- src/xine-utils/base64.c | 10 +- src/xine-utils/base64.h | 4 +- 5 files changed, 252 insertions(+), 68 deletions(-) (limited to 'src') diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index fce6e4a30..22d677e0b 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -34,6 +34,7 @@ #include #include #include +#include "bswap.h" #include "configfile.h" #define LOG_MODULE "configfile" @@ -1210,10 +1211,6 @@ static void config_unset_new_entry_callback (config_values_t *this) { pthread_mutex_unlock(&this->config_lock); } -static void config_register_entry (config_values_t *this, cfg_entry_t* entry) { - /* FIXME: TODO */ -} - static int put_int(uint8_t *buffer, int pos, int value) { int32_t value_int32 = (int32_t)value; @@ -1232,8 +1229,8 @@ static int put_string(uint8_t *buffer, int pos, const char *value, int value_len return 4 + value_len; } -static unsigned char* config_serialize_entry (config_values_t *this, const char *key) { - unsigned char *output = NULL; +static char* config_get_serialized_entry (config_values_t *this, const char *key) { + char *output = NULL; cfg_entry_t *entry, *prev; pthread_mutex_lock(&this->config_lock); @@ -1246,6 +1243,8 @@ static unsigned char* config_serialize_entry (config_values_t *this, const char int range_min; int range_max; int exp_level; + int num_default; + int num_value; char *key; char *str_default; char *description; @@ -1257,6 +1256,12 @@ static unsigned char* config_serialize_entry (config_values_t *this, const char int str_default_len = 0; int description_len = 0; int help_len = 0; + unsigned long output_len; + unsigned long total_len; + int value_count; + int value_len[10]; + int pos = 0; + int i; if (entry->key) key_len = strlen(entry->key); @@ -1269,7 +1274,7 @@ static unsigned char* config_serialize_entry (config_values_t *this, const char // integers // value: 4 bytes - unsigned long total_len = 4 * sizeof(int32_t); + total_len = 6 * sizeof(int32_t); // strings (size + char buffer) // length: 4 bytes @@ -1284,8 +1289,7 @@ static unsigned char* config_serialize_entry (config_values_t *this, const char // for each value: // length: 4 bytes // buffer: length bytes - int value_count = 0; - int value_len[10]; + value_count = 0; total_len += sizeof(int32_t); /* value count */ char **cur_value = entry->enum_values; @@ -1303,32 +1307,31 @@ static unsigned char* config_serialize_entry (config_values_t *this, const char if (!buffer) return NULL; /* Let's go */ - int pos = 0; - // the integers + /* the integers */ pos += put_int(buffer, pos, entry->type); pos += put_int(buffer, pos, entry->range_min); pos += put_int(buffer, pos, entry->range_max); pos += put_int(buffer, pos, entry->exp_level); + pos += put_int(buffer, pos, entry->num_default); + pos += put_int(buffer, pos, entry->num_value); - // the strings + /* the strings */ pos += put_string(buffer, pos, entry->key, key_len); pos += put_string(buffer, pos, entry->str_default, str_default_len); pos += put_string(buffer, pos, entry->description, description_len); pos += put_string(buffer, pos, entry->help, help_len); - // the enum stuff + /* the enum stuff */ pos += put_int(buffer, pos, value_count); cur_value = entry->enum_values; - int i; for (i = 0; i < value_count; i++) { pos += put_string(buffer, pos, *cur_value, value_len[i]); cur_value++; } - // and now the output encoding - unsigned long output_len; + /* and now the output encoding */ output = base64_encode (buffer, total_len, &output_len); free(buffer); @@ -1336,10 +1339,166 @@ static unsigned char* config_serialize_entry (config_values_t *this, const char pthread_mutex_unlock(&this->config_lock); return output; + } -static cfg_entry_t* config_deserialize_entry (config_values_t *this, const char *value) { - /* FIXME: TODO */ +static int get_int(uint8_t *buffer, int buffer_size, int pos, int *value) { + int32_t value_int32; + + if ((pos + sizeof(int32_t)) > buffer_size) + return 0; + + value_int32 = LE_32(&buffer[pos]); + *value = (int)value_int32; + return sizeof(int32_t); +} + +static int get_string(uint8_t *buffer, int buffer_size, int pos, char **value) { + int len; + int bytes = get_int(buffer, buffer_size, pos, &len); + *value = NULL; + + if (!bytes || (len < 0) || (len > 1024*64)) + return 0; + + char *str = malloc(len + 1); + pos += bytes; + memcpy(str, &buffer[pos], len); + str[len] = 0; + + *value = str; + return bytes + len; +} + +static char* config_register_serialized_entry (config_values_t *this, const char *value) { + + /* + fields serialized : + int type; + int range_min; + int range_max; + int exp_level; + int num_default; + int num_value; + char *key; + char *str_default; + char *description; + char *help; + char **enum_values; + */ + int type; + int range_min; + int range_max; + int exp_level; + int num_default; + int num_value; + char *key; + char *str_default; + char *description; + char *help; + char **enum_values; + + int bytes; + int pos; + void *output; + unsigned long output_len; + int value_count; + int i; + + output = base64_decode (value, strlen(value), &output_len); + + pos = 0; + pos += bytes = get_int(output, output_len, pos, &type); + if (!bytes) goto error; + + pos += bytes = get_int(output, output_len, pos, &range_min); + if (!bytes) goto error; + + pos += bytes = get_int(output, output_len, pos, &range_max); + if (!bytes) goto error; + + pos += bytes = get_int(output, output_len, pos, &exp_level); + if (!bytes) goto error; + + pos += bytes = get_int(output, output_len, pos, &num_default); + if (!bytes) goto error; + + pos += bytes = get_int(output, output_len, pos, &num_value); + if (!bytes) goto error; + + pos += bytes = get_string(output, output_len, pos, &key); + if (!bytes) goto error; + + pos += bytes = get_string(output, output_len, pos, &str_default); + if (!bytes) goto error; + + pos += bytes = get_string(output, output_len, pos, &description); + if (!bytes) goto error; + + pos += bytes = get_string(output, output_len, pos, &help); + if (!bytes) goto error; + + pos += bytes = get_int(output, output_len, pos, &value_count); + if (!bytes) goto error; + if ((value_count < 0) || (value_count > 256)) goto error; + + enum_values = malloc (sizeof(void*) * value_count + 1); + for (i = 0; i < value_count; i++) { + pos += bytes = get_string(output, output_len, pos, &enum_values[i]); + if (!bytes) goto error; + } + enum_values[value_count] = NULL; + +#if LOG + printf("config entry deserialization:\n"); + printf(" key : %s\n", key); + printf(" type : %d\n", type); + printf(" exp_level : %d\n", exp_level); + printf(" num_default: %d\n", num_default); + printf(" num_value : %d\n", num_value); + printf(" str_default: %s\n", str_default); + printf(" range_min : %d\n", range_min); + printf(" range_max : %d\n", range_max); + printf(" description: %s\n", description); + printf(" help : %s\n", help); + printf(" enum : %d values\n", value_count); + + for (i = 0; i < value_count; i++) { + printf(" enum[%2d]: %s\n", i, enum_values[i]); + } + printf("\n"); +#endif + + switch (type) { + case XINE_CONFIG_TYPE_STRING: + switch (num_value) { + case 0: + this->register_string(this, key, str_default, description, help, exp_level, NULL, NULL); + default: + this->register_filename(this, key, str_default, num_value, description, help, exp_level, NULL, NULL); + } + break; + case XINE_CONFIG_TYPE_RANGE: + this->register_range(this, key, num_default, range_min, range_max, description, help, exp_level, NULL, NULL); + break; + case XINE_CONFIG_TYPE_ENUM: + this->register_enum(this, key, num_default, enum_values, description, help, exp_level, NULL, NULL); + break; + case XINE_CONFIG_TYPE_NUM: + this->register_num(this, key, num_default, description, help, exp_level, NULL, NULL); + break; + case XINE_CONFIG_TYPE_BOOL: + this->register_bool(this, key, num_default, description, help, exp_level, NULL, NULL); + break; + case XINE_CONFIG_TYPE_UNKNOWN: + break; + } + + + return key; + +error: + /* serialization error */ return NULL; } @@ -1368,23 +1527,22 @@ config_values_t *_x_config_init (void) { pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&this->config_lock, &attr); - this->register_string = config_register_string; - this->register_filename = config_register_filename; - this->register_range = config_register_range; - this->register_enum = config_register_enum; - this->register_num = config_register_num; - this->register_bool = config_register_bool; - this->update_num = config_update_num; - this->update_string = config_update_string; - this->parse_enum = config_parse_enum; - this->lookup_entry = config_lookup_entry; - this->unregister_callback = config_unregister_cb; - this->dispose = config_dispose; - this->set_new_entry_callback = config_set_new_entry_callback; - this->unset_new_entry_callback = config_unset_new_entry_callback; - this->register_entry = config_register_entry; - this->serialize_entry = config_serialize_entry; - this->deserialize_entry = config_deserialize_entry; + this->register_string = config_register_string; + this->register_filename = config_register_filename; + this->register_range = config_register_range; + this->register_enum = config_register_enum; + this->register_num = config_register_num; + this->register_bool = config_register_bool; + this->register_serialized_entry = config_register_serialized_entry; + this->update_num = config_update_num; + this->update_string = config_update_string; + this->parse_enum = config_parse_enum; + this->lookup_entry = config_lookup_entry; + this->unregister_callback = config_unregister_cb; + this->dispose = config_dispose; + this->set_new_entry_callback = config_set_new_entry_callback; + this->unset_new_entry_callback = config_unset_new_entry_callback; + this->get_serialized_entry = config_get_serialized_entry; return this; } diff --git a/src/xine-engine/configfile.h b/src/xine-engine/configfile.h index e1416432b..a4f4b34ec 100644 --- a/src/xine-engine/configfile.h +++ b/src/xine-engine/configfile.h @@ -201,13 +201,14 @@ struct config_values_s { * serialize a config entry. * return a base64 null terminated string. */ - char* (*serialize_entry) (config_values_t *self, const char *key); + char* (*get_serialized_entry) (config_values_t *self, const char *key); /* * deserialize a config entry. * value is a base 64 encoded string + * return the key of the serialized entry */ - cfg_entry_t* (*deserialize_entry) (config_values_t *self, const char *value); + char* (*register_serialized_entry) (config_values_t *self, const char *value); /* diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index b2d2f1d9d..2b7177511 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -64,6 +64,8 @@ #include "xineutils.h" #include "compat.h" +#define LINE_MAX_LENGTH (1024 * 32) /* 32 KiB */ + #if 0 static char *plugin_name; @@ -695,6 +697,15 @@ static inline int _plugin_info_equal(const plugin_info_t *a, return 1; } +static void _attach_entry_to_node (plugin_node_t *node, void *key) { + + if (!node->config_entry_list) { + node->config_entry_list = xine_list_new(); + } + + xine_list_push_back(node->config_entry_list, key); +} + /* * This callback is called by the config entry system when a plugin register a * new config entry. @@ -702,11 +713,7 @@ static inline int _plugin_info_equal(const plugin_info_t *a, static void _new_entry_cb (void *user_data, xine_cfg_entry_t *entry) { plugin_node_t *node = (plugin_node_t *)user_data; - if (!node->config_entry_list) { - node->config_entry_list = xine_list_new(); - } - - xine_list_push_back(node->config_entry_list, (void *)entry->key); + _attach_entry_to_node(node, (void *)entry->key); } static int _load_plugin_class(xine_t *this, @@ -922,16 +929,16 @@ static void save_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *list) { break; } - if (node->config_entry_list) - { + /* config entries */ + if (node->config_entry_list) { xine_list_iterator_t ite = xine_list_front(node->config_entry_list); while (ite) { char *key = xine_list_get_value(node->config_entry_list, ite); /* now get the representation of the config key */ - char *key_value = this->config->serialize_entry(this->config, key); + char *key_value = this->config->get_serialized_entry(this->config, key); - printf(" config key: %s, serialization: %d bytes\n", key, strlen(key_value)); + lprintf(" config key: %s, serialization: %d bytes\n", key, strlen(key_value)); fprintf(fp, "config_key=%s\n", key_value); free (key_value); @@ -947,7 +954,7 @@ static void save_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *list) { /* * load plugin list information from file (cached catalog) */ -static void load_plugin_list(FILE *fp, xine_sarray_t *plugins) { +static void load_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *plugins) { plugin_node_t *node; plugin_file_t *file; @@ -960,20 +967,29 @@ static void load_plugin_list(FILE *fp, xine_sarray_t *plugins) { int i; uint64_t llu; unsigned long lu; - char line[1024]; + char *line; char *value; + size_t line_len; int version_ok = 0; + line = malloc(LINE_MAX_LENGTH); + if (!line) + return; + node = NULL; file = NULL; - while (fgets (line, 1023, fp)) { + while (fgets (line, LINE_MAX_LENGTH, fp)) { if (line[0] == '#') continue; - - if( (value = strchr(line, '\r')) || (value = strchr(line, '\n')) ) - *value = (char) 0; /* eliminate any cr/lf */ + line_len = strlen(line); + if (line_len < 3) + continue; + + value = &line[line_len - 1]; + if( (*value == '\r') || (*value == '\n') ) + *value-- = (char) 0; /* eliminate any cr/lf */ - if( (value = strchr(line, '\r')) || (value = strchr(line, '\n')) ) + if( (*value == '\r') || (*value == '\n') ) *value = (char) 0; /* eliminate any cr/lf */ if (line[0] == '[' && version_ok) { @@ -1048,11 +1064,11 @@ static void load_plugin_list(FILE *fp, xine_sarray_t *plugins) { xine_xmalloc(sizeof(decoder_info_t)); break; - case PLUGIN_POST: - node->info->special_info = post_info = - xine_xmalloc(sizeof(post_info_t)); - break; - } + case PLUGIN_POST: + node->info->special_info = post_info = + xine_xmalloc(sizeof(post_info_t)); + break; + } } else if( !strcmp("api",line) ) { sscanf(value," %d",&i); @@ -1092,8 +1108,15 @@ static void load_plugin_list(FILE *fp, xine_sarray_t *plugins) { sscanf(value," %d",&i); input_info->priority = i; } else if( !strcmp("post_type",line) && post_info ) { - sscanf(value," %lu",&lu); - post_info->type = lu; + sscanf(value," %lu",&lu); + post_info->type = lu; + } else if( !strcmp("config_key",line) ) { + char* cfg_key; + + cfg_key = this->config->register_serialized_entry(this->config, value); + if (cfg_key != NULL) { + _attach_entry_to_node(node, cfg_key); + } } } } @@ -1102,6 +1125,8 @@ static void load_plugin_list(FILE *fp, xine_sarray_t *plugins) { if( node ) { xine_sarray_add (plugins, node); } + + free (line); } @@ -1154,7 +1179,7 @@ static void load_cached_catalog (xine_t *this) { sprintf(cachefile, "%s/%s", xine_get_homedir(), relname); if( (fp = fopen(cachefile,"r")) != NULL ) { - load_plugin_list (fp, this->plugin_catalog->cache_list); + load_plugin_list (this, fp, this->plugin_catalog->cache_list); fclose(fp); } free(cachefile); diff --git a/src/xine-utils/base64.c b/src/xine-utils/base64.c index 358cbbada..af6e2eadf 100644 --- a/src/xine-utils/base64.c +++ b/src/xine-utils/base64.c @@ -134,14 +134,14 @@ unsigned char *rfc822_binary (void *src,unsigned long srcl,unsigned long *len) return ret; /* return the resulting string */ } -unsigned char *base64_encode (void *src,unsigned long srcl,unsigned long *len) +char *base64_encode (const void *src, unsigned long srcl, unsigned long *len) { - unsigned char *ret,*d; + char *ret, *d; unsigned char *s = (unsigned char *) src; char *v = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._"; unsigned long i = ((srcl + 2) / 3) * 4; *len = i; - d = ret = (unsigned char *) malloc ((size_t) ++i); + d = ret = (char *) malloc ((size_t) ++i); for (i = 0; srcl; s += 3) { /* process tuplets */ *d++ = v[s[0] >> 2]; /* byte 1: high 6 bits (1) */ /* byte 2: low 2 bits (1), high 4 bits (2) */ @@ -157,7 +157,7 @@ unsigned char *base64_encode (void *src,unsigned long srcl,unsigned long *len) return ret; /* return the resulting string */ } -void *base64_decode (unsigned char *src,unsigned long srcl,unsigned long *len) +void *base64_decode (const char *src, unsigned long srcl, unsigned long *len) { void *ret; unsigned char *d; @@ -185,7 +185,7 @@ void *base64_decode (unsigned char *src,unsigned long srcl,unsigned long *len) } srcl--; } else { - tuplet[j] = 64; + (*len)--; } } diff --git a/src/xine-utils/base64.h b/src/xine-utils/base64.h index 6a45aebc6..409d4c64e 100644 --- a/src/xine-utils/base64.h +++ b/src/xine-utils/base64.h @@ -92,7 +92,7 @@ unsigned char *rfc822_binary (void *src,unsigned long srcl,unsigned long *len); -unsigned char *base64_encode (void *src,unsigned long srcl,unsigned long *len); -void *base64_decode (unsigned char *src,unsigned long srcl,unsigned long *len); +char *base64_encode (const void *src, unsigned long srcl, unsigned long *len); +void *base64_decode (const char *src, unsigned long srcl, unsigned long *len); #endif -- cgit v1.2.3 From 3dc931e217272f0781ef8f7d7ed228467fe5604c Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Wed, 11 Apr 2007 14:49:02 +0200 Subject: Released allocated strings. Added some profiling (XINE_PROFILE). --- src/xine-engine/configfile.c | 60 ++++++++++++++++++++++++------------------ src/xine-engine/load_plugins.c | 23 ++++++++++------ src/xine-engine/xine.c | 3 ++- 3 files changed, 52 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index 22d677e0b..294da5700 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -1371,7 +1371,6 @@ static int get_string(uint8_t *buffer, int buffer_size, int pos, char **value) { } static char* config_register_serialized_entry (config_values_t *this, const char *value) { - /* fields serialized : int type; @@ -1392,60 +1391,60 @@ static char* config_register_serialized_entry (config_values_t *this, const char int exp_level; int num_default; int num_value; - char *key; - char *str_default; - char *description; - char *help; - char **enum_values; + char *key = NULL; + char *str_default = NULL; + char *description = NULL; + char *help = NULL; + char **enum_values = NULL; int bytes; int pos; - void *output; + void *output = NULL; unsigned long output_len; - int value_count; + int value_count = 0; int i; output = base64_decode (value, strlen(value), &output_len); pos = 0; pos += bytes = get_int(output, output_len, pos, &type); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_int(output, output_len, pos, &range_min); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_int(output, output_len, pos, &range_max); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_int(output, output_len, pos, &exp_level); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_int(output, output_len, pos, &num_default); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_int(output, output_len, pos, &num_value); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_string(output, output_len, pos, &key); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_string(output, output_len, pos, &str_default); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_string(output, output_len, pos, &description); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_string(output, output_len, pos, &help); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_int(output, output_len, pos, &value_count); - if (!bytes) goto error; - if ((value_count < 0) || (value_count > 256)) goto error; + if (!bytes) goto exit; + if ((value_count < 0) || (value_count > 256)) goto exit; enum_values = malloc (sizeof(void*) * value_count + 1); for (i = 0; i < value_count; i++) { pos += bytes = get_string(output, output_len, pos, &enum_values[i]); - if (!bytes) goto error; + if (!bytes) goto exit; } enum_values[value_count] = NULL; @@ -1474,8 +1473,10 @@ static char* config_register_serialized_entry (config_values_t *this, const char switch (num_value) { case 0: this->register_string(this, key, str_default, description, help, exp_level, NULL, NULL); + break; default: this->register_filename(this, key, str_default, num_value, description, help, exp_level, NULL, NULL); + break; } break; case XINE_CONFIG_TYPE_RANGE: @@ -1494,12 +1495,21 @@ static char* config_register_serialized_entry (config_values_t *this, const char break; } +exit: + /* cleanup */ + free(str_default); + free(description); + free(help); + free(output); + + if (enum_values) { + for (i = 0; i < value_count; i++) { + free(enum_values[i]); + } + free(enum_values); + } return key; - -error: - /* serialization error */ - return NULL; } config_values_t *_x_config_init (void) { diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index 2b7177511..fc708db13 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -48,6 +48,7 @@ /* #define LOG +#define DEBUG */ #define XINE_ENABLE_EXPERIMENTAL_FEATURES 1 @@ -697,7 +698,7 @@ static inline int _plugin_info_equal(const plugin_info_t *a, return 1; } -static void _attach_entry_to_node (plugin_node_t *node, void *key) { +static void _attach_entry_to_node (plugin_node_t *node, char *key) { if (!node->config_entry_list) { node->config_entry_list = xine_list_new(); @@ -713,7 +714,7 @@ static void _attach_entry_to_node (plugin_node_t *node, void *key) { static void _new_entry_cb (void *user_data, xine_cfg_entry_t *entry) { plugin_node_t *node = (plugin_node_t *)user_data; - _attach_entry_to_node(node, (void *)entry->key); + _attach_entry_to_node(node, strdup(entry->key)); } static int _load_plugin_class(xine_t *this, @@ -935,7 +936,7 @@ static void save_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *list) { while (ite) { char *key = xine_list_get_value(node->config_entry_list, ite); - /* now get the representation of the config key */ + /* now serialize the config key */ char *key_value = this->config->get_serialized_entry(this->config, key); lprintf(" config key: %s, serialization: %d bytes\n", key, strlen(key_value)); @@ -1205,7 +1206,7 @@ void _x_scan_plugins (xine_t *this) { homedir = strdup(xine_get_homedir()); this->plugin_catalog = _new_catalog(); - load_cached_catalog (this); + XINE_PROFILE(load_cached_catalog (this)); if ((pluginpath = getenv("XINE_PLUGIN_PATH")) != NULL) { pluginpath = strdup(pluginpath); @@ -1227,7 +1228,7 @@ void _x_scan_plugins (xine_t *this) { case XINE_PATH_SEPARATOR_CHAR: case '\0': plugindir[j] = '\0'; - collect_plugins(this, plugindir); + XINE_PROFILE(collect_plugins(this, plugindir)); j = 0; break; case '~': @@ -1244,9 +1245,9 @@ void _x_scan_plugins (xine_t *this) { free(pluginpath); free(homedir); - load_required_plugins (this); + /* load_required_plugins (this); */ - save_catalog (this); + XINE_PROFILE(save_catalog (this)); map_decoders (this); } @@ -2649,7 +2650,13 @@ static void dispose_plugin_list (xine_sarray_t *list) { free (node->info); if (node->config_entry_list) { - xine_list_delete(node->config_entry_list); + xine_list_iterator_t ite = xine_list_front (node->config_entry_list); + while (ite) { + char *key = xine_list_get_value (node->config_entry_list, ite); + free (key); + ite = xine_list_next (node->config_entry_list, ite); + } + xine_list_delete(node->config_entry_list); } free (node); } diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index f49a988c9..32c2d7672 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -51,6 +51,7 @@ #define LOG_VERBOSE /* #define LOG +#define DEBUG */ #define XINE_ENABLE_EXPERIMENTAL_FEATURES @@ -1547,7 +1548,7 @@ void xine_init (xine_t *this) { /* * plugins */ - _x_scan_plugins(this); + XINE_PROFILE(_x_scan_plugins(this)); #ifdef HAVE_SETLOCALE if (!setlocale(LC_CTYPE, "")) -- cgit v1.2.3 From ab2c5817538265f0e8411b3ebabf8ad29bce807b Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Thu, 12 Apr 2007 17:15:47 +0200 Subject: Fixed double free problem. --- src/xine-engine/configfile.c | 22 +++++++------ src/xine-engine/load_plugins.c | 71 +++++++++++++++++++++++++--------------- src/xine-engine/plugin_catalog.h | 2 +- 3 files changed, 57 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index 294da5700..0d3ec4bd1 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -1272,23 +1272,25 @@ static char* config_get_serialized_entry (config_values_t *this, const char *key if (entry->help) help_len = strlen(entry->help); - // integers - // value: 4 bytes + /* integers */ + /* value: 4 bytes */ total_len = 6 * sizeof(int32_t); - // strings (size + char buffer) - // length: 4 bytes - // buffer: length bytes + /* strings (size + char buffer) + * length: 4 bytes + * buffer: length bytes + */ total_len += sizeof(int32_t) + key_len; total_len += sizeof(int32_t) + str_default_len; total_len += sizeof(int32_t) + description_len; total_len += sizeof(int32_t) + help_len; - /* enum values... */ - // value count: 4 bytes - // for each value: - // length: 4 bytes - // buffer: length bytes + /* enum values... + * value count: 4 bytes + * for each value: + * length: 4 bytes + * buffer: length bytes + */ value_count = 0; total_len += sizeof(int32_t); /* value count */ diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index fc708db13..f34b3bb66 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -252,26 +252,26 @@ static void _decoder_priority_cb(void *data, xine_cfg_entry_t *cfg) { map_decoders((xine_t *)data); } -static plugin_info_t *_get_cached_info (xine_t *this, +static plugin_node_t *_get_cached_node (xine_t *this, char *filename, off_t filesize, time_t filemtime, - plugin_info_t *previous_info) { + plugin_node_t *previous_node) { xine_sarray_t *list = this->plugin_catalog->cache_list; int list_id, list_size; list_size = xine_sarray_size (list); for (list_id = 0; list_id < list_size; list_id++) { plugin_node_t *node = xine_sarray_get (list, list_id); - if( !previous_info && + if( !previous_node && node->file->filesize == filesize && node->file->filemtime == filemtime && !strcmp( node->file->filename, filename )) { - return node->info; + return node; } /* skip previously returned items */ - if( node->info == previous_info ) - previous_info = NULL; + if( node == previous_node ) + previous_node = NULL; } return NULL; @@ -301,6 +301,7 @@ static plugin_file_t *_insert_file (xine_t *this, static void _insert_node (xine_t *this, xine_sarray_t *list, plugin_file_t *file, + plugin_node_t *node_cache, plugin_info_t *info, int api_version){ @@ -341,7 +342,7 @@ static void _insert_node (xine_t *this, entry->file = file; entry->ref = 0; entry->priority = 0; /* default priority */ - entry->config_entry_list = NULL; + entry->config_entry_list = (node_cache) ? node_cache->config_entry_list : NULL; switch (info->type & PLUGIN_TYPE_MASK){ @@ -489,7 +490,8 @@ static plugin_catalog_t *_new_catalog(void){ return catalog; } -static void _register_plugins_internal(xine_t *this, plugin_file_t *file, plugin_info_t *info) { +static void _register_plugins_internal(xine_t *this, plugin_file_t *file, + plugin_node_t *node_cache, plugin_info_t *info) { _x_assert(this); _x_assert(info); @@ -515,7 +517,7 @@ static void _register_plugins_internal(xine_t *this, plugin_file_t *file, plugin int plugin_type = info->type & PLUGIN_TYPE_MASK; if ((plugin_type > 0) && (plugin_type <= PLUGIN_TYPE_MAX)) { - _insert_node (this, this->plugin_catalog->plugin_lists[plugin_type - 1], file, info, + _insert_node (this, this->plugin_catalog->plugin_lists[plugin_type - 1], file, node_cache, info, plugin_iface_versions[plugin_type - 1]); if ((plugin_type == PLUGIN_AUDIO_DECODER) || @@ -539,15 +541,17 @@ static void _register_plugins_internal(xine_t *this, plugin_file_t *file, plugin /* get next info */ if( file && !file->lib_handle ) { lprintf("get cached info\n"); - info = _get_cached_info (this, file->filename, file->filesize, file->filemtime, info); + node_cache = _get_cached_node (this, file->filename, file->filesize, file->filemtime, node_cache); + info = (node_cache) ? node_cache->info : NULL; } else { + info++; } } } void xine_register_plugins(xine_t *self, plugin_info_t *info) { - _register_plugins_internal(self, NULL, info); + _register_plugins_internal(self, NULL, NULL, info); } /* @@ -578,6 +582,7 @@ static void collect_plugins(xine_t *this, char *path){ size_t new_str_size, d_len; void *lib = NULL; plugin_info_t *info = NULL; + plugin_node_t *node = NULL; struct stat statbuffer; @@ -620,7 +625,8 @@ static void collect_plugins(xine_t *this, char *path){ lib = NULL; /* get the first plugin_info_t */ - info = _get_cached_info (this, str, statbuffer.st_size, statbuffer.st_mtime, NULL); + node = _get_cached_node (this, str, statbuffer.st_size, statbuffer.st_mtime, NULL); + info = (node) ? node->info : NULL; #ifdef LOG if( info ) printf("load_plugins: using cached %s\n", str); @@ -641,7 +647,7 @@ static void collect_plugins(xine_t *this, char *path){ file = _insert_file(this, this->plugin_catalog->file_list, str, &statbuffer, lib); - _register_plugins_internal(this, file, info); + _register_plugins_internal(this, file, node, info); } else { const char *error = dlerror(); @@ -749,6 +755,7 @@ static int _load_plugin_class(xine_t *this, config_values_t *config = this->config; /* the callback is called for each entry registered by this plugin */ + lprintf("plugin init %s\n", node->info->id); config->set_new_entry_callback(config, _new_entry_cb, node); node->plugin_class = info->init(this, data); config->unset_new_entry_callback(config); @@ -832,8 +839,12 @@ static void _load_required_plugins(xine_t *this, xine_sarray_t *list) { while (list_id < list_size) { plugin_node_t *node = xine_sarray_get(list, list_id); - if( (node->info->type & PLUGIN_MUST_PRELOAD) && !node->plugin_class ) { - + /* + * preload plugins if not cached + */ + if( (node->info->type & PLUGIN_MUST_PRELOAD) && !node->plugin_class && + node->file->lib_handle ) { + lprintf("preload plugin %s from %s\n", node->info->id, node->file->filename); if (! _load_plugin_class (this, node, NULL)) { @@ -1115,8 +1126,11 @@ static void load_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *plugins) { char* cfg_key; cfg_key = this->config->register_serialized_entry(this->config, value); - if (cfg_key != NULL) { + if (cfg_key) { + /* this node is a cached node */ _attach_entry_to_node(node, cfg_key); + } else { + lprintf("failed to deserialize config entry key\n"); } } } @@ -1245,7 +1259,7 @@ void _x_scan_plugins (xine_t *this) { free(pluginpath); free(homedir); - /* load_required_plugins (this); */ + load_required_plugins (this); XINE_PROFILE(save_catalog (this)); @@ -2611,7 +2625,7 @@ char *xine_get_demux_for_mime_type (xine_t *self, const char *mime_type) { } -static void dispose_plugin_list (xine_sarray_t *list) { +static void dispose_plugin_list (xine_sarray_t *list, int is_cache) { plugin_node_t *node; decoder_info_t *decoder_info; @@ -2649,14 +2663,17 @@ static void dispose_plugin_list (xine_sarray_t *list) { free (node->info->id); free (node->info); - if (node->config_entry_list) { - xine_list_iterator_t ite = xine_list_front (node->config_entry_list); - while (ite) { - char *key = xine_list_get_value (node->config_entry_list, ite); - free (key); - ite = xine_list_next (node->config_entry_list, ite); + /* don't free the entry list if the node is cache */ + if (!is_cache) { + if (node->config_entry_list) { + xine_list_iterator_t ite = xine_list_front (node->config_entry_list); + while (ite) { + char *key = xine_list_get_value (node->config_entry_list, ite); + free (key); + ite = xine_list_next (node->config_entry_list, ite); + } + xine_list_delete(node->config_entry_list); } - xine_list_delete(node->config_entry_list); } free (node); } @@ -2690,10 +2707,10 @@ void _x_dispose_plugins (xine_t *this) { int i; for (i = 0; i < PLUGIN_TYPE_MAX; i++) { - dispose_plugin_list (this->plugin_catalog->plugin_lists[i]); + dispose_plugin_list (this->plugin_catalog->plugin_lists[i], 0); } - dispose_plugin_list (this->plugin_catalog->cache_list); + dispose_plugin_list (this->plugin_catalog->cache_list, 1); dispose_plugin_file_list (this->plugin_catalog->file_list); for (i = 0; this->plugin_catalog->prio_desc[i]; i++) diff --git a/src/xine-engine/plugin_catalog.h b/src/xine-engine/plugin_catalog.h index 26905ebff..909756e2b 100644 --- a/src/xine-engine/plugin_catalog.h +++ b/src/xine-engine/plugin_catalog.h @@ -40,7 +40,7 @@ /* the engine takes this many plugins for one stream type */ #define PLUGINS_PER_TYPE 10 -#define CACHE_CATALOG_VERSION 2 +#define CACHE_CATALOG_VERSION 3 #define CACHE_CATALOG_FILE ".xine/catalog.cache" #define CACHE_CATALOG_DIR ".xine" -- cgit v1.2.3 From 7598a6152ba55ef0ff8dda7f1b7729d2bb22a594 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 6 Jun 2007 23:36:19 +0100 Subject: Correctly check for LOG being defined. --HG-- extra : transplant_source : %DFs%84N%8AG%00%5B%EFv%FF%E6%CD%93%23%D8%E6%A1%C2%18 --- src/xine-engine/configfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index 0d3ec4bd1..38f2c5a6c 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -1450,7 +1450,7 @@ static char* config_register_serialized_entry (config_values_t *this, const char } enum_values[value_count] = NULL; -#if LOG +#ifdef LOG printf("config entry deserialization:\n"); printf(" key : %s\n", key); printf(" type : %d\n", type); -- cgit v1.2.3 From 46c59ae8695a4b6f62af89afef68895e70985d77 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Thu, 3 Jan 2008 15:16:07 +0100 Subject: Detect corrupted or broken seek tables for CBR MP3 files. [Bug #3] --HG-- extra : transplant_source : %00%11%94ZZG%2A%A0%2A%3B%DA%CDx%AC%02%A8%E8%C3%DF%A5 --- src/demuxers/demux_mpgaudio.c | 70 ++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index 73e43c199..8e716f095 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -64,6 +64,7 @@ /* Xing header stuff */ #define XING_TAG FOURCC_TAG('X', 'i', 'n', 'g') +#define INFO_TAG FOURCC_TAG('I', 'n', 'f', 'o') #define XING_FRAMES_FLAG 0x0001 #define XING_BYTES_FLAG 0x0002 #define XING_TOC_FLAG 0x0004 @@ -295,16 +296,8 @@ static int parse_frame_header(mpg_audio_frame_t *const frame, const uint8_t *con */ static xing_header_t* parse_xing_header(mpg_audio_frame_t *frame, uint8_t *buf, int bufsize) { - -#ifdef LOG - int i; -#endif uint8_t *ptr = buf; - xing_header_t *xing; - - xing = xine_xmalloc (sizeof (xing_header_t)); - if (!xing) - return NULL; + xing_header_t *xing = NULL; /* offset of the Xing header */ if (frame->lsf_bit) { @@ -319,52 +312,87 @@ static xing_header_t* parse_xing_header(mpg_audio_frame_t *frame, ptr += (9 + 4); } - if (ptr >= (buf + bufsize - 4)) return 0; + if (ptr >= (buf + bufsize - 4)) goto exit_error; lprintf("checking %08X\n", *ptr); + if (_X_BE_32(ptr) == XING_TAG) { + int has_frames_flag = 0; + int has_bytes_flag = 0; + + xing = xine_xmalloc (sizeof (xing_header_t)); + if (!xing) + goto exit_error; + lprintf("Xing header found\n"); ptr += 4; - if (ptr >= (buf + bufsize - 4)) return 0; + if (ptr >= (buf + bufsize - 4)) goto exit_error; xing->flags = _X_BE_32(ptr); ptr += 4; if (xing->flags & XING_FRAMES_FLAG) { - if (ptr >= (buf + bufsize - 4)) return 0; + if (ptr >= (buf + bufsize - 4)) goto exit_error; xing->stream_frames = _X_BE_32(ptr); ptr += 4; lprintf("stream frames: %d\n", xing->stream_frames); + has_frames_flag = 1; } if (xing->flags & XING_BYTES_FLAG) { - if (ptr >= (buf + bufsize - 4)) return 0; + if (ptr >= (buf + bufsize - 4)) goto exit_error; xing->stream_size = _X_BE_32(ptr); ptr += 4; lprintf("stream size: %d\n", xing->stream_size); + has_bytes_flag = 1; + } + + /* check if it's a useful Xing header */ + if (!has_frames_flag || !has_bytes_flag) { + lprintf("Stupid Xing tag, cannot do anything with it !\n"); + goto exit_error; } + if (xing->flags & XING_TOC_FLAG) { + int i; + lprintf("toc found\n"); - if (ptr >= (buf + bufsize - XING_TOC_LENGTH)) return 0; + if (ptr >= (buf + bufsize - XING_TOC_LENGTH)) goto exit_error; memcpy(xing->toc, ptr, XING_TOC_LENGTH); #ifdef LOG for (i = 0; i < XING_TOC_LENGTH; i++) { - lprintf("%d ", xing->toc[i]); + printf("%d ", xing->toc[i]); } - lprintf("\n"); + printf("\n"); #endif + /* check the table validity + * - MUST start with 0 + * - values MUST increase + */ + if (xing->toc[0] != 0) { + lprintf("invalid Xing toc\n"); + goto exit_error; + } + for (i = 1; i < XING_TOC_LENGTH; i++) { + if (xing->toc[i] < xing->toc[i-1]) { + lprintf("invalid Xing toc\n"); + goto exit_error; + } + } ptr += XING_TOC_LENGTH; } xing->vbr_scale = -1; if (xing->flags & XING_VBR_SCALE_FLAG) { - if (ptr >= (buf + bufsize - 4)) return 0; + if (ptr >= (buf + bufsize - 4)) goto exit_error; xing->vbr_scale = _X_BE_32(ptr); lprintf("vbr_scale: %d\n", xing->vbr_scale); } - - return xing; } else { lprintf("Xing header not found\n"); + } + return xing; + +exit_error: + lprintf("Xing header parse error\n"); free(xing); return NULL; } -} /* * Parse a Vbri header @@ -922,7 +950,7 @@ static int demux_mpgaudio_seek (demux_plugin_t *this_gen, if (this->stream_length > 0) { if (this->xing_header && - (this->xing_header->flags & (XING_TOC_FLAG | XING_BYTES_FLAG))) { + (this->xing_header->flags & XING_TOC_FLAG)) { seek_pos += xing_get_seek_point(this->xing_header, start_time, this->stream_length); lprintf("time seek: xing: time=%d, pos=%"PRId64"\n", start_time, seek_pos); } else if (this->vbri_header) { -- cgit v1.2.3 From 9276e56845b6c048cdf1e98574fa8fc80ffe8488 Mon Sep 17 00:00:00 2001 From: Richard van Paasen Date: Fri, 4 Jan 2008 00:00:08 +0100 Subject: Fixed an issue in input_pvr with setting the frequency of the tuner for ivtv versions 0.10.6+ Note: the old code divided the frequency by 62.5. But, the ivtv driver expects a different format. I changed the implementation in input_pvr such that the frequency can be given as provided by cable companies, multiplied by 1000: e.g. 503250 for 503.250 MHz. --- src/input/input_pvr.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/input/input_pvr.c b/src/input/input_pvr.c index f07e98133..1b8000072 100644 --- a/src/input/input_pvr.c +++ b/src/input/input_pvr.c @@ -1016,19 +1016,21 @@ static void pvr_event_handler (pvr_input_plugin_t *this) { /* change input */ if (v4l2_data->input != -1 && v4l2_data->input != this->input) { - lprintf("change input to:%d\n", v4l2_data->input); this->input = v4l2_data->input; /* as of ivtv 0.10.6: must close and reopen to set input */ close(this->dev_fd); this->dev_fd = open (this->class->devname, O_RDWR); - if (this->dev_fd == -1) { + if (this->dev_fd < 0) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_pvr: error opening device %s\n", this->class->devname ); } else { - if( ioctl(this->dev_fd, VIDIOC_S_INPUT, &this->input) ) + if( ioctl(this->dev_fd, VIDIOC_S_INPUT, &this->input) == 0 ) { + lprintf("Tuner Input set to:%d\n", v4l2_data->input); + } else { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_pvr: error setting v4l2 input\n"); + } } } @@ -1040,14 +1042,30 @@ static void pvr_event_handler (pvr_input_plugin_t *this) { /* change frequency */ if (v4l2_data->frequency != -1 && v4l2_data->frequency != this->frequency) { - lprintf("changing frequency to:%.2f\n", (float)v4l2_data->frequency * 62.5); + double freq = (double)v4l2_data->frequency / 1000.0; struct v4l2_frequency vf; + struct v4l2_tuner vt; + double fac = 16; + + memset(&vf, 0, sizeof(vf)); + memset(&vt, 0, sizeof(vt)); + this->frequency = v4l2_data->frequency; - vf.frequency = this->frequency; + + if (ioctl(this->dev_fd, VIDIOC_G_TUNER, &vt) == 0) { + fac = (vt.capability & V4L2_TUNER_CAP_LOW) ? 16000 : 16; + } + vf.tuner = 0; - if( ioctl(this->dev_fd, VIDIOC_S_FREQUENCY, &vf) ) + vf.type = vt.type; + vf.frequency = (__u32)(freq * fac); + + if (ioctl(this->dev_fd, VIDIOC_S_FREQUENCY, &vf) == 0) { + lprintf("Tuner Frequency set to %d (%f.3 MHz)\n", vf.frequency, vf.frequency / fac); + } else { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_pvr: error setting v4l2 frequency\n"); + } } pthread_mutex_unlock(&this->dev_lock); -- cgit v1.2.3 From 29de3d76ef4761e34aee107d458bfabe3ce96298 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Fri, 4 Jan 2008 18:12:53 +0000 Subject: Pass $(X_CFLAGS) when compiling syncfb. Noticed by Thomas Koeller . --- src/video_out/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/video_out/Makefile.am b/src/video_out/Makefile.am index c40535d9e..d447417c5 100644 --- a/src/video_out/Makefile.am +++ b/src/video_out/Makefile.am @@ -136,7 +136,7 @@ xineplug_vo_out_opengl_la_CFLAGS = $(VISIBILITY_FLAG) $(X_CFLAGS) $(MLIB_CFLAGS) xineplug_vo_out_syncfb_la_SOURCES = video_out_syncfb.c xineplug_vo_out_syncfb_la_LIBADD = $(XINE_LIB) $(X_LIBS) $(PTHREAD_LIBS) $(LTLIBINTL) -xineplug_vo_out_syncfb_la_CFLAGS = $(VISIBILITY_FLAG) +xineplug_vo_out_syncfb_la_CFLAGS = $(VISIBILITY_FLAG) $(X_CFLAGS) xineplug_vo_out_pgx64_la_SOURCES = video_out_pgx64.c xineplug_vo_out_pgx64_la_LIBADD = $(XINE_LIB) $(X_LIBS) $(SUNDGA_LIBS) $(PTHREAD_LIBS) $(LTLIBINTL) -- cgit v1.2.3 From 051c124db8a2ab27f45530323d9cbd673e277794 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sat, 5 Jan 2008 22:18:27 +0000 Subject: Enable the VMware Screen codec (ffmpeg). --- src/libffmpeg/ff_video_decoder.c | 4 ++++ src/xine-engine/buffer.h | 1 + src/xine-engine/buffer_types.c | 8 ++++++++ 3 files changed, 13 insertions(+) (limited to 'src') diff --git a/src/libffmpeg/ff_video_decoder.c b/src/libffmpeg/ff_video_decoder.c index dc1176e78..dc07abb9f 100644 --- a/src/libffmpeg/ff_video_decoder.c +++ b/src/libffmpeg/ff_video_decoder.c @@ -315,6 +315,7 @@ static const ff_codec_t ff_video_lookup[] = { {BUF_VIDEO_KMVC, CODEC_ID_KMVC, "Karl Morton's Video Codec (ffmpeg)"}, {BUF_VIDEO_FLASHSV, CODEC_ID_FLASHSV, "Flash Screen Video (ffmpeg)"}, {BUF_VIDEO_CAVS, CODEC_ID_CAVS, "Chinese AVS (ffmpeg)"}, + {BUF_VIDEO_VMNC, CODEC_ID_VMNC, "VMware Screen Codec (ffmpeg)"}, {BUF_VIDEO_THEORA_RAW, CODEC_ID_THEORA, "Theora (ffmpeg)"}, }; @@ -1855,6 +1856,9 @@ static uint32_t supported_video_types[] = { #ifdef CONFIG_CAVS_DECODER BUF_VIDEO_CAVS, #endif + #ifdef CONFIG_VMNC_DECODER + BUF_VIDEO_VMNC, + #endif BUF_VIDEO_THEORA_RAW, 0 }; diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h index 35ab1e620..2bcc29510 100644 --- a/src/xine-engine/buffer.h +++ b/src/xine-engine/buffer.h @@ -190,6 +190,7 @@ extern "C" { #define BUF_VIDEO_VP6F 0x02630000 #define BUF_VIDEO_THEORA_RAW 0x02640000 #define BUF_VIDEO_VC1 0x02650000 +#define BUF_VIDEO_VMNC 0x02660000 /* audio buffer types: (please keep in sync with buffer_types.c) */ diff --git a/src/xine-engine/buffer_types.c b/src/xine-engine/buffer_types.c index ee50e5391..7242738e1 100644 --- a/src/xine-engine/buffer_types.c +++ b/src/xine-engine/buffer_types.c @@ -771,6 +771,14 @@ static const video_db_t video_db[] = { BUF_VIDEO_KMVC, "Karl Morton's Video Codec" }, +{ + { + ME_FOURCC('V','M','n','c'), + 0 + }, + BUF_VIDEO_VMNC, + "VMware Screen Codec" +}, { { 0 }, 0, "last entry" } }; -- cgit v1.2.3 From ff632b94b6b25c35239ebb49a8e123d11f2fa8f4 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sun, 6 Jan 2008 03:30:02 +0000 Subject: Tell the Real demuxer about lists of http references. Such broken wrong-extension wrong-MIME-type lists exist in the wild... --- src/demuxers/demux_real.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c index 85d7dc5a3..9206bfc74 100644 --- a/src/demuxers/demux_real.c +++ b/src/demuxers/demux_real.c @@ -806,12 +806,22 @@ static int demux_real_parse_references( demux_real_t *this) { if (!strncmp(buf,"http://",7)) { - for (i = 0; buf[i] && !isspace(buf[i]); ++i) - /**/; - buf[i] = 0; - lprintf("reference [%s] found\n", buf); - - _x_demux_send_mrl_reference (this->stream, 0, buf, NULL, 0, 0); + i = 0; + while (buf[i]) + { + j = i; + while (buf[i] && !isspace(buf[i])) + ++i; /* skip non-space */ + len = buf[i]; + buf[i] = 0; + if (strncmp (buf + j, "http://", 7) || (i - j) < 8) + break; /* stop at the first non-http reference */ + lprintf("reference [%s] found\n", buf + j); + _x_demux_send_mrl_reference (this->stream, 0, buf + j, NULL, 0, 0); + buf[i] = (char) len; + while (buf[i] && isspace(buf[i])) + ++i; /* skip spaces */ + } } else for (i = 0; i < buf_used; ++i) { -- cgit v1.2.3 From 45aa7ebe596abd3263c747c642a2416a7ebbbbba Mon Sep 17 00:00:00 2001 From: Dongsu Park Date: Sun, 6 Jan 2008 16:03:20 +0000 Subject: for resolving Korean subtitle bug In draw_subtitle(), if the given encoding is one the CJK charset, colored typefaces functionality is disabled and subtitles are printed with the render_text() method. Otherwise subtitles are drawn by ogm_render_line() function. --- src/libsputext/xine_sputext_decoder.c | 50 ++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/libsputext/xine_sputext_decoder.c b/src/libsputext/xine_sputext_decoder.c index 1de1eb099..d45886300 100644 --- a/src/libsputext/xine_sputext_decoder.c +++ b/src/libsputext/xine_sputext_decoder.c @@ -506,11 +506,54 @@ static void read_ssa_tag(sputext_decoder_t *this, const char* text, (*sub_x), (*sub_y), (*max_width), (*alignment)); } +static int is_cjk_encoding(const char *enc) { + char **pstr; + + /* CJK charset strings defined in iconvdata/gconv-modules of glibc */ + static char *cjk_encoding_strings[] = { + "SJIS", + "CP932", + "EUC-KR", + "UHC", + "JOHAB", + "BIG5", + "BIG5HKSCS", + "EUC-JP-MS", + "EUC-JP", + "EUC-CN", + "GBBIG5", + "GBK", + "GBGBK", + "EUC-TW", + "ISO-2022-JP", + "ISO-2022-JP-2", + "ISO-2022-JP-3", + "ISO-2022-KR", + "ISO-2022-CN", + "ISO-2022-CN-EXT", + "GB18030", + "EUC-JISX0213", + "SHIFT_JISX0213", + NULL + }; + + /* return 1 if encoding string is one of the CJK(Chinese,Jananese,Korean) + * character set strings. */ + for (pstr = cjk_encoding_strings; *pstr; pstr++) { + if (strcasecmp(enc, *pstr) == 0) + return 1; + } + + return 0; +} + static void draw_subtitle(sputext_decoder_t *this, int64_t sub_start, int64_t sub_end ) { int line, y; int font_size; char *font; + char *encoding = (this->buf_encoding)?this->buf_encoding: + this->class->src_encoding; int sub_x, sub_y, max_width; int alignment; int rebuild_all; @@ -719,7 +762,12 @@ static void draw_subtitle(sputext_decoder_t *this, int64_t sub_start, int64_t su } } - ogm_render_line(this, x, y + line*this->line_height, this->text[line]); + if( is_cjk_encoding(encoding) ) { + this->renderer->render_text (this->osd, x, y + line * this->line_height, + this->text[line], OSD_TEXT1); + } else { + ogm_render_line(this, x, y + line*this->line_height, this->text[line]); + } } if( font_size != this->font_size ) -- cgit v1.2.3 From 3b8eab0196256be7240878cb718fceb7cd373549 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sun, 6 Jan 2008 15:56:24 +0000 Subject: Constify bits of the OGM subtitle hack. Add a changelog entry. --- src/libsputext/xine_sputext_decoder.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/libsputext/xine_sputext_decoder.c b/src/libsputext/xine_sputext_decoder.c index d45886300..d0cab9cbf 100644 --- a/src/libsputext/xine_sputext_decoder.c +++ b/src/libsputext/xine_sputext_decoder.c @@ -507,10 +507,8 @@ static void read_ssa_tag(sputext_decoder_t *this, const char* text, } static int is_cjk_encoding(const char *enc) { - char **pstr; - /* CJK charset strings defined in iconvdata/gconv-modules of glibc */ - static char *cjk_encoding_strings[] = { + static const char cjk_encoding_strings[][16] = { "SJIS", "CP932", "EUC-KR", @@ -534,15 +532,15 @@ static int is_cjk_encoding(const char *enc) { "GB18030", "EUC-JISX0213", "SHIFT_JISX0213", - NULL }; + int pstr; + /* return 1 if encoding string is one of the CJK(Chinese,Jananese,Korean) * character set strings. */ - for (pstr = cjk_encoding_strings; *pstr; pstr++) { - if (strcasecmp(enc, *pstr) == 0) + for (pstr = 0; pstr < sizeof (cjk_encoding_strings) / sizeof (cjk_encoding_strings[0]); pstr++) + if (strcasecmp (enc, cjk_encoding_strings[pstr]) == 0) return 1; - } return 0; } @@ -552,7 +550,7 @@ static void draw_subtitle(sputext_decoder_t *this, int64_t sub_start, int64_t su int line, y; int font_size; char *font; - char *encoding = (this->buf_encoding)?this->buf_encoding: + const char *encoding = (this->buf_encoding)?this->buf_encoding: this->class->src_encoding; int sub_x, sub_y, max_width; int alignment; -- cgit v1.2.3 From 108b12c4b3abb63f4ac39bfed1fe44f2e1bab6c3 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 9 Jan 2008 18:37:35 +0000 Subject: Some lexer state tokenisation which somehow slipped through a crack somewhere. --- src/xine-utils/xmllexer.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/xine-utils/xmllexer.c b/src/xine-utils/xmllexer.c index 579007e52..75a1aafec 100644 --- a/src/xine-utils/xmllexer.c +++ b/src/xine-utils/xmllexer.c @@ -531,27 +531,28 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) { /* Terminate the current token */ tok[tok_pos] = '\0'; switch (state) { - case 0: - case 1: - case 2: + case STATE_IDLE: + case STATE_EOL: + case STATE_SEPAR: return T_EOF; break; - case 3: + case STATE_T_M_START: return T_M_START_1; break; - case 4: + case STATE_T_M_STOP_1: return T_M_STOP_1; break; - case 5: + case STATE_T_M_STOP_2: return T_ERROR; break; - case 6: + case STATE_T_EQUAL: return T_EQUAL; break; - case 7: + case STATE_T_STRING_SINGLE: + case STATE_T_STRING_DOUBLE: return T_STRING; break; - case 100: + case STATE_IDENT: return T_DATA; break; default: -- cgit v1.2.3 From f3e691cf556bd4ad1338f222ffcf5eaecafd6a24 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Fri, 11 Jan 2008 13:49:08 +0000 Subject: Fix a buffer overflow in the RTSP header-handling code. CVE-2008-0225; ported from mplayer changeset 22821. --- src/input/libreal/rmff.c | 85 +++++++++++++++++++++++++++++----------- src/input/libreal/rmff.h | 6 +++ src/input/librtsp/rtsp_session.c | 6 +++ 3 files changed, 75 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/input/libreal/rmff.c b/src/input/libreal/rmff.c index 159b81ee6..b79eb5e0f 100644 --- a/src/input/libreal/rmff.c +++ b/src/input/libreal/rmff.c @@ -35,9 +35,13 @@ * writes header data to a buffer */ -static void rmff_dump_fileheader(rmff_fileheader_t *fileheader, char *buffer) { +static int rmff_dump_fileheader(rmff_fileheader_t *fileheader, uint8_t *buffer, int bufsize) { + + if (!fileheader) return 0; + + if (bufsize < RMFF_FILEHEADER_SIZE) + return -1; - if (!fileheader) return; fileheader->object_id=_X_BE_32(&fileheader->object_id); fileheader->size=_X_BE_32(&fileheader->size); fileheader->object_version=_X_BE_16(&fileheader->object_version); @@ -53,11 +57,17 @@ static void rmff_dump_fileheader(rmff_fileheader_t *fileheader, char *buffer) { fileheader->file_version=_X_BE_32(&fileheader->file_version); fileheader->num_headers=_X_BE_32(&fileheader->num_headers); fileheader->object_id=_X_BE_32(&fileheader->object_id); + + return RMFF_FILEHEADER_SIZE; } -static void rmff_dump_prop(rmff_prop_t *prop, char *buffer) { +static int rmff_dump_prop(rmff_prop_t *prop, uint8_t *buffer, int bufsize) { + + if (!prop) return 0; + + if (bufsize < RMFF_PROPHEADER_SIZE) + return -1; - if (!prop) return; prop->object_id=_X_BE_32(&prop->object_id); prop->size=_X_BE_32(&prop->size); prop->object_version=_X_BE_16(&prop->object_version); @@ -93,13 +103,19 @@ static void rmff_dump_prop(rmff_prop_t *prop, char *buffer) { prop->num_streams=_X_BE_16(&prop->num_streams); prop->flags=_X_BE_16(&prop->flags); prop->object_id=_X_BE_32(&prop->object_id); + + return RMFF_PROPHEADER_SIZE; } -static void rmff_dump_mdpr(rmff_mdpr_t *mdpr, char *buffer) { +static int rmff_dump_mdpr(rmff_mdpr_t *mdpr, uint8_t *buffer, int bufsize) { int s1, s2, s3; - if (!mdpr) return; + if (!mdpr) return 0; + + if (bufsize < RMFF_MDPRHEADER_SIZE + mdpr->type_specific_len + mdpr->stream_name_size + mdpr->mime_type_size) + return -1; + mdpr->object_id=_X_BE_32(&mdpr->object_id); mdpr->size=_X_BE_32(&mdpr->size); mdpr->object_version=_X_BE_16(&mdpr->object_version); @@ -141,13 +157,19 @@ static void rmff_dump_mdpr(rmff_mdpr_t *mdpr, char *buffer) { mdpr->duration=_X_BE_32(&mdpr->duration); mdpr->object_id=_X_BE_32(&mdpr->object_id); + return RMFF_MDPRHEADER_SIZE + s1 + s2 + s3; } -static void rmff_dump_cont(rmff_cont_t *cont, char *buffer) { +static int rmff_dump_cont(rmff_cont_t *cont, uint8_t *buffer, int bufsize) { int p; - if (!cont) return; + if (!cont) return 0; + + if (bufsize < RMFF_CONTHEADER_SIZE + cont->title_len + cont->author_len + + cont->copyright_len + cont->comment_len) + return -1; + cont->object_id=_X_BE_32(&cont->object_id); cont->size=_X_BE_32(&cont->size); cont->object_version=_X_BE_16(&cont->object_version); @@ -181,11 +203,18 @@ static void rmff_dump_cont(rmff_cont_t *cont, char *buffer) { cont->size=_X_BE_32(&cont->size); cont->object_version=_X_BE_16(&cont->object_version); cont->object_id=_X_BE_32(&cont->object_id); + + return RMFF_CONTHEADER_SIZE + cont->title_len + cont->author_len + + cont->copyright_len + cont->comment_len; } -static void rmff_dump_dataheader(rmff_data_t *data, char *buffer) { +static int rmff_dump_dataheader(rmff_data_t *data, uint8_t *buffer, int bufsize) { + + if (!data) return 0; + + if (bufsize < RMFF_DATAHEADER_SIZE) + return -1; - if (!data) return; data->object_id=_X_BE_32(&data->object_id); data->size=_X_BE_32(&data->size); data->object_version=_X_BE_16(&data->object_version); @@ -201,31 +230,43 @@ static void rmff_dump_dataheader(rmff_data_t *data, char *buffer) { data->size=_X_BE_32(&data->size); data->object_version=_X_BE_16(&data->object_version); data->object_id=_X_BE_32(&data->object_id); + + return RMFF_DATAHEADER_SIZE; } -int rmff_dump_header(rmff_header_t *h, char *buffer, int max) { +int rmff_dump_header(rmff_header_t *h, void *buf_gen, int max) { + uint8_t *buffer = buf_gen; - int written=0; + int written=0, size; rmff_mdpr_t **stream=h->streams; - rmff_dump_fileheader(h->fileheader, &buffer[written]); - written+=h->fileheader->size; - rmff_dump_prop(h->prop, &buffer[written]); - written+=h->prop->size; - rmff_dump_cont(h->cont, &buffer[written]); - written+=h->cont->size; + if ((size=rmff_dump_fileheader(h->fileheader, &buffer[written], max)) < 0) + return -1; + written+=size; + max -= size; + if ((size=rmff_dump_prop(h->prop, &buffer[written], max)) < 0) + return -1; + written+=size; + max -= size; + if ((size=rmff_dump_cont(h->cont, &buffer[written], max)) < 0) + return -1; + written+=size; + max -= size; if (stream) { while(*stream) { - rmff_dump_mdpr(*stream, &buffer[written]); - written+=(*stream)->size; + if ((size=rmff_dump_mdpr(*stream, &buffer[written], max)) < 0) + return -1; + written+=size; + max -= size; stream++; } } - rmff_dump_dataheader(h->data, &buffer[written]); - written+=18; + if ((size=rmff_dump_dataheader(h->data, &buffer[written], max)) < 0) + return -1; + written+=size; return written; } diff --git a/src/input/libreal/rmff.h b/src/input/libreal/rmff.h index d39942088..5288fc558 100644 --- a/src/input/libreal/rmff.h +++ b/src/input/libreal/rmff.h @@ -39,6 +39,12 @@ #define RMFF_HEADER_SIZE 0x12 +#define RMFF_FILEHEADER_SIZE 18 +#define RMFF_PROPHEADER_SIZE 50 +#define RMFF_MDPRHEADER_SIZE 46 +#define RMFF_CONTHEADER_SIZE 18 +#define RMFF_DATAHEADER_SIZE 18 + #define FOURCC_TAG( ch0, ch1, ch2, ch3 ) \ (((long)(unsigned char)(ch3) ) | \ ( (long)(unsigned char)(ch2) << 8 ) | \ diff --git a/src/input/librtsp/rtsp_session.c b/src/input/librtsp/rtsp_session.c index f3ddb59bc..5b02282e9 100644 --- a/src/input/librtsp/rtsp_session.c +++ b/src/input/librtsp/rtsp_session.c @@ -148,6 +148,11 @@ connect: rtsp_session->header_left = rtsp_session->header_len = rmff_dump_header(h,rtsp_session->header,HEADER_SIZE); + if (rtsp_session->header_len < 0) { + xprintf (stream->xine, XINE_VERBOSITY_LOG, + _("rtsp_session: rtsp server returned overly-large headers, session can not be established.\n")); + goto session_abort; + } xine_buffer_copyin(rtsp_session->recv, 0, rtsp_session->header, rtsp_session->header_len); rtsp_session->recv_size = rtsp_session->header_len; @@ -157,6 +162,7 @@ connect: { xprintf(stream->xine, XINE_VERBOSITY_LOG, _("rtsp_session: rtsp server type '%s' not supported yet. sorry.\n"), server); + session_abort: rtsp_close(rtsp_session->s); free(server); xine_buffer_free(rtsp_session->recv); -- cgit v1.2.3 From a9aa9d58524fd95b1babe4a47308b126899c1113 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Fri, 11 Jan 2008 15:21:53 +0000 Subject: Correct the prototype of rmff_dump_header. (Build fix.) --- src/input/libreal/rmff.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/input/libreal/rmff.h b/src/input/libreal/rmff.h index 5288fc558..b03d12b1b 100644 --- a/src/input/libreal/rmff.h +++ b/src/input/libreal/rmff.h @@ -251,7 +251,7 @@ int rmff_get_header_size(rmff_header_t *h); /* * dumps the header to . is the size of */ -int rmff_dump_header(rmff_header_t *h, char *buffer, int max); +int rmff_dump_header(rmff_header_t *h, void *buf_gen, int max); /* * dumps a packet header -- cgit v1.2.3 From 0c0bc8da469f415f3558010658df40349f9eca74 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Fri, 11 Jan 2008 15:35:04 +0000 Subject: XineOpenViewGL bug on PPC/Darwin Typo of WORDS_BIGENDIAN in in /src/video_out/macosx/XineVOpenGLView.m. It only affects big-endian systems (PowerPC) as it defaults to little-endian. --- src/video_out/macosx/XineOpenGLView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/video_out/macosx/XineOpenGLView.m b/src/video_out/macosx/XineOpenGLView.m index a9ffee00f..1f947ca16 100644 --- a/src/video_out/macosx/XineOpenGLView.m +++ b/src/video_out/macosx/XineOpenGLView.m @@ -340,7 +340,7 @@ NSColorToYUV(NSColor *color) // http://developer.apple.com/samplecode/Sample_Code/Graphics_3D/TextureRange/MainOpenGLView.m.htm glTexSubImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, videoSize.width, videoSize.height, GL_YCBCR_422_APPLE, -#if WORDS_BIG_ENDIAN +#if WORDS_BIGENDIAN GL_UNSIGNED_SHORT_8_8_APPLE, #else GL_UNSIGNED_SHORT_8_8_REV_APPLE, -- cgit v1.2.3 From 37e7a5aa4c03f8793dc9da8058a5625f5ff84d4b Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Sat, 12 Jan 2008 15:48:13 +0100 Subject: Don't send BUF_FLAG_FRAME_START twice per frame, otherwise the ffmpeg plugin skips the first part of the frame. Fixed wmv playback with ffmpeg. --- src/demuxers/demux_asf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_asf.c b/src/demuxers/demux_asf.c index 9aab59977..c4a154f99 100644 --- a/src/demuxers/demux_asf.c +++ b/src/demuxers/demux_asf.c @@ -723,6 +723,9 @@ static void asf_send_buffer_nodefrag (demux_asf_t *this, asf_demux_stream_t *str buf->size = bufsize; timestamp = 0; + if (stream->frag_offset == 0) + buf->decoder_flags |= BUF_FLAG_FRAME_START; + stream->frag_offset += bufsize; frag_len -= bufsize; @@ -733,10 +736,6 @@ static void asf_send_buffer_nodefrag (demux_asf_t *this, asf_demux_stream_t *str else check_newpts (this, buf->pts, PTS_AUDIO, package_done); - - if (frag_offset == 0) - buf->decoder_flags |= BUF_FLAG_FRAME_START; - /* test if whole packet read */ if (package_done) { buf->decoder_flags |= BUF_FLAG_FRAME_END; -- cgit v1.2.3 From 1324f12dc8213fc0f7e4549665f7d3f5b7f3100e Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Sat, 12 Jan 2008 16:51:25 +0100 Subject: Fixed metadata reading when length=0. Fixed bug id=17. --- src/demuxers/asfheader.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/demuxers/asfheader.c b/src/demuxers/asfheader.c index ea92f878b..eb74c0886 100644 --- a/src/demuxers/asfheader.c +++ b/src/demuxers/asfheader.c @@ -142,9 +142,9 @@ static uint8_t *asf_reader_get_bytes(asf_reader_t *reader, size_t size) { static char *asf_reader_get_string(asf_reader_t *reader, size_t size, iconv_t cd) { char *inbuf, *outbuf; size_t inbytesleft, outbytesleft; - char scratch[2048]; + char scratch[2048]; - if ((reader->size - reader->pos) < size) + if ((size == 0) ||((reader->size - reader->pos) < size)) return NULL; inbuf = (char *)reader->buffer + reader->pos; @@ -599,6 +599,12 @@ static int asf_header_parse_content_description(asf_header_t *header_pub, uint8_ content->description = asf_reader_get_string(&reader, description_length, header->iconv_cd); content->rating = asf_reader_get_string(&reader, rating_length, header->iconv_cd); + lprintf("title: %d chars: \"%s\"\n", title_length, content->title); + lprintf("author: %d chars: \"%s\"\n", author_length, content->author); + lprintf("copyright: %d chars: \"%s\"\n", copyright_length, content->copyright); + lprintf("description: %d chars: \"%s\"\n", description_length, content->description); + lprintf("rating: %d chars: \"%s\"\n", rating_length, content->rating); + header->pub.content = content; return 1; } -- cgit v1.2.3 From 1a2ce4b7f270a680f2510a525926ba31b8b385f0 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Sun, 13 Jan 2008 17:27:39 +0100 Subject: Added data accumulation logic. Fixed bug id=2. --- src/libxineadec/xine_vorbis_decoder.c | 250 +++++++++++++++++++--------------- 1 file changed, 141 insertions(+), 109 deletions(-) (limited to 'src') diff --git a/src/libxineadec/xine_vorbis_decoder.c b/src/libxineadec/xine_vorbis_decoder.c index 4b7a6c15d..b3acff811 100644 --- a/src/libxineadec/xine_vorbis_decoder.c +++ b/src/libxineadec/xine_vorbis_decoder.c @@ -41,6 +41,7 @@ #include #define MAX_NUM_SAMPLES 4096 +#define INIT_BUFSIZE 8192 typedef struct { audio_decoder_class_t decoder_class; @@ -70,6 +71,11 @@ typedef struct vorbis_decoder_s { xine_stream_t *stream; + /* data accumulation stuff */ + unsigned char *buf; + int bufsize; + int size; + } vorbis_decoder_t; @@ -78,6 +84,7 @@ static void vorbis_reset (audio_decoder_t *this_gen) { vorbis_decoder_t *this = (vorbis_decoder_t *) this_gen; if( this->header_count ) return; + this->size = 0; /* clear block first, as it might contain allocated data */ vorbis_block_clear(&this->vb); @@ -136,126 +143,147 @@ static void get_metadata (vorbis_decoder_t *this) { _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "vorbis"); } +static void vorbis_check_bufsize (vorbis_decoder_t *this, int size) { + if (size > this->bufsize) { + this->bufsize = size + size / 2; + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + _("vorbis: increasing buffer to %d to avoid overflow.\n"), + this->bufsize); + this->buf = realloc(this->buf, this->bufsize); + } +} + static void vorbis_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { vorbis_decoder_t *this = (vorbis_decoder_t *) this_gen; memset( &this->op, 0, sizeof(this->op) ); - this->op.packet = buf->content; - this->op.bytes = buf->size; - - if ( (buf->decoder_flags & BUF_FLAG_HEADER) && - !(buf->decoder_flags & BUF_FLAG_STDHEADER) ) { - lprintf ("%d headers to go\n", this->header_count); - if (this->header_count) { - int res = 0; + /* data accumulation */ + vorbis_check_bufsize(this, this->size + buf->size); + xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size); + this->size += buf->size; - if (this->header_count == 3) - this->op.b_o_s = 1; + if (buf->decoder_flags & BUF_FLAG_FRAME_END) { + this->op.packet = this->buf; + this->op.bytes = this->size; - - if( (res = vorbis_synthesis_headerin(&this->vi,&this->vc,&this->op)) < 0 ){ - /* error case; not a vorbis header */ - xine_log(this->stream->xine, XINE_LOG_MSG, "libvorbis: this bitstream does not contain vorbis audio data. Following first 64 bytes (return: %d).\n", res); - xine_hexdump((char *)this->op.packet, this->op.bytes < 64 ? this->op.bytes : 64); - return; - } - - this->header_count--; - - if (!this->header_count) { - - int mode = AO_CAP_MODE_MONO; - - get_metadata (this); - - mode = _x_ao_channels2mode(this->vi.channels); - - this->convsize=MAX_NUM_SAMPLES/this->vi.channels; - - if (!this->output_open) { - this->output_open = (this->stream->audio_out->open) (this->stream->audio_out, - this->stream, - 16, - this->vi.rate, - mode) ; - - _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITRATE, - this->vi.bitrate_nominal); - - } - - /* OK, got and parsed all three headers. Initialize the Vorbis - * packet->PCM decoder. */ - lprintf("all three headers parsed. initializing decoder.\n"); - /* initialize central decode state */ - vorbis_synthesis_init(&this->vd,&this->vi); - /* initialize local state for most of the decode so multiple - * block decodes can proceed in parallel. We could init - * multiple vorbis_block structures for vd here */ - vorbis_block_init(&this->vd,&this->vb); + /* reset accumultaion buffer */ + this->size = 0; + + if ( (buf->decoder_flags & BUF_FLAG_HEADER) && + !(buf->decoder_flags & BUF_FLAG_STDHEADER) ) { + + lprintf ("%d headers to go\n", this->header_count); + + if (this->header_count) { + int res = 0; + + if (this->header_count == 3) + this->op.b_o_s = 1; + + if ( (res = vorbis_synthesis_headerin(&this->vi,&this->vc,&this->op)) < 0 ) { + /* error case; not a vorbis header */ + xine_log(this->stream->xine, XINE_LOG_MSG, "libvorbis: this bitstream does not contain vorbis audio data. Following first 64 bytes (return: %d).\n", res); + xine_hexdump((char *)this->op.packet, this->op.bytes < 64 ? this->op.bytes : 64); + return; + } + + this->header_count--; + + if (!this->header_count) { + + int mode = AO_CAP_MODE_MONO; + + get_metadata (this); + + mode = _x_ao_channels2mode(this->vi.channels); + + this->convsize=MAX_NUM_SAMPLES/this->vi.channels; + + if (!this->output_open) { + this->output_open = (this->stream->audio_out->open) (this->stream->audio_out, + this->stream, + 16, + this->vi.rate, + mode) ; + + _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITRATE, + this->vi.bitrate_nominal); + + } + + /* OK, got and parsed all three headers. Initialize the Vorbis + * packet->PCM decoder. */ + lprintf("all three headers parsed. initializing decoder.\n"); + /* initialize central decode state */ + vorbis_synthesis_init(&this->vd,&this->vi); + /* initialize local state for most of the decode so multiple + * block decodes can proceed in parallel. We could init + * multiple vorbis_block structures for vd here */ + vorbis_block_init(&this->vd,&this->vb); + } } - } - - } else if (this->output_open) { - - float **pcm; - int samples; - - if(vorbis_synthesis(&this->vb,&this->op)==0) - vorbis_synthesis_blockin(&this->vd,&this->vb); - - if (buf->pts!=0) - this->pts=buf->pts; - - while ((samples=vorbis_synthesis_pcmout(&this->vd,&pcm))>0){ - - /* **pcm is a multichannel float vector. In stereo, for - * example, pcm[0][...] is left, and pcm[1][...] is right. - * samples is the size of each channel. Convert the float - * values (-1.<=range<=1.) to whatever PCM format and write - * it out - */ - - int i,j; - int bout=(samplesconvsize?samples:this->convsize); - audio_buffer_t *audio_buffer; - - audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out); - - /* convert floats to 16 bit signed ints (host order) and - interleave */ - for(i=0;ivi.channels;i++){ - ogg_int16_t *ptr=audio_buffer->mem+i; - float *mono=pcm[i]; - for(j=0;j32767){ - val=32767; - } else if(val<-32768){ - val=-32768; - } - *ptr=val; - ptr+=this->vi.channels; - } + + } else if (this->output_open) { + + float **pcm; + int samples; + + if(vorbis_synthesis(&this->vb,&this->op)==0) + vorbis_synthesis_blockin(&this->vd,&this->vb); + + if (buf->pts!=0) + this->pts=buf->pts; + + while ((samples=vorbis_synthesis_pcmout(&this->vd,&pcm))>0){ + + /* **pcm is a multichannel float vector. In stereo, for + * example, pcm[0][...] is left, and pcm[1][...] is right. + * samples is the size of each channel. Convert the float + * values (-1.<=range<=1.) to whatever PCM format and write + * it out + */ + + int i,j; + int bout=(samplesconvsize?samples:this->convsize); + audio_buffer_t *audio_buffer; + + audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out); + + /* convert floats to 16 bit signed ints (host order) and + interleave */ + for(i=0;ivi.channels;i++){ + ogg_int16_t *ptr=audio_buffer->mem+i; + float *mono=pcm[i]; + for(j=0;j32767){ + val=32767; + } else if(val<-32768){ + val=-32768; + } + *ptr=val; + ptr+=this->vi.channels; + } + } + + audio_buffer->vpts = this->pts; + this->pts=0; + audio_buffer->num_frames = bout; + + this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream); + + buf->pts=0; + + /* tell libvorbis how many samples we actually consumed */ + vorbis_synthesis_read(&this->vd,bout); } - - audio_buffer->vpts = this->pts; - this->pts=0; - audio_buffer->num_frames = bout; - - this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream); - - buf->pts=0; - - /* tell libvorbis how many samples we actually consumed */ - vorbis_synthesis_read(&this->vd,bout); + } else { + lprintf("output not open\n"); } - } else { - lprintf("output not open\n"); } } @@ -299,6 +327,10 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, this->header_count = 3; this->convsize = 0; + this->bufsize = INIT_BUFSIZE; + this->buf = xine_xmalloc(INIT_BUFSIZE); + this->size = 0; + vorbis_info_init(&this->vi); vorbis_comment_init(&this->vc); -- cgit v1.2.3 From 934857924c40f5fc075359f8ad60bf49e4687d24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Mon, 14 Jan 2008 19:45:14 +0100 Subject: Support all the extensions reported by xiph's documentation (plus ogm). --- src/demuxers/demux_ogg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c index 9ed39f12d..43ab3cb36 100644 --- a/src/demuxers/demux_ogg.c +++ b/src/demuxers/demux_ogg.c @@ -2155,7 +2155,7 @@ static const char *ogg_get_identifier (demux_class_t *this_gen) { } static const char *ogg_get_extensions (demux_class_t *this_gen) { - return "ogg ogm spx"; + return "ogx ogv oga ogg spx ogm"; } static const char *ogg_get_mimetypes (demux_class_t *this_gen) { -- cgit v1.2.3 From 7558fb41b257c2d05e243c9c3640bf5c08c4808d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Mon, 14 Jan 2008 20:05:42 +0100 Subject: Update mimetypes for Annodex and Ogg. --- src/demuxers/demux_ogg.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c index 43ab3cb36..d1b522727 100644 --- a/src/demuxers/demux_ogg.c +++ b/src/demuxers/demux_ogg.c @@ -2118,7 +2118,9 @@ static const char *anx_get_extensions (demux_class_t *this_gen) { } static const char *anx_get_mimetypes (demux_class_t *this_gen) { - return "application/x-annodex: ogg: Annodex media;"; + return "application/annodex: anx: Annodex media;" + "audio/annodex: axa: Annodex audio;" + "video/annodex: axv: Annodex video;"; } static void anx_class_dispose (demux_class_t *this_gen) { @@ -2159,10 +2161,9 @@ static const char *ogg_get_extensions (demux_class_t *this_gen) { } static const char *ogg_get_mimetypes (demux_class_t *this_gen) { - return "audio/x-ogg: ogg: OggVorbis Audio;" - "audio/x-speex: ogg: Speex Audio;" - "application/x-ogg: ogg: Ogg Stream;" - "application/ogg: ogg: Ogg Stream;"; + return "application/ogg: ogx: Ogg Stream;" + "audio/ogg: oga: Ogg Audio;" + "video/ogg: ogv: Ogg Video;"; } static void ogg_class_dispose (demux_class_t *this_gen) { -- cgit v1.2.3 From 4392eb46e57120ef2c17d34ed07df089c16cd730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Mon, 14 Jan 2008 20:08:23 +0100 Subject: Update demuxer for 1.2 branch to the correct extensions and mimetype declared by Xiph. --- src/combined/xine_ogg_demuxer.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/combined/xine_ogg_demuxer.c b/src/combined/xine_ogg_demuxer.c index d6b5ea214..f5a1e5306 100644 --- a/src/combined/xine_ogg_demuxer.c +++ b/src/combined/xine_ogg_demuxer.c @@ -2079,7 +2079,10 @@ static void *anx_init_class (xine_t *xine, void *data) { this->demux_class.open_plugin = anx_open_plugin; this->demux_class.description = N_("Annodex demux plugin"); this->demux_class.identifier = "Annodex"; - this->demux_class.mimetypes = "application/x-annodex: ogg: Annodex media;"; + this->demux_class.mimetypes = + "application/annodex: anx: Annodex media;" + "audio/annodex: axa: Annodex audio;" + "video/annodex: axv: Annodex video;"; this->demux_class.extensions = "anx axa axv"; this->demux_class.dispose = default_demux_class_dispose; @@ -2098,11 +2101,10 @@ static void *ogg_init_class (xine_t *xine, void *data) { this->demux_class.description = N_("OGG demux plugin"); this->demux_class.identifier = "OGG"; this->demux_class.mimetypes = - "audio/x-ogg: ogg: OggVorbis Audio;" - "audio/x-speex: ogg: Speex Audio;" - "application/x-ogg: ogg: Ogg Stream;" - "application/ogg: ogg: Ogg Stream;"; - this->demux_class.extensions = "ogg ogm spx"; + "application/ogg: ogx: Ogg Stream;" + "audio/ogg: oga: Ogg Audio;" + "video/ogg: ogv: Ogg Video;" + this->demux_class.extensions = "ogx ogv oga ogg spx ogm"; this->demux_class.dispose = default_demux_class_dispose; return this; -- cgit v1.2.3 From bc09805e004f1a68d7a632a38ed6309f6c9ec356 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Mon, 14 Jan 2008 23:24:15 +0000 Subject: Change the default v4l device paths to /dev/{video,radio}0. --- src/input/input_v4l.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/input/input_v4l.c b/src/input/input_v4l.c index b43a2684a..34f6a0684 100644 --- a/src/input/input_v4l.c +++ b/src/input/input_v4l.c @@ -91,8 +91,8 @@ static const resolution_t resolutions[] = { }; #define NUM_RESOLUTIONS (sizeof(resolutions)/sizeof(resolutions[0])) -#define RADIO_DEV "/dev/v4l/radio0" -#define VIDEO_DEV "/dev/v4l/video0" +#define RADIO_DEV "/dev/radio0" +#define VIDEO_DEV "/dev/video0" #if !defined(NDELAY) && defined(O_NDELAY) #define FNDELAY O_NDELAY -- cgit v1.2.3 From fa109cc055ecf40ec01f82f313ed2cccf094bbaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Tue, 15 Jan 2008 16:31:32 +0100 Subject: Fix missing semicolon. --- src/combined/xine_ogg_demuxer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/combined/xine_ogg_demuxer.c b/src/combined/xine_ogg_demuxer.c index f5a1e5306..e0610f5ca 100644 --- a/src/combined/xine_ogg_demuxer.c +++ b/src/combined/xine_ogg_demuxer.c @@ -2103,7 +2103,7 @@ static void *ogg_init_class (xine_t *xine, void *data) { this->demux_class.mimetypes = "application/ogg: ogx: Ogg Stream;" "audio/ogg: oga: Ogg Audio;" - "video/ogg: ogv: Ogg Video;" + "video/ogg: ogv: Ogg Video;"; this->demux_class.extensions = "ogx ogv oga ogg spx ogm"; this->demux_class.dispose = default_demux_class_dispose; -- cgit v1.2.3 From e5ad26d14f37f097be7284dbf972ddae35dfec36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Tue, 15 Jan 2008 17:09:22 +0100 Subject: Use GCSECTIONS for libxine too. --- src/xine-engine/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/xine-engine/Makefile.am b/src/xine-engine/Makefile.am index 49757f841..2942d3560 100644 --- a/src/xine-engine/Makefile.am +++ b/src/xine-engine/Makefile.am @@ -33,7 +33,7 @@ libxine_la_LIBADD = $(PTHREAD_LIBS) $(DYNAMIC_LD_LIBS) $(LTLIBINTL) $(ZLIB_LIBS) -lm $(XINEUTILS_LIB) $(LTLIBICONV) $(FT2_LIBS) $(FONTCONFIG_LIBS) \ $(LIBXINEPOSIX) $(RT_LIBS) $(NET_LIBS) $(XDG_BASEDIR_LIBS) -libxine_la_LDFLAGS = $(AM_LDFLAGS) $(def_ldflags) \ +libxine_la_LDFLAGS = $(AM_LDFLAGS) $(def_ldflags) $(GCSECTIONS) \ -version-info $(XINE_LT_CURRENT):$(XINE_LT_REVISION):$(XINE_LT_AGE) $(XINEUTILS_LIB): -- cgit v1.2.3 From eef1dd9c03642f1abeee307a6786566ce3ef7e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 16 Jan 2008 19:45:26 +0100 Subject: Remove deprecated unused functions. --- src/input/input_dvb.c | 3 --- src/input/input_pnm.c | 2 -- src/input/input_rtsp.c | 2 -- src/input/net_buf_ctrl.c | 23 ----------------------- src/input/net_buf_ctrl.h | 6 ------ 5 files changed, 36 deletions(-) (limited to 'src') diff --git a/src/input/input_dvb.c b/src/input/input_dvb.c index b3a9d8e46..07aefc362 100644 --- a/src/input/input_dvb.c +++ b/src/input/input_dvb.c @@ -2496,9 +2496,6 @@ static off_t dvb_plugin_read (input_plugin_t *this_gen, "input_dvb: reading %" PRIdMAX " bytes...\n", (intmax_t)len); #endif -#ifndef DVB_NO_BUFFERING - nbc_check_buffers (this->nbc); -#endif /* protect against channel changes */ have_mutex = pthread_mutex_lock(&this->channel_change_mutex); total=0; diff --git a/src/input/input_pnm.c b/src/input/input_pnm.c index 3271a04c9..e11e3b361 100644 --- a/src/input/input_pnm.c +++ b/src/input/input_pnm.c @@ -83,8 +83,6 @@ static off_t pnm_plugin_read (input_plugin_t *this_gen, lprintf ("pnm_plugin_read: %"PRId64" bytes ...\n", len); - nbc_check_buffers (this->nbc); - n = pnm_read (this->pnm, buf, len); this->curpos += n; diff --git a/src/input/input_rtsp.c b/src/input/input_rtsp.c index bee192c0d..e2b1bae99 100644 --- a/src/input/input_rtsp.c +++ b/src/input/input_rtsp.c @@ -83,8 +83,6 @@ static off_t rtsp_plugin_read (input_plugin_t *this_gen, lprintf ("rtsp_plugin_read: %"PRId64" bytes ...\n", len); - nbc_check_buffers (this->nbc); - n = rtsp_session_read (this->rtsp, buf, len); this->curpos += n; diff --git a/src/input/net_buf_ctrl.c b/src/input/net_buf_ctrl.c index aaf575e40..03a24d38f 100644 --- a/src/input/net_buf_ctrl.c +++ b/src/input/net_buf_ctrl.c @@ -113,10 +113,6 @@ static void nbc_set_speed_normal (nbc_t *this) { stream->xine->clock->set_option (stream->xine->clock, CLOCK_SCR_ADJUSTABLE, 1); } -void nbc_check_buffers (nbc_t *this) { - /* Deprecated */ -} - static void display_stats (nbc_t *this) { static const char buffering[2][4] = {" ", "buf"}; static const char enabled[2][4] = {"off", "on "}; @@ -564,22 +560,3 @@ void nbc_close (nbc_t *this) { free (this); xprintf(xine, XINE_VERBOSITY_DEBUG, "\nnet_buf_ctrl: nbc_close: done\n"); } - - -void nbc_set_high_water_mark(nbc_t *this, int value) { -/* - Deprecated - this->high_water_mark = value; -*/ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, - "\nnet_buf_ctrl: this method is deprecated, please fix the input plugin\n"); -} - -void nbc_set_low_water_mark(nbc_t *this, int value) { -/* - Deprecated - this->low_water_mark = value; -*/ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, - "\nnet_buf_ctrl: this method is deprecated, please fix the input plugin\n"); -} diff --git a/src/input/net_buf_ctrl.h b/src/input/net_buf_ctrl.h index c35187179..87d6d84a1 100644 --- a/src/input/net_buf_ctrl.h +++ b/src/input/net_buf_ctrl.h @@ -29,12 +29,6 @@ typedef struct nbc_s nbc_t; nbc_t *nbc_init (xine_stream_t *xine); -void nbc_check_buffers (nbc_t *this); - void nbc_close (nbc_t *this); -void nbc_set_high_water_mark(nbc_t *this, int value); - -void nbc_set_low_water_mark(nbc_t *this, int value); - #endif -- cgit v1.2.3 From abef42f0fb968e8489b2ac46963530ab81e2f3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 16 Jan 2008 19:49:58 +0100 Subject: Make _x_canonicalise_url an inline function, as it's only ever used once (either in input_http or in the test for http_helper). --- src/input/http_helper.c | 23 ----------------------- src/input/http_helper.h | 24 +++++++++++++++++++++++- 2 files changed, 23 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/input/http_helper.c b/src/input/http_helper.c index 83562c9dc..f4950a084 100644 --- a/src/input/http_helper.c +++ b/src/input/http_helper.c @@ -220,29 +220,6 @@ error: return 0; } -char *_x_canonicalise_url (const char *base, const char *url) { - - size_t base_length; - char *cut, *ret; - - if ((cut = strstr (url, "://"))) - return strdup (url); - - cut = strstr (base, "://"); - if (url[0] == '/') { - /* absolute - base up to first '/' after "://", then url */ - cut = strchr (cut + 3, '/'); - } - else { - /* relative - base up to & inc. last '/', then url */ - cut = strrchr (cut, '/'); - if (cut) - ++cut; - } - base_length = cut ? (size_t)(cut - base) : strlen (base); - asprintf (&ret, "%.*s%s", (int)base_length, base, url); - return ret; -} #ifdef TEST_URL /* diff --git a/src/input/http_helper.h b/src/input/http_helper.h index 3ce3f2b7c..9baa05235 100644 --- a/src/input/http_helper.h +++ b/src/input/http_helper.h @@ -43,6 +43,28 @@ int _x_parse_url (char *url, char **proto, char** host, int *port, * return: * the canonicalised URL (caller must free() it) */ -char *_x_canonicalise_url (const char *base, const char *url); +static inline char *_x_canonicalise_url (const char *base, const char *url) { + + size_t base_length; + char *cut, *ret; + + if ((cut = strstr (url, "://"))) + return strdup (url); + + cut = strstr (base, "://"); + if (url[0] == '/') { + /* absolute - base up to first '/' after "://", then url */ + cut = strchr (cut + 3, '/'); + } + else { + /* relative - base up to & inc. last '/', then url */ + cut = strrchr (cut, '/'); + if (cut) + ++cut; + } + base_length = cut ? (size_t)(cut - base) : strlen (base); + asprintf (&ret, "%.*s%s", (int)base_length, base, url); + return ret; +} #endif /* HTTP_HELPER_H */ -- cgit v1.2.3 From 1adcc214c14fb6d8a5c78ff62e4bb16f1c1d1e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 16 Jan 2008 20:00:50 +0100 Subject: Put under #if 0 a few functions that never gets used in xine at all. --- src/input/libreal/rmff.c | 6 ++++++ src/input/libreal/rmff.h | 6 ++++++ src/input/librtsp/rtsp.c | 6 ++++++ src/input/librtsp/rtsp.h | 6 ++++++ 4 files changed, 24 insertions(+) (limited to 'src') diff --git a/src/input/libreal/rmff.c b/src/input/libreal/rmff.c index 0e803e4d4..1600e967a 100644 --- a/src/input/libreal/rmff.c +++ b/src/input/libreal/rmff.c @@ -475,6 +475,7 @@ rmff_header_t *rmff_scan_header(const char *data) { return header; } +#if 0 rmff_header_t *rmff_scan_header_stream(int fd) { rmff_header_t *header; @@ -525,6 +526,7 @@ void rmff_scan_pheader(rmff_pheader_t *h, char *data) { h->reserved=(uint8_t)data[10]; h->flags=(uint8_t)data[11]; } +#endif rmff_fileheader_t *rmff_new_fileheader(uint32_t num_headers) { @@ -670,6 +672,7 @@ rmff_data_t *rmff_new_dataheader(uint32_t num_packets, uint32_t next_data_header return data; } +#if 0 void rmff_print_header(rmff_header_t *h) { rmff_mdpr_t **stream; @@ -736,6 +739,7 @@ void rmff_print_header(rmff_header_t *h) { printf("next DATA : 0x%08x\n", h->data->next_data_header); } } +#endif void rmff_fix_header(rmff_header_t *h) { @@ -844,6 +848,7 @@ void rmff_fix_header(rmff_header_t *h) { } } +#if 0 int rmff_get_header_size(rmff_header_t *h) { if (!h) return 0; @@ -883,3 +888,4 @@ void rmff_free_header(rmff_header_t *h) { } free(h); } +#endif diff --git a/src/input/libreal/rmff.h b/src/input/libreal/rmff.h index 2521ebda6..3fe3af284 100644 --- a/src/input/libreal/rmff.h +++ b/src/input/libreal/rmff.h @@ -222,6 +222,7 @@ rmff_data_t *rmff_new_dataheader( */ rmff_header_t *rmff_scan_header(const char *data); +#if 0 /* * scans a data packet header. Notice, that this function does not allocate * the header struct itself. @@ -237,16 +238,19 @@ rmff_header_t *rmff_scan_header_stream(int fd); * prints header information in human readible form to stdout */ void rmff_print_header(rmff_header_t *h); +#endif /* * does some checks and fixes header if possible */ void rmff_fix_header(rmff_header_t *h); +#if 0 /* * returns the size of the header (incl. first data-header) */ int rmff_get_header_size(rmff_header_t *h); +#endif /* * dumps the header to . is the size of @@ -258,9 +262,11 @@ int rmff_dump_header(rmff_header_t *h, void *buffer, int max); */ void rmff_dump_pheader(rmff_pheader_t *h, uint8_t *data); +#if 0 /* * frees a header struct */ void rmff_free_header(rmff_header_t *h); +#endif #endif diff --git a/src/input/librtsp/rtsp.c b/src/input/librtsp/rtsp.c index cd844654b..c660751fe 100644 --- a/src/input/librtsp/rtsp.c +++ b/src/input/librtsp/rtsp.c @@ -359,12 +359,14 @@ int rtsp_request_play(rtsp_t *s, const char *what) { return rtsp_get_answers(s); } +#if 0 int rtsp_request_tearoff(rtsp_t *s, const char *what) { rtsp_send_request(s,"TEAROFF",what); return rtsp_get_answers(s); } +#endif /* * read opaque data from stream @@ -557,6 +559,7 @@ char *rtsp_search_answers(rtsp_t *s, const char *tag) { return NULL; } +#if 0 /* * session id management */ @@ -574,6 +577,7 @@ char *rtsp_get_session(rtsp_t *s) { return s->session; } +#endif char *rtsp_get_mrl(rtsp_t *s) { @@ -597,6 +601,7 @@ void rtsp_schedule_field(rtsp_t *s, const char *string) { s->scheduled[i]=strdup(string); } +#if 0 /* * removes the first scheduled field which prefix matches string. */ @@ -617,6 +622,7 @@ void rtsp_unschedule_field(rtsp_t *s, const char *string) { *(ptr-1)=*ptr; } while(*ptr); } +#endif /* * unschedule all fields diff --git a/src/input/librtsp/rtsp.h b/src/input/librtsp/rtsp.h index 3c829e2e8..1cec57e1e 100644 --- a/src/input/librtsp/rtsp.h +++ b/src/input/librtsp/rtsp.h @@ -47,7 +47,9 @@ int rtsp_request_describe(rtsp_t *s, const char *what); int rtsp_request_setup(rtsp_t *s, const char *what); int rtsp_request_setparameter(rtsp_t *s, const char *what); int rtsp_request_play(rtsp_t *s, const char *what); +#if 0 int rtsp_request_tearoff(rtsp_t *s, const char *what); +#endif int rtsp_send_ok(rtsp_t *s); @@ -61,15 +63,19 @@ void rtsp_free_answers(rtsp_t *this); int rtsp_read (rtsp_t *this, char *data, int len); void rtsp_close (rtsp_t *this); +#if 0 void rtsp_set_session(rtsp_t *s, const char *id); char *rtsp_get_session(rtsp_t *s); +#endif char *rtsp_get_mrl(rtsp_t *s); /*int rtsp_peek_header (rtsp_t *this, char *data); */ void rtsp_schedule_field(rtsp_t *s, const char *string); +#if 0 void rtsp_unschedule_field(rtsp_t *s, const char *string); +#endif void rtsp_unschedule_all(rtsp_t *s); #endif -- cgit v1.2.3 From e0f1a28dfc53c6ef22307e6e474605e47539f035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 16 Jan 2008 20:03:10 +0100 Subject: Put under #if 0 a few functions that never gets used in xine at all. --- src/demuxers/ebml.c | 4 ++++ src/demuxers/ebml.h | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'src') diff --git a/src/demuxers/ebml.c b/src/demuxers/ebml.c index 772b848eb..41a91371e 100644 --- a/src/demuxers/ebml.c +++ b/src/demuxers/ebml.c @@ -234,6 +234,7 @@ int ebml_read_uint(ebml_parser_t *ebml, ebml_elem_t *elem, uint64_t *num) { return 1; } +#if 0 int ebml_read_sint (ebml_parser_t *ebml, ebml_elem_t *elem, int64_t *num) { uint8_t data[8]; uint64_t size = elem->len; @@ -260,6 +261,7 @@ int ebml_read_sint (ebml_parser_t *ebml, ebml_elem_t *elem, int64_t *num) { return 1; } +#endif int ebml_read_float (ebml_parser_t *ebml, ebml_elem_t *elem, double *num) { @@ -304,6 +306,7 @@ int ebml_read_ascii(ebml_parser_t *ebml, ebml_elem_t *elem, char *str) { return 1; } +#if 0 int ebml_read_utf8 (ebml_parser_t *ebml, ebml_elem_t *elem, char *str) { return ebml_read_ascii (ebml, elem, str); } @@ -311,6 +314,7 @@ int ebml_read_utf8 (ebml_parser_t *ebml, ebml_elem_t *elem, char *str) { int ebml_read_date (ebml_parser_t *ebml, ebml_elem_t *elem, int64_t *date) { return ebml_read_sint (ebml, elem, date); } +#endif int ebml_read_master (ebml_parser_t *ebml, ebml_elem_t *elem) { ebml_elem_t *top_elem; diff --git a/src/demuxers/ebml.h b/src/demuxers/ebml.h index 7ebd68da2..31d825e35 100644 --- a/src/demuxers/ebml.h +++ b/src/demuxers/ebml.h @@ -83,15 +83,19 @@ int ebml_skip(ebml_parser_t *ebml, ebml_elem_t *elem); /* EBML types */ int ebml_read_uint(ebml_parser_t *ebml, ebml_elem_t *elem, uint64_t *val); +#if 0 int ebml_read_sint(ebml_parser_t *ebml, ebml_elem_t *elem, int64_t *val); +#endif int ebml_read_float(ebml_parser_t *ebml, ebml_elem_t *elem, double *val); int ebml_read_ascii(ebml_parser_t *ebml, ebml_elem_t *elem, char *str); +#if 0 int ebml_read_utf8(ebml_parser_t *ebml, ebml_elem_t *elem, char *str); int ebml_read_date(ebml_parser_t *ebml, ebml_elem_t *elem, int64_t *date); +#endif int ebml_read_master(ebml_parser_t *ebml, ebml_elem_t *elem); -- cgit v1.2.3 From e454b8cfad52523f96edafefd6e6392646c005de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 16 Jan 2008 20:03:58 +0100 Subject: Remove function never used in xine. --- src/post/visualizations/fft.c | 12 ------------ src/post/visualizations/fft.h | 1 - 2 files changed, 13 deletions(-) (limited to 'src') diff --git a/src/post/visualizations/fft.c b/src/post/visualizations/fft.c index e9a99911a..01044987b 100644 --- a/src/post/visualizations/fft.c +++ b/src/post/visualizations/fft.c @@ -183,18 +183,6 @@ double fft_amp (int n, complex_t wave[], int bits) return (hypot (REAL(n), IMAG(n))); } -/* - * Calculate phase of component n in the decimated wave[] array. - */ -double fft_phase (int n, complex_t wave[], int bits) -{ - n = PERMUTE (n, bits); - if (REAL(n) != 0.0) - return (atan (IMAG(n) / REAL(n))); - else - return (0.0); -} - /* * Scale sampled values. * Do this *before* the fft. diff --git a/src/post/visualizations/fft.h b/src/post/visualizations/fft.h index dff3cd7e8..1600430bc 100644 --- a/src/post/visualizations/fft.h +++ b/src/post/visualizations/fft.h @@ -44,7 +44,6 @@ void fft_compute (fft_t *fft, complex_t wave[]); void fft_window (fft_t *fft, complex_t wave[]); double fft_amp (int n, complex_t wave[], int bits); -double fft_phase (int n, complex_t wave[], int bits); void fft_scale (complex_t wave[], int bits); #endif /* FFT_H */ -- cgit v1.2.3 From 19e1fa84aafee1f845e39afd20deb9d7783ad935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 16 Jan 2008 20:09:47 +0100 Subject: Remove two unused files, don't define (x)mmx_supported on non-x86. --- src/post/goom/Makefile.am | 2 +- src/post/goom/goomsl_lex.c | 2108 ------------------------------ src/post/goom/goomsl_yacc.c | 2997 ------------------------------------------- src/post/goom/mmx.c | 2 + src/post/goom/mmx.h | 2 + src/post/goom/xmmx.c | 2 + 6 files changed, 7 insertions(+), 5106 deletions(-) delete mode 100644 src/post/goom/goomsl_lex.c delete mode 100644 src/post/goom/goomsl_yacc.c (limited to 'src') diff --git a/src/post/goom/Makefile.am b/src/post/goom/Makefile.am index 22b4af79f..81e2eff32 100644 --- a/src/post/goom/Makefile.am +++ b/src/post/goom/Makefile.am @@ -30,7 +30,7 @@ xinepost_LTLIBRARIES = xineplug_post_goom.la xineplug_post_goom_la_SOURCES = mmx.c xine_goom.c \ config_param.c convolve_fx.c cpu_info.c drawmethods.c filters.c flying_stars_fx.c \ gfontlib.c goom_core.c goom_tools.c goomsl.c goomsl_hash.c goomsl_heap.c \ - goomsl_lex.c goomsl_yacc.c graphic.c ifs.c lines.c \ + graphic.c ifs.c lines.c \ plugin_info.c sound_tester.c surf3d.c tentacle3d.c v3d.c xineplug_post_goom_la_LIBADD = $(XINE_LIB) $(GOOM_LIBS) $(PTHREAD_LIBS) $(LTLIBINTL) -lm $(noinst_LTLIBRARIES) xineplug_post_goom_la_CFLAGS = $(DEFAULT_OCFLAGS) $(AM_CFLAGS) diff --git a/src/post/goom/goomsl_lex.c b/src/post/goom/goomsl_lex.c deleted file mode 100644 index 988fb99da..000000000 --- a/src/post/goom/goomsl_lex.c +++ /dev/null @@ -1,2108 +0,0 @@ -#line 2 "goomsl_lex.c" - -#line 4 "goomsl_lex.c" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 31 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN (yy_start) = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START (((yy_start) - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -extern int yyleng; - -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires - * access to the local variable yy_act. Since yyless() is a macro, it would break - * existing scanners that call yyless() from OUTSIDE yylex. - * One obvious solution it to make yy_act a global. I tried that, and saw - * a 5% performance hit in a non-yylineno scanner, because yy_act is - * normally declared as a register variable-- so it is not worth it. - */ - #define YY_LESS_LINENO(n) \ - do { \ - int yyl;\ - for ( yyl = n; yyl < yyleng; ++yyl )\ - if ( yytext[yyl] == '\n' )\ - --yylineno;\ - }while(0) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, (yytext_ptr) ) - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef unsigned int yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; -static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 1; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart (FILE *input_file ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); -void yy_delete_buffer (YY_BUFFER_STATE b ); -void yy_flush_buffer (YY_BUFFER_STATE b ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state (void ); - -static void yyensure_buffer_stack (void ); -static void yy_load_buffer_state (void ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); - -#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); - -void *yyalloc (yy_size_t ); -void *yyrealloc (void *,yy_size_t ); -void yyfree (void * ); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -typedef unsigned char YY_CHAR; - -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; - -typedef int yy_state_type; - -#define YY_FLEX_LEX_COMPAT -extern int yylineno; - -int yylineno = 1; - -extern char yytext[]; - -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - if ( yyleng + (yy_more_offset) >= YYLMAX ) \ - YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \ - yy_flex_strncpy( &yytext[(yy_more_offset)], (yytext_ptr), yyleng + 1 ); \ - yyleng += (yy_more_offset); \ - (yy_prev_more_offset) = (yy_more_offset); \ - (yy_more_offset) = 0; \ - (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 49 -#define YY_END_OF_BUFFER 50 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_acclist[214] = - { 0, - 50, 48, 49, 47, 48, 49, 4, 49, 48, 49, - 13, 48, 49, 10, 48, 49, 33, 48, 49, 48, - 49, 48, 49, 48, 49, 48, 49, 48, 49, 34, - 48, 49, 34, 48, 49, 48, 49, 48, 49, 33, - 48, 49, 33, 48, 49, 33, 48, 49, 33, 48, - 49, 33, 48, 49, 33, 48, 49, 33, 48, 49, - 33, 48, 49, 33, 48, 49, 33, 48, 49, 47, - 48, 49, 1, 4, 49, 48, 49, 7, 49, 6, - 49, 7, 49, 7, 49, 1, 6, 49, 7, 49, - 3, 49, 1, 3, 49, 17, 49, 49, 16, 17, - - 49, 17, 49, 47, 45, 10, 10, 10, 33, 40, - 39, 41, 11, 12, 42, 38, 37, 34, 43, 46, - 44, 33, 33, 28, 33, 33, 33, 33, 33, 30, - 33, 33, 33, 33, 33, 33, 47, 1, 12, 5, - 15, 14, 10, 10, 35, 37, 36, 33, 33, 33, - 33, 33, 29, 33, 19, 33, 26, 33, 21, 33, - 33, 33, 33, 2, 10, 10, 33, 33, 33, 33, - 33, 33, 33, 31, 33, 33, 10, 10, 33, 33, - 33, 32, 33, 18, 33, 33, 33, 27, 33, 10, - 10, 33, 33, 33, 22, 33, 25, 33, 10, 9, - - 10, 10, 20, 33, 23, 33, 33, 10, 24, 33, - 10, 8, 10 - } ; - -static yyconst flex_int16_t yy_accept[152] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 4, 7, 9, 11, 14, 17, 20, 22, 24, 26, - 28, 30, 33, 36, 38, 40, 43, 46, 49, 52, - 55, 58, 61, 64, 67, 70, 73, 76, 78, 80, - 82, 84, 86, 89, 91, 93, 96, 98, 99, 102, - 104, 105, 106, 107, 108, 109, 110, 110, 111, 112, - 113, 114, 115, 116, 117, 118, 119, 119, 120, 121, - 122, 123, 124, 126, 127, 128, 129, 130, 132, 133, - 134, 135, 136, 137, 138, 139, 139, 140, 141, 141, - 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, - - 151, 152, 153, 155, 157, 159, 161, 162, 163, 164, - 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, - 174, 176, 177, 178, 179, 180, 181, 182, 184, 186, - 187, 188, 190, 191, 192, 193, 194, 195, 197, 199, - 200, 202, 203, 205, 207, 208, 209, 211, 212, 214, - 214 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 4, 5, 6, 7, 1, 8, 9, 10, 1, - 1, 11, 12, 1, 13, 14, 15, 16, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 1, 1, 18, - 19, 20, 1, 9, 21, 21, 21, 21, 22, 23, - 21, 21, 24, 21, 21, 25, 21, 26, 21, 21, - 21, 27, 28, 29, 21, 21, 21, 21, 21, 21, - 1, 30, 1, 1, 31, 1, 32, 33, 34, 35, - - 36, 37, 38, 39, 40, 21, 21, 41, 21, 42, - 43, 44, 21, 45, 46, 47, 48, 21, 49, 50, - 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst flex_int32_t yy_meta[51] = - { 0, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 1, 4, 4, 1, 1, 1, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, - 3, 4, 4, 4, 4, 4, 4, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 - } ; - -static yyconst flex_int16_t yy_base[159] = - { 0, - 0, 49, 51, 54, 221, 57, 60, 64, 223, 225, - 69, 225, 203, 225, 51, 0, 0, 202, 201, 200, - 64, 68, 72, 72, 199, 174, 57, 166, 55, 173, - 171, 166, 165, 166, 171, 99, 225, 93, 225, 225, - 194, 107, 225, 193, 225, 225, 225, 225, 225, 71, - 93, 225, 0, 183, 178, 0, 195, 225, 225, 225, - 225, 225, 225, 225, 89, 107, 0, 225, 225, 225, - 161, 169, 0, 155, 160, 157, 154, 151, 150, 151, - 150, 146, 153, 123, 225, 177, 188, 225, 126, 187, - 225, 225, 164, 159, 225, 100, 0, 146, 145, 149, - - 138, 151, 0, 0, 0, 0, 59, 146, 140, 177, - 225, 157, 147, 141, 144, 130, 138, 126, 130, 137, - 0, 134, 165, 143, 133, 112, 109, 0, 0, 102, - 92, 0, 130, 112, 93, 98, 101, 0, 0, 125, - 124, 94, 0, 0, 78, 59, 0, 61, 0, 225, - 141, 145, 149, 151, 155, 51, 159, 163 - } ; - -static yyconst flex_int16_t yy_def[159] = - { 0, - 150, 1, 151, 151, 151, 151, 152, 152, 150, 150, - 150, 150, 150, 150, 153, 154, 155, 150, 150, 150, - 150, 150, 150, 150, 150, 154, 154, 154, 154, 154, - 154, 154, 154, 154, 154, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, - 150, 150, 153, 153, 153, 154, 150, 150, 150, 150, - 150, 150, 150, 150, 150, 150, 156, 150, 150, 150, - 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, - 154, 154, 154, 150, 150, 150, 157, 150, 150, 157, - 150, 150, 153, 153, 150, 150, 156, 154, 154, 154, - - 154, 154, 154, 154, 154, 154, 154, 154, 154, 157, - 150, 153, 153, 154, 154, 154, 154, 154, 154, 154, - 154, 154, 153, 153, 154, 154, 154, 154, 154, 154, - 154, 154, 158, 153, 154, 154, 154, 154, 154, 158, - 158, 153, 154, 154, 154, 153, 154, 153, 153, 0, - 150, 150, 150, 150, 150, 150, 150, 150 - } ; - -static yyconst flex_int16_t yy_nxt[276] = - { 0, - 10, 11, 12, 11, 13, 14, 15, 10, 16, 17, - 18, 19, 20, 10, 21, 22, 23, 24, 10, 25, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 10, - 16, 16, 26, 16, 27, 28, 29, 16, 16, 30, - 16, 31, 16, 32, 16, 33, 34, 16, 35, 16, - 36, 37, 36, 40, 97, 42, 43, 42, 42, 46, - 42, 41, 48, 38, 41, 49, 48, 149, 44, 49, - 51, 44, 51, 54, 61, 64, 91, 55, 62, 64, - 148, 65, 63, 66, 66, 65, 75, 66, 66, 50, - 68, 69, 72, 50, 51, 76, 51, 77, 119, 73, - - 84, 85, 84, 61, 96, 96, 120, 87, 89, 85, - 89, 63, 92, 86, 64, 96, 96, 67, 147, 146, - 65, 86, 66, 66, 84, 85, 84, 89, 85, 89, - 141, 141, 145, 144, 143, 142, 141, 86, 139, 138, - 86, 39, 39, 39, 39, 47, 47, 47, 47, 53, - 137, 53, 53, 56, 56, 57, 136, 57, 57, 110, - 110, 110, 110, 140, 135, 140, 140, 134, 133, 132, - 131, 130, 129, 128, 127, 126, 125, 124, 123, 111, - 122, 121, 118, 117, 116, 115, 114, 113, 112, 111, - 111, 90, 109, 108, 107, 106, 105, 104, 103, 102, - - 101, 100, 99, 98, 95, 94, 93, 90, 88, 83, - 82, 81, 80, 79, 78, 74, 71, 70, 60, 59, - 58, 52, 150, 45, 9, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 150 - } ; - -static yyconst flex_int16_t yy_chk[276] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 3, 156, 4, 4, 4, 6, 6, - 6, 3, 7, 2, 4, 7, 8, 148, 4, 8, - 11, 6, 11, 15, 21, 22, 50, 15, 21, 23, - 146, 22, 21, 22, 22, 23, 29, 23, 23, 7, - 24, 24, 27, 8, 51, 29, 51, 29, 107, 27, - - 36, 36, 36, 38, 65, 65, 107, 38, 42, 42, - 42, 38, 50, 36, 66, 96, 96, 22, 145, 142, - 66, 42, 66, 66, 84, 84, 84, 89, 89, 89, - 141, 140, 137, 136, 135, 134, 133, 84, 131, 130, - 89, 151, 151, 151, 151, 152, 152, 152, 152, 153, - 127, 153, 153, 154, 154, 155, 126, 155, 155, 157, - 157, 157, 157, 158, 125, 158, 158, 124, 123, 122, - 120, 119, 118, 117, 116, 115, 114, 113, 112, 110, - 109, 108, 102, 101, 100, 99, 98, 94, 93, 90, - 87, 86, 83, 82, 81, 80, 79, 78, 77, 76, - - 75, 74, 72, 71, 57, 55, 54, 44, 41, 35, - 34, 33, 32, 31, 30, 28, 26, 25, 20, 19, - 18, 13, 9, 5, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 150 - } ; - -/* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[50] = - { 0, -1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; - -extern int yy_flex_debug; -int yy_flex_debug = 0; - -static yy_state_type *yy_state_buf=0, *yy_state_ptr=0; -static char *yy_full_match; -static int yy_lp; -#define REJECT \ -{ \ -*yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ \ -yy_cp = (yy_full_match); /* restore poss. backed-over text */ \ -++(yy_lp); \ -goto find_rule; \ -} - -static int yy_more_offset = 0; -static int yy_prev_more_offset = 0; -#define yymore() ((yy_more_offset) = yy_flex_strlen( yytext )) -#define YY_NEED_STRLEN -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET \ - { \ - (yy_more_offset) = (yy_prev_more_offset); \ - yyleng -= (yy_more_offset); \ - } -#ifndef YYLMAX -#define YYLMAX 8192 -#endif - -char yytext[YYLMAX]; -char *yytext_ptr; -#line 1 "goomsl_lex.l" -#line 2 "goomsl_lex.l" - -#include -#include -#include -#include "goomsl.h" -#include "goomsl_private.h" -#include "goomsl_yacc.h" -void yyerror(char *); -void yyparse(void); - -GoomSL *currentGoomSL; -static int string_size; -static char string[1024]; - - - -#line 639 "goomsl_lex.c" - -#define INITIAL 0 -#define C_COMMENT 1 -#define LINE_COMMENT 2 -#define STRING 3 - -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap (void ); -#else -extern int yywrap (void ); -#endif -#endif - - static void yyunput (int c,char *buf_ptr ); - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (void ); -#else -static int input (void ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - size_t n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (void); - -#define YY_DECL int yylex (void) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - if ( yyleng > 0 ) \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ - (yytext[yyleng - 1] == '\n'); \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 25 "goomsl_lex.l" - - -#line 797 "goomsl_lex.c" - - if ( (yy_init) ) - { - (yy_init) = 0; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! (yy_state_buf) ) - (yy_state_buf) = (yy_state_type *)yyalloc(YY_BUF_SIZE + 2 ); - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); - } - - yy_load_buffer_state( ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = (yy_c_buf_p); - - /* Support of yytext. */ - *yy_cp = (yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = (yy_start); - yy_current_state += YY_AT_BOL(); - - (yy_state_ptr) = (yy_state_buf); - *(yy_state_ptr)++ = yy_current_state; - -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 151 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *(yy_state_ptr)++ = yy_current_state; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 225 ); - -yy_find_action: - yy_current_state = *--(yy_state_ptr); - (yy_lp) = yy_accept[yy_current_state]; -find_rule: /* we branch to this label when backing up */ - for ( ; ; ) /* until we find what rule we matched */ - { - if ( (yy_lp) && (yy_lp) < yy_accept[yy_current_state + 1] ) - { - yy_act = yy_acclist[(yy_lp)]; - { - (yy_full_match) = yy_cp; - break; - } - } - --yy_cp; - yy_current_state = *--(yy_state_ptr); - (yy_lp) = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - - if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) - { - int yyl; - for ( yyl = (yy_prev_more_offset); yyl < yyleng; ++yyl ) - if ( yytext[yyl] == '\n' ) - - yylineno++; -; - } - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ -case 1: -/* rule 1 can match eol */ -YY_RULE_SETUP -#line 27 "goomsl_lex.l" -{ ++currentGoomSL->num_lines; /* Ignore empty lines */ } - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -#line 28 "goomsl_lex.l" -{ ++currentGoomSL->num_lines; /* Ignore empty lines */ } - YY_BREAK -case 3: -/* rule 3 can match eol */ -YY_RULE_SETUP -#line 30 "goomsl_lex.l" -{ ++currentGoomSL->num_lines; yylval.charValue=*yytext; BEGIN INITIAL; return '\n'; } - YY_BREAK -case 4: -/* rule 4 can match eol */ -YY_RULE_SETUP -#line 31 "goomsl_lex.l" -{ ++currentGoomSL->num_lines; yylval.charValue=*yytext; return '\n'; } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 33 "goomsl_lex.l" -{ BEGIN INITIAL; } - YY_BREAK -case 6: -/* rule 6 can match eol */ -YY_RULE_SETUP -#line 34 "goomsl_lex.l" -{ ++currentGoomSL->num_lines; } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 35 "goomsl_lex.l" -{ /* eat up comment */ } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 37 "goomsl_lex.l" -{ currentGoomSL->num_lines = 0; } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 38 "goomsl_lex.l" -{ currentGoomSL->num_lines = 0; printf("%s\n", yytext); } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 39 "goomsl_lex.l" -{ /* ignore preprocessor lines */ } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 41 "goomsl_lex.l" -{ BEGIN C_COMMENT; } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 42 "goomsl_lex.l" -{ BEGIN LINE_COMMENT; } - YY_BREAK -case 13: -YY_RULE_SETUP -#line 43 "goomsl_lex.l" -{ BEGIN STRING; string_size=0; } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 45 "goomsl_lex.l" -{ string[string_size++] = '\n'; } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 46 "goomsl_lex.l" -{ string[string_size++] = '\"'; } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 47 "goomsl_lex.l" -{ /* fin de la chaine: on cree le pointeur qui va bien */ - unsigned int tmp; - BEGIN INITIAL; - string[string_size]=0; - tmp = gsl_malloc(currentGoomSL, string_size+1); - strcpy((char*)currentGoomSL->ptrArray[tmp],string); - sprintf(yylval.strValue, "0x%08x", tmp); - return LTYPE_PTR; - } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 56 "goomsl_lex.l" -{ string[string_size++] = *yytext; } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 58 "goomsl_lex.l" -{ return FLOAT_TK; } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 59 "goomsl_lex.l" -{ return INT_TK; } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 60 "goomsl_lex.l" -{ return INT_TK; } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 61 "goomsl_lex.l" -{ return PTR_TK; } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 62 "goomsl_lex.l" -{ return PTR_TK; } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 63 "goomsl_lex.l" -{ return DECLARE; } - YY_BREAK -case 24: -YY_RULE_SETUP -#line 64 "goomsl_lex.l" -{ return EXTERNAL; } - YY_BREAK -case 25: -YY_RULE_SETUP -#line 65 "goomsl_lex.l" -{ return STRUCT; } - YY_BREAK -case 26: -YY_RULE_SETUP -#line 66 "goomsl_lex.l" -{ return NOT; } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 67 "goomsl_lex.l" -{ return WHILE; } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 68 "goomsl_lex.l" -{ return DO; } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 69 "goomsl_lex.l" -{ return FOR; } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 70 "goomsl_lex.l" -{ return IN; } - YY_BREAK -case 31: -YY_RULE_SETUP -#line 71 "goomsl_lex.l" -{ strncpy(yylval.strValue, "1", 2047); return LTYPE_INTEGER; } - YY_BREAK -case 32: -YY_RULE_SETUP -#line 72 "goomsl_lex.l" -{ strncpy(yylval.strValue, "0", 2047); return LTYPE_INTEGER; } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 73 "goomsl_lex.l" -{ strncpy(yylval.strValue, yytext, 2047); return LTYPE_VAR; } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 74 "goomsl_lex.l" -{ strncpy(yylval.strValue, yytext, 2047); return LTYPE_INTEGER; } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 75 "goomsl_lex.l" -{ sprintf(yylval.strValue, "%d", (int)yytext[1]); return LTYPE_INTEGER; } - YY_BREAK -case 36: -YY_RULE_SETUP -#line 76 "goomsl_lex.l" -{ strncpy(yylval.strValue, yytext, 2047); return LTYPE_INTEGER; } - YY_BREAK -case 37: -YY_RULE_SETUP -#line 77 "goomsl_lex.l" -{ strncpy(yylval.strValue, yytext, 2047); return LTYPE_FLOAT; } - YY_BREAK -case 38: -YY_RULE_SETUP -#line 78 "goomsl_lex.l" -{ sprintf(yylval.strValue, "%3.2f", atof(yytext)/100.0f); return LTYPE_FLOAT; } - YY_BREAK -case 39: -YY_RULE_SETUP -#line 79 "goomsl_lex.l" -{ return PLUS_EQ; } - YY_BREAK -case 40: -YY_RULE_SETUP -#line 80 "goomsl_lex.l" -{ return MUL_EQ; } - YY_BREAK -case 41: -YY_RULE_SETUP -#line 81 "goomsl_lex.l" -{ return SUB_EQ; } - YY_BREAK -case 42: -YY_RULE_SETUP -#line 82 "goomsl_lex.l" -{ return DIV_EQ; } - YY_BREAK -case 43: -YY_RULE_SETUP -#line 83 "goomsl_lex.l" -{ return LOW_EQ; } - YY_BREAK -case 44: -YY_RULE_SETUP -#line 84 "goomsl_lex.l" -{ return SUP_EQ; } - YY_BREAK -case 45: -YY_RULE_SETUP -#line 85 "goomsl_lex.l" -{ return NOT_EQ; } - YY_BREAK -case 46: -YY_RULE_SETUP -#line 86 "goomsl_lex.l" -{ return NOT_EQ; } - YY_BREAK -case 47: -YY_RULE_SETUP -#line 87 "goomsl_lex.l" -/* eat up whitespace */ - YY_BREAK -case 48: -YY_RULE_SETUP -#line 88 "goomsl_lex.l" -{ yylval.charValue = *yytext; return *yytext; } - YY_BREAK -case 49: -YY_RULE_SETUP -#line 90 "goomsl_lex.l" -ECHO; - YY_BREAK -#line 1155 "goomsl_lex.c" - case YY_STATE_EOF(INITIAL): - case YY_STATE_EOF(C_COMMENT): - case YY_STATE_EOF(LINE_COMMENT): - case YY_STATE_EOF(STRING): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = (yy_c_buf_p); - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_END_OF_FILE: - { - (yy_did_buffer_switch_on_eof) = 0; - - if ( yywrap( ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (void) -{ - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; - int ret_val; - - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; - - else - { - size_t num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ( (yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (void) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = (yy_start); - yy_current_state += YY_AT_BOL(); - - (yy_state_ptr) = (yy_state_buf); - *(yy_state_ptr)++ = yy_current_state; - - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 151 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *(yy_state_ptr)++ = yy_current_state; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) -{ - register int yy_is_jam; - - register YY_CHAR yy_c = 1; - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 151 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 150); - if ( ! yy_is_jam ) - *(yy_state_ptr)++ = yy_current_state; - - return yy_is_jam ? 0 : yy_current_state; -} - - static void yyunput (int c, register char * yy_bp ) -{ - register char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up yytext */ - *yy_cp = (yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - if ( c == '\n' ){ - --yylineno; - } - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (void) -#else - static int input (void) -#endif - -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - int offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); - - switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart(yyin ); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( ) ) - return EOF; - - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve yytext */ - (yy_hold_char) = *++(yy_c_buf_p); - - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); - if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol ) - - yylineno++; -; - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file ) -{ - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); - } - - yy_init_buffer(YY_CURRENT_BUFFER,input_file ); - yy_load_buffer_state( ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) -{ - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - -static void yy_load_buffer_state (void) -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer(b,file ); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * - */ - void yy_delete_buffer (YY_BUFFER_STATE b ) -{ - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ); - - yyfree((void *) b ); -} - -#ifndef __cplusplus -extern int isatty (int ); -#endif /* __cplusplus */ - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) - -{ - int oerrno = errno; - - yy_flush_buffer(b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ - void yy_flush_buffer (YY_BUFFER_STATE b ) -{ - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) -{ - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void yypop_buffer_state (void) -{ - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (void) -{ - int num_to_alloc; - - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer(b ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param str a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (yyconst char * str ) -{ - - return yy_scan_bytes(str,strlen(str) ); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * bytes, int len ) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = len + 2; - buf = (char *) yyalloc(n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < len; ++i ) - buf[i] = bytes[i]; - - buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer(buf,n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg ) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = (yy_hold_char); \ - (yy_c_buf_p) = yytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the current line number. - * - */ -int yyget_lineno (void) -{ - - return yylineno; -} - -/** Get the input stream. - * - */ -FILE *yyget_in (void) -{ - return yyin; -} - -/** Get the output stream. - * - */ -FILE *yyget_out (void) -{ - return yyout; -} - -/** Get the length of the current token. - * - */ -int yyget_leng (void) -{ - return yyleng; -} - -/** Get the current token. - * - */ - -char *yyget_text (void) -{ - return yytext; -} - -/** Set the current line number. - * @param line_number - * - */ -void yyset_lineno (int line_number ) -{ - - yylineno = line_number; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * in_str ) -{ - yyin = in_str ; -} - -void yyset_out (FILE * out_str ) -{ - yyout = out_str ; -} - -int yyget_debug (void) -{ - return yy_flex_debug; -} - -void yyset_debug (int bdebug ) -{ - yy_flex_debug = bdebug ; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (void) -{ - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(); - } - - /* Destroy the stack itself. */ - yyfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - yyfree ( (yy_state_buf) ); - - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size ) -{ - return (void *) malloc( size ); -} - -void *yyrealloc (void * ptr, yy_size_t size ) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void yyfree (void * ptr ) -{ - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif -#line 90 "goomsl_lex.l" - - - - -int yywrap(void) { return 1; yyunput(0,0); } - - diff --git a/src/post/goom/goomsl_yacc.c b/src/post/goom/goomsl_yacc.c deleted file mode 100644 index 589b171be..000000000 --- a/src/post/goom/goomsl_yacc.c +++ /dev/null @@ -1,2997 +0,0 @@ -/* A Bison parser, made by GNU Bison 1.875. */ - -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 0 - -/* Using locations. */ -#define YYLSP_NEEDED 0 - - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - LTYPE_INTEGER = 258, - LTYPE_FLOAT = 259, - LTYPE_VAR = 260, - LTYPE_PTR = 261, - PTR_TK = 262, - INT_TK = 263, - FLOAT_TK = 264, - DECLARE = 265, - EXTERNAL = 266, - WHILE = 267, - DO = 268, - NOT = 269, - PLUS_EQ = 270, - SUB_EQ = 271, - DIV_EQ = 272, - MUL_EQ = 273, - SUP_EQ = 274, - LOW_EQ = 275, - NOT_EQ = 276, - STRUCT = 277, - FOR = 278, - IN = 279 - }; -#endif -#define LTYPE_INTEGER 258 -#define LTYPE_FLOAT 259 -#define LTYPE_VAR 260 -#define LTYPE_PTR 261 -#define PTR_TK 262 -#define INT_TK 263 -#define FLOAT_TK 264 -#define DECLARE 265 -#define EXTERNAL 266 -#define WHILE 267 -#define DO 268 -#define NOT 269 -#define PLUS_EQ 270 -#define SUB_EQ 271 -#define DIV_EQ 272 -#define MUL_EQ 273 -#define SUP_EQ 274 -#define LOW_EQ 275 -#define NOT_EQ 276 -#define STRUCT 277 -#define FOR 278 -#define IN 279 - - - - -/* Copy the first part of user declarations. */ -#line 6 "goomsl_yacc.y" - - #include - #include - #include - #include "goomsl.h" - #include "goomsl_private.h" - -#define STRUCT_ALIGNMENT 16 -/* #define VERBOSE */ - - int yylex(void); - void yyerror(char *); - extern GoomSL *currentGoomSL; - - static NodeType *nodeNew(const char *str, int type, int line_number); - static NodeType *nodeClone(NodeType *node); - static void nodeFreeInternals(NodeType *node); - static void nodeFree(NodeType *node); - - static void commit_node(NodeType *node, int releaseIfTemp); - static void precommit_node(NodeType *node); - - static NodeType *new_constInt(const char *str, int line_number); - static NodeType *new_constFloat(const char *str, int line_number); - static NodeType *new_constPtr(const char *str, int line_number); - static NodeType *new_var(const char *str, int line_number); - static NodeType *new_nop(const char *str); - static NodeType *new_op(const char *str, int type, int nbOp); - - static int allocateLabel(); - static int allocateTemp(); - static void releaseTemp(int n); - static void releaseAllTemps(); - - static int is_tmp_expr(NodeType *node) { - if (node->str) { - return (!strncmp(node->str,"_i_tmp_",7)) - || (!strncmp(node->str,"_f_tmp_",7)) - || (!strncmp(node->str,"_p_tmp",7)); - } - return 0; - } - /* pre: is_tmp_expr(node); */ - static int get_tmp_id(NodeType *node) { return atoi((node->str)+5); } - - static int is_commutative_expr(int itype) - { /* {{{ */ - return (itype == INSTR_ADD) - || (itype == INSTR_MUL) - || (itype == INSTR_ISEQUAL); - } /* }}} */ - - static void GSL_PUT_LABEL(char *name, int line_number) - { /* {{{ */ -#ifdef VERBOSE - printf("label %s\n", name); -#endif - currentGoomSL->instr = gsl_instr_init(currentGoomSL, "label", INSTR_LABEL, 1, line_number); - gsl_instr_add_param(currentGoomSL->instr, name, TYPE_LABEL); - } /* }}} */ - static void GSL_PUT_JUMP(char *name, int line_number) - { /* {{{ */ -#ifdef VERBOSE - printf("jump %s\n", name); -#endif - currentGoomSL->instr = gsl_instr_init(currentGoomSL, "jump", INSTR_JUMP, 1, line_number); - gsl_instr_add_param(currentGoomSL->instr, name, TYPE_LABEL); - } /* }}} */ - - static void GSL_PUT_JXXX(char *name, char *iname, int instr_id, int line_number) - { /* {{{ */ -#ifdef VERBOSE - printf("%s %s\n", iname, name); -#endif - currentGoomSL->instr = gsl_instr_init(currentGoomSL, iname, instr_id, 1, line_number); - gsl_instr_add_param(currentGoomSL->instr, name, TYPE_LABEL); - } /* }}} */ - static void GSL_PUT_JZERO(char *name,int line_number) - { /* {{{ */ - GSL_PUT_JXXX(name,"jzero.i",INSTR_JZERO,line_number); - } /* }}} */ - static void GSL_PUT_JNZERO(char *name, int line_number) - { /* {{{ */ - GSL_PUT_JXXX(name,"jnzero.i",INSTR_JNZERO,line_number); - } /* }}} */ - - /* Structures Management */ - -#define ALIGN_ADDR(_addr,_align) {\ - if (_align>1) {\ - int _dec = (_addr%_align);\ - if (_dec != 0) _addr += _align - _dec;\ - }} - - /* */ - void gsl_prepare_struct(GSL_Struct *s, int s_align, int i_align, int f_align) - { - int i; - int consumed = 0; - int iblk=0, fblk=0; - - s->iBlock[0].size = 0; - s->iBlock[0].data = 0; - s->fBlock[0].size = 0; - s->fBlock[0].data = 0; - - /* Prepare sub-struct and calculate space needed for their storage */ - for (i = 0; i < s->nbFields; ++i) - { - if (s->fields[i]->type < FIRST_RESERVED) - { - int j=0; - GSL_Struct *substruct = currentGoomSL->gsl_struct[s->fields[i]->type]; - consumed += sizeof(int); /* stocke le prefix */ - ALIGN_ADDR(consumed, s_align); - s->fields[i]->offsetInStruct = consumed; - gsl_prepare_struct(substruct, s_align, i_align, f_align); - for(j=0;substruct->iBlock[j].size>0;++j) { - s->iBlock[iblk].data = consumed + substruct->iBlock[j].data; - s->iBlock[iblk].size = substruct->iBlock[j].size; - iblk++; - } - for(j=0;substruct->fBlock[j].size>0;++j) { - s->fBlock[fblk].data = consumed + substruct->fBlock[j].data; - s->fBlock[fblk].size = substruct->fBlock[j].size; - fblk++; - } - consumed += substruct->size; - } - } - - /* Then prepare integers */ - ALIGN_ADDR(consumed, i_align); - for (i = 0; i < s->nbFields; ++i) - { - if (s->fields[i]->type == INSTR_INT) - { - if (s->iBlock[iblk].size == 0) { - s->iBlock[iblk].size = 1; - s->iBlock[iblk].data = consumed; - } else { - s->iBlock[iblk].size += 1; - } - s->fields[i]->offsetInStruct = consumed; - consumed += sizeof(int); - } - } - - iblk++; - s->iBlock[iblk].size = 0; - s->iBlock[iblk].data = 0; - - /* Then prepare floats */ - ALIGN_ADDR(consumed, f_align); - for (i = 0; i < s->nbFields; ++i) - { - if (s->fields[i]->type == INSTR_FLOAT) - { - if (s->fBlock[fblk].size == 0) { - s->fBlock[fblk].size = 1; - s->fBlock[fblk].data = consumed; - } else { - s->fBlock[fblk].size += 1; - } - s->fields[i]->offsetInStruct = consumed; - consumed += sizeof(int); - } - } - - fblk++; - s->fBlock[fblk].size = 0; - s->fBlock[fblk].data = 0; - - /* Finally prepare pointers */ - ALIGN_ADDR(consumed, i_align); - for (i = 0; i < s->nbFields; ++i) - { - if (s->fields[i]->type == INSTR_PTR) - { - s->fields[i]->offsetInStruct = consumed; - consumed += sizeof(int); - } - } - s->size = consumed; - } - - /* Returns the ID of a struct from its name */ - int gsl_get_struct_id(const char *name) /* {{{ */ - { - HashValue *ret = goom_hash_get(currentGoomSL->structIDS, name); - if (ret != NULL) return ret->i; - return -1; - } /* }}} */ - - /* Adds the definition of a struct */ - void gsl_add_struct(const char *name, GSL_Struct *gsl_struct) /* {{{ */ - { - /* Prepare the struct: ie calculate internal storage format */ - gsl_prepare_struct(gsl_struct, STRUCT_ALIGNMENT, STRUCT_ALIGNMENT, STRUCT_ALIGNMENT); - - /* If the struct does not already exists */ - if (gsl_get_struct_id(name) < 0) - { - /* adds it */ - int id = currentGoomSL->nbStructID++; - goom_hash_put_int(currentGoomSL->structIDS, name, id); - if (currentGoomSL->gsl_struct_size <= id) { - currentGoomSL->gsl_struct_size *= 2; - currentGoomSL->gsl_struct = (GSL_Struct**)realloc(currentGoomSL->gsl_struct, - sizeof(GSL_Struct*) * currentGoomSL->gsl_struct_size); - } - currentGoomSL->gsl_struct[id] = gsl_struct; - } - } /* }}} */ - - /* Creates a field for a struct */ - GSL_StructField *gsl_new_struct_field(const char *name, int type) - { - GSL_StructField *field = (GSL_StructField*)malloc(sizeof(GSL_StructField)); - strcpy(field->name, name); - field->type = type; - return field; - } - - /* Create as field for a struct which will be a struct itself */ - GSL_StructField *gsl_new_struct_field_struct(const char *name, const char *type) - { - GSL_StructField *field = gsl_new_struct_field(name, gsl_get_struct_id(type)); - if (field->type < 0) { - fprintf(stderr, "ERROR: Line %d, Unknown structure: '%s'\n", - currentGoomSL->num_lines, type); - exit(1); - } - return field; - } - - /* Creates a Struct */ - GSL_Struct *gsl_new_struct(GSL_StructField *field) - { - GSL_Struct *s = (GSL_Struct*)malloc(sizeof(GSL_Struct)); - s->nbFields = 1; - s->fields[0] = field; - return s; - } - - /* Adds a field to a struct */ - void gsl_add_struct_field(GSL_Struct *s, GSL_StructField *field) - { - s->fields[s->nbFields++] = field; - } - - int gsl_type_of_var(GoomHash *ns, const char *name) - { - char type_of[256]; - HashValue *hv; - sprintf(type_of, "__type_of_%s", name); - hv = goom_hash_get(ns, type_of); - if (hv != NULL) - return hv->i; - fprintf(stderr, "ERROR: Unknown variable type: '%s'\n", name); - return -1; - } - - static void gsl_declare_var(GoomHash *ns, const char *name, int type, void *space) - { - char type_of[256]; - if (name[0] == '@') { ns = currentGoomSL->vars; } - - if (space == NULL) { - switch (type) { - case INSTR_INT: - case INSTR_FLOAT: - case INSTR_PTR: - space = goom_heap_malloc_with_alignment(currentGoomSL->data_heap, - sizeof(int), sizeof(int)); - break; - case -1: - fprintf(stderr, "What the fuck!\n"); - exit(1); - default: /* On a un struct_id */ - space = goom_heap_malloc_with_alignment_prefixed(currentGoomSL->data_heap, - currentGoomSL->gsl_struct[type]->size, STRUCT_ALIGNMENT, sizeof(int)); - } - } - goom_hash_put_ptr(ns, name, (void*)space); - sprintf(type_of, "__type_of_%s", name); - goom_hash_put_int(ns, type_of, type); - - /* Ensuite le hack: on ajoute les champs en tant que variables. */ - if (type < FIRST_RESERVED) - { - int i; - GSL_Struct *gsl_struct = currentGoomSL->gsl_struct[type]; - ((int*)space)[-1] = type; /* stockage du type dans le prefixe de structure */ - for (i = 0; i < gsl_struct->nbFields; ++i) - { - char full_name[256]; - char *cspace = (char*)space + gsl_struct->fields[i]->offsetInStruct; - sprintf(full_name, "%s.%s", name, gsl_struct->fields[i]->name); - gsl_declare_var(ns, full_name, gsl_struct->fields[i]->type, cspace); - } - } - } - - /* Declare a variable which will be a struct */ - static void gsl_struct_decl(GoomHash *namespace, const char *struct_name, const char *name) - { - int struct_id = gsl_get_struct_id(struct_name); - gsl_declare_var(namespace, name, struct_id, NULL); - } - - static void gsl_float_decl_global(const char *name) - { - gsl_declare_var(currentGoomSL->vars, name, INSTR_FLOAT, NULL); - } - static void gsl_int_decl_global(const char *name) - { - gsl_declare_var(currentGoomSL->vars, name, INSTR_INT, NULL); - } - static void gsl_ptr_decl_global(const char *name) - { - gsl_declare_var(currentGoomSL->vars, name, INSTR_PTR, NULL); - } - static void gsl_struct_decl_global_from_id(const char *name, int id) - { - gsl_declare_var(currentGoomSL->vars, name, id, NULL); - } - - /* FLOAT */ - static void gsl_float_decl_local(const char *name) - { - gsl_declare_var(currentGoomSL->namespaces[currentGoomSL->currentNS], name, INSTR_FLOAT, NULL); - } - /* INT */ - static void gsl_int_decl_local(const char *name) - { - gsl_declare_var(currentGoomSL->namespaces[currentGoomSL->currentNS], name, INSTR_INT, NULL); - } - /* PTR */ - static void gsl_ptr_decl_local(const char *name) - { - gsl_declare_var(currentGoomSL->namespaces[currentGoomSL->currentNS], name, INSTR_PTR, NULL); - } - /* STRUCT */ - static void gsl_struct_decl_local(const char *struct_name, const char *name) - { - gsl_struct_decl(currentGoomSL->namespaces[currentGoomSL->currentNS],struct_name,name); - } - - - static void commit_test2(NodeType *set,const char *type, int instr); - static NodeType *new_call(const char *name, NodeType *affect_list); - - /* SETTER */ - static NodeType *new_set(NodeType *lvalue, NodeType *expression) - { /* {{{ */ - NodeType *set = new_op("set", OPR_SET, 2); - set->unode.opr.op[0] = lvalue; - set->unode.opr.op[1] = expression; - return set; - } /* }}} */ - static void commit_set(NodeType *set) - { /* {{{ */ - commit_test2(set,"set",INSTR_SET); - } /* }}} */ - - /* PLUS_EQ */ - static NodeType *new_plus_eq(NodeType *lvalue, NodeType *expression) /* {{{ */ - { - NodeType *set = new_op("plus_eq", OPR_PLUS_EQ, 2); - set->unode.opr.op[0] = lvalue; - set->unode.opr.op[1] = expression; - return set; - } - static void commit_plus_eq(NodeType *set) - { - precommit_node(set->unode.opr.op[1]); -#ifdef VERBOSE - printf("add %s %s\n", set->unode.opr.op[0]->str, set->unode.opr.op[1]->str); -#endif - currentGoomSL->instr = gsl_instr_init(currentGoomSL, "add", INSTR_ADD, 2, set->line_number); - commit_node(set->unode.opr.op[0],0); - commit_node(set->unode.opr.op[1],1); - } /* }}} */ - - /* SUB_EQ */ - static NodeType *new_sub_eq(NodeType *lvalue, NodeType *expression) /* {{{ */ - { - NodeType *set = new_op("sub_eq", OPR_SUB_EQ, 2); - set->unode.opr.op[0] = lvalue; - set->unode.opr.op[1] = expression; - return set; - } - static void commit_sub_eq(NodeType *set) - { - precommit_node(set->unode.opr.op[1]); -#ifdef VERBOSE - printf("sub %s %s\n", set->unode.opr.op[0]->str, set->unode.opr.op[1]->str); -#endif - currentGoomSL->instr = gsl_instr_init(currentGoomSL, "sub", INSTR_SUB, 2, set->line_number); - commit_node(set->unode.opr.op[0],0); - commit_node(set->unode.opr.op[1],1); - } /* }}} */ - - /* MUL_EQ */ - static NodeType *new_mul_eq(NodeType *lvalue, NodeType *expression) /* {{{ */ - { - NodeType *set = new_op("mul_eq", OPR_MUL_EQ, 2); - set->unode.opr.op[0] = lvalue; - set->unode.opr.op[1] = expression; - return set; - } - static void commit_mul_eq(NodeType *set) - { - precommit_node(set->unode.opr.op[1]); -#ifdef VERBOSE - printf("mul %s %s\n", set->unode.opr.op[0]->str, set->unode.opr.op[1]->str); -#endif - currentGoomSL->instr = gsl_instr_init(currentGoomSL, "mul", INSTR_MUL, 2, set->line_number); - commit_node(set->unode.opr.op[0],0); - commit_node(set->unode.opr.op[1],1); - } /* }}} */ - - /* DIV_EQ */ - static NodeType *new_div_eq(NodeType *lvalue, NodeType *expression) /* {{{ */ - { - NodeType *set = new_op("div_eq", OPR_DIV_EQ, 2); - set->unode.opr.op[0] = lvalue; - set->unode.opr.op[1] = expression; - return set; - } - static void commit_div_eq(NodeType *set) - { - precommit_node(set->unode.opr.op[1]); -#ifdef VERBOSE - printf("div %s %s\n", set->unode.opr.op[0]->str, set->unode.opr.op[1]->str); -#endif - currentGoomSL->instr = gsl_instr_init(currentGoomSL, "div", INSTR_DIV, 2, set->line_number); - commit_node(set->unode.opr.op[0],0); - commit_node(set->unode.opr.op[1],1); - } /* }}} */ - - /* commodity method for add, mult, ... */ - - static void precommit_expr(NodeType *expr, const char *type, int instr_id) - { /* {{{ */ - NodeType *tmp, *tmpcpy; - int toAdd; - - /* compute "left" and "right" */ - switch (expr->unode.opr.nbOp) { - case 2: - precommit_node(expr->unode.opr.op[1]); - case 1: - precommit_node(expr->unode.opr.op[0]); - } - - if (is_tmp_expr(expr->unode.opr.op[0])) { - tmp = expr->unode.opr.op[0]; - toAdd = 1; - } - else if (is_commutative_expr(instr_id) && (expr->unode.opr.nbOp==2) && is_tmp_expr(expr->unode.opr.op[1])) { - tmp = expr->unode.opr.op[1]; - toAdd = 0; - } - else { - char stmp[256]; - /* declare a temporary variable to store the result */ - if (expr->unode.opr.op[0]->type == CONST_INT_NODE) { - sprintf(stmp,"_i_tmp_%i",allocateTemp()); - gsl_int_decl_global(stmp); - } - else if (expr->unode.opr.op[0]->type == CONST_FLOAT_NODE) { - sprintf(stmp,"_f_tmp%i",allocateTemp()); - gsl_float_decl_global(stmp); - } - else if (expr->unode.opr.op[0]->type == CONST_PTR_NODE) { - sprintf(stmp,"_p_tmp%i",allocateTemp()); - gsl_ptr_decl_global(stmp); - } - else { - int type = gsl_type_of_var(expr->unode.opr.op[0]->vnamespace, expr->unode.opr.op[0]->str); - if (type == INSTR_FLOAT) { - sprintf(stmp,"_f_tmp_%i",allocateTemp()); - gsl_float_decl_global(stmp); - } - else if (type == INSTR_PTR) { - sprintf(stmp,"_p_tmp_%i",allocateTemp()); - gsl_ptr_decl_global(stmp); - } - else if (type == INSTR_INT) { - sprintf(stmp,"_i_tmp_%i",allocateTemp()); - gsl_int_decl_global(stmp); - } - else if (type == -1) { - fprintf(stderr, "ERROR: Line %d, Could not find variable '%s'\n", - expr->line_number, expr->unode.opr.op[0]->str); - exit(1); - } - else { /* type is a struct_id */ - sprintf(stmp,"_s_tmp_%i",allocateTemp()); - gsl_struct_decl_global_from_id(stmp,type); - } - } - tmp = new_var(stmp,expr->line_number); - - /* set the tmp to the value of "op1" */ - tmpcpy = nodeClone(tmp); - commit_node(new_set(tmp,expr->unode.opr.op[0]),0); - toAdd = 1; - - tmp = tmpcpy; - } - - /* add op2 to tmp */ -#ifdef VERBOSE - if (expr->unode.opr.nbOp == 2) - printf("%s %s %s\n", type, tmp->str, expr->unode.opr.op[toAdd]->str); - else - printf("%s %s\n", type, tmp->str); -#endif - currentGoomSL->instr = gsl_instr_init(currentGoomSL, type, instr_id, expr->unode.opr.nbOp, expr->line_number); - tmpcpy = nodeClone(tmp); - commit_node(tmp,0); - if (expr->unode.opr.nbOp == 2) { - commit_node(expr->unode.opr.op[toAdd],1); - } - - /* redefine the ADD node now as the computed variable */ - nodeFreeInternals(expr); - *expr = *tmpcpy; - free(tmpcpy); - } /* }}} */ - - static NodeType *new_expr1(const char *name, int id, NodeType *expr1) - { /* {{{ */ - NodeType *add = new_op(name, id, 1); - add->unode.opr.op[0] = expr1; - return add; - } /* }}} */ - - static NodeType *new_expr2(const char *name, int id, NodeType *expr1, NodeType *expr2) - { /* {{{ */ - NodeType *add = new_op(name, id, 2); - add->unode.opr.op[0] = expr1; - add->unode.opr.op[1] = expr2; - return add; - } /* }}} */ - - /* ADD */ - static NodeType *new_add(NodeType *expr1, NodeType *expr2) { /* {{{ */ - return new_expr2("add", OPR_ADD, expr1, expr2); - } - static void precommit_add(NodeType *add) { - precommit_expr(add,"add",INSTR_ADD); - } /* }}} */ - - /* SUB */ - static NodeType *new_sub(NodeType *expr1, NodeType *expr2) { /* {{{ */ - return new_expr2("sub", OPR_SUB, expr1, expr2); - } - static void precommit_sub(NodeType *sub) { - precommit_expr(sub,"sub",INSTR_SUB); - } /* }}} */ - - /* NEG */ - static NodeType *new_neg(NodeType *expr) { /* {{{ */ - NodeType *zeroConst = NULL; - if (expr->type == CONST_INT_NODE) - zeroConst = new_constInt("0", currentGoomSL->num_lines); - else if (expr->type == CONST_FLOAT_NODE) - zeroConst = new_constFloat("0.0", currentGoomSL->num_lines); - else if (expr->type == CONST_PTR_NODE) { - fprintf(stderr, "ERROR: Line %d, Could not negate const pointer.\n", - currentGoomSL->num_lines); - exit(1); - } - else { - int type = gsl_type_of_var(expr->vnamespace, expr->str); - if (type == INSTR_FLOAT) - zeroConst = new_constFloat("0.0", currentGoomSL->num_lines); - else if (type == INSTR_PTR) { - fprintf(stderr, "ERROR: Line %d, Could not negate pointer.\n", - currentGoomSL->num_lines); - exit(1); - } - else if (type == INSTR_INT) - zeroConst = new_constInt("0", currentGoomSL->num_lines); - else if (type == -1) { - fprintf(stderr, "ERROR: Line %d, Could not find variable '%s'\n", - expr->line_number, expr->unode.opr.op[0]->str); - exit(1); - } - else { /* type is a struct_id */ - fprintf(stderr, "ERROR: Line %d, Could not negate struct '%s'\n", - expr->line_number, expr->str); - exit(1); - } - } - return new_expr2("sub", OPR_SUB, zeroConst, expr); - } - /* }}} */ - - /* MUL */ - static NodeType *new_mul(NodeType *expr1, NodeType *expr2) { /* {{{ */ - return new_expr2("mul", OPR_MUL, expr1, expr2); - } - static void precommit_mul(NodeType *mul) { - precommit_expr(mul,"mul",INSTR_MUL); - } /* }}} */ - - /* DIV */ - static NodeType *new_div(NodeType *expr1, NodeType *expr2) { /* {{{ */ - return new_expr2("div", OPR_DIV, expr1, expr2); - } - static void precommit_div(NodeType *mul) { - precommit_expr(mul,"div",INSTR_DIV); - } /* }}} */ - - /* CALL EXPRESSION */ - static NodeType *new_call_expr(const char *name, NodeType *affect_list) { /* {{{ */ - NodeType *call = new_call(name,affect_list); - NodeType *node = new_expr1(name, OPR_CALL_EXPR, call); - node->vnamespace = gsl_find_namespace(name); - if (node->vnamespace == NULL) - fprintf(stderr, "ERROR: Line %d, No return type for: '%s'\n", currentGoomSL->num_lines, name); - return node; - } - static void precommit_call_expr(NodeType *call) { - char stmp[256]; - NodeType *tmp,*tmpcpy; - int type = gsl_type_of_var(call->vnamespace, call->str); - if (type == INSTR_FLOAT) { - sprintf(stmp,"_f_tmp_%i",allocateTemp()); - gsl_float_decl_global(stmp); - } - else if (type == INSTR_PTR) { - sprintf(stmp,"_p_tmp_%i",allocateTemp()); - gsl_ptr_decl_global(stmp); - } - else if (type == INSTR_INT) { - sprintf(stmp,"_i_tmp_%i",allocateTemp()); - gsl_int_decl_global(stmp); - } - else if (type == -1) { - fprintf(stderr, "ERROR: Line %d, Could not find variable '%s'\n", - call->line_number, call->str); - exit(1); - } - else { /* type is a struct_id */ - sprintf(stmp,"_s_tmp_%i",allocateTemp()); - gsl_struct_decl_global_from_id(stmp,type); - } - tmp = new_var(stmp,call->line_number); - commit_node(call->unode.opr.op[0],0); - tmpcpy = nodeClone(tmp); - commit_node(new_set(tmp,new_var(call->str,call->line_number)),0); - - nodeFreeInternals(call); - *call = *tmpcpy; - free(tmpcpy); - } /* }}} */ - - static void commit_test2(NodeType *set,const char *type, int instr) - { /* {{{ */ - NodeType *tmp; - char stmp[256]; - precommit_node(set->unode.opr.op[0]); - precommit_node(set->unode.opr.op[1]); - tmp = set->unode.opr.op[0]; - - stmp[0] = 0; - if (set->unode.opr.op[0]->type == CONST_INT_NODE) { - sprintf(stmp,"_i_tmp_%i",allocateTemp()); - gsl_int_decl_global(stmp); - } - else if (set->unode.opr.op[0]->type == CONST_FLOAT_NODE) { - sprintf(stmp,"_f_tmp%i",allocateTemp()); - gsl_float_decl_global(stmp); - } - else if (set->unode.opr.op[0]->type == CONST_PTR_NODE) { - sprintf(stmp,"_p_tmp%i",allocateTemp()); - gsl_ptr_decl_global(stmp); - } - if (stmp[0]) { - NodeType *tmpcpy; - tmp = new_var(stmp, set->line_number); - tmpcpy = nodeClone(tmp); - commit_node(new_set(tmp,set->unode.opr.op[0]),0); - tmp = tmpcpy; - } - -#ifdef VERBOSE - printf("%s %s %s\n", type, tmp->str, set->unode.opr.op[1]->str); -#endif - currentGoomSL->instr = gsl_instr_init(currentGoomSL, type, instr, 2, set->line_number); - commit_node(tmp,instr!=INSTR_SET); - commit_node(set->unode.opr.op[1],1); - } /* }}} */ - - /* NOT */ - static NodeType *new_not(NodeType *expr1) { /* {{{ */ - return new_expr1("not", OPR_NOT, expr1); - } - static void commit_not(NodeType *set) - { - commit_node(set->unode.opr.op[0],0); -#ifdef VERBOSE - printf("not\n"); -#endif - currentGoomSL->instr = gsl_instr_init(currentGoomSL, "not", INSTR_NOT, 1, set->line_number); - gsl_instr_add_param(currentGoomSL->instr, "|dummy|", TYPE_LABEL); - } /* }}} */ - - /* EQU */ - static NodeType *new_equ(NodeType *expr1, NodeType *expr2) { /* {{{ */ - return new_expr2("isequal", OPR_EQU, expr1, expr2); - } - static void commit_equ(NodeType *mul) { - commit_test2(mul,"isequal",INSTR_ISEQUAL); - } /* }}} */ - - /* INF */ - static NodeType *new_low(NodeType *expr1, NodeType *expr2) { /* {{{ */ - return new_expr2("islower", OPR_LOW, expr1, expr2); - } - static void commit_low(NodeType *mul) { - commit_test2(mul,"islower",INSTR_ISLOWER); - } /* }}} */ - - /* WHILE */ - static NodeType *new_while(NodeType *expression, NodeType *instr) { /* {{{ */ - NodeType *node = new_op("while", OPR_WHILE, 2); - node->unode.opr.op[0] = expression; - node->unode.opr.op[1] = instr; - return node; - } - - static void commit_while(NodeType *node) - { - int lbl = allocateLabel(); - char start_while[1024], test_while[1024]; - sprintf(start_while, "|start_while_%d|", lbl); - sprintf(test_while, "|test_while_%d|", lbl); - - GSL_PUT_JUMP(test_while,node->line_number); - GSL_PUT_LABEL(start_while,node->line_number); - - /* code */ - commit_node(node->unode.opr.op[1],0); - - GSL_PUT_LABEL(test_while,node->line_number); - commit_node(node->unode.opr.op[0],0); - GSL_PUT_JNZERO(start_while,node->line_number); - } /* }}} */ - - /* FOR EACH */ - static NodeType *new_static_foreach(NodeType *var, NodeType *var_list, NodeType *instr) { /* {{{ */ - NodeType *node = new_op("for", OPR_FOREACH, 3); - node->unode.opr.op[0] = var; - node->unode.opr.op[1] = var_list; - node->unode.opr.op[2] = instr; - node->line_number = currentGoomSL->num_lines; - return node; - } - static void commit_foreach(NodeType *node) - { - NodeType *cur = node->unode.opr.op[1]; - char tmp_func[256], tmp_loop[256]; - int lbl = allocateLabel(); - sprintf(tmp_func, "|foreach_func_%d|", lbl); - sprintf(tmp_loop, "|foreach_loop_%d|", lbl); - - GSL_PUT_JUMP(tmp_loop, node->line_number); - GSL_PUT_LABEL(tmp_func, node->line_number); - - precommit_node(node->unode.opr.op[2]); - commit_node(node->unode.opr.op[2], 0); - - currentGoomSL->instr = gsl_instr_init(currentGoomSL, "ret", INSTR_RET, 1, node->line_number); - gsl_instr_add_param(currentGoomSL->instr, "|dummy|", TYPE_LABEL); -#ifdef VERBOSE - printf("ret\n"); -#endif - - GSL_PUT_LABEL(tmp_loop, node->line_number); - - while (cur != NULL) - { - NodeType *x, *var; - - /* 1: x=var */ - x = nodeClone(node->unode.opr.op[0]); - var = nodeClone(cur->unode.opr.op[0]); - commit_node(new_set(x, var),0); - - /* 2: instr */ - currentGoomSL->instr = gsl_instr_init(currentGoomSL, "call", INSTR_CALL, 1, node->line_number); - gsl_instr_add_param(currentGoomSL->instr, tmp_func, TYPE_LABEL); -#ifdef VERBOSE - printf("call %s\n", tmp_func); -#endif - - /* 3: var=x */ - x = nodeClone(node->unode.opr.op[0]); - var = cur->unode.opr.op[0]; - commit_node(new_set(var, x),0); - cur = cur->unode.opr.op[1]; - } - nodeFree(node->unode.opr.op[0]); - } /* }}} */ - - /* IF */ - static NodeType *new_if(NodeType *expression, NodeType *instr) { /* {{{ */ - NodeType *node = new_op("if", OPR_IF, 2); - node->unode.opr.op[0] = expression; - node->unode.opr.op[1] = instr; - return node; - } - static void commit_if(NodeType *node) { - - char slab[1024]; - sprintf(slab, "|eif%d|", allocateLabel()); - commit_node(node->unode.opr.op[0],0); - GSL_PUT_JZERO(slab,node->line_number); - /* code */ - commit_node(node->unode.opr.op[1],0); - GSL_PUT_LABEL(slab,node->line_number); - } /* }}} */ - - /* BLOCK */ - static NodeType *new_block(NodeType *lastNode) { /* {{{ */ - NodeType *blk = new_op("block", OPR_BLOCK, 2); - blk->unode.opr.op[0] = new_nop("start_of_block"); - blk->unode.opr.op[1] = lastNode; - return blk; - } - static void commit_block(NodeType *node) { - commit_node(node->unode.opr.op[0]->unode.opr.next,0); - } /* }}} */ - - /* FUNCTION INTRO */ - static NodeType *new_function_intro(const char *name) { /* {{{ */ - char stmp[256]; - if (strlen(name) < 200) { - sprintf(stmp, "|__func_%s|", name); - } - return new_op(stmp, OPR_FUNC_INTRO, 0); - } - static void commit_function_intro(NodeType *node) { - currentGoomSL->instr = gsl_instr_init(currentGoomSL, "label", INSTR_LABEL, 1, node->line_number); - gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_LABEL); -#ifdef VERBOSE - printf("label %s\n", node->str); -#endif - } /* }}} */ - - /* FUNCTION OUTRO */ - static NodeType *new_function_outro() { /* {{{ */ - return new_op("ret", OPR_FUNC_OUTRO, 0); - } - static void commit_function_outro(NodeType *node) { - currentGoomSL->instr = gsl_instr_init(currentGoomSL, "ret", INSTR_RET, 1, node->line_number); - gsl_instr_add_param(currentGoomSL->instr, "|dummy|", TYPE_LABEL); - releaseAllTemps(); -#ifdef VERBOSE - printf("ret\n"); -#endif - } /* }}} */ - - /* AFFECTATION LIST */ - static NodeType *new_affec_list(NodeType *set, NodeType *next) /* {{{ */ - { - NodeType *node = new_op("affect_list", OPR_AFFECT_LIST, 2); - node->unode.opr.op[0] = set; - node->unode.opr.op[1] = next; - return node; - } - static NodeType *new_affect_list_after(NodeType *affect_list) - { - NodeType *ret = NULL; - NodeType *cur = affect_list; - while(cur != NULL) { - NodeType *set = cur->unode.opr.op[0]; - NodeType *next = cur->unode.opr.op[1]; - NodeType *lvalue = set->unode.opr.op[0]; - NodeType *expression = set->unode.opr.op[1]; - if ((lvalue->str[0] == '&') && (expression->type == VAR_NODE)) { - NodeType *nset = new_set(nodeClone(expression), nodeClone(lvalue)); - ret = new_affec_list(nset, ret); - } - cur = next; - } - return ret; - } - static void commit_affect_list(NodeType *node) - { - NodeType *cur = node; - while(cur != NULL) { - NodeType *set = cur->unode.opr.op[0]; - precommit_node(set->unode.opr.op[0]); - precommit_node(set->unode.opr.op[1]); - cur = cur->unode.opr.op[1]; - } - cur = node; - while(cur != NULL) { - NodeType *set = cur->unode.opr.op[0]; - commit_node(set,0); - cur = cur->unode.opr.op[1]; - } - } /* }}} */ - - /* VAR LIST */ - static NodeType *new_var_list(NodeType *var, NodeType *next) /* {{{ */ - { - NodeType *node = new_op("var_list", OPR_VAR_LIST, 2); - node->unode.opr.op[0] = var; - node->unode.opr.op[1] = next; - return node; - } - static void commit_var_list(NodeType *node) - { - } /* }}} */ - - /* FUNCTION CALL */ - static NodeType *new_call(const char *name, NodeType *affect_list) { /* {{{ */ - HashValue *fval; - fval = goom_hash_get(currentGoomSL->functions, name); - if (!fval) { - gsl_declare_task(name); - fval = goom_hash_get(currentGoomSL->functions, name); - } - if (!fval) { - fprintf(stderr, "ERROR: Line %d, Could not find function %s\n", currentGoomSL->num_lines, name); - exit(1); - return NULL; - } - else { - ExternalFunctionStruct *gef = (ExternalFunctionStruct*)fval->ptr; - if (gef->is_extern) { - NodeType *node = new_op(name, OPR_EXT_CALL, 1); - node->unode.opr.op[0] = affect_list; - return node; - } - else { - NodeType *node; - char stmp[256]; - if (strlen(name) < 200) { - sprintf(stmp, "|__func_%s|", name); - } - node = new_op(stmp, OPR_CALL, 1); - node->unode.opr.op[0] = affect_list; - return node; - } - } - } - static void commit_ext_call(NodeType *node) { - NodeType *alafter = new_affect_list_after(node->unode.opr.op[0]); - commit_node(node->unode.opr.op[0],0); - currentGoomSL->instr = gsl_instr_init(currentGoomSL, "extcall", INSTR_EXT_CALL, 1, node->line_number); - gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_VAR); -#ifdef VERBOSE - printf("extcall %s\n", node->str); -#endif - commit_node(alafter,0); - } - static void commit_call(NodeType *node) { - NodeType *alafter = new_affect_list_after(node->unode.opr.op[0]); - commit_node(node->unode.opr.op[0],0); - currentGoomSL->instr = gsl_instr_init(currentGoomSL, "call", INSTR_CALL, 1, node->line_number); - gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_LABEL); -#ifdef VERBOSE - printf("call %s\n", node->str); -#endif - commit_node(alafter,0); - } /* }}} */ - - /** **/ - - static NodeType *rootNode = 0; /* TODO: reinitialiser a chaque compilation. */ - static NodeType *lastNode = 0; - static NodeType *gsl_append(NodeType *curNode) { - if (curNode == 0) return 0; /* {{{ */ - if (lastNode) - lastNode->unode.opr.next = curNode; - lastNode = curNode; - while(lastNode->unode.opr.next) lastNode = lastNode->unode.opr.next; - if (rootNode == 0) - rootNode = curNode; - return curNode; - } /* }}} */ - -#if 1 - int allocateTemp() { - return allocateLabel(); - } - void releaseAllTemps() {} - void releaseTemp(int n) {} -#else - static int nbTemp = 0; - static int *tempArray = 0; - static int tempArraySize = 0; - int allocateTemp() { /* TODO: allocateITemp, allocateFTemp */ - int i = 0; /* {{{ */ - if (tempArray == 0) { - tempArraySize = 256; - tempArray = (int*)malloc(tempArraySize * sizeof(int)); - } - while (1) { - int j; - for (j=0;jtype == OPR_NODE) - switch(node->unode.opr.type) { - case OPR_ADD: precommit_add(node); break; - case OPR_SUB: precommit_sub(node); break; - case OPR_MUL: precommit_mul(node); break; - case OPR_DIV: precommit_div(node); break; - case OPR_CALL_EXPR: precommit_call_expr(node); break; - } - } /* }}} */ - - void commit_node(NodeType *node, int releaseIfTmp) - { /* {{{ */ - if (node == 0) return; - - switch(node->type) { - case OPR_NODE: - switch(node->unode.opr.type) { - case OPR_SET: commit_set(node); break; - case OPR_PLUS_EQ: commit_plus_eq(node); break; - case OPR_SUB_EQ: commit_sub_eq(node); break; - case OPR_MUL_EQ: commit_mul_eq(node); break; - case OPR_DIV_EQ: commit_div_eq(node); break; - case OPR_IF: commit_if(node); break; - case OPR_WHILE: commit_while(node); break; - case OPR_BLOCK: commit_block(node); break; - case OPR_FUNC_INTRO: commit_function_intro(node); break; - case OPR_FUNC_OUTRO: commit_function_outro(node); break; - case OPR_CALL: commit_call(node); break; - case OPR_EXT_CALL: commit_ext_call(node); break; - case OPR_EQU: commit_equ(node); break; - case OPR_LOW: commit_low(node); break; - case OPR_NOT: commit_not(node); break; - case OPR_AFFECT_LIST: commit_affect_list(node); break; - case OPR_FOREACH: commit_foreach(node); break; - case OPR_VAR_LIST: commit_var_list(node); break; -#ifdef VERBOSE - case EMPTY_NODE: printf("NOP\n"); break; -#endif - } - - commit_node(node->unode.opr.next,0); /* recursive for the moment, maybe better to do something iterative? */ - break; - - case VAR_NODE: gsl_instr_set_namespace(currentGoomSL->instr, node->vnamespace); - gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_VAR); break; - case CONST_INT_NODE: gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_INTEGER); break; - case CONST_FLOAT_NODE: gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_FLOAT); break; - case CONST_PTR_NODE: gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_PTR); break; - } - if (releaseIfTmp && is_tmp_expr(node)) - releaseTemp(get_tmp_id(node)); - - nodeFree(node); - } /* }}} */ - - NodeType *nodeNew(const char *str, int type, int line_number) { - NodeType *node = (NodeType*)malloc(sizeof(NodeType)); /* {{{ */ - node->type = type; - node->str = (char*)malloc(strlen(str)+1); - node->vnamespace = NULL; - node->line_number = line_number; - strcpy(node->str, str); - return node; - } /* }}} */ - static NodeType *nodeClone(NodeType *node) { - NodeType *ret = nodeNew(node->str, node->type, node->line_number); /* {{{ */ - ret->vnamespace = node->vnamespace; - ret->unode = node->unode; - return ret; - } /* }}} */ - - void nodeFreeInternals(NodeType *node) { - free(node->str); /* {{{ */ - } /* }}} */ - - void nodeFree(NodeType *node) { - nodeFreeInternals(node); /* {{{ */ - free(node); - } /* }}} */ - - NodeType *new_constInt(const char *str, int line_number) { - NodeType *node = nodeNew(str, CONST_INT_NODE, line_number); /* {{{ */ - node->unode.constInt.val = atoi(str); - return node; - } /* }}} */ - - NodeType *new_constPtr(const char *str, int line_number) { - NodeType *node = nodeNew(str, CONST_PTR_NODE, line_number); /* {{{ */ - node->unode.constPtr.id = strtol(str,NULL,0); - return node; - } /* }}} */ - - NodeType *new_constFloat(const char *str, int line_number) { - NodeType *node = nodeNew(str, CONST_FLOAT_NODE, line_number); /* {{{ */ - node->unode.constFloat.val = atof(str); - return node; - } /* }}} */ - - NodeType *new_var(const char *str, int line_number) { - NodeType *node = nodeNew(str, VAR_NODE, line_number); /* {{{ */ - node->vnamespace = gsl_find_namespace(str); - if (node->vnamespace == 0) { - fprintf(stderr, "ERROR: Line %d, Variable not found: '%s'\n", line_number, str); - exit(1); - } - return node; - } /* }}} */ - - NodeType *new_nop(const char *str) { - NodeType *node = new_op(str, EMPTY_NODE, 0); /* {{{ */ - return node; - } /* }}} */ - - NodeType *new_op(const char *str, int type, int nbOp) { - int i; /* {{{ */ - NodeType *node = nodeNew(str, OPR_NODE, currentGoomSL->num_lines); - node->unode.opr.next = 0; - node->unode.opr.type = type; - node->unode.opr.nbOp = nbOp; - for (i=0;iunode.opr.op[i] = 0; - return node; - } /* }}} */ - - - void gsl_declare_global_variable(int type, char *name) { - switch(type){ - case -1: break; - case FLOAT_TK:gsl_float_decl_global(name);break; - case INT_TK: gsl_int_decl_global(name);break; - case PTR_TK: gsl_ptr_decl_global(name);break; - default: - { - int id = type - 1000; - gsl_struct_decl_global_from_id(name,id); - } - } - } - - - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 1199 "goomsl_yacc.y" -typedef union YYSTYPE { - int intValue; - float floatValue; - char charValue; - char strValue[2048]; - NodeType *nPtr; - GoomHash *namespace; - GSL_Struct *gsl_struct; - GSL_StructField *gsl_struct_field; - } YYSTYPE; -/* Line 191 of yacc.c. */ -#line 1327 "goomsl_yacc.c" -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - -/* Copy the second part of user declarations. */ - - -/* Line 214 of yacc.c. */ -#line 1339 "goomsl_yacc.c" - -#if ! defined (yyoverflow) || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# else -# ifndef YYSTACK_USE_ALLOCA -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# else -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -# define YYSTACK_ALLOC malloc -# define YYSTACK_FREE free -# endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ - - -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - short yyss; - YYSTYPE yyvs; - }; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - register YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (0) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) - -#endif - -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short yysigned_char; -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 3 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 229 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 42 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 30 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 89 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 217 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 279 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 25, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 35, 36, 32, 29, 34, 30, 2, 31, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 33, 2, - 27, 26, 28, 37, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 40, 2, 41, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 38, 2, 39, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const unsigned short yyprhs[] = -{ - 0, 0, 3, 7, 10, 19, 30, 39, 50, 53, - 56, 57, 65, 68, 73, 76, 79, 82, 85, 87, - 89, 90, 93, 96, 99, 102, 104, 108, 111, 112, - 116, 122, 130, 131, 132, 137, 142, 147, 152, 154, - 157, 160, 163, 166, 169, 172, 179, 186, 193, 195, - 199, 203, 207, 211, 218, 222, 224, 227, 231, 232, - 234, 236, 240, 244, 248, 252, 255, 259, 261, 265, - 269, 273, 277, 281, 285, 288, 290, 292, 294, 298, - 304, 310, 318, 323, 330, 333, 335, 340, 344, 346 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yysigned_char yyrhs[] = -{ - 43, 0, -1, 44, 55, 52, -1, 44, 59, -1, - 44, 11, 27, 48, 28, 50, 25, 56, -1, 44, - 11, 27, 48, 33, 51, 28, 50, 25, 56, -1, - 44, 10, 27, 49, 28, 50, 25, 56, -1, 44, - 10, 27, 49, 33, 51, 28, 50, 25, 56, -1, - 44, 45, -1, 44, 25, -1, -1, 22, 27, 5, - 33, 46, 28, 25, -1, 71, 47, -1, 46, 34, - 71, 47, -1, 8, 5, -1, 9, 5, -1, 7, - 5, -1, 5, 5, -1, 5, -1, 5, -1, -1, - 33, 8, -1, 33, 9, -1, 33, 7, -1, 33, - 5, -1, 58, -1, 58, 34, 51, -1, 52, 53, - -1, -1, 54, 44, 55, -1, 27, 49, 28, 50, - 25, -1, 27, 49, 33, 51, 28, 50, 25, -1, - -1, -1, 9, 5, 26, 64, -1, 8, 5, 26, - 64, -1, 7, 5, 26, 64, -1, 5, 5, 26, - 64, -1, 58, -1, 9, 5, -1, 8, 5, -1, - 7, 5, -1, 5, 5, -1, 62, 25, -1, 57, - 25, -1, 35, 65, 36, 37, 71, 59, -1, 12, - 65, 71, 13, 71, 59, -1, 38, 25, 63, 44, - 39, 25, -1, 67, -1, 5, 15, 64, -1, 5, - 16, 64, -1, 5, 18, 64, -1, 5, 17, 64, - -1, 23, 5, 24, 60, 13, 59, -1, 35, 61, - 36, -1, 5, -1, 5, 61, -1, 5, 26, 64, - -1, -1, 5, -1, 66, -1, 64, 32, 64, -1, - 64, 31, 64, -1, 64, 29, 64, -1, 64, 30, - 64, -1, 30, 64, -1, 35, 64, 36, -1, 68, - -1, 64, 26, 64, -1, 64, 27, 64, -1, 64, - 28, 64, -1, 64, 19, 64, -1, 64, 20, 64, - -1, 64, 21, 64, -1, 14, 65, -1, 4, -1, - 3, -1, 6, -1, 49, 25, 56, -1, 49, 33, - 69, 25, 56, -1, 40, 49, 41, 25, 56, -1, - 40, 49, 33, 69, 41, 25, 56, -1, 40, 49, - 56, 41, -1, 40, 49, 33, 69, 41, 56, -1, - 70, 69, -1, 70, -1, 5, 26, 56, 64, -1, - 33, 56, 64, -1, 25, -1, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned short yyrline[] = -{ - 0, 1236, 1236, 1238, 1239, 1240, 1241, 1242, 1243, 1244, - 1245, 1250, 1253, 1254, 1257, 1258, 1259, 1260, 1265, 1267, - 1270, 1271, 1272, 1273, 1274, 1277, 1278, 1283, 1284, 1287, - 1289, 1291, 1294, 1296, 1300, 1301, 1302, 1303, 1304, 1307, - 1308, 1309, 1310, 1315, 1316, 1317, 1318, 1319, 1320, 1321, - 1322, 1323, 1324, 1325, 1328, 1330, 1331, 1334, 1336, 1339, - 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1350, 1351, - 1352, 1353, 1354, 1355, 1356, 1359, 1360, 1361, 1366, 1367, - 1368, 1369, 1373, 1374, 1377, 1378, 1380, 1384, 1393, 1393 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE -/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "LTYPE_INTEGER", "LTYPE_FLOAT", - "LTYPE_VAR", "LTYPE_PTR", "PTR_TK", "INT_TK", "FLOAT_TK", "DECLARE", - "EXTERNAL", "WHILE", "DO", "NOT", "PLUS_EQ", "SUB_EQ", "DIV_EQ", - "MUL_EQ", "SUP_EQ", "LOW_EQ", "NOT_EQ", "STRUCT", "FOR", "IN", "'\\n'", - "'='", "'<'", "'>'", "'+'", "'-'", "'/'", "'*'", "':'", "','", "'('", - "')'", "'?'", "'{'", "'}'", "'['", "']'", "$accept", "gsl", "gsl_code", - "struct_declaration", "struct_members", "struct_member", - "ext_task_name", "task_name", "return_type", "arglist", - "gsl_def_functions", "function", "function_intro", "function_outro", - "leave_namespace", "declaration", "empty_declaration", "instruction", - "var_list", "var_list_content", "affectation", "start_block", - "expression", "test", "constValue", "func_call", "func_call_expression", - "affectation_list", "affectation_in_list", "opt_nl", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const unsigned short yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 10, 61, 60, 62, 43, - 45, 47, 42, 58, 44, 40, 41, 63, 123, 125, - 91, 93 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned char yyr1[] = -{ - 0, 42, 43, 44, 44, 44, 44, 44, 44, 44, - 44, 45, 46, 46, 47, 47, 47, 47, 48, 49, - 50, 50, 50, 50, 50, 51, 51, 52, 52, 53, - 54, 54, 55, 56, 57, 57, 57, 57, 57, 58, - 58, 58, 58, 59, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 59, 60, 61, 61, 62, 63, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, - 65, 65, 65, 65, 65, 66, 66, 66, 67, 67, - 67, 67, 68, 68, 69, 69, 70, 70, 71, 71 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = -{ - 0, 2, 3, 2, 8, 10, 8, 10, 2, 2, - 0, 7, 2, 4, 2, 2, 2, 2, 1, 1, - 0, 2, 2, 2, 2, 1, 3, 2, 0, 3, - 5, 7, 0, 0, 4, 4, 4, 4, 1, 2, - 2, 2, 2, 2, 2, 6, 6, 6, 1, 3, - 3, 3, 3, 6, 3, 1, 2, 3, 0, 1, - 1, 3, 3, 3, 3, 2, 3, 1, 3, 3, - 3, 3, 3, 3, 2, 1, 1, 1, 3, 5, - 5, 7, 4, 6, 2, 1, 4, 3, 1, 0 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const unsigned char yydefact[] = -{ - 10, 0, 32, 1, 19, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 0, 0, 0, 8, 0, 28, - 0, 38, 3, 0, 48, 42, 0, 0, 0, 0, - 0, 41, 40, 39, 0, 0, 76, 75, 59, 77, - 0, 0, 0, 0, 0, 89, 60, 67, 0, 0, - 0, 58, 19, 0, 33, 0, 2, 44, 43, 0, - 49, 50, 52, 51, 57, 0, 0, 0, 0, 18, - 0, 74, 65, 0, 33, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 88, 0, 0, 0, 0, - 10, 0, 0, 78, 0, 33, 0, 85, 0, 27, - 10, 37, 36, 35, 34, 20, 0, 20, 0, 66, - 0, 0, 71, 72, 73, 68, 69, 70, 63, 64, - 62, 61, 89, 89, 0, 0, 89, 0, 0, 33, - 33, 0, 33, 84, 0, 32, 0, 0, 0, 0, - 0, 0, 0, 25, 0, 0, 0, 82, 0, 0, - 0, 55, 0, 0, 0, 0, 0, 80, 0, 87, - 79, 20, 0, 29, 24, 23, 21, 22, 33, 42, - 41, 40, 39, 20, 0, 33, 20, 33, 46, 0, - 89, 0, 0, 0, 0, 12, 56, 54, 53, 45, - 47, 33, 86, 0, 0, 6, 0, 26, 4, 0, - 83, 11, 0, 17, 16, 14, 15, 81, 30, 20, - 33, 33, 13, 0, 7, 5, 31 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const short yydefgoto[] = -{ - -1, 1, 2, 17, 149, 185, 70, 18, 137, 142, - 56, 99, 100, 19, 93, 20, 21, 22, 125, 152, - 23, 90, 44, 45, 46, 24, 47, 96, 97, 86 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -116 -static const short yypact[] = -{ - -116, 40, 136, -116, 103, 39, 66, 68, 61, 65, - 1, 77, 101, -116, 1, 84, 109, -116, 12, -116, - 91, -116, -116, 97, -116, 98, 72, 72, 72, 72, - 72, 99, 104, 113, 109, 130, -116, -116, -116, -116, - 1, 72, 72, 109, 166, 115, -116, -116, 145, 131, - 118, -116, -116, -24, -116, -3, 138, -116, -116, 72, - 159, 159, 159, 159, 159, 72, 72, 72, 14, -116, - 51, -116, 22, 102, 124, 72, 72, 72, 72, 72, - 72, 72, 72, 72, 72, -116, 160, 139, 140, 141, - -116, -3, 152, -116, 154, -116, 156, -3, 109, -116, - -116, 159, 159, 159, 159, 150, 82, 150, 82, -116, - -3, 158, 159, 159, 159, 159, 159, 159, 22, 22, - -116, -116, 115, 115, 195, 188, 115, 88, 162, -116, - -116, 72, -116, -116, 52, 136, 155, 177, 199, 200, - 201, 202, 180, 175, 185, 183, 171, -116, 144, 18, - 161, 195, 178, 144, 144, 190, 191, -116, 72, 159, - -116, 150, 82, -116, -116, -116, -116, -116, -116, -116, - -116, -116, -116, 150, 82, -116, 150, -116, -116, 192, - 115, 208, 213, 214, 215, -116, -116, -116, -116, -116, - -116, -116, 159, 196, 194, -116, 198, -116, -116, 203, - -116, -116, 161, -116, -116, -116, -116, -116, -116, 150, - -116, -116, -116, 204, -116, -116, -116 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yysigned_char yypgoto[] = -{ - -116, -116, -68, -116, -116, 23, -116, -15, -104, -92, - -116, -116, -116, 89, -74, -116, -88, -115, -116, 75, - -116, -116, -16, -6, -116, -116, -116, -62, -116, -99 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -1 -static const unsigned char yytable[] = -{ - 111, 53, 94, 144, 36, 37, 38, 39, 50, 91, - 60, 61, 62, 63, 64, 40, 145, 92, 143, 68, - 143, 131, 127, 148, 150, 72, 73, 154, 74, 128, - 95, 41, 135, 178, 71, 133, 42, 54, 188, 189, - 3, 43, 105, 101, 31, 55, 179, 106, 146, 102, - 103, 104, 180, 83, 84, 157, 158, 193, 160, 112, - 113, 114, 115, 116, 117, 118, 119, 120, 121, 196, - 194, 32, 199, 33, 143, 36, 37, 38, 39, 107, - 161, 202, 197, 134, 108, 162, 143, 138, 34, 139, - 140, 141, 35, 4, 195, 5, 6, 7, 8, 9, - 10, 198, 41, 200, 48, 213, 49, 42, 25, 51, - 11, 12, 43, 13, 52, 159, 57, 207, 26, 27, - 28, 29, 58, 14, 59, 65, 15, 155, 16, 30, - 66, 81, 82, 83, 84, 69, 214, 215, 109, 67, - 85, 4, 192, 5, 6, 7, 8, 9, 10, 4, - 87, 5, 6, 7, 89, 88, 10, 110, 11, 12, - 164, 13, 165, 166, 167, 98, 181, 12, 182, 183, - 184, 14, 123, 122, 15, 124, 16, 129, 126, 14, - 130, 132, 15, 136, 16, 75, 76, 77, 81, 82, - 83, 84, 78, 79, 80, 81, 82, 83, 84, 147, - 151, 153, 168, 156, 169, 170, 171, 172, 173, 174, - 175, 176, 177, 203, 187, 190, 191, 201, 204, 205, - 206, 208, 209, 210, 163, 212, 186, 0, 211, 216 -}; - -static const short yycheck[] = -{ - 74, 16, 5, 107, 3, 4, 5, 6, 14, 33, - 26, 27, 28, 29, 30, 14, 108, 41, 106, 34, - 108, 95, 90, 122, 123, 41, 42, 126, 43, 91, - 33, 30, 100, 148, 40, 97, 35, 25, 153, 154, - 0, 40, 28, 59, 5, 33, 28, 33, 110, 65, - 66, 67, 34, 31, 32, 129, 130, 161, 132, 75, - 76, 77, 78, 79, 80, 81, 82, 83, 84, 173, - 162, 5, 176, 5, 162, 3, 4, 5, 6, 28, - 28, 180, 174, 98, 33, 33, 174, 5, 27, 7, - 8, 9, 27, 5, 168, 7, 8, 9, 10, 11, - 12, 175, 30, 177, 27, 209, 5, 35, 5, 25, - 22, 23, 40, 25, 5, 131, 25, 191, 15, 16, - 17, 18, 25, 35, 26, 26, 38, 39, 40, 26, - 26, 29, 30, 31, 32, 5, 210, 211, 36, 26, - 25, 5, 158, 7, 8, 9, 10, 11, 12, 5, - 5, 7, 8, 9, 36, 24, 12, 33, 22, 23, - 5, 25, 7, 8, 9, 27, 5, 23, 7, 8, - 9, 35, 33, 13, 38, 35, 40, 25, 37, 35, - 26, 25, 38, 33, 40, 19, 20, 21, 29, 30, - 31, 32, 26, 27, 28, 29, 30, 31, 32, 41, - 5, 13, 25, 41, 5, 5, 5, 5, 28, 34, - 25, 28, 41, 5, 36, 25, 25, 25, 5, 5, - 5, 25, 28, 25, 135, 202, 151, -1, 25, 25 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const unsigned char yystos[] = -{ - 0, 43, 44, 0, 5, 7, 8, 9, 10, 11, - 12, 22, 23, 25, 35, 38, 40, 45, 49, 55, - 57, 58, 59, 62, 67, 5, 15, 16, 17, 18, - 26, 5, 5, 5, 27, 27, 3, 4, 5, 6, - 14, 30, 35, 40, 64, 65, 66, 68, 27, 5, - 65, 25, 5, 49, 25, 33, 52, 25, 25, 26, - 64, 64, 64, 64, 64, 26, 26, 26, 49, 5, - 48, 65, 64, 64, 49, 19, 20, 21, 26, 27, - 28, 29, 30, 31, 32, 25, 71, 5, 24, 36, - 63, 33, 41, 56, 5, 33, 69, 70, 27, 53, - 54, 64, 64, 64, 64, 28, 33, 28, 33, 36, - 33, 56, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 13, 33, 35, 60, 37, 44, 69, 25, - 26, 56, 25, 69, 49, 44, 33, 50, 5, 7, - 8, 9, 51, 58, 50, 51, 69, 41, 71, 46, - 71, 5, 61, 13, 71, 39, 41, 56, 56, 64, - 56, 28, 33, 55, 5, 7, 8, 9, 25, 5, - 5, 5, 5, 28, 34, 25, 28, 41, 59, 28, - 34, 5, 7, 8, 9, 47, 61, 36, 59, 59, - 25, 25, 64, 50, 51, 56, 50, 51, 56, 50, - 56, 25, 71, 5, 5, 5, 5, 56, 25, 28, - 25, 25, 47, 50, 56, 56, 25 -}; - -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ - -#define YYFAIL goto yyerrlab - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror ("syntax error: cannot back up");\ - YYERROR; \ - } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -/* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). */ - -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - Current.first_line = Rhs[1].first_line; \ - Current.first_column = Rhs[1].first_column; \ - Current.last_line = Rhs[N].last_line; \ - Current.last_column = Rhs[N].last_column; -#endif - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (YYLEX_PARAM) -#else -# define YYLEX yylex () -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) - -# define YYDSYMPRINT(Args) \ -do { \ - if (yydebug) \ - yysymprint Args; \ -} while (0) - -# define YYDSYMPRINTF(Title, Token, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Token, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (cinluded). | -`------------------------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_stack_print (short *bottom, short *top) -#else -static void -yy_stack_print (bottom, top) - short *bottom; - short *top; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_reduce_print (int yyrule) -#else -static void -yy_reduce_print (yyrule) - int yyrule; -#endif -{ - int yyi; - unsigned int yylineno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", - yyrule - 1, yylineno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (Rule); \ -} while (0) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YYDSYMPRINT(Args) -# define YYDSYMPRINTF(Title, Token, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#if YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) -yystrlen (const char *yystr) -# else -yystrlen (yystr) - const char *yystr; -# endif -{ - register const char *yys = yystr; - - while (*yys++ != '\0') - continue; - - return yys - yystr - 1; -} -# endif -# endif - -# ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -# if defined (__STDC__) || defined (__cplusplus) -yystpcpy (char *yydest, const char *yysrc) -# else -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif -{ - register char *yyd = yydest; - register const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -#endif /* !YYERROR_VERBOSE */ - - - -#if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) -#else -static void -yysymprint (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - if (yytype < YYNTOKENS) - { - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); -# ifdef YYPRINT - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - } - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - switch (yytype) - { - default: - break; - } - YYFPRINTF (yyoutput, ")"); -} - -#endif /* ! YYDEBUG */ -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yydestruct (int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yytype, yyvaluep) - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - switch (yytype) - { - - default: - break; - } -} - - -/* Prevent warnings from -Wmissing-prototypes. */ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM); -# else -int yyparse (); -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - - -/* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; - - - -/*----------. -| yyparse. | -`----------*/ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int -yyparse (void) -#else -int -yyparse () - -#endif -#endif -{ - - register int yystate; - register int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - short yyssa[YYINITDEPTH]; - short *yyss = yyssa; - register short *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - register YYSTYPE *yyvsp; - - - -#define YYPOPSTACK (yyvsp--, yyssp--) - - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; - - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; - - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow ("parser stack overflow", - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyoverflowlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyoverflowlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - short *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyoverflowlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; - - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - yystate = yyn; - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 3: -#line 1238 "goomsl_yacc.y" - { gsl_append(yyvsp[0].nPtr); } - break; - - case 4: -#line 1239 "goomsl_yacc.y" - { gsl_declare_global_variable(yyvsp[-2].intValue,yyvsp[-4].strValue); } - break; - - case 5: -#line 1240 "goomsl_yacc.y" - { gsl_declare_global_variable(yyvsp[-2].intValue,yyvsp[-6].strValue); } - break; - - case 6: -#line 1241 "goomsl_yacc.y" - { gsl_declare_global_variable(yyvsp[-2].intValue,yyvsp[-4].strValue); } - break; - - case 7: -#line 1242 "goomsl_yacc.y" - { gsl_declare_global_variable(yyvsp[-2].intValue,yyvsp[-6].strValue); } - break; - - case 11: -#line 1250 "goomsl_yacc.y" - { gsl_add_struct(yyvsp[-4].strValue, yyvsp[-2].gsl_struct); } - break; - - case 12: -#line 1253 "goomsl_yacc.y" - { yyval.gsl_struct = gsl_new_struct(yyvsp[0].gsl_struct_field); } - break; - - case 13: -#line 1254 "goomsl_yacc.y" - { yyval.gsl_struct = yyvsp[-3].gsl_struct; gsl_add_struct_field(yyvsp[-3].gsl_struct, yyvsp[0].gsl_struct_field); } - break; - - case 14: -#line 1257 "goomsl_yacc.y" - { yyval.gsl_struct_field = gsl_new_struct_field(yyvsp[0].strValue, INSTR_INT); } - break; - - case 15: -#line 1258 "goomsl_yacc.y" - { yyval.gsl_struct_field = gsl_new_struct_field(yyvsp[0].strValue, INSTR_FLOAT); } - break; - - case 16: -#line 1259 "goomsl_yacc.y" - { yyval.gsl_struct_field = gsl_new_struct_field(yyvsp[0].strValue, INSTR_PTR); } - break; - - case 17: -#line 1260 "goomsl_yacc.y" - { yyval.gsl_struct_field = gsl_new_struct_field_struct(yyvsp[0].strValue, yyvsp[-1].strValue); } - break; - - case 18: -#line 1265 "goomsl_yacc.y" - { gsl_declare_external_task(yyvsp[0].strValue); gsl_enternamespace(yyvsp[0].strValue); strcpy(yyval.strValue,yyvsp[0].strValue); } - break; - - case 19: -#line 1267 "goomsl_yacc.y" - { gsl_declare_task(yyvsp[0].strValue); gsl_enternamespace(yyvsp[0].strValue); strcpy(yyval.strValue,yyvsp[0].strValue); strcpy(yyval.strValue,yyvsp[0].strValue); } - break; - - case 20: -#line 1270 "goomsl_yacc.y" - { yyval.intValue=-1; } - break; - - case 21: -#line 1271 "goomsl_yacc.y" - { yyval.intValue=INT_TK; } - break; - - case 22: -#line 1272 "goomsl_yacc.y" - { yyval.intValue=FLOAT_TK; } - break; - - case 23: -#line 1273 "goomsl_yacc.y" - { yyval.intValue=PTR_TK; } - break; - - case 24: -#line 1274 "goomsl_yacc.y" - { yyval.intValue= 1000 + gsl_get_struct_id(yyvsp[0].strValue); } - break; - - case 29: -#line 1287 "goomsl_yacc.y" - { gsl_leavenamespace(); } - break; - - case 30: -#line 1289 "goomsl_yacc.y" - { gsl_append(new_function_intro(yyvsp[-3].strValue)); - gsl_declare_global_variable(yyvsp[-1].intValue,yyvsp[-3].strValue); } - break; - - case 31: -#line 1291 "goomsl_yacc.y" - { gsl_append(new_function_intro(yyvsp[-5].strValue)); - gsl_declare_global_variable(yyvsp[-1].intValue,yyvsp[-5].strValue); } - break; - - case 32: -#line 1294 "goomsl_yacc.y" - { gsl_append(new_function_outro()); } - break; - - case 33: -#line 1296 "goomsl_yacc.y" - { yyval.namespace = gsl_leavenamespace(); } - break; - - case 34: -#line 1300 "goomsl_yacc.y" - { gsl_float_decl_local(yyvsp[-2].strValue); yyval.nPtr = new_set(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines), yyvsp[0].nPtr); } - break; - - case 35: -#line 1301 "goomsl_yacc.y" - { gsl_int_decl_local(yyvsp[-2].strValue); yyval.nPtr = new_set(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines), yyvsp[0].nPtr); } - break; - - case 36: -#line 1302 "goomsl_yacc.y" - { gsl_ptr_decl_local(yyvsp[-2].strValue); yyval.nPtr = new_set(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines), yyvsp[0].nPtr); } - break; - - case 37: -#line 1303 "goomsl_yacc.y" - { gsl_struct_decl_local(yyvsp[-3].strValue,yyvsp[-2].strValue); yyval.nPtr = new_set(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines), yyvsp[0].nPtr); } - break; - - case 38: -#line 1304 "goomsl_yacc.y" - { yyval.nPtr = 0; } - break; - - case 39: -#line 1307 "goomsl_yacc.y" - { gsl_float_decl_local(yyvsp[0].strValue); } - break; - - case 40: -#line 1308 "goomsl_yacc.y" - { gsl_int_decl_local(yyvsp[0].strValue); } - break; - - case 41: -#line 1309 "goomsl_yacc.y" - { gsl_ptr_decl_local(yyvsp[0].strValue); } - break; - - case 42: -#line 1310 "goomsl_yacc.y" - { gsl_struct_decl_local(yyvsp[-1].strValue,yyvsp[0].strValue); } - break; - - case 43: -#line 1315 "goomsl_yacc.y" - { yyval.nPtr = yyvsp[-1].nPtr; } - break; - - case 44: -#line 1316 "goomsl_yacc.y" - { yyval.nPtr = yyvsp[-1].nPtr; } - break; - - case 45: -#line 1317 "goomsl_yacc.y" - { yyval.nPtr = new_if(yyvsp[-4].nPtr,yyvsp[0].nPtr); } - break; - - case 46: -#line 1318 "goomsl_yacc.y" - { yyval.nPtr = new_while(yyvsp[-4].nPtr,yyvsp[0].nPtr); } - break; - - case 47: -#line 1319 "goomsl_yacc.y" - { lastNode = yyvsp[-3].nPtr->unode.opr.op[1]; yyval.nPtr=yyvsp[-3].nPtr; } - break; - - case 48: -#line 1320 "goomsl_yacc.y" - { yyval.nPtr = yyvsp[0].nPtr; } - break; - - case 49: -#line 1321 "goomsl_yacc.y" - { yyval.nPtr = new_plus_eq(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); } - break; - - case 50: -#line 1322 "goomsl_yacc.y" - { yyval.nPtr = new_sub_eq(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); } - break; - - case 51: -#line 1323 "goomsl_yacc.y" - { yyval.nPtr = new_mul_eq(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); } - break; - - case 52: -#line 1324 "goomsl_yacc.y" - { yyval.nPtr = new_div_eq(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); } - break; - - case 53: -#line 1325 "goomsl_yacc.y" - { yyval.nPtr = new_static_foreach(new_var(yyvsp[-4].strValue, currentGoomSL->num_lines), yyvsp[-2].nPtr, yyvsp[0].nPtr); } - break; - - case 54: -#line 1328 "goomsl_yacc.y" - { yyval.nPtr = yyvsp[-1].nPtr; } - break; - - case 55: -#line 1330 "goomsl_yacc.y" - { yyval.nPtr = new_var_list(new_var(yyvsp[0].strValue,currentGoomSL->num_lines), NULL); } - break; - - case 56: -#line 1331 "goomsl_yacc.y" - { yyval.nPtr = new_var_list(new_var(yyvsp[-1].strValue,currentGoomSL->num_lines), yyvsp[0].nPtr); } - break; - - case 57: -#line 1334 "goomsl_yacc.y" - { yyval.nPtr = new_set(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); } - break; - - case 58: -#line 1336 "goomsl_yacc.y" - { yyval.nPtr = new_block(lastNode); lastNode = yyval.nPtr->unode.opr.op[0]; } - break; - - case 59: -#line 1339 "goomsl_yacc.y" - { yyval.nPtr = new_var(yyvsp[0].strValue,currentGoomSL->num_lines); } - break; - - case 60: -#line 1340 "goomsl_yacc.y" - { yyval.nPtr = yyvsp[0].nPtr; } - break; - - case 61: -#line 1341 "goomsl_yacc.y" - { yyval.nPtr = new_mul(yyvsp[-2].nPtr,yyvsp[0].nPtr); } - break; - - case 62: -#line 1342 "goomsl_yacc.y" - { yyval.nPtr = new_div(yyvsp[-2].nPtr,yyvsp[0].nPtr); } - break; - - case 63: -#line 1343 "goomsl_yacc.y" - { yyval.nPtr = new_add(yyvsp[-2].nPtr,yyvsp[0].nPtr); } - break; - - case 64: -#line 1344 "goomsl_yacc.y" - { yyval.nPtr = new_sub(yyvsp[-2].nPtr,yyvsp[0].nPtr); } - break; - - case 65: -#line 1345 "goomsl_yacc.y" - { yyval.nPtr = new_neg(yyvsp[0].nPtr); } - break; - - case 66: -#line 1346 "goomsl_yacc.y" - { yyval.nPtr = yyvsp[-1].nPtr; } - break; - - case 67: -#line 1347 "goomsl_yacc.y" - { yyval.nPtr = yyvsp[0].nPtr; } - break; - - case 68: -#line 1350 "goomsl_yacc.y" - { yyval.nPtr = new_equ(yyvsp[-2].nPtr,yyvsp[0].nPtr); } - break; - - case 69: -#line 1351 "goomsl_yacc.y" - { yyval.nPtr = new_low(yyvsp[-2].nPtr,yyvsp[0].nPtr); } - break; - - case 70: -#line 1352 "goomsl_yacc.y" - { yyval.nPtr = new_low(yyvsp[0].nPtr,yyvsp[-2].nPtr); } - break; - - case 71: -#line 1353 "goomsl_yacc.y" - { yyval.nPtr = new_not(new_low(yyvsp[-2].nPtr,yyvsp[0].nPtr)); } - break; - - case 72: -#line 1354 "goomsl_yacc.y" - { yyval.nPtr = new_not(new_low(yyvsp[0].nPtr,yyvsp[-2].nPtr)); } - break; - - case 73: -#line 1355 "goomsl_yacc.y" - { yyval.nPtr = new_not(new_equ(yyvsp[-2].nPtr,yyvsp[0].nPtr)); } - break; - - case 74: -#line 1356 "goomsl_yacc.y" - { yyval.nPtr = new_not(yyvsp[0].nPtr); } - break; - - case 75: -#line 1359 "goomsl_yacc.y" - { yyval.nPtr = new_constFloat(yyvsp[0].strValue,currentGoomSL->num_lines); } - break; - - case 76: -#line 1360 "goomsl_yacc.y" - { yyval.nPtr = new_constInt(yyvsp[0].strValue,currentGoomSL->num_lines); } - break; - - case 77: -#line 1361 "goomsl_yacc.y" - { yyval.nPtr = new_constPtr(yyvsp[0].strValue,currentGoomSL->num_lines); } - break; - - case 78: -#line 1366 "goomsl_yacc.y" - { yyval.nPtr = new_call(yyvsp[-2].strValue,NULL); } - break; - - case 79: -#line 1367 "goomsl_yacc.y" - { yyval.nPtr = new_call(yyvsp[-4].strValue,yyvsp[-2].nPtr); } - break; - - case 80: -#line 1368 "goomsl_yacc.y" - { yyval.nPtr = new_call(yyvsp[-3].strValue,NULL); } - break; - - case 81: -#line 1369 "goomsl_yacc.y" - { yyval.nPtr = new_call(yyvsp[-5].strValue,yyvsp[-3].nPtr); } - break; - - case 82: -#line 1373 "goomsl_yacc.y" - { yyval.nPtr = new_call_expr(yyvsp[-2].strValue,NULL); } - break; - - case 83: -#line 1374 "goomsl_yacc.y" - { yyval.nPtr = new_call_expr(yyvsp[-4].strValue,yyvsp[-2].nPtr); } - break; - - case 84: -#line 1377 "goomsl_yacc.y" - { yyval.nPtr = new_affec_list(yyvsp[-1].nPtr,yyvsp[0].nPtr); } - break; - - case 85: -#line 1378 "goomsl_yacc.y" - { yyval.nPtr = new_affec_list(yyvsp[0].nPtr,NULL); } - break; - - case 86: -#line 1380 "goomsl_yacc.y" - { - gsl_reenternamespace(yyvsp[-1].namespace); - yyval.nPtr = new_set(new_var(yyvsp[-3].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); - } - break; - - case 87: -#line 1384 "goomsl_yacc.y" - { - gsl_reenternamespace(yyvsp[-1].namespace); - yyval.nPtr = new_set(new_var("&this", currentGoomSL->num_lines),yyvsp[0].nPtr); - } - break; - - - } - -/* Line 999 of yacc.c. */ -#line 2792 "goomsl_yacc.c" - - yyvsp -= yylen; - yyssp -= yylen; - - - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (YYPACT_NINF < yyn && yyn < YYLAST) - { - YYSIZE_T yysize = 0; - int yytype = YYTRANSLATE (yychar); - char *yymsg; - int yyx, yycount; - - yycount = 0; - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - yysize += yystrlen (yytname[yyx]) + 15, yycount++; - yysize += yystrlen ("syntax error, unexpected ") + 1; - yysize += yystrlen (yytname[yytype]); - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg != 0) - { - char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); - yyp = yystpcpy (yyp, yytname[yytype]); - - if (yycount < 5) - { - yycount = 0; - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); - yyx++) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - const char *yyq = ! yycount ? ", expecting " : " or "; - yyp = yystpcpy (yyp, yyq); - yyp = yystpcpy (yyp, yytname[yyx]); - yycount++; - } - } - yyerror (yymsg); - YYSTACK_FREE (yymsg); - } - else - yyerror ("syntax error; also virtual memory exhausted"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror ("syntax error"); - } - - - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - /* Return failure if at end of input. */ - if (yychar == YYEOF) - { - /* Pop the error token. */ - YYPOPSTACK; - /* Pop the rest of the stack. */ - while (yyss < yyssp) - { - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[*yyssp], yyvsp); - YYPOPSTACK; - } - YYABORT; - } - - YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); - yydestruct (yytoken, &yylval); - yychar = YYEMPTY; - - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*----------------------------------------------------. -| yyerrlab1 -- error raised explicitly by an action. | -`----------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[yystate], yyvsp); - yyvsp--; - yystate = *--yyssp; - - YY_STACK_PRINT (yyss, yyssp); - } - - if (yyn == YYFINAL) - YYACCEPT; - - YYDPRINTF ((stderr, "Shifting error token, ")); - - *++yyvsp = yylval; - - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#ifndef yyoverflow -/*----------------------------------------------. -| yyoverflowlab -- parser overflow comes here. | -`----------------------------------------------*/ -yyoverflowlab: - yyerror ("parser stack overflow"); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif - return yyresult; -} - - -#line 1396 "goomsl_yacc.y" - - - -void yyerror(char *str) -{ /* {{{ */ - fprintf(stderr, "ERROR: Line %d, %s\n", currentGoomSL->num_lines, str); - currentGoomSL->compilationOK = 0; - exit(1); -} /* }}} */ - - diff --git a/src/post/goom/mmx.c b/src/post/goom/mmx.c index 3c9d0ee4a..953b59152 100644 --- a/src/post/goom/mmx.c +++ b/src/post/goom/mmx.c @@ -16,9 +16,11 @@ // faire : a / sqrtperte <=> a >> PERTEDEC #define PERTEDEC 4 +#ifdef CPU_X86 int mmx_supported (void) { return (mm_support()&0x1); } +#endif void zoom_filter_mmx (int prevX, int prevY, Pixel *expix1, Pixel *expix2, diff --git a/src/post/goom/mmx.h b/src/post/goom/mmx.h index 6861b7cfe..d422eac20 100644 --- a/src/post/goom/mmx.h +++ b/src/post/goom/mmx.h @@ -244,8 +244,10 @@ mmx_ok(void) return ( mm_support() & 0x1 ); } +#ifdef CPU_X86 int mmx_supported (void); int xmmx_supported (void); +#endif /* MMX optimized implementations */ diff --git a/src/post/goom/xmmx.c b/src/post/goom/xmmx.c index 6b76a86a3..2b9103a3e 100644 --- a/src/post/goom/xmmx.c +++ b/src/post/goom/xmmx.c @@ -23,6 +23,7 @@ /*#include "xmmx.h"*/ #include "goom_graphic.h" +#ifdef CPU_X86 int xmmx_supported (void) { #ifdef ARCH_X86_64 return 0; /* Haven't yet converted zoom_filter_xmmx @@ -31,6 +32,7 @@ int xmmx_supported (void) { return (mm_support()&0x8)>>3; #endif } +#endif void zoom_filter_xmmx (int prevX, int prevY, Pixel *expix1, Pixel *expix2, -- cgit v1.2.3 From 2b3df508106c0cf311132baeab89a2049fe22a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Thu, 17 Jan 2008 20:25:53 +0100 Subject: Remove SyncFB video output plugin, and related documentation and code. Matthias Dahl, the last maintainer of the code, confirms that the needed Linux kernel module is not building anymore, and thus this is unusable. Please consider using VIDIX or DirectFB instead, which should both work fine with Matrox cards. --- src/video_out/Makefile.am | 10 +- src/video_out/video_out_syncfb.c | 1120 -------------------------------------- src/video_out/video_out_syncfb.h | 236 -------- src/xine-engine/configfile.c | 2 - 4 files changed, 1 insertion(+), 1367 deletions(-) delete mode 100644 src/video_out/video_out_syncfb.c delete mode 100644 src/video_out/video_out_syncfb.h (limited to 'src') diff --git a/src/video_out/Makefile.am b/src/video_out/Makefile.am index b7e24d088..3b5703792 100644 --- a/src/video_out/Makefile.am +++ b/src/video_out/Makefile.am @@ -12,7 +12,7 @@ endif EXTRA_DIST = video_out_directx.c video_out_macosx.m -noinst_HEADERS = video_out_syncfb.h yuv2rgb.h x11osd.h xcbosd.h +noinst_HEADERS = yuv2rgb.h x11osd.h xcbosd.h if HAVE_X11 X11OSD = x11osd.c @@ -29,9 +29,6 @@ endif if ENABLE_OPENGL opengl_module = xineplug_vo_out_opengl.la endif -if ENABLE_SYNCFB -syncfb_module = xineplug_vo_out_syncfb.la -endif if ENABLE_SUNFB if ENABLE_SUNDGA pgx64_module = xineplug_vo_out_pgx64.la @@ -93,7 +90,6 @@ endif xineplug_LTLIBRARIES = $(xshm_module) $(xv_module) $(xvmc_module) \ $(opengl_module) \ - $(syncfb_module) \ $(pgx64_module) $(pgx32_module)\ $(vidix_module) \ $(aa_module) \ @@ -140,10 +136,6 @@ xineplug_vo_out_opengl_la_LIBADD = $(MLIB_LIBS) $(OPENGL_LIBS) $(GLUT_LIBS) \ $(GLU_LIBS) $(X_LIBS) $(XINE_LIB) $(PTHREAD_LIBS) $(DYNAMIC_LD_LIBS) $(LTLIBINTL) xineplug_vo_out_opengl_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS) $(MLIB_CFLAGS) -fno-strict-aliasing -xineplug_vo_out_syncfb_la_SOURCES = video_out_syncfb.c -xineplug_vo_out_syncfb_la_LIBADD = $(XINE_LIB) $(X_LIBS) $(PTHREAD_LIBS) $(LTLIBINTL) -xineplug_vo_out_syncfb_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS) - xineplug_vo_out_pgx64_la_SOURCES = video_out_pgx64.c xineplug_vo_out_pgx64_la_LIBADD = $(XINE_LIB) $(X_LIBS) $(SUNDGA_LIBS) $(PTHREAD_LIBS) $(LTLIBINTL) xineplug_vo_out_pgx64_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS) diff --git a/src/video_out/video_out_syncfb.c b/src/video_out/video_out_syncfb.c deleted file mode 100644 index 49c0d371a..000000000 --- a/src/video_out/video_out_syncfb.c +++ /dev/null @@ -1,1120 +0,0 @@ -/* - * Copyright (C) 2000-2003 the xine project - * - * This file is part of xine, a free video player. - * - * xine is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * xine 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * video_out_syncfb.c, SyncFB (for Matrox G200/G400 cards) interface for xine - * - * based on video_out_xv.c by (see file for original authors) - * - * with lot's of code from: - * video_out_syncfb.c by Joachim Koenig - * and by Matthias Oelmann - * video_out_mga by Aaron Holtzman - * - * glued together for xine by Matthias Dahl - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef __sun -#include -#endif - -#include -#if defined (__FreeBSD__) -#include -#endif -#include -#include -#include -#include - -#include -#include - -#include "video_out_syncfb.h" - -#include "xine.h" -#include -#include -#include -#include - -/*#define DEBUG_OUTPUT*/ - -typedef struct syncfb_driver_s syncfb_driver_t; - -typedef struct { - int value; - int min; - int max; -} syncfb_property_t; - -typedef struct { - vo_frame_t vo_frame; -/* uint8_t* data_mem[3];*/ - int width, height, format; - double ratio; -} syncfb_frame_t; - -struct syncfb_driver_s { - - vo_driver_t vo_driver; - - config_values_t *config; - - /* X11 related stuff */ - Display *display; - int screen; - Drawable drawable; - XVisualInfo vinfo; - GC gc; - XColor black; - - vo_scale_t sc; - - int virtual_screen_width; - int virtual_screen_height; - int screen_depth; - - syncfb_property_t props[VO_NUM_PROPERTIES]; - - syncfb_frame_t* cur_frame; - vo_overlay_t* overlay; - - /* syncfb module related stuff */ - int fd; /* file descriptor of the syncfb device */ - int yuv_format; /* either YUV420P3, YUV420P2 or YUV422 */ - int overlay_state; /* 0 = off, 1 = on */ - uint8_t* video_mem; /* mmapped video memory */ - int default_repeat; /* how many times a frame will be repeatedly displayed */ - uint32_t supported_capabilities; - - syncfb_config_t syncfb_config; - syncfb_capability_t capabilities; - syncfb_buffer_info_t bufinfo; - syncfb_param_t params; - - int video_win_visibility; - xine_t *xine; - - alphablend_t alphablend_extra_data; -}; - -typedef struct { - video_driver_class_t driver_class; - - config_values_t *config; - char *device_name; - xine_t *xine; -} syncfb_class_t; - -/* - * internal video_out_syncfb functions - */ - -/* returns boolean value (1 success, 0 failure) */ -static int syncfb_overlay_on(syncfb_driver_t* this) -{ - if(ioctl(this->fd, SYNCFB_ON)) { - xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_syncfb: error. (on ioctl failed)\n"); - return 0; - } else { - this->overlay_state = 1; - return 1; - } -} - -/* returns boolean value (1 success, 0 failure) */ -static int syncfb_overlay_off(syncfb_driver_t* this) -{ - if(ioctl(this->fd, SYNCFB_OFF)) { - xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_syncfb: error. (off ioctl failed)\n"); - return 0; - } else { - this->overlay_state = 0; - return 1; - } -} - -static void write_frame_YUV422(syncfb_driver_t* this, syncfb_frame_t* frame) -{ - uint8_t* y = (uint_8 *)frame->vo_frame.base[0]; - uint8_t* cb = (uint_8 *)frame->vo_frame.base[1]; - uint8_t* cr = (uint_8 *)frame->vo_frame.base[2]; - uint8_t* crp; - uint8_t* cbp; - uint32_t* dst32 = (uint32_t *)(this->video_mem + this->bufinfo.offset); - int h,w; - - for(h = 0; h < (frame->height / 2); h++) { - cbp = cb; - crp = cr; - - for(w = 0; w < (frame->width / 2); w++) { - *dst32++ = (*y) + ((*cb)<<8) + ((*(y+1))<<16) + ((*cr)<<24); - y++; y++; cb++; cr++; - } - - dst32 += (this->syncfb_config.src_pitch - frame->width) / 2; - - for(w=0; w < (frame->width / 2); w++) { - *dst32++ = (*y) + ((*cbp)<<8) + ((*(y+1))<<16) + ((*crp)<<24); - y++; y++; cbp++; crp++; - } - - dst32 += (this->syncfb_config.src_pitch - frame->width) / 2; - } -} - -static void write_frame_YUV420P2(syncfb_driver_t* this, syncfb_frame_t* frame) -{ - uint8_t* y = (uint8_t *)frame->vo_frame.base[0]; - uint8_t* cb = (uint8_t *)frame->vo_frame.base[1]; - uint8_t* cr = (uint8_t *)frame->vo_frame.base[2]; - uint8_t* dst8 = this->video_mem + this->bufinfo.offset_p2; - int h, w; - - register uint32_t* tmp32; - register uint8_t* rcr; - register uint8_t* rcb; - - rcr = cr; - rcb = cb; - - for(h = 0; h < (frame->height / 2); h++) { - tmp32 = (uint32_t *)dst8; - w = (frame->width / 8) * 2; - - while(w--) { - register uint32_t temp; - - temp = (*rcb) | (*rcr << 8); - rcr++; - rcb++; - temp |= (*rcb << 16) | (*rcr << 24); - rcr++; - rcb++; - *tmp32 = temp; - tmp32++; - } - - dst8 += this->syncfb_config.src_pitch; - } - - dst8 = this->video_mem + this->bufinfo.offset; - for(h = 0; h < frame->height; h++) { - xine_fast_memcpy(dst8, y, frame->width); - y += frame->width; - dst8 += this->syncfb_config.src_pitch; - } -} - -static void write_frame_YUV420P3(syncfb_driver_t* this, syncfb_frame_t* frame) -{ - uint8_t* y = (uint8_t *)frame->vo_frame.base[0]; - uint8_t* cb = (uint8_t *)frame->vo_frame.base[1]; - uint8_t* cr = (uint8_t *)frame->vo_frame.base[2]; - uint8_t* dst8 = this->video_mem + this->bufinfo.offset; - int h, half_width = (frame->width/2); - - for(h = 0; h < frame->height; h++) { - xine_fast_memcpy(dst8, y, frame->width); - y += frame->width; - dst8 += this->syncfb_config.src_pitch; - } - - dst8 = this->video_mem; - for(h = 0; h < (frame->height / 2); h++) { - xine_fast_memcpy((dst8 + this->bufinfo.offset_p2), cb, half_width); - xine_fast_memcpy((dst8 + this->bufinfo.offset_p3), cr, half_width); - - cb += half_width; - cr += half_width; - - dst8 += (this->syncfb_config.src_pitch / 2); - } -} - -static void write_frame_YUY2(syncfb_driver_t* this, syncfb_frame_t* frame) -{ - uint8_t* src8 = (uint8_t *)frame->vo_frame.base[0]; - uint8_t* dst8 = (uint8_t *)(this->video_mem + this->bufinfo.offset); - int h, double_width = (frame->width * 2); - - for(h = 0; h < frame->height; h++) { - xine_fast_memcpy(dst8, src8, double_width); - - dst8 += (this->syncfb_config.src_pitch * 2); - src8 += double_width; - } -} - -static void write_frame_sfb(syncfb_driver_t* this, syncfb_frame_t* frame) -{ - switch(frame->format) { - case XINE_IMGFMT_YUY2: - if(this->capabilities.palettes & (1<xine, XINE_VERBOSITY_LOG, - _("video_out_syncfb: error. (YUY2 not supported by your graphic card)\n")); - break; - - case XINE_IMGFMT_YV12: - switch(this->yuv_format) { - case VIDEO_PALETTE_YUV422: - write_frame_YUV422(this, frame); - break; - case VIDEO_PALETTE_YUV420P2: - write_frame_YUV420P2(this, frame); - break; - case VIDEO_PALETTE_YUV420P3: - write_frame_YUV420P3(this, frame); - break; - default: - xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_syncfb: error. (YV12 not supported by your graphic card)\n")); - } - break; - - default: - xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out_syncfb: error. (unknown frame format)\n"); - break; - } - - frame->vo_frame.free(&frame->vo_frame); -} - -static void free_framedata(syncfb_frame_t* frame) -{ -/* if(frame->data_mem[0]) { - free(frame->data_mem[0]); - frame->data_mem[0] = NULL; - } - - if(frame->data_mem[1]) { - free(frame->data_mem[1]); - frame->data_mem[1] = NULL; - } - - if(frame->data_mem[2]) { - free(frame->data_mem[2]); - frame->data_mem[2] = NULL; - }*/ - - if(frame->vo_frame.base[0]) { - free(frame->vo_frame.base[0]); - frame->vo_frame.base[0] = NULL; - } - - if(frame->vo_frame.base[1]) { - free(frame->vo_frame.base[1]); - frame->vo_frame.base[1] = NULL; - } - - if(frame->vo_frame.base[2]) { - free(frame->vo_frame.base[2]); - frame->vo_frame.base[2] = NULL; - } -} - -static void syncfb_clean_output_area(syncfb_driver_t* this) -{ - XLockDisplay (this->display); - - XSetForeground (this->display, this->gc, this->black.pixel); - - XFillRectangle(this->display, this->drawable, this->gc, - this->sc.gui_x, this->sc.gui_y, this->sc.gui_width, this->sc.gui_height); - - XUnlockDisplay (this->display); -} - - -static void syncfb_compute_ideal_size (syncfb_driver_t *this) -{ - _x_vo_scale_compute_ideal_size( &this->sc ); -} - -/* make ideal width/height "fit" into the gui */ -static void syncfb_compute_output_size(syncfb_driver_t *this) -{ - _x_vo_scale_compute_output_size( &this->sc ); - -#ifdef DEBUG_OUTPUT - printf("video_out_syncfb: debug. (frame source %d x %d, screen output %d x %d)\n", - this->sc.delivered_width, this->sc.delivered_height, - this->sc.output_width, this->sc.output_height); -#endif - - /* - * configuring SyncFB module from this point on. - */ - syncfb_overlay_off(this); - - /* sanity checking - certain situations *may* crash the SyncFB module, so - * take care that we always have valid numbers. - */ - if(this->sc.output_xoffset >= 0 && this->sc.output_yoffset >= 0 && - this->cur_frame->width > 0 && this->cur_frame->height > 0 && - this->sc.output_width > 0 && this->sc.output_height > 0 && - this->cur_frame->format > 0 && this->video_win_visibility) { - - if(ioctl(this->fd, SYNCFB_GET_CONFIG, &this->syncfb_config)) - xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_syncfb: error. (get_config ioctl failed)\n"); - - this->syncfb_config.syncfb_mode = SYNCFB_FEATURE_SCALE | SYNCFB_FEATURE_CROP; - - if(this->props[VO_PROP_INTERLACED].value) - this->syncfb_config.syncfb_mode |= SYNCFB_FEATURE_DEINTERLACE; - - switch(this->cur_frame->format) { - case XINE_IMGFMT_YV12: - this->syncfb_config.src_palette = this->yuv_format; - break; - case XINE_IMGFMT_YUY2: - this->syncfb_config.src_palette = VIDEO_PALETTE_YUV422; - break; - default: - xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_syncfb: error. (unknown frame format)\n"); - this->syncfb_config.src_palette = 0; - break; - } - - this->syncfb_config.fb_screen_size = this->virtual_screen_width * this->virtual_screen_height * (this->screen_depth / 8) * 2; - this->syncfb_config.src_width = this->cur_frame->width; - this->syncfb_config.src_height = this->cur_frame->height; - - this->syncfb_config.image_width = this->sc.output_width; - this->syncfb_config.image_height = this->sc.output_height; - - this->syncfb_config.image_xorg = this->sc.output_xoffset + this->sc.gui_win_x; - this->syncfb_config.image_yorg = this->sc.output_yoffset + this->sc.gui_win_y; - - this->syncfb_config.src_crop_top = this->sc.displayed_yoffset; - this->syncfb_config.src_crop_bot = (this->props[VO_PROP_INTERLACED].value && this->sc.displayed_yoffset == 0) ? 1 : this->sc.displayed_yoffset; - this->syncfb_config.src_crop_left = this->sc.displayed_xoffset; - this->syncfb_config.src_crop_right = this->sc.displayed_xoffset; - - this->syncfb_config.default_repeat = (this->props[VO_PROP_INTERLACED].value) ? 1 : this->default_repeat; - - if(this->capabilities.palettes & (1<syncfb_config.src_palette)) { - if(ioctl(this->fd,SYNCFB_SET_CONFIG,&this->syncfb_config)) - xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out_syncfb: error. (set_config ioctl failed)\n"); - - syncfb_overlay_on(this); - } - } -} - -/* - * public functions defined and used by the xine interface - */ - -static int syncfb_redraw_needed(vo_driver_t* this_gen) -{ - syncfb_driver_t* this = (syncfb_driver_t *) this_gen; - - int ret = 0; - - if( _x_vo_scale_redraw_needed( &this->sc ) ) { - - syncfb_compute_output_size (this); - - syncfb_clean_output_area (this); - - ret = 1; - } - - return ret; -} - -static uint32_t syncfb_get_capabilities (vo_driver_t *this_gen) -{ - syncfb_driver_t *this = (syncfb_driver_t *) this_gen; - - return this->supported_capabilities; -} - -static void syncfb_frame_field (vo_frame_t *vo_img, int which_field) -{ - /* not needed for SyncFB */ -} - -static void syncfb_frame_dispose(vo_frame_t* vo_img) -{ - syncfb_frame_t* frame = (syncfb_frame_t *) vo_img; - - if(frame) { - free_framedata(frame); - free(frame); - } -} - -static vo_frame_t* syncfb_alloc_frame(vo_driver_t* this_gen) -{ - /* syncfb_driver_t *this = (syncfb_driver_t *) this_gen; */ - syncfb_frame_t *frame; - - frame = (syncfb_frame_t *) xine_xmalloc(sizeof(syncfb_frame_t)); - if(!frame) - return NULL; - - pthread_mutex_init(&frame->vo_frame.mutex, NULL); - - frame->vo_frame.base[0] = NULL; - frame->vo_frame.base[1] = NULL; - frame->vo_frame.base[2] = NULL; - - /* - * supply required functions - */ - frame->vo_frame.proc_slice = NULL; - frame->vo_frame.proc_frame = NULL; - frame->vo_frame.field = syncfb_frame_field; - frame->vo_frame.dispose = syncfb_frame_dispose; - - frame->vo_frame.driver = this_gen; - - return (vo_frame_t *) frame; -} - -static void syncfb_update_frame_format(vo_driver_t* this_gen, - vo_frame_t* frame_gen, - uint32_t width, uint32_t height, - double ratio, int format, int flags) -{ - syncfb_driver_t *this = (syncfb_driver_t *) this_gen; - syncfb_frame_t *frame = (syncfb_frame_t *) frame_gen; - /* uint32_t frame_size = width*height; */ - - if((frame->width != width) - || (frame->height != height) - || (frame->format != format)) { - -#ifdef DEBUG_OUTPUT - printf("video_out_syncfb: debug. (update frame format: old values [width=%d, height=%d, format=%04x], new values [width=%d, height=%d, format=%04x])\n", frame->width, frame->height, frame->format, width, height, format); -#endif - free_framedata(frame); - - frame->width = width; - frame->height = height; - frame->format = format; - - switch(format) { - case XINE_IMGFMT_YV12: -/* frame->vo_frame.base[0] = xine_xmalloc_aligned(16, frame_size, (void **)&frame->data_mem[0]); - frame->vo_frame.base[1] = xine_xmalloc_aligned(16, frame_size/4, (void **)&frame->data_mem[1]); - frame->vo_frame.base[2] = xine_xmalloc_aligned(16, frame_size/4, (void **)&frame->data_mem[2]);*/ - frame->vo_frame.pitches[0] = 8*((width + 7) / 8); - frame->vo_frame.pitches[1] = 8*((width + 15) / 16); - frame->vo_frame.pitches[2] = 8*((width + 15) / 16); - frame->vo_frame.base[0] = malloc(frame->vo_frame.pitches[0] * height); - frame->vo_frame.base[1] = malloc(frame->vo_frame.pitches[1] * ((height+1)/2)); - frame->vo_frame.base[2] = malloc(frame->vo_frame.pitches[2] * ((height+1)/2)); - break; - case XINE_IMGFMT_YUY2: -/* frame->vo_frame.base[0] = xine_xmalloc_aligned(16, (frame_size*2), (void **)&frame->data_mem[0]);*/ - frame->vo_frame.pitches[0] = 8*((width + 3) / 4); - frame->vo_frame.base[0] = malloc(frame->vo_frame.pitches[0] * height); - frame->vo_frame.base[1] = NULL; - frame->vo_frame.base[2] = NULL; - break; - default: - xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_syncfb: error. (unable to allocate " - "framedata because of unknown frame format: %04x)\n", format); - } - -/* if((format == IMGFMT_YV12 && (frame->data_mem[0] == NULL || frame->data_mem[1] == NULL || frame->data_mem[2] == NULL)) - || (format == IMGFMT_YUY2 && frame->data_mem[0] == NULL)) {*/ - if((format == XINE_IMGFMT_YV12 && (frame->vo_frame.base[0] == NULL || frame->vo_frame.base[1] == NULL || frame->vo_frame.base[2] == NULL)) - || (format == XINE_IMGFMT_YUY2 && frame->vo_frame.base[0] == NULL)) { - xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_syncfb: error. (framedata allocation failed: out of memory)\n"); - - free_framedata(frame); - } - } - - frame->ratio = ratio; -} - -static void syncfb_overlay_blend(vo_driver_t* this_gen, vo_frame_t* frame_gen, vo_overlay_t* overlay) -{ - syncfb_frame_t* frame = (syncfb_frame_t *) frame_gen; - syncfb_driver_t* this = (syncfb_driver_t *) this_gen; - - this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x; - this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y; - - /* alpha blend here */ - if (overlay->rle) { - if (frame->format == XINE_IMGFMT_YV12) - _x_blend_yuv(frame->vo_frame.base, overlay, frame->width, frame->height, frame->vo_frame.pitches, &this->alphablend_extra_data); - else - _x_blend_yuy2(frame->vo_frame.base[0], overlay, frame->width, frame->height, frame->vo_frame.pitches[0], &this->alphablend_extra_data); - } -} - -static void syncfb_display_frame(vo_driver_t* this_gen, vo_frame_t* frame_gen) -{ - syncfb_driver_t* this = (syncfb_driver_t *) this_gen; - syncfb_frame_t* frame = (syncfb_frame_t *) frame_gen; - - this->cur_frame = frame; - - /* - * let's see if this frame is different in size / aspect - * ratio from the previous one - */ - if((frame->width != this->sc.delivered_width) - || (frame->height != this->sc.delivered_height) - || (frame->ratio != this->sc.delivered_ratio)) { -#ifdef DEBUG_OUTPUT - printf("video_out_syncfb: debug. (frame format changed)\n"); -#endif - - this->sc.delivered_width = frame->width; - this->sc.delivered_height = frame->height; - this->sc.delivered_ratio = frame->ratio; - - this->sc.crop_left = frame->vo_frame.crop_left; - this->sc.crop_right = frame->vo_frame.crop_right; - this->sc.crop_top = frame->vo_frame.crop_top; - this->sc.crop_bottom = frame->vo_frame.crop_bottom; - - syncfb_compute_ideal_size(this); - - this->sc.force_redraw = 1; - } - - /* - * tell gui that we are about to display a frame, - * ask for offset and output size - */ - syncfb_redraw_needed(this_gen); - - /* the rest is only successful and safe, if the overlay is really on */ - if(this->overlay_state) { - if(this->bufinfo.id != -1) { - xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_syncfb: error. (invalid syncfb image buffer state)\n"); - frame->vo_frame.free(&frame->vo_frame); - - return; - } - - if(ioctl(this->fd, SYNCFB_REQUEST_BUFFER, &this->bufinfo)) - xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out_syncfb: error. (request ioctl failed)\n"); - - if(this->bufinfo.id == -1) { - xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_syncfb: error. (syncfb module couldn't allocate image buffer)\n"); - frame->vo_frame.free(&frame->vo_frame); - - /* - * there are several "fixable" situations when this request will fail. - * for example when the screen resolution changes, the kernel module - * will get confused - reinitializing everything will fix things for - * the next frame in that case. - */ - syncfb_compute_ideal_size(this); - syncfb_compute_output_size(this); - syncfb_clean_output_area(this); - - return; - } - - write_frame_sfb(this, frame); - - if(ioctl(this->fd, SYNCFB_COMMIT_BUFFER, &this->bufinfo)) - xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out_syncfb: error. (commit ioctl failed)\n"); - } - else - frame->vo_frame.free(&frame->vo_frame); - - this->bufinfo.id = -1; -} - -static int syncfb_get_property(vo_driver_t* this_gen, int property) -{ - syncfb_driver_t* this = (syncfb_driver_t *) this_gen; - - switch (property) { - case VO_PROP_WINDOW_WIDTH: - this->props[property].value = this->sc.gui_width; - break; - case VO_PROP_WINDOW_HEIGHT: - this->props[property].value = this->sc.gui_height; - break; - case VO_PROP_OUTPUT_WIDTH: - this->props[property].value = this->sc.output_width; - break; - case VO_PROP_OUTPUT_HEIGHT: - this->props[property].value = this->sc.output_height; - break; - case VO_PROP_OUTPUT_XOFFSET: - this->props[property].value = this->sc.output_xoffset; - break; - case VO_PROP_OUTPUT_YOFFSET: - this->props[property].value = this->sc.output_yoffset; - break; - } - - return this->props[property].value; -} - -static int syncfb_set_property(vo_driver_t* this_gen, int property, int value) -{ - syncfb_driver_t* this = (syncfb_driver_t *) this_gen; - - switch (property) { - case VO_PROP_INTERLACED: - this->props[property].value = value; - -#ifdef DEBUG_OUTPUT - printf("video_out_syncfb: debug. (VO_PROP_INTERLACED(%d))\n", - this->props[property].value); -#endif - - syncfb_compute_ideal_size(this); - syncfb_compute_output_size(this); - syncfb_clean_output_area(this); - break; - - case VO_PROP_ASPECT_RATIO: - if(value >= XINE_VO_ASPECT_NUM_RATIOS) - value = XINE_VO_ASPECT_AUTO; - - this->props[property].value = value; - this->sc.user_ratio = value; - -#ifdef DEBUG_OUTPUT - printf("video_out_syncfb: debug. (VO_PROP_ASPECT_RATIO(%d))\n", - this->props[property].value); -#endif - - syncfb_compute_ideal_size(this); - syncfb_compute_output_size(this); - syncfb_clean_output_area(this); - break; - - case VO_PROP_ZOOM_X: - if ((value >= XINE_VO_ZOOM_MIN) && (value <= XINE_VO_ZOOM_MAX)) { - this->props[property].value = value; - this->sc.zoom_factor_x = (double)value / (double)XINE_VO_ZOOM_STEP; - - syncfb_compute_ideal_size (this); - - this->sc.force_redraw = 1; - } -/* - printf("video_out_syncfb: info. (the zooming feature is not supported at the moment because of a bug with the SyncFB kernel driver, please refer to README.syncfb)\n"); -*/ - break; - - case VO_PROP_ZOOM_Y: - if ((value >= XINE_VO_ZOOM_MIN) && (value <= XINE_VO_ZOOM_MAX)) { - this->props[property].value = value; - this->sc.zoom_factor_y = (double)value / (double)XINE_VO_ZOOM_STEP; - - syncfb_compute_ideal_size (this); - - this->sc.force_redraw = 1; - } -/* - printf("video_out_syncfb: info. (the zooming feature is not supported at the moment because of a bug with the SyncFB kernel driver, please refer to README.syncfb)\n"); -*/ - break; - - case VO_PROP_CONTRAST: - this->props[property].value = value; - -#ifdef DEBUG_OUTPUT - printf("video_out_syncfb: debug. (VO_PROP_CONTRAST(%d))\n", - this->props[property].value); -#endif - - this->params.contrast = value; - this->params.brightness = this->props[VO_PROP_BRIGHTNESS].value; - this->params.image_width = this->syncfb_config.image_width; /* FIXME */ - this->params.image_height = this->syncfb_config.image_height; - this->params.image_xorg = this->syncfb_config.image_xorg; - this->params.image_yorg = this->syncfb_config.image_yorg; - - if(ioctl(this->fd,SYNCFB_SET_PARAMS,&this->params)) - xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_syncfb: error. (setting of contrast value failed)\n"); - - break; - - case VO_PROP_BRIGHTNESS: - this->props[property].value = value; - -#ifdef DEBUG_OUTPUT - printf("video_out_syncfb: debug. (VO_PROP_BRIGHTNESS(%d))\n", - this->props[property].value); -#endif - - this->params.brightness = value; - this->params.contrast = this->props[VO_PROP_CONTRAST].value; - this->params.image_width = this->syncfb_config.image_width; /* FIXME */ - this->params.image_height = this->syncfb_config.image_height; - this->params.image_xorg = this->syncfb_config.image_xorg; - this->params.image_yorg = this->syncfb_config.image_yorg; - - if(ioctl(this->fd,SYNCFB_SET_PARAMS,&this->params)) - xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_syncfb: error. (setting of brightness value failed)\n"); - - break; - } - - return value; -} - -static void syncfb_get_property_min_max(vo_driver_t *this_gen, - int property, int *min, int *max) -{ - syncfb_driver_t* this = (syncfb_driver_t *) this_gen; - - *min = this->props[property].min; - *max = this->props[property].max; -} - -static int syncfb_gui_data_exchange(vo_driver_t* this_gen, int data_type, - void *data) -{ - syncfb_driver_t* this = (syncfb_driver_t *) this_gen; - - switch (data_type) { - case XINE_GUI_SEND_DRAWABLE_CHANGED: - this->drawable = (Drawable) data; - - XLockDisplay (this->display); - XFreeGC(this->display, this->gc); - this->gc = XCreateGC (this->display, this->drawable, 0, NULL); - XUnlockDisplay (this->display); - break; - case XINE_GUI_SEND_TRANSLATE_GUI_TO_VIDEO: - { - int x1, y1, x2, y2; - x11_rectangle_t *rect = data; - - _x_vo_scale_translate_gui2video(&this->sc, rect->x, rect->y, - &x1, &y1); - _x_vo_scale_translate_gui2video(&this->sc, rect->x + rect->w, rect->y + rect->h, - &x2, &y2); - rect->x = x1; - rect->y = y1; - rect->w = x2-x1; - rect->h = y2-y1; - } - break; - /* - case XINE_GUI_DATA_EX_VIDEOWIN_VISIBLE: - this->video_win_visibility = (int)(int *)data; - syncfb_compute_output_size(this); - break; - */ - - default: - return -1; - } - - return 0; -} - -static void syncfb_dispose(vo_driver_t *this_gen) -{ - syncfb_driver_t *this = (syncfb_driver_t *) this_gen; - - /* get it off the screen - I wanna see my desktop again :-) */ - syncfb_overlay_off(this); - - /* don't know if it is necessary are even right, but anyway...?! */ - munmap(0, this->capabilities.memory_size); - - close(this->fd); - - XLockDisplay (this->display); - XFreeGC(this->display, this->gc); - XUnlockDisplay (this->display); - - _x_alphablend_free(&this->alphablend_extra_data); - - free(this); -} - -static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *visual_gen) { - - syncfb_class_t *class = (syncfb_class_t *) class_gen; - config_values_t *config = class->config; - syncfb_driver_t* this; - Display* display = NULL; - unsigned int i; - x11_visual_t* visual = (x11_visual_t *) visual_gen; - XColor dummy; - XWindowAttributes attr; - - display = visual->display; - - if(!(this = xine_xmalloc(sizeof (syncfb_driver_t)))) - return NULL; - - _x_alphablend_init(&this->alphablend_extra_data, class->xine); - - /* check for syncfb device */ - if((this->fd = open(class->device_name, O_RDWR)) < 0) { - xprintf(class->xine, XINE_VERBOSITY_DEBUG, - "video_out_syncfb: aborting. (unable to open syncfb device \"%s\")\n", class->device_name); - free(this); - return NULL; - } - - this->xine = class->xine; - - /* get capabilities from the syncfb module */ - if(ioctl(this->fd, SYNCFB_GET_CAPS, &this->capabilities)) { - xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_syncfb: aborting. (syncfb_get_caps ioctl failed)\n"); - - close(this->fd); - free(this); - - return NULL; - } - - /* mmap whole video memory */ - this->video_mem = (uint8_t *) mmap(0, this->capabilities.memory_size, PROT_WRITE, MAP_SHARED, this->fd, 0); - - if(this->video_mem == MAP_FAILED) { - xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_syncfb: aborting. (mmap of video memory failed)\n"); - - close(this->fd); - free(this); - - return NULL; - } - - /* - * init properties and capabilities - */ - for (i = 0; iprops[i].value = 0; - this->props[i].min = 0; - this->props[i].max = 0; - } - - this->props[VO_PROP_INTERLACED].value = 0; - this->sc.user_ratio = this->props[VO_PROP_ASPECT_RATIO].value = XINE_VO_ASPECT_AUTO; - this->props[VO_PROP_ZOOM_X].value = 100; - this->props[VO_PROP_ZOOM_Y].value = 100; - - /* check for formats we need... */ - this->supported_capabilities = VO_CAP_CROP; - this->yuv_format = 0; - - /* - * simple fallback mechanism - we want YUV 4:2:0 (3 plane) but we can also - * convert YV12 material to YUV 4:2:0 (2 plane) and YUV 4:2:2 ... - */ - if(this->capabilities.palettes & (1<supported_capabilities |= VO_CAP_YV12; - this->yuv_format = VIDEO_PALETTE_YUV420P3; - xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_syncfb: info. (SyncFB module supports YUV 4:2:0 (3 plane))\n")); - } else if(this->capabilities.palettes & (1<supported_capabilities |= VO_CAP_YV12; - this->yuv_format = VIDEO_PALETTE_YUV420P2; - xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_syncfb: info. (SyncFB module supports YUV 4:2:0 (2 plane))\n")); - } else if(this->capabilities.palettes & (1<supported_capabilities |= VO_CAP_YV12; - this->yuv_format = VIDEO_PALETTE_YUV422; - xprintf(this->xine, XINE_VERBOSITY_DEBUG, - _("video_out_syncfb: info. (SyncFB module supports YUV 4:2:2)\n")); - } - - if(this->capabilities.palettes & (1<supported_capabilities |= VO_CAP_YUY2; - xprintf(this->xine, XINE_VERBOSITY_DEBUG, - _("video_out_syncfb: info. (SyncFB module supports YUY2)\n")); - } - if(this->capabilities.palettes & (1<supported_capabilities |= VO_CAP_RGB; - */ - xprintf(this->xine, XINE_VERBOSITY_DEBUG, - _("video_out_syncfb: info. (SyncFB module supports RGB565)\n")); - } - - if(!this->supported_capabilities) { - xprintf(this->xine, XINE_VERBOSITY_DEBUG, - _("video_out_syncfb: aborting. (SyncFB module does not support YV12, YUY2 nor RGB565)\n")); - - munmap(0, this->capabilities.memory_size); - close(this->fd); - free(this); - - return NULL; - } - - if(ioctl(this->fd,SYNCFB_GET_PARAMS,&this->params) == 0) { - this->props[VO_PROP_CONTRAST].value = this->params.contrast; - this->props[VO_PROP_CONTRAST].min = 0; - this->props[VO_PROP_CONTRAST].max = 255; - - this->props[VO_PROP_BRIGHTNESS].value = this->params.brightness; - this->props[VO_PROP_BRIGHTNESS].min = -128; - this->props[VO_PROP_BRIGHTNESS].max = 127; - } else { - xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_syncfb: info. (brightness/contrast control won\'t be available because " - "your SyncFB kernel module seems to be outdated. Please refer to README." - "syncfb for informations on how to update it.)\n")); - } - - /* check for virtual screen size and screen depth - this is rather important - because that data is later used for free memory calculation */ - XGetWindowAttributes(visual->display, DefaultRootWindow(visual->display), &attr); - - this->virtual_screen_height = attr.height; - this->virtual_screen_width = attr.width; - this->screen_depth = attr.depth; - - /* initialize the rest of the variables now with default values */ - this->bufinfo.id = -1; - this->config = config; - this->cur_frame = NULL; - - /* FIXME: setting the default_repeat to anything higher than 1 will result - in a distorted video, so for now, set this manually to 0 until - the kernel driver is fixed... */ -#if 0 - this->default_repeat = config->register_range(config, - "video.device.syncfb_default_repeat", 3, 1, 4, - _("default number of frame repetitions"), - _("This specifies how many times a single video " - "frame will be displayed consecutively."), - 10, NULL, NULL); -#endif - this->default_repeat = 0; - - this->display = visual->display; - this->drawable = visual->d; - this->gc = XCreateGC (this->display, this->drawable, 0, NULL); - - _x_vo_scale_init (&this->sc, 1, 0, config ); - this->sc.frame_output_cb = visual->frame_output_cb; - this->sc.user_data = visual->user_data; - - this->overlay = NULL; - this->screen = visual->screen; - this->video_win_visibility = 1; - - XAllocNamedColor(this->display, - DefaultColormap(this->display, this->screen), - "black", &this->black, &dummy); - - this->vo_driver.get_capabilities = syncfb_get_capabilities; - this->vo_driver.alloc_frame = syncfb_alloc_frame; - this->vo_driver.update_frame_format = syncfb_update_frame_format; - this->vo_driver.overlay_begin = NULL; /* not used */ - this->vo_driver.overlay_blend = syncfb_overlay_blend; - this->vo_driver.overlay_end = NULL; /* not used */ - this->vo_driver.display_frame = syncfb_display_frame; - this->vo_driver.get_property = syncfb_get_property; - this->vo_driver.set_property = syncfb_set_property; - this->vo_driver.get_property_min_max = syncfb_get_property_min_max; - this->vo_driver.gui_data_exchange = syncfb_gui_data_exchange; - this->vo_driver.dispose = syncfb_dispose; - this->vo_driver.redraw_needed = syncfb_redraw_needed; - - return &this->vo_driver; -} - -/* - * class functions - */ -static void *init_class (xine_t *xine, void *visual_gen) { - - syncfb_class_t *this; - char* device_name; - int fd; - - device_name = xine->config->register_filename(xine->config, "video.device.syncfb_device", "/dev/syncfb", - XINE_CONFIG_STRING_IS_DEVICE_NAME, - _("SyncFB device name"), - _("Specifies the file name for the SyncFB (TeleTux) device " - "to be used.\nThis setting is security critical, " - "because when changed to a different file, xine " - "can be used to fill this file with arbitrary content. " - "So you should be careful that the value you enter " - "really is a proper framebuffer device."), - XINE_CONFIG_SECURITY, NULL, NULL); - - /* check for syncfb device */ - if((fd = open(device_name, O_RDWR)) < 0) { - xprintf(xine, XINE_VERBOSITY_DEBUG, - "video_out_syncfb: aborting. (unable to open syncfb device \"%s\")\n", device_name); - return NULL; - } - close(fd); - - /* - * from this point on, nothing should go wrong anymore - */ - this = (syncfb_class_t *) xine_xmalloc (sizeof (syncfb_class_t)); - - this->driver_class.open_plugin = open_plugin; - this->driver_class.identifier = "SyncFB"; - this->driver_class.description = N_("xine video output plugin using the SyncFB module for Matrox G200/G400 cards"); - this->driver_class.dispose = default_video_driver_class_dispose; - - this->config = xine->config; - this->xine = xine; - this->device_name = device_name; - - return this; -} - -static const vo_info_t vo_info_syncfb = { - 7, /* priority */ - XINE_VISUAL_TYPE_X11 /* visual type */ -}; - -/* - * exported plugin catalog entry - */ - -const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ - { PLUGIN_VIDEO_OUT, 22, "SyncFB", XINE_VERSION_CODE, &vo_info_syncfb, init_class }, - { PLUGIN_NONE, 0, "", 0, NULL, NULL } -}; - diff --git a/src/video_out/video_out_syncfb.h b/src/video_out/video_out_syncfb.h deleted file mode 100644 index 1fc3df83a..000000000 --- a/src/video_out/video_out_syncfb.h +++ /dev/null @@ -1,236 +0,0 @@ -#ifndef __LINUX_SYNCFB_H -#define __LINUX_SYNCFB_H - -#ifdef __KERNEL__ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#define TRUE 1 -#define FALSE 0 - -#define SFB_STATUS_FREE 0 -#define SFB_STATUS_OFFS 1 -#define SFB_STATUS_WAIT 2 -#define SFB_STATUS_LIVE 3 - -#endif /* KERNEL */ - - -#ifndef AARONS_TYPES -typedef unsigned long uint_32; -typedef unsigned char uint_8; -#endif - -#define SYNCFB_MAJOR 178 - -#define SYNCFB_ERROR_NO_ERROR 0; -#define SYNCFB_ERROR_NO_BUFFER_AVAILABLE 1; -#define SYNCFB_ERROR_PALETTE_NOT_SUPPORTED 2; -#define SYNCFB_ERROR_NOT_ENOUGH_MEMORY 3; - - - -#ifndef __LINUX_VIDEODEV_H -#define VIDEO_PALETTE_GREY 1 /* Linear greyscale */ -#define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */ -#define VIDEO_PALETTE_RGB565 3 /* 565 16 bit RGB */ -#define VIDEO_PALETTE_RGB24 4 /* 24bit RGB */ -#define VIDEO_PALETTE_RGB32 5 /* 32bit RGB */ -#define VIDEO_PALETTE_RGB555 6 /* 555 15bit RGB */ -#define VIDEO_PALETTE_YUV422 7 /* YUV422 capture */ -#define VIDEO_PALETTE_YUYV 8 -#define VIDEO_PALETTE_UYVY 9 /* The great thing about standards is ... */ -#define VIDEO_PALETTE_YUV420 10 -#define VIDEO_PALETTE_YUV411 11 /* YUV411 capture */ -#define VIDEO_PALETTE_RAW 12 /* RAW capture (BT848) */ -#define VIDEO_PALETTE_YUV422P 13 /* YUV 4:2:2 Planar */ -#define VIDEO_PALETTE_YUV411P 14 /* YUV 4:1:1 Planar */ -#define VIDEO_PALETTE_YUV420P 15 /* YUV 4:2:0 Planar */ -#define VIDEO_PALETTE_YUV410P 16 /* YUV 4:1:0 Planar */ -#define VIDEO_PALETTE_PLANAR 13 /* start of planar entries */ -#define VIDEO_PALETTE_COMPONENT 7 /* start of component entries */ -#endif - - -#define VIDEO_PALETTE_YUV422P3 13 /* YUV 4:2:2 Planar (3 Plane, same as YUV422P) */ -#define VIDEO_PALETTE_YUV422P2 17 /* YUV 4:2:2 Planar (2 Plane) */ - -#define VIDEO_PALETTE_YUV411P3 14 /* YUV 4:1:1 Planar (3 Plane, same as YUV411P) */ -#define VIDEO_PALETTE_YUV411P2 18 /* YUV 4:1:1 Planar (2 Plane) */ - -#define VIDEO_PALETTE_YUV420P3 15 /* YUV 4:2:0 Planar (3 Plane, same as YUV420P) */ -#define VIDEO_PALETTE_YUV420P2 19 /* YUV 4:2:0 Planar (2 Plane) */ - -#define VIDEO_PALETTE_YUV410P3 16 /* YUV 4:1:0 Planar (3 Plane, same as YUV410P) */ -#define VIDEO_PALETTE_YUV410P2 20 /* YUV 4:1:0 Planar (2 Plane) */ - - - -#define SYNCFB_FEATURE_SCALE_H 1 -#define SYNCFB_FEATURE_SCALE_V 2 -#define SYNCFB_FEATURE_SCALE 3 -#define SYNCFB_FEATURE_CROP 4 -#define SYNCFB_FEATURE_OFFSET 8 -#define SYNCFB_FEATURE_DEINTERLACE 16 -#define SYNCFB_FEATURE_PROCAMP 32 -#define SYNCFB_FEATURE_TRANSITIONS 64 -#define SYNCFB_FEATURE_COLKEY 128 -#define SYNCFB_FEATURE_MIRROR_H 256 -#define SYNCFB_FEATURE_MIRROR_V 512 -#define SYNCFB_FEATURE_BLOCK_REQUEST 1024 -#define SYNCFB_FEATURE_FREQDIV2 2048 - - -typedef struct syncfb_config_s -{ - uint_32 syncfb_mode; /* bitfield: turn on/off the available features */ - uint_32 error_code; /* RO: returns 0 on successful config calls, error code otherwise */ - - uint_32 fb_screen_size; /* WO, size in bytes of video memory reserved for fbdev */ - uint_32 fb_screen_width; /* WO, visible screen width in pixel */ - uint_32 fb_screen_height; /* WO, visible screen height in pixel */ - - uint_32 buffers; /* RO, number of available buffers */ - uint_32 buffer_size; /* RO, filled in by syncfb */ - - uint_32 default_repeat; /* default repeat time for a single frame, can be overridden in syncfb_buffer_info_t */ - - uint_32 src_width; /* source image width in pixel */ - uint_32 src_height; /* source image height in pixel */ - uint_32 src_palette; /* set palette mode, see videodev.h for palettes */ - uint_32 src_pitch; /* RO: filled in by ioctl: actual line length in pixel */ - - uint_32 image_xorg; /* x position of the image on the screen */ - uint_32 image_yorg; /* y position of the image on the screen */ - - /* if syncfb has FEATURE_SCALE */ - uint_32 scale_filters; /* 0: no filtering, 255: all filters on */ - uint_32 image_width; /* onscreen image width */ - uint_32 image_height; /* onscreen image height */ - - /* if syncfb has FEATURE_CROP */ - uint_32 src_crop_left; /* */ - uint_32 src_crop_right; /* */ - uint_32 src_crop_top; /* */ - uint_32 src_crop_bot; /* */ - - /* if syncfb has FEATURE_OFFSET */ - uint_32 image_offset_left; /* */ - uint_32 image_offset_right; /* */ - uint_32 image_offset_top; /* */ - uint_32 image_offset_bot; /* */ - - /* if syncfb has FEATURE_COLKEY */ - uint_8 colkey_red; - uint_8 colkey_green; - uint_8 colkey_blue; - -} syncfb_config_t; - - -/* - picture parameters, -*/ -typedef struct syncfb_param_s -{ - /* the idea is to enable smooth transitions between eg. image sizes (not yet implemented) */ - /* if syncfb has FEATURE_TRANSITIONS */ - uint_32 transition_time; - - /* if syncfb has FEATURE_PROCAMP */ - uint_32 contrast; /* 0: least contrast, 1000: normal contrast, */ - uint_32 brightness; - uint_32 color; /* for syncfb_matrox: color=0: b/w else: full color */ - - /* if syncfb has FEATURE_SCALE , currently only supported in CONFIG call */ - uint_8 scale_filters; /* 0: no filtering, 255: all filters on */ - uint_32 image_xorg; /* x position of the image on the screen */ - uint_32 image_yorg; /* y position of the image on the screen */ - uint_32 image_width; /* onscreen image width */ - uint_32 image_height; /* onscreen image height */ - -} syncfb_param_t; - - - -typedef struct syncfb_status_info_s -{ - uint_32 field_cnt; /* basically all vbi's since the start of syncfb */ - uint_32 frame_cnt; /* number of frames comitted & output */ - - uint_32 hold_field_cnt; /* number of repeated fields becaus no new data was available */ - uint_32 skip_field_cnt; /* skipped fields when fifo was about to fill up */ - - uint_32 request_frames; /* number of request_buffer calls */ - uint_32 commit_frames; /* number of commit_buffer calls */ - - uint_32 failed_requests; /* number of calls to request_buffer that failed */ - - uint_32 buffers_waiting; - uint_32 buffers_free; - -} syncfb_status_info_t; - - - - -typedef struct syncfb_capability_s -{ - char name[64]; /* A name for the syncfb ... */ - uint_32 palettes; /* supported palettes - see videodev.h for palettes, test the corresponding bit here */ - uint_32 features; /* supported features - see SYNCFB_FEATURE_* */ - uint_32 memory_size; /* total size of mappable video memory */ - -} syncfb_capability_t; - - - -typedef struct syncfb_buffer_info_s -{ - int id; /* buffer id: a return value of -1 means no buffer available */ - uint_32 repeat; /* the buffer will be shown times */ - uint_32 offset; /* buffer offset from start of video memory */ - uint_32 offset_p2; /* yuv plane 2 buffer offset from start of video memory */ - uint_32 offset_p3; /* yuv plane 3 buffer offset from start of video memory */ - -} syncfb_buffer_info_t; - - - - - - - -/* get syncfb capabilities */ -#define SYNCFB_GET_CAPS _IOR('J', 1, syncfb_config_t) - -#define SYNCFB_GET_CONFIG _IOR('J', 2, syncfb_config_t) -#define SYNCFB_SET_CONFIG _IOR('J', 3, syncfb_config_t) -#define SYNCFB_ON _IO ('J', 4) -#define SYNCFB_OFF _IO ('J', 5) -#define SYNCFB_REQUEST_BUFFER _IOR ('J', 6, syncfb_buffer_info_t) -#define SYNCFB_COMMIT_BUFFER _IOR ('J', 7, syncfb_buffer_info_t) -#define SYNCFB_STATUS _IOR ('J', 8, syncfb_status_info_t) -#define SYNCFB_VBI _IO ('J', 9) /* simulate interrupt - debugging only */ -#define SYNCFB_SET_PARAMS _IOR('J', 10, syncfb_param_t) -#define SYNCFB_GET_PARAMS _IOR('J', 11, syncfb_param_t) - - - - -#endif /* __LINUX_SYNCFB_H */ - diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index 3e3c0f7b5..2934b7fef 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -182,8 +182,6 @@ static const xine_config_entry_translation_t config_entry_translation[] = { { "video.pgx64_overlay_mode", "" }, { "video.pgx64_saturation", "video.output.pgx64_saturation" }, { "video.sdl_hw_accel", "video.device.sdl_hw_accel" }, - { "video.syncfb_default_repeat", "video.device.syncfb_default_repeat" }, - { "video.syncfb_device", "video.device.syncfb_device" }, { "video.unichrome_cpu_save", "video.device.unichrome_cpu_save" }, { "video.vertical_position", "video.output.vertical_position" }, { "video.vidix_blue_intensity", "video.output.vidix_blue_intensity" }, -- cgit v1.2.3 From 7d9294e060283d36cc1ac996cba807e95de5dc31 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Thu, 17 Jan 2008 22:37:10 +0000 Subject: Backed out changeset d35b87a8b361 due to build failure. --- src/post/goom/Makefile.am | 2 +- src/post/goom/goomsl_lex.c | 2108 ++++++++++++++++++++++++++++++ src/post/goom/goomsl_yacc.c | 2997 +++++++++++++++++++++++++++++++++++++++++++ src/post/goom/mmx.c | 2 - src/post/goom/mmx.h | 2 - src/post/goom/xmmx.c | 2 - 6 files changed, 5106 insertions(+), 7 deletions(-) create mode 100644 src/post/goom/goomsl_lex.c create mode 100644 src/post/goom/goomsl_yacc.c (limited to 'src') diff --git a/src/post/goom/Makefile.am b/src/post/goom/Makefile.am index 81e2eff32..22b4af79f 100644 --- a/src/post/goom/Makefile.am +++ b/src/post/goom/Makefile.am @@ -30,7 +30,7 @@ xinepost_LTLIBRARIES = xineplug_post_goom.la xineplug_post_goom_la_SOURCES = mmx.c xine_goom.c \ config_param.c convolve_fx.c cpu_info.c drawmethods.c filters.c flying_stars_fx.c \ gfontlib.c goom_core.c goom_tools.c goomsl.c goomsl_hash.c goomsl_heap.c \ - graphic.c ifs.c lines.c \ + goomsl_lex.c goomsl_yacc.c graphic.c ifs.c lines.c \ plugin_info.c sound_tester.c surf3d.c tentacle3d.c v3d.c xineplug_post_goom_la_LIBADD = $(XINE_LIB) $(GOOM_LIBS) $(PTHREAD_LIBS) $(LTLIBINTL) -lm $(noinst_LTLIBRARIES) xineplug_post_goom_la_CFLAGS = $(DEFAULT_OCFLAGS) $(AM_CFLAGS) diff --git a/src/post/goom/goomsl_lex.c b/src/post/goom/goomsl_lex.c new file mode 100644 index 000000000..988fb99da --- /dev/null +++ b/src/post/goom/goomsl_lex.c @@ -0,0 +1,2108 @@ +#line 2 "goomsl_lex.c" + +#line 4 "goomsl_lex.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 31 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart(yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int yyleng; + +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires + * access to the local variable yy_act. Since yyless() is a macro, it would break + * existing scanners that call yyless() from OUTSIDE yylex. + * One obvious solution it to make yy_act a global. I tried that, and saw + * a 5% performance hit in a non-yylineno scanner, because yy_act is + * normally declared as a register variable-- so it is not worth it. + */ + #define YY_LESS_LINENO(n) \ + do { \ + int yyl;\ + for ( yyl = n; yyl < yyleng; ++yyl )\ + if ( yytext[yyl] == '\n' )\ + --yylineno;\ + }while(0) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef unsigned int yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart (FILE *input_file ); +void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); +void yy_delete_buffer (YY_BUFFER_STATE b ); +void yy_flush_buffer (YY_BUFFER_STATE b ); +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state (void ); + +static void yyensure_buffer_stack (void ); +static void yy_load_buffer_state (void ); +static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); + +void *yyalloc (yy_size_t ); +void *yyrealloc (void *,yy_size_t ); +void yyfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +typedef unsigned char YY_CHAR; + +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; + +typedef int yy_state_type; + +#define YY_FLEX_LEX_COMPAT +extern int yylineno; + +int yylineno = 1; + +extern char yytext[]; + +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + if ( yyleng + (yy_more_offset) >= YYLMAX ) \ + YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \ + yy_flex_strncpy( &yytext[(yy_more_offset)], (yytext_ptr), yyleng + 1 ); \ + yyleng += (yy_more_offset); \ + (yy_prev_more_offset) = (yy_more_offset); \ + (yy_more_offset) = 0; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 49 +#define YY_END_OF_BUFFER 50 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_acclist[214] = + { 0, + 50, 48, 49, 47, 48, 49, 4, 49, 48, 49, + 13, 48, 49, 10, 48, 49, 33, 48, 49, 48, + 49, 48, 49, 48, 49, 48, 49, 48, 49, 34, + 48, 49, 34, 48, 49, 48, 49, 48, 49, 33, + 48, 49, 33, 48, 49, 33, 48, 49, 33, 48, + 49, 33, 48, 49, 33, 48, 49, 33, 48, 49, + 33, 48, 49, 33, 48, 49, 33, 48, 49, 47, + 48, 49, 1, 4, 49, 48, 49, 7, 49, 6, + 49, 7, 49, 7, 49, 1, 6, 49, 7, 49, + 3, 49, 1, 3, 49, 17, 49, 49, 16, 17, + + 49, 17, 49, 47, 45, 10, 10, 10, 33, 40, + 39, 41, 11, 12, 42, 38, 37, 34, 43, 46, + 44, 33, 33, 28, 33, 33, 33, 33, 33, 30, + 33, 33, 33, 33, 33, 33, 47, 1, 12, 5, + 15, 14, 10, 10, 35, 37, 36, 33, 33, 33, + 33, 33, 29, 33, 19, 33, 26, 33, 21, 33, + 33, 33, 33, 2, 10, 10, 33, 33, 33, 33, + 33, 33, 33, 31, 33, 33, 10, 10, 33, 33, + 33, 32, 33, 18, 33, 33, 33, 27, 33, 10, + 10, 33, 33, 33, 22, 33, 25, 33, 10, 9, + + 10, 10, 20, 33, 23, 33, 33, 10, 24, 33, + 10, 8, 10 + } ; + +static yyconst flex_int16_t yy_accept[152] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 4, 7, 9, 11, 14, 17, 20, 22, 24, 26, + 28, 30, 33, 36, 38, 40, 43, 46, 49, 52, + 55, 58, 61, 64, 67, 70, 73, 76, 78, 80, + 82, 84, 86, 89, 91, 93, 96, 98, 99, 102, + 104, 105, 106, 107, 108, 109, 110, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 119, 120, 121, + 122, 123, 124, 126, 127, 128, 129, 130, 132, 133, + 134, 135, 136, 137, 138, 139, 139, 140, 141, 141, + 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, + + 151, 152, 153, 155, 157, 159, 161, 162, 163, 164, + 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, + 174, 176, 177, 178, 179, 180, 181, 182, 184, 186, + 187, 188, 190, 191, 192, 193, 194, 195, 197, 199, + 200, 202, 203, 205, 207, 208, 209, 211, 212, 214, + 214 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 4, 5, 6, 7, 1, 8, 9, 10, 1, + 1, 11, 12, 1, 13, 14, 15, 16, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 1, 1, 18, + 19, 20, 1, 9, 21, 21, 21, 21, 22, 23, + 21, 21, 24, 21, 21, 25, 21, 26, 21, 21, + 21, 27, 28, 29, 21, 21, 21, 21, 21, 21, + 1, 30, 1, 1, 31, 1, 32, 33, 34, 35, + + 36, 37, 38, 39, 40, 21, 21, 41, 21, 42, + 43, 44, 21, 45, 46, 47, 48, 21, 49, 50, + 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[51] = + { 0, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 3, 1, 4, 4, 1, 1, 1, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, + 3, 4, 4, 4, 4, 4, 4, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 + } ; + +static yyconst flex_int16_t yy_base[159] = + { 0, + 0, 49, 51, 54, 221, 57, 60, 64, 223, 225, + 69, 225, 203, 225, 51, 0, 0, 202, 201, 200, + 64, 68, 72, 72, 199, 174, 57, 166, 55, 173, + 171, 166, 165, 166, 171, 99, 225, 93, 225, 225, + 194, 107, 225, 193, 225, 225, 225, 225, 225, 71, + 93, 225, 0, 183, 178, 0, 195, 225, 225, 225, + 225, 225, 225, 225, 89, 107, 0, 225, 225, 225, + 161, 169, 0, 155, 160, 157, 154, 151, 150, 151, + 150, 146, 153, 123, 225, 177, 188, 225, 126, 187, + 225, 225, 164, 159, 225, 100, 0, 146, 145, 149, + + 138, 151, 0, 0, 0, 0, 59, 146, 140, 177, + 225, 157, 147, 141, 144, 130, 138, 126, 130, 137, + 0, 134, 165, 143, 133, 112, 109, 0, 0, 102, + 92, 0, 130, 112, 93, 98, 101, 0, 0, 125, + 124, 94, 0, 0, 78, 59, 0, 61, 0, 225, + 141, 145, 149, 151, 155, 51, 159, 163 + } ; + +static yyconst flex_int16_t yy_def[159] = + { 0, + 150, 1, 151, 151, 151, 151, 152, 152, 150, 150, + 150, 150, 150, 150, 153, 154, 155, 150, 150, 150, + 150, 150, 150, 150, 150, 154, 154, 154, 154, 154, + 154, 154, 154, 154, 154, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 153, 153, 153, 154, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 156, 150, 150, 150, + 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, + 154, 154, 154, 150, 150, 150, 157, 150, 150, 157, + 150, 150, 153, 153, 150, 150, 156, 154, 154, 154, + + 154, 154, 154, 154, 154, 154, 154, 154, 154, 157, + 150, 153, 153, 154, 154, 154, 154, 154, 154, 154, + 154, 154, 153, 153, 154, 154, 154, 154, 154, 154, + 154, 154, 158, 153, 154, 154, 154, 154, 154, 158, + 158, 153, 154, 154, 154, 153, 154, 153, 153, 0, + 150, 150, 150, 150, 150, 150, 150, 150 + } ; + +static yyconst flex_int16_t yy_nxt[276] = + { 0, + 10, 11, 12, 11, 13, 14, 15, 10, 16, 17, + 18, 19, 20, 10, 21, 22, 23, 24, 10, 25, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 10, + 16, 16, 26, 16, 27, 28, 29, 16, 16, 30, + 16, 31, 16, 32, 16, 33, 34, 16, 35, 16, + 36, 37, 36, 40, 97, 42, 43, 42, 42, 46, + 42, 41, 48, 38, 41, 49, 48, 149, 44, 49, + 51, 44, 51, 54, 61, 64, 91, 55, 62, 64, + 148, 65, 63, 66, 66, 65, 75, 66, 66, 50, + 68, 69, 72, 50, 51, 76, 51, 77, 119, 73, + + 84, 85, 84, 61, 96, 96, 120, 87, 89, 85, + 89, 63, 92, 86, 64, 96, 96, 67, 147, 146, + 65, 86, 66, 66, 84, 85, 84, 89, 85, 89, + 141, 141, 145, 144, 143, 142, 141, 86, 139, 138, + 86, 39, 39, 39, 39, 47, 47, 47, 47, 53, + 137, 53, 53, 56, 56, 57, 136, 57, 57, 110, + 110, 110, 110, 140, 135, 140, 140, 134, 133, 132, + 131, 130, 129, 128, 127, 126, 125, 124, 123, 111, + 122, 121, 118, 117, 116, 115, 114, 113, 112, 111, + 111, 90, 109, 108, 107, 106, 105, 104, 103, 102, + + 101, 100, 99, 98, 95, 94, 93, 90, 88, 83, + 82, 81, 80, 79, 78, 74, 71, 70, 60, 59, + 58, 52, 150, 45, 9, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150 + } ; + +static yyconst flex_int16_t yy_chk[276] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 3, 156, 4, 4, 4, 6, 6, + 6, 3, 7, 2, 4, 7, 8, 148, 4, 8, + 11, 6, 11, 15, 21, 22, 50, 15, 21, 23, + 146, 22, 21, 22, 22, 23, 29, 23, 23, 7, + 24, 24, 27, 8, 51, 29, 51, 29, 107, 27, + + 36, 36, 36, 38, 65, 65, 107, 38, 42, 42, + 42, 38, 50, 36, 66, 96, 96, 22, 145, 142, + 66, 42, 66, 66, 84, 84, 84, 89, 89, 89, + 141, 140, 137, 136, 135, 134, 133, 84, 131, 130, + 89, 151, 151, 151, 151, 152, 152, 152, 152, 153, + 127, 153, 153, 154, 154, 155, 126, 155, 155, 157, + 157, 157, 157, 158, 125, 158, 158, 124, 123, 122, + 120, 119, 118, 117, 116, 115, 114, 113, 112, 110, + 109, 108, 102, 101, 100, 99, 98, 94, 93, 90, + 87, 86, 83, 82, 81, 80, 79, 78, 77, 76, + + 75, 74, 72, 71, 57, 55, 54, 44, 41, 35, + 34, 33, 32, 31, 30, 28, 26, 25, 20, 19, + 18, 13, 9, 5, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150 + } ; + +/* Table of booleans, true if rule could match eol. */ +static yyconst flex_int32_t yy_rule_can_match_eol[50] = + { 0, +1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; + +extern int yy_flex_debug; +int yy_flex_debug = 0; + +static yy_state_type *yy_state_buf=0, *yy_state_ptr=0; +static char *yy_full_match; +static int yy_lp; +#define REJECT \ +{ \ +*yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ \ +yy_cp = (yy_full_match); /* restore poss. backed-over text */ \ +++(yy_lp); \ +goto find_rule; \ +} + +static int yy_more_offset = 0; +static int yy_prev_more_offset = 0; +#define yymore() ((yy_more_offset) = yy_flex_strlen( yytext )) +#define YY_NEED_STRLEN +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET \ + { \ + (yy_more_offset) = (yy_prev_more_offset); \ + yyleng -= (yy_more_offset); \ + } +#ifndef YYLMAX +#define YYLMAX 8192 +#endif + +char yytext[YYLMAX]; +char *yytext_ptr; +#line 1 "goomsl_lex.l" +#line 2 "goomsl_lex.l" + +#include +#include +#include +#include "goomsl.h" +#include "goomsl_private.h" +#include "goomsl_yacc.h" +void yyerror(char *); +void yyparse(void); + +GoomSL *currentGoomSL; +static int string_size; +static char string[1024]; + + + +#line 639 "goomsl_lex.c" + +#define INITIAL 0 +#define C_COMMENT 1 +#define LINE_COMMENT 2 +#define STRING 3 + +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap (void ); +#else +extern int yywrap (void ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex (void); + +#define YY_DECL int yylex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + if ( yyleng > 0 ) \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ + (yytext[yyleng - 1] == '\n'); \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 25 "goomsl_lex.l" + + +#line 797 "goomsl_lex.c" + + if ( (yy_init) ) + { + (yy_init) = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_state_buf) ) + (yy_state_buf) = (yy_state_type *)yyalloc(YY_BUF_SIZE + 2 ); + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer(yyin,YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); + yy_current_state += YY_AT_BOL(); + + (yy_state_ptr) = (yy_state_buf); + *(yy_state_ptr)++ = yy_current_state; + +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 151 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + *(yy_state_ptr)++ = yy_current_state; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 225 ); + +yy_find_action: + yy_current_state = *--(yy_state_ptr); + (yy_lp) = yy_accept[yy_current_state]; +find_rule: /* we branch to this label when backing up */ + for ( ; ; ) /* until we find what rule we matched */ + { + if ( (yy_lp) && (yy_lp) < yy_accept[yy_current_state + 1] ) + { + yy_act = yy_acclist[(yy_lp)]; + { + (yy_full_match) = yy_cp; + break; + } + } + --yy_cp; + yy_current_state = *--(yy_state_ptr); + (yy_lp) = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) + { + int yyl; + for ( yyl = (yy_prev_more_offset); yyl < yyleng; ++yyl ) + if ( yytext[yyl] == '\n' ) + + yylineno++; +; + } + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ +case 1: +/* rule 1 can match eol */ +YY_RULE_SETUP +#line 27 "goomsl_lex.l" +{ ++currentGoomSL->num_lines; /* Ignore empty lines */ } + YY_BREAK +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 28 "goomsl_lex.l" +{ ++currentGoomSL->num_lines; /* Ignore empty lines */ } + YY_BREAK +case 3: +/* rule 3 can match eol */ +YY_RULE_SETUP +#line 30 "goomsl_lex.l" +{ ++currentGoomSL->num_lines; yylval.charValue=*yytext; BEGIN INITIAL; return '\n'; } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 31 "goomsl_lex.l" +{ ++currentGoomSL->num_lines; yylval.charValue=*yytext; return '\n'; } + YY_BREAK +case 5: +YY_RULE_SETUP +#line 33 "goomsl_lex.l" +{ BEGIN INITIAL; } + YY_BREAK +case 6: +/* rule 6 can match eol */ +YY_RULE_SETUP +#line 34 "goomsl_lex.l" +{ ++currentGoomSL->num_lines; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 35 "goomsl_lex.l" +{ /* eat up comment */ } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 37 "goomsl_lex.l" +{ currentGoomSL->num_lines = 0; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 38 "goomsl_lex.l" +{ currentGoomSL->num_lines = 0; printf("%s\n", yytext); } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 39 "goomsl_lex.l" +{ /* ignore preprocessor lines */ } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 41 "goomsl_lex.l" +{ BEGIN C_COMMENT; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 42 "goomsl_lex.l" +{ BEGIN LINE_COMMENT; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 43 "goomsl_lex.l" +{ BEGIN STRING; string_size=0; } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 45 "goomsl_lex.l" +{ string[string_size++] = '\n'; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 46 "goomsl_lex.l" +{ string[string_size++] = '\"'; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 47 "goomsl_lex.l" +{ /* fin de la chaine: on cree le pointeur qui va bien */ + unsigned int tmp; + BEGIN INITIAL; + string[string_size]=0; + tmp = gsl_malloc(currentGoomSL, string_size+1); + strcpy((char*)currentGoomSL->ptrArray[tmp],string); + sprintf(yylval.strValue, "0x%08x", tmp); + return LTYPE_PTR; + } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 56 "goomsl_lex.l" +{ string[string_size++] = *yytext; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 58 "goomsl_lex.l" +{ return FLOAT_TK; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 59 "goomsl_lex.l" +{ return INT_TK; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 60 "goomsl_lex.l" +{ return INT_TK; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 61 "goomsl_lex.l" +{ return PTR_TK; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 62 "goomsl_lex.l" +{ return PTR_TK; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 63 "goomsl_lex.l" +{ return DECLARE; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 64 "goomsl_lex.l" +{ return EXTERNAL; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 65 "goomsl_lex.l" +{ return STRUCT; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 66 "goomsl_lex.l" +{ return NOT; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 67 "goomsl_lex.l" +{ return WHILE; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 68 "goomsl_lex.l" +{ return DO; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 69 "goomsl_lex.l" +{ return FOR; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 70 "goomsl_lex.l" +{ return IN; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 71 "goomsl_lex.l" +{ strncpy(yylval.strValue, "1", 2047); return LTYPE_INTEGER; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 72 "goomsl_lex.l" +{ strncpy(yylval.strValue, "0", 2047); return LTYPE_INTEGER; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 73 "goomsl_lex.l" +{ strncpy(yylval.strValue, yytext, 2047); return LTYPE_VAR; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 74 "goomsl_lex.l" +{ strncpy(yylval.strValue, yytext, 2047); return LTYPE_INTEGER; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 75 "goomsl_lex.l" +{ sprintf(yylval.strValue, "%d", (int)yytext[1]); return LTYPE_INTEGER; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 76 "goomsl_lex.l" +{ strncpy(yylval.strValue, yytext, 2047); return LTYPE_INTEGER; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 77 "goomsl_lex.l" +{ strncpy(yylval.strValue, yytext, 2047); return LTYPE_FLOAT; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 78 "goomsl_lex.l" +{ sprintf(yylval.strValue, "%3.2f", atof(yytext)/100.0f); return LTYPE_FLOAT; } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 79 "goomsl_lex.l" +{ return PLUS_EQ; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 80 "goomsl_lex.l" +{ return MUL_EQ; } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 81 "goomsl_lex.l" +{ return SUB_EQ; } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 82 "goomsl_lex.l" +{ return DIV_EQ; } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 83 "goomsl_lex.l" +{ return LOW_EQ; } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 84 "goomsl_lex.l" +{ return SUP_EQ; } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 85 "goomsl_lex.l" +{ return NOT_EQ; } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 86 "goomsl_lex.l" +{ return NOT_EQ; } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 87 "goomsl_lex.l" +/* eat up whitespace */ + YY_BREAK +case 48: +YY_RULE_SETUP +#line 88 "goomsl_lex.l" +{ yylval.charValue = *yytext; return *yytext; } + YY_BREAK +case 49: +YY_RULE_SETUP +#line 90 "goomsl_lex.l" +ECHO; + YY_BREAK +#line 1155 "goomsl_lex.c" + case YY_STATE_EOF(INITIAL): + case YY_STATE_EOF(C_COMMENT): + case YY_STATE_EOF(LINE_COMMENT): + case YY_STATE_EOF(STRING): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart(yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + yy_current_state += YY_AT_BOL(); + + (yy_state_ptr) = (yy_state_buf); + *(yy_state_ptr)++ = yy_current_state; + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 151 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + *(yy_state_ptr)++ = yy_current_state; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + register int yy_is_jam; + + register YY_CHAR yy_c = 1; + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 151 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 150); + if ( ! yy_is_jam ) + *(yy_state_ptr)++ = yy_current_state; + + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + if ( c == '\n' ){ + --yylineno; + } + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart(yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); + if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol ) + + yylineno++; +; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer(yyin,YY_BUF_SIZE ); + } + + yy_init_buffer(YY_CURRENT_BUFFER,input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void yy_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yy_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree((void *) b->yy_ch_buf ); + + yyfree((void *) b ); +} + +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + yy_flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yy_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param str a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (yyconst char * str ) +{ + + return yy_scan_bytes(str,strlen(str) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (yyconst char * bytes, int len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yyalloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int yyget_lineno (void) +{ + + return yylineno; +} + +/** Get the input stream. + * + */ +FILE *yyget_in (void) +{ + return yyin; +} + +/** Get the output stream. + * + */ +FILE *yyget_out (void) +{ + return yyout; +} + +/** Get the length of the current token. + * + */ +int yyget_leng (void) +{ + return yyleng; +} + +/** Get the current token. + * + */ + +char *yyget_text (void) +{ + return yytext; +} + +/** Set the current line number. + * @param line_number + * + */ +void yyset_lineno (int line_number ) +{ + + yylineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * in_str ) +{ + yyin = in_str ; +} + +void yyset_out (FILE * out_str ) +{ + yyout = out_str ; +} + +int yyget_debug (void) +{ + return yy_flex_debug; +} + +void yyset_debug (int bdebug ) +{ + yy_flex_debug = bdebug ; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(); + } + + /* Destroy the stack itself. */ + yyfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + yyfree ( (yy_state_buf) ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *yyrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#undef YY_NEW_FILE +#undef YY_FLUSH_BUFFER +#undef yy_set_bol +#undef yy_new_buffer +#undef yy_set_interactive +#undef YY_DO_BEFORE_ACTION + +#ifdef YY_DECL_IS_OURS +#undef YY_DECL_IS_OURS +#undef YY_DECL +#endif +#line 90 "goomsl_lex.l" + + + + +int yywrap(void) { return 1; yyunput(0,0); } + + diff --git a/src/post/goom/goomsl_yacc.c b/src/post/goom/goomsl_yacc.c new file mode 100644 index 000000000..589b171be --- /dev/null +++ b/src/post/goom/goomsl_yacc.c @@ -0,0 +1,2997 @@ +/* A Bison parser, made by GNU Bison 1.875. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + LTYPE_INTEGER = 258, + LTYPE_FLOAT = 259, + LTYPE_VAR = 260, + LTYPE_PTR = 261, + PTR_TK = 262, + INT_TK = 263, + FLOAT_TK = 264, + DECLARE = 265, + EXTERNAL = 266, + WHILE = 267, + DO = 268, + NOT = 269, + PLUS_EQ = 270, + SUB_EQ = 271, + DIV_EQ = 272, + MUL_EQ = 273, + SUP_EQ = 274, + LOW_EQ = 275, + NOT_EQ = 276, + STRUCT = 277, + FOR = 278, + IN = 279 + }; +#endif +#define LTYPE_INTEGER 258 +#define LTYPE_FLOAT 259 +#define LTYPE_VAR 260 +#define LTYPE_PTR 261 +#define PTR_TK 262 +#define INT_TK 263 +#define FLOAT_TK 264 +#define DECLARE 265 +#define EXTERNAL 266 +#define WHILE 267 +#define DO 268 +#define NOT 269 +#define PLUS_EQ 270 +#define SUB_EQ 271 +#define DIV_EQ 272 +#define MUL_EQ 273 +#define SUP_EQ 274 +#define LOW_EQ 275 +#define NOT_EQ 276 +#define STRUCT 277 +#define FOR 278 +#define IN 279 + + + + +/* Copy the first part of user declarations. */ +#line 6 "goomsl_yacc.y" + + #include + #include + #include + #include "goomsl.h" + #include "goomsl_private.h" + +#define STRUCT_ALIGNMENT 16 +/* #define VERBOSE */ + + int yylex(void); + void yyerror(char *); + extern GoomSL *currentGoomSL; + + static NodeType *nodeNew(const char *str, int type, int line_number); + static NodeType *nodeClone(NodeType *node); + static void nodeFreeInternals(NodeType *node); + static void nodeFree(NodeType *node); + + static void commit_node(NodeType *node, int releaseIfTemp); + static void precommit_node(NodeType *node); + + static NodeType *new_constInt(const char *str, int line_number); + static NodeType *new_constFloat(const char *str, int line_number); + static NodeType *new_constPtr(const char *str, int line_number); + static NodeType *new_var(const char *str, int line_number); + static NodeType *new_nop(const char *str); + static NodeType *new_op(const char *str, int type, int nbOp); + + static int allocateLabel(); + static int allocateTemp(); + static void releaseTemp(int n); + static void releaseAllTemps(); + + static int is_tmp_expr(NodeType *node) { + if (node->str) { + return (!strncmp(node->str,"_i_tmp_",7)) + || (!strncmp(node->str,"_f_tmp_",7)) + || (!strncmp(node->str,"_p_tmp",7)); + } + return 0; + } + /* pre: is_tmp_expr(node); */ + static int get_tmp_id(NodeType *node) { return atoi((node->str)+5); } + + static int is_commutative_expr(int itype) + { /* {{{ */ + return (itype == INSTR_ADD) + || (itype == INSTR_MUL) + || (itype == INSTR_ISEQUAL); + } /* }}} */ + + static void GSL_PUT_LABEL(char *name, int line_number) + { /* {{{ */ +#ifdef VERBOSE + printf("label %s\n", name); +#endif + currentGoomSL->instr = gsl_instr_init(currentGoomSL, "label", INSTR_LABEL, 1, line_number); + gsl_instr_add_param(currentGoomSL->instr, name, TYPE_LABEL); + } /* }}} */ + static void GSL_PUT_JUMP(char *name, int line_number) + { /* {{{ */ +#ifdef VERBOSE + printf("jump %s\n", name); +#endif + currentGoomSL->instr = gsl_instr_init(currentGoomSL, "jump", INSTR_JUMP, 1, line_number); + gsl_instr_add_param(currentGoomSL->instr, name, TYPE_LABEL); + } /* }}} */ + + static void GSL_PUT_JXXX(char *name, char *iname, int instr_id, int line_number) + { /* {{{ */ +#ifdef VERBOSE + printf("%s %s\n", iname, name); +#endif + currentGoomSL->instr = gsl_instr_init(currentGoomSL, iname, instr_id, 1, line_number); + gsl_instr_add_param(currentGoomSL->instr, name, TYPE_LABEL); + } /* }}} */ + static void GSL_PUT_JZERO(char *name,int line_number) + { /* {{{ */ + GSL_PUT_JXXX(name,"jzero.i",INSTR_JZERO,line_number); + } /* }}} */ + static void GSL_PUT_JNZERO(char *name, int line_number) + { /* {{{ */ + GSL_PUT_JXXX(name,"jnzero.i",INSTR_JNZERO,line_number); + } /* }}} */ + + /* Structures Management */ + +#define ALIGN_ADDR(_addr,_align) {\ + if (_align>1) {\ + int _dec = (_addr%_align);\ + if (_dec != 0) _addr += _align - _dec;\ + }} + + /* */ + void gsl_prepare_struct(GSL_Struct *s, int s_align, int i_align, int f_align) + { + int i; + int consumed = 0; + int iblk=0, fblk=0; + + s->iBlock[0].size = 0; + s->iBlock[0].data = 0; + s->fBlock[0].size = 0; + s->fBlock[0].data = 0; + + /* Prepare sub-struct and calculate space needed for their storage */ + for (i = 0; i < s->nbFields; ++i) + { + if (s->fields[i]->type < FIRST_RESERVED) + { + int j=0; + GSL_Struct *substruct = currentGoomSL->gsl_struct[s->fields[i]->type]; + consumed += sizeof(int); /* stocke le prefix */ + ALIGN_ADDR(consumed, s_align); + s->fields[i]->offsetInStruct = consumed; + gsl_prepare_struct(substruct, s_align, i_align, f_align); + for(j=0;substruct->iBlock[j].size>0;++j) { + s->iBlock[iblk].data = consumed + substruct->iBlock[j].data; + s->iBlock[iblk].size = substruct->iBlock[j].size; + iblk++; + } + for(j=0;substruct->fBlock[j].size>0;++j) { + s->fBlock[fblk].data = consumed + substruct->fBlock[j].data; + s->fBlock[fblk].size = substruct->fBlock[j].size; + fblk++; + } + consumed += substruct->size; + } + } + + /* Then prepare integers */ + ALIGN_ADDR(consumed, i_align); + for (i = 0; i < s->nbFields; ++i) + { + if (s->fields[i]->type == INSTR_INT) + { + if (s->iBlock[iblk].size == 0) { + s->iBlock[iblk].size = 1; + s->iBlock[iblk].data = consumed; + } else { + s->iBlock[iblk].size += 1; + } + s->fields[i]->offsetInStruct = consumed; + consumed += sizeof(int); + } + } + + iblk++; + s->iBlock[iblk].size = 0; + s->iBlock[iblk].data = 0; + + /* Then prepare floats */ + ALIGN_ADDR(consumed, f_align); + for (i = 0; i < s->nbFields; ++i) + { + if (s->fields[i]->type == INSTR_FLOAT) + { + if (s->fBlock[fblk].size == 0) { + s->fBlock[fblk].size = 1; + s->fBlock[fblk].data = consumed; + } else { + s->fBlock[fblk].size += 1; + } + s->fields[i]->offsetInStruct = consumed; + consumed += sizeof(int); + } + } + + fblk++; + s->fBlock[fblk].size = 0; + s->fBlock[fblk].data = 0; + + /* Finally prepare pointers */ + ALIGN_ADDR(consumed, i_align); + for (i = 0; i < s->nbFields; ++i) + { + if (s->fields[i]->type == INSTR_PTR) + { + s->fields[i]->offsetInStruct = consumed; + consumed += sizeof(int); + } + } + s->size = consumed; + } + + /* Returns the ID of a struct from its name */ + int gsl_get_struct_id(const char *name) /* {{{ */ + { + HashValue *ret = goom_hash_get(currentGoomSL->structIDS, name); + if (ret != NULL) return ret->i; + return -1; + } /* }}} */ + + /* Adds the definition of a struct */ + void gsl_add_struct(const char *name, GSL_Struct *gsl_struct) /* {{{ */ + { + /* Prepare the struct: ie calculate internal storage format */ + gsl_prepare_struct(gsl_struct, STRUCT_ALIGNMENT, STRUCT_ALIGNMENT, STRUCT_ALIGNMENT); + + /* If the struct does not already exists */ + if (gsl_get_struct_id(name) < 0) + { + /* adds it */ + int id = currentGoomSL->nbStructID++; + goom_hash_put_int(currentGoomSL->structIDS, name, id); + if (currentGoomSL->gsl_struct_size <= id) { + currentGoomSL->gsl_struct_size *= 2; + currentGoomSL->gsl_struct = (GSL_Struct**)realloc(currentGoomSL->gsl_struct, + sizeof(GSL_Struct*) * currentGoomSL->gsl_struct_size); + } + currentGoomSL->gsl_struct[id] = gsl_struct; + } + } /* }}} */ + + /* Creates a field for a struct */ + GSL_StructField *gsl_new_struct_field(const char *name, int type) + { + GSL_StructField *field = (GSL_StructField*)malloc(sizeof(GSL_StructField)); + strcpy(field->name, name); + field->type = type; + return field; + } + + /* Create as field for a struct which will be a struct itself */ + GSL_StructField *gsl_new_struct_field_struct(const char *name, const char *type) + { + GSL_StructField *field = gsl_new_struct_field(name, gsl_get_struct_id(type)); + if (field->type < 0) { + fprintf(stderr, "ERROR: Line %d, Unknown structure: '%s'\n", + currentGoomSL->num_lines, type); + exit(1); + } + return field; + } + + /* Creates a Struct */ + GSL_Struct *gsl_new_struct(GSL_StructField *field) + { + GSL_Struct *s = (GSL_Struct*)malloc(sizeof(GSL_Struct)); + s->nbFields = 1; + s->fields[0] = field; + return s; + } + + /* Adds a field to a struct */ + void gsl_add_struct_field(GSL_Struct *s, GSL_StructField *field) + { + s->fields[s->nbFields++] = field; + } + + int gsl_type_of_var(GoomHash *ns, const char *name) + { + char type_of[256]; + HashValue *hv; + sprintf(type_of, "__type_of_%s", name); + hv = goom_hash_get(ns, type_of); + if (hv != NULL) + return hv->i; + fprintf(stderr, "ERROR: Unknown variable type: '%s'\n", name); + return -1; + } + + static void gsl_declare_var(GoomHash *ns, const char *name, int type, void *space) + { + char type_of[256]; + if (name[0] == '@') { ns = currentGoomSL->vars; } + + if (space == NULL) { + switch (type) { + case INSTR_INT: + case INSTR_FLOAT: + case INSTR_PTR: + space = goom_heap_malloc_with_alignment(currentGoomSL->data_heap, + sizeof(int), sizeof(int)); + break; + case -1: + fprintf(stderr, "What the fuck!\n"); + exit(1); + default: /* On a un struct_id */ + space = goom_heap_malloc_with_alignment_prefixed(currentGoomSL->data_heap, + currentGoomSL->gsl_struct[type]->size, STRUCT_ALIGNMENT, sizeof(int)); + } + } + goom_hash_put_ptr(ns, name, (void*)space); + sprintf(type_of, "__type_of_%s", name); + goom_hash_put_int(ns, type_of, type); + + /* Ensuite le hack: on ajoute les champs en tant que variables. */ + if (type < FIRST_RESERVED) + { + int i; + GSL_Struct *gsl_struct = currentGoomSL->gsl_struct[type]; + ((int*)space)[-1] = type; /* stockage du type dans le prefixe de structure */ + for (i = 0; i < gsl_struct->nbFields; ++i) + { + char full_name[256]; + char *cspace = (char*)space + gsl_struct->fields[i]->offsetInStruct; + sprintf(full_name, "%s.%s", name, gsl_struct->fields[i]->name); + gsl_declare_var(ns, full_name, gsl_struct->fields[i]->type, cspace); + } + } + } + + /* Declare a variable which will be a struct */ + static void gsl_struct_decl(GoomHash *namespace, const char *struct_name, const char *name) + { + int struct_id = gsl_get_struct_id(struct_name); + gsl_declare_var(namespace, name, struct_id, NULL); + } + + static void gsl_float_decl_global(const char *name) + { + gsl_declare_var(currentGoomSL->vars, name, INSTR_FLOAT, NULL); + } + static void gsl_int_decl_global(const char *name) + { + gsl_declare_var(currentGoomSL->vars, name, INSTR_INT, NULL); + } + static void gsl_ptr_decl_global(const char *name) + { + gsl_declare_var(currentGoomSL->vars, name, INSTR_PTR, NULL); + } + static void gsl_struct_decl_global_from_id(const char *name, int id) + { + gsl_declare_var(currentGoomSL->vars, name, id, NULL); + } + + /* FLOAT */ + static void gsl_float_decl_local(const char *name) + { + gsl_declare_var(currentGoomSL->namespaces[currentGoomSL->currentNS], name, INSTR_FLOAT, NULL); + } + /* INT */ + static void gsl_int_decl_local(const char *name) + { + gsl_declare_var(currentGoomSL->namespaces[currentGoomSL->currentNS], name, INSTR_INT, NULL); + } + /* PTR */ + static void gsl_ptr_decl_local(const char *name) + { + gsl_declare_var(currentGoomSL->namespaces[currentGoomSL->currentNS], name, INSTR_PTR, NULL); + } + /* STRUCT */ + static void gsl_struct_decl_local(const char *struct_name, const char *name) + { + gsl_struct_decl(currentGoomSL->namespaces[currentGoomSL->currentNS],struct_name,name); + } + + + static void commit_test2(NodeType *set,const char *type, int instr); + static NodeType *new_call(const char *name, NodeType *affect_list); + + /* SETTER */ + static NodeType *new_set(NodeType *lvalue, NodeType *expression) + { /* {{{ */ + NodeType *set = new_op("set", OPR_SET, 2); + set->unode.opr.op[0] = lvalue; + set->unode.opr.op[1] = expression; + return set; + } /* }}} */ + static void commit_set(NodeType *set) + { /* {{{ */ + commit_test2(set,"set",INSTR_SET); + } /* }}} */ + + /* PLUS_EQ */ + static NodeType *new_plus_eq(NodeType *lvalue, NodeType *expression) /* {{{ */ + { + NodeType *set = new_op("plus_eq", OPR_PLUS_EQ, 2); + set->unode.opr.op[0] = lvalue; + set->unode.opr.op[1] = expression; + return set; + } + static void commit_plus_eq(NodeType *set) + { + precommit_node(set->unode.opr.op[1]); +#ifdef VERBOSE + printf("add %s %s\n", set->unode.opr.op[0]->str, set->unode.opr.op[1]->str); +#endif + currentGoomSL->instr = gsl_instr_init(currentGoomSL, "add", INSTR_ADD, 2, set->line_number); + commit_node(set->unode.opr.op[0],0); + commit_node(set->unode.opr.op[1],1); + } /* }}} */ + + /* SUB_EQ */ + static NodeType *new_sub_eq(NodeType *lvalue, NodeType *expression) /* {{{ */ + { + NodeType *set = new_op("sub_eq", OPR_SUB_EQ, 2); + set->unode.opr.op[0] = lvalue; + set->unode.opr.op[1] = expression; + return set; + } + static void commit_sub_eq(NodeType *set) + { + precommit_node(set->unode.opr.op[1]); +#ifdef VERBOSE + printf("sub %s %s\n", set->unode.opr.op[0]->str, set->unode.opr.op[1]->str); +#endif + currentGoomSL->instr = gsl_instr_init(currentGoomSL, "sub", INSTR_SUB, 2, set->line_number); + commit_node(set->unode.opr.op[0],0); + commit_node(set->unode.opr.op[1],1); + } /* }}} */ + + /* MUL_EQ */ + static NodeType *new_mul_eq(NodeType *lvalue, NodeType *expression) /* {{{ */ + { + NodeType *set = new_op("mul_eq", OPR_MUL_EQ, 2); + set->unode.opr.op[0] = lvalue; + set->unode.opr.op[1] = expression; + return set; + } + static void commit_mul_eq(NodeType *set) + { + precommit_node(set->unode.opr.op[1]); +#ifdef VERBOSE + printf("mul %s %s\n", set->unode.opr.op[0]->str, set->unode.opr.op[1]->str); +#endif + currentGoomSL->instr = gsl_instr_init(currentGoomSL, "mul", INSTR_MUL, 2, set->line_number); + commit_node(set->unode.opr.op[0],0); + commit_node(set->unode.opr.op[1],1); + } /* }}} */ + + /* DIV_EQ */ + static NodeType *new_div_eq(NodeType *lvalue, NodeType *expression) /* {{{ */ + { + NodeType *set = new_op("div_eq", OPR_DIV_EQ, 2); + set->unode.opr.op[0] = lvalue; + set->unode.opr.op[1] = expression; + return set; + } + static void commit_div_eq(NodeType *set) + { + precommit_node(set->unode.opr.op[1]); +#ifdef VERBOSE + printf("div %s %s\n", set->unode.opr.op[0]->str, set->unode.opr.op[1]->str); +#endif + currentGoomSL->instr = gsl_instr_init(currentGoomSL, "div", INSTR_DIV, 2, set->line_number); + commit_node(set->unode.opr.op[0],0); + commit_node(set->unode.opr.op[1],1); + } /* }}} */ + + /* commodity method for add, mult, ... */ + + static void precommit_expr(NodeType *expr, const char *type, int instr_id) + { /* {{{ */ + NodeType *tmp, *tmpcpy; + int toAdd; + + /* compute "left" and "right" */ + switch (expr->unode.opr.nbOp) { + case 2: + precommit_node(expr->unode.opr.op[1]); + case 1: + precommit_node(expr->unode.opr.op[0]); + } + + if (is_tmp_expr(expr->unode.opr.op[0])) { + tmp = expr->unode.opr.op[0]; + toAdd = 1; + } + else if (is_commutative_expr(instr_id) && (expr->unode.opr.nbOp==2) && is_tmp_expr(expr->unode.opr.op[1])) { + tmp = expr->unode.opr.op[1]; + toAdd = 0; + } + else { + char stmp[256]; + /* declare a temporary variable to store the result */ + if (expr->unode.opr.op[0]->type == CONST_INT_NODE) { + sprintf(stmp,"_i_tmp_%i",allocateTemp()); + gsl_int_decl_global(stmp); + } + else if (expr->unode.opr.op[0]->type == CONST_FLOAT_NODE) { + sprintf(stmp,"_f_tmp%i",allocateTemp()); + gsl_float_decl_global(stmp); + } + else if (expr->unode.opr.op[0]->type == CONST_PTR_NODE) { + sprintf(stmp,"_p_tmp%i",allocateTemp()); + gsl_ptr_decl_global(stmp); + } + else { + int type = gsl_type_of_var(expr->unode.opr.op[0]->vnamespace, expr->unode.opr.op[0]->str); + if (type == INSTR_FLOAT) { + sprintf(stmp,"_f_tmp_%i",allocateTemp()); + gsl_float_decl_global(stmp); + } + else if (type == INSTR_PTR) { + sprintf(stmp,"_p_tmp_%i",allocateTemp()); + gsl_ptr_decl_global(stmp); + } + else if (type == INSTR_INT) { + sprintf(stmp,"_i_tmp_%i",allocateTemp()); + gsl_int_decl_global(stmp); + } + else if (type == -1) { + fprintf(stderr, "ERROR: Line %d, Could not find variable '%s'\n", + expr->line_number, expr->unode.opr.op[0]->str); + exit(1); + } + else { /* type is a struct_id */ + sprintf(stmp,"_s_tmp_%i",allocateTemp()); + gsl_struct_decl_global_from_id(stmp,type); + } + } + tmp = new_var(stmp,expr->line_number); + + /* set the tmp to the value of "op1" */ + tmpcpy = nodeClone(tmp); + commit_node(new_set(tmp,expr->unode.opr.op[0]),0); + toAdd = 1; + + tmp = tmpcpy; + } + + /* add op2 to tmp */ +#ifdef VERBOSE + if (expr->unode.opr.nbOp == 2) + printf("%s %s %s\n", type, tmp->str, expr->unode.opr.op[toAdd]->str); + else + printf("%s %s\n", type, tmp->str); +#endif + currentGoomSL->instr = gsl_instr_init(currentGoomSL, type, instr_id, expr->unode.opr.nbOp, expr->line_number); + tmpcpy = nodeClone(tmp); + commit_node(tmp,0); + if (expr->unode.opr.nbOp == 2) { + commit_node(expr->unode.opr.op[toAdd],1); + } + + /* redefine the ADD node now as the computed variable */ + nodeFreeInternals(expr); + *expr = *tmpcpy; + free(tmpcpy); + } /* }}} */ + + static NodeType *new_expr1(const char *name, int id, NodeType *expr1) + { /* {{{ */ + NodeType *add = new_op(name, id, 1); + add->unode.opr.op[0] = expr1; + return add; + } /* }}} */ + + static NodeType *new_expr2(const char *name, int id, NodeType *expr1, NodeType *expr2) + { /* {{{ */ + NodeType *add = new_op(name, id, 2); + add->unode.opr.op[0] = expr1; + add->unode.opr.op[1] = expr2; + return add; + } /* }}} */ + + /* ADD */ + static NodeType *new_add(NodeType *expr1, NodeType *expr2) { /* {{{ */ + return new_expr2("add", OPR_ADD, expr1, expr2); + } + static void precommit_add(NodeType *add) { + precommit_expr(add,"add",INSTR_ADD); + } /* }}} */ + + /* SUB */ + static NodeType *new_sub(NodeType *expr1, NodeType *expr2) { /* {{{ */ + return new_expr2("sub", OPR_SUB, expr1, expr2); + } + static void precommit_sub(NodeType *sub) { + precommit_expr(sub,"sub",INSTR_SUB); + } /* }}} */ + + /* NEG */ + static NodeType *new_neg(NodeType *expr) { /* {{{ */ + NodeType *zeroConst = NULL; + if (expr->type == CONST_INT_NODE) + zeroConst = new_constInt("0", currentGoomSL->num_lines); + else if (expr->type == CONST_FLOAT_NODE) + zeroConst = new_constFloat("0.0", currentGoomSL->num_lines); + else if (expr->type == CONST_PTR_NODE) { + fprintf(stderr, "ERROR: Line %d, Could not negate const pointer.\n", + currentGoomSL->num_lines); + exit(1); + } + else { + int type = gsl_type_of_var(expr->vnamespace, expr->str); + if (type == INSTR_FLOAT) + zeroConst = new_constFloat("0.0", currentGoomSL->num_lines); + else if (type == INSTR_PTR) { + fprintf(stderr, "ERROR: Line %d, Could not negate pointer.\n", + currentGoomSL->num_lines); + exit(1); + } + else if (type == INSTR_INT) + zeroConst = new_constInt("0", currentGoomSL->num_lines); + else if (type == -1) { + fprintf(stderr, "ERROR: Line %d, Could not find variable '%s'\n", + expr->line_number, expr->unode.opr.op[0]->str); + exit(1); + } + else { /* type is a struct_id */ + fprintf(stderr, "ERROR: Line %d, Could not negate struct '%s'\n", + expr->line_number, expr->str); + exit(1); + } + } + return new_expr2("sub", OPR_SUB, zeroConst, expr); + } + /* }}} */ + + /* MUL */ + static NodeType *new_mul(NodeType *expr1, NodeType *expr2) { /* {{{ */ + return new_expr2("mul", OPR_MUL, expr1, expr2); + } + static void precommit_mul(NodeType *mul) { + precommit_expr(mul,"mul",INSTR_MUL); + } /* }}} */ + + /* DIV */ + static NodeType *new_div(NodeType *expr1, NodeType *expr2) { /* {{{ */ + return new_expr2("div", OPR_DIV, expr1, expr2); + } + static void precommit_div(NodeType *mul) { + precommit_expr(mul,"div",INSTR_DIV); + } /* }}} */ + + /* CALL EXPRESSION */ + static NodeType *new_call_expr(const char *name, NodeType *affect_list) { /* {{{ */ + NodeType *call = new_call(name,affect_list); + NodeType *node = new_expr1(name, OPR_CALL_EXPR, call); + node->vnamespace = gsl_find_namespace(name); + if (node->vnamespace == NULL) + fprintf(stderr, "ERROR: Line %d, No return type for: '%s'\n", currentGoomSL->num_lines, name); + return node; + } + static void precommit_call_expr(NodeType *call) { + char stmp[256]; + NodeType *tmp,*tmpcpy; + int type = gsl_type_of_var(call->vnamespace, call->str); + if (type == INSTR_FLOAT) { + sprintf(stmp,"_f_tmp_%i",allocateTemp()); + gsl_float_decl_global(stmp); + } + else if (type == INSTR_PTR) { + sprintf(stmp,"_p_tmp_%i",allocateTemp()); + gsl_ptr_decl_global(stmp); + } + else if (type == INSTR_INT) { + sprintf(stmp,"_i_tmp_%i",allocateTemp()); + gsl_int_decl_global(stmp); + } + else if (type == -1) { + fprintf(stderr, "ERROR: Line %d, Could not find variable '%s'\n", + call->line_number, call->str); + exit(1); + } + else { /* type is a struct_id */ + sprintf(stmp,"_s_tmp_%i",allocateTemp()); + gsl_struct_decl_global_from_id(stmp,type); + } + tmp = new_var(stmp,call->line_number); + commit_node(call->unode.opr.op[0],0); + tmpcpy = nodeClone(tmp); + commit_node(new_set(tmp,new_var(call->str,call->line_number)),0); + + nodeFreeInternals(call); + *call = *tmpcpy; + free(tmpcpy); + } /* }}} */ + + static void commit_test2(NodeType *set,const char *type, int instr) + { /* {{{ */ + NodeType *tmp; + char stmp[256]; + precommit_node(set->unode.opr.op[0]); + precommit_node(set->unode.opr.op[1]); + tmp = set->unode.opr.op[0]; + + stmp[0] = 0; + if (set->unode.opr.op[0]->type == CONST_INT_NODE) { + sprintf(stmp,"_i_tmp_%i",allocateTemp()); + gsl_int_decl_global(stmp); + } + else if (set->unode.opr.op[0]->type == CONST_FLOAT_NODE) { + sprintf(stmp,"_f_tmp%i",allocateTemp()); + gsl_float_decl_global(stmp); + } + else if (set->unode.opr.op[0]->type == CONST_PTR_NODE) { + sprintf(stmp,"_p_tmp%i",allocateTemp()); + gsl_ptr_decl_global(stmp); + } + if (stmp[0]) { + NodeType *tmpcpy; + tmp = new_var(stmp, set->line_number); + tmpcpy = nodeClone(tmp); + commit_node(new_set(tmp,set->unode.opr.op[0]),0); + tmp = tmpcpy; + } + +#ifdef VERBOSE + printf("%s %s %s\n", type, tmp->str, set->unode.opr.op[1]->str); +#endif + currentGoomSL->instr = gsl_instr_init(currentGoomSL, type, instr, 2, set->line_number); + commit_node(tmp,instr!=INSTR_SET); + commit_node(set->unode.opr.op[1],1); + } /* }}} */ + + /* NOT */ + static NodeType *new_not(NodeType *expr1) { /* {{{ */ + return new_expr1("not", OPR_NOT, expr1); + } + static void commit_not(NodeType *set) + { + commit_node(set->unode.opr.op[0],0); +#ifdef VERBOSE + printf("not\n"); +#endif + currentGoomSL->instr = gsl_instr_init(currentGoomSL, "not", INSTR_NOT, 1, set->line_number); + gsl_instr_add_param(currentGoomSL->instr, "|dummy|", TYPE_LABEL); + } /* }}} */ + + /* EQU */ + static NodeType *new_equ(NodeType *expr1, NodeType *expr2) { /* {{{ */ + return new_expr2("isequal", OPR_EQU, expr1, expr2); + } + static void commit_equ(NodeType *mul) { + commit_test2(mul,"isequal",INSTR_ISEQUAL); + } /* }}} */ + + /* INF */ + static NodeType *new_low(NodeType *expr1, NodeType *expr2) { /* {{{ */ + return new_expr2("islower", OPR_LOW, expr1, expr2); + } + static void commit_low(NodeType *mul) { + commit_test2(mul,"islower",INSTR_ISLOWER); + } /* }}} */ + + /* WHILE */ + static NodeType *new_while(NodeType *expression, NodeType *instr) { /* {{{ */ + NodeType *node = new_op("while", OPR_WHILE, 2); + node->unode.opr.op[0] = expression; + node->unode.opr.op[1] = instr; + return node; + } + + static void commit_while(NodeType *node) + { + int lbl = allocateLabel(); + char start_while[1024], test_while[1024]; + sprintf(start_while, "|start_while_%d|", lbl); + sprintf(test_while, "|test_while_%d|", lbl); + + GSL_PUT_JUMP(test_while,node->line_number); + GSL_PUT_LABEL(start_while,node->line_number); + + /* code */ + commit_node(node->unode.opr.op[1],0); + + GSL_PUT_LABEL(test_while,node->line_number); + commit_node(node->unode.opr.op[0],0); + GSL_PUT_JNZERO(start_while,node->line_number); + } /* }}} */ + + /* FOR EACH */ + static NodeType *new_static_foreach(NodeType *var, NodeType *var_list, NodeType *instr) { /* {{{ */ + NodeType *node = new_op("for", OPR_FOREACH, 3); + node->unode.opr.op[0] = var; + node->unode.opr.op[1] = var_list; + node->unode.opr.op[2] = instr; + node->line_number = currentGoomSL->num_lines; + return node; + } + static void commit_foreach(NodeType *node) + { + NodeType *cur = node->unode.opr.op[1]; + char tmp_func[256], tmp_loop[256]; + int lbl = allocateLabel(); + sprintf(tmp_func, "|foreach_func_%d|", lbl); + sprintf(tmp_loop, "|foreach_loop_%d|", lbl); + + GSL_PUT_JUMP(tmp_loop, node->line_number); + GSL_PUT_LABEL(tmp_func, node->line_number); + + precommit_node(node->unode.opr.op[2]); + commit_node(node->unode.opr.op[2], 0); + + currentGoomSL->instr = gsl_instr_init(currentGoomSL, "ret", INSTR_RET, 1, node->line_number); + gsl_instr_add_param(currentGoomSL->instr, "|dummy|", TYPE_LABEL); +#ifdef VERBOSE + printf("ret\n"); +#endif + + GSL_PUT_LABEL(tmp_loop, node->line_number); + + while (cur != NULL) + { + NodeType *x, *var; + + /* 1: x=var */ + x = nodeClone(node->unode.opr.op[0]); + var = nodeClone(cur->unode.opr.op[0]); + commit_node(new_set(x, var),0); + + /* 2: instr */ + currentGoomSL->instr = gsl_instr_init(currentGoomSL, "call", INSTR_CALL, 1, node->line_number); + gsl_instr_add_param(currentGoomSL->instr, tmp_func, TYPE_LABEL); +#ifdef VERBOSE + printf("call %s\n", tmp_func); +#endif + + /* 3: var=x */ + x = nodeClone(node->unode.opr.op[0]); + var = cur->unode.opr.op[0]; + commit_node(new_set(var, x),0); + cur = cur->unode.opr.op[1]; + } + nodeFree(node->unode.opr.op[0]); + } /* }}} */ + + /* IF */ + static NodeType *new_if(NodeType *expression, NodeType *instr) { /* {{{ */ + NodeType *node = new_op("if", OPR_IF, 2); + node->unode.opr.op[0] = expression; + node->unode.opr.op[1] = instr; + return node; + } + static void commit_if(NodeType *node) { + + char slab[1024]; + sprintf(slab, "|eif%d|", allocateLabel()); + commit_node(node->unode.opr.op[0],0); + GSL_PUT_JZERO(slab,node->line_number); + /* code */ + commit_node(node->unode.opr.op[1],0); + GSL_PUT_LABEL(slab,node->line_number); + } /* }}} */ + + /* BLOCK */ + static NodeType *new_block(NodeType *lastNode) { /* {{{ */ + NodeType *blk = new_op("block", OPR_BLOCK, 2); + blk->unode.opr.op[0] = new_nop("start_of_block"); + blk->unode.opr.op[1] = lastNode; + return blk; + } + static void commit_block(NodeType *node) { + commit_node(node->unode.opr.op[0]->unode.opr.next,0); + } /* }}} */ + + /* FUNCTION INTRO */ + static NodeType *new_function_intro(const char *name) { /* {{{ */ + char stmp[256]; + if (strlen(name) < 200) { + sprintf(stmp, "|__func_%s|", name); + } + return new_op(stmp, OPR_FUNC_INTRO, 0); + } + static void commit_function_intro(NodeType *node) { + currentGoomSL->instr = gsl_instr_init(currentGoomSL, "label", INSTR_LABEL, 1, node->line_number); + gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_LABEL); +#ifdef VERBOSE + printf("label %s\n", node->str); +#endif + } /* }}} */ + + /* FUNCTION OUTRO */ + static NodeType *new_function_outro() { /* {{{ */ + return new_op("ret", OPR_FUNC_OUTRO, 0); + } + static void commit_function_outro(NodeType *node) { + currentGoomSL->instr = gsl_instr_init(currentGoomSL, "ret", INSTR_RET, 1, node->line_number); + gsl_instr_add_param(currentGoomSL->instr, "|dummy|", TYPE_LABEL); + releaseAllTemps(); +#ifdef VERBOSE + printf("ret\n"); +#endif + } /* }}} */ + + /* AFFECTATION LIST */ + static NodeType *new_affec_list(NodeType *set, NodeType *next) /* {{{ */ + { + NodeType *node = new_op("affect_list", OPR_AFFECT_LIST, 2); + node->unode.opr.op[0] = set; + node->unode.opr.op[1] = next; + return node; + } + static NodeType *new_affect_list_after(NodeType *affect_list) + { + NodeType *ret = NULL; + NodeType *cur = affect_list; + while(cur != NULL) { + NodeType *set = cur->unode.opr.op[0]; + NodeType *next = cur->unode.opr.op[1]; + NodeType *lvalue = set->unode.opr.op[0]; + NodeType *expression = set->unode.opr.op[1]; + if ((lvalue->str[0] == '&') && (expression->type == VAR_NODE)) { + NodeType *nset = new_set(nodeClone(expression), nodeClone(lvalue)); + ret = new_affec_list(nset, ret); + } + cur = next; + } + return ret; + } + static void commit_affect_list(NodeType *node) + { + NodeType *cur = node; + while(cur != NULL) { + NodeType *set = cur->unode.opr.op[0]; + precommit_node(set->unode.opr.op[0]); + precommit_node(set->unode.opr.op[1]); + cur = cur->unode.opr.op[1]; + } + cur = node; + while(cur != NULL) { + NodeType *set = cur->unode.opr.op[0]; + commit_node(set,0); + cur = cur->unode.opr.op[1]; + } + } /* }}} */ + + /* VAR LIST */ + static NodeType *new_var_list(NodeType *var, NodeType *next) /* {{{ */ + { + NodeType *node = new_op("var_list", OPR_VAR_LIST, 2); + node->unode.opr.op[0] = var; + node->unode.opr.op[1] = next; + return node; + } + static void commit_var_list(NodeType *node) + { + } /* }}} */ + + /* FUNCTION CALL */ + static NodeType *new_call(const char *name, NodeType *affect_list) { /* {{{ */ + HashValue *fval; + fval = goom_hash_get(currentGoomSL->functions, name); + if (!fval) { + gsl_declare_task(name); + fval = goom_hash_get(currentGoomSL->functions, name); + } + if (!fval) { + fprintf(stderr, "ERROR: Line %d, Could not find function %s\n", currentGoomSL->num_lines, name); + exit(1); + return NULL; + } + else { + ExternalFunctionStruct *gef = (ExternalFunctionStruct*)fval->ptr; + if (gef->is_extern) { + NodeType *node = new_op(name, OPR_EXT_CALL, 1); + node->unode.opr.op[0] = affect_list; + return node; + } + else { + NodeType *node; + char stmp[256]; + if (strlen(name) < 200) { + sprintf(stmp, "|__func_%s|", name); + } + node = new_op(stmp, OPR_CALL, 1); + node->unode.opr.op[0] = affect_list; + return node; + } + } + } + static void commit_ext_call(NodeType *node) { + NodeType *alafter = new_affect_list_after(node->unode.opr.op[0]); + commit_node(node->unode.opr.op[0],0); + currentGoomSL->instr = gsl_instr_init(currentGoomSL, "extcall", INSTR_EXT_CALL, 1, node->line_number); + gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_VAR); +#ifdef VERBOSE + printf("extcall %s\n", node->str); +#endif + commit_node(alafter,0); + } + static void commit_call(NodeType *node) { + NodeType *alafter = new_affect_list_after(node->unode.opr.op[0]); + commit_node(node->unode.opr.op[0],0); + currentGoomSL->instr = gsl_instr_init(currentGoomSL, "call", INSTR_CALL, 1, node->line_number); + gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_LABEL); +#ifdef VERBOSE + printf("call %s\n", node->str); +#endif + commit_node(alafter,0); + } /* }}} */ + + /** **/ + + static NodeType *rootNode = 0; /* TODO: reinitialiser a chaque compilation. */ + static NodeType *lastNode = 0; + static NodeType *gsl_append(NodeType *curNode) { + if (curNode == 0) return 0; /* {{{ */ + if (lastNode) + lastNode->unode.opr.next = curNode; + lastNode = curNode; + while(lastNode->unode.opr.next) lastNode = lastNode->unode.opr.next; + if (rootNode == 0) + rootNode = curNode; + return curNode; + } /* }}} */ + +#if 1 + int allocateTemp() { + return allocateLabel(); + } + void releaseAllTemps() {} + void releaseTemp(int n) {} +#else + static int nbTemp = 0; + static int *tempArray = 0; + static int tempArraySize = 0; + int allocateTemp() { /* TODO: allocateITemp, allocateFTemp */ + int i = 0; /* {{{ */ + if (tempArray == 0) { + tempArraySize = 256; + tempArray = (int*)malloc(tempArraySize * sizeof(int)); + } + while (1) { + int j; + for (j=0;jtype == OPR_NODE) + switch(node->unode.opr.type) { + case OPR_ADD: precommit_add(node); break; + case OPR_SUB: precommit_sub(node); break; + case OPR_MUL: precommit_mul(node); break; + case OPR_DIV: precommit_div(node); break; + case OPR_CALL_EXPR: precommit_call_expr(node); break; + } + } /* }}} */ + + void commit_node(NodeType *node, int releaseIfTmp) + { /* {{{ */ + if (node == 0) return; + + switch(node->type) { + case OPR_NODE: + switch(node->unode.opr.type) { + case OPR_SET: commit_set(node); break; + case OPR_PLUS_EQ: commit_plus_eq(node); break; + case OPR_SUB_EQ: commit_sub_eq(node); break; + case OPR_MUL_EQ: commit_mul_eq(node); break; + case OPR_DIV_EQ: commit_div_eq(node); break; + case OPR_IF: commit_if(node); break; + case OPR_WHILE: commit_while(node); break; + case OPR_BLOCK: commit_block(node); break; + case OPR_FUNC_INTRO: commit_function_intro(node); break; + case OPR_FUNC_OUTRO: commit_function_outro(node); break; + case OPR_CALL: commit_call(node); break; + case OPR_EXT_CALL: commit_ext_call(node); break; + case OPR_EQU: commit_equ(node); break; + case OPR_LOW: commit_low(node); break; + case OPR_NOT: commit_not(node); break; + case OPR_AFFECT_LIST: commit_affect_list(node); break; + case OPR_FOREACH: commit_foreach(node); break; + case OPR_VAR_LIST: commit_var_list(node); break; +#ifdef VERBOSE + case EMPTY_NODE: printf("NOP\n"); break; +#endif + } + + commit_node(node->unode.opr.next,0); /* recursive for the moment, maybe better to do something iterative? */ + break; + + case VAR_NODE: gsl_instr_set_namespace(currentGoomSL->instr, node->vnamespace); + gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_VAR); break; + case CONST_INT_NODE: gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_INTEGER); break; + case CONST_FLOAT_NODE: gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_FLOAT); break; + case CONST_PTR_NODE: gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_PTR); break; + } + if (releaseIfTmp && is_tmp_expr(node)) + releaseTemp(get_tmp_id(node)); + + nodeFree(node); + } /* }}} */ + + NodeType *nodeNew(const char *str, int type, int line_number) { + NodeType *node = (NodeType*)malloc(sizeof(NodeType)); /* {{{ */ + node->type = type; + node->str = (char*)malloc(strlen(str)+1); + node->vnamespace = NULL; + node->line_number = line_number; + strcpy(node->str, str); + return node; + } /* }}} */ + static NodeType *nodeClone(NodeType *node) { + NodeType *ret = nodeNew(node->str, node->type, node->line_number); /* {{{ */ + ret->vnamespace = node->vnamespace; + ret->unode = node->unode; + return ret; + } /* }}} */ + + void nodeFreeInternals(NodeType *node) { + free(node->str); /* {{{ */ + } /* }}} */ + + void nodeFree(NodeType *node) { + nodeFreeInternals(node); /* {{{ */ + free(node); + } /* }}} */ + + NodeType *new_constInt(const char *str, int line_number) { + NodeType *node = nodeNew(str, CONST_INT_NODE, line_number); /* {{{ */ + node->unode.constInt.val = atoi(str); + return node; + } /* }}} */ + + NodeType *new_constPtr(const char *str, int line_number) { + NodeType *node = nodeNew(str, CONST_PTR_NODE, line_number); /* {{{ */ + node->unode.constPtr.id = strtol(str,NULL,0); + return node; + } /* }}} */ + + NodeType *new_constFloat(const char *str, int line_number) { + NodeType *node = nodeNew(str, CONST_FLOAT_NODE, line_number); /* {{{ */ + node->unode.constFloat.val = atof(str); + return node; + } /* }}} */ + + NodeType *new_var(const char *str, int line_number) { + NodeType *node = nodeNew(str, VAR_NODE, line_number); /* {{{ */ + node->vnamespace = gsl_find_namespace(str); + if (node->vnamespace == 0) { + fprintf(stderr, "ERROR: Line %d, Variable not found: '%s'\n", line_number, str); + exit(1); + } + return node; + } /* }}} */ + + NodeType *new_nop(const char *str) { + NodeType *node = new_op(str, EMPTY_NODE, 0); /* {{{ */ + return node; + } /* }}} */ + + NodeType *new_op(const char *str, int type, int nbOp) { + int i; /* {{{ */ + NodeType *node = nodeNew(str, OPR_NODE, currentGoomSL->num_lines); + node->unode.opr.next = 0; + node->unode.opr.type = type; + node->unode.opr.nbOp = nbOp; + for (i=0;iunode.opr.op[i] = 0; + return node; + } /* }}} */ + + + void gsl_declare_global_variable(int type, char *name) { + switch(type){ + case -1: break; + case FLOAT_TK:gsl_float_decl_global(name);break; + case INT_TK: gsl_int_decl_global(name);break; + case PTR_TK: gsl_ptr_decl_global(name);break; + default: + { + int id = type - 1000; + gsl_struct_decl_global_from_id(name,id); + } + } + } + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +#line 1199 "goomsl_yacc.y" +typedef union YYSTYPE { + int intValue; + float floatValue; + char charValue; + char strValue[2048]; + NodeType *nPtr; + GoomHash *namespace; + GSL_Struct *gsl_struct; + GSL_StructField *gsl_struct_field; + } YYSTYPE; +/* Line 191 of yacc.c. */ +#line 1327 "goomsl_yacc.c" +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 214 of yacc.c. */ +#line 1339 "goomsl_yacc.c" + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# else +# ifndef YYSTACK_USE_ALLOCA +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC malloc +# define YYSTACK_FREE free +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 3 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 229 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 30 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 89 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 217 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 279 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 25, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 35, 36, 32, 29, 34, 30, 2, 31, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 33, 2, + 27, 26, 28, 37, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 40, 2, 41, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 38, 2, 39, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned short yyprhs[] = +{ + 0, 0, 3, 7, 10, 19, 30, 39, 50, 53, + 56, 57, 65, 68, 73, 76, 79, 82, 85, 87, + 89, 90, 93, 96, 99, 102, 104, 108, 111, 112, + 116, 122, 130, 131, 132, 137, 142, 147, 152, 154, + 157, 160, 163, 166, 169, 172, 179, 186, 193, 195, + 199, 203, 207, 211, 218, 222, 224, 227, 231, 232, + 234, 236, 240, 244, 248, 252, 255, 259, 261, 265, + 269, 273, 277, 281, 285, 288, 290, 292, 294, 298, + 304, 310, 318, 323, 330, 333, 335, 340, 344, 346 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 43, 0, -1, 44, 55, 52, -1, 44, 59, -1, + 44, 11, 27, 48, 28, 50, 25, 56, -1, 44, + 11, 27, 48, 33, 51, 28, 50, 25, 56, -1, + 44, 10, 27, 49, 28, 50, 25, 56, -1, 44, + 10, 27, 49, 33, 51, 28, 50, 25, 56, -1, + 44, 45, -1, 44, 25, -1, -1, 22, 27, 5, + 33, 46, 28, 25, -1, 71, 47, -1, 46, 34, + 71, 47, -1, 8, 5, -1, 9, 5, -1, 7, + 5, -1, 5, 5, -1, 5, -1, 5, -1, -1, + 33, 8, -1, 33, 9, -1, 33, 7, -1, 33, + 5, -1, 58, -1, 58, 34, 51, -1, 52, 53, + -1, -1, 54, 44, 55, -1, 27, 49, 28, 50, + 25, -1, 27, 49, 33, 51, 28, 50, 25, -1, + -1, -1, 9, 5, 26, 64, -1, 8, 5, 26, + 64, -1, 7, 5, 26, 64, -1, 5, 5, 26, + 64, -1, 58, -1, 9, 5, -1, 8, 5, -1, + 7, 5, -1, 5, 5, -1, 62, 25, -1, 57, + 25, -1, 35, 65, 36, 37, 71, 59, -1, 12, + 65, 71, 13, 71, 59, -1, 38, 25, 63, 44, + 39, 25, -1, 67, -1, 5, 15, 64, -1, 5, + 16, 64, -1, 5, 18, 64, -1, 5, 17, 64, + -1, 23, 5, 24, 60, 13, 59, -1, 35, 61, + 36, -1, 5, -1, 5, 61, -1, 5, 26, 64, + -1, -1, 5, -1, 66, -1, 64, 32, 64, -1, + 64, 31, 64, -1, 64, 29, 64, -1, 64, 30, + 64, -1, 30, 64, -1, 35, 64, 36, -1, 68, + -1, 64, 26, 64, -1, 64, 27, 64, -1, 64, + 28, 64, -1, 64, 19, 64, -1, 64, 20, 64, + -1, 64, 21, 64, -1, 14, 65, -1, 4, -1, + 3, -1, 6, -1, 49, 25, 56, -1, 49, 33, + 69, 25, 56, -1, 40, 49, 41, 25, 56, -1, + 40, 49, 33, 69, 41, 25, 56, -1, 40, 49, + 56, 41, -1, 40, 49, 33, 69, 41, 56, -1, + 70, 69, -1, 70, -1, 5, 26, 56, 64, -1, + 33, 56, 64, -1, 25, -1, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned short yyrline[] = +{ + 0, 1236, 1236, 1238, 1239, 1240, 1241, 1242, 1243, 1244, + 1245, 1250, 1253, 1254, 1257, 1258, 1259, 1260, 1265, 1267, + 1270, 1271, 1272, 1273, 1274, 1277, 1278, 1283, 1284, 1287, + 1289, 1291, 1294, 1296, 1300, 1301, 1302, 1303, 1304, 1307, + 1308, 1309, 1310, 1315, 1316, 1317, 1318, 1319, 1320, 1321, + 1322, 1323, 1324, 1325, 1328, 1330, 1331, 1334, 1336, 1339, + 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1350, 1351, + 1352, 1353, 1354, 1355, 1356, 1359, 1360, 1361, 1366, 1367, + 1368, 1369, 1373, 1374, 1377, 1378, 1380, 1384, 1393, 1393 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "LTYPE_INTEGER", "LTYPE_FLOAT", + "LTYPE_VAR", "LTYPE_PTR", "PTR_TK", "INT_TK", "FLOAT_TK", "DECLARE", + "EXTERNAL", "WHILE", "DO", "NOT", "PLUS_EQ", "SUB_EQ", "DIV_EQ", + "MUL_EQ", "SUP_EQ", "LOW_EQ", "NOT_EQ", "STRUCT", "FOR", "IN", "'\\n'", + "'='", "'<'", "'>'", "'+'", "'-'", "'/'", "'*'", "':'", "','", "'('", + "')'", "'?'", "'{'", "'}'", "'['", "']'", "$accept", "gsl", "gsl_code", + "struct_declaration", "struct_members", "struct_member", + "ext_task_name", "task_name", "return_type", "arglist", + "gsl_def_functions", "function", "function_intro", "function_outro", + "leave_namespace", "declaration", "empty_declaration", "instruction", + "var_list", "var_list_content", "affectation", "start_block", + "expression", "test", "constValue", "func_call", "func_call_expression", + "affectation_list", "affectation_in_list", "opt_nl", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 10, 61, 60, 62, 43, + 45, 47, 42, 58, 44, 40, 41, 63, 123, 125, + 91, 93 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 44, 44, 44, 44, + 44, 45, 46, 46, 47, 47, 47, 47, 48, 49, + 50, 50, 50, 50, 50, 51, 51, 52, 52, 53, + 54, 54, 55, 56, 57, 57, 57, 57, 57, 58, + 58, 58, 58, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 60, 61, 61, 62, 63, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, + 65, 65, 65, 65, 65, 66, 66, 66, 67, 67, + 67, 67, 68, 68, 69, 69, 70, 70, 71, 71 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 3, 2, 8, 10, 8, 10, 2, 2, + 0, 7, 2, 4, 2, 2, 2, 2, 1, 1, + 0, 2, 2, 2, 2, 1, 3, 2, 0, 3, + 5, 7, 0, 0, 4, 4, 4, 4, 1, 2, + 2, 2, 2, 2, 2, 6, 6, 6, 1, 3, + 3, 3, 3, 6, 3, 1, 2, 3, 0, 1, + 1, 3, 3, 3, 3, 2, 3, 1, 3, 3, + 3, 3, 3, 3, 2, 1, 1, 1, 3, 5, + 5, 7, 4, 6, 2, 1, 4, 3, 1, 0 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 10, 0, 32, 1, 19, 0, 0, 0, 0, 0, + 0, 0, 0, 9, 0, 0, 0, 8, 0, 28, + 0, 38, 3, 0, 48, 42, 0, 0, 0, 0, + 0, 41, 40, 39, 0, 0, 76, 75, 59, 77, + 0, 0, 0, 0, 0, 89, 60, 67, 0, 0, + 0, 58, 19, 0, 33, 0, 2, 44, 43, 0, + 49, 50, 52, 51, 57, 0, 0, 0, 0, 18, + 0, 74, 65, 0, 33, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 88, 0, 0, 0, 0, + 10, 0, 0, 78, 0, 33, 0, 85, 0, 27, + 10, 37, 36, 35, 34, 20, 0, 20, 0, 66, + 0, 0, 71, 72, 73, 68, 69, 70, 63, 64, + 62, 61, 89, 89, 0, 0, 89, 0, 0, 33, + 33, 0, 33, 84, 0, 32, 0, 0, 0, 0, + 0, 0, 0, 25, 0, 0, 0, 82, 0, 0, + 0, 55, 0, 0, 0, 0, 0, 80, 0, 87, + 79, 20, 0, 29, 24, 23, 21, 22, 33, 42, + 41, 40, 39, 20, 0, 33, 20, 33, 46, 0, + 89, 0, 0, 0, 0, 12, 56, 54, 53, 45, + 47, 33, 86, 0, 0, 6, 0, 26, 4, 0, + 83, 11, 0, 17, 16, 14, 15, 81, 30, 20, + 33, 33, 13, 0, 7, 5, 31 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const short yydefgoto[] = +{ + -1, 1, 2, 17, 149, 185, 70, 18, 137, 142, + 56, 99, 100, 19, 93, 20, 21, 22, 125, 152, + 23, 90, 44, 45, 46, 24, 47, 96, 97, 86 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -116 +static const short yypact[] = +{ + -116, 40, 136, -116, 103, 39, 66, 68, 61, 65, + 1, 77, 101, -116, 1, 84, 109, -116, 12, -116, + 91, -116, -116, 97, -116, 98, 72, 72, 72, 72, + 72, 99, 104, 113, 109, 130, -116, -116, -116, -116, + 1, 72, 72, 109, 166, 115, -116, -116, 145, 131, + 118, -116, -116, -24, -116, -3, 138, -116, -116, 72, + 159, 159, 159, 159, 159, 72, 72, 72, 14, -116, + 51, -116, 22, 102, 124, 72, 72, 72, 72, 72, + 72, 72, 72, 72, 72, -116, 160, 139, 140, 141, + -116, -3, 152, -116, 154, -116, 156, -3, 109, -116, + -116, 159, 159, 159, 159, 150, 82, 150, 82, -116, + -3, 158, 159, 159, 159, 159, 159, 159, 22, 22, + -116, -116, 115, 115, 195, 188, 115, 88, 162, -116, + -116, 72, -116, -116, 52, 136, 155, 177, 199, 200, + 201, 202, 180, 175, 185, 183, 171, -116, 144, 18, + 161, 195, 178, 144, 144, 190, 191, -116, 72, 159, + -116, 150, 82, -116, -116, -116, -116, -116, -116, -116, + -116, -116, -116, 150, 82, -116, 150, -116, -116, 192, + 115, 208, 213, 214, 215, -116, -116, -116, -116, -116, + -116, -116, 159, 196, 194, -116, 198, -116, -116, 203, + -116, -116, 161, -116, -116, -116, -116, -116, -116, 150, + -116, -116, -116, 204, -116, -116, -116 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yysigned_char yypgoto[] = +{ + -116, -116, -68, -116, -116, 23, -116, -15, -104, -92, + -116, -116, -116, 89, -74, -116, -88, -115, -116, 75, + -116, -116, -16, -6, -116, -116, -116, -62, -116, -99 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const unsigned char yytable[] = +{ + 111, 53, 94, 144, 36, 37, 38, 39, 50, 91, + 60, 61, 62, 63, 64, 40, 145, 92, 143, 68, + 143, 131, 127, 148, 150, 72, 73, 154, 74, 128, + 95, 41, 135, 178, 71, 133, 42, 54, 188, 189, + 3, 43, 105, 101, 31, 55, 179, 106, 146, 102, + 103, 104, 180, 83, 84, 157, 158, 193, 160, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 196, + 194, 32, 199, 33, 143, 36, 37, 38, 39, 107, + 161, 202, 197, 134, 108, 162, 143, 138, 34, 139, + 140, 141, 35, 4, 195, 5, 6, 7, 8, 9, + 10, 198, 41, 200, 48, 213, 49, 42, 25, 51, + 11, 12, 43, 13, 52, 159, 57, 207, 26, 27, + 28, 29, 58, 14, 59, 65, 15, 155, 16, 30, + 66, 81, 82, 83, 84, 69, 214, 215, 109, 67, + 85, 4, 192, 5, 6, 7, 8, 9, 10, 4, + 87, 5, 6, 7, 89, 88, 10, 110, 11, 12, + 164, 13, 165, 166, 167, 98, 181, 12, 182, 183, + 184, 14, 123, 122, 15, 124, 16, 129, 126, 14, + 130, 132, 15, 136, 16, 75, 76, 77, 81, 82, + 83, 84, 78, 79, 80, 81, 82, 83, 84, 147, + 151, 153, 168, 156, 169, 170, 171, 172, 173, 174, + 175, 176, 177, 203, 187, 190, 191, 201, 204, 205, + 206, 208, 209, 210, 163, 212, 186, 0, 211, 216 +}; + +static const short yycheck[] = +{ + 74, 16, 5, 107, 3, 4, 5, 6, 14, 33, + 26, 27, 28, 29, 30, 14, 108, 41, 106, 34, + 108, 95, 90, 122, 123, 41, 42, 126, 43, 91, + 33, 30, 100, 148, 40, 97, 35, 25, 153, 154, + 0, 40, 28, 59, 5, 33, 28, 33, 110, 65, + 66, 67, 34, 31, 32, 129, 130, 161, 132, 75, + 76, 77, 78, 79, 80, 81, 82, 83, 84, 173, + 162, 5, 176, 5, 162, 3, 4, 5, 6, 28, + 28, 180, 174, 98, 33, 33, 174, 5, 27, 7, + 8, 9, 27, 5, 168, 7, 8, 9, 10, 11, + 12, 175, 30, 177, 27, 209, 5, 35, 5, 25, + 22, 23, 40, 25, 5, 131, 25, 191, 15, 16, + 17, 18, 25, 35, 26, 26, 38, 39, 40, 26, + 26, 29, 30, 31, 32, 5, 210, 211, 36, 26, + 25, 5, 158, 7, 8, 9, 10, 11, 12, 5, + 5, 7, 8, 9, 36, 24, 12, 33, 22, 23, + 5, 25, 7, 8, 9, 27, 5, 23, 7, 8, + 9, 35, 33, 13, 38, 35, 40, 25, 37, 35, + 26, 25, 38, 33, 40, 19, 20, 21, 29, 30, + 31, 32, 26, 27, 28, 29, 30, 31, 32, 41, + 5, 13, 25, 41, 5, 5, 5, 5, 28, 34, + 25, 28, 41, 5, 36, 25, 25, 25, 5, 5, + 5, 25, 28, 25, 135, 202, 151, -1, 25, 25 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 43, 44, 0, 5, 7, 8, 9, 10, 11, + 12, 22, 23, 25, 35, 38, 40, 45, 49, 55, + 57, 58, 59, 62, 67, 5, 15, 16, 17, 18, + 26, 5, 5, 5, 27, 27, 3, 4, 5, 6, + 14, 30, 35, 40, 64, 65, 66, 68, 27, 5, + 65, 25, 5, 49, 25, 33, 52, 25, 25, 26, + 64, 64, 64, 64, 64, 26, 26, 26, 49, 5, + 48, 65, 64, 64, 49, 19, 20, 21, 26, 27, + 28, 29, 30, 31, 32, 25, 71, 5, 24, 36, + 63, 33, 41, 56, 5, 33, 69, 70, 27, 53, + 54, 64, 64, 64, 64, 28, 33, 28, 33, 36, + 33, 56, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 13, 33, 35, 60, 37, 44, 69, 25, + 26, 56, 25, 69, 49, 44, 33, 50, 5, 7, + 8, 9, 51, 58, 50, 51, 69, 41, 71, 46, + 71, 5, 61, 13, 71, 39, 41, 56, 56, 64, + 56, 28, 33, 55, 5, 7, 8, 9, 25, 5, + 5, 5, 5, 28, 34, 25, 28, 41, 59, 28, + 34, 5, 7, 8, 9, 47, 61, 36, 59, 59, + 25, 25, 64, 50, 51, 56, 50, 51, 56, 50, + 56, 25, 71, 5, 5, 5, 5, 56, 25, 28, + 25, 25, 47, 50, 56, 56, 25 +}; + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + Current.first_line = Rhs[1].first_line; \ + Current.first_column = Rhs[1].first_column; \ + Current.last_line = Rhs[N].last_line; \ + Current.last_column = Rhs[N].last_column; +#endif + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YYDSYMPRINT(Args) \ +do { \ + if (yydebug) \ + yysymprint Args; \ +} while (0) + +# define YYDSYMPRINTF(Title, Token, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Token, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (cinluded). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short *bottom, short *top) +#else +static void +yy_stack_print (bottom, top) + short *bottom; + short *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylineno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylineno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YYDSYMPRINT(Args) +# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ + + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + { + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); +# ifdef YYPRINT + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + } + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yytype, yyvaluep) + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + + + +#define YYPOPSTACK (yyvsp--, yyssp--) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; + + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + yystate = yyn; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 3: +#line 1238 "goomsl_yacc.y" + { gsl_append(yyvsp[0].nPtr); } + break; + + case 4: +#line 1239 "goomsl_yacc.y" + { gsl_declare_global_variable(yyvsp[-2].intValue,yyvsp[-4].strValue); } + break; + + case 5: +#line 1240 "goomsl_yacc.y" + { gsl_declare_global_variable(yyvsp[-2].intValue,yyvsp[-6].strValue); } + break; + + case 6: +#line 1241 "goomsl_yacc.y" + { gsl_declare_global_variable(yyvsp[-2].intValue,yyvsp[-4].strValue); } + break; + + case 7: +#line 1242 "goomsl_yacc.y" + { gsl_declare_global_variable(yyvsp[-2].intValue,yyvsp[-6].strValue); } + break; + + case 11: +#line 1250 "goomsl_yacc.y" + { gsl_add_struct(yyvsp[-4].strValue, yyvsp[-2].gsl_struct); } + break; + + case 12: +#line 1253 "goomsl_yacc.y" + { yyval.gsl_struct = gsl_new_struct(yyvsp[0].gsl_struct_field); } + break; + + case 13: +#line 1254 "goomsl_yacc.y" + { yyval.gsl_struct = yyvsp[-3].gsl_struct; gsl_add_struct_field(yyvsp[-3].gsl_struct, yyvsp[0].gsl_struct_field); } + break; + + case 14: +#line 1257 "goomsl_yacc.y" + { yyval.gsl_struct_field = gsl_new_struct_field(yyvsp[0].strValue, INSTR_INT); } + break; + + case 15: +#line 1258 "goomsl_yacc.y" + { yyval.gsl_struct_field = gsl_new_struct_field(yyvsp[0].strValue, INSTR_FLOAT); } + break; + + case 16: +#line 1259 "goomsl_yacc.y" + { yyval.gsl_struct_field = gsl_new_struct_field(yyvsp[0].strValue, INSTR_PTR); } + break; + + case 17: +#line 1260 "goomsl_yacc.y" + { yyval.gsl_struct_field = gsl_new_struct_field_struct(yyvsp[0].strValue, yyvsp[-1].strValue); } + break; + + case 18: +#line 1265 "goomsl_yacc.y" + { gsl_declare_external_task(yyvsp[0].strValue); gsl_enternamespace(yyvsp[0].strValue); strcpy(yyval.strValue,yyvsp[0].strValue); } + break; + + case 19: +#line 1267 "goomsl_yacc.y" + { gsl_declare_task(yyvsp[0].strValue); gsl_enternamespace(yyvsp[0].strValue); strcpy(yyval.strValue,yyvsp[0].strValue); strcpy(yyval.strValue,yyvsp[0].strValue); } + break; + + case 20: +#line 1270 "goomsl_yacc.y" + { yyval.intValue=-1; } + break; + + case 21: +#line 1271 "goomsl_yacc.y" + { yyval.intValue=INT_TK; } + break; + + case 22: +#line 1272 "goomsl_yacc.y" + { yyval.intValue=FLOAT_TK; } + break; + + case 23: +#line 1273 "goomsl_yacc.y" + { yyval.intValue=PTR_TK; } + break; + + case 24: +#line 1274 "goomsl_yacc.y" + { yyval.intValue= 1000 + gsl_get_struct_id(yyvsp[0].strValue); } + break; + + case 29: +#line 1287 "goomsl_yacc.y" + { gsl_leavenamespace(); } + break; + + case 30: +#line 1289 "goomsl_yacc.y" + { gsl_append(new_function_intro(yyvsp[-3].strValue)); + gsl_declare_global_variable(yyvsp[-1].intValue,yyvsp[-3].strValue); } + break; + + case 31: +#line 1291 "goomsl_yacc.y" + { gsl_append(new_function_intro(yyvsp[-5].strValue)); + gsl_declare_global_variable(yyvsp[-1].intValue,yyvsp[-5].strValue); } + break; + + case 32: +#line 1294 "goomsl_yacc.y" + { gsl_append(new_function_outro()); } + break; + + case 33: +#line 1296 "goomsl_yacc.y" + { yyval.namespace = gsl_leavenamespace(); } + break; + + case 34: +#line 1300 "goomsl_yacc.y" + { gsl_float_decl_local(yyvsp[-2].strValue); yyval.nPtr = new_set(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines), yyvsp[0].nPtr); } + break; + + case 35: +#line 1301 "goomsl_yacc.y" + { gsl_int_decl_local(yyvsp[-2].strValue); yyval.nPtr = new_set(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines), yyvsp[0].nPtr); } + break; + + case 36: +#line 1302 "goomsl_yacc.y" + { gsl_ptr_decl_local(yyvsp[-2].strValue); yyval.nPtr = new_set(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines), yyvsp[0].nPtr); } + break; + + case 37: +#line 1303 "goomsl_yacc.y" + { gsl_struct_decl_local(yyvsp[-3].strValue,yyvsp[-2].strValue); yyval.nPtr = new_set(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines), yyvsp[0].nPtr); } + break; + + case 38: +#line 1304 "goomsl_yacc.y" + { yyval.nPtr = 0; } + break; + + case 39: +#line 1307 "goomsl_yacc.y" + { gsl_float_decl_local(yyvsp[0].strValue); } + break; + + case 40: +#line 1308 "goomsl_yacc.y" + { gsl_int_decl_local(yyvsp[0].strValue); } + break; + + case 41: +#line 1309 "goomsl_yacc.y" + { gsl_ptr_decl_local(yyvsp[0].strValue); } + break; + + case 42: +#line 1310 "goomsl_yacc.y" + { gsl_struct_decl_local(yyvsp[-1].strValue,yyvsp[0].strValue); } + break; + + case 43: +#line 1315 "goomsl_yacc.y" + { yyval.nPtr = yyvsp[-1].nPtr; } + break; + + case 44: +#line 1316 "goomsl_yacc.y" + { yyval.nPtr = yyvsp[-1].nPtr; } + break; + + case 45: +#line 1317 "goomsl_yacc.y" + { yyval.nPtr = new_if(yyvsp[-4].nPtr,yyvsp[0].nPtr); } + break; + + case 46: +#line 1318 "goomsl_yacc.y" + { yyval.nPtr = new_while(yyvsp[-4].nPtr,yyvsp[0].nPtr); } + break; + + case 47: +#line 1319 "goomsl_yacc.y" + { lastNode = yyvsp[-3].nPtr->unode.opr.op[1]; yyval.nPtr=yyvsp[-3].nPtr; } + break; + + case 48: +#line 1320 "goomsl_yacc.y" + { yyval.nPtr = yyvsp[0].nPtr; } + break; + + case 49: +#line 1321 "goomsl_yacc.y" + { yyval.nPtr = new_plus_eq(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); } + break; + + case 50: +#line 1322 "goomsl_yacc.y" + { yyval.nPtr = new_sub_eq(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); } + break; + + case 51: +#line 1323 "goomsl_yacc.y" + { yyval.nPtr = new_mul_eq(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); } + break; + + case 52: +#line 1324 "goomsl_yacc.y" + { yyval.nPtr = new_div_eq(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); } + break; + + case 53: +#line 1325 "goomsl_yacc.y" + { yyval.nPtr = new_static_foreach(new_var(yyvsp[-4].strValue, currentGoomSL->num_lines), yyvsp[-2].nPtr, yyvsp[0].nPtr); } + break; + + case 54: +#line 1328 "goomsl_yacc.y" + { yyval.nPtr = yyvsp[-1].nPtr; } + break; + + case 55: +#line 1330 "goomsl_yacc.y" + { yyval.nPtr = new_var_list(new_var(yyvsp[0].strValue,currentGoomSL->num_lines), NULL); } + break; + + case 56: +#line 1331 "goomsl_yacc.y" + { yyval.nPtr = new_var_list(new_var(yyvsp[-1].strValue,currentGoomSL->num_lines), yyvsp[0].nPtr); } + break; + + case 57: +#line 1334 "goomsl_yacc.y" + { yyval.nPtr = new_set(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); } + break; + + case 58: +#line 1336 "goomsl_yacc.y" + { yyval.nPtr = new_block(lastNode); lastNode = yyval.nPtr->unode.opr.op[0]; } + break; + + case 59: +#line 1339 "goomsl_yacc.y" + { yyval.nPtr = new_var(yyvsp[0].strValue,currentGoomSL->num_lines); } + break; + + case 60: +#line 1340 "goomsl_yacc.y" + { yyval.nPtr = yyvsp[0].nPtr; } + break; + + case 61: +#line 1341 "goomsl_yacc.y" + { yyval.nPtr = new_mul(yyvsp[-2].nPtr,yyvsp[0].nPtr); } + break; + + case 62: +#line 1342 "goomsl_yacc.y" + { yyval.nPtr = new_div(yyvsp[-2].nPtr,yyvsp[0].nPtr); } + break; + + case 63: +#line 1343 "goomsl_yacc.y" + { yyval.nPtr = new_add(yyvsp[-2].nPtr,yyvsp[0].nPtr); } + break; + + case 64: +#line 1344 "goomsl_yacc.y" + { yyval.nPtr = new_sub(yyvsp[-2].nPtr,yyvsp[0].nPtr); } + break; + + case 65: +#line 1345 "goomsl_yacc.y" + { yyval.nPtr = new_neg(yyvsp[0].nPtr); } + break; + + case 66: +#line 1346 "goomsl_yacc.y" + { yyval.nPtr = yyvsp[-1].nPtr; } + break; + + case 67: +#line 1347 "goomsl_yacc.y" + { yyval.nPtr = yyvsp[0].nPtr; } + break; + + case 68: +#line 1350 "goomsl_yacc.y" + { yyval.nPtr = new_equ(yyvsp[-2].nPtr,yyvsp[0].nPtr); } + break; + + case 69: +#line 1351 "goomsl_yacc.y" + { yyval.nPtr = new_low(yyvsp[-2].nPtr,yyvsp[0].nPtr); } + break; + + case 70: +#line 1352 "goomsl_yacc.y" + { yyval.nPtr = new_low(yyvsp[0].nPtr,yyvsp[-2].nPtr); } + break; + + case 71: +#line 1353 "goomsl_yacc.y" + { yyval.nPtr = new_not(new_low(yyvsp[-2].nPtr,yyvsp[0].nPtr)); } + break; + + case 72: +#line 1354 "goomsl_yacc.y" + { yyval.nPtr = new_not(new_low(yyvsp[0].nPtr,yyvsp[-2].nPtr)); } + break; + + case 73: +#line 1355 "goomsl_yacc.y" + { yyval.nPtr = new_not(new_equ(yyvsp[-2].nPtr,yyvsp[0].nPtr)); } + break; + + case 74: +#line 1356 "goomsl_yacc.y" + { yyval.nPtr = new_not(yyvsp[0].nPtr); } + break; + + case 75: +#line 1359 "goomsl_yacc.y" + { yyval.nPtr = new_constFloat(yyvsp[0].strValue,currentGoomSL->num_lines); } + break; + + case 76: +#line 1360 "goomsl_yacc.y" + { yyval.nPtr = new_constInt(yyvsp[0].strValue,currentGoomSL->num_lines); } + break; + + case 77: +#line 1361 "goomsl_yacc.y" + { yyval.nPtr = new_constPtr(yyvsp[0].strValue,currentGoomSL->num_lines); } + break; + + case 78: +#line 1366 "goomsl_yacc.y" + { yyval.nPtr = new_call(yyvsp[-2].strValue,NULL); } + break; + + case 79: +#line 1367 "goomsl_yacc.y" + { yyval.nPtr = new_call(yyvsp[-4].strValue,yyvsp[-2].nPtr); } + break; + + case 80: +#line 1368 "goomsl_yacc.y" + { yyval.nPtr = new_call(yyvsp[-3].strValue,NULL); } + break; + + case 81: +#line 1369 "goomsl_yacc.y" + { yyval.nPtr = new_call(yyvsp[-5].strValue,yyvsp[-3].nPtr); } + break; + + case 82: +#line 1373 "goomsl_yacc.y" + { yyval.nPtr = new_call_expr(yyvsp[-2].strValue,NULL); } + break; + + case 83: +#line 1374 "goomsl_yacc.y" + { yyval.nPtr = new_call_expr(yyvsp[-4].strValue,yyvsp[-2].nPtr); } + break; + + case 84: +#line 1377 "goomsl_yacc.y" + { yyval.nPtr = new_affec_list(yyvsp[-1].nPtr,yyvsp[0].nPtr); } + break; + + case 85: +#line 1378 "goomsl_yacc.y" + { yyval.nPtr = new_affec_list(yyvsp[0].nPtr,NULL); } + break; + + case 86: +#line 1380 "goomsl_yacc.y" + { + gsl_reenternamespace(yyvsp[-1].namespace); + yyval.nPtr = new_set(new_var(yyvsp[-3].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); + } + break; + + case 87: +#line 1384 "goomsl_yacc.y" + { + gsl_reenternamespace(yyvsp[-1].namespace); + yyval.nPtr = new_set(new_var("&this", currentGoomSL->num_lines),yyvsp[0].nPtr); + } + break; + + + } + +/* Line 999 of yacc.c. */ +#line 2792 "goomsl_yacc.c" + + yyvsp -= yylen; + yyssp -= yylen; + + + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (YYPACT_NINF < yyn && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + char *yymsg; + int yyx, yycount; + + yycount = 0; + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + yysize += yystrlen (yytname[yyx]) + 15, yycount++; + yysize += yystrlen ("syntax error, unexpected ") + 1; + yysize += yystrlen (yytname[yytype]); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); + + if (yycount < 5) + { + yycount = 0; + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); + yyx++) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + const char *yyq = ! yycount ? ", expecting " : " or "; + yyp = yystpcpy (yyp, yyq); + yyp = yystpcpy (yyp, yytname[yyx]); + yycount++; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("syntax error; also virtual memory exhausted"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + /* Return failure if at end of input. */ + if (yychar == YYEOF) + { + /* Pop the error token. */ + YYPOPSTACK; + /* Pop the rest of the stack. */ + while (yyss < yyssp) + { + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + YYPOPSTACK; + } + YYABORT; + } + + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; + + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*----------------------------------------------------. +| yyerrlab1 -- error raised explicitly by an action. | +`----------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[yystate], yyvsp); + yyvsp--; + yystate = *--yyssp; + + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; + + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} + + +#line 1396 "goomsl_yacc.y" + + + +void yyerror(char *str) +{ /* {{{ */ + fprintf(stderr, "ERROR: Line %d, %s\n", currentGoomSL->num_lines, str); + currentGoomSL->compilationOK = 0; + exit(1); +} /* }}} */ + + diff --git a/src/post/goom/mmx.c b/src/post/goom/mmx.c index 953b59152..3c9d0ee4a 100644 --- a/src/post/goom/mmx.c +++ b/src/post/goom/mmx.c @@ -16,11 +16,9 @@ // faire : a / sqrtperte <=> a >> PERTEDEC #define PERTEDEC 4 -#ifdef CPU_X86 int mmx_supported (void) { return (mm_support()&0x1); } -#endif void zoom_filter_mmx (int prevX, int prevY, Pixel *expix1, Pixel *expix2, diff --git a/src/post/goom/mmx.h b/src/post/goom/mmx.h index d422eac20..6861b7cfe 100644 --- a/src/post/goom/mmx.h +++ b/src/post/goom/mmx.h @@ -244,10 +244,8 @@ mmx_ok(void) return ( mm_support() & 0x1 ); } -#ifdef CPU_X86 int mmx_supported (void); int xmmx_supported (void); -#endif /* MMX optimized implementations */ diff --git a/src/post/goom/xmmx.c b/src/post/goom/xmmx.c index 2b9103a3e..6b76a86a3 100644 --- a/src/post/goom/xmmx.c +++ b/src/post/goom/xmmx.c @@ -23,7 +23,6 @@ /*#include "xmmx.h"*/ #include "goom_graphic.h" -#ifdef CPU_X86 int xmmx_supported (void) { #ifdef ARCH_X86_64 return 0; /* Haven't yet converted zoom_filter_xmmx @@ -32,7 +31,6 @@ int xmmx_supported (void) { return (mm_support()&0x8)>>3; #endif } -#endif void zoom_filter_xmmx (int prevX, int prevY, Pixel *expix1, Pixel *expix2, -- cgit v1.2.3 From 9c59211e1b6f6c41c5915a49e42737408ba7a680 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Sat, 19 Jan 2008 13:43:30 +0100 Subject: Be sure libmad has enough data. Fixed random glitches. --- src/libmad/xine_mad_decoder.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libmad/xine_mad_decoder.c b/src/libmad/xine_mad_decoder.c index 2f6d7cfe3..be616be36 100644 --- a/src/libmad/xine_mad_decoder.c +++ b/src/libmad/xine_mad_decoder.c @@ -48,6 +48,20 @@ #define INPUT_BUF_SIZE 16384 +/* According to Rob Leslie (libmad author) : + * The absolute theoretical maximum frame size is 2881 bytes: MPEG 2.5 Layer II, + * 8000 Hz @ 160 kbps, with a padding slot. (Such a frame is unlikely, but it was + * a useful exercise to compute all possible frame sizes.) Add to this an 8 byte + * MAD_BUFFER_GUARD, and the minimum buffer size you should be streaming to + * libmad in the general case is 2889 bytes. + + * Theoretical frame sizes for Layer III range from 24 to 1441 bytes, but there + * is a "soft" limit imposed by the standard of 960 bytes. Nonetheless MAD can + * decode frames of any size as long as they fit entirely in the buffer you pass, + * not including the MAD_BUFFER_GUARD bytes. + */ +#define MAD_MIN_SIZE 2889 + typedef struct { audio_decoder_class_t decoder_class; } mad_class_t; @@ -136,8 +150,8 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { mad_decoder_t *this = (mad_decoder_t *) this_gen; - lprintf ("decode data, decoder_flags: %d\n", buf->decoder_flags); - + lprintf ("decode data, size: %d, decoder_flags: %d\n", buf->size, buf->decoder_flags); + if (buf->size>(INPUT_BUF_SIZE-this->bytes_in_buffer)) { xprintf (this->xstream->xine, XINE_VERBOSITY_DEBUG, "libmad: ALERT input buffer too small (%d bytes, %d avail)!\n", @@ -167,6 +181,9 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { mad_stream_buffer (&this->stream, this->buffer, this->bytes_in_buffer); + if (this->bytes_in_buffer < MAD_MIN_SIZE) + return; + while (1) { if (mad_frame_decode (&this->frame, &this->stream) != 0) { @@ -187,6 +204,7 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { return; default: + lprintf ("error 0x%04X, mad_stream_buffer %d bytes\n", this->stream.error, this->bytes_in_buffer); mad_stream_buffer (&this->stream, this->buffer, this->bytes_in_buffer); } -- cgit v1.2.3 From ce16be132cec33879e3f1521997aa30993d7fd93 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Sat, 19 Jan 2008 13:52:43 +0100 Subject: Initial support of free bitrate streams. --- src/demuxers/demux_mpgaudio.c | 284 ++++++++++++++++++++++++++++++------------ 1 file changed, 203 insertions(+), 81 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index 8e716f095..027c46c45 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -35,9 +35,9 @@ #define LOG_MODULE "demux_mpeg_audio" #define LOG_VERBOSE -/* + #define LOG -*/ + #include "xine_internal.h" #include "xineutils.h" #include "demux.h" @@ -52,7 +52,6 @@ */ #define NUM_PREVIEW_BUFFERS 2 -#define WRAP_THRESHOLD 120000 #define FOURCC_TAG BE_FOURCC #define RIFF_CHECK_BYTES 1024 @@ -77,16 +76,16 @@ /* mp3 frame struct */ typedef struct { /* header */ - double duration; - uint32_t size; /* in bytes */ + double duration; /* in milliseconds */ + uint32_t size; /* in bytes; including padding */ uint32_t bitrate; /* in bit per second */ uint16_t freq; /* in Hz */ - uint8_t layer; - uint8_t version_idx:2; /* 0: mpeg1, 1: mpeg2, 2: mpeg2.5 */ uint8_t lsf_bit:1; uint8_t channel_mode:3; + uint8_t padding:3; /* in bytes */ + uint8_t is_free_bitrate:1; } mpg_audio_frame_t; /* Xing Vbr Header struct */ @@ -125,7 +124,16 @@ typedef struct { int br; /* bitrate in bits/second */ uint32_t blocksize; + /* current mp3 frame */ mpg_audio_frame_t cur_frame; + + /* next mp3 frame, used when the frame size cannot be computed from the + * current frame header */ + mpg_audio_frame_t next_frame; + + /* reference mp3 frame, used for extra validation when sync is lost */ + mpg_audio_frame_t ref_frame; + double cur_time; /* in milliseconds */ off_t mpg_frame_start; /* offset */ @@ -135,7 +143,12 @@ typedef struct { int check_vbr_header; xing_header_t *xing_header; vbri_header_t *vbri_header; - + + int found_next_frame:1; + int has_ref_frame:1; + off_t free_bitrate_size; + uint8_t next_header[4]; + } demux_mpgaudio_t ; /* demuxer class struct */ @@ -206,14 +219,14 @@ static int parse_frame_header(mpg_audio_frame_t *const frame, const uint8_t *con const uint32_t head = _X_BE_32(buf); const uint16_t frame_sync = head >> 21; - lprintf("header: %08X\n", head); if (frame_sync != 0x7ff) { - lprintf("invalid frame sync\n"); + lprintf("invalid frame sync %08X\n", head); return 0; } + lprintf("header: %08X\n", head); frame_header.mpeg25_bit = (head >> 20) & 0x1; - frame->lsf_bit = (head >> 19) & 0x1; + frame->lsf_bit = (head >> 19) & 0x1; if (!frame_header.mpeg25_bit) { if (frame->lsf_bit) { lprintf("reserved mpeg25 lsf combination\n"); @@ -234,14 +247,14 @@ static int parse_frame_header(mpg_audio_frame_t *const frame, const uint8_t *con } frame_header.bitrate_idx = (head >> 12) & 0xf; - if ((frame_header.bitrate_idx == 0) || (frame_header.bitrate_idx == 15)) { - lprintf("invalid bitrate index\n"); + if (frame_header.bitrate_idx == 15) { + lprintf("invalid bitrate index: %d\n", frame_header.bitrate_idx); return 0; } frame_header.freq_idx = (head >> 10) & 0x3; if (frame_header.freq_idx == 3) { - lprintf("invalid frequence index\n"); + lprintf("invalid frequence index: %d\n", frame_header.freq_idx); return 0; } @@ -274,19 +287,27 @@ static int parse_frame_header(mpg_audio_frame_t *const frame, const uint8_t *con const uint16_t samples = mp3_samples[frame->version_idx][frame->layer - 1]; frame->bitrate = mp3_bitrates[frame->version_idx][frame->layer - 1][frame_header.bitrate_idx] * 1000; frame->freq = mp3_freqs[frame->version_idx][frame_header.freq_idx]; - - frame->size = samples * (frame->bitrate / 8); - frame->size /= frame->freq; - /* Padding: only if padding_bit is set; 4 bytes for Layer 1 and 1 byte for others */ - frame->size += ( frame_header.padding_bit ? ( frame->layer == 1 ? 4 : 1 ) : 0 ); - frame->duration = 1000.0f * (double)samples / (double)frame->freq; + frame->padding = ( frame_header.padding_bit ? ( frame->layer == 1 ? 4 : 1 ) : 0 ); + frame->channel_mode = frame_header.channel_mode; + + if (frame->bitrate > 0) { + frame->size = samples * (frame->bitrate / 8); + frame->size /= frame->freq; + /* Padding: only if padding_bit is set; 4 bytes for Layer 1 and 1 byte for others */ + frame->size += frame->padding; + } else { + /* Free bitrate frame, the size of the frame cannot be computed from the header. */ + frame->is_free_bitrate = 1; + frame->size = 0; + } } - lprintf("mpeg %d, layer %d\n", frame->version_idx + 1, frame->layer); - lprintf("bitrate: %d bps, samplerate: %d Hz\n", frame->bitrate, frame->freq); + lprintf("mpeg %d, layer %d, channel_mode: %d\n", frame->version_idx + 1, + frame->layer, frame->channel_mode); + lprintf("bitrate: %d bps, output freq: %d Hz\n", frame->bitrate, frame->freq); lprintf("length: %d bytes, %f ms\n", frame->size, frame->duration); - lprintf("padding: %d bytes\n", ( frame_header.padding_bit ? ( frame->layer == 1 ? 4 : 1 ) : 0 )); + lprintf("padding: %d bytes\n", frame->padding); return 1; } @@ -478,6 +499,25 @@ static vbri_header_t* parse_vbri_header(mpg_audio_frame_t *frame, } } +static int check_frame_validity(demux_mpgaudio_t *const this, mpg_audio_frame_t *const frame) { + int result = 0; + + if (this->ref_frame.is_free_bitrate) { + if ((frame->bitrate == 0) && + (this->ref_frame.freq == frame->freq) && + (this->ref_frame.version_idx == frame->version_idx) && + (this->ref_frame.channel_mode == frame->channel_mode)) { + result = 1; + } + } else { + if ((this->ref_frame.version_idx == frame->version_idx) && + (this->ref_frame.channel_mode == frame->channel_mode)) { + result = 1; + } + } + return result; +} + /* * Parse a mp3 frame paylod * return 1 on success, 0 on error @@ -488,9 +528,10 @@ static int parse_frame_payload(demux_mpgaudio_t *this, buf_element_t *buf; off_t frame_pos, len; uint64_t pts = 0; + int payload_size = 0; frame_pos = this->input->get_current_pos(this->input) - 4; - lprintf("frame_pos = %"PRId64"\n", frame_pos); + lprintf("frame_pos = %"PRId64", header: %08X\n", frame_pos, _X_BE_32(frame_header)); buf = this->audio_fifo->buffer_pool_alloc(this->audio_fifo); @@ -500,31 +541,93 @@ static int parse_frame_payload(demux_mpgaudio_t *this, buf->free_buffer(buf); return 0; } - + /* the decoder needs the frame header */ - memcpy(buf->mem, frame_header, 4); + if (!this->found_next_frame) { + memcpy(buf->content, frame_header, 4); + } - len = this->input->read(this->input, buf->mem + 4, this->cur_frame.size - 4); - if (len != (this->cur_frame.size - 4)) { - buf->free_buffer(buf); - return 0; + /* compute the payload size */ + if (this->cur_frame.size > 0) { + payload_size = this->cur_frame.size - 4; + } else if (this->free_bitrate_size > 0) { +// payload_size = this->free_bitrate_size + this->cur_frame.padding - 4; +// this->cur_frame.size = payload_size + 4; + payload_size = 0; + } else { + payload_size = 0; + } + + /* Read the payload data. */ + if (payload_size > 0) { + off_t len; + + /* If we know the payload size, it's easy */ + this->found_next_frame = 0; + len = this->input->read(this->input, buf->content + 4, payload_size); + if (len != payload_size) { + buf->free_buffer(buf); + return 0; + } + } else { + /* Search for the beginning of the next frame and deduce the size of the + * current frame from the position of the next one. */ + int payload_size = 0; + int max_size = buf->max_size - 4; + int header_size = 4 * !this->found_next_frame; + + while (payload_size < max_size) { + len = this->input->read(this->input, + &buf->content[header_size + payload_size], 1); + if (len != 1) { + lprintf("EOF\n"); + buf->free_buffer(buf); + return 0; + } + payload_size += len; + + if ((header_size + payload_size) >= 4) { + if (parse_frame_header(&this->next_frame, + &buf->content[header_size + payload_size - 4])) { + if (check_frame_validity(this, &this->next_frame)) { + lprintf("found next frame header\n"); + if (this->free_bitrate_size == 0) { + this->free_bitrate_size = payload_size - this->cur_frame.padding; + } + /* don't read the frame header twice */ + this->found_next_frame = 1; + memcpy(&this->next_header[0], &buf->content[header_size + payload_size], 4); + payload_size -= 4; + break; + } else { + lprintf("invalid frame\n"); + } + } + } + } + this->cur_frame.size = header_size + payload_size + 4; + if (this->br == 0) { + this->br = 8000 * this->cur_frame.size / this->cur_frame.duration; + } + this->cur_frame.bitrate = this->br; + lprintf("free bitrate: bitrate: %d, frame size: %d\n", this->br, this->cur_frame.size); + } if (this->check_vbr_header) { this->check_vbr_header = 0; this->mpg_frame_start = frame_pos; - this->xing_header = parse_xing_header(&this->cur_frame, buf->mem, this->cur_frame.size); + this->xing_header = parse_xing_header(&this->cur_frame, buf->content, this->cur_frame.size); if (this->xing_header) { buf->free_buffer(buf); return 1; } - this->vbri_header = parse_vbri_header(&this->cur_frame, buf->mem, this->cur_frame.size); + this->vbri_header = parse_vbri_header(&this->cur_frame, buf->content, this->cur_frame.size); if (this->vbri_header) { buf->free_buffer(buf); return 1; } } - pts = (int64_t)(this->cur_time * 90.0f); @@ -533,14 +636,13 @@ static int parse_frame_payload(demux_mpgaudio_t *this, buf->extra_info->input_time = this->cur_time; buf->pts = pts; - buf->size = len + 4; - buf->content = buf->mem; + buf->size = this->cur_frame.size; buf->type = BUF_AUDIO_MPEG; buf->decoder_info[0] = 1; buf->decoder_flags = decoder_flags|BUF_FLAG_FRAME_END; + lprintf("send buffer: size=%d, pts=%"PRId64"\n", buf->size, pts); this->audio_fifo->put(this->audio_fifo, buf); - lprintf("send buffer: pts=%"PRId64"\n", pts); this->cur_time += this->cur_frame.duration; return 1; } @@ -604,56 +706,74 @@ static int read_frame_header(demux_mpgaudio_t *this, uint8_t *header_buf, int by * Parse next mp3 frame */ static int demux_mpgaudio_next (demux_mpgaudio_t *this, int decoder_flags, int send_header) { - uint8_t header_buf[4]; - int bytes = 4; - - for (;;) { - - if (read_frame_header(this, header_buf, bytes)) { - - if (parse_frame_header(&this->cur_frame, header_buf)) { - - /* send header buffer */ - if ( send_header ) { - buf_element_t *buf; - - buf = this->audio_fifo->buffer_pool_alloc(this->audio_fifo); - - buf->type = BUF_AUDIO_MPEG; - buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAME_END; - - buf->decoder_info[0] = 0; - buf->decoder_info[1] = this->cur_frame.freq; - buf->decoder_info[2] = 0; /* bits_per_sample */ - - /* Only for channel_mode == 3 (mono) there is one channel, for any other case, there are 2 */ - buf->decoder_info[3] = ( this->cur_frame.channel_mode == 3 ) ? 1 : 2; - - buf->size = 0; /* No extra header data */ - - this->audio_fifo->put(this->audio_fifo, buf); - } - - return parse_frame_payload(this, header_buf, decoder_flags); - - } else if ( id3v2_istag(header_buf) ) { - if (!id3v2_parse_tag(this->input, this->stream, header_buf)) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": ID3V2 tag parsing error\n"); - bytes = 1; /* resync */ + uint8_t buffer[4]; + uint8_t *header = buffer; + + if (this->found_next_frame) { + lprintf("skip header reading\n"); + header = this->next_header; + memcpy(&this->cur_frame, &this->next_frame, sizeof(mpg_audio_frame_t)); + } else { + int bytes = 4; + + for (;;) { + if (!read_frame_header(this, header, bytes)) + return 0; + if (parse_frame_header(&this->cur_frame, header)) { + if (!this->has_ref_frame) { + this->has_ref_frame = 1; + memcpy(&this->ref_frame, &this->cur_frame, sizeof(mpg_audio_frame_t)); + lprintf("ref frame saved\n"); } else { - bytes = 4; + if (!check_frame_validity(this, &this->cur_frame)) { + lprintf("invalid frame\n"); + bytes = 1; /* resync */ + continue; + } } + lprintf("frame found\n"); + break; } else { - /* skip */ - bytes = 1; + lprintf("loose sync\n"); + + if ( id3v2_istag(header) ) { + if (!id3v2_parse_tag(this->input, this->stream, header)) { + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + LOG_MODULE ": ID3V2 tag parsing error\n"); + bytes = 1; /* resync */ + } else { + bytes = 4; + } + } else { + /* skip */ + bytes = 1; + } } - - } else { - lprintf("read error\n"); - return 0; } } + + /* send header buffer */ + if ( send_header ) { + buf_element_t *buf; + + buf = this->audio_fifo->buffer_pool_alloc(this->audio_fifo); + + buf->type = BUF_AUDIO_MPEG; + buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAME_END; + + buf->decoder_info[0] = 0; + buf->decoder_info[1] = this->cur_frame.freq; + buf->decoder_info[2] = 0; /* bits_per_sample */ + + /* Only for channel_mode == 3 (mono) there is one channel, for any other case, there are 2 */ + buf->decoder_info[3] = ( this->cur_frame.channel_mode == 3 ) ? 1 : 2; + + buf->size = 0; /* No extra header data */ + + this->audio_fifo->put(this->audio_fifo, buf); + } + + return parse_frame_payload(this, header, decoder_flags); } static int demux_mpgaudio_send_chunk (demux_plugin_t *this_gen) { @@ -779,6 +899,7 @@ static void demux_mpgaudio_send_headers (demux_plugin_t *this_gen) { */ this->check_vbr_header = 1; for (i = 0; i < NUM_PREVIEW_BUFFERS; i++) { + lprintf("preview buffer number %d / %d\n", i + 1, NUM_PREVIEW_BUFFERS); if (!demux_mpgaudio_next (this, BUF_FLAG_PREVIEW, i == 0)) { break; } @@ -965,7 +1086,8 @@ static int demux_mpgaudio_seek (demux_plugin_t *this_gen, /* assume seeking is always perfect... */ this->cur_time = start_time; this->input->seek (this->input, seek_pos, SEEK_SET); - + this->found_next_frame = 0; + if (playing) { _x_demux_flush_engine(this->stream); } -- cgit v1.2.3 From ead9fc9aabadff4ea507e442a272ca2847ec537d Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Sat, 19 Jan 2008 20:33:21 +0100 Subject: Cleanup. --- src/demuxers/demux_mpgaudio.c | 50 ++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index 027c46c45..afd695d84 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -542,17 +542,14 @@ static int parse_frame_payload(demux_mpgaudio_t *this, return 0; } - /* the decoder needs the frame header */ - if (!this->found_next_frame) { - memcpy(buf->content, frame_header, 4); - } + memcpy(buf->content, frame_header, 4); /* compute the payload size */ if (this->cur_frame.size > 0) { payload_size = this->cur_frame.size - 4; } else if (this->free_bitrate_size > 0) { -// payload_size = this->free_bitrate_size + this->cur_frame.padding - 4; -// this->cur_frame.size = payload_size + 4; + payload_size = this->free_bitrate_size + this->cur_frame.padding - 4; + this->cur_frame.size = payload_size + 4; payload_size = 0; } else { payload_size = 0; @@ -574,11 +571,9 @@ static int parse_frame_payload(demux_mpgaudio_t *this, * current frame from the position of the next one. */ int payload_size = 0; int max_size = buf->max_size - 4; - int header_size = 4 * !this->found_next_frame; while (payload_size < max_size) { - len = this->input->read(this->input, - &buf->content[header_size + payload_size], 1); + len = this->input->read(this->input, &buf->content[payload_size], 1); if (len != 1) { lprintf("EOF\n"); buf->free_buffer(buf); @@ -586,32 +581,29 @@ static int parse_frame_payload(demux_mpgaudio_t *this, } payload_size += len; - if ((header_size + payload_size) >= 4) { - if (parse_frame_header(&this->next_frame, - &buf->content[header_size + payload_size - 4])) { - if (check_frame_validity(this, &this->next_frame)) { - lprintf("found next frame header\n"); - if (this->free_bitrate_size == 0) { - this->free_bitrate_size = payload_size - this->cur_frame.padding; - } - /* don't read the frame header twice */ - this->found_next_frame = 1; - memcpy(&this->next_header[0], &buf->content[header_size + payload_size], 4); - payload_size -= 4; - break; - } else { - lprintf("invalid frame\n"); + if (parse_frame_header(&this->next_frame, + &buf->content[payload_size - 4])) { + if (check_frame_validity(this, &this->next_frame)) { + lprintf("found next frame header\n"); + if (this->free_bitrate_size == 0) { + this->free_bitrate_size = payload_size - this->cur_frame.padding; } + /* don't read the frame header twice */ + this->found_next_frame = 1; + memcpy(&this->next_header[0], &buf->content[payload_size], 4); + payload_size -= 4; + break; + } else { + lprintf("invalid frame\n"); } } } - this->cur_frame.size = header_size + payload_size + 4; + this->cur_frame.size = payload_size + 4; if (this->br == 0) { this->br = 8000 * this->cur_frame.size / this->cur_frame.duration; } this->cur_frame.bitrate = this->br; lprintf("free bitrate: bitrate: %d, frame size: %d\n", this->br, this->cur_frame.size); - } if (this->check_vbr_header) { @@ -904,7 +896,7 @@ static void demux_mpgaudio_send_headers (demux_plugin_t *this_gen) { break; } } - + if (this->xing_header) { xing_header_t *xing = this->xing_header; @@ -915,7 +907,7 @@ static void demux_mpgaudio_send_headers (demux_plugin_t *this_gen) { if (this->stream_length) { this->br = ((uint64_t)xing->stream_size * 8 * 1000) / this->stream_length; } - + } else if (this->vbri_header) { vbri_header_t *vbri = this->vbri_header; @@ -958,7 +950,7 @@ static void demux_mpgaudio_send_headers (demux_plugin_t *this_gen) { { char scratch_buf[256]; char *mpeg_ver[3] = {"1", "2", "2.5"}; - + snprintf(scratch_buf, 256, "MPEG %s Layer %1d%s", mpeg_ver[this->cur_frame.version_idx], this->cur_frame.layer, (this->xing_header)? " VBR" : " CBR" ); -- cgit v1.2.3 From 4a85a1853424d220a4488b1e158b778ab9d7e56b Mon Sep 17 00:00:00 2001 From: Claudio Ciccani Date: Sat, 19 Jan 2008 13:30:23 +0100 Subject: Introducing new features from FusionSound-1.1.0 (dolby surround). --- src/audio_out/audio_fusionsound_out.c | 45 ++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/audio_out/audio_fusionsound_out.c b/src/audio_out/audio_fusionsound_out.c index a79d21213..b33850c5e 100644 --- a/src/audio_out/audio_fusionsound_out.c +++ b/src/audio_out/audio_fusionsound_out.c @@ -47,6 +47,12 @@ #define FUSIONSOUND_VERSION_CODE VERSION_CODE( FUSIONSOUND_MAJOR_VERSION, \ FUSIONSOUND_MINOR_VERSION, \ FUSIONSOUND_MICRO_VERSION ) + +#if FUSIONSOUND_VERSION_CODE >= VERSION_CODE(1,1,0) +# include /* defines FS_MAX_CHANNELS */ +#else +# define FS_MAX_CHANNELS 2 +#endif #define AO_OUT_FS_IFACE_VERSION 9 @@ -100,7 +106,29 @@ static int ao_fusionsound_open(ao_driver_t *ao_driver, break; case AO_CAP_MODE_STEREO: dsc.channels = 2; - break; + break; +#if FS_MAX_CHANNELS > 2 + case AO_CAP_MODE_4CHANNEL: + dsc.channels = 4; + dsc.channelmode = FSCM_SURROUND40_2F2R; + dsc.flags |= FSBDF_CHANNELMODE; + break; + case AO_CAP_MODE_4_1CHANNEL: + dsc.channels = 5; + dsc.channelmode = FSCM_SURROUND41_2F2R; + dsc.flags |= FSBDF_CHANNELMODE; + break; + case AO_CAP_MODE_5CHANNEL: + dsc.channels = 5; + dsc.channelmode = FSCM_SURROUND50; + dsc.flags |= FSBDF_CHANNELMODE; + break; + case AO_CAP_MODE_5_1CHANNEL: + dsc.channels = 6; + dsc.channelmode = FSCM_SURROUND51; + dsc.flags |= FSBDF_CHANNELMODE; + break; +#endif default: xprintf (this->xine, XINE_VERBOSITY_LOG, "audio_fusionsound_out: mode %#x not supported\n", mode); @@ -250,13 +278,18 @@ static void ao_fusionsound_close(ao_driver_t *ao_driver){ */ static uint32_t ao_fusionsound_get_capabilities(ao_driver_t *ao_driver) { + uint32_t caps = AO_CAP_MODE_MONO | AO_CAP_MODE_STEREO | + AO_CAP_MIXER_VOL | AO_CAP_MUTE_VOL | + AO_CAP_8BITS | AO_CAP_16BITS | + AO_CAP_24BITS; #if FUSIONSOUND_VERSION_CODE >= VERSION_CODE(0,9,26) - return (AO_CAP_MODE_MONO | AO_CAP_MODE_STEREO | AO_CAP_MIXER_VOL | - AO_CAP_8BITS | AO_CAP_16BITS | AO_CAP_24BITS | AO_CAP_FLOAT32); -#else - return (AO_CAP_MODE_MONO | AO_CAP_MODE_STEREO | AO_CAP_MIXER_VOL | - AO_CAP_8BITS | AO_CAP_16BITS | AO_CAP_24BITS); + caps |= AO_CAP_FLOAT32; +#endif +#if FS_MAX_CHANNELS > 2 + caps |= AO_CAP_MODE_4CHANNEL | AO_CAP_MODE_4_1CHANNEL | + AO_CAP_MODE_5CHANNEL | AO_CAP_MODE_5_1CHANNEL; #endif + return caps; } static void ao_fusionsound_exit(ao_driver_t *ao_driver) { -- cgit v1.2.3 From e372abc3772aa47b90fa0aadddb65ba33c54f574 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sun, 20 Jan 2008 01:09:10 +0000 Subject: Comment out "#define LOG" again. --- src/demuxers/demux_mpgaudio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index afd695d84..ee1dc915c 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -35,9 +35,9 @@ #define LOG_MODULE "demux_mpeg_audio" #define LOG_VERBOSE - +/* #define LOG - +*/ #include "xine_internal.h" #include "xineutils.h" #include "demux.h" -- cgit v1.2.3 From dd125c93bdfbef26909ad684b678781abfd88c4a Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sun, 20 Jan 2008 15:14:25 +0000 Subject: Don't unescape #subtitle:scheme://data. This was broken in 1.1.8 when #subtitle:/file was fixed. --- src/xine-engine/xine.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index eae13bec9..4f6ba2a80 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -780,6 +780,19 @@ void _x_flush_events_queues (xine_stream_t *stream) { pthread_mutex_unlock (&stream->event_queues_lock); } +static inline int _x_path_looks_like_mrl (const char *path) +{ + if ((*path & 0xDF) < 'A' || (*path & 0xDF) > 'Z') + return 0; + + for (++path; *path; ++path) + if ((*path != '-' && *path < '0') || (*path > '9' && *path < 'A') || + (*path > 'Z' && *path < 'a') || *path > 'z') + break; + + return path[0] == ':' && path[1] == '/'; +} + /*static*/ int open_internal (xine_stream_t *stream, const char *mrl) { const char *stream_setup = NULL; @@ -1091,7 +1104,9 @@ void _x_flush_events_queues (xine_stream_t *stream) { memcpy(subtitle_mrl, tmp, strlen(tmp)); subtitle_mrl[strlen(tmp)] = '\0'; } - _x_mrl_unescape(subtitle_mrl); + /* unescape for xine_open() if the MRL looks like a raw pathname */ + if (!_x_path_looks_like_mrl(subtitle_mrl)) + _x_mrl_unescape(subtitle_mrl); stream->slave = xine_stream_new (stream->xine, NULL, stream->video_out ); stream->slave_affection = XINE_MASTER_SLAVE_PLAY | XINE_MASTER_SLAVE_STOP; if( xine_open( stream->slave, subtitle_mrl ) ) { -- cgit v1.2.3 From 94cf4ac059aa99952196af650401cdfa684e04a2 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sun, 20 Jan 2008 15:35:05 +0000 Subject: Unescape the "#save:" filename, allowing ";" etc. in file names. This has a side effect: versions older than 1.1.10 do not unescape, so "#save:foo%23.ts" will result in a file named "foo%23.ts". Front end maintainers, beware :-) --- src/xine-engine/xine.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 4f6ba2a80..13c6d19e9 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -930,6 +930,7 @@ static inline int _x_path_looks_like_mrl (const char *path) memcpy(filename, tmp, strlen(tmp)); filename[strlen(tmp)] = '\0'; } + _x_mrl_unescape(filename);# xine_log(stream->xine, XINE_LOG_MSG, _("xine: join rip input plugin\n")); input_saver = _x_rip_plugin_get_instance (stream, filename); -- cgit v1.2.3 From d19e7735c81d329742dd4a75d7115d2a2e2ed969 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sun, 20 Jan 2008 16:06:31 +0000 Subject: Unmaking a # of it. --- src/xine-engine/xine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 13c6d19e9..0558f2f81 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -930,7 +930,7 @@ static inline int _x_path_looks_like_mrl (const char *path) memcpy(filename, tmp, strlen(tmp)); filename[strlen(tmp)] = '\0'; } - _x_mrl_unescape(filename);# + _x_mrl_unescape(filename); xine_log(stream->xine, XINE_LOG_MSG, _("xine: join rip input plugin\n")); input_saver = _x_rip_plugin_get_instance (stream, filename); -- cgit v1.2.3 From 76f79f2572257261d451b89d7c4f8a0d05a3aefe Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Mon, 21 Jan 2008 22:40:54 +0100 Subject: Fixed problems introduced by the free bitrate handling when frame sync is lost. --- src/demuxers/demux_mpgaudio.c | 133 ++++++++++++++++++++---------------------- 1 file changed, 63 insertions(+), 70 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index ee1dc915c..8ccaa9810 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -126,14 +126,11 @@ typedef struct { /* current mp3 frame */ mpg_audio_frame_t cur_frame; - + /* next mp3 frame, used when the frame size cannot be computed from the * current frame header */ mpg_audio_frame_t next_frame; - - /* reference mp3 frame, used for extra validation when sync is lost */ - mpg_audio_frame_t ref_frame; - + double cur_time; /* in milliseconds */ off_t mpg_frame_start; /* offset */ @@ -145,9 +142,12 @@ typedef struct { vbri_header_t *vbri_header; int found_next_frame:1; - int has_ref_frame:1; - off_t free_bitrate_size; + int free_bitrate_count; + off_t free_bitrate_size; /* use this size if 3 free bitrate frames are encountered */ uint8_t next_header[4]; + int mpg_version; + int mpg_layer; + int valid_frames; } demux_mpgaudio_t ; @@ -344,7 +344,7 @@ static xing_header_t* parse_xing_header(mpg_audio_frame_t *frame, if (!xing) goto exit_error; - lprintf("Xing header found\n"); + lprintf("found Xing header\n"); ptr += 4; if (ptr >= (buf + bufsize - 4)) goto exit_error; @@ -435,7 +435,7 @@ static vbri_header_t* parse_vbri_header(mpg_audio_frame_t *frame, if ((ptr + 4) >= (buf + bufsize)) return 0; lprintf("Checking %08X\n", *ptr); if (_X_BE_32(ptr) == VBRI_TAG) { - lprintf("Vbri header found\n"); + lprintf("found Vbri header\n"); ptr += 4; if ((ptr + 22) >= (buf + bufsize)) return 0; @@ -499,24 +499,6 @@ static vbri_header_t* parse_vbri_header(mpg_audio_frame_t *frame, } } -static int check_frame_validity(demux_mpgaudio_t *const this, mpg_audio_frame_t *const frame) { - int result = 0; - - if (this->ref_frame.is_free_bitrate) { - if ((frame->bitrate == 0) && - (this->ref_frame.freq == frame->freq) && - (this->ref_frame.version_idx == frame->version_idx) && - (this->ref_frame.channel_mode == frame->channel_mode)) { - result = 1; - } - } else { - if ((this->ref_frame.version_idx == frame->version_idx) && - (this->ref_frame.channel_mode == frame->channel_mode)) { - result = 1; - } - } - return result; -} /* * Parse a mp3 frame paylod @@ -547,11 +529,12 @@ static int parse_frame_payload(demux_mpgaudio_t *this, /* compute the payload size */ if (this->cur_frame.size > 0) { payload_size = this->cur_frame.size - 4; - } else if (this->free_bitrate_size > 0) { + this->free_bitrate_count = 0; + } else if (this->free_bitrate_count >= 3) { payload_size = this->free_bitrate_size + this->cur_frame.padding - 4; this->cur_frame.size = payload_size + 4; - payload_size = 0; } else { + this->free_bitrate_count++; payload_size = 0; } @@ -573,7 +556,7 @@ static int parse_frame_payload(demux_mpgaudio_t *this, int max_size = buf->max_size - 4; while (payload_size < max_size) { - len = this->input->read(this->input, &buf->content[payload_size], 1); + len = this->input->read(this->input, &buf->content[4 + payload_size], 1); if (len != 1) { lprintf("EOF\n"); buf->free_buffer(buf); @@ -581,28 +564,22 @@ static int parse_frame_payload(demux_mpgaudio_t *this, } payload_size += len; - if (parse_frame_header(&this->next_frame, - &buf->content[payload_size - 4])) { - if (check_frame_validity(this, &this->next_frame)) { - lprintf("found next frame header\n"); - if (this->free_bitrate_size == 0) { - this->free_bitrate_size = payload_size - this->cur_frame.padding; - } - /* don't read the frame header twice */ - this->found_next_frame = 1; - memcpy(&this->next_header[0], &buf->content[payload_size], 4); - payload_size -= 4; - break; - } else { - lprintf("invalid frame\n"); + if (parse_frame_header(&this->next_frame, &buf->content[payload_size])) { + lprintf("found next frame header\n"); + + if (this->free_bitrate_size == 0) { + this->free_bitrate_size = payload_size - this->cur_frame.padding; } + + /* don't read the frame header twice */ + this->found_next_frame = 1; + memcpy(&this->next_header[0], &buf->content[payload_size], 4); + payload_size -= 4; + break; } } this->cur_frame.size = payload_size + 4; - if (this->br == 0) { - this->br = 8000 * this->cur_frame.size / this->cur_frame.duration; - } - this->cur_frame.bitrate = this->br; + this->cur_frame.bitrate = 8000 * this->cur_frame.size / this->cur_frame.duration; lprintf("free bitrate: bitrate: %d, frame size: %d\n", this->br, this->cur_frame.size); } @@ -612,11 +589,15 @@ static int parse_frame_payload(demux_mpgaudio_t *this, this->xing_header = parse_xing_header(&this->cur_frame, buf->content, this->cur_frame.size); if (this->xing_header) { buf->free_buffer(buf); + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + "demux_mpgaudio: found Xing header at offset %PRId64\n", frame_pos); return 1; } this->vbri_header = parse_vbri_header(&this->cur_frame, buf->content, this->cur_frame.size); if (this->vbri_header) { buf->free_buffer(buf); + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + "demux_mpgaudio: found Vbri header at offset %PRId64\n", frame_pos); return 1; } } @@ -707,39 +688,51 @@ static int demux_mpgaudio_next (demux_mpgaudio_t *this, int decoder_flags, int s memcpy(&this->cur_frame, &this->next_frame, sizeof(mpg_audio_frame_t)); } else { int bytes = 4; + int loose_sync = 0; for (;;) { if (!read_frame_header(this, header, bytes)) return 0; if (parse_frame_header(&this->cur_frame, header)) { - if (!this->has_ref_frame) { - this->has_ref_frame = 1; - memcpy(&this->ref_frame, &this->cur_frame, sizeof(mpg_audio_frame_t)); - lprintf("ref frame saved\n"); - } else { - if (!check_frame_validity(this, &this->cur_frame)) { - lprintf("invalid frame\n"); - bytes = 1; /* resync */ - continue; - } - } lprintf("frame found\n"); - break; - } else { - lprintf("loose sync\n"); - if ( id3v2_istag(header) ) { - if (!id3v2_parse_tag(this->input, this->stream, header)) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": ID3V2 tag parsing error\n"); - bytes = 1; /* resync */ + /* additionnal checks */ + if ((this->mpg_version == (this->cur_frame.version_idx + 1)) && + (this->mpg_layer == this->cur_frame.layer)) { + this->valid_frames++; + break; + } else { + if (this->valid_frames > 3) { + lprintf("invalid frame. expected mpeg %d, layer %d\n", this->mpg_version, this->mpg_layer); } else { - bytes = 4; + this->mpg_version = this->cur_frame.version_idx + 1; + this->mpg_layer = this->cur_frame.layer; + this->valid_frames = 0; + break; } + } + } + + if (!loose_sync) { + off_t frame_pos = this->input->get_current_pos(this->input) - 4; + loose_sync = 1; + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + LOG_MODULE ": loose mp3 sync at offset %"PRId64"\n", frame_pos); + } + /* the stream is broken, don't keep info about previous frames */ + this->free_bitrate_size = 0; + + if ( id3v2_istag(header) ) { + if (!id3v2_parse_tag(this->input, this->stream, header)) { + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + LOG_MODULE ": ID3V2 tag parsing error\n"); + bytes = 1; /* resync */ } else { - /* skip */ - bytes = 1; + bytes = 4; } + } else { + /* skip */ + bytes = 1; } } } -- cgit v1.2.3 From e6a7cabd6e6bf25145eaef168823ab3f42dcbdc8 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Mon, 21 Jan 2008 23:05:28 +0100 Subject: Fixed logging. Replaced a magic number by #define. --- src/demuxers/demux_mpgaudio.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index 8ccaa9810..180a9752c 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -33,7 +33,7 @@ #include #include -#define LOG_MODULE "demux_mpeg_audio" +#define LOG_MODULE "demux_mpgaudio" #define LOG_VERBOSE /* #define LOG @@ -51,6 +51,7 @@ * the second mp3 frame is sent to the decoder */ #define NUM_PREVIEW_BUFFERS 2 +#define NUM_VALID_FRAMES 3 #define FOURCC_TAG BE_FOURCC @@ -519,7 +520,7 @@ static int parse_frame_payload(demux_mpgaudio_t *this, if (this->cur_frame.size > buf->max_size) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - "demux_mpgaudio: frame size is greater than fifo buffer size\n"); + LOG_MODULE ": frame size is greater than fifo buffer size\n"); buf->free_buffer(buf); return 0; } @@ -530,7 +531,7 @@ static int parse_frame_payload(demux_mpgaudio_t *this, if (this->cur_frame.size > 0) { payload_size = this->cur_frame.size - 4; this->free_bitrate_count = 0; - } else if (this->free_bitrate_count >= 3) { + } else if (this->free_bitrate_count >= NUM_VALID_FRAMES) { payload_size = this->free_bitrate_size + this->cur_frame.padding - 4; this->cur_frame.size = payload_size + 4; } else { @@ -590,14 +591,14 @@ static int parse_frame_payload(demux_mpgaudio_t *this, if (this->xing_header) { buf->free_buffer(buf); xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - "demux_mpgaudio: found Xing header at offset %PRId64\n", frame_pos); + LOG_MODULE ": found Xing header at offset %PRId64\n", frame_pos); return 1; } this->vbri_header = parse_vbri_header(&this->cur_frame, buf->content, this->cur_frame.size); if (this->vbri_header) { buf->free_buffer(buf); xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - "demux_mpgaudio: found Vbri header at offset %PRId64\n", frame_pos); + LOG_MODULE ": found Vbri header at offset %PRId64\n", frame_pos); return 1; } } @@ -702,7 +703,7 @@ static int demux_mpgaudio_next (demux_mpgaudio_t *this, int decoder_flags, int s this->valid_frames++; break; } else { - if (this->valid_frames > 3) { + if (this->valid_frames >= NUM_VALID_FRAMES) { lprintf("invalid frame. expected mpeg %d, layer %d\n", this->mpg_version, this->mpg_layer); } else { this->mpg_version = this->cur_frame.version_idx + 1; -- cgit v1.2.3 From 9c0f263985b4612e7e67244d6140c087f880602c Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Mon, 21 Jan 2008 23:06:12 +0100 Subject: Fixed logging. --- src/demuxers/id3.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/demuxers/id3.c b/src/demuxers/id3.c index 6b36cc666..cd72646ef 100644 --- a/src/demuxers/id3.c +++ b/src/demuxers/id3.c @@ -349,21 +349,21 @@ int id3v22_parse_tag(input_plugin_t *input, if (tag_header.flags & ID3V22_ZERO_FLAG) { /* invalid flags */ xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid header flags (%02x)\n", tag_header.flags); + LOG_MODULE ": invalid header flags (%02x)\n", tag_header.flags); input->seek (input, tag_header.size - pos, SEEK_CUR); return 0; } if (tag_header.flags & ID3V22_COMPRESS_FLAG) { /* compressed tag: not supported */ xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: compressed tags are not supported\n"); + LOG_MODULE ": compressed tags are not supported\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 0; } if (tag_header.flags & ID3V22_UNSYNCH_FLAG) { /* unsynchronized tag: not supported */ xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: unsynchronized tags are not supported\n"); + LOG_MODULE ": unsynchronized tags are not supported\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 0; } @@ -375,11 +375,11 @@ int id3v22_parse_tag(input_plugin_t *input, if ((pos + tag_frame_header.size) <= tag_header.size) { if (!id3v22_interp_frame(input, stream, &tag_frame_header)) { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid frame content\n"); + LOG_MODULE ": invalid frame content\n"); } } else { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid frame header\n"); + LOG_MODULE ": invalid frame header\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 1; } @@ -391,13 +391,13 @@ int id3v22_parse_tag(input_plugin_t *input, } } else { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: id3v2_parse_frame_header problem\n"); + LOG_MODULE ": id3v2_parse_frame_header problem\n"); return 0; } } return 1; } else { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "id3: id3v2_parse_header problem\n"); + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": id3v2_parse_header problem\n"); return 0; } } @@ -543,14 +543,14 @@ int id3v23_parse_tag(input_plugin_t *input, if (tag_header.flags & ID3V23_ZERO_FLAG) { /* invalid flags */ xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid header flags (%02x)\n", tag_header.flags); + LOG_MODULE ": invalid header flags (%02x)\n", tag_header.flags); input->seek (input, tag_header.size - pos, SEEK_CUR); return 0; } if (tag_header.flags & ID3V23_UNSYNCH_FLAG) { /* unsynchronized tag: not supported */ xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: unsynchronized tags are not supported\n"); + LOG_MODULE ": unsynchronized tags are not supported\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 0; } @@ -568,11 +568,11 @@ int id3v23_parse_tag(input_plugin_t *input, if ((pos + tag_frame_header.size) <= tag_header.size) { if (!id3v23_interp_frame(input, stream, &tag_frame_header)) { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid frame content\n"); + LOG_MODULE ": invalid frame content\n"); } } else { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid frame header\n"); + LOG_MODULE ": invalid frame header\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 1; } @@ -584,13 +584,13 @@ int id3v23_parse_tag(input_plugin_t *input, } } else { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: id3v2_parse_frame_header problem\n"); + LOG_MODULE ": id3v2_parse_frame_header problem\n"); return 0; } } return 1; } else { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "id3v23: id3v2_parse_header problem\n"); + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": id3v2_parse_header problem\n"); return 0; } } @@ -794,7 +794,7 @@ int id3v24_parse_tag(input_plugin_t *input, if (tag_header.flags & ID3V24_ZERO_FLAG) { /* invalid flags */ xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid header flags (%02x)\n", tag_header.flags); + LOG_MODULE ": invalid header flags (%02x)\n", tag_header.flags); input->seek (input, tag_header.size - pos, SEEK_CUR); return 0; } @@ -818,11 +818,11 @@ int id3v24_parse_tag(input_plugin_t *input, if ((pos + tag_frame_header.size) <= tag_header.size) { if (!id3v24_interp_frame(input, stream, &tag_frame_header)) { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid frame content\n"); + LOG_MODULE ": invalid frame content\n"); } } else { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid frame header\n"); + LOG_MODULE ": invalid frame header\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 1; } @@ -834,7 +834,7 @@ int id3v24_parse_tag(input_plugin_t *input, } } else { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: id3v2_parse_frame_header problem\n"); + LOG_MODULE ": id3v2_parse_frame_header problem\n"); return 0; } } @@ -844,7 +844,7 @@ int id3v24_parse_tag(input_plugin_t *input, } return 1; } else { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "id3v23: id3v2_parse_header problem\n"); + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": id3v2_parse_header problem\n"); return 0; } } @@ -858,22 +858,22 @@ int id3v2_parse_tag(input_plugin_t *input, switch(mp3_frame_header[3]) { case 2: - xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.2 tag\n"); + xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2.2 tag\n"); result = id3v22_parse_tag(input, stream, mp3_frame_header); break; case 3: - xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.3 tag\n"); + xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2.3 tag\n"); result = id3v23_parse_tag(input, stream, mp3_frame_header); break; case 4: - xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.4 tag\n"); + xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2.4 tag\n"); result = id3v24_parse_tag(input, stream, mp3_frame_header); break; default: - xprintf(stream->xine, XINE_VERBOSITY_LOG, "Unknown ID3v2 version: 0x%02x.\n", mp3_frame_header[3]); + xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": Unknown ID3v2 version: 0x%02x.\n", mp3_frame_header[3]); } return result; -- cgit v1.2.3 From ada8ce027fc69e8a660e64849f3568c7396a84ae Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Wed, 23 Jan 2008 00:41:55 +0100 Subject: Fixed pts handling, used the amount of data stored in the internal buffer to compensate pts. --- src/libmad/xine_mad_decoder.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/libmad/xine_mad_decoder.c b/src/libmad/xine_mad_decoder.c index be616be36..46464d23b 100644 --- a/src/libmad/xine_mad_decoder.c +++ b/src/libmad/xine_mad_decoder.c @@ -149,6 +149,7 @@ static int head_check(mad_decoder_t *this) { static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { mad_decoder_t *this = (mad_decoder_t *) this_gen; + int bytes_in_buffer_at_pts; lprintf ("decode data, size: %d, decoder_flags: %d\n", buf->size, buf->decoder_flags); @@ -170,6 +171,8 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { this->preview_mode = 1; } + bytes_in_buffer_at_pts = this->bytes_in_buffer; + xine_fast_memcpy (&this->buffer[this->bytes_in_buffer], buf->content, buf->size); this->bytes_in_buffer += buf->size; @@ -271,6 +274,8 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { struct mad_pcm *pcm = &this->synth.pcm; audio_buffer_t *audio_buffer; uint16_t *output; + int bitrate; + int pts_offset; audio_buffer = this->xstream->audio_out->get_buffer (this->xstream->audio_out); output = audio_buffer->mem; @@ -291,7 +296,22 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { } audio_buffer->num_frames = pcm->length; - audio_buffer->vpts = buf->pts; + + /* pts computing */ + if (this->frame.header.bitrate > 0) { + bitrate = this->frame.header.bitrate; + } else { + bitrate = _x_stream_info_get(this->xstream, XINE_STREAM_INFO_AUDIO_BITRATE); + lprintf("offset %d bps\n", bitrate); + } + audio_buffer->vpts = buf->pts; + if (audio_buffer->vpts && (bitrate > 0)) { + pts_offset = (bytes_in_buffer_at_pts * 8 * 90) / (bitrate / 1000); + lprintf("pts: %"PRId64", offset: %d pts, %d bytes\n", buf->pts, pts_offset, bytes_in_buffer_at_pts); + if (audio_buffer->vpts < pts_offset) + pts_offset = audio_buffer->vpts; + audio_buffer->vpts -= pts_offset; + } this->xstream->audio_out->put_buffer (this->xstream->audio_out, audio_buffer, this->xstream); -- cgit v1.2.3 From 3a3fa364d3380c95f453f8f225a601279d8ed056 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 23 Jan 2008 19:40:16 +0000 Subject: Sanity-check ASF header sizes. This fixes a crash in the ASF demuxer, caused by the example exploit file given for CVE-2006-1664. --- src/demuxers/demux_asf.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/demuxers/demux_asf.c b/src/demuxers/demux_asf.c index c4a154f99..4eb9398be 100644 --- a/src/demuxers/demux_asf.c +++ b/src/demuxers/demux_asf.c @@ -379,10 +379,21 @@ static int asf_read_header (demux_asf_t *this) { char *asf_header_buffer = NULL; asf_header_len = get_le64(this); - asf_header_buffer = alloca(asf_header_len); + if (asf_header_len > 4 * 1024 * 1024) + { + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + "demux_asf: asf_read_header: overly-large header? (%"PRIu64" bytes)\n", + asf_header_len); + return 0; + } + + asf_header_buffer = malloc (asf_header_len); if (this->input->read (this->input, asf_header_buffer, asf_header_len) != asf_header_len) + { + free (asf_header_buffer); return 0; + } /* delete previous header */ if (this->asf_header) { @@ -395,7 +406,11 @@ static int asf_read_header (demux_asf_t *this) { */ this->asf_header = asf_header_new(asf_header_buffer, asf_header_len); if (!this->asf_header) + { + free (asf_header_buffer); return 0; + } + free (asf_header_buffer); lprintf("asf header parsing ok\n"); -- cgit v1.2.3 From a6e720ee0284c0c9ec6eb5894ab8e87ee1e53f09 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Thu, 24 Jan 2008 19:28:43 +0100 Subject: Don't discard audio samples forever. Fixed streaming playback --- src/xine-engine/audio_out.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 7fe92d9fe..e9bda70fb 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -1619,6 +1619,7 @@ static void ao_close(xine_audio_port_t *this_gen, xine_stream_t *stream) { } /* make sure there are no more buffers on queue */ fifo_wait_empty(this->out_fifo); + ao_set_property(this_gen, AO_PROP_DISCARD_BUFFERS, 0); } pthread_mutex_lock( &this->driver_lock ); -- cgit v1.2.3 From b24d41f54d441f518c68c120b8ee1a2673bfbe0d Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Thu, 24 Jan 2008 23:38:09 +0000 Subject: Only restore the audio buffer discard setting if it was altered. (Cset 1a0447486a13 broke things differently.) --- src/xine-engine/audio_out.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index e9bda70fb..4dcdb5af0 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -287,6 +287,7 @@ struct audio_fifo_s { int num_buffers; }; +static int ao_get_property (xine_audio_port_t *this_gen, int property); static int ao_set_property (xine_audio_port_t *this_gen, int property, int value); static audio_fifo_t *fifo_new (xine_t *xine) { @@ -1612,14 +1613,17 @@ static void ao_close(xine_audio_port_t *this_gen, xine_stream_t *stream) { xprintf (this->xine, XINE_VERBOSITY_DEBUG, "audio_out: no streams left, closing driver\n"); if (this->audio_loop_running) { + /* make sure there are no more buffers on queue */ if (this->clock->speed == XINE_SPEED_PAUSE || (this->clock->speed != XINE_FINE_SPEED_NORMAL && !this->slow_fast_audio)) { - /* discard buffers, otherwise we'll wait forever */ + int discard = ao_get_property(this_gen, AO_PROP_DISCARD_BUFFERS); + /* discard buffers while waiting, otherwise we'll wait forever */ ao_set_property(this_gen, AO_PROP_DISCARD_BUFFERS, 1); + fifo_wait_empty(this->out_fifo); + ao_set_property(this_gen, AO_PROP_DISCARD_BUFFERS, discard); } - /* make sure there are no more buffers on queue */ - fifo_wait_empty(this->out_fifo); - ao_set_property(this_gen, AO_PROP_DISCARD_BUFFERS, 0); + else + fifo_wait_empty(this->out_fifo); } pthread_mutex_lock( &this->driver_lock ); -- cgit v1.2.3 From 6c456a0d597c2a96aadee33c7af5845de279e478 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Thu, 24 Jan 2008 23:47:36 +0000 Subject: Fix a possible crash on channel change in the DVB plugin. Some 0-sized sections were observed in the TS PMT parser. Test setup details: Test channel is Film 4 on Freeview. Test hardware is a Nova-T Stick (older dib7000m variant). Drivers from v4l-dvb hg, id a1c94c4a05f5, with dib7000m_set_frontend() patched to select OUTMODE_HIGH_Z while tuning. --- src/demuxers/demux_ts.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index 86a14f019..0fa0c971c 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.c @@ -1193,6 +1193,15 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num return; } + if (!section_length) { + free (this->pmt[program_count]); + this->pmt[program_count] = NULL; +#ifdef TS_PMT_LOG + printf ("ts_demux: eek, zero-length section?\n"); +#endif + return; + } + #ifdef TS_PMT_LOG printf ("ts_demux: have all TS packets for the PMT section\n"); #endif -- cgit v1.2.3 From 4e96930cdea7c448f8a47405166575a54c454588 Mon Sep 17 00:00:00 2001 From: Claudio Ciccani Date: Fri, 25 Jan 2008 12:30:58 +0100 Subject: Fixed parsing of keyframes indices (do not assume a specific order betwen "times" and "filepositions"). Parse flv script data only once upon send_headers(). Use relative seeking instead of absolute seeking when seek_time-current_time is below 5 seconds. --- src/demuxers/demux_flv.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_flv.c b/src/demuxers/demux_flv.c index e6a7e234a..a65702207 100644 --- a/src/demuxers/demux_flv.c +++ b/src/demuxers/demux_flv.c @@ -306,9 +306,12 @@ static int parse_flv_var(demux_flv_t *this, num = _X_BE_32(tmp); tmp += 4; if (key && keylen == 5 && !strncmp(key, "times", 5)) { - free (this->index); - this->index = xine_xcalloc(num, sizeof(flv_index_entry_t)); - this->num_indices = num; + if (!this->index || this->num_indices != num) { + if (this->index) + free(this->index); + this->index = xine_xcalloc(num, sizeof(flv_index_entry_t)); + this->num_indices = num; + } for (num = 0; num < this->num_indices && tmp < end; num++) { if (*tmp++ == FLV_DATA_TYPE_NUMBER) { lprintf(" got number (%f)\n", BE_F64(tmp)); @@ -319,16 +322,20 @@ static int parse_flv_var(demux_flv_t *this, break; } if (key && keylen == 13 && !strncmp(key, "filepositions", 13)) { - if (this->index && this->num_indices == num) { - for (num = 0; num < this->num_indices && tmp < end; num++) { - if (*tmp++ == FLV_DATA_TYPE_NUMBER) { - lprintf(" got number (%f)\n", BE_F64(tmp)); - this->index[num].offset = BE_F64(tmp); - tmp += 8; - } + if (!this->index || this->num_indices != num) { + if (this->index) + free(this->index); + this->index = xine_xcalloc(num, sizeof(flv_index_entry_t)); + this->num_indices = num; + } + for (num = 0; num < this->num_indices && tmp < end; num++) { + if (*tmp++ == FLV_DATA_TYPE_NUMBER) { + lprintf(" got number (%f)\n", BE_F64(tmp)); + this->index[num].offset = BE_F64(tmp); + tmp += 8; } - break; } + break; } while (num-- && tmp < end) { len = parse_flv_var(this, tmp, end-tmp, NULL, 0); @@ -501,9 +508,9 @@ static int read_flv_packet(demux_flv_t *this, int preview) { case FLV_TAG_TYPE_SCRIPT: lprintf(" got script tag...\n"); - parse_flv_script(this, remaining_bytes); - if (preview) { + parse_flv_script(this, remaining_bytes); + /* send init info to decoders using script information as reference */ if (!this->got_audio_header && this->audiocodec) { buf = this->audio_fifo->buffer_pool_alloc(this->audio_fifo); @@ -569,7 +576,9 @@ static int read_flv_packet(demux_flv_t *this, int preview) { } return this->status; - } + } + /* no preview */ + this->input->seek(this->input, remaining_bytes, SEEK_CUR); continue; default: @@ -661,7 +670,7 @@ static void seek_flv_file(demux_flv_t *this, off_t seek_pos, int seek_pts) { } } - if (seek_pos && this->videocodec) { + if (seek_pos && this->videocodec && abs(seek_pts-this->cur_pts) > 300000) { off_t pos, size; pos = this->input->get_current_pos(this->input); -- cgit v1.2.3 From d8d66952029c89a0b4ffcedc0c22f56c9c01c0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Fri, 25 Jan 2008 22:46:31 +0100 Subject: Advertise proper support for FLAC files. application/x-flac is not reported anywhere. Both file(1) and shared-mime-info report audio/x-flac. Xiph wiki[1] reports audio/flac as being queued for registration. Report both audio/x-flac and audio/flac for compatibility. [1] http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions --- src/combined/demux_flac.c | 3 ++- src/demuxers/demux_flac.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/combined/demux_flac.c b/src/combined/demux_flac.c index 85f98e876..fdc7ab7ea 100644 --- a/src/combined/demux_flac.c +++ b/src/combined/demux_flac.c @@ -732,7 +732,8 @@ get_extensions (demux_class_t *this_gen) { static char * get_mimetypes (demux_class_t *this_gen) { - return "application/x-flac: flac: FLAC Audio;"; + return "audio/x-flac: flac: FLAC Audio;" + "audio/flac: flac: FLAC Audio;"; } static void diff --git a/src/demuxers/demux_flac.c b/src/demuxers/demux_flac.c index 3afb5b031..23e2faef9 100644 --- a/src/demuxers/demux_flac.c +++ b/src/demuxers/demux_flac.c @@ -544,7 +544,8 @@ static const char *get_extensions (demux_class_t *this_gen) { } static const char *get_mimetypes (demux_class_t *this_gen) { - return NULL; + return "audio/x-flac: flac: FLAC Audio;" + "audio/flac: flac: FLAC Audio;"; } static void class_dispose (demux_class_t *this_gen) { -- cgit v1.2.3 From 499a81b162ecb54d061f103b51b33f024cd2eb30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Fri, 25 Jan 2008 22:49:26 +0100 Subject: Report unofficial mimetypes (x- variants) for the Ogg demuxer too. --- src/demuxers/demux_ogg.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c index d1b522727..82eefdf75 100644 --- a/src/demuxers/demux_ogg.c +++ b/src/demuxers/demux_ogg.c @@ -2119,8 +2119,11 @@ static const char *anx_get_extensions (demux_class_t *this_gen) { static const char *anx_get_mimetypes (demux_class_t *this_gen) { return "application/annodex: anx: Annodex media;" + "application/x-annodex: anx: Annodex media;" "audio/annodex: axa: Annodex audio;" + "audio/x-annodex: axa: Annodex audio;" "video/annodex: axv: Annodex video;"; + "video/x-annodex: axv: Annodex video;"; } static void anx_class_dispose (demux_class_t *this_gen) { @@ -2162,8 +2165,11 @@ static const char *ogg_get_extensions (demux_class_t *this_gen) { static const char *ogg_get_mimetypes (demux_class_t *this_gen) { return "application/ogg: ogx: Ogg Stream;" + "application/x-ogg: ogx: Ogg Stream;" "audio/ogg: oga: Ogg Audio;" + "audio/x-ogg: oga: Ogg Audio;" "video/ogg: ogv: Ogg Video;"; + "video/x-ogg: ogv: Ogg Video;"; } static void ogg_class_dispose (demux_class_t *this_gen) { -- cgit v1.2.3 From ef96216c903e38dc3c8b835efc9bf27605179249 Mon Sep 17 00:00:00 2001 From: Claudio Ciccani Date: Fri, 25 Jan 2008 12:30:58 +0100 Subject: Fixed parsing of keyframes indices (do not assume a specific order betwen "times" and "filepositions"). Parse flv script data only once upon send_headers(). Use relative seeking instead of absolute seeking when seek_time-current_time is below 5 seconds. (transplanted from 689daba9823670864eaef213733987196be21acc) --HG-- extra : transplant_source : %3CA%D9%CBuM%14%DAR%F8%89K%EF%13%83%17%9A%F7%AB%8F --- src/demuxers/demux_flv.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_flv.c b/src/demuxers/demux_flv.c index bdb33d21d..a1f0b3a7b 100644 --- a/src/demuxers/demux_flv.c +++ b/src/demuxers/demux_flv.c @@ -306,10 +306,12 @@ static int parse_flv_var(demux_flv_t *this, num = _X_BE_32(tmp); tmp += 4; if (key && keylen == 5 && !strncmp(key, "times", 5)) { - if (this->index) - free (this->index); - this->index = xine_xmalloc(num*sizeof(flv_index_entry_t)); - this->num_indices = num; + if (!this->index || this->num_indices != num) { + if (this->index) + free(this->index); + this->index = xine_xmalloc(num*sizeof(flv_index_entry_t)); + this->num_indices = num; + } for (num = 0; num < this->num_indices && tmp < end; num++) { if (*tmp++ == FLV_DATA_TYPE_NUMBER) { lprintf(" got number (%f)\n", BE_F64(tmp)); @@ -320,16 +322,20 @@ static int parse_flv_var(demux_flv_t *this, break; } if (key && keylen == 13 && !strncmp(key, "filepositions", 13)) { - if (this->index && this->num_indices == num) { - for (num = 0; num < this->num_indices && tmp < end; num++) { - if (*tmp++ == FLV_DATA_TYPE_NUMBER) { - lprintf(" got number (%f)\n", BE_F64(tmp)); - this->index[num].offset = BE_F64(tmp); - tmp += 8; - } + if (!this->index || this->num_indices != num) { + if (this->index) + free(this->index); + this->index = xine_xmalloc(num*sizeof(flv_index_entry_t)); + this->num_indices = num; + } + for (num = 0; num < this->num_indices && tmp < end; num++) { + if (*tmp++ == FLV_DATA_TYPE_NUMBER) { + lprintf(" got number (%f)\n", BE_F64(tmp)); + this->index[num].offset = BE_F64(tmp); + tmp += 8; } - break; } + break; } while (num-- && tmp < end) { len = parse_flv_var(this, tmp, end-tmp, NULL, 0); @@ -502,9 +508,9 @@ static int read_flv_packet(demux_flv_t *this, int preview) { case FLV_TAG_TYPE_SCRIPT: lprintf(" got script tag...\n"); - parse_flv_script(this, remaining_bytes); - if (preview) { + parse_flv_script(this, remaining_bytes); + /* send init info to decoders using script information as reference */ if (!this->got_audio_header && this->audiocodec) { buf = this->audio_fifo->buffer_pool_alloc(this->audio_fifo); @@ -570,7 +576,9 @@ static int read_flv_packet(demux_flv_t *this, int preview) { } return this->status; - } + } + /* no preview */ + this->input->seek(this->input, remaining_bytes, SEEK_CUR); continue; default: @@ -662,7 +670,7 @@ static void seek_flv_file(demux_flv_t *this, off_t seek_pos, int seek_pts) { } } - if (seek_pos && this->videocodec) { + if (seek_pos && this->videocodec && abs(seek_pts-this->cur_pts) > 300000) { off_t pos, size; pos = this->input->get_current_pos(this->input); -- cgit v1.2.3 From d9e8c92bbc90bc0c2d8a4b71059936176bf2d6d0 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Fri, 25 Jan 2008 13:30:34 +0000 Subject: Always use xine_xmalloc in plugin class init; avoids uninitialised pointers. --- src/post/audio/stretch.c | 2 +- src/post/audio/upmix.c | 2 +- src/post/audio/upmix_mono.c | 2 +- src/post/audio/volnorm.c | 2 +- src/post/visualizations/fftgraph.c | 2 +- src/post/visualizations/fftscope.c | 2 +- src/post/visualizations/fooviz.c | 2 +- src/post/visualizations/oscope.c | 2 +- src/vdr/post_vdr_audio.c | 2 +- src/vdr/post_vdr_video.c | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/post/audio/stretch.c b/src/post/audio/stretch.c index bc079fd8d..5a0382895 100644 --- a/src/post/audio/stretch.c +++ b/src/post/audio/stretch.c @@ -662,7 +662,7 @@ static post_plugin_t *stretch_open_plugin(post_class_t *class_gen, int inputs, /* plugin class initialization function */ void *stretch_init_plugin(xine_t *xine, void *data) { - post_class_stretch_t *class = (post_class_stretch_t *)malloc(sizeof(post_class_stretch_t)); + post_class_stretch_t *class = (post_class_stretch_t *)xine_xmalloc(sizeof(post_class_stretch_t)); if (!class) return NULL; diff --git a/src/post/audio/upmix.c b/src/post/audio/upmix.c index 30fbb452b..573354450 100644 --- a/src/post/audio/upmix.c +++ b/src/post/audio/upmix.c @@ -417,7 +417,7 @@ static post_plugin_t *upmix_open_plugin(post_class_t *class_gen, int inputs, /* plugin class initialization function */ void *upmix_init_plugin(xine_t *xine, void *data) { - post_class_upmix_t *class = (post_class_upmix_t *)malloc(sizeof(post_class_upmix_t)); + post_class_upmix_t *class = (post_class_upmix_t *)xine_xmalloc(sizeof(post_class_upmix_t)); if (!class) return NULL; diff --git a/src/post/audio/upmix_mono.c b/src/post/audio/upmix_mono.c index 53fd23109..82ceb1877 100644 --- a/src/post/audio/upmix_mono.c +++ b/src/post/audio/upmix_mono.c @@ -332,7 +332,7 @@ static post_plugin_t *upmix_mono_open_plugin(post_class_t *class_gen, int inputs /* plugin class initialization function */ void *upmix_mono_init_plugin(xine_t *xine, void *data) { - post_class_upmix_mono_t *class = (post_class_upmix_mono_t *)malloc(sizeof(post_class_upmix_mono_t)); + post_class_upmix_mono_t *class = (post_class_upmix_mono_t *)xine_xmalloc(sizeof(post_class_upmix_mono_t)); if (!class) return NULL; diff --git a/src/post/audio/volnorm.c b/src/post/audio/volnorm.c index 4fb2a0411..de4ebde87 100644 --- a/src/post/audio/volnorm.c +++ b/src/post/audio/volnorm.c @@ -450,7 +450,7 @@ static post_plugin_t *volnorm_open_plugin(post_class_t *class_gen, int inputs, /* plugin class initialization function */ void *volnorm_init_plugin(xine_t *xine, void *data) { - post_class_volnorm_t *class = (post_class_volnorm_t *)malloc(sizeof(post_class_volnorm_t)); + post_class_volnorm_t *class = (post_class_volnorm_t *)xine_xmalloc(sizeof(post_class_volnorm_t)); if (!class) return NULL; diff --git a/src/post/visualizations/fftgraph.c b/src/post/visualizations/fftgraph.c index c31c529f2..39d17c730 100644 --- a/src/post/visualizations/fftgraph.c +++ b/src/post/visualizations/fftgraph.c @@ -455,7 +455,7 @@ static post_plugin_t *fftgraph_open_plugin(post_class_t *class_gen, int inputs, /* plugin class initialization function */ void *fftgraph_init_plugin(xine_t *xine, void *data) { - post_class_fftgraph_t *class = (post_class_fftgraph_t *)malloc(sizeof(post_class_fftgraph_t)); + post_class_fftgraph_t *class = (post_class_fftgraph_t *)xine_xmalloc(sizeof(post_class_fftgraph_t)); if (!class) return NULL; diff --git a/src/post/visualizations/fftscope.c b/src/post/visualizations/fftscope.c index dd474bd6f..1a9ea905a 100644 --- a/src/post/visualizations/fftscope.c +++ b/src/post/visualizations/fftscope.c @@ -476,7 +476,7 @@ static post_plugin_t *fftscope_open_plugin(post_class_t *class_gen, int inputs, /* plugin class initialization function */ void *fftscope_init_plugin(xine_t *xine, void *data) { - post_class_fftscope_t *class = (post_class_fftscope_t *)malloc(sizeof(post_class_fftscope_t)); + post_class_fftscope_t *class = (post_class_fftscope_t *)xine_xmalloc(sizeof(post_class_fftscope_t)); if (!class) return NULL; diff --git a/src/post/visualizations/fooviz.c b/src/post/visualizations/fooviz.c index 2cf77cadc..3e5702168 100644 --- a/src/post/visualizations/fooviz.c +++ b/src/post/visualizations/fooviz.c @@ -287,7 +287,7 @@ static post_plugin_t *fooviz_open_plugin(post_class_t *class_gen, int inputs, /* plugin class initialization function */ static void *fooviz_init_plugin(xine_t *xine, void *data) { - post_class_fooviz_t *class = (post_class_fooviz_t *)malloc(sizeof(post_class_fooviz_t)); + post_class_fooviz_t *class = (post_class_fooviz_t *)xine_xmalloc(sizeof(post_class_fooviz_t)); if (!class) return NULL; diff --git a/src/post/visualizations/oscope.c b/src/post/visualizations/oscope.c index 1d498980a..7c9faeeaa 100644 --- a/src/post/visualizations/oscope.c +++ b/src/post/visualizations/oscope.c @@ -358,7 +358,7 @@ static post_plugin_t *oscope_open_plugin(post_class_t *class_gen, int inputs, /* plugin class initialization function */ void *oscope_init_plugin(xine_t *xine, void *data) { - post_class_oscope_t *class = (post_class_oscope_t *)malloc(sizeof(post_class_oscope_t)); + post_class_oscope_t *class = (post_class_oscope_t *)xine_xmalloc(sizeof(post_class_oscope_t)); if (!class) return NULL; diff --git a/src/vdr/post_vdr_audio.c b/src/vdr/post_vdr_audio.c index ca45ecd35..49de8f9cf 100644 --- a/src/vdr/post_vdr_audio.c +++ b/src/vdr/post_vdr_audio.c @@ -71,7 +71,7 @@ static void vdr_audio_port_put_buffer(xine_audio_port_t *port_gen, aud void *vdr_audio_init_plugin(xine_t *xine, void *data) { - post_class_t *class = (post_class_t *)malloc(sizeof (post_class_t)); + post_class_t *class = (post_class_t *)xine_xmalloc(sizeof (post_class_t)); if (!class) return NULL; diff --git a/src/vdr/post_vdr_video.c b/src/vdr/post_vdr_video.c index ff6c32504..4d1055aaf 100644 --- a/src/vdr/post_vdr_video.c +++ b/src/vdr/post_vdr_video.c @@ -94,7 +94,7 @@ static int vdr_video_draw(vo_frame_t *frame, xine_stream_t *stream); void *vdr_video_init_plugin(xine_t *xine, void *data) { - post_class_t *class = (post_class_t *)malloc(sizeof (post_class_t)); + post_class_t *class = (post_class_t *)xine_xmalloc(sizeof (post_class_t)); if (!class) return NULL; -- cgit v1.2.3 From c20f6876baae32c2ef18999def0245bf0c23000a Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Tue, 12 Feb 2008 16:39:57 +0000 Subject: Avoid possible excess linkage in the tvtime plugin. Its convenience lib needs $(XINE_LIB) but it gets that when it's linked into the shared lib. --- src/post/deinterlace/plugins/Makefile.am | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/post/deinterlace/plugins/Makefile.am b/src/post/deinterlace/plugins/Makefile.am index 2bc8abd58..1ff139d29 100644 --- a/src/post/deinterlace/plugins/Makefile.am +++ b/src/post/deinterlace/plugins/Makefile.am @@ -48,7 +48,6 @@ libdeinterlaceplugins_la_SOURCES = \ scalerbob.c \ kdetv_greedyh.c \ kdetv_tomsmocomp.c -libdeinterlaceplugins_la_LIBADD = $(XINE_LIB) libdeinterlaceplugins_la_CFLAGS = $(VISIBILITY_FLAG) $(AM_CFLAGS) libdeinterlaceplugins_la_LDFLAGS = -avoid-version -module -- cgit v1.2.3 From 07a99628d88294244393abc463ae193e2e97f08b Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Thu, 14 Feb 2008 21:16:43 +0100 Subject: Fixed mp3 sniff code. Fixed bug 4 sample playback (nilbymouthclapton.112.mp3). (transplanted from 4843103240d4fc85d31bd210194a98c1e1bdbd7a) --HG-- extra : transplant_source : HC%102%40%D4%FC%85%D3%1B%D2%10%19J%98%C1%E1%BD%BDz --- src/demuxers/demux_mpgaudio.c | 59 +++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index 82a7dd7ab..56759dd4b 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -626,11 +626,12 @@ static int parse_frame_payload(demux_mpgaudio_t *this, * 32-bit MP3 frame header. * return 1 if found, 0 if not found */ -static int sniff_buffer_looks_like_mp3 (uint8_t *buf, int buflen) +static int sniff_buffer_looks_like_mp3 (uint8_t *buf, int buflen, int *version, int *layer) { int offset; mpg_audio_frame_t frame; + *version = *layer = 0; if (buf == NULL) return 0; @@ -639,20 +640,21 @@ static int sniff_buffer_looks_like_mp3 (uint8_t *buf, int buflen) if (parse_frame_header(&frame, buf + offset)) { size_t size = frame.size; - /* Since one frame is available, is there another frame - * just to be sure this is more likely to be a real MP3 - * buffer? */ - offset += size; - - if (offset + 4 >= buflen) { - return 0; - } + if (size > 0) { + /* Since one frame is available, is there another frame + * just to be sure this is more likely to be a real MP3 + * buffer? */ + if (offset + size + 4 >= buflen) { + return 0; + } - if (parse_frame_header(&frame, buf + offset)) { - lprintf("mpeg audio frame detected\n"); - return 1; + if (parse_frame_header(&frame, buf + offset + size)) { + *version = frame.version_idx + 1; + *layer = frame.layer; + lprintf("frame detected, mpeg %d layer %d\n", *version, *layer); + return 1; + } } - break; } } return 0; @@ -806,11 +808,13 @@ static int demux_mpgaudio_read_head(input_plugin_t *input, uint8_t *buf) { * mp3 stream detection * return 1 if detected, 0 otherwise */ -static int detect_mpgaudio_file(input_plugin_t *input) { +static int detect_mpgaudio_file(input_plugin_t *input, + int *version, int *layer) { uint8_t buf[MAX_PREVIEW_SIZE]; int preview_len; uint32_t head; + *version = *layer = 0; preview_len = demux_mpgaudio_read_head(input, buf); if (preview_len < 4) return 0; @@ -837,7 +841,7 @@ static int detect_mpgaudio_file(input_plugin_t *input) { lprintf("cannot read mp3 frame header\n"); return 0; } - if (!sniff_buffer_looks_like_mp3(&buf[10 + tag_size], preview_len - 10 - tag_size)) { + if (!sniff_buffer_looks_like_mp3(&buf[10 + tag_size], preview_len - 10 - tag_size, version, layer)) { lprintf ("sniff_buffer_looks_like_mp3 failed\n"); return 0; } else { @@ -845,7 +849,7 @@ static int detect_mpgaudio_file(input_plugin_t *input) { } } else if (head == MPEG_MARKER) { return 0; - } else if (!sniff_buffer_looks_like_mp3(buf, preview_len)) { + } else if (!sniff_buffer_looks_like_mp3(buf, preview_len, version, layer)) { lprintf ("sniff_buffer_looks_like_mp3 failed\n"); return 0; } @@ -1112,13 +1116,15 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str input_plugin_t *input) { demux_mpgaudio_t *this; + int version = 0; + int layer = 0; lprintf("trying to open %s...\n", input->get_mrl(input)); switch (stream->content_detection_method) { case METHOD_BY_CONTENT: { - if (!detect_mpgaudio_file(input)) + if (!detect_mpgaudio_file(input, &version, &layer)) return NULL; } break; @@ -1141,7 +1147,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str default: return NULL; } - + this = xine_xmalloc (sizeof (demux_mpgaudio_t)); this->demux_plugin.send_headers = demux_mpgaudio_send_headers; @@ -1153,12 +1159,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str this->demux_plugin.get_capabilities = demux_mpgaudio_get_capabilities; this->demux_plugin.get_optional_data = demux_mpgaudio_get_optional_data; this->demux_plugin.demux_class = class_gen; - - this->input = input; - this->audio_fifo = stream->audio_fifo; - this->status = DEMUX_FINISHED; - this->stream = stream; - + + this->input = input; + this->audio_fifo = stream->audio_fifo; + this->status = DEMUX_FINISHED; + this->stream = stream; + + this->mpg_version = version; + this->mpg_layer = layer; + if (version || layer) { + this->valid_frames = NUM_VALID_FRAMES; + } return &this->demux_plugin; } -- cgit v1.2.3 From b0c97c912f4ee5bc34692d7d737979b390ac621b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Fri, 25 Jan 2008 23:02:29 +0100 Subject: Advertise audio/x-wavpack mime type for WavPack demuxer. --HG-- extra : transplant_source : iT%08m0%F6%E0%8B-%24%1F%BC%EB%24%25.%C0p%E2%14 --- src/combined/demux_wavpack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/combined/demux_wavpack.c b/src/combined/demux_wavpack.c index e8081bca9..a79f70627 100644 --- a/src/combined/demux_wavpack.c +++ b/src/combined/demux_wavpack.c @@ -391,7 +391,7 @@ static const char *get_extensions (demux_class_t *const this_gen) { } static const char *get_mimetypes (demux_class_t *const this_gen) { - return NULL; + return "audio/x-wavpack"; } static void class_dispose (demux_class_t *const this_gen) { -- cgit v1.2.3 From da5afb9cc5c1369b99db81f3c254eaf69642b777 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sat, 26 Jan 2008 01:39:52 +0000 Subject: Fix a few recently-caused compiler warnings. --- src/demuxers/demux_mpgaudio.c | 4 ++-- src/demuxers/demux_ogg.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index 180a9752c..1bea02302 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -591,14 +591,14 @@ static int parse_frame_payload(demux_mpgaudio_t *this, if (this->xing_header) { buf->free_buffer(buf); xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": found Xing header at offset %PRId64\n", frame_pos); + LOG_MODULE ": found Xing header at offset %"PRId64"\n", frame_pos); return 1; } this->vbri_header = parse_vbri_header(&this->cur_frame, buf->content, this->cur_frame.size); if (this->vbri_header) { buf->free_buffer(buf); xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": found Vbri header at offset %PRId64\n", frame_pos); + LOG_MODULE ": found Vbri header at offset %"PRId64"\n", frame_pos); return 1; } } diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c index 82eefdf75..dc867e5f1 100644 --- a/src/demuxers/demux_ogg.c +++ b/src/demuxers/demux_ogg.c @@ -2122,7 +2122,7 @@ static const char *anx_get_mimetypes (demux_class_t *this_gen) { "application/x-annodex: anx: Annodex media;" "audio/annodex: axa: Annodex audio;" "audio/x-annodex: axa: Annodex audio;" - "video/annodex: axv: Annodex video;"; + "video/annodex: axv: Annodex video;" "video/x-annodex: axv: Annodex video;"; } @@ -2168,7 +2168,7 @@ static const char *ogg_get_mimetypes (demux_class_t *this_gen) { "application/x-ogg: ogx: Ogg Stream;" "audio/ogg: oga: Ogg Audio;" "audio/x-ogg: oga: Ogg Audio;" - "video/ogg: ogv: Ogg Video;"; + "video/ogg: ogv: Ogg Video;" "video/x-ogg: ogv: Ogg Video;"; } -- cgit v1.2.3 From c018c8408df06dcf47c2c924e0b88a6a048573de Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sat, 26 Jan 2008 17:42:56 +0000 Subject: Quick hack to allow configuration of the V4L ALSA audio input device. --- src/input/input_v4l.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/input/input_v4l.c b/src/input/input_v4l.c index 34f6a0684..d0558b492 100644 --- a/src/input/input_v4l.c +++ b/src/input/input_v4l.c @@ -93,6 +93,9 @@ static const resolution_t resolutions[] = { #define NUM_RESOLUTIONS (sizeof(resolutions)/sizeof(resolutions[0])) #define RADIO_DEV "/dev/radio0" #define VIDEO_DEV "/dev/video0" +#ifdef HAVE_ALSA +#define AUDIO_DEV "plughw:0,0" +#endif #if !defined(NDELAY) && defined(O_NDELAY) #define FNDELAY O_NDELAY @@ -1701,6 +1704,9 @@ static input_plugin_t *v4l_class_get_instance (input_class_t *cls_gen, { /* v4l_input_class_t *cls = (v4l_input_class_t *) cls_gen; */ v4l_input_plugin_t *this; +#ifdef HAVE_ALSA + cfg_entry_t *entry; +#endif char *mrl = strdup(data); /* Example mrl: v4l:/Television/62500 */ @@ -1721,13 +1727,14 @@ static input_plugin_t *v4l_class_get_instance (input_class_t *cls_gen, this->event_queue = NULL; this->scr = NULL; #ifdef HAVE_ALSA - this->pcm_name = NULL; this->pcm_data = NULL; this->pcm_hwparams = NULL; /* Audio */ this->pcm_stream = SND_PCM_STREAM_CAPTURE; - this->pcm_name = strdup("plughw:0,0"); + entry = this->stream->xine->config->lookup_entry(this->stream->xine->config, + "media.video4linux.audio_device"); + this->pcm_name = strdup (entry->str_value); this->audio_capture = 1; #endif this->rate = 44100; @@ -1910,7 +1917,15 @@ static void *init_video_class (xine_t *xine, void *data) _("v4l video device"), _("The path to your Video4Linux video device."), 10, NULL, NULL); - +#ifdef HAVE_ALSA + config->register_filename (config, "media.video4linux.audio_device", + AUDIO_DEV, 0, + _("v4l ALSA audio input device"), + _("The name of the audio device which corresponds " + "to your Video4Linux video device."), + 10, NULL, NULL); +#endif + return this; } -- cgit v1.2.3 From 99a04ec01e35ff6e0c84195381ab55f2f8e04b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sun, 27 Jan 2008 13:10:07 +0100 Subject: Avoid one recursive make by declaring all the installed headers inside include/Makefile.am. --- src/xine-engine/audio_out.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 855051582..34f982d18 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -1626,6 +1626,7 @@ static void ao_close(xine_audio_port_t *this_gen, xine_stream_t *stream) { } else fifo_wait_empty(this->out_fifo); + ao_set_property(this_gen, AO_PROP_DISCARD_BUFFERS, 0); } pthread_mutex_lock( &this->driver_lock ); -- cgit v1.2.3 From d3801a2f741ac6931824bfef41ea0e7c39aa193d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sun, 27 Jan 2008 13:52:33 +0100 Subject: Move base64 header to xine-utils as we don't want it installed. --HG-- rename : include/xine/base64.h => src/xine-utils/base64.h --- src/input/input_cdda.c | 1 + src/xine-engine/configfile.c | 1 + src/xine-utils/Makefile.am | 1 + src/xine-utils/base64.c | 2 +- src/xine-utils/base64.h | 94 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 src/xine-utils/base64.h (limited to 'src') diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c index 0e378c299..e2c32d509 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -69,6 +69,7 @@ #include #include #include "media_helper.h" +#include "base64.h" #if defined(__sun) #define DEFAULT_CDDA_DEVICE "/vol/dev/aliases/cdrom0" diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index 550c0372f..8ac0e7eb3 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -33,6 +33,7 @@ #include #include #include "bswap.h" +#include "base64.h" #define LOG_MODULE "configfile" #define LOG_VERBOSE diff --git a/src/xine-utils/Makefile.am b/src/xine-utils/Makefile.am index d3b4c2b1c..6509f1178 100644 --- a/src/xine-utils/Makefile.am +++ b/src/xine-utils/Makefile.am @@ -16,6 +16,7 @@ endif endif libxineutils_la_SOURCES = $(pppc_files) \ + base64.h \ base64.c \ cpu_accel.c \ color.c \ diff --git a/src/xine-utils/base64.c b/src/xine-utils/base64.c index 102f15256..583723cdc 100644 --- a/src/xine-utils/base64.c +++ b/src/xine-utils/base64.c @@ -92,7 +92,7 @@ #include #include -#include +#include "base64.h" /* NOTE: This is not true RFC822 anymore. The use of the characters diff --git a/src/xine-utils/base64.h b/src/xine-utils/base64.h new file mode 100644 index 000000000..61d362150 --- /dev/null +++ b/src/xine-utils/base64.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2000 Robert Kaye + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Base64 encoding modified for Musicbrainz + * relicensed under the GNU General Public License for use in xine-lib + */ +/* -------------------------------------------------------------------------- + + MusicBrainz -- The Internet music metadatabase + + Copyright (C) 2000 Robert Kaye + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + +----------------------------------------------------------------------------*/ +/* + * Program: RFC-822 routines (originally from SMTP) + * + * Author: Mark Crispin + * Networks and Distributed Computing + * Computing & Communications + * University of Washington + * Administration Building, AG-44 + * Seattle, WA 98195 + * Internet: MRC@CAC.Washington.EDU + * + * Date: 27 July 1988 + * Last Edited: 10 September 1998 + * + * Sponsorship: The original version of this work was developed in the + * Symbolic Systems Resources Group of the Knowledge Systems + * Laboratory at Stanford University in 1987-88, and was funded + * by the Biomedical Research Technology Program of the National + * Institutes of Health under grant number RR-00785. + * + * Original version Copyright 1988 by The Leland Stanford Junior University + * Copyright 1998 by the University of Washington + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notices appear in all copies and that both the + * above copyright notices and this permission notice appear in supporting + * documentation, and that the name of the University of Washington or The + * Leland Stanford Junior University not be used in advertising or publicity + * pertaining to distribution of the software without specific, written prior + * permission. This software is made available "as is", and + * THE UNIVERSITY OF WASHINGTON AND THE LELAND STANFORD JUNIOR UNIVERSITY + * DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO THIS SOFTWARE, + * INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF + * WASHINGTON OR THE LELAND STANFORD JUNIOR UNIVERSITY BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, TORT (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef BASE64_H +#define BASE64_H + +unsigned char *xine_rfc822_binary (void *src,unsigned long srcl,unsigned long *len) XINE_PROTECTED; + +char *xine_base64_encode (const void *src, unsigned long srcl, unsigned long *len) XINE_PROTECTED; +void *xine_base64_decode (const char *src, unsigned long srcl, unsigned long *len) XINE_PROTECTED; + +#endif -- cgit v1.2.3 From 7c166d8088e0a128a7b223c62fd2b8dc1a1b70c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sun, 27 Jan 2008 13:58:31 +0100 Subject: Rename base64 functions to _x_ as they should not be part of the public API. Note that these will be removed as soon as -libavutil branch is merged, in favour of libavutil's base64 implementation. --- src/input/input_cdda.c | 2 +- src/xine-engine/configfile.c | 4 ++-- src/xine-utils/base64.c | 6 +++--- src/xine-utils/base64.h | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c index e2c32d509..64495c433 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -1936,7 +1936,7 @@ static void _cdda_cdindex(cdda_input_plugin_t *this, cdrom_toc *toc) { sha_final(digest, &sha); - base64 = xine_rfc822_binary(digest, 20, &size); + base64 = _x_rfc822_binary(digest, 20, &size); base64[size] = 0; _x_meta_info_set_utf8(this->stream, XINE_META_INFO_CDINDEX_DISCID, base64); diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index 8ac0e7eb3..37a4e38ad 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -1342,7 +1342,7 @@ static char* config_get_serialized_entry (config_values_t *this, const char *key } /* and now the output encoding */ - output = xine_base64_encode (buffer, total_len, &output_len); + output = _x_base64_encode (buffer, total_len, &output_len); free(buffer); } @@ -1414,7 +1414,7 @@ static char* config_register_serialized_entry (config_values_t *this, const char int value_count = 0; int i; - output = xine_base64_decode (value, strlen(value), &output_len); + output = _x_base64_decode (value, strlen(value), &output_len); pos = 0; pos += bytes = get_int(output, output_len, pos, &type); diff --git a/src/xine-utils/base64.c b/src/xine-utils/base64.c index 583723cdc..5730f30db 100644 --- a/src/xine-utils/base64.c +++ b/src/xine-utils/base64.c @@ -107,7 +107,7 @@ * Returns: destination as BASE64 */ -unsigned char *xine_rfc822_binary (void *src,unsigned long srcl,unsigned long *len) +unsigned char *_x_rfc822_binary (void *src,unsigned long srcl,unsigned long *len) { unsigned char *ret,*d; unsigned char *s = (unsigned char *) src; @@ -134,7 +134,7 @@ unsigned char *xine_rfc822_binary (void *src,unsigned long srcl,unsigned long *l return ret; /* return the resulting string */ } -char *xine_base64_encode (const void *src, unsigned long srcl, unsigned long *len) +char *_x_base64_encode (const void *src, unsigned long srcl, unsigned long *len) { char *ret, *d; unsigned char *s = (unsigned char *) src; @@ -157,7 +157,7 @@ char *xine_base64_encode (const void *src, unsigned long srcl, unsigned long *le return ret; /* return the resulting string */ } -void *xine_base64_decode (const char *src, unsigned long srcl, unsigned long *len) +void *_x_base64_decode (const char *src, unsigned long srcl, unsigned long *len) { void *ret; unsigned char *d; diff --git a/src/xine-utils/base64.h b/src/xine-utils/base64.h index 61d362150..f22f9b0c4 100644 --- a/src/xine-utils/base64.h +++ b/src/xine-utils/base64.h @@ -86,9 +86,9 @@ #ifndef BASE64_H #define BASE64_H -unsigned char *xine_rfc822_binary (void *src,unsigned long srcl,unsigned long *len) XINE_PROTECTED; +unsigned char *_x_rfc822_binary (void *src,unsigned long srcl,unsigned long *len) XINE_PROTECTED; -char *xine_base64_encode (const void *src, unsigned long srcl, unsigned long *len) XINE_PROTECTED; -void *xine_base64_decode (const char *src, unsigned long srcl, unsigned long *len) XINE_PROTECTED; +char *_x_base64_encode (const void *src, unsigned long srcl, unsigned long *len) XINE_PROTECTED; +void *_x_base64_decode (const char *src, unsigned long srcl, unsigned long *len) XINE_PROTECTED; #endif -- cgit v1.2.3 From b5f4ef58160be1126dd5226f89fd704b24006760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sun, 27 Jan 2008 16:07:42 +0100 Subject: Remove another recursive make invocation, build the vcd plugin inside src/input even if the source files are in src/input/vcd. --- src/input/Makefile.am | 17 ++++++++++++----- src/input/vcd/Makefile.am | 13 ------------- 2 files changed, 12 insertions(+), 18 deletions(-) delete mode 100644 src/input/vcd/Makefile.am (limited to 'src') diff --git a/src/input/Makefile.am b/src/input/Makefile.am index ca7e6dabd..64ba0ce54 100644 --- a/src/input/Makefile.am +++ b/src/input/Makefile.am @@ -11,9 +11,6 @@ AM_LDFLAGS = $(xineplug_ldflags) # SUBDIRS = libreal librtsp -if ENABLE_VCD -SUBDIRS += vcd -endif if !WITH_EXTERNAL_DVDNAV SUBDIRS += libdvdnav endif @@ -21,13 +18,16 @@ endif noinst_HEADERS = net_buf_ctrl.h mms.h mmsh.h pnm.h media_helper.h http_helper.h - if ENABLE_DVB in_dvb = xineplug_inp_dvb.la endif +if ENABLE_VCD +in_vcd = xineplug_inp_vcd.la +endif + if ENABLE_VCDO -in_vcd = xineplug_inp_vcdo.la +in_vcdo = xineplug_inp_vcdo.la endif if ENABLE_V4L @@ -62,6 +62,7 @@ xineplug_LTLIBRARIES = \ xineplug_inp_http.la \ xineplug_inp_dvd.la \ $(in_vcd) \ + $(in_vcdo) \ $(in_v4l) \ $(in_gnome_vfs) \ $(in_smb) \ @@ -92,6 +93,12 @@ xineplug_inp_mms_la_LIBADD = $(XINE_LIB) $(LTLIBICONV) $(PTHREAD_LIBS) $(LTLIBIN xineplug_inp_vcdo_la_SOURCES = input_vcd.c media_helper.c xineplug_inp_vcdo_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) +xineplug_inp_vcd_la_SOURCES = vcd/xineplug_inp_vcd.c vcd/vcdplayer.c \ + vcd/vcdio.c vcd/xine-extra.c vcd/vcdio.h \ + vcd/vcdplayer.h vcd/xine-extra.h +xineplug_inp_vcd_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) $(LIBCDIO_LIBS) $(LIBVCD_LIBS) $(LIBVCDINFO_LIBS) $(LIBISO9660_LIBS) -lm +xineplug_inp_vcd_la_CFLAGS = $(AM_CFLAGS) $(LIBCDIO_CFLAGS) $(LIBVCD_CFLAGS) + xineplug_inp_stdin_fifo_la_SOURCES = input_stdin_fifo.c net_buf_ctrl.c xineplug_inp_stdin_fifo_la_LIBADD = $(XINE_LIB) $(PTHREAD_LIBS) $(LTLIBINTL) diff --git a/src/input/vcd/Makefile.am b/src/input/vcd/Makefile.am deleted file mode 100644 index 2b47415fd..000000000 --- a/src/input/vcd/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -include $(top_srcdir)/misc/Makefile.common - -AM_CFLAGS = $(DEFAULT_OCFLAGS) $(VISIBILITY_FLAG) -AM_LDFLAGS = $(xineplug_ldflags) - -noinst_HEADERS = vcdio.h vcdplayer.h xine-extra.h - -xineplug_LTLIBRARIES = xineplug_inp_vcd.la - -xineplug_inp_vcd_la_SOURCES = xineplug_inp_vcd.c vcdplayer.c vcdio.c xine-extra.c -xineplug_inp_vcd_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) $(LIBCDIO_LIBS) $(LIBVCD_LIBS) $(LIBVCDINFO_LIBS) $(LIBISO9660_LIBS) -lm -xineplug_inp_vcd_la_DEPENDENCIES = $(LIBCDIO_DEPS) $(LIBVCD_DEPS) $(LIBVCDINFO_DEPS) $(LIBISO9660_DEPS) -xineplug_inp_vcd_la_CFLAGS = $(AM_CFLAGS) $(LIBCDIO_CFLAGS) $(LIBVCD_CFLAGS) -- cgit v1.2.3 From 9c881836d4dead995213b4863e055d32e7372a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sun, 27 Jan 2008 16:17:47 +0100 Subject: Compile librtsp and libreal source files directly into the rtsp plugin. Avoid two recursive make calls. --- src/input/Makefile.am | 14 ++++++++++---- src/input/libreal/Makefile.am | 10 ---------- src/input/librtsp/Makefile.am | 10 ---------- 3 files changed, 10 insertions(+), 24 deletions(-) delete mode 100644 src/input/libreal/Makefile.am delete mode 100644 src/input/librtsp/Makefile.am (limited to 'src') diff --git a/src/input/Makefile.am b/src/input/Makefile.am index 64ba0ce54..74aca7240 100644 --- a/src/input/Makefile.am +++ b/src/input/Makefile.am @@ -10,9 +10,8 @@ AM_LDFLAGS = $(xineplug_ldflags) # All of xine input plugins should be named like the scheme "xineplug_inp_" # -SUBDIRS = libreal librtsp if !WITH_EXTERNAL_DVDNAV -SUBDIRS += libdvdnav +SUBDIRS = libdvdnav endif @@ -116,8 +115,15 @@ xineplug_inp_dvb_la_DEPS = $(XDG_BASEDIR_DEPS) xineplug_inp_dvb_la_LIBADD = $(XINE_LIB) $(PTHREAD_LIBS) $(LTLIBINTL) $(XDG_BASEDIR_LIBS) xineplug_inp_dvb_la_CPPFLAGS = $(AM_CPPFLAGS) $(XDG_BASEDIR_CPPFLAGS) -xineplug_inp_rtsp_la_SOURCES = input_rtsp.c net_buf_ctrl.c -xineplug_inp_rtsp_la_LIBADD = $(XINE_LIB) $(PTHREAD_LIBS) $(LTLIBINTL) libreal/libreal.la librtsp/librtsp.la +xineplug_inp_rtsp_la_SOURCES = input_rtsp.c net_buf_ctrl.c \ + librtsp/rtsp.c librtsp/rtsp_session.c \ + librtsp/rtsp.h librtsp/rtsp_session.h \ + libreal/real.c libreal/asmrp.c \ + libreal/rmff.c libreal/sdpplin.c \ + libreal/real.h libreal/asmrp.h \ + libreal/rmff.h libreal/sdpplin.h +xineplug_inp_rtsp_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/libreal -I$(srcdir)/librtsp +xineplug_inp_rtsp_la_LIBADD = $(XINE_LIB) $(PTHREAD_LIBS) $(LTLIBINTL) xineplug_inp_cdda_la_SOURCES = input_cdda.c media_helper.c sha1.c sha1.h xineplug_inp_cdda_la_DEPS = $(XDG_BASEDIR_DEPS) diff --git a/src/input/libreal/Makefile.am b/src/input/libreal/Makefile.am deleted file mode 100644 index bd97a7548..000000000 --- a/src/input/libreal/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -include $(top_srcdir)/misc/Makefile.common - -AM_CFLAGS = $(DEFAULT_OCFLAGS) $(VISIBILITY_FLAG) -AM_CPPFLAGS = -I$(top_srcdir)/src/input/librtsp - -noinst_HEADERS = real.h asmrp.h rmff.h sdpplin.h - -noinst_LTLIBRARIES = libreal.la - -libreal_la_SOURCES = real.c asmrp.c rmff.c sdpplin.c diff --git a/src/input/librtsp/Makefile.am b/src/input/librtsp/Makefile.am deleted file mode 100644 index 68d554c2c..000000000 --- a/src/input/librtsp/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -include $(top_srcdir)/misc/Makefile.common - -AM_CFLAGS = $(DEFAULT_OCFLAGS) $(VISIBILITY_FLAG) -AM_CPPFLAGS = -I$(top_srcdir)/src/input/libreal - -noinst_HEADERS = rtsp.h rtsp_session.h - -noinst_LTLIBRARIES = librtsp.la - -librtsp_la_SOURCES = rtsp.c rtsp_session.c -- cgit v1.2.3 From 873a841ce7df818c82991dfa2eeafa019043fae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sun, 27 Jan 2008 16:32:37 +0100 Subject: Move macosx video output library building inside src/video_out, avoid one recursive make call. --- src/video_out/Makefile.am | 8 +++++++- src/video_out/macosx/Makefile.am | 12 ------------ 2 files changed, 7 insertions(+), 13 deletions(-) delete mode 100644 src/video_out/macosx/Makefile.am (limited to 'src') diff --git a/src/video_out/Makefile.am b/src/video_out/Makefile.am index 3b5703792..b661fdd4b 100644 --- a/src/video_out/Makefile.am +++ b/src/video_out/Makefile.am @@ -7,7 +7,8 @@ AM_OBJCFLAGS = $(DEFAULT_OCFLAGS) $(VISIBILITY_FLAG) SUBDIRS = if ENABLE_MACOSX_VIDEO -SUBDIRS += macosx +xineinclude_HEADERS = macosx/video_window.h macosx/XineOpenGLView.h macosx/XineVideoWindow.h +lib_LTLIBRARIES = libxineMacOSXVideo.la endif EXTRA_DIST = video_out_directx.c video_out_macosx.m @@ -194,3 +195,8 @@ xineplug_vo_out_none_la_LIBADD = $(XINE_LIB) $(PTHREAD_LIBS) $(LTLIBINTL) xineplug_vo_out_macosx_la_SOURCES = video_out_macosx.m xineplug_vo_out_macosx_la_LIBADD = $(XINE_LIB) $(PTHREAD_LIBS) xineplug_vo_out_macosx_la_LDFLAGS = $(AM_LDFLAGS) -framework Cocoa -framework OpenGL + +libxineMacOSXVideo_la_SOURCES = macosx/XineOpenGLView.m macosx/XineVideoWindow.m +libxineMacOSXVideo_la_LDFLAGS = $(AM_LDFLAGS) -framework Cocoa \ + -framework OpenGL -version-info \ + $(XINE_LT_CURRENT):$(XINE_LT_REVISION):$(XINE_LT_AGE) diff --git a/src/video_out/macosx/Makefile.am b/src/video_out/macosx/Makefile.am deleted file mode 100644 index ae6a5acc8..000000000 --- a/src/video_out/macosx/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -include $(top_srcdir)/misc/Makefile.common - -AM_CFLAGS = $(DEFAULT_OCFLAGS) $(VISIBILITY_FLAG) -AM_OBJCFLAGS = $(DEFAULT_OCFLAGS) $(VISIBILITY_FLAG) - -xineinclude_HEADERS = video_window.h XineOpenGLView.h XineVideoWindow.h - -lib_LTLIBRARIES = libxineMacOSXVideo.la - -libxineMacOSXVideo_la_SOURCES = XineOpenGLView.m XineVideoWindow.m -libxineMacOSXVideo_la_LDFLAGS = $(AM_LDFLAGS) -framework Cocoa -framework OpenGL \ - -version-info $(XINE_LT_CURRENT):$(XINE_LT_REVISION):$(XINE_LT_AGE) -- cgit v1.2.3 From 435a5d525c9aa9e4a4b174949b2d67d57110aa9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sun, 27 Jan 2008 16:40:07 +0100 Subject: Move libmpeg2-based decoder building in video_dec. Avoid one recursive make call. --- src/video_dec/Makefile.am | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/video_dec/Makefile.am b/src/video_dec/Makefile.am index 91246eb4d..1b0fec998 100644 --- a/src/video_dec/Makefile.am +++ b/src/video_dec/Makefile.am @@ -1,5 +1,3 @@ -SUBDIRS = libmpeg2 - include $(top_srcdir)/misc/Makefile.common AM_CFLAGS = $(DEFAULT_OCFLAGS) $(VISIBILITY_FLAG) @@ -20,7 +18,8 @@ xineplug_LTLIBRARIES = $(image_module) \ $(theora_module) \ xineplug_decode_bitplane.la \ xineplug_decode_rgb.la \ - xineplug_decode_yuv.la + xineplug_decode_yuv.la \ + xineplug_decode_mpeg2.la xineplug_decode_bitplane_la_SOURCES = bitplane.c xineplug_decode_bitplane_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) @@ -38,3 +37,18 @@ xineplug_decode_image_la_CFLAGS = $(AM_CFLAGS) $(WAND_CFLAGS) xineplug_decode_gdk_pixbuf_la_SOURCES = gdkpixbuf.c xineplug_decode_gdk_pixbuf_la_LIBADD = $(XINE_LIB) $(DYNAMIC_LD_LIBS) $(GDK_PIXBUF_LIBS) xineplug_decode_gdk_pixbuf_la_CFLAGS = $(AM_CFLAGS) $(GDK_PIXBUF_CFLAGS) + +xineplug_decode_mpeg2_la_SOURCES = libmpeg2/cpu_state.c \ + libmpeg2/decode.c libmpeg2/header.c libmpeg2/idct.c \ + libmpeg2/idct_altivec.c libmpeg2/idct_mlib.c \ + libmpeg2/idct_mmx.c libmpeg2/motion_comp.c \ + libmpeg2/motion_comp_altivec.c libmpeg2/motion_comp_mmx.c \ + libmpeg2/motion_comp_mlib.c libmpeg2/motion_comp_vis.c \ + libmpeg2/slice.c libmpeg2/slice_xvmc.c \ + libmpeg2/slice_xvmc_vld.c libmpeg2/stats.c \ + libmpeg2/xine_mpeg2_decoder.c libmpeg2/libmpeg2_accel.c \ + libmpeg2/vlc.h libmpeg2/mpeg2.h libmpeg2/xvmc.h \ + libmpeg2/xvmc_vld.h libmpeg2/mpeg2_internal.h \ + libmpeg2/idct_mlib.h libmpeg2/vis.h libmpeg2/libmpeg2_accel.h +xineplug_decode_mpeg2_la_LIBADD = $(XINE_LIB) $(MLIB_LIBS) -lm +xineplug_decode_mpeg2_la_CFLAGS = $(AM_CFLAGS) $(MLIB_CFLAGS) -- cgit v1.2.3 From fdd31b7b130a36dbd1d59b075667626e592cac70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sun, 27 Jan 2008 16:42:52 +0100 Subject: Remove makefile I should have removed before. --- src/video_dec/libmpeg2/Makefile.am | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 src/video_dec/libmpeg2/Makefile.am (limited to 'src') diff --git a/src/video_dec/libmpeg2/Makefile.am b/src/video_dec/libmpeg2/Makefile.am deleted file mode 100644 index 2f7429942..000000000 --- a/src/video_dec/libmpeg2/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -include $(top_srcdir)/misc/Makefile.common - -AM_CFLAGS = $(DEFAULT_OCFLAGS) $(VISIBILITY_FLAG) -AM_LDFLAGS = $(xineplug_ldflags) - -noinst_HEADERS = vlc.h mpeg2.h xvmc.h xvmc_vld.h mpeg2_internal.h idct_mlib.h vis.h \ - libmpeg2_accel.h - -xineplug_LTLIBRARIES = xineplug_decode_mpeg2.la - -xineplug_decode_mpeg2_la_SOURCES = \ - cpu_state.c \ - decode.c \ - header.c \ - idct.c \ - idct_altivec.c \ - idct_mlib.c \ - idct_mmx.c \ - motion_comp.c \ - motion_comp_altivec.c \ - motion_comp_mmx.c \ - motion_comp_mlib.c \ - motion_comp_vis.c \ - slice.c \ - slice_xvmc.c \ - slice_xvmc_vld.c \ - stats.c \ - xine_mpeg2_decoder.c \ - libmpeg2_accel.c - -xineplug_decode_mpeg2_la_LIBADD = $(XINE_LIB) $(MLIB_LIBS) -lm -xineplug_decode_mpeg2_la_CFLAGS = $(AM_CFLAGS) $(MLIB_CFLAGS) -- cgit v1.2.3 From ed50aae86ce8fd29842df53ee83e0b1d4cddb828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sun, 27 Jan 2008 16:51:38 +0100 Subject: Revert part of commit applied by mistake. --- src/xine-engine/audio_out.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 34f982d18..855051582 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -1626,7 +1626,6 @@ static void ao_close(xine_audio_port_t *this_gen, xine_stream_t *stream) { } else fifo_wait_empty(this->out_fifo); - ao_set_property(this_gen, AO_PROP_DISCARD_BUFFERS, 0); } pthread_mutex_lock( &this->driver_lock ); -- cgit v1.2.3 From 3343d52e459bfc9c9db28dcba7afb0c6e2f05f59 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Mon, 28 Jan 2008 17:03:37 +0000 Subject: Fix a RealPlayer codec detection bug. --- src/libreal/real_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libreal/real_common.c b/src/libreal/real_common.c index fcd0fac8f..6fda4ddbe 100644 --- a/src/libreal/real_common.c +++ b/src/libreal/real_common.c @@ -77,8 +77,8 @@ void _x_real_codecs_init(xine_t *const xine) { default_real_codecs_path[0] = 0; -#define UL64 0x05 /* /usr/{,local/}lib64 */ -#define UL 0x0A /* /usr/{,local/}lib */ +#define UL64 0x03 /* /usr/{,local/}lib64 */ +#define UL 0x0C /* /usr/{,local/}lib */ #define O 0x10 /* /opt */ #define OL64 0x20 /* /opt/lib64 */ #define OL 0x40 /* /opt/lib */ -- cgit v1.2.3 From 72abc5e53ea918cdf2813a722e14760d8e797b3d Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Fri, 1 Feb 2008 00:01:12 +0000 Subject: Back out vcd build changes: separate unit (though used only once). Also, built files don't end up in the vcd directory. --- src/input/Makefile.am | 17 +++++------------ src/input/vcd/Makefile.am | 13 +++++++++++++ 2 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 src/input/vcd/Makefile.am (limited to 'src') diff --git a/src/input/Makefile.am b/src/input/Makefile.am index 64ba0ce54..ca7e6dabd 100644 --- a/src/input/Makefile.am +++ b/src/input/Makefile.am @@ -11,6 +11,9 @@ AM_LDFLAGS = $(xineplug_ldflags) # SUBDIRS = libreal librtsp +if ENABLE_VCD +SUBDIRS += vcd +endif if !WITH_EXTERNAL_DVDNAV SUBDIRS += libdvdnav endif @@ -18,16 +21,13 @@ endif noinst_HEADERS = net_buf_ctrl.h mms.h mmsh.h pnm.h media_helper.h http_helper.h + if ENABLE_DVB in_dvb = xineplug_inp_dvb.la endif -if ENABLE_VCD -in_vcd = xineplug_inp_vcd.la -endif - if ENABLE_VCDO -in_vcdo = xineplug_inp_vcdo.la +in_vcd = xineplug_inp_vcdo.la endif if ENABLE_V4L @@ -62,7 +62,6 @@ xineplug_LTLIBRARIES = \ xineplug_inp_http.la \ xineplug_inp_dvd.la \ $(in_vcd) \ - $(in_vcdo) \ $(in_v4l) \ $(in_gnome_vfs) \ $(in_smb) \ @@ -93,12 +92,6 @@ xineplug_inp_mms_la_LIBADD = $(XINE_LIB) $(LTLIBICONV) $(PTHREAD_LIBS) $(LTLIBIN xineplug_inp_vcdo_la_SOURCES = input_vcd.c media_helper.c xineplug_inp_vcdo_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) -xineplug_inp_vcd_la_SOURCES = vcd/xineplug_inp_vcd.c vcd/vcdplayer.c \ - vcd/vcdio.c vcd/xine-extra.c vcd/vcdio.h \ - vcd/vcdplayer.h vcd/xine-extra.h -xineplug_inp_vcd_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) $(LIBCDIO_LIBS) $(LIBVCD_LIBS) $(LIBVCDINFO_LIBS) $(LIBISO9660_LIBS) -lm -xineplug_inp_vcd_la_CFLAGS = $(AM_CFLAGS) $(LIBCDIO_CFLAGS) $(LIBVCD_CFLAGS) - xineplug_inp_stdin_fifo_la_SOURCES = input_stdin_fifo.c net_buf_ctrl.c xineplug_inp_stdin_fifo_la_LIBADD = $(XINE_LIB) $(PTHREAD_LIBS) $(LTLIBINTL) diff --git a/src/input/vcd/Makefile.am b/src/input/vcd/Makefile.am new file mode 100644 index 000000000..2b47415fd --- /dev/null +++ b/src/input/vcd/Makefile.am @@ -0,0 +1,13 @@ +include $(top_srcdir)/misc/Makefile.common + +AM_CFLAGS = $(DEFAULT_OCFLAGS) $(VISIBILITY_FLAG) +AM_LDFLAGS = $(xineplug_ldflags) + +noinst_HEADERS = vcdio.h vcdplayer.h xine-extra.h + +xineplug_LTLIBRARIES = xineplug_inp_vcd.la + +xineplug_inp_vcd_la_SOURCES = xineplug_inp_vcd.c vcdplayer.c vcdio.c xine-extra.c +xineplug_inp_vcd_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) $(LIBCDIO_LIBS) $(LIBVCD_LIBS) $(LIBVCDINFO_LIBS) $(LIBISO9660_LIBS) -lm +xineplug_inp_vcd_la_DEPENDENCIES = $(LIBCDIO_DEPS) $(LIBVCD_DEPS) $(LIBVCDINFO_DEPS) $(LIBISO9660_DEPS) +xineplug_inp_vcd_la_CFLAGS = $(AM_CFLAGS) $(LIBCDIO_CFLAGS) $(LIBVCD_CFLAGS) -- cgit v1.2.3 From d865cc45e9f9c9d9e1dfeef714cf7221d39fb3e8 Mon Sep 17 00:00:00 2001 From: Jean-Yves Lefort Date: Fri, 1 Feb 2008 02:16:14 +0000 Subject: patch adding video.device.xv_port option The attached patch allows to specify the Xv port to use (needed with some nvidia twinview configurations). --- src/video_out/video_out_xv.c | 53 ++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index d6419c00b..da679d088 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -1136,6 +1136,30 @@ static void xv_update_xv_pitch_alignment(void *this_gen, xine_cfg_entry_t *entry this->use_pitch_alignment = entry->num_value; } +static int xv_open_port (xv_driver_t *this, XvPortID port) { + return ! xv_check_yv12(this->display, port) + && XvGrabPort(this->display, port, 0) == Success; +} + +static XvPortID xv_autodetect_port(xv_driver_t *this, + unsigned int adaptors, + XvAdaptorInfo *adaptor_info, + unsigned int *adaptor_num) { + unsigned int an, j; + + for (an = 0; an < adaptors; an++) + if (adaptor_info[an].type & XvImageMask) + for (j = 0; j < adaptor_info[an].num_ports; j++) { + XvPortID port = adaptor_info[an].base_id + j; + if (xv_open_port(this, port)) { + *adaptor_num = an; + return port; + } + } + + return 0; +} + /* expects XINE_VISUAL_TYPE_X11_2 with configurable locking */ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void *visual_gen) { xv_class_t *class = (xv_class_t *) class_gen; @@ -1148,7 +1172,7 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * x11_visual_t *visual = (x11_visual_t *) visual_gen; XColor dummy; XvImage *myimage; - unsigned int adaptors, j; + unsigned int adaptors; unsigned int ver,rel,req,ev,err; XShmSegmentInfo myshminfo; XvPortID xv_port; @@ -1191,25 +1215,16 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * return NULL; } - xv_port = 0; + xv_port = config->register_num (config, "video.device.xv_port", 0, + _("Xv port number"), + _("Selects the Xv port number to use (0 to autodetect)."), + 10, NULL, NULL); - for ( adaptor_num = 0; (adaptor_num < adaptors) && !xv_port; adaptor_num++ ) { - - if (adaptor_info[adaptor_num].type & XvImageMask) { - - for (j = 0; j < adaptor_info[adaptor_num].num_ports && !xv_port; j++) - if (( !(xv_check_yv12 (this->display, - adaptor_info[adaptor_num].base_id + j))) - && (XvGrabPort (this->display, - adaptor_info[adaptor_num].base_id + j, - 0) == Success)) { - xv_port = adaptor_info[adaptor_num].base_id + j; - } - - if( xv_port ) - break; - } - } + if (xv_port != 0) { + if (! xv_open_port(this, xv_port)) + xv_port = 0; + } else + xv_port = xv_autodetect_port(this, adaptors, adaptor_info, &adaptor_num); if (!xv_port) { xprintf(class->xine, XINE_VERBOSITY_LOG, -- cgit v1.2.3 From 3123c1c76b8eb9e6236f9d17dc6e283281495def Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Fri, 1 Feb 2008 02:17:09 +0000 Subject: Fallback to auto-detect when the specified Xv port is unavailable or unusable. --- src/video_out/video_out_xv.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index da679d088..61b2638ec 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -1137,8 +1137,25 @@ static void xv_update_xv_pitch_alignment(void *this_gen, xine_cfg_entry_t *entry } static int xv_open_port (xv_driver_t *this, XvPortID port) { - return ! xv_check_yv12(this->display, port) + int ret; + x11_InstallXErrorHandler (this); + ret = ! xv_check_yv12(this->display, port) && XvGrabPort(this->display, port, 0) == Success; + x11_DeInstallXErrorHandler (this); + return ret; +} + +static unsigned int +xv_find_adaptor_by_port (int port, unsigned int adaptors, + XvAdaptorInfo *adaptor_info) +{ + unsigned int an; + for (an = 0; an < adaptors; an++) + if (adaptor_info[an].type & XvImageMask) + if (port >= adaptor_info[an].base_id && + port < adaptor_info[an].base_id + adaptor_info[an].num_ports) + return an; + return 0; /* shouldn't happen */ } static XvPortID xv_autodetect_port(xv_driver_t *this, @@ -1221,8 +1238,13 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * 10, NULL, NULL); if (xv_port != 0) { - if (! xv_open_port(this, xv_port)) - xv_port = 0; + if (! xv_open_port(this, xv_port)) { + xprintf(class->xine, XINE_VERBOSITY_NONE, + _("%s: could not open Xv port %d - autodetecting\n"), + LOG_MODULE, xv_port); + xv_port = xv_autodetect_port(this, adaptors, adaptor_info, &adaptor_num); + } else + adaptor_num = xv_find_adaptor_by_port (xv_port, adaptors, adaptor_info); } else xv_port = xv_autodetect_port(this, adaptors, adaptor_info, &adaptor_num); -- cgit v1.2.3 From 5f2f836776194347fefa595d53ebe3d9790b4a74 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Fri, 1 Feb 2008 03:03:12 +0000 Subject: Add Xv port selection to the XCB xv plugin. --- src/video_out/video_out_xcbxv.c | 86 ++++++++++++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_xcbxv.c b/src/video_out/video_out_xcbxv.c index 19a387732..cb07d949b 100644 --- a/src/video_out/video_out_xcbxv.c +++ b/src/video_out/video_out_xcbxv.c @@ -1089,13 +1089,60 @@ static void xv_update_xv_pitch_alignment(void *this_gen, xine_cfg_entry_t *entry this->use_pitch_alignment = entry->num_value; } +static xcb_xv_port_t xv_open_port (xv_driver_t *this, xcb_xv_port_t port) { + xcb_xv_grab_port_cookie_t grab_port_cookie; + xcb_xv_grab_port_reply_t *grab_port_reply; + + if (xv_check_yv12 (this->connection, port)) + return 0; + + grab_port_cookie = xcb_xv_grab_port (this->connection, port, XCB_CURRENT_TIME); + grab_port_reply = xcb_xv_grab_port_reply (this->connection, grab_port_cookie, NULL); + + if (grab_port_reply && (grab_port_reply->result == XCB_GRAB_STATUS_SUCCESS)) + { + free (grab_port_reply); + return port; + } + free (grab_port_reply); + return 0; +} + +static xcb_xv_adaptor_info_iterator_t * +xv_find_adaptor_by_port (int port, xcb_xv_adaptor_info_iterator_t *adaptor_it) +{ + for (; adaptor_it->rem; xcb_xv_adaptor_info_next(adaptor_it)) + if (adaptor_it->data->type & XCB_XV_TYPE_IMAGE_MASK) + if (port >= adaptor_it->data->base_id && + port < adaptor_it->data->base_id + adaptor_it->data->num_ports) + return adaptor_it; + return NULL; /* shouldn't happen */ +} + +static xcb_xv_port_t xv_autodetect_port(xv_driver_t *this, + xcb_xv_adaptor_info_iterator_t *adaptor_it) +{ + for (; adaptor_it->rem; xcb_xv_adaptor_info_next(adaptor_it)) + if (adaptor_it->data->type & XCB_XV_TYPE_IMAGE_MASK) + { + int j; + for (j = 0; j < adaptor_it->data->num_ports; ++j) + if (!xv_check_yv12 (this->connection, adaptor_it->data->base_id + j)) + { + xcb_xv_port_t port = xv_open_port (this, adaptor_it->data->base_id + j); + if (port) + return port; + } + } + return 0; +} + static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *visual_gen) { xv_class_t *class = (xv_class_t *) class_gen; config_values_t *config = class->config; xv_driver_t *this; int i; xcb_visual_t *visual = (xcb_visual_t *) visual_gen; - unsigned int j; xcb_xv_port_t xv_port; const xcb_query_extension_reply_t *query_extension_reply; @@ -1146,28 +1193,21 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis } adaptor_it = xcb_xv_query_adaptors_info_iterator(query_adaptors_reply); - - xv_port = 0; - - for (; adaptor_it.rem && !xv_port; xcb_xv_adaptor_info_next(&adaptor_it)) { - - if (adaptor_it.data->type & XCB_XV_TYPE_IMAGE_MASK) { - - for (j = 0; j < adaptor_it.data->num_ports; j++) - if (!xv_check_yv12(this->connection, adaptor_it.data->base_id + j)) { - xcb_xv_grab_port_cookie_t grab_port_cookie; - xcb_xv_grab_port_reply_t *grab_port_reply; - grab_port_cookie = xcb_xv_grab_port(this->connection, adaptor_it.data->base_id + j, XCB_CURRENT_TIME); - grab_port_reply = xcb_xv_grab_port_reply(this->connection, grab_port_cookie, NULL); - if (grab_port_reply && (grab_port_reply->result == XCB_GRAB_STATUS_SUCCESS)) { - free(grab_port_reply); - xv_port = adaptor_it.data->base_id + j; - break; - } - free(grab_port_reply); - } - } - } + xv_port = config->register_num (config, "video.device.xv_port", 0, + _("Xv port number"), + _("Selects the Xv port number to use (0 to autodetect)."), + 10, NULL, NULL); + + if (xv_port != 0) { + if (! xv_open_port(this, xv_port)) { + xprintf(class->xine, XINE_VERBOSITY_NONE, + _("%s: could not open Xv port %d - autodetecting\n"), + LOG_MODULE, xv_port); + xv_port = xv_autodetect_port (this, &adaptor_it); + } else + xv_find_adaptor_by_port (xv_port, &adaptor_it); + } else + xv_port = xv_autodetect_port (this, &adaptor_it); if (!xv_port) { xprintf(class->xine, XINE_VERBOSITY_LOG, -- cgit v1.2.3 From e27e5b16313734e45fa974b988f439b9c8a11894 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Fri, 1 Feb 2008 16:44:43 +0000 Subject: Port Xv port selection to xxmc. --- src/video_out/video_out_xxmc.c | 73 +++++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_xxmc.c b/src/video_out/video_out_xxmc.c index 98ce99f1f..7fc136e94 100644 --- a/src/video_out/video_out_xxmc.c +++ b/src/video_out/video_out_xxmc.c @@ -2237,6 +2237,47 @@ static void xxmc_update_disable_bob_for_scaled_osd(void *this_gen, xine_cfg_entr this->disable_bob_for_scaled_osd = entry->num_value; } +static int xxmc_open_port (xxmc_driver_t *this, XvPortID port) { + int ret; + x11_InstallXErrorHandler (this); + ret = ! xxmc_check_yv12(this->display, port) + && XvGrabPort(this->display, port, 0) == Success; + x11_DeInstallXErrorHandler (this); + return ret; +} + +static unsigned int +xxmc_find_adaptor_by_port (int port, unsigned int adaptors, + XvAdaptorInfo *adaptor_info) +{ + unsigned int an; + for (an = 0; an < adaptors; an++) + if (adaptor_info[an].type & XvImageMask) + if (port >= adaptor_info[an].base_id && + port < adaptor_info[an].base_id + adaptor_info[an].num_ports) + return an; + return 0; /* shouldn't happen */ +} + +static XvPortID xxmc_autodetect_port(xxmc_driver_t *this, + unsigned int adaptors, + XvAdaptorInfo *adaptor_info, + unsigned int *adaptor_num) { + unsigned int an, j; + + for (an = 0; an < adaptors; an++) + if (adaptor_info[an].type & XvImageMask) + for (j = 0; j < adaptor_info[an].num_ports; j++) { + XvPortID port = adaptor_info[an].base_id + j; + if (xxmc_open_port(this, port)) { + *adaptor_num = an; + return port; + } + } + + return 0; +} + static void checkXvMCCap( xxmc_driver_t *this, XvPortID xv_port) { @@ -2436,25 +2477,21 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi return NULL; } - xv_port = 0; - - for ( adaptor_num = 0; (adaptor_num < adaptors) && !xv_port; adaptor_num++ ) { + xv_port = config->register_num (config, "video.device.xv_port", 0, + _("Xv port number"), + _("Selects the Xv port number to use (0 to autodetect)."), + 10, NULL, NULL); - if (adaptor_info[adaptor_num].type & XvImageMask) { - - for (j = 0; j < adaptor_info[adaptor_num].num_ports && !xv_port; j++) - if (( !(xxmc_check_yv12 (this->display, - adaptor_info[adaptor_num].base_id + j))) - && (XvGrabPort (this->display, - adaptor_info[adaptor_num].base_id + j, - 0) == Success)) { - xv_port = adaptor_info[adaptor_num].base_id + j; - } - - if( xv_port ) - break; - } - } + if (xv_port != 0) { + if (! xxmc_open_port(this, xv_port)) { + xprintf(class->xine, XINE_VERBOSITY_NONE, + _("%s: could not open Xv port %d - autodetecting\n"), + LOG_MODULE, xv_port); + xv_port = xxmc_autodetect_port(this, adaptors, adaptor_info, &adaptor_num); + } else + adaptor_num = xxmc_find_adaptor_by_port (xv_port, adaptors, adaptor_info); + } else + xv_port = xxmc_autodetect_port(this, adaptors, adaptor_info, &adaptor_num); if (!xv_port) { xprintf(class->xine, XINE_VERBOSITY_LOG, -- cgit v1.2.3 From e37643a0929038587a8517a266c4f20806542788 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sat, 2 Feb 2008 00:18:43 +0000 Subject: Convert xshm_set_property() from if() chain to switch block. --- src/video_out/video_out_xcbshm.c | 24 +++++++++++------------- src/video_out/video_out_xshm.c | 24 +++++++++++------------- 2 files changed, 22 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_xcbshm.c b/src/video_out/video_out_xcbshm.c index bb19058f5..9895d1852 100644 --- a/src/video_out/video_out_xcbshm.c +++ b/src/video_out/video_out_xcbshm.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2003, 2007 the xine project + * Copyright (C) 2000-2003, 2007-2008 the xine project * * This file is part of xine, a free video player. * @@ -750,45 +750,43 @@ static int xshm_set_property (vo_driver_t *this_gen, int property, int value) { xshm_driver_t *this = (xshm_driver_t *) this_gen; - if ( property == VO_PROP_ASPECT_RATIO) { - + switch (property) { + case VO_PROP_ASPECT_RATIO: if (value>=XINE_VO_ASPECT_NUM_RATIOS) value = XINE_VO_ASPECT_AUTO; this->sc.user_ratio = value; xprintf(this->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": aspect ratio changed to %s\n", _x_vo_scale_aspect_ratio_name_table[value]); + break; - } else if (property == VO_PROP_BRIGHTNESS) { - + case VO_PROP_BRIGHTNESS: this->yuv2rgb_brightness = value; this->yuv2rgb_factory->set_csc_levels (this->yuv2rgb_factory, this->yuv2rgb_brightness, this->yuv2rgb_contrast, this->yuv2rgb_saturation); - this->sc.force_redraw = 1; + break; - } else if (property == VO_PROP_CONTRAST) { - + case VO_PROP_CONTRAST: this->yuv2rgb_contrast = value; this->yuv2rgb_factory->set_csc_levels (this->yuv2rgb_factory, this->yuv2rgb_brightness, this->yuv2rgb_contrast, this->yuv2rgb_saturation); - this->sc.force_redraw = 1; + break; - } else if (property == VO_PROP_SATURATION) { - + case VO_PROP_SATURATION: this->yuv2rgb_saturation = value; this->yuv2rgb_factory->set_csc_levels (this->yuv2rgb_factory, this->yuv2rgb_brightness, this->yuv2rgb_contrast, this->yuv2rgb_saturation); - this->sc.force_redraw = 1; + break; - } else { + default: xprintf (this->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": tried to set unsupported property %d\n", property); } diff --git a/src/video_out/video_out_xshm.c b/src/video_out/video_out_xshm.c index ecaf61f06..7801bb03b 100644 --- a/src/video_out/video_out_xshm.c +++ b/src/video_out/video_out_xshm.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2003 the xine project + * Copyright (C) 2000-2003, 2008 the xine project * * This file is part of xine, a free video player. * @@ -839,45 +839,43 @@ static int xshm_set_property (vo_driver_t *this_gen, int property, int value) { xshm_driver_t *this = (xshm_driver_t *) this_gen; - if ( property == VO_PROP_ASPECT_RATIO) { - + switch (property) { + case VO_PROP_ASPECT_RATIO: if (value>=XINE_VO_ASPECT_NUM_RATIOS) value = XINE_VO_ASPECT_AUTO; this->sc.user_ratio = value; xprintf(this->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": aspect ratio changed to %s\n", _x_vo_scale_aspect_ratio_name_table[value]); + break; - } else if (property == VO_PROP_BRIGHTNESS) { - + case VO_PROP_BRIGHTNESS: this->yuv2rgb_brightness = value; this->yuv2rgb_factory->set_csc_levels (this->yuv2rgb_factory, this->yuv2rgb_brightness, this->yuv2rgb_contrast, this->yuv2rgb_saturation); - this->sc.force_redraw = 1; + break; - } else if (property == VO_PROP_CONTRAST) { - + case VO_PROP_CONTRAST: this->yuv2rgb_contrast = value; this->yuv2rgb_factory->set_csc_levels (this->yuv2rgb_factory, this->yuv2rgb_brightness, this->yuv2rgb_contrast, this->yuv2rgb_saturation); - this->sc.force_redraw = 1; + break; - } else if (property == VO_PROP_SATURATION) { - + case VO_PROP_SATURATION: this->yuv2rgb_saturation = value; this->yuv2rgb_factory->set_csc_levels (this->yuv2rgb_factory, this->yuv2rgb_brightness, this->yuv2rgb_contrast, this->yuv2rgb_saturation); - this->sc.force_redraw = 1; + break; - } else { + default: xprintf (this->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": tried to set unsupported property %d\n", property); } -- cgit v1.2.3 From 3c7b2fa3c7f6640434d64ccfdb72ef77333f40e0 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sat, 2 Feb 2008 00:21:41 +0000 Subject: Add a header file for some strings shared between the Xv-using plugins. --- src/video_out/Makefile.am | 2 +- src/video_out/xv_common.h | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/video_out/xv_common.h (limited to 'src') diff --git a/src/video_out/Makefile.am b/src/video_out/Makefile.am index 3b5703792..c1d142263 100644 --- a/src/video_out/Makefile.am +++ b/src/video_out/Makefile.am @@ -12,7 +12,7 @@ endif EXTRA_DIST = video_out_directx.c video_out_macosx.m -noinst_HEADERS = yuv2rgb.h x11osd.h xcbosd.h +noinst_HEADERS = yuv2rgb.h x11osd.h xcbosd.h xv_common.h if HAVE_X11 X11OSD = x11osd.c diff --git a/src/video_out/xv_common.h b/src/video_out/xv_common.h new file mode 100644 index 000000000..71eecddad --- /dev/null +++ b/src/video_out/xv_common.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2008 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * xv_common.h: X11 Xv common bits + */ + +#define VIDEO_DEVICE_XV_COLORKEY_HELP \ + _("video overlay colour key"), \ + _("The colour key is used to tell the graphics card where to " \ + "overlay the video image. Try different values, if you "\ + "experience windows becoming transparent.") + +#define VIDEO_DEVICE_XV_AUTOPAINT_COLORKEY_HELP \ + _("autopaint colour key"), \ + _("Make Xv autopaint its colour key.") + +#define VIDEO_DEVICE_XV_FILTER_HELP \ + _("bilinear scaling mode"), \ + _("Selects the bilinear scaling mode for Permedia cards. " \ + "The individual values are:\n\n" \ + "Permedia 2\n" \ + "0 - disable bilinear filtering\n" \ + "1 - enable bilinear filtering\n\n" \ + "Permedia 3\n" \ + "0 - disable bilinear filtering\n" \ + "1 - horizontal linear filtering\n" \ + "2 - enable full bilinear filtering") + +#define VIDEO_DEVICE_XV_DOUBLE_BUFFER_HELP \ + _("enable double buffering"), \ + _("Double buffering will synchronize the update of the video " \ + "image to the repainting of the entire screen (\"vertical " \ + "retrace\"). This eliminates flickering and tearing artifacts, " \ + "but will use more graphics memory.") -- cgit v1.2.3 From ca31816f2589c5908488cd0e6c8b5ec215486f31 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sat, 2 Feb 2008 00:27:08 +0000 Subject: Convert the plain Xv plugins to use the new header file. Also, a few trivial constness cleanups. --- src/video_out/video_out_xcbxv.c | 60 ++++++++++++++-------------------------- src/video_out/video_out_xv.c | 61 ++++++++++++++--------------------------- 2 files changed, 40 insertions(+), 81 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_xcbxv.c b/src/video_out/video_out_xcbxv.c index cb07d949b..63313c43a 100644 --- a/src/video_out/video_out_xcbxv.c +++ b/src/video_out/video_out_xcbxv.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2004, 2007 the xine project + * Copyright (C) 2000-2004, 2007-2008 the xine project * * This file is part of xine, a free video player. * @@ -64,6 +64,7 @@ #include #include #include "xcbosd.h" +#include "xv_common.h" typedef struct xv_driver_s xv_driver_t; @@ -965,7 +966,7 @@ static void xv_check_capability (xv_driver_t *this, char *config_help) { int int_default; cfg_entry_t *entry; - char *str_prop = xcb_xv_attribute_info_name(attr); + const char *str_prop = xcb_xv_attribute_info_name(attr); xcb_xv_get_port_attribute_cookie_t get_attribute_cookie; xcb_xv_get_port_attribute_reply_t *get_attribute_reply; @@ -1285,10 +1286,11 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis for (; attribute_it.rem; xcb_xv_attribute_info_next(&attribute_it)) { if ((attribute_it.data->flags & XCB_XV_ATTRIBUTE_FLAG_SETTABLE) && (attribute_it.data->flags & XCB_XV_ATTRIBUTE_FLAG_GETTABLE)) { + const char *const name = xcb_xv_attribute_info_name(attribute_it.data); /* store initial port attribute value */ - xv_store_port_attribute(this, xcb_xv_attribute_info_name(attribute_it.data)); - - if(!strcmp(xcb_xv_attribute_info_name(attribute_it.data), "XV_HUE")) { + xv_store_port_attribute(this, name); + + if(!strcmp(name, "XV_HUE")) { if (!strncmp(xcb_xv_adaptor_info_name(adaptor_it.data), "NV", 2)) { xprintf (this->xine, XINE_VERBOSITY_NONE, LOG_MODULE ": ignoring broken XV_HUE settings on NVidia cards\n"); } else { @@ -1296,63 +1298,41 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis adaptor_it.data->base_id, NULL, NULL, NULL); } - } else if(!strcmp(xcb_xv_attribute_info_name(attribute_it.data), "XV_SATURATION")) { + } else if(!strcmp(name, "XV_SATURATION")) { xv_check_capability (this, VO_PROP_SATURATION, attribute_it.data, adaptor_it.data->base_id, NULL, NULL, NULL); - - } else if(!strcmp(xcb_xv_attribute_info_name(attribute_it.data), "XV_BRIGHTNESS")) { + } else if(!strcmp(name, "XV_BRIGHTNESS")) { xv_check_capability (this, VO_PROP_BRIGHTNESS, attribute_it.data, adaptor_it.data->base_id, NULL, NULL, NULL); - - } else if(!strcmp(xcb_xv_attribute_info_name(attribute_it.data), "XV_CONTRAST")) { + } else if(!strcmp(name, "XV_CONTRAST")) { xv_check_capability (this, VO_PROP_CONTRAST, attribute_it.data, adaptor_it.data->base_id, NULL, NULL, NULL); - - } else if(!strcmp(xcb_xv_attribute_info_name(attribute_it.data), "XV_COLORKEY")) { + } else if(!strcmp(name, "XV_COLORKEY")) { xv_check_capability (this, VO_PROP_COLORKEY, attribute_it.data, adaptor_it.data->base_id, "video.device.xv_colorkey", - _("video overlay colour key"), - _("The colour key is used to tell the graphics card where to " - "overlay the video image. Try different values, if you experience " - "windows becoming transparent.")); - - } else if(!strcmp(xcb_xv_attribute_info_name(attribute_it.data), "XV_AUTOPAINT_COLORKEY")) { + VIDEO_DEVICE_XV_COLORKEY_HELP); + } else if(!strcmp(name, "XV_AUTOPAINT_COLORKEY")) { xv_check_capability (this, VO_PROP_AUTOPAINT_COLORKEY, attribute_it.data, adaptor_it.data->base_id, "video.device.xv_autopaint_colorkey", - _("autopaint colour key"), - _("Make Xv autopaint its colour key.")); - - } else if(!strcmp(xcb_xv_attribute_info_name(attribute_it.data), "XV_FILTER")) { + VIDEO_DEVICE_XV_AUTOPAINT_COLORKEY_HELP); + } else if(!strcmp(name, "XV_FILTER")) { int xv_filter; /* This setting is specific to Permedia 2/3 cards. */ xv_filter = config->register_range (config, "video.device.xv_filter", 0, attribute_it.data->min, attribute_it.data->max, - _("bilinear scaling mode"), - _("Selects the bilinear scaling mode for Permedia cards. " - "The individual values are:\n\n" - "Permedia 2\n" - "0 - disable bilinear filtering\n" - "1 - enable bilinear filtering\n\n" - "Permedia 3\n" - "0 - disable bilinear filtering\n" - "1 - horizontal linear filtering\n" - "2 - enable full bilinear filtering"), + VIDEO_DEVICE_XV_FILTER_HELP, 20, xv_update_XV_FILTER, this); config->update_num(config,"video.device.xv_filter",xv_filter); - } else if(!strcmp(xcb_xv_attribute_info_name(attribute_it.data), "XV_DOUBLE_BUFFER")) { - int xv_double_buffer; - xv_double_buffer = + } else if(!strcmp(name, "XV_DOUBLE_BUFFER")) { + int xv_double_buffer = config->register_bool (config, "video.device.xv_double_buffer", 1, - _("enable double buffering"), - _("Double buffering will synchronize the update of the video image to the " - "repainting of the entire screen (\"vertical retrace\"). This eliminates " - "flickering and tearing artifacts, but will use more graphics memory."), - 20, xv_update_XV_DOUBLE_BUFFER, this); + VIDEO_DEVICE_XV_DOUBLE_BUFFER_HELP, + 20, xv_update_XV_DOUBLE_BUFFER, this); config->update_num(config,"video.device.xv_double_buffer",xv_double_buffer); } } diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index 61b2638ec..a92f6dbe8 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2004 the xine project + * Copyright (C) 2000-2004, 2008 the xine project * * This file is part of xine, a free video player. * @@ -69,6 +69,7 @@ #include #include #include "x11osd.h" +#include "xv_common.h" #define LOCK_DISPLAY(this) {if(this->lock_display) this->lock_display(this->user_data); \ else XLockDisplay(this->display);} @@ -1028,14 +1029,13 @@ static int xv_check_yv12 (Display *display, XvPortID port) { /* called xlocked */ static void xv_check_capability (xv_driver_t *this, - int property, XvAttribute attr, - int base_id, + int property, XvAttribute attr, int base_id, const char *config_name, const char *config_desc, const char *config_help) { int int_default; cfg_entry_t *entry; - char *str_prop = attr.name; + const char *str_prop = attr.name; /* * some Xv drivers (Gatos ATI) report some ~0 as max values, this is confusing. @@ -1335,10 +1335,11 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * for(k = 0; k < nattr; k++) { if((attr[k].flags & XvSettable) && (attr[k].flags & XvGettable)) { + const char *const name = attr[k].name; /* store initial port attribute value */ - xv_store_port_attribute(this, attr[k].name); + xv_store_port_attribute(this, name); - if(!strcmp(attr[k].name, "XV_HUE")) { + if(!strcmp(name, "XV_HUE")) { if (!strncmp(adaptor_info[adaptor_num].name, "NV", 2)) { xprintf (this->xine, XINE_VERBOSITY_NONE, LOG_MODULE ": ignoring broken XV_HUE settings on NVidia cards\n"); } else { @@ -1346,63 +1347,41 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); } - } else if(!strcmp(attr[k].name, "XV_SATURATION")) { + } else if(!strcmp(name, "XV_SATURATION")) { xv_check_capability (this, VO_PROP_SATURATION, attr[k], adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); - - } else if(!strcmp(attr[k].name, "XV_BRIGHTNESS")) { + } else if(!strcmp(name, "XV_BRIGHTNESS")) { xv_check_capability (this, VO_PROP_BRIGHTNESS, attr[k], adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); - - } else if(!strcmp(attr[k].name, "XV_CONTRAST")) { + } else if(!strcmp(name, "XV_CONTRAST")) { xv_check_capability (this, VO_PROP_CONTRAST, attr[k], adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); - - } else if(!strcmp(attr[k].name, "XV_COLORKEY")) { + } else if(!strcmp(name, "XV_COLORKEY")) { xv_check_capability (this, VO_PROP_COLORKEY, attr[k], adaptor_info[adaptor_num].base_id, "video.device.xv_colorkey", - _("video overlay colour key"), - _("The colour key is used to tell the graphics card where to " - "overlay the video image. Try different values, if you experience " - "windows becoming transparent.")); - - } else if(!strcmp(attr[k].name, "XV_AUTOPAINT_COLORKEY")) { + VIDEO_DEVICE_XV_COLORKEY_HELP); + } else if(!strcmp(name, "XV_AUTOPAINT_COLORKEY")) { xv_check_capability (this, VO_PROP_AUTOPAINT_COLORKEY, attr[k], adaptor_info[adaptor_num].base_id, "video.device.xv_autopaint_colorkey", - _("autopaint colour key"), - _("Make Xv autopaint its colour key.")); - - } else if(!strcmp(attr[k].name, "XV_FILTER")) { + VIDEO_DEVICE_XV_AUTOPAINT_COLORKEY_HELP); + } else if(!strcmp(name, "XV_FILTER")) { int xv_filter; /* This setting is specific to Permedia 2/3 cards. */ xv_filter = config->register_range (config, "video.device.xv_filter", 0, attr[k].min_value, attr[k].max_value, - _("bilinear scaling mode"), - _("Selects the bilinear scaling mode for Permedia cards. " - "The individual values are:\n\n" - "Permedia 2\n" - "0 - disable bilinear filtering\n" - "1 - enable bilinear filtering\n\n" - "Permedia 3\n" - "0 - disable bilinear filtering\n" - "1 - horizontal linear filtering\n" - "2 - enable full bilinear filtering"), + VIDEO_DEVICE_XV_FILTER_HELP, 20, xv_update_XV_FILTER, this); config->update_num(config,"video.device.xv_filter",xv_filter); - } else if(!strcmp(attr[k].name, "XV_DOUBLE_BUFFER")) { - int xv_double_buffer; - xv_double_buffer = + } else if(!strcmp(name, "XV_DOUBLE_BUFFER")) { + int xv_double_buffer = config->register_bool (config, "video.device.xv_double_buffer", 1, - _("enable double buffering"), - _("Double buffering will synchronize the update of the video image to the " - "repainting of the entire screen (\"vertical retrace\"). This eliminates " - "flickering and tearing artifacts, but will use more graphics memory."), - 20, xv_update_XV_DOUBLE_BUFFER, this); + VIDEO_DEVICE_XV_DOUBLE_BUFFER_HELP, + 20, xv_update_XV_DOUBLE_BUFFER, this); config->update_num(config,"video.device.xv_double_buffer",xv_double_buffer); } } -- cgit v1.2.3 From 5358d8d5b08bf99f43d508b63e4dcca3da79caba Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sat, 2 Feb 2008 00:39:07 +0000 Subject: XvMC plugin uses the new header; use config_help; small var/struct cleanup. - Removed display in open_plugin(); - Converted adaptor_{info,num} in xvmc_class_t into locals in open_plugin(). Also, a few trivial constness cleanups. (Not fully tested; XvMC doesn't work for me. --- src/video_out/video_out_xvmc.c | 92 +++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 55 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_xvmc.c b/src/video_out/video_out_xvmc.c index 6aa8f430d..c0fb10be3 100644 --- a/src/video_out/video_out_xvmc.c +++ b/src/video_out/video_out_xvmc.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2004 the xine project + * Copyright (C) 2000-2004, 2008 the xine project * * This file is part of xine, a free video player. * @@ -72,6 +72,7 @@ #include #include +#include "xv_common.h" /* #define LOG1 */ /* #define DLOG */ @@ -217,8 +218,6 @@ typedef struct { Display *display; config_values_t *config; XvPortID xv_port; - XvAdaptorInfo *adaptor_info; - unsigned int adaptor_num; int surface_type_id; unsigned int max_surface_width; @@ -1224,13 +1223,13 @@ static void xvmc_dispose (vo_driver_t *this_gen) { /* called xlocked */ static void xvmc_check_capability (xvmc_driver_t *this, - int property, XvAttribute attr, - int base_id, char *str_prop, - char *config_name, - char *config_desc, - char *config_help) { + int property, XvAttribute attr, int base_id, + const char *config_name, + const char *config_desc, + const char *config_help) { int int_default; cfg_entry_t *entry; + const char *str_prop = attr.name; /* * some Xv drivers (Gatos ATI) report some ~0 as max values, this is confusing. @@ -1253,13 +1252,13 @@ static void xvmc_check_capability (xvmc_driver_t *this, if ((attr.min_value == 0) && (attr.max_value == 1)) { this->config->register_bool (this->config, config_name, int_default, config_desc, - NULL, 20, xvmc_property_callback, &this->props[property]); + config_help, 20, xvmc_property_callback, &this->props[property]); } else { this->config->register_range (this->config, config_name, int_default, this->props[property].min, this->props[property].max, config_desc, - NULL, 20, xvmc_property_callback, &this->props[property]); + config_help, 20, xvmc_property_callback, &this->props[property]); } entry = this->config->lookup_entry (this->config, config_name); @@ -1297,7 +1296,6 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi xvmc_class_t *class = (xvmc_class_t *) class_gen; config_values_t *config = class->config; xvmc_driver_t *this = NULL; - Display *display = NULL; unsigned int i, formats; XvPortID xv_port = class->xv_port; XvAttribute *attr; @@ -1305,13 +1303,12 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi int nattr; x11_visual_t *visual = (x11_visual_t *) visual_gen; XColor dummy; + XvAdaptorInfo *adaptor_info; + unsigned int adaptor_num; /* XvImage *myimage; */ lprintf ("open_plugin\n"); - display = visual->display; - - /* TODO ??? */ this = (xvmc_driver_t *) xine_xmalloc (sizeof (xvmc_driver_t)); if (!this) @@ -1393,56 +1390,47 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi this->capabilities |= VO_CAP_XVMC_IDCT; XLockDisplay(this->display); - attr = XvQueryPortAttributes(display, xv_port, &nattr); + attr = XvQueryPortAttributes(this->display, xv_port, &nattr); if(attr && nattr) { int k; for(k = 0; k < nattr; k++) { if((attr[k].flags & XvSettable) && (attr[k].flags & XvGettable)) { - if(!strcmp(attr[k].name, "XV_HUE")) { - xvmc_check_capability (this, VO_PROP_HUE, attr[k], - class->adaptor_info[class->adaptor_num].base_id, "XV_HUE", - NULL, NULL, NULL); - - } else if(!strcmp(attr[k].name, "XV_SATURATION")) { + const char *const name = attr[k].name; + if(!strcmp(name, "XV_HUE")) { + if (!strncmp(adaptor_info[adaptor_num].name, "NV", 2)) { + xprintf (this->xine, XINE_VERBOSITY_NONE, LOG_MODULE ": ignoring broken XV_HUE settings on NVidia cards\n"); + } else { + xvmc_check_capability (this, VO_PROP_HUE, attr[k], + adaptor_info[adaptor_num].base_id, + NULL, NULL, NULL); + } + } else if(!strcmp(name, "XV_SATURATION")) { xvmc_check_capability (this, VO_PROP_SATURATION, attr[k], - class->adaptor_info[class->adaptor_num].base_id, "XV_SATURATION", + adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); - } else if(!strcmp(attr[k].name, "XV_BRIGHTNESS")) { xvmc_check_capability (this, VO_PROP_BRIGHTNESS, attr[k], - class->adaptor_info[class->adaptor_num].base_id, "XV_BRIGHTNESS", + adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); - - } else if(!strcmp(attr[k].name, "XV_CONTRAST")) { + } else if(!strcmp(name, "XV_CONTRAST")) { xvmc_check_capability (this, VO_PROP_CONTRAST, attr[k], - class->adaptor_info[class->adaptor_num].base_id, "XV_CONTRAST", + adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); - - } else if(!strcmp(attr[k].name, "XV_COLORKEY")) { + } else if(!strcmp(name, "XV_COLORKEY")) { xvmc_check_capability (this, VO_PROP_COLORKEY, attr[k], - class->adaptor_info[class->adaptor_num].base_id, "XV_COLORKEY", + adaptor_info[adaptor_num].base_id, "video.device.xv_colorkey", - _("video overlay colour key"), - _("The colour key is used to tell the graphics card where to " - "overlay the video image. Try different values, if you experience " - "windows becoming transparent.")); - - } else if(!strcmp(attr[k].name, "XV_AUTOPAINT_COLORKEY")) { + VIDEO_DEVICE_XV_COLORKEY_HELP); + } else if(!strcmp(name, "XV_AUTOPAINT_COLORKEY")) { xvmc_check_capability (this, VO_PROP_AUTOPAINT_COLORKEY, attr[k], - class->adaptor_info[class->adaptor_num].base_id, "XV_AUTOPAINT_COLORKEY", + adaptor_info[adaptor_num].base_id, "video.device.xv_autopaint_colorkey", - _("autopaint colour key"), - _("Make Xv autopaint its colour key.")); - - } else if(!strcmp(attr[k].name, "XV_DOUBLE_BUFFER")) { - int xvmc_double_buffer; - xvmc_double_buffer = config->register_bool (config, "video.device.xv_double_buffer", 1, - _("enable double buffering"), - _("Double buffering will synchronize the update of the video image to the " - "repainting of the entire screen (\"vertical retrace\"). This eliminates " - "flickering and tearing artifacts, but will use more graphics memory."), - 20, xvmc_update_XV_DOUBLE_BUFFER, this); + VIDEO_DEVICE_XV_AUTOPAINT_COLORKEY_HELP); + } else if(!strcmp(name, "XV_DOUBLE_BUFFER")) { + int xvmc_double_buffer = config->register_bool (config, "video.device.xv_double_buffer", 1, + VIDEO_DEVICE_XV_DOUBLE_BUFFER_HELP, + 20, xvmc_update_XV_DOUBLE_BUFFER, this); config->update_num(config,"video.device.xv_double_buffer",xvmc_double_buffer); } } @@ -1457,7 +1445,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi /* * check supported image formats */ - fo = XvListImageFormats(display, this->xv_port, (int*)&formats); + fo = XvListImageFormats(this->display, this->xv_port, (int*)&formats); XUnlockDisplay(this->display); this->xvmc_format_yv12 = 0; @@ -1509,10 +1497,6 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi static void dispose_class (video_driver_class_t *this_gen) { xvmc_class_t *this = (xvmc_class_t *) this_gen; - XLockDisplay(this->display); - XvFreeAdaptorInfo (this->adaptor_info); - XUnlockDisplay(this->display); - free (this); } @@ -1685,8 +1669,6 @@ static void *init_class (xine_t *xine, void *visual_gen) { this->display = display; this->config = xine->config; this->xv_port = xv_port; - this->adaptor_info = adaptor_info; - this->adaptor_num = adaptor_num; this->surface_type_id = surface_type; this->max_surface_width = max_width; this->max_surface_height = max_height; -- cgit v1.2.3 From faa7ff213ca3c85b0abde257d5a65b7e4b9c1338 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sat, 2 Feb 2008 00:47:58 +0000 Subject: Convert the XxMC plugin to use the new header file. Also, a few trivial constness cleanups. --- src/video_out/video_out_xxmc.c | 75 +++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_xxmc.c b/src/video_out/video_out_xxmc.c index 7fc136e94..af7f52f54 100644 --- a/src/video_out/video_out_xxmc.c +++ b/src/video_out/video_out_xxmc.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2004 the xine project + * Copyright (C) 2000-2004, 2008 the xine project * Copyright (C) 2004 the Unichrome project * * This file is part of xine, a free video player. @@ -34,9 +34,9 @@ */ - #include "xxmc.h" #include +#include "xv_common.h" static int gX11Fail; @@ -2101,13 +2101,13 @@ static int xxmc_check_yv12 (Display *display, XvPortID port) { /* called xlocked */ static void xxmc_check_capability (xxmc_driver_t *this, - int property, XvAttribute attr, - int base_id, char *str_prop, - char *config_name, - char *config_desc, - char *config_help) { + int property, XvAttribute attr, int base_id, + const char *config_name, + const char *config_desc, + const char *config_help) { int int_default; cfg_entry_t *entry; + const char *str_prop = attr.name; if (VO_PROP_COLORKEY && (attr.max_value == ~0)) attr.max_value = 2147483615; @@ -2580,70 +2580,49 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi for(k = 0; k < nattr; k++) { if((attr[k].flags & XvSettable) && (attr[k].flags & XvGettable)) { - if(!strcmp(attr[k].name, "XV_HUE")) { + const char *const name = attr[k].name; + if(!strcmp(name, "XV_HUE")) { if (!strncmp(adaptor_info[adaptor_num].name, "NV", 2)) { xprintf (this->xine, XINE_VERBOSITY_NONE, LOG_MODULE ": ignoring broken XV_HUE settings on NVidia cards\n"); } else { xxmc_check_capability (this, VO_PROP_HUE, attr[k], - adaptor_info[adaptor_num].base_id, "XV_HUE", + adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); } - } else if(!strcmp(attr[k].name, "XV_SATURATION")) { + } else if(!strcmp(name, "XV_SATURATION")) { xxmc_check_capability (this, VO_PROP_SATURATION, attr[k], - adaptor_info[adaptor_num].base_id, "XV_SATURATION", + adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); - - } else if(!strcmp(attr[k].name, "XV_BRIGHTNESS")) { + } else if(!strcmp(name, "XV_BRIGHTNESS")) { xxmc_check_capability (this, VO_PROP_BRIGHTNESS, attr[k], - adaptor_info[adaptor_num].base_id, "XV_BRIGHTNESS", + adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); - - } else if(!strcmp(attr[k].name, "XV_CONTRAST")) { + } else if(!strcmp(name, "XV_CONTRAST")) { xxmc_check_capability (this, VO_PROP_CONTRAST, attr[k], - adaptor_info[adaptor_num].base_id, "XV_CONTRAST", + adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); - - } else if(!strcmp(attr[k].name, "XV_COLORKEY")) { + } else if(!strcmp(name, "XV_COLORKEY")) { xxmc_check_capability (this, VO_PROP_COLORKEY, attr[k], - adaptor_info[adaptor_num].base_id, "XV_COLORKEY", + adaptor_info[adaptor_num].base_id, "video.device.xv_colorkey", - _("video overlay colour key"), - _("The colour key is used to tell the graphics card where to " - "overlay the video image. Try different values, if you experience " - "windows becoming transparent.")); - - } else if(!strcmp(attr[k].name, "XV_AUTOPAINT_COLORKEY")) { + VIDEO_DEVICE_XV_COLORKEY_HELP); + } else if(!strcmp(name, "XV_AUTOPAINT_COLORKEY")) { xxmc_check_capability (this, VO_PROP_AUTOPAINT_COLORKEY, attr[k], - adaptor_info[adaptor_num].base_id, "XV_AUTOPAINT_COLORKEY", + adaptor_info[adaptor_num].base_id, "video.device.xv_autopaint_colorkey", - _("autopaint colour key"), - _("Make Xv autopaint its colour key.")); - - } else if(!strcmp(attr[k].name, "XV_FILTER")) { + VIDEO_DEVICE_XV_AUTOPAINT_COLORKEY_HELP); + } else if(!strcmp(name, "XV_FILTER")) { int xv_filter; /* This setting is specific to Permedia 2/3 cards. */ xv_filter = config->register_range (config, "video.device.xv_filter", 0, attr[k].min_value, attr[k].max_value, - _("bilinear scaling mode"), - _("Selects the bilinear scaling mode for Permedia cards. " - "The individual values are:\n\n" - "Permedia 2\n" - "0 - disable bilinear filtering\n" - "1 - enable bilinear filtering\n\n" - "Permedia 3\n" - "0 - disable bilinear filtering\n" - "1 - horizontal linear filtering\n" - "2 - enable full bilinear filtering"), + VIDEO_DEVICE_XV_FILTER_HELP, 20, xxmc_update_XV_FILTER, this); config->update_num(config,"video.device.xv_filter",xv_filter); - } else if(!strcmp(attr[k].name, "XV_DOUBLE_BUFFER")) { - int xv_double_buffer; - xv_double_buffer = + } else if(!strcmp(name, "XV_DOUBLE_BUFFER")) { + int xv_double_buffer = config->register_bool (config, "video.device.xv_double_buffer", 1, - _("enable double buffering"), - _("Double buffering will synchronize the update of the video image to the " - "repainting of the entire screen (\"vertical retrace\"). This eliminates " - "flickering and tearing artifacts, but will use more graphics memory."), + VIDEO_DEVICE_XV_DOUBLE_BUFFER_HELP, 20, xxmc_update_XV_DOUBLE_BUFFER, this); config->update_num(config,"video.device.xv_double_buffer",xv_double_buffer); } -- cgit v1.2.3 From d51d909e4cad6d49827ac23b36a99abd8f485eac Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sat, 2 Feb 2008 17:36:33 +0000 Subject: Handle invalid port nos. properly (avoids a possible xcbxv segfault). --HG-- extra : transplant_source : %8AQ%03%86%FE%20%26%92%D2%A6%13g%1E%85%60%14%A0%A9%F3%22 --- src/video_out/video_out_xcbxv.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/video_out/video_out_xcbxv.c b/src/video_out/video_out_xcbxv.c index 63313c43a..5064e89ad 100644 --- a/src/video_out/video_out_xcbxv.c +++ b/src/video_out/video_out_xcbxv.c @@ -945,6 +945,8 @@ static int xv_check_yv12(xcb_connection_t *connection, xcb_xv_port_t port) { list_formats_cookie = xcb_xv_list_image_formats(connection, port); list_formats_reply = xcb_xv_list_image_formats_reply(connection, list_formats_cookie, NULL); + if (!list_formats_reply) + return 1; /* no formats listed; probably due to an invalid port no. */ format_it = xcb_xv_list_image_formats_format_iterator(list_formats_reply); for (; format_it.rem; xcb_xv_image_format_info_next(&format_it)) -- cgit v1.2.3 From 4eed5fa989c8547195f7035fd59a1430b8962c5a Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sat, 2 Feb 2008 18:18:15 +0000 Subject: Move more shared Xv config desc. & help strings; add new location to POTFILES. --- src/video_out/video_out_xcbxv.c | 6 ++---- src/video_out/video_out_xv.c | 6 ++---- src/video_out/video_out_xxmc.c | 6 ++---- src/video_out/xv_common.h | 8 ++++++++ 4 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_xcbxv.c b/src/video_out/video_out_xcbxv.c index 5064e89ad..f61ae6a9c 100644 --- a/src/video_out/video_out_xcbxv.c +++ b/src/video_out/video_out_xcbxv.c @@ -1197,8 +1197,7 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis adaptor_it = xcb_xv_query_adaptors_info_iterator(query_adaptors_reply); xv_port = config->register_num (config, "video.device.xv_port", 0, - _("Xv port number"), - _("Selects the Xv port number to use (0 to autodetect)."), + VIDEO_DEVICE_XV_PORT_HELP, 10, NULL, NULL); if (xv_port != 0) { @@ -1380,8 +1379,7 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis this->use_pitch_alignment = config->register_bool (config, "video.device.xv_pitch_alignment", 0, - _("pitch alignment workaround"), - _("Some buggy video drivers need a workaround to function properly."), + VIDEO_DEVICE_XV_PITCH_ALIGNMENT_HELP, 10, xv_update_xv_pitch_alignment, this); if(this->use_colorkey==1) { diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index a92f6dbe8..6cdbc6b64 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -1233,8 +1233,7 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * } xv_port = config->register_num (config, "video.device.xv_port", 0, - _("Xv port number"), - _("Selects the Xv port number to use (0 to autodetect)."), + VIDEO_DEVICE_XV_PORT_HELP, 10, NULL, NULL); if (xv_port != 0) { @@ -1438,8 +1437,7 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * this->use_pitch_alignment = config->register_bool (config, "video.device.xv_pitch_alignment", 0, - _("pitch alignment workaround"), - _("Some buggy video drivers need a workaround to function properly."), + VIDEO_DEVICE_XV_PITCH_ALIGNMENT_HELP, 10, xv_update_xv_pitch_alignment, this); LOCK_DISPLAY(this); diff --git a/src/video_out/video_out_xxmc.c b/src/video_out/video_out_xxmc.c index af7f52f54..107ed9c7b 100644 --- a/src/video_out/video_out_xxmc.c +++ b/src/video_out/video_out_xxmc.c @@ -2478,8 +2478,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi } xv_port = config->register_num (config, "video.device.xv_port", 0, - _("Xv port number"), - _("Selects the Xv port number to use (0 to autodetect)."), + VIDEO_DEVICE_XV_PORT_HELP, 10, NULL, NULL); if (xv_port != 0) { @@ -2688,8 +2687,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi this->use_pitch_alignment = config->register_bool (config, "video.device.xv_pitch_alignment", 0, - _("pitch alignment workaround"), - _("Some buggy video drivers need a workaround to function properly."), + VIDEO_DEVICE_XV_PITCH_ALIGNMENT_HELP, 10, xxmc_update_xv_pitch_alignment, this); use_more_frames= diff --git a/src/video_out/xv_common.h b/src/video_out/xv_common.h index 71eecddad..ee2ab9a10 100644 --- a/src/video_out/xv_common.h +++ b/src/video_out/xv_common.h @@ -48,3 +48,11 @@ "image to the repainting of the entire screen (\"vertical " \ "retrace\"). This eliminates flickering and tearing artifacts, " \ "but will use more graphics memory.") + +#define VIDEO_DEVICE_XV_PORT_HELP \ + _("Xv port number"), \ + _("Selects the Xv port number to use (0 to autodetect).") + +#define VIDEO_DEVICE_XV_PITCH_ALIGNMENT_HELP \ + _("pitch alignment workaround"), \ + _("Some buggy video drivers need a workaround to function properly.") -- cgit v1.2.3 From 15ed98032861393d23adf4076c704a0d85361895 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sun, 3 Feb 2008 00:34:10 +0000 Subject: The AVI demuxer already has the video type when checking for XVid. Optimise. --- src/demuxers/demux_avi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c index c6a73ebde..239517777 100644 --- a/src/demuxers/demux_avi.c +++ b/src/demuxers/demux_avi.c @@ -1899,8 +1899,8 @@ static void demux_avi_send_headers (demux_plugin_t *this_gen) { * however, at least for this case (compressor: xvid biCompression: DIVX), the * xvid fourcc must prevail as it is used by ffmpeg to detect encoder bugs. [MF] */ - if( _x_fourcc_to_buf_video(this->avi->compressor) == BUF_VIDEO_XVID && - _x_fourcc_to_buf_video(this->avi->bih->biCompression) == BUF_VIDEO_MPEG4 ) { + if( this->avi->video_type == BUF_VIDEO_MPEG4 && + _x_fourcc_to_buf_video(this->avi->compressor) == BUF_VIDEO_XVID ) { this->avi->bih->biCompression = this->avi->compressor; this->avi->video_type = BUF_VIDEO_XVID; } -- cgit v1.2.3 From 07252cde358272ec7a65f9d862462ba5ca08d682 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Mon, 4 Feb 2008 00:25:26 +0000 Subject: Fix a few remaining and apparently harmless linkage order issues. --- src/video_out/Makefile.am | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/video_out/Makefile.am b/src/video_out/Makefile.am index d447417c5..6376e7629 100644 --- a/src/video_out/Makefile.am +++ b/src/video_out/Makefile.am @@ -130,8 +130,8 @@ xineplug_vo_out_xxmc_la_CFLAGS = $(VISIBILITY_FLAG) $(X_CFLAGS) $(XV_CFLAGS) -fn xineplug_vo_out_opengl_la_SOURCES = yuv2rgb.c yuv2rgb_mmx.c yuv2rgb_mlib.c \ video_out_opengl.c myglext.h $(X11OSD) -xineplug_vo_out_opengl_la_LIBADD = $(MLIB_LIBS) $(OPENGL_LIBS) $(GLUT_LIBS) \ - $(GLU_LIBS) $(X_LIBS) $(XINE_LIB) $(PTHREAD_LIBS) $(DYNAMIC_LD_LIBS) $(LTLIBINTL) +xineplug_vo_out_opengl_la_LIBADD = $(XINE_LIB) $(MLIB_LIBS) $(OPENGL_LIBS) \ + $(GLUT_LIBS) $(GLU_LIBS) $(X_LIBS) $(PTHREAD_LIBS) $(DYNAMIC_LD_LIBS) $(LTLIBINTL) xineplug_vo_out_opengl_la_CFLAGS = $(VISIBILITY_FLAG) $(X_CFLAGS) $(MLIB_CFLAGS) -fno-strict-aliasing xineplug_vo_out_syncfb_la_SOURCES = video_out_syncfb.c @@ -193,8 +193,8 @@ xineplug_vo_out_none_la_CFLAGS = $(VISIBILITY_FLAG) xineplug_vo_out_macosx_la_SOURCES = video_out_macosx.m xineplug_vo_out_macosx_la_CPPFLAGS = $(AM_CPPFLAGS) $(X_CFLAGS) $(MLIB_CFLAGS) xineplug_vo_out_macosx_la_OBJCFLAGS = $(VISIBILITY_FLAG) -xineplug_vo_out_macosx_la_LIBADD = $(MLIB_LIBS) $(OPENGL_LIBS) $(GLUT_LIBS) \ - $(GLU_LIBS) $(X_LIBS) $(XINE_LIB) $(PTHREAD_LIBS) +xineplug_vo_out_macosx_la_LIBADD = $(XINE_LIB) $(MLIB_LIBS) $(OPENGL_LIBS) \ + $(GLUT_LIBS) $(GLU_LIBS) $(X_LIBS) $(PTHREAD_LIBS) # The "-Wl,-framework -Wl,Cocoa" is needed for libtool versions before # 1.5.x (1.257): the default version that ships with Mac OS X is 1.5 (1.1220) xineplug_vo_out_macosx_la_LDFLAGS = $(AM_LDFLAGS) \ -- cgit v1.2.3 From b9aad123aa3af9db55ce604b3eb185e26b0361a5 Mon Sep 17 00:00:00 2001 From: Mathieu Olivier Date: Mon, 4 Feb 2008 15:08:25 +0000 Subject: Check block sizes & frame sizes. Use unsigned variables where appropriate. --- src/demuxers/demux_matroska.c | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_matroska.c b/src/demuxers/demux_matroska.c index b973c1caf..3c992ecca 100644 --- a/src/demuxers/demux_matroska.c +++ b/src/demuxers/demux_matroska.c @@ -1836,7 +1836,7 @@ static int parse_block (demux_matroska_t *this, uint64_t block_size, uint64_t cluster_timecode, uint64_t block_duration, int normpos, int is_key) { matroska_track_t *track; - int64_t track_num; + uint64_t track_num; uint8_t *data; uint8_t flags; int gap, lacing, num_len; @@ -1855,7 +1855,7 @@ static int parse_block (demux_matroska_t *this, uint64_t block_size, flags = *data; data += 1; - lprintf("track_num: %" PRId64 ", timecode_diff: %d, flags: 0x%x\n", track_num, timecode_diff, flags); + lprintf("track_num: %" PRIu64 ", timecode_diff: %d, flags: 0x%x\n", track_num, timecode_diff, flags); gap = flags & 1; lacing = (flags >> 1) & 0x3; @@ -1863,7 +1863,7 @@ static int parse_block (demux_matroska_t *this, uint64_t block_size, if (!find_track_by_id(this, (int)track_num, &track)) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - "demux_matroska: invalid track id: %" PRId64 "\n", track_num); + "demux_matroska: invalid track id: %" PRIu64 "\n", track_num); return 0; } @@ -1972,24 +1972,51 @@ static int parse_block (demux_matroska_t *this, uint64_t block_size, break; case MATROSKA_EBML_LACING: { - int64_t tmp; + uint64_t first_frame_size; lprintf("ebml lacing\n"); /* size of each frame */ - if (!(num_len = parse_ebml_uint(this, data, &tmp))) + if (!(num_len = parse_ebml_uint(this, data, &first_frame_size))) return 0; + if (num_len > block_size_left) { + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + "demux_matroska: block too small\n"); + return 0; + } + if (first_frame_size > INT_MAX) { + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + "demux_matroska: invalid first frame size (%" PRId64 ")\n", + first_frame_size); + return 0; + } data += num_len; block_size_left -= num_len; - frame[0] = (int) tmp; + frame[0] = (int) first_frame_size; lprintf("first frame len: %d\n", frame[0]); block_size_left -= frame[0]; for (i = 1; i < lace_num; i++) { - if (!(num_len = parse_ebml_sint(this, data, &tmp))) + int64_t frame_size_diff; + int64_t frame_size; + + if (!(num_len = parse_ebml_sint(this, data, &frame_size_diff))) return 0; + if (num_len > block_size_left) { + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + "demux_matroska: block too small\n"); + return 0; + } data += num_len; block_size_left -= num_len; - frame[i] = frame[i-1] + tmp; + + frame_size = frame[i-1] + frame_size_diff; + if (frame_size > INT_MAX || frame_size < 0) { + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + "demux_matroska: invalid frame size (%" PRId64 ")\n", + frame_size); + return 0; + } + frame[i] = frame_size; block_size_left -= frame[i]; } -- cgit v1.2.3 From dac76e08eaf7a876df7d251d613b4a175dbbe2ff Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Mon, 4 Feb 2008 16:54:51 +0000 Subject: Backed out changeset a8b157e7359c (reported to cause a regression). A proper fix is in changeset a62d6f482a69. --- src/demuxers/demux_matroska.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_matroska.c b/src/demuxers/demux_matroska.c index f8166173a..7deceb500 100644 --- a/src/demuxers/demux_matroska.c +++ b/src/demuxers/demux_matroska.c @@ -1845,7 +1845,7 @@ static int parse_block (demux_matroska_t *this, uint64_t block_size, int decoder_flags = 0; data = this->block_data; - if (!(num_len = parse_ebml_sint(this, data, &track_num))) + if (!(num_len = parse_ebml_uint(this, data, &track_num))) return 0; data += num_len; @@ -1977,7 +1977,7 @@ static int parse_block (demux_matroska_t *this, uint64_t block_size, lprintf("ebml lacing\n"); /* size of each frame */ - if (!(num_len = parse_ebml_sint(this, data, &tmp))) + if (!(num_len = parse_ebml_uint(this, data, &tmp))) return 0; data += num_len; block_size_left -= num_len; frame[0] = (int) tmp; -- cgit v1.2.3 From 62edd260de78d783eda0174c65a991389b5343ab Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Mon, 4 Feb 2008 16:50:37 +0000 Subject: Silence vdr_video (unless LOG and LOG_VERBOSE are defined). --HG-- extra : transplant_source : %B3%7E6%F5%18%80i%20rb%10m%8AA8G%87%F5%A8r --- src/vdr/post_vdr_video.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/vdr/post_vdr_video.c b/src/vdr/post_vdr_video.c index 4d1055aaf..178538655 100644 --- a/src/vdr/post_vdr_video.c +++ b/src/vdr/post_vdr_video.c @@ -23,9 +23,9 @@ */ #define LOG_MODULE "vdr_video" -#define LOG_VERBOSE /* #define LOG +#define LOG_VERBOSE */ #include @@ -437,12 +437,14 @@ static int vdr_video_draw(vo_frame_t *frame, xine_stream_t *stream) frame->next->pts = 0; } */ +#if defined(LOG) && defined(LOG_VERBOSE) { int a = 0, b = 0, c = 0, d = 0; if (stream) _x_query_buffer_usage(stream, &a, &b, &c, &d); - fprintf(stderr, "buffer usage: %3d, %2d, %2d, %2d, %p\n", a, b, c, d, stream); + lprintf("buffer usage: %3d, %2d, %2d, %2d, %p\n", a, b, c, d, stream); } +#endif if (!this->enabled || frame->bad_frame -- cgit v1.2.3 From 9ce813b22bb06b78c97c5c249e8feeb2ec1441bd Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Mon, 4 Feb 2008 17:19:22 +0000 Subject: Tidy up Xv YUY2/YV12 checking & reporting. --- src/video_out/video_out_xcbxv.c | 13 +++++++++---- src/video_out/video_out_xv.c | 13 +++++++++---- src/video_out/video_out_xvmc.c | 20 +++++++++++++------- src/video_out/video_out_xxmc.c | 13 +++++++++---- 4 files changed, 40 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_xcbxv.c b/src/video_out/video_out_xcbxv.c index f61ae6a9c..6fed0f90a 100644 --- a/src/video_out/video_out_xcbxv.c +++ b/src/video_out/video_out_xcbxv.c @@ -1362,16 +1362,21 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis (format_it.data->format == XCB_XV_IMAGE_FORMAT_INFO_FORMAT_PACKED) ? "packed" : "planar"); - if (format_it.data->id == XINE_IMGFMT_YV12) { + switch (format_it.data->id) { + case XINE_IMGFMT_YV12: this->xv_format_yv12 = format_it.data->id; this->capabilities |= VO_CAP_YV12; xprintf(this->xine, XINE_VERBOSITY_LOG, - _("%s: this adaptor supports the yv12 format.\n"), LOG_MODULE); - } else if (format_it.data->id == XINE_IMGFMT_YUY2) { + _("%s: this adaptor supports the %s format.\n"), LOG_MODULE, "YV12"); + break; + case XINE_IMGFMT_YUY2: this->xv_format_yuy2 = format_it.data->id; this->capabilities |= VO_CAP_YUY2; xprintf(this->xine, XINE_VERBOSITY_LOG, - _("%s: this adaptor supports the yuy2 format.\n"), LOG_MODULE); + _("%s: this adaptor supports the %s format.\n"), LOG_MODULE, "YUY2"); + break; + default: + break; } } diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index 6cdbc6b64..6f5c68e51 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -1406,16 +1406,21 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * fo[i].id, (char*)&fo[i].id, (fo[i].format == XvPacked) ? "packed" : "planar"); - if (fo[i].id == XINE_IMGFMT_YV12) { + switch (fo[i].id) { + case XINE_IMGFMT_YV12: this->xv_format_yv12 = fo[i].id; this->capabilities |= VO_CAP_YV12; xprintf(this->xine, XINE_VERBOSITY_LOG, - _("%s: this adaptor supports the yv12 format.\n"), LOG_MODULE); - } else if (fo[i].id == XINE_IMGFMT_YUY2) { + _("%s: this adaptor supports the %s format.\n"), LOG_MODULE, "YV12"); + break; + case XINE_IMGFMT_YUY2: this->xv_format_yuy2 = fo[i].id; this->capabilities |= VO_CAP_YUY2; xprintf(this->xine, XINE_VERBOSITY_LOG, - _("%s: this adaptor supports the yuy2 format.\n"), LOG_MODULE); + _("%s: this adaptor supports the %s format.\n"), LOG_MODULE, "YUY2"); + break; + default: + break; } } diff --git a/src/video_out/video_out_xvmc.c b/src/video_out/video_out_xvmc.c index c0fb10be3..9618b082c 100644 --- a/src/video_out/video_out_xvmc.c +++ b/src/video_out/video_out_xvmc.c @@ -1456,15 +1456,21 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi fo[i].id, (char*)&fo[i].id, (fo[i].format == XvPacked) ? "packed" : "planar"); - if (fo[i].id == XINE_IMGFMT_YV12) { + switch (fo[i].id) { + case XINE_IMGFMT_YV12: this->xvmc_format_yv12 = fo[i].id; - this->capabilities |= VO_CAP_YV12; - lprintf("this adaptor supports the yv12 format.\n"); - } - else if (fo[i].id == XINE_IMGFMT_YUY2) { + this->capabilities |= VO_CAP_YV12; + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: this adaptor supports the %s format.\n"), LOG_MODULE, "YV12"); + break; + case XINE_IMGFMT_YUY2: this->xvmc_format_yuy2 = fo[i].id; - this->capabilities |= VO_CAP_YUY2; - lprintf("this adaptor supports the yuy2 format.\n"); + this->capabilities |= VO_CAP_YUY2; + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: this adaptor supports the %s format.\n"), LOG_MODULE, "YUY2"); + break; + default: + break; } } diff --git a/src/video_out/video_out_xxmc.c b/src/video_out/video_out_xxmc.c index 107ed9c7b..2c42dda2e 100644 --- a/src/video_out/video_out_xxmc.c +++ b/src/video_out/video_out_xxmc.c @@ -2655,16 +2655,21 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi fo[i].id, (char*)&fo[i].id, (fo[i].format == XvPacked) ? "packed" : "planar"); - if (fo[i].id == XINE_IMGFMT_YV12) { + switch (fo[i].id) { + case XINE_IMGFMT_YV12: this->xv_format_yv12 = fo[i].id; this->capabilities |= VO_CAP_YV12; xprintf(this->xine, XINE_VERBOSITY_LOG, - _("%s: this adaptor supports the yv12 format.\n"), LOG_MODULE); - } else if (fo[i].id == XINE_IMGFMT_YUY2) { + _("%s: this adaptor supports the %s format.\n"), LOG_MODULE, "YV12"); + break; + case XINE_IMGFMT_YUY2: this->xv_format_yuy2 = fo[i].id; this->capabilities |= VO_CAP_YUY2; xprintf(this->xine, XINE_VERBOSITY_LOG, - _("%s: this adaptor supports the yuy2 format.\n"), LOG_MODULE); + _("%s: this adaptor supports the %s format.\n"), LOG_MODULE, "YUY2"); + break; + default: + break; } } -- cgit v1.2.3 From 1258f00aaa71c16800717caf628f69f2e8e6f4ca Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Mon, 4 Feb 2008 18:16:37 +0000 Subject: Report the identifiers of unrecognised video & audio codecs. --- src/combined/xine_ogg_demuxer.c | 9 +++++++-- src/demuxers/demux_asf.c | 9 +++------ src/demuxers/demux_avi.c | 11 +++++++++-- src/demuxers/demux_film.c | 4 ++++ src/demuxers/demux_matroska.c | 4 ++++ src/demuxers/demux_nsv.c | 8 ++++++++ src/demuxers/demux_qt.c | 8 ++++++++ src/demuxers/demux_real.c | 6 ++++++ src/demuxers/demux_smjpeg.c | 4 ++++ src/xine-engine/buffer_types.c | 39 +++++++++++++++++++++++++++++++++++++++ 10 files changed, 92 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/combined/xine_ogg_demuxer.c b/src/combined/xine_ogg_demuxer.c index b09bc1a41..88fcea08a 100644 --- a/src/combined/xine_ogg_demuxer.c +++ b/src/combined/xine_ogg_demuxer.c @@ -892,7 +892,10 @@ static void decode_video_header (demux_ogg_t *this, const int stream_num, ogg_pa this->si[stream_num]->buf_types = _x_fourcc_to_buf_video (locsubtype); if( !this->si[stream_num]->buf_types ) + { this->si[stream_num]->buf_types = BUF_VIDEO_UNKNOWN; + _x_report_video_fourcc (this->stream->xine, LOG_MODULE, locsubtype); + } this->si[stream_num]->buf_types |= channel; this->si[stream_num]->headers = 0; /* header is sent below */ @@ -977,9 +980,8 @@ static void decode_audio_header (demux_ogg_t *this, const int stream_num, ogg_pa if( this->si[stream_num]->buf_types ) { this->si[stream_num]->buf_types |= channel; } else { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, - "demux_ogg: unknown audio codec type 0x%x\n", codec); this->si[stream_num]->buf_types = BUF_AUDIO_UNKNOWN; + _x_report_audio_format_tag (this->stream->xine, LOG_MODULE, codec); /*break;*/ } @@ -1044,7 +1046,10 @@ static void decode_dshow_header (demux_ogg_t *this, const int stream_num, ogg_pa this->si[stream_num]->buf_types = _x_fourcc_to_buf_video (fcc); if( !this->si[stream_num]->buf_types ) + { this->si[stream_num]->buf_types = BUF_VIDEO_UNKNOWN; + _x_report_video_fourcc (this->stream->xine, LOG_MODULE, fcc); + } this->si[stream_num]->buf_types |= channel; bih.biSize = sizeof(xine_bmiheader); diff --git a/src/demuxers/demux_asf.c b/src/demuxers/demux_asf.c index 827557333..73f70eeb3 100644 --- a/src/demuxers/demux_asf.c +++ b/src/demuxers/demux_asf.c @@ -464,10 +464,9 @@ static int asf_read_header (demux_asf_t *this) { demux_stream->buf_type = _x_formattag_to_buf_audio ( ((xine_waveformatex *)asf_stream->private_data)->wFormatTag ); if ( !demux_stream->buf_type ) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, - "demux_asf: unknown audio type 0x%x\n", - ((xine_waveformatex *)asf_stream->private_data)->wFormatTag); demux_stream->buf_type = BUF_AUDIO_UNKNOWN; + _x_report_audio_format_tag (this->stream->xine, LOG_MODULE, + ((xine_waveformatex *)asf_stream->private_data)->wFormatTag); } _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC, _x_buf_audio_name(demux_stream->buf_type)); @@ -510,10 +509,8 @@ static int asf_read_header (demux_asf_t *this) { demux_stream->buf_type = _x_fourcc_to_buf_video(bmiheader->biCompression); if( !demux_stream->buf_type ) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, - "demux_asf: unknown video format %.4s\n", (char*)&(bmiheader->biCompression)); - demux_stream->buf_type = BUF_VIDEO_UNKNOWN; + _x_report_video_fourcc (this->stream->xine, LOG_MODULE, bmiheader->biCompression); } _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, _x_buf_video_name(demux_stream->buf_type)); diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c index 239517777..27dfce443 100644 --- a/src/demuxers/demux_avi.c +++ b/src/demuxers/demux_avi.c @@ -1871,7 +1871,12 @@ static void demux_avi_send_headers (demux_plugin_t *this_gen) { if (!this->avi->bih->biCompression) this->avi->video_type = BUF_VIDEO_RGB; else + { this->avi->video_type = _x_fourcc_to_buf_video(this->avi->bih->biCompression); + if (!this->avi->video_type) + _x_report_video_fourcc (this->stream->xine, LOG_MODULE, + this->avi->bih->biCompression); + } for(i=0; i < this->avi->n_audio; i++) { this->avi->audio[i]->audio_type = _x_formattag_to_buf_audio (this->avi->audio[i]->wavex->wFormatTag); @@ -1884,10 +1889,10 @@ static void demux_avi_send_headers (demux_plugin_t *this_gen) { } if( !this->avi->audio[i]->audio_type ) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "unknown audio type 0x%x\n", - this->avi->audio[i]->wavex->wFormatTag); this->no_audio = 1; this->avi->audio[i]->audio_type = BUF_AUDIO_UNKNOWN; + _x_report_audio_format_tag (this->stream->xine, LOG_MODULE, + this->avi->audio[i]->wavex->wFormatTag); } else xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_avi: audio type %s (wFormatTag 0x%x)\n", _x_buf_audio_name(this->avi->audio[i]->audio_type), @@ -1949,6 +1954,8 @@ static void demux_avi_send_headers (demux_plugin_t *this_gen) { this->avi->compressor = this->avi->bih->biCompression; } else { this->avi->video_type = _x_fourcc_to_buf_video(this->avi->compressor); + if (!this->avi->video_type) + _x_fourcc_to_buf_video(this->avi->bih->biCompression); } _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_FOURCC, diff --git a/src/demuxers/demux_film.c b/src/demuxers/demux_film.c index cc9e90d66..193d8850b 100644 --- a/src/demuxers/demux_film.c +++ b/src/demuxers/demux_film.c @@ -201,7 +201,11 @@ static int open_film_file(demux_film_t *film) { film->video_type = _x_fourcc_to_buf_video(*(uint32_t *)&film_header[i + 8]); if( !film->video_type ) + { film->video_type = BUF_VIDEO_UNKNOWN; + _x_report_video_fourcc (film->stream->xine, LOG_MODULE, + *(uint32_t *)&film_header[i + 8]); + } /* fetch the audio information if the chunk size checks out */ if (chunk_size == 32) { diff --git a/src/demuxers/demux_matroska.c b/src/demuxers/demux_matroska.c index 9b32f02c9..ae71923d6 100644 --- a/src/demuxers/demux_matroska.c +++ b/src/demuxers/demux_matroska.c @@ -1303,6 +1303,8 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) { _x_bmiheader_le2me(bih); track->buf_type = _x_fourcc_to_buf_video(bih->biCompression); + if (!track->buf_type) + _x_report_video_fourcc (this->stream->xine, LOG_MODULE, bih->biCompression); init_codec = init_codec_video; } else if (!strcmp(track->codec_id, MATROSKA_CODEC_ID_V_UNCOMPRESSED)) { @@ -1413,6 +1415,8 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) { _x_waveformatex_le2me(wfh); track->buf_type = _x_formattag_to_buf_audio(wfh->wFormatTag); + if (!track->buf_type) + _x_report_audio_format_tag (this->stream->xine, LOG_MODULE, wfh->wFormatTag); init_codec = init_codec_audio; } else if (!strncmp(track->codec_id, MATROSKA_CODEC_ID_A_AAC, sizeof(MATROSKA_CODEC_ID_A_AAC) - 1)) { diff --git a/src/demuxers/demux_nsv.c b/src/demuxers/demux_nsv.c index 74f98c7cd..43b1fbc88 100644 --- a/src/demuxers/demux_nsv.c +++ b/src/demuxers/demux_nsv.c @@ -305,13 +305,21 @@ static int open_nsv_file(demux_nsv_t *this) { if (_X_BE_32(&preview[4]) == NONE_TAG) this->video_type = 0; else + { this->video_type = _x_fourcc_to_buf_video(this->video_fourcc); + if (!this->video_type) + _x_report_video_fourcc (this->stream->xine, LOG_MODULE, this->video_fourcc); + } this->audio_fourcc = _X_ME_32(&preview[8]); if (_X_BE_32(&preview[8]) == NONE_TAG) this->audio_type = 0; else + { this->audio_type = _x_formattag_to_buf_audio(this->audio_fourcc); + if (!this->audio_type) + _x_report_audio_format_tag (this->stream->xine, LOG_MODULE, this->audio_fourcc); + } this->bih.biSize = sizeof(this->bih); this->bih.biWidth = _X_LE_16(&preview[12]); diff --git a/src/demuxers/demux_qt.c b/src/demuxers/demux_qt.c index 6b2aa5eea..ecd2c319a 100644 --- a/src/demuxers/demux_qt.c +++ b/src/demuxers/demux_qt.c @@ -2628,7 +2628,11 @@ static void demux_qt_send_headers(demux_plugin_t *this_gen) { if( !video_trak->properties->video.codec_buftype && video_trak->properties->video.codec_fourcc ) + { video_trak->properties->video.codec_buftype = BUF_VIDEO_UNKNOWN; + _x_report_video_fourcc (this->stream->xine, LOG_MODULE, + video_trak->properties->video.codec_fourcc); + } _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, 1); _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, @@ -2670,7 +2674,11 @@ static void demux_qt_send_headers(demux_plugin_t *this_gen) { if( !audio_trak->properties->audio.codec_buftype && audio_trak->properties->audio.codec_fourcc ) + { audio_trak->properties->audio.codec_buftype = BUF_AUDIO_UNKNOWN; + _x_report_audio_format_tag (this->stream->xine, LOG_MODULE, + audio_trak->properties->audio.codec_fourcc); + } _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, 1); _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_CHANNELS, diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c index 8f6ce0611..41c6fb4a2 100644 --- a/src/demuxers/demux_real.c +++ b/src/demuxers/demux_real.c @@ -459,6 +459,9 @@ static void real_parse_headers (demux_real_t *this) { this->num_audio_streams++; + if (!this->audio_streams[this->num_audio_streams].buf_type) + _x_report_audio_format_tag (this->stream->xine, LOG_MODULE, fourcc); + } else if(_X_BE_32(mdpr->type_specific_data + 4) == VIDO_TAG) { if(this->num_video_streams == MAX_VIDEO_STREAMS) { @@ -479,6 +482,9 @@ static void real_parse_headers (demux_real_t *this) { this->num_video_streams++; + if (!this->video_streams[this->num_video_streams].buf_type) + _x_report_video_fourcc (this->stream->xine, LOG_MODULE, fourcc); + } else { lprintf("unrecognised type specific data\n"); diff --git a/src/demuxers/demux_smjpeg.c b/src/demuxers/demux_smjpeg.c index 10cdf8120..d9b436032 100644 --- a/src/demuxers/demux_smjpeg.c +++ b/src/demuxers/demux_smjpeg.c @@ -147,6 +147,8 @@ static int open_smjpeg_file(demux_smjpeg_t *this) { this->bih.biHeight = _X_BE_16(&header_chunk[10]); this->bih.biCompression = *(uint32_t *)&header_chunk[12]; this->video_type = _x_fourcc_to_buf_video(this->bih.biCompression); + if (!this->video_type) + _x_report_video_fourcc (this->stream->xine, LOG_MODULE, this->bih.biCompression); break; case _SND_TAG: @@ -166,6 +168,8 @@ static int open_smjpeg_file(demux_smjpeg_t *this) { } else { audio_codec = *(uint32_t *)&header_chunk[8]; this->audio_type = _x_formattag_to_buf_audio(audio_codec); + if (!this->audio_type) + _x_report_audio_format_tag (this->stream->xine, LOG_MODULE, audio_codec); } break; diff --git a/src/xine-engine/buffer_types.c b/src/xine-engine/buffer_types.c index c7b6ae860..b0e01db31 100644 --- a/src/xine-engine/buffer_types.c +++ b/src/xine-engine/buffer_types.c @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include "bswap.h" typedef struct video_db_s { @@ -1209,6 +1211,43 @@ int i; return ""; } + +static void code_to_text (char ascii[5], uint32_t code) +{ + int i; + for (i = 0; i < 4; ++i) + { + int byte = code & 0xFF; + ascii[i] = (byte < ' ') ? ' ' : (byte >= 0x7F) ? '.' : (char) byte; + code >>= 8; + } +} + +void _x_report_video_fourcc (xine_t *xine, const char *module, uint32_t code) +{ + if (code) + { + char ascii[5]; + code_to_text (ascii, code); + xprintf (xine, XINE_VERBOSITY_LOG, + _("%s: unknown video FourCC code %#x \"%s\"\n"), + module, code, ascii); + } +} + +void _x_report_audio_format_tag (xine_t *xine, const char *module, uint32_t code) +{ + if (code) + { + char ascii[5]; + code_to_text (ascii, code); + xprintf (xine, XINE_VERBOSITY_LOG, + _("%s: unknown audio format tag code %#x \"%s\"\n"), + module, code, ascii); + } +} + + void _x_bmiheader_le2me( xine_bmiheader *bih ) { /* OBS: fourcc must be read using machine endianness * so don't play with biCompression here! -- cgit v1.2.3 From fac37975dd471c945145e5f147932170d4f4198f Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 6 Feb 2008 18:27:31 +0000 Subject: Change from release numbering to ABI numbering for the plugin directory. This is to avoid having to rebuild external plugins for each new release. --HG-- extra : transplant_source : %C2%3EF%0B%EF%16%40K%FD.%EB9%E07%CB%97GhU%98 --- src/xine-engine/load_plugins.c | 79 +++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index 71cb19d3b..11a74b097 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -1119,14 +1119,24 @@ static void load_cached_catalog (xine_t *this) { } +/* helper function for _x_scan_plugins */ +static void push_if_dir (xine_list_t *plugindirs, void *path) +{ + struct stat st; + if (!stat (path, &st) && S_ISDIR (st.st_mode)) + xine_list_push_back (plugindirs, path); + else + free (path); +} + /* * initialize catalog, load all plugins into new catalog */ void _x_scan_plugins (xine_t *this) { - - char *homedir, *plugindir, *pluginpath; - int i,j; - int lenpluginpath; + + char *homedir, *pluginpath; + xine_list_t *plugindirs = xine_list_new (); + xine_list_iterator_t iter; lprintf("_x_scan_plugins()\n"); @@ -1140,41 +1150,38 @@ void _x_scan_plugins (xine_t *this) { this->plugin_catalog = _new_catalog(); load_cached_catalog (this); - if ((pluginpath = getenv("XINE_PLUGIN_PATH")) != NULL) { - pluginpath = strdup(pluginpath); + if ((pluginpath = getenv("XINE_PLUGIN_PATH")) != NULL && *pluginpath) { + char *p = pluginpath - 1; + while (p[1]) + { + char *dir, *q = p; + p = strchr (p + 1, XINE_PATH_SEPARATOR_CHAR); + if (q[0] == '~' && q[1] == '/') + asprintf (&dir, "%s%.*s", homedir, (int)(p - q - 1), q + 1); + else + dir = strndup (q, p - q); + push_if_dir (plugindirs, dir); /* store or free it */ + } } else { - const char *str1, *str2; - int len; - - str1 = "~/.xine/plugins"; - str2 = XINE_PLUGINDIR; - len = strlen(str1) + strlen(str2) + 2; - pluginpath = xine_xmalloc(len); - snprintf(pluginpath, len, "%s" XINE_PATH_SEPARATOR_STRING "%s", str1, str2); - } - plugindir = xine_xmalloc(strlen(pluginpath)+strlen(homedir)+2); - j=0; - lenpluginpath = strlen(pluginpath); - for (i=0; i <= lenpluginpath; ++i){ - switch (pluginpath[i]){ - case XINE_PATH_SEPARATOR_CHAR: - case '\0': - plugindir[j] = '\0'; - collect_plugins(this, plugindir); - j = 0; - break; - case '~': - if (j == 0){ - strcpy(plugindir, homedir); - j = strlen(plugindir); - break; - } - default: - plugindir[j++] = pluginpath[i]; + char *dir; + int i; + asprintf (&dir, "%s/.xine/plugins", homedir); + push_if_dir (plugindirs, dir); + for (i = 0; i <= XINE_LT_AGE; ++i) + { + asprintf (&dir, "%s.%d", XINE_PLUGINROOT, i); + push_if_dir (plugindirs, dir); } } - free(plugindir); - free(pluginpath); + for (iter = xine_list_front (plugindirs); iter; + iter = xine_list_next (plugindirs, iter)) + { + char *dir = xine_list_get_value (plugindirs, iter); +fprintf (stderr, "%s\n", dir); + collect_plugins(this, dir); + free (dir); + } + xine_list_delete (plugindirs); free(homedir); save_catalog (this); -- cgit v1.2.3 From 167035abe222bad88269d296f9d819365a6c6007 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Thu, 7 Feb 2008 02:03:00 +0000 Subject: Reverse the order in which the plugin dirs are scanned; remove a stray printf. --- src/xine-engine/load_plugins.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index 11a74b097..0188fb01d 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -1169,7 +1169,7 @@ void _x_scan_plugins (xine_t *this) { push_if_dir (plugindirs, dir); for (i = 0; i <= XINE_LT_AGE; ++i) { - asprintf (&dir, "%s.%d", XINE_PLUGINROOT, i); + asprintf (&dir, "%s.%d", XINE_PLUGINROOT, XINE_LT_AGE - i); push_if_dir (plugindirs, dir); } } @@ -1177,7 +1177,6 @@ void _x_scan_plugins (xine_t *this) { iter = xine_list_next (plugindirs, iter)) { char *dir = xine_list_get_value (plugindirs, iter); -fprintf (stderr, "%s\n", dir); collect_plugins(this, dir); free (dir); } -- cgit v1.2.3 From 5c051b721ee7ff79ae655660e9695563a902945c Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Thu, 7 Feb 2008 17:51:59 +0000 Subject: Add length checking in the FLAC metadata-parsing code. Make the tracknumber/tracktotal buffer larger (possible overflow). --- src/demuxers/demux_flac.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_flac.c b/src/demuxers/demux_flac.c index 23e2faef9..e5d1297a2 100644 --- a/src/demuxers/demux_flac.c +++ b/src/demuxers/demux_flac.c @@ -189,7 +189,7 @@ static int open_flac_file(demux_flac_t *flac) { case 4: lprintf ("VORBIS_COMMENT metadata\n"); { - char comments[block_length]; + char comments[block_length + 1]; /* last byte for NUL termination */ char *ptr = comments; uint32_t length, user_comment_list_length; int cn; @@ -202,18 +202,25 @@ static int open_flac_file(demux_flac_t *flac) { length = _X_LE_32(ptr); ptr += 4 + length; + if (length >= block_length - 8) + return 0; /* bad length or too little left in the buffer */ user_comment_list_length = _X_LE_32(ptr); ptr += 4; cn = 0; for (; cn < user_comment_list_length; cn++) { + if (ptr > comments + block_length - 4) + return 0; /* too little left in the buffer */ + length = _X_LE_32(ptr); ptr += 4; + if (length >= block_length || ptr + length > comments + block_length) + return 0; /* bad length */ comment = (char*) ptr; c = comment[length]; - comment[length] = 0; + comment[length] = 0; /* NUL termination */ lprintf ("comment[%02d] = %s\n", cn, comment); @@ -248,8 +255,8 @@ static int open_flac_file(demux_flac_t *flac) { } if ((tracknumber > 0) && (tracktotal > 0)) { - char tn[16]; - snprintf (tn, 16, "%02d/%02d", tracknumber, tracktotal); + char tn[24]; + snprintf (tn, 24, "%02d/%02d", tracknumber, tracktotal); _x_meta_info_set(flac->stream, XINE_META_INFO_TRACK_NUMBER, tn); } else if (tracknumber > 0) { -- cgit v1.2.3 From 69bc8833d2108303d7984cab5e1ad5f49dd66085 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Thu, 7 Feb 2008 22:36:52 +0100 Subject: Improve detection of MP3 streams with ID3v2 tags. Don't trust the tag size. --- src/demuxers/demux_mpgaudio.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index 1bea02302..82a7dd7ab 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -807,7 +807,6 @@ static int demux_mpgaudio_read_head(input_plugin_t *input, uint8_t *buf) { * return 1 if detected, 0 otherwise */ static int detect_mpgaudio_file(input_plugin_t *input) { - mpg_audio_frame_t frame; uint8_t buf[MAX_PREVIEW_SIZE]; int preview_len; uint32_t head; @@ -838,8 +837,8 @@ static int detect_mpgaudio_file(input_plugin_t *input) { lprintf("cannot read mp3 frame header\n"); return 0; } - if (!parse_frame_header(&frame, &buf[10 + tag_size])) { - lprintf ("invalid mp3 frame header\n"); + if (!sniff_buffer_looks_like_mp3(&buf[10 + tag_size], preview_len - 10 - tag_size)) { + lprintf ("sniff_buffer_looks_like_mp3 failed\n"); return 0; } else { lprintf ("a valid mp3 frame follows the id3v2 tag\n"); -- cgit v1.2.3 From 91906eeb746d96a39560471e92431a0c6632c70a Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Fri, 8 Feb 2008 22:20:47 +0000 Subject: Avoid a build failure (affects gcc 4.0 on x86_32). --- src/post/deinterlace/plugins/Makefile.am | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/post/deinterlace/plugins/Makefile.am b/src/post/deinterlace/plugins/Makefile.am index 17d170127..2bc8abd58 100644 --- a/src/post/deinterlace/plugins/Makefile.am +++ b/src/post/deinterlace/plugins/Makefile.am @@ -32,6 +32,9 @@ EXTRA_DIST = greedy2frame_template.c greedyh.asm \ AM_CFLAGS = -I$(top_srcdir)/src/post/deinterlace \ -I$(top_srcdir)/src/libffmpeg/libavcodec/libpostproc +# Avoid "can't find register" failures with -O0, -O2, -O3 (gcc 4.0) +libdeinterlaceplugins_la-kdetv_greedyh.o libdeinterlaceplugins_la-kdetv_greedyh.lo: CFLAGS=$(shell echo @CFLAGS@ | sed -e 's/$$/ -O1/') + noinst_LTLIBRARIES = libdeinterlaceplugins.la libdeinterlaceplugins_la_SOURCES = \ -- cgit v1.2.3 From 34af4adde1c65495fa8948c482ef83bd73204d89 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sat, 9 Feb 2008 16:51:19 +0000 Subject: Remove some unnecessary tests (which the compiler would discard). --- src/xine-utils/utils.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c index c5f18a699..cc3ffdc2c 100644 --- a/src/xine-utils/utils.c +++ b/src/xine-utils/utils.c @@ -324,22 +324,18 @@ const char *xine_get_homedir(void) { char *s; int len; - if (!homedir[0]) { - len = xine_strcpy_command(GetCommandLine(), homedir, sizeof(homedir)); - s = strdup(homedir); - GetFullPathName(s, sizeof(homedir), homedir, NULL); - free(s); - if ((s = strrchr(homedir, '\\'))) *s = '\0'; - } + len = xine_strcpy_command(GetCommandLine(), homedir, sizeof(homedir)); + s = strdup(homedir); + GetFullPathName(s, sizeof(homedir), homedir, NULL); + free(s); + if ((s = strrchr(homedir, '\\'))) + *s = '\0'; return homedir; #else struct passwd pwd, *pw = NULL; static char homedir[BUFSIZ] = {0,}; - if(homedir[0]) - return homedir; - #ifdef HAVE_GETPWUID_R if(getpwuid_r(getuid(), &pwd, homedir, sizeof(homedir), &pw) != 0 || pw == NULL) { #else -- cgit v1.2.3 From 82525c0275a04d84d2d577a5d7411d3e55eea8c6 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Thu, 14 Feb 2008 21:16:43 +0100 Subject: Fixed mp3 sniff code. Fixed bug 4 sample playback (nilbymouthclapton.112.mp3). --- src/demuxers/demux_mpgaudio.c | 59 +++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index dd6c62015..dfb905520 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -626,11 +626,12 @@ static int parse_frame_payload(demux_mpgaudio_t *this, * 32-bit MP3 frame header. * return 1 if found, 0 if not found */ -static int sniff_buffer_looks_like_mp3 (uint8_t *buf, int buflen) +static int sniff_buffer_looks_like_mp3 (uint8_t *buf, int buflen, int *version, int *layer) { int offset; mpg_audio_frame_t frame; + *version = *layer = 0; if (buf == NULL) return 0; @@ -639,20 +640,21 @@ static int sniff_buffer_looks_like_mp3 (uint8_t *buf, int buflen) if (parse_frame_header(&frame, buf + offset)) { size_t size = frame.size; - /* Since one frame is available, is there another frame - * just to be sure this is more likely to be a real MP3 - * buffer? */ - offset += size; - - if (offset + 4 >= buflen) { - return 0; - } + if (size > 0) { + /* Since one frame is available, is there another frame + * just to be sure this is more likely to be a real MP3 + * buffer? */ + if (offset + size + 4 >= buflen) { + return 0; + } - if (parse_frame_header(&frame, buf + offset)) { - lprintf("mpeg audio frame detected\n"); - return 1; + if (parse_frame_header(&frame, buf + offset + size)) { + *version = frame.version_idx + 1; + *layer = frame.layer; + lprintf("frame detected, mpeg %d layer %d\n", *version, *layer); + return 1; + } } - break; } } return 0; @@ -806,11 +808,13 @@ static int demux_mpgaudio_read_head(input_plugin_t *input, uint8_t *buf) { * mp3 stream detection * return 1 if detected, 0 otherwise */ -static int detect_mpgaudio_file(input_plugin_t *input) { +static int detect_mpgaudio_file(input_plugin_t *input, + int *version, int *layer) { uint8_t buf[MAX_PREVIEW_SIZE]; int preview_len; uint32_t head; + *version = *layer = 0; preview_len = demux_mpgaudio_read_head(input, buf); if (preview_len < 4) return 0; @@ -834,7 +838,7 @@ static int detect_mpgaudio_file(input_plugin_t *input) { lprintf("cannot read mp3 frame header\n"); return 0; } - if (!sniff_buffer_looks_like_mp3(&buf[10 + tag_size], preview_len - 10 - tag_size)) { + if (!sniff_buffer_looks_like_mp3(&buf[10 + tag_size], preview_len - 10 - tag_size, version, layer)) { lprintf ("sniff_buffer_looks_like_mp3 failed\n"); return 0; } else { @@ -842,7 +846,7 @@ static int detect_mpgaudio_file(input_plugin_t *input) { } } else if (head == MPEG_MARKER) { return 0; - } else if (!sniff_buffer_looks_like_mp3(buf, preview_len)) { + } else if (!sniff_buffer_looks_like_mp3(buf, preview_len, version, layer)) { lprintf ("sniff_buffer_looks_like_mp3 failed\n"); return 0; } @@ -1104,13 +1108,15 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str input_plugin_t *input) { demux_mpgaudio_t *this; + int version = 0; + int layer = 0; lprintf("trying to open %s...\n", input->get_mrl(input)); switch (stream->content_detection_method) { case METHOD_BY_CONTENT: { - if (!detect_mpgaudio_file(input)) + if (!detect_mpgaudio_file(input, &version, &layer)) return NULL; } break; @@ -1122,7 +1128,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str default: return NULL; } - + this = xine_xmalloc (sizeof (demux_mpgaudio_t)); this->demux_plugin.send_headers = demux_mpgaudio_send_headers; @@ -1134,12 +1140,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str this->demux_plugin.get_capabilities = demux_mpgaudio_get_capabilities; this->demux_plugin.get_optional_data = demux_mpgaudio_get_optional_data; this->demux_plugin.demux_class = class_gen; - - this->input = input; - this->audio_fifo = stream->audio_fifo; - this->status = DEMUX_FINISHED; - this->stream = stream; - + + this->input = input; + this->audio_fifo = stream->audio_fifo; + this->status = DEMUX_FINISHED; + this->stream = stream; + + this->mpg_version = version; + this->mpg_layer = layer; + if (version || layer) { + this->valid_frames = NUM_VALID_FRAMES; + } return &this->demux_plugin; } -- cgit v1.2.3 From a53d75fb7fd3bbe4bc619658fe9ed7ed1b4f2879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Fri, 15 Feb 2008 13:21:09 +0100 Subject: Don't unlock unconditionally the mainloop on failure. --- src/audio_out/audio_pulse_out.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/audio_out/audio_pulse_out.c b/src/audio_out/audio_pulse_out.c index 26d121bf6..2811bbdbc 100644 --- a/src/audio_out/audio_pulse_out.c +++ b/src/audio_out/audio_pulse_out.c @@ -246,7 +246,7 @@ static int ao_pulse_open(ao_driver_t *this_gen, pa_threaded_mainloop_lock(this->pa_class->mainloop); ret = pa_context_connect(this->pa_class->context, this->host, 1, NULL); if ( ret < 0 ) - goto fail; + goto fail_unlock; pa_context_set_state_callback(this->pa_class->context, __xine_pa_context_status_callback, this); @@ -289,8 +289,9 @@ static int ao_pulse_open(ao_driver_t *this_gen, return this->sample_rate; -fail: + fail_unlock: pa_threaded_mainloop_unlock(this->pa_class->mainloop); + fail: this_gen->close(this_gen); return 0; } -- cgit v1.2.3 From ac63f46f26fa2bc9a0be9feacae52d55249685be Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Fri, 15 Feb 2008 09:33:51 +0100 Subject: Fixed endianess problem. This should allow big ID3v2 tag to be parsed (i mean tags with embedded pictures). (transplanted from ebb0d5507d3208f8e73af78f912230719d37830a) --HG-- extra : transplant_source : %EB%B0%D5P%7D2%08%F8%E7%3A%F7%8F%91%220q%9D7%83%0A --- src/demuxers/demux_mpgaudio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index 56759dd4b..648f04410 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -725,8 +725,8 @@ static int demux_mpgaudio_next (demux_mpgaudio_t *this, int decoder_flags, int s /* the stream is broken, don't keep info about previous frames */ this->free_bitrate_size = 0; - if ( id3v2_istag(header) ) { - if (!id3v2_parse_tag(this->input, this->stream, header)) { + if ( id3v2_istag(_X_ME_32(header)) ) { + if (!id3v2_parse_tag(this->input, this->stream, _X_ME_32(header))) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2 tag parsing error\n"); bytes = 1; /* resync */ -- cgit v1.2.3 From 977484032ff46573c8d3bf39de73cff4304b7a80 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Fri, 15 Feb 2008 09:33:51 +0100 Subject: Fixed endianess problem. This should allow big ID3v2 tag to be parsed (i mean tags with embedded pictures). --- src/demuxers/demux_mpgaudio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index dfb905520..6eb4ee622 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -725,8 +725,8 @@ static int demux_mpgaudio_next (demux_mpgaudio_t *this, int decoder_flags, int s /* the stream is broken, don't keep info about previous frames */ this->free_bitrate_size = 0; - if ( id3v2_istag(header) ) { - if (!id3v2_parse_tag(this->input, this->stream, header)) { + if ( id3v2_istag(_X_ME_32(header)) ) { + if (!id3v2_parse_tag(this->input, this->stream, _X_ME_32(header))) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2 tag parsing error\n"); bytes = 1; /* resync */ -- cgit v1.2.3 From b69b862d5d47f3c17cee1dbbbe4743d51bbc9d3c Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Sat, 16 Feb 2008 00:12:08 +0100 Subject: Take in account the size of the extended header. --HG-- extra : transplant_source : %C0%D71D1%8CQ%889P%21%20%D7%F7%B5%F2T%FE%88%FA --- src/demuxers/id3.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/demuxers/id3.c b/src/demuxers/id3.c index cd72646ef..85b42efa8 100644 --- a/src/demuxers/id3.c +++ b/src/demuxers/id3.c @@ -559,6 +559,7 @@ int id3v23_parse_tag(input_plugin_t *input, if (!id3v23_parse_frame_ext_header(input, &tag_frame_ext_header)) { return 0; } + pos += tag_frame_ext_header.size; } /* frame parsing */ while ((pos + ID3V23_FRAME_HEADER_SIZE) <= tag_header.size) { @@ -579,7 +580,8 @@ int id3v23_parse_tag(input_plugin_t *input, pos += tag_frame_header.size; } else { /* end of frames, the rest is padding */ - input->seek (input, tag_header.size - pos, SEEK_CUR); + lprintf("skipping padding %d bytes\n", tag_header.size - pos); + input->seek (input, tag_header.size - pos, SEEK_CUR); return 1; } } else { @@ -809,6 +811,7 @@ int id3v24_parse_tag(input_plugin_t *input, if (!id3v24_parse_ext_header(input, &tag_frame_ext_header)) { return 0; } + pos += tag_frame_ext_header.size; } /* frame parsing */ while ((pos + ID3V24_FRAME_HEADER_SIZE) <= tag_header.size) { -- cgit v1.2.3 From a03ad73663dc3342f3f6d2a084b55cb05229054d Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Sun, 17 Feb 2008 19:18:35 -0300 Subject: nvidia driver uses XV_SYNC_TO_VBLANK attribute, not XV_DOUBLE_BUFFER as xine expected. add code to set this attribute from xine and mention nvidia-settings, since the user may need to select a sync device as well. --- src/video_out/video_out_xcbxv.c | 33 +++++++++++++++++++++++++++++++++ src/video_out/video_out_xv.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) (limited to 'src') diff --git a/src/video_out/video_out_xcbxv.c b/src/video_out/video_out_xcbxv.c index 18ab5c6fb..f83512bd0 100644 --- a/src/video_out/video_out_xcbxv.c +++ b/src/video_out/video_out_xcbxv.c @@ -1247,6 +1247,27 @@ static void xv_update_XV_DOUBLE_BUFFER(void *this_gen, xine_cfg_entry_t *entry) "video_out_xcbxv: double buffering mode = %d\n", xv_double_buffer); } +static void xv_update_XV_SYNC_TO_VBLANK(void *this_gen, xine_cfg_entry_t *entry) { + xv_driver_t *this = (xv_driver_t *) this_gen; + int xv_sync_to_vblank; + + xcb_intern_atom_cookie_t atom_cookie; + xcb_intern_atom_reply_t *atom_reply; + + xv_sync_to_vblank = entry->num_value; + + pthread_mutex_lock(&this->main_mutex); + atom_cookie = xcb_intern_atom(this->connection, 0, sizeof("XV_SYNC_TO_VBLANK"), "XV_SYNC_TO_VBLANK"); + atom_reply = xcb_intern_atom_reply(this->connection, atom_cookie, NULL); + xcb_xv_set_port_attribute(this->connection, this->xv_port, atom_reply->atom, xv_sync_to_vblank); + free(atom_reply); + pthread_mutex_unlock(&this->main_mutex); + + xprintf(this->xine, XINE_VERBOSITY_DEBUG, + "video_out_xcbxv: sync to vblank = %d\n", xv_sync_to_vblank); +} + + static void xv_update_xv_pitch_alignment(void *this_gen, xine_cfg_entry_t *entry) { xv_driver_t *this = (xv_driver_t *) this_gen; @@ -1480,6 +1501,18 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis "flickering and tearing artifacts, but will use more graphics memory."), 20, xv_update_XV_DOUBLE_BUFFER, this); config->update_num(config,"video.device.xv_double_buffer",xv_double_buffer); + } else if(!strcmp(xcb_xv_attribute_info_name(attribute_it.data), "XV_SYNC_TO_VBLANK")) { + int xv_sync_to_vblank; + xv_sync_to_vblank = + config->register_bool (config, "video.device.xv_sync_to_vblank", 1, + _("enable vblank sync"), + _("This option will synchronize the update of the video image to the " + "repainting of the entire screen (\"vertical retrace\"). This eliminates " + "flickering and tearing artifacts. On nvidia cards one may also " + "need to run \"nvidia-settings\" and choose which display device to " + "sync to under the XVideo Settings tab"), + 20, xv_update_XV_SYNC_TO_VBLANK, this); + config->update_num(config,"video.device.xv_sync_to_vblank",xv_sync_to_vblank); } } } diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index 3bb0a93dc..f6bd1a429 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -1299,6 +1299,22 @@ static void xv_update_XV_DOUBLE_BUFFER(void *this_gen, xine_cfg_entry_t *entry) "video_out_xv: double buffering mode = %d\n", xv_double_buffer); } +static void xv_update_XV_SYNC_TO_VBLANK(void *this_gen, xine_cfg_entry_t *entry) { + xv_driver_t *this = (xv_driver_t *) this_gen; + Atom atom; + int xv_sync_to_vblank; + + xv_sync_to_vblank = entry->num_value; + + LOCK_DISPLAY(this); + atom = XInternAtom (this->display, "XV_SYNC_TO_VBLANK", False); + XvSetPortAttribute (this->display, this->xv_port, atom, xv_sync_to_vblank); + UNLOCK_DISPLAY(this); + + xprintf(this->xine, XINE_VERBOSITY_DEBUG, + "video_out_xv: sync to vblank = %d\n", xv_sync_to_vblank); +} + static void xv_update_xv_pitch_alignment(void *this_gen, xine_cfg_entry_t *entry) { xv_driver_t *this = (xv_driver_t *) this_gen; @@ -1538,6 +1554,18 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * "flickering and tearing artifacts, but will use more graphics memory."), 20, xv_update_XV_DOUBLE_BUFFER, this); config->update_num(config,"video.device.xv_double_buffer",xv_double_buffer); + } else if(!strcmp(attr[k].name, "XV_SYNC_TO_VBLANK")) { + int xv_sync_to_vblank; + xv_sync_to_vblank = + config->register_bool (config, "video.device.xv_sync_to_vblank", 1, + _("enable vblank sync"), + _("This option will synchronize the update of the video image to the " + "repainting of the entire screen (\"vertical retrace\"). This eliminates " + "flickering and tearing artifacts. On nvidia cards one may also " + "need to run \"nvidia-settings\" and choose which display device to " + "sync to under the XVideo Settings tab"), + 20, xv_update_XV_SYNC_TO_VBLANK, this); + config->update_num(config,"video.device.xv_sync_to_vblank",xv_sync_to_vblank); } } } -- cgit v1.2.3 From 0ac9aca92944c9a3243dabace9a928916010dd55 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Mon, 18 Feb 2008 22:01:32 +0100 Subject: Backed out changeset 698d30889b29 id3v2_istag has not the same signature in 1.1 and 1.2. --- src/demuxers/demux_mpgaudio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index 648f04410..56759dd4b 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -725,8 +725,8 @@ static int demux_mpgaudio_next (demux_mpgaudio_t *this, int decoder_flags, int s /* the stream is broken, don't keep info about previous frames */ this->free_bitrate_size = 0; - if ( id3v2_istag(_X_ME_32(header)) ) { - if (!id3v2_parse_tag(this->input, this->stream, _X_ME_32(header))) { + if ( id3v2_istag(header) ) { + if (!id3v2_parse_tag(this->input, this->stream, header)) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2 tag parsing error\n"); bytes = 1; /* resync */ -- cgit v1.2.3 From dfaac7bec1f45bbabb8e5cfbe1001dee13829496 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Mon, 18 Feb 2008 23:51:40 +0100 Subject: Timecode diff is signed. Should fix bug 35. --HG-- extra : transplant_source : %DD%95%9F%A7%8D%01%BD%98%40%E4R%AAW%F2%ED%93%B2%DE%1A%E9 --- src/demuxers/demux_matroska.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_matroska.c b/src/demuxers/demux_matroska.c index 3c992ecca..63b6ea3c8 100644 --- a/src/demuxers/demux_matroska.c +++ b/src/demuxers/demux_matroska.c @@ -1832,6 +1832,15 @@ static int read_block_data (demux_matroska_t *this, int len) { return 1; } +static int parse_int16(uint8_t *data) { + int value = (int)_X_BE_16(data); + if (value & 1<<15) + { + value -= 1<<16; + } + return value; +} + static int parse_block (demux_matroska_t *this, uint64_t block_size, uint64_t cluster_timecode, uint64_t block_duration, int normpos, int is_key) { @@ -1848,8 +1857,9 @@ static int parse_block (demux_matroska_t *this, uint64_t block_size, if (!(num_len = parse_ebml_uint(this, data, &track_num))) return 0; data += num_len; - - timecode_diff = (int)_X_BE_16(data); + + /* timecode_diff is signed */ + timecode_diff = parse_int16(data); data += 2; flags = *data; -- cgit v1.2.3 From a2f6c4214b7f7efecd0bfddcedfdf9a413d842f8 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 20 Feb 2008 23:19:15 +0000 Subject: Off-by-one in the FLAC security fix, breaking playback of some files. --- src/demuxers/demux_flac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/demuxers/demux_flac.c b/src/demuxers/demux_flac.c index e5d1297a2..f6544bb67 100644 --- a/src/demuxers/demux_flac.c +++ b/src/demuxers/demux_flac.c @@ -202,7 +202,7 @@ static int open_flac_file(demux_flac_t *flac) { length = _X_LE_32(ptr); ptr += 4 + length; - if (length >= block_length - 8) + if (length > block_length - 8) return 0; /* bad length or too little left in the buffer */ user_comment_list_length = _X_LE_32(ptr); -- cgit v1.2.3 From dff9fc9bb1e3a5593c8dcc1c77116d1647b9af99 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Mon, 25 Feb 2008 17:23:51 +0000 Subject: Add more VO_CAP_* to indicate support for colour controls & zoom properties. --HG-- extra : transplant_source : %C2%84%E8%0E%FD%DE%D3%3E%FB%B8%AF%F3%80a%5E%B3v%C5%8B%08 --- src/video_out/video_out_directfb.c | 18 ++++++++++++++++-- src/video_out/video_out_fb.c | 2 +- src/video_out/video_out_opengl.c | 2 +- src/video_out/video_out_pgx64.c | 3 +-- src/video_out/video_out_vidix.c | 6 +++++- src/video_out/video_out_xcbshm.c | 2 +- src/video_out/video_out_xcbxv.c | 8 +++++++- src/video_out/video_out_xshm.c | 2 +- src/video_out/video_out_xv.c | 8 +++++++- src/video_out/video_out_xvmc.c | 8 +++++++- src/video_out/video_out_xxmc.c | 8 +++++++- 11 files changed, 54 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_directfb.c b/src/video_out/video_out_directfb.c index d85df411a..fecc2c5b0 100644 --- a/src/video_out/video_out_directfb.c +++ b/src/video_out/video_out_directfb.c @@ -1742,6 +1742,20 @@ static void directfb_frame_output_cb (void *user_data, int video_width, int vide /*** DirectFB plugin functions ***/ +static inline int convert_caps (DFBDisplayLayerCapabilities caps) +{ + int vo = VO_CAP_YV12 | VO_CAP_YUY2 | VO_CAP_CROP | VO_CAP_ZOOM_X | VO_CAP_ZOOM_Y; + if (caps & DLCAPS_HUE) + vo |= VO_CAP_HUE; + if (caps & DLCAPS_SATURATION) + vo |= VO_CAP_SATURATION; + if (caps & DLCAPS_CONTRAST) + vo |= VO_CAP_CONTRAST; + if (caps & DLCAPS_BRIGHTNESS) + vo |= VO_CAP_BRIGHTNESS; + return vo; +} + static vo_driver_t *open_plugin_fb (video_driver_class_t *class_gen, const void *visual_gen) { directfb_class_t *class = (directfb_class_t *) class_gen; directfb_driver_t *this; @@ -1821,7 +1835,7 @@ static vo_driver_t *open_plugin_fb (video_driver_class_t *class_gen, const void return NULL; } - this->capabilities = VO_CAP_YV12 | VO_CAP_YUY2 | VO_CAP_CROP; + this->capabilities = convert_caps (this->caps); /* set default configuration */ this->buffermode = 1; // double this->vsync = 0; @@ -2000,7 +2014,7 @@ static vo_driver_t *open_plugin_x11 (video_driver_class_t *class_gen, const void xprintf (this->xine, XINE_VERBOSITY_LOG, _("video_out_directfb: using display layer #%d.\n"), id); - this->capabilities = VO_CAP_YV12 | VO_CAP_YUY2 | VO_CAP_CROP; + this->capabilities = convert_caps (this->caps); /* set default configuration */ this->buffermode = 1; // double this->vsync = 0; diff --git a/src/video_out/video_out_fb.c b/src/video_out/video_out_fb.c index 17224ecad..5a49b80a3 100644 --- a/src/video_out/video_out_fb.c +++ b/src/video_out/video_out_fb.c @@ -155,7 +155,7 @@ typedef struct static uint32_t fb_get_capabilities(vo_driver_t *this_gen) { - return VO_CAP_YV12 | VO_CAP_YUY2; + return VO_CAP_YV12 | VO_CAP_YUY2 | VO_CAP_BRIGHTNESS | VO_CAP_CONTRAST | VO_CAP_SATURATION; } static void fb_frame_proc_slice(vo_frame_t *vo_img, uint8_t **src) diff --git a/src/video_out/video_out_opengl.c b/src/video_out/video_out_opengl.c index 21383453e..2ffd83637 100644 --- a/src/video_out/video_out_opengl.c +++ b/src/video_out/video_out_opengl.c @@ -1200,7 +1200,7 @@ static void *render_run (opengl_driver_t *this) { static uint32_t opengl_get_capabilities (vo_driver_t *this_gen) { /* opengl_driver_t *this = (opengl_driver_t *) this_gen; */ - uint32_t capabilities = VO_CAP_YV12 | VO_CAP_YUY2; + uint32_t capabilities = VO_CAP_YV12 | VO_CAP_YUY2 | VO_CAP_BRIGHTNESS | VO_CAP_CONTRAST | VO_CAP_SATURATION; /* TODO: somehow performance goes down during the first few frames */ /* if (this->xoverlay) */ diff --git a/src/video_out/video_out_pgx64.c b/src/video_out/video_out_pgx64.c index d0e74b1e3..0bdcc35fe 100644 --- a/src/video_out/video_out_pgx64.c +++ b/src/video_out/video_out_pgx64.c @@ -552,8 +552,7 @@ static uint32_t pgx64_get_capabilities(vo_driver_t *this_gen) { /*pgx64_driver_t *this = (pgx64_driver_t *)(void *)this_gen;*/ - return VO_CAP_YV12 | - VO_CAP_YUY2; + return VO_CAP_YV12 | VO_CAP_YUY2 | VO_CAP_BRIGHTNESS | VO_CAP_SATURATION; } static vo_frame_t *pgx64_alloc_frame(vo_driver_t *this_gen) diff --git a/src/video_out/video_out_vidix.c b/src/video_out/video_out_vidix.c index f4b74ad2a..586268513 100644 --- a/src/video_out/video_out_vidix.c +++ b/src/video_out/video_out_vidix.c @@ -964,7 +964,7 @@ static vidix_driver_t *open_plugin (video_driver_class_t *class_gen) { this->config = config; this->got_frame_data = 0; - this->capabilities = VO_CAP_CROP; + this->capabilities = VO_CAP_CROP | VO_CAP_ZOOM_X | VO_CAP_ZOOM_Y; /* Find what equalizer flags are supported */ if(this->vidix_cap.flags & FLAG_EQUALIZER) { @@ -973,24 +973,28 @@ static vidix_driver_t *open_plugin (video_driver_class_t *class_gen) { "video_out_vidix: couldn't get equalizer capabilities: %s\n", strerror(err)); } else { if(this->vidix_eq.cap & VEQ_CAP_BRIGHTNESS) { + this->capabilities |= VO_CAP_BRIGHTNESS; this->props[VO_PROP_BRIGHTNESS].value = 0; this->props[VO_PROP_BRIGHTNESS].min = -1000; this->props[VO_PROP_BRIGHTNESS].max = 1000; } if(this->vidix_eq.cap & VEQ_CAP_CONTRAST) { + this->capabilities |= VO_CAP_CONTRAST; this->props[VO_PROP_CONTRAST].value = 0; this->props[VO_PROP_CONTRAST].min = -1000; this->props[VO_PROP_CONTRAST].max = 1000; } if(this->vidix_eq.cap & VEQ_CAP_SATURATION) { + this->capabilities |= VO_CAP_SATURATION; this->props[VO_PROP_SATURATION].value = 0; this->props[VO_PROP_SATURATION].min = -1000; this->props[VO_PROP_SATURATION].max = 1000; } if(this->vidix_eq.cap & VEQ_CAP_HUE) { + this->capabilities |= VO_CAP_HUE; this->props[VO_PROP_HUE].value = 0; this->props[VO_PROP_HUE].min = -1000; this->props[VO_PROP_HUE].max = 1000; diff --git a/src/video_out/video_out_xcbshm.c b/src/video_out/video_out_xcbshm.c index 9895d1852..1bacf50c9 100644 --- a/src/video_out/video_out_xcbshm.c +++ b/src/video_out/video_out_xcbshm.c @@ -221,7 +221,7 @@ static void dispose_ximage(xshm_driver_t *this, xshm_frame_t *frame) static uint32_t xshm_get_capabilities (vo_driver_t *this_gen) { xshm_driver_t *this = (xshm_driver_t *) this_gen; - uint32_t capabilities = VO_CAP_YV12 | VO_CAP_YUY2; + uint32_t capabilities = VO_CAP_YV12 | VO_CAP_YUY2 | VO_CAP_BRIGHTNESS | VO_CAP_CONTRAST | VO_CAP_SATURATION; if( this->xoverlay ) capabilities |= VO_CAP_UNSCALED_OVERLAY; diff --git a/src/video_out/video_out_xcbxv.c b/src/video_out/video_out_xcbxv.c index 6fed0f90a..18d752431 100644 --- a/src/video_out/video_out_xcbxv.c +++ b/src/video_out/video_out_xcbxv.c @@ -1234,7 +1234,7 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis this->gc = xcb_generate_id(this->connection); xcb_create_gc(this->connection, this->gc, this->window, 0, NULL); - this->capabilities = VO_CAP_CROP; + this->capabilities = VO_CAP_CROP | VO_CAP_ZOOM_X | VO_CAP_ZOOM_Y; this->use_shm = 1; this->use_colorkey = 0; this->colorkey = 0; @@ -1295,28 +1295,34 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis if (!strncmp(xcb_xv_adaptor_info_name(adaptor_it.data), "NV", 2)) { xprintf (this->xine, XINE_VERBOSITY_NONE, LOG_MODULE ": ignoring broken XV_HUE settings on NVidia cards\n"); } else { + this->capabilities |= VO_CAP_HUE; xv_check_capability (this, VO_PROP_HUE, attribute_it.data, adaptor_it.data->base_id, NULL, NULL, NULL); } } else if(!strcmp(name, "XV_SATURATION")) { + this->capabilities |= VO_CAP_SATURATION; xv_check_capability (this, VO_PROP_SATURATION, attribute_it.data, adaptor_it.data->base_id, NULL, NULL, NULL); } else if(!strcmp(name, "XV_BRIGHTNESS")) { + this->capabilities |= VO_CAP_BRIGHTNESS; xv_check_capability (this, VO_PROP_BRIGHTNESS, attribute_it.data, adaptor_it.data->base_id, NULL, NULL, NULL); } else if(!strcmp(name, "XV_CONTRAST")) { + this->capabilities |= VO_CAP_CONTRAST; xv_check_capability (this, VO_PROP_CONTRAST, attribute_it.data, adaptor_it.data->base_id, NULL, NULL, NULL); } else if(!strcmp(name, "XV_COLORKEY")) { + this->capabilities |= VO_CAP_COLORKEY; xv_check_capability (this, VO_PROP_COLORKEY, attribute_it.data, adaptor_it.data->base_id, "video.device.xv_colorkey", VIDEO_DEVICE_XV_COLORKEY_HELP); } else if(!strcmp(name, "XV_AUTOPAINT_COLORKEY")) { + this->capabilities |= VO_CAP_AUTOPAINT_COLORKEY; xv_check_capability (this, VO_PROP_AUTOPAINT_COLORKEY, attribute_it.data, adaptor_it.data->base_id, "video.device.xv_autopaint_colorkey", diff --git a/src/video_out/video_out_xshm.c b/src/video_out/video_out_xshm.c index 7801bb03b..8f51964e2 100644 --- a/src/video_out/video_out_xshm.c +++ b/src/video_out/video_out_xshm.c @@ -314,7 +314,7 @@ static void dispose_ximage (xshm_driver_t *this, static uint32_t xshm_get_capabilities (vo_driver_t *this_gen) { xshm_driver_t *this = (xshm_driver_t *) this_gen; - uint32_t capabilities = VO_CAP_YV12 | VO_CAP_YUY2; + uint32_t capabilities = VO_CAP_YV12 | VO_CAP_YUY2 | VO_CAP_BRIGHTNESS | VO_CAP_CONTRAST | VO_CAP_SATURATION; if( this->xoverlay ) capabilities |= VO_CAP_UNSCALED_OVERLAY; diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index 6f5c68e51..115489e57 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -1275,7 +1275,7 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * LOCK_DISPLAY(this); this->gc = XCreateGC (this->display, this->drawable, 0, NULL); UNLOCK_DISPLAY(this); - this->capabilities = VO_CAP_CROP; + this->capabilities = VO_CAP_CROP | VO_CAP_ZOOM_X | VO_CAP_ZOOM_Y; this->use_shm = 1; this->use_colorkey = 0; this->colorkey = 0; @@ -1342,28 +1342,34 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * if (!strncmp(adaptor_info[adaptor_num].name, "NV", 2)) { xprintf (this->xine, XINE_VERBOSITY_NONE, LOG_MODULE ": ignoring broken XV_HUE settings on NVidia cards\n"); } else { + this->capabilities |= VO_CAP_HUE; xv_check_capability (this, VO_PROP_HUE, attr[k], adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); } } else if(!strcmp(name, "XV_SATURATION")) { + this->capabilities |= VO_CAP_SATURATION; xv_check_capability (this, VO_PROP_SATURATION, attr[k], adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); } else if(!strcmp(name, "XV_BRIGHTNESS")) { + this->capabilities |= VO_CAP_BRIGHTNESS; xv_check_capability (this, VO_PROP_BRIGHTNESS, attr[k], adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); } else if(!strcmp(name, "XV_CONTRAST")) { + this->capabilities |= VO_CAP_CONTRAST; xv_check_capability (this, VO_PROP_CONTRAST, attr[k], adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); } else if(!strcmp(name, "XV_COLORKEY")) { + this->capabilities |= VO_CAP_COLORKEY; xv_check_capability (this, VO_PROP_COLORKEY, attr[k], adaptor_info[adaptor_num].base_id, "video.device.xv_colorkey", VIDEO_DEVICE_XV_COLORKEY_HELP); } else if(!strcmp(name, "XV_AUTOPAINT_COLORKEY")) { + this->capabilities |= VO_CAP_AUTOPAINT_COLORKEY; xv_check_capability (this, VO_PROP_AUTOPAINT_COLORKEY, attr[k], adaptor_info[adaptor_num].base_id, "video.device.xv_autopaint_colorkey", diff --git a/src/video_out/video_out_xvmc.c b/src/video_out/video_out_xvmc.c index 9618b082c..7f282ee53 100644 --- a/src/video_out/video_out_xvmc.c +++ b/src/video_out/video_out_xvmc.c @@ -1332,7 +1332,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi XLockDisplay(this->display); this->gc = XCreateGC(this->display, this->drawable, 0, NULL); XUnlockDisplay(this->display); - this->capabilities = VO_CAP_XVMC_MOCOMP | VO_CAP_CROP; + this->capabilities = VO_CAP_XVMC_MOCOMP | VO_CAP_CROP | VO_CAP_ZOOM_X | VO_CAP_ZOOM_Y; this->surface_type_id = class->surface_type_id; this->max_surface_width = class->max_surface_width; @@ -1401,28 +1401,34 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi if (!strncmp(adaptor_info[adaptor_num].name, "NV", 2)) { xprintf (this->xine, XINE_VERBOSITY_NONE, LOG_MODULE ": ignoring broken XV_HUE settings on NVidia cards\n"); } else { + this->capabilities |= VO_CAP_HUE; xvmc_check_capability (this, VO_PROP_HUE, attr[k], adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); } } else if(!strcmp(name, "XV_SATURATION")) { + this->capabilities |= VO_CAP_SATURATION; xvmc_check_capability (this, VO_PROP_SATURATION, attr[k], adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); } else if(!strcmp(attr[k].name, "XV_BRIGHTNESS")) { + this->capabilities |= VO_CAP_BRIGHTNESS; xvmc_check_capability (this, VO_PROP_BRIGHTNESS, attr[k], adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); } else if(!strcmp(name, "XV_CONTRAST")) { + this->capabilities |= VO_CAP_CONTRAST; xvmc_check_capability (this, VO_PROP_CONTRAST, attr[k], adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); } else if(!strcmp(name, "XV_COLORKEY")) { + this->capabilities |= VO_CAP_COLORKEY; xvmc_check_capability (this, VO_PROP_COLORKEY, attr[k], adaptor_info[adaptor_num].base_id, "video.device.xv_colorkey", VIDEO_DEVICE_XV_COLORKEY_HELP); } else if(!strcmp(name, "XV_AUTOPAINT_COLORKEY")) { + this->capabilities |= VO_CAP_AUTOPAINT_COLORKEY; xvmc_check_capability (this, VO_PROP_AUTOPAINT_COLORKEY, attr[k], adaptor_info[adaptor_num].base_id, "video.device.xv_autopaint_colorkey", diff --git a/src/video_out/video_out_xxmc.c b/src/video_out/video_out_xxmc.c index 2c42dda2e..35346dd1d 100644 --- a/src/video_out/video_out_xxmc.c +++ b/src/video_out/video_out_xxmc.c @@ -2520,7 +2520,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi XLockDisplay (this->display); this->gc = XCreateGC (this->display, this->drawable, 0, NULL); XUnlockDisplay (this->display); - this->capabilities = VO_CAP_CROP; + this->capabilities = VO_CAP_CROP | VO_CAP_ZOOM_X | VO_CAP_ZOOM_Y; this->use_shm = 1; this->use_colorkey = 0; this->colorkey = 0; @@ -2584,28 +2584,34 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi if (!strncmp(adaptor_info[adaptor_num].name, "NV", 2)) { xprintf (this->xine, XINE_VERBOSITY_NONE, LOG_MODULE ": ignoring broken XV_HUE settings on NVidia cards\n"); } else { + this->capabilities |= VO_CAP_HUE; xxmc_check_capability (this, VO_PROP_HUE, attr[k], adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); } } else if(!strcmp(name, "XV_SATURATION")) { + this->capabilities |= VO_CAP_SATURATION; xxmc_check_capability (this, VO_PROP_SATURATION, attr[k], adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); } else if(!strcmp(name, "XV_BRIGHTNESS")) { + this->capabilities |= VO_CAP_BRIGHTNESS; xxmc_check_capability (this, VO_PROP_BRIGHTNESS, attr[k], adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); } else if(!strcmp(name, "XV_CONTRAST")) { + this->capabilities |= VO_CAP_CONTRAST; xxmc_check_capability (this, VO_PROP_CONTRAST, attr[k], adaptor_info[adaptor_num].base_id, NULL, NULL, NULL); } else if(!strcmp(name, "XV_COLORKEY")) { + this->capabilities |= VO_CAP_COLORKEY; xxmc_check_capability (this, VO_PROP_COLORKEY, attr[k], adaptor_info[adaptor_num].base_id, "video.device.xv_colorkey", VIDEO_DEVICE_XV_COLORKEY_HELP); } else if(!strcmp(name, "XV_AUTOPAINT_COLORKEY")) { + this->capabilities |= VO_CAP_AUTOPAINT_COLORKEY; xxmc_check_capability (this, VO_PROP_AUTOPAINT_COLORKEY, attr[k], adaptor_info[adaptor_num].base_id, "video.device.xv_autopaint_colorkey", -- cgit v1.2.3 From e15dfd5952406f62cbceec59114920c8b758524e Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Mon, 25 Feb 2008 18:53:19 +0000 Subject: When auto-detecting Xv ports, prefer port nos. >= configured. --- src/video_out/video_out_xcbxv.c | 17 +++++++++++------ src/video_out/video_out_xv.c | 12 +++++++----- src/video_out/video_out_xxmc.c | 12 +++++++----- 3 files changed, 25 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_xcbxv.c b/src/video_out/video_out_xcbxv.c index 18d752431..b7001ca03 100644 --- a/src/video_out/video_out_xcbxv.c +++ b/src/video_out/video_out_xcbxv.c @@ -1123,19 +1123,23 @@ xv_find_adaptor_by_port (int port, xcb_xv_adaptor_info_iterator_t *adaptor_it) } static xcb_xv_port_t xv_autodetect_port(xv_driver_t *this, - xcb_xv_adaptor_info_iterator_t *adaptor_it) + xcb_xv_adaptor_info_iterator_t *adaptor_it, + xcb_xv_port_t base) { for (; adaptor_it->rem; xcb_xv_adaptor_info_next(adaptor_it)) if (adaptor_it->data->type & XCB_XV_TYPE_IMAGE_MASK) { int j; for (j = 0; j < adaptor_it->data->num_ports; ++j) - if (!xv_check_yv12 (this->connection, adaptor_it->data->base_id + j)) + { + xcb_xv_port_t port = adaptor_it->data->base_id + j; + if (port >= base && !xv_check_yv12 (this->connection, port)) { - xcb_xv_port_t port = xv_open_port (this, adaptor_it->data->base_id + j); + xcb_xv_port_t port = xv_open_port (this, port); if (port) return port; } + } } return 0; } @@ -1205,11 +1209,12 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis xprintf(class->xine, XINE_VERBOSITY_NONE, _("%s: could not open Xv port %d - autodetecting\n"), LOG_MODULE, xv_port); - xv_port = xv_autodetect_port (this, &adaptor_it); + xv_port = xv_autodetect_port (this, &adaptor_it, xv_port); } else xv_find_adaptor_by_port (xv_port, &adaptor_it); - } else - xv_port = xv_autodetect_port (this, &adaptor_it); + } + if (!xv_port) + xv_port = xv_autodetect_port (this, &adaptor_it, 0); if (!xv_port) { xprintf(class->xine, XINE_VERBOSITY_LOG, diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index 115489e57..bc5928c25 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -1161,14 +1161,15 @@ xv_find_adaptor_by_port (int port, unsigned int adaptors, static XvPortID xv_autodetect_port(xv_driver_t *this, unsigned int adaptors, XvAdaptorInfo *adaptor_info, - unsigned int *adaptor_num) { + unsigned int *adaptor_num, + XvPortID base) { unsigned int an, j; for (an = 0; an < adaptors; an++) if (adaptor_info[an].type & XvImageMask) for (j = 0; j < adaptor_info[an].num_ports; j++) { XvPortID port = adaptor_info[an].base_id + j; - if (xv_open_port(this, port)) { + if (port >= base && xv_open_port(this, port)) { *adaptor_num = an; return port; } @@ -1241,11 +1242,12 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * xprintf(class->xine, XINE_VERBOSITY_NONE, _("%s: could not open Xv port %d - autodetecting\n"), LOG_MODULE, xv_port); - xv_port = xv_autodetect_port(this, adaptors, adaptor_info, &adaptor_num); + xv_port = xv_autodetect_port(this, adaptors, adaptor_info, &adaptor_num, xv_port); } else adaptor_num = xv_find_adaptor_by_port (xv_port, adaptors, adaptor_info); - } else - xv_port = xv_autodetect_port(this, adaptors, adaptor_info, &adaptor_num); + } + if (!xv_port) + xv_port = xv_autodetect_port(this, adaptors, adaptor_info, &adaptor_num, 0); if (!xv_port) { xprintf(class->xine, XINE_VERBOSITY_LOG, diff --git a/src/video_out/video_out_xxmc.c b/src/video_out/video_out_xxmc.c index 35346dd1d..1ef3652a9 100644 --- a/src/video_out/video_out_xxmc.c +++ b/src/video_out/video_out_xxmc.c @@ -2262,14 +2262,15 @@ xxmc_find_adaptor_by_port (int port, unsigned int adaptors, static XvPortID xxmc_autodetect_port(xxmc_driver_t *this, unsigned int adaptors, XvAdaptorInfo *adaptor_info, - unsigned int *adaptor_num) { + unsigned int *adaptor_num, + XvPortID base) { unsigned int an, j; for (an = 0; an < adaptors; an++) if (adaptor_info[an].type & XvImageMask) for (j = 0; j < adaptor_info[an].num_ports; j++) { XvPortID port = adaptor_info[an].base_id + j; - if (xxmc_open_port(this, port)) { + if (port >= base && xxmc_open_port(this, port)) { *adaptor_num = an; return port; } @@ -2486,11 +2487,12 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi xprintf(class->xine, XINE_VERBOSITY_NONE, _("%s: could not open Xv port %d - autodetecting\n"), LOG_MODULE, xv_port); - xv_port = xxmc_autodetect_port(this, adaptors, adaptor_info, &adaptor_num); + xv_port = xxmc_autodetect_port(this, adaptors, adaptor_info, &adaptor_num, xv_port); } else adaptor_num = xxmc_find_adaptor_by_port (xv_port, adaptors, adaptor_info); - } else - xv_port = xxmc_autodetect_port(this, adaptors, adaptor_info, &adaptor_num); + } + if (!xv_port) + xv_port = xxmc_autodetect_port(this, adaptors, adaptor_info, &adaptor_num, 0); if (!xv_port) { xprintf(class->xine, XINE_VERBOSITY_LOG, -- cgit v1.2.3 From 4a2a24dc98003e59ea9d7da982fefc81a82890d2 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Thu, 28 Feb 2008 13:47:59 +0000 Subject: Unbreak xcbxv port auto-detection (broken in cset f03669a2395d). --- src/video_out/video_out_xcbxv.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_xcbxv.c b/src/video_out/video_out_xcbxv.c index b7001ca03..204f59c2c 100644 --- a/src/video_out/video_out_xcbxv.c +++ b/src/video_out/video_out_xcbxv.c @@ -1133,12 +1133,8 @@ static xcb_xv_port_t xv_autodetect_port(xv_driver_t *this, for (j = 0; j < adaptor_it->data->num_ports; ++j) { xcb_xv_port_t port = adaptor_it->data->base_id + j; - if (port >= base && !xv_check_yv12 (this->connection, port)) - { - xcb_xv_port_t port = xv_open_port (this, port); - if (port) - return port; - } + if (port >= base && xv_open_port (this, port)) + return port; } } return 0; -- cgit v1.2.3 From fb54f247855376800b65585e5868cd4d2062c0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sat, 1 Mar 2008 02:45:44 +0100 Subject: Support the new FFmpeg include layout. Now the same include directive should work for both internal and external FFmpeg (with new layout). --- src/libffmpeg/Makefile.am | 2 ++ src/libffmpeg/ff_dvaudio_decoder.c | 8 ++++---- src/libffmpeg/ff_video_decoder.c | 4 ++-- src/libffmpeg/ffmpeg_decoder.h | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/libffmpeg/Makefile.am b/src/libffmpeg/Makefile.am index 61acdd0d1..96d269278 100644 --- a/src/libffmpeg/Makefile.am +++ b/src/libffmpeg/Makefile.am @@ -1,5 +1,7 @@ include $(top_srcdir)/misc/Makefile.common +DEFAULT_INCLUDES = -I. + if HAVE_FFMPEG AM_CFLAGS = $(FFMPEG_CFLAGS) $(FFMPEG_POSTPROC_CFLAGS) link_ffmpeg = $(FFMPEG_LIBS) $(FFMPEG_POSTPROC_LIBS) diff --git a/src/libffmpeg/ff_dvaudio_decoder.c b/src/libffmpeg/ff_dvaudio_decoder.c index 0796b3862..a394e6615 100644 --- a/src/libffmpeg/ff_dvaudio_decoder.c +++ b/src/libffmpeg/ff_dvaudio_decoder.c @@ -52,14 +52,14 @@ # undef uint64_t #endif -#ifdef HAVE_FFMPEG +#ifdef HAVE_FFMPEG_AVCODEC_H # include -# include "libavcodec/dvdata.h" #else -# include "libavcodec/avcodec.h" -# include "libavcodec/dvdata.h" +# include #endif +#include "libavcodec/dvdata.h" + #ifdef _MSC_VER # undef malloc # undef free diff --git a/src/libffmpeg/ff_video_decoder.c b/src/libffmpeg/ff_video_decoder.c index dc07abb9f..d1d69416e 100644 --- a/src/libffmpeg/ff_video_decoder.c +++ b/src/libffmpeg/ff_video_decoder.c @@ -45,10 +45,10 @@ #include "ffmpeg_decoder.h" #include "ff_mpeg_parser.h" -#ifdef HAVE_FFMPEG +#ifdef HAVE_FFMPEG_AVCODEC_H # include #else -# include "libavcodec/libpostproc/postprocess.h" +# include #endif #define VIDEOBUFSIZE (128*1024) diff --git a/src/libffmpeg/ffmpeg_decoder.h b/src/libffmpeg/ffmpeg_decoder.h index 14788cf29..adf0908dd 100644 --- a/src/libffmpeg/ffmpeg_decoder.h +++ b/src/libffmpeg/ffmpeg_decoder.h @@ -25,10 +25,10 @@ #include "config.h" #endif -#ifdef HAVE_FFMPEG +#ifdef HAVE_FFMPEG_AVCODEC_H # include #else -# include "libavcodec/avcodec.h" +# include #endif typedef struct ff_codec_s { -- cgit v1.2.3 From 6cfb0e7a31d0cb5da6b10bdb4cb2a41d55531812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sat, 1 Mar 2008 02:54:13 +0100 Subject: Only include the toplevel ffmpeg directory, with the new style include it works better. --- src/combined/ffmpeg/Makefile.am | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/combined/ffmpeg/Makefile.am b/src/combined/ffmpeg/Makefile.am index b9dee7ea6..93d9b8143 100644 --- a/src/combined/ffmpeg/Makefile.am +++ b/src/combined/ffmpeg/Makefile.am @@ -8,9 +8,7 @@ if WITH_EXTERNAL_FFMPEG AM_CFLAGS += $(FFMPEG_CFLAGS) $(FFMPEG_POSTPROC_CFLAGS) link_ffmpeg = $(FFMPEG_LIBS) $(FFMPEG_POSTPROC_LIBS) else -AM_CPPFLAGS += -I$(top_srcdir)/contrib/ffmpeg/libavutil \ - -I$(top_srcdir)/contrib/ffmpeg/libavcodec \ - -I$(top_srcdir)/contrib/ffmpeg/libpostproc +AM_CPPFLAGS += -I$(top_srcdir)/contrib/ffmpeg link_ffmpeg = $(top_builddir)/contrib/ffmpeg/libavcodec/libavcodec.a \ $(top_builddir)/contrib/ffmpeg/libavutil/libavutil.a \ $(top_builddir)/contrib/ffmpeg/libpostproc/libpostproc.a @@ -59,4 +57,4 @@ xineplug_decode_ff_la_LDFLAGS = $(AM_LDFLAGS) $(IMPURE_TEXT_LDFLAGS) xineplug_decode_dvaudio_la_SOURCES = ff_dvaudio_decoder.c xineplug_decode_dvaudio_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) -xineplug_decode_dvaudio_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/contrib/ffmpeg/libavcodec +xineplug_decode_dvaudio_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/contrib/ffmpeg -- cgit v1.2.3 From df2107b51d969709c851b5cffe76cd0c9c2f4335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sat, 1 Mar 2008 02:54:39 +0100 Subject: dvdata.h is no more in include path alone. --- src/combined/ffmpeg/ff_dvaudio_decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/combined/ffmpeg/ff_dvaudio_decoder.c b/src/combined/ffmpeg/ff_dvaudio_decoder.c index 293f35e7c..be7e8025f 100644 --- a/src/combined/ffmpeg/ff_dvaudio_decoder.c +++ b/src/combined/ffmpeg/ff_dvaudio_decoder.c @@ -58,7 +58,7 @@ # include #endif -#include /* This is not installed by FFmpeg, its usage has to be cleared up */ +#include /* This is not installed by FFmpeg, its usage has to be cleared up */ #ifdef _MSC_VER # undef malloc -- cgit v1.2.3 From a1508e2f58d2c4b32d032d798f6f137262717e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sat, 1 Mar 2008 03:07:38 +0100 Subject: Add extra include, dvaudio always have to use internal copy. --- src/combined/ffmpeg/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/combined/ffmpeg/Makefile.am b/src/combined/ffmpeg/Makefile.am index 93d9b8143..b9f0eac5c 100644 --- a/src/combined/ffmpeg/Makefile.am +++ b/src/combined/ffmpeg/Makefile.am @@ -57,4 +57,4 @@ xineplug_decode_ff_la_LDFLAGS = $(AM_LDFLAGS) $(IMPURE_TEXT_LDFLAGS) xineplug_decode_dvaudio_la_SOURCES = ff_dvaudio_decoder.c xineplug_decode_dvaudio_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) -xineplug_decode_dvaudio_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/contrib/ffmpeg +xineplug_decode_dvaudio_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/contrib/ffmpeg -I$(top_srcdir)/contrib/ffmpeg/libavutil -- cgit v1.2.3