From: Diego 'F. P. <fla...@gm...> - 2008-05-23 13:08:38
|
# [node 907d7287c37ba2007e7b0a462206822c97bcd493 part 2] diff -r 14fced98788787727e1286da5dcf1e051cabbf15 -r 907d7287c37ba2007e7b0a462206822c97bcd493 src/xine-engine/xine.c --- a/src/xine-engine/xine.c Fri May 23 15:06:46 2008 +0200 +++ b/src/xine-engine/xine.c Sun May 11 17:42:59 2008 +0200 @@ -341,7 +341,7 @@ static xine_ticket_t *ticket_init(void) static xine_ticket_t *ticket_init(void) { xine_ticket_t *port_ticket; - port_ticket = (xine_ticket_t *) xine_xmalloc(sizeof(xine_ticket_t)); + port_ticket = calloc(1, sizeof(xine_ticket_t)); port_ticket->acquire_nonblocking = ticket_acquire_nonblocking; port_ticket->acquire = ticket_acquire; @@ -611,7 +611,7 @@ xine_stream_t *xine_stream_new (xine_t * pthread_mutex_lock (&this->streams_lock); - stream = (xine_stream_t *) xine_xmalloc (sizeof (xine_stream_t)) ; + stream = (xine_stream_t *) calloc (1, sizeof (xine_stream_t)) ; stream->current_extra_info = malloc( sizeof( extra_info_t ) ); stream->audio_decoder_extra_info = malloc( sizeof( extra_info_t ) ); stream->video_decoder_extra_info = malloc( sizeof( extra_info_t ) ); @@ -777,7 +777,7 @@ xine_stream_t *xine_stream_new (xine_t * } void _x_mrl_unescape(char *mrl) { - int i, len = strlen(mrl); + size_t i, len = strlen(mrl); for (i = 0; i < len; i++) { if ((mrl[i]=='%') && (i<(len-2))) { @@ -1591,7 +1591,7 @@ xine_t *xine_new (void) { int i_err; #endif - this = xine_xmalloc (sizeof (xine_t)); + this = calloc(1, sizeof (xine_t)); if (!this) _x_abort(); @@ -1981,67 +1981,60 @@ int xine_get_pos_length (xine_stream_t * return 1; } -static int _x_get_current_frame_impl (xine_stream_t *stream, int *width, int *height, - int *ratio_code, int *format, - uint8_t **img, int *size, int alloc_img, - int *interlaced, - int *crop_left, int *crop_right, - int *crop_top, int *crop_bottom) { +static int _x_get_current_frame_data (xine_stream_t *stream, + xine_current_frame_data_t *data, + int flags, int img_size_unknown) { vo_frame_t *frame; - int required_size; + size_t required_size; stream->xine->port_ticket->acquire(stream->xine->port_ticket, 0); frame = stream->video_out->get_last_frame (stream->video_out); stream->xine->port_ticket->release(stream->xine->port_ticket, 0); - if (!frame) + if (!frame) { + data->img_size = 0; return 0; - - *width = frame->width; - *height = frame->height; - - *ratio_code = 10000.0 * frame->ratio; + } + + data->width = frame->width; + data->height = frame->height; + data->crop_left = frame->crop_left; + data->crop_right = frame->crop_right; + data->crop_top = frame->crop_top; + data->crop_bottom = frame->crop_bottom; + + data->ratio_code = 10000.0 * frame->ratio; /* make ratio_code backward compatible */ #define RATIO_LIKE(a, b) ((b) - 1 <= (a) && (a) <= 1 + (b)) - if (RATIO_LIKE(*ratio_code, 10000)) - *ratio_code = XINE_VO_ASPECT_SQUARE; - else if (RATIO_LIKE(*ratio_code, 13333)) - *ratio_code = XINE_VO_ASPECT_4_3; - else if (RATIO_LIKE(*ratio_code, 17778)) - *ratio_code = XINE_VO_ASPECT_ANAMORPHIC; - else if (RATIO_LIKE(*ratio_code, 21100)) - *ratio_code = XINE_VO_ASPECT_DVB; - - *format = frame->format; - - if (interlaced) - *interlaced = frame->progressive_frame ? 0 : (2 - frame->top_field_first); - if (crop_left) - *crop_left = frame->crop_left; - if (crop_right) - *crop_right = frame->crop_right; - if (crop_top) - *crop_top = frame->crop_top; - if (crop_bottom) - *crop_bottom = frame->crop_bottom; - - switch (*format) { + if (RATIO_LIKE(data->ratio_code, 10000)) + data->ratio_code = XINE_VO_ASPECT_SQUARE; + else if (RATIO_LIKE(data->ratio_code, 13333)) + data->ratio_code = XINE_VO_ASPECT_4_3; + else if (RATIO_LIKE(data->ratio_code, 17778)) + data->ratio_code = XINE_VO_ASPECT_ANAMORPHIC; + else if (RATIO_LIKE(data->ratio_code, 21100)) + data->ratio_code = XINE_VO_ASPECT_DVB; + + data->format = frame->format; + data->interlaced = frame->progressive_frame ? 0 : (2 - frame->top_field_first); + + switch (frame->format) { case XINE_IMGFMT_YV12: - required_size = *width * *height - + ((*width + 1) / 2) * ((*height + 1) / 2) - + ((*width + 1) / 2) * ((*height + 1) / 2); + required_size = frame->width * frame->height + + ((frame->width + 1) / 2) * ((frame->height + 1) / 2) + + ((frame->width + 1) / 2) * ((frame->height + 1) / 2); break; [... 39 lines omitted ...] - if (size) - *size = required_size; + /* return used buffer size */ + data->img_size = required_size; } - if (*img) { + if (data->img) { switch (frame->format) { case XINE_IMGFMT_YV12: yv12_to_yv12( /* Y */ frame->base[0], frame->pitches[0], - *img, frame->width, + data->img, frame->width, /* U */ frame->base[1], frame->pitches[1], - *img+frame->width*frame->height, frame->width/2, + data->img+frame->width*frame->height, frame->width/2, /* V */ frame->base[2], frame->pitches[2], - *img+frame->width*frame->height+frame->width*frame->height/4, frame->width/2, + data->img+frame->width*frame->height+frame->width*frame->height/4, frame->width/2, /* width x height */ frame->width, frame->height); break; @@ -2091,7 +2082,7 @@ static int _x_get_current_frame_impl (xi /* src */ frame->base[0], frame->pitches[0], /* dst */ - *img, frame->width*2, + data->img, frame->width*2, /* width x height */ frame->width, frame->height); break; @@ -2105,29 +2096,79 @@ static int _x_get_current_frame_impl (xi return 1; } +int xine_get_current_frame_data (xine_stream_t *stream, + xine_current_frame_data_t *data, + int flags) { + + return _x_get_current_frame_data(stream, data, flags, 0); +} + int xine_get_current_frame_alloc (xine_stream_t *stream, int *width, int *height, int *ratio_code, int *format, - uint8_t **img, int *size, - int *interlaced, - int *crop_left, int *crop_right, - int *crop_top, int *crop_bottom) { - uint8_t *no_img = NULL; - return _x_get_current_frame_impl(stream, width, height, ratio_code, format, img ? img : &no_img, size, img != NULL, interlaced, crop_left, crop_right, crop_top, crop_bottom); + uint8_t **img, int *img_size) { + + int result; + xine_current_frame_data_t data; + + memset(&data, 0, sizeof (data)); + + result = _x_get_current_frame_data(stream, &data, img ? XINE_FRAME_DATA_ALLOCATE_IMG : 0, 0); + if (width) *width = data.width; + if (height) *height = data.height; + if (ratio_code) *ratio_code = data.ratio_code; + if (format) *format = data.format; + if (img_size) *img_size = data.img_size; + if (img) *img = data.img; + return result; } int xine_get_current_frame_s (xine_stream_t *stream, int *width, int *height, int *ratio_code, int *format, - uint8_t *img, int *size, - int *interlaced, - int *crop_left, int *crop_right, - int *crop_top, int *crop_bottom) { - return (!img || size) && _x_get_current_frame_impl(stream, width, height, ratio_code, format, &img, size, 0, interlaced, crop_left, crop_right, crop_top, crop_bottom); + uint8_t *img, int *img_size) { + int result; + xine_current_frame_data_t data; + + memset(&data, 0, sizeof (data)); + data.img = img; + if (img_size) + data.img_size = *img_size; + + result = _x_get_current_frame_data(stream, &data, 0, 0); + if (width) *width = data.width; + if (height) *height = data.height; + if (ratio_code) *ratio_code = data.ratio_code; + if (format) *format = data.format; + if (img_size) *img_size = data.img_size; + return result; } int xine_get_current_frame (xine_stream_t *stream, int *width, int *height, int *ratio_code, int *format, uint8_t *img) { - return _x_get_current_frame_impl(stream, width, height, ratio_code, format, &img, NULL, 0, NULL, NULL, NULL, NULL, NULL); + int result; + xine_current_frame_data_t data; + + memset(&data, 0, sizeof (data)); + data.img = img; + + result = _x_get_current_frame_data(stream, &data, 0, 1); + if (width) *width = data.width; + if (height) *height = data.height; + if (ratio_code) *ratio_code = data.ratio_code; + if (format) *format = data.format; + return result; +} + +int xine_get_video_frame (xine_stream_t *stream, + int timestamp, /* msec */ + int *width, int *height, + int *ratio_code, + int *duration, /* msec */ + int *format, + uint8_t *img) { + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "xine: xine_get_video_frame not implemented yet.\n"); + _x_abort (); + return 0; } int xine_get_spu_lang (xine_stream_t *stream, int channel, char *lang) { diff -r 14fced98788787727e1286da5dcf1e051cabbf15 -r 907d7287c37ba2007e7b0a462206822c97bcd493 src/xine-engine/xine_interface.c --- a/src/xine-engine/xine_interface.c Fri May 23 15:06:46 2008 +0200 +++ b/src/xine-engine/xine_interface.c Sun May 11 17:42:59 2008 +0200 @@ -936,7 +936,7 @@ int _x_message(xine_stream_t *stream, in xine_ui_message_data_t *data; xine_event_t event; const char *explanation; - int size; + size_t size; int n; va_list ap; char *s, *params; @@ -981,7 +981,7 @@ int _x_message(xine_stream_t *stream, in args[n] = NULL; size += sizeof(xine_ui_message_data_t) + 1; - data = xine_xmalloc( size ); + data = calloc(1, size ); strcpy(data->compatibility.str, "Upgrade your frontend to see the error messages"); data->type = type; diff -r 14fced98788787727e1286da5dcf1e051cabbf15 -r 907d7287c37ba2007e7b0a462206822c97bcd493 src/xine-utils/Makefile.am --- a/src/xine-utils/Makefile.am Fri May 23 15:06:46 2008 +0200 +++ b/src/xine-utils/Makefile.am Sun May 11 17:42:59 2008 +0200 @@ -5,7 +5,7 @@ AM_CPPFLAGS = -DXINE_LIBRARY_COMPILE EXTRA_DIST = ppcasm_string.S ppc_asm.tmpl -noinst_HEADERS = ppcasm_string.h xine_check.h mangle.h +noinst_HEADERS = ppcasm_string.h mangle.h noinst_LTLIBRARIES = libxineutils.la diff -r 14fced98788787727e1286da5dcf1e051cabbf15 -r 907d7287c37ba2007e7b0a462206822c97bcd493 src/xine-utils/list.c --- a/src/xine-utils/list.c Fri May 23 15:06:46 2008 +0200 +++ b/src/xine-utils/list.c Sun May 11 17:42:59 2008 +0200 @@ -69,7 +69,7 @@ struct xine_list_s { */ static xine_list_chunk_t *xine_list_alloc_chunk(size_t size) { xine_list_chunk_t *new_chunk; - size_t chunk_mem_size;; + size_t chunk_mem_size; chunk_mem_size = sizeof(xine_list_chunk_t); chunk_mem_size += sizeof(xine_list_elem_t) * size; diff -r 14fced98788787727e1286da5dcf1e051cabbf15 -r 907d7287c37ba2007e7b0a462206822c97bcd493 src/xine-utils/utils.c --- a/src/xine-utils/utils.c Fri May 23 15:06:46 2008 +0200 +++ b/src/xine-utils/utils.c Sun May 11 17:42:59 2008 +0200 @@ -236,7 +236,25 @@ static const lang_locale_t lang_locales[ { "" } }; - +/** + * @brief Allocate and clean memory size_t 'size', then return the + * pointer to the allocated memory. + * @param size Size of the memory area to allocate. + * + * @return A pointer to the allocated memory area, or NULL in case of + * error. + * + * The behaviour of this function differs from standard malloc() as + * xine_xmalloc(0) will not return a NULL pointer, but rather a + * pointer to a memory area of size 1 byte. + * + * The NULL value is only ever returned in case of an error in + * malloc(), and is reported to stderr stream. + * + * @deprecated This function has been deprecated, as the behaviour of + * allocating a 1 byte memory area on zero size is almost + * never desired, and the function is thus mostly misused. + */ void *xine_xmalloc(size_t size) { void *ptr; @@ -278,7 +296,7 @@ void *xine_xmalloc_aligned(size_t alignm char *ptr; - *base = ptr = xine_xmalloc (size+alignment); + *base = ptr = calloc(1, size+alignment); while ((size_t) ptr % alignment) ptr++; @@ -543,7 +561,7 @@ void xine_hexdump (const void *buf_gen, static const lang_locale_t *_get_first_lang_locale(const char *lcal) { const lang_locale_t *llocale; - int lang_len; + size_t lang_len; char *mod; if(lcal && *lcal) { diff -r 14fced98788787727e1286da5dcf1e051cabbf15 -r 907d7287c37ba2007e7b0a462206822c97bcd493 src/xine-utils/xine_buffer.c --- a/src/xine-utils/xine_buffer.c Fri May 23 15:06:46 2008 +0200 +++ b/src/xine-utils/xine_buffer.c Sun May 11 17:42:59 2008 +0200 @@ -117,7 +117,7 @@ typedef struct { */ void *xine_buffer_init(int chunk_size) { - uint8_t *data=xine_xmalloc(chunk_size+XINE_BUFFER_HEADER_SIZE); + uint8_t *data=calloc(1, chunk_size+XINE_BUFFER_HEADER_SIZE); xine_buffer_header_t *header=(xine_buffer_header_t*)data; header->size=chunk_size; @@ -162,7 +162,7 @@ void *xine_buffer_dup(const void *buf) { CHECK_MAGIC(buf); #endif -new=xine_xmalloc(GET_HEADER(buf)->size+XINE_BUFFER_HEADER_SIZE); + new = malloc(GET_HEADER(buf)->size+XINE_BUFFER_HEADER_SIZE); xine_fast_memcpy(new, ((uint8_t*)buf)-XINE_BUFFER_HEADER_SIZE, GET_HEADER(buf)->size+XINE_BUFFER_HEADER_SIZE); diff -r 14fced98788787727e1286da5dcf1e051cabbf15 -r 907d7287c37ba2007e7b0a462206822c97bcd493 src/xine-utils/xine_check.c --- a/src/xine-utils/xine_check.c Fri May 23 15:06:46 2008 +0200 +++ b/src/xine-utils/xine_check.c Sun May 11 17:42:59 2008 +0200 @@ -44,7 +44,6 @@ #include <fcntl.h> #include <unistd.h> -#include "xine_check.h" #include <xine/xineutils.h> #if defined(__linux__) @@ -102,38 +101,7 @@ set_hc_result(xine_health_check_t* hc, i #if defined(__linux__) -xine_health_check_t* xine_health_check (xine_health_check_t* hc, int check_num) { - - switch(check_num) { - case CHECK_KERNEL: - hc = _x_health_check_kernel (hc); - break; - case CHECK_MTRR: - hc = _x_health_check_mtrr (hc); - break; - case CHECK_CDROM: - hc = _x_health_check_cdrom (hc); - break; - case CHECK_DVDROM: - hc = _x_health_check_dvdrom (hc); - break; - case CHECK_DMA: - hc = _x_health_check_dma (hc); - break; - case CHECK_X: - hc = _x_health_check_x (hc); - break; - case CHECK_XV: - hc = _x_health_check_xv (hc); - break; - default: - hc->status = XINE_HEALTH_CHECK_NO_SUCH_CHECK; - } - - return hc; -} - -xine_health_check_t* _x_health_check_kernel (xine_health_check_t* hc) { +static xine_health_check_t* _x_health_check_kernel (xine_health_check_t* hc) { struct utsname kernel; hc->title = "Check for kernel version"; @@ -153,7 +121,7 @@ xine_health_check_t* _x_health_check_ker } #if defined(ARCH_X86) || defined(ARCH_X86_64) -xine_health_check_t* _x_health_check_mtrr (xine_health_check_t* hc) { +static xine_health_check_t* _x_health_check_mtrr (xine_health_check_t* hc) { FILE *fd; hc->title = "Check for MTRR support"; @@ -170,7 +138,7 @@ xine_health_check_t* _x_health_check_mtr return hc; } #else -xine_health_check_t* _x_health_check_mtrr (xine_health_check_t* hc) { +static xine_health_check_t* _x_health_check_mtrr (xine_health_check_t* hc) { hc->title = "Check for MTRR support"; hc->explanation = "Don't worry about this one"; @@ -181,7 +149,7 @@ xine_health_check_t* _x_health_check_mtr } #endif -xine_health_check_t* _x_health_check_cdrom (xine_health_check_t* hc) { +static xine_health_check_t* _x_health_check_cdrom (xine_health_check_t* hc) { struct stat cdrom_st; int fd; @@ -217,7 +185,7 @@ xine_health_check_t* _x_health_check_cdr return hc; } -xine_health_check_t* _x_health_check_dvdrom(xine_health_check_t* hc) { +static xine_health_check_t* _x_health_check_dvdrom(xine_health_check_t* hc) { struct stat dvdrom_st; int fd; @@ -253,7 +221,7 @@ xine_health_check_t* _x_health_check_dvd return hc; } -xine_health_check_t* _x_health_check_dma (xine_health_check_t* hc) { +static xine_health_check_t* _x_health_check_dma (xine_health_check_t* hc) { int is_scsi_dev = 0; int fd = 0; @@ -307,7 +275,7 @@ xine_health_check_t* _x_health_check_dma } -xine_health_check_t* _x_health_check_x (xine_health_check_t* hc) { +static xine_health_check_t* _x_health_check_x (xine_health_check_t* hc) { char* env_display = getenv("DISPLAY"); hc->title = "Check for X11 environment"; @@ -323,7 +291,7 @@ xine_health_check_t* _x_health_check_x ( return hc; } -xine_health_check_t* _x_health_check_xv (xine_health_check_t* hc) { +static xine_health_check_t* _x_health_check_xv (xine_health_check_t* hc) { #ifdef HAVE_X11 #ifdef HAVE_XV @@ -497,6 +465,37 @@ xine_health_check_t* _x_health_check_xv #endif /* ! HAVE_X11 */ } +xine_health_check_t* xine_health_check (xine_health_check_t* hc, int check_num) { + + switch(check_num) { + case CHECK_KERNEL: + hc = _x_health_check_kernel (hc); + break; + case CHECK_MTRR: + hc = _x_health_check_mtrr (hc); + break; + case CHECK_CDROM: + hc = _x_health_check_cdrom (hc); + break; + case CHECK_DVDROM: + hc = _x_health_check_dvdrom (hc); + break; + case CHECK_DMA: + hc = _x_health_check_dma (hc); + break; + case CHECK_X: + hc = _x_health_check_x (hc); + break; + case CHECK_XV: + hc = _x_health_check_xv (hc); + break; + default: + hc->status = XINE_HEALTH_CHECK_NO_SUCH_CHECK; + } + + return hc; +} + #else /* !__linux__ */ xine_health_check_t* xine_health_check (xine_health_check_t* hc, int check_num) { hc->title = "xine health check not supported on this platform"; diff -r 14fced98788787727e1286da5dcf1e051cabbf15 -r 907d7287c37ba2007e7b0a462206822c97bcd493 src/xine-utils/xmllexer.c --- a/src/xine-utils/xmllexer.c Fri May 23 15:06:46 2008 +0200 +++ b/src/xine-utils/xmllexer.c Sun May 11 17:42:59 2008 +0200 @@ -29,7 +29,6 @@ #include <xine/xineutils.h> #else #define lprintf(...) -#define xine_xmalloc malloc #endif #include <xine/xmllexer.h> #include <stdio.h> @@ -592,7 +591,7 @@ static struct { char *lexer_decode_entities (const char *tok) { - char *buf = xine_xmalloc (strlen (tok) + 1); + char *buf = calloc (strlen (tok) + 1, sizeof(char)); char *bp = buf; char c; diff -r 14fced98788787727e1286da5dcf1e051cabbf15 -r 907d7287c37ba2007e7b0a462206822c97bcd493 src/xine-utils/xmlparser.c --- a/src/xine-utils/xmlparser.c Fri May 23 15:06:46 2008 +0200 +++ b/src/xine-utils/xmlparser.c Sun May 11 17:42:59 2008 +0200 @@ -40,7 +40,6 @@ #include <xine/xineutils.h> #else #define lprintf(...) -#define xine_xmalloc malloc #endif #include <xine/xmllexer.h> #include <xine/xmlparser.h> @@ -645,11 +644,12 @@ static int xml_parser_get_node (xml_node int token_buffer_size = TOKEN_SIZE; int pname_buffer_size = TOKEN_SIZE; int nname_buffer_size = TOKEN_SIZE; - char *token_buffer = xine_xmalloc (token_buffer_size); - char *pname_buffer = xine_xmalloc (pname_buffer_size); - char *nname_buffer = xine_xmalloc (nname_buffer_size); + char *token_buffer = calloc(1, token_buffer_size); + char *pname_buffer = calloc(1, pname_buffer_size); + char *nname_buffer = calloc(1, nname_buffer_size); char *root_names[MAX_RECURSION + 1]; root_names[0] = ""; + res = xml_parser_get_node_internal (&token_buffer, &token_buffer_size, &pname_buffer, &pname_buffer_size, &nname_buffer, &nname_buffer_size, @@ -794,7 +794,7 @@ static int xml_escape_string_internal (c char *xml_escape_string (const char *s, xml_escape_quote_t quote_type) { - char *buf = xine_xmalloc (xml_escape_string_internal (NULL, s, quote_type)); + char *buf = calloc (1, xml_escape_string_internal (NULL, s, quote_type)); return buf ? (xml_escape_string_internal (buf, s, quote_type), buf) : NULL; } @@ -802,11 +802,10 @@ static void xml_parser_dump_node (const xml_property_t *p; xml_node_t *n; - int l; printf ("%*s<%s ", indent, "", node->name); - l = strlen (node->name); + size_t l = strlen (node->name); p = node->props; while (p) { diff -r 14fced98788787727e1286da5dcf1e051cabbf15 -r 907d7287c37ba2007e7b0a462206822c97bcd493 src/xine-utils/xine_check.h --- a/src/xine-utils/xine_check.h Fri May 23 15:06:46 2008 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -#ifndef XINE_CHECK_H -#define XINE_CHECK_H -#include <stdio.h> - -#include <xine.h> - -/* - * Start checking xine setup here - * - * cdrom_dev = Name of the device link for the cdrom drive (e.g. /dev/cdrom) - * dvd_dev = Name of the device link for the dvd drive (e.g. /dev/dvd) - */ - -/* Get Kernel information */ -xine_health_check_t* _x_health_check_kernel(xine_health_check_t*); - -/* health_check MTRR */ -xine_health_check_t* _x_health_check_mtrr(xine_health_check_t*); - -/* health_check CDROM */ -xine_health_check_t* _x_health_check_cdrom(xine_health_check_t*); - -/* health_check DVDROM */ -xine_health_check_t* _x_health_check_dvdrom(xine_health_check_t*); - -/* health_check DMA settings of DVD drive*/ -xine_health_check_t* _x_health_check_dma(xine_health_check_t*); - -/* health_check X */ -xine_health_check_t* _x_health_check_x(xine_health_check_t*); - -/* health_check Xv extension */ -xine_health_check_t* _x_health_check_xv(xine_health_check_t*); - -#endif |