Thread: [Mplayerxp-cvslog] SF.net SVN: mplayerxp:[385] mplayerxp (Page 6)
Brought to you by:
olov
From: <nic...@us...> - 2012-11-16 12:13:45
|
Revision: 385 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=385&view=rev Author: nickols_k Date: 2012-11-16 12:13:37 +0000 (Fri, 16 Nov 2012) Log Message: ----------- more C++ sources Modified Paths: -------------- mplayerxp/libmpdemux/freesdp/Makefile mplayerxp/libmpdemux/freesdp/priv.h mplayerxp/osdep/Makefile mplayerxp/osdep/get_path.h mplayerxp/osdep/shmem.h mplayerxp/postproc/Makefile mplayerxp/postproc/libmenu/Makefile mplayerxp/postproc/libmenu/menu.h Added Paths: ----------- mplayerxp/libmpdemux/freesdp/parser.cpp mplayerxp/osdep/get_path.cpp mplayerxp/osdep/shmem.cpp mplayerxp/postproc/af_export.cpp mplayerxp/postproc/libmenu/menu.cpp Removed Paths: ------------- mplayerxp/libmpdemux/freesdp/parser.c mplayerxp/osdep/get_path.c mplayerxp/osdep/shmem.c mplayerxp/postproc/af_export.c mplayerxp/postproc/libmenu/menu.c Modified: mplayerxp/libmpdemux/freesdp/Makefile =================================================================== --- mplayerxp/libmpdemux/freesdp/Makefile 2012-11-16 11:32:49 UTC (rev 384) +++ mplayerxp/libmpdemux/freesdp/Makefile 2012-11-16 12:13:37 UTC (rev 385) @@ -1,18 +1,23 @@ include ../../mp_config.mak +CXXSRCS=parser.cpp SRCS = common.c \ - errorlist.c \ - parser.c + errorlist.c + OBJS=$(SRCS:.c=.o) +CXXOBJS=$(CXXSRCS:.cpp=.o) CFLAGS = $(OPTFLAGS) -I. -I../.. $(EXTRA_INC) -Wall +CXXFLAGS = $(OPTXXFLAGS) -I. -I../.. $(EXTRA_INC) -Wall .SUFFIXES: .c .o -all: $(OBJS) +all: $(OBJS) $(CXXOBJS) .c.o: $(CC) -c $(CFLAGS) -o $@ $< +.cpp.o: + $(CC) -c $(CXXFLAGS) -o $@ $< clean: rm -f *.o *.a *~ @@ -23,7 +28,7 @@ dep: depend depend: - $(CC) -MM $(CFLAGS) $(SRCS) 1>.depend + $(CC) -MM $(CFLAGS) $(SRCS) $(CXXSRCS) 1>.depend # # include dependency files if they exist Deleted: mplayerxp/libmpdemux/freesdp/parser.c =================================================================== --- mplayerxp/libmpdemux/freesdp/parser.c 2012-11-16 11:32:49 UTC (rev 384) +++ mplayerxp/libmpdemux/freesdp/parser.c 2012-11-16 12:13:37 UTC (rev 385) @@ -1,1959 +0,0 @@ -/* - This file is part of FreeSDP - Copyright (C) 2001,2002,2003 Federico Montesino Pouzols <fe...@al...> - - FreeSDP is mp_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. - - 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 - - Benjamin Zores, (C) 2006 - added support in parser for the a=control: lines. - added support in parser for the a=range: lines. -*/ - -/** - * @file parser.c - * - * @short Parsing module implementation. - * - * This file implements the parsing routine <code>fsdp_parse</code> - * and the <code>fsdp_get_xxxx</code> routines that allow to get the - * session properties from a session description object build through - * the application of <code>fsdp_parse</code> to a textual SDP session - * description. - **/ - -#include "parserpriv.h" -#include "osdep/mplib.h" - -/** - * \brief find the start of the next line - * \param c pointer to current position in string - * \return pointer to start of next line or NULL if illegal (i.e. - * a '\r' is not followed by a '\n' - */ -static const char *next_line(const char *c) { - c += strcspn(c, "\n\r"); - if (*c == 0) return c; - if (*c == '\r') c++; - if (*c == '\n') - return c + 1; - return NULL; -} - -/** - * Moves the <code>c<code> pointer up to the beginning of the next - * line. - * - * @param c char pointer to pointer - * @retval FSDPE_ILLEGAL_CHARACTER, when an illegal '\r' character - * (not followed by a '\n') is found, returns - */ -#define NEXT_LINE(c) do { if (!(c = next_line(c))) return FSDPE_ILLEGAL_CHARACTER; } while (0); - -fsdp_error_t -fsdp_parse (const char *text_description, fsdp_description_t * dsc) -{ - fsdp_error_t result; - const char *p = text_description, *p2; - unsigned int _index, j; - /* temps for sscanf */ - const unsigned int TEMPCHARS = 6; - char fsdp_buf[TEMPCHARS][MAXSHORTFIELDLEN]; - char longfsdp_buf[MAXLONGFIELDLEN]; - const unsigned int TEMPINTS = 2; - unsigned long int wuint[TEMPINTS]; - - if ((NULL == text_description) || (NULL == dsc)) - return FSDPE_INVALID_PARAMETER; - - /***************************************************************************/ - /* A) parse session-level description */ - /***************************************************************************/ - - /* `v=' line (protocol version) */ - /* according to the RFC, only `v=0' is valid */ - if (sscanf (p, "v=%1lu", &wuint[0])) - { - if (wuint[0] != 0) - return FSDPE_INVALID_VERSION; - } - else - { - return FSDPE_MISSING_VERSION; - } - NEXT_LINE (p); - - /* `o=' line (owner/creator and session identifier) */ - /* o=<username> <session id> <version> <network type> <address type> - <address> */ - if (!strncmp (p, "o=", 2)) - { - p += 2; - /* note that the following max lengths may vary in the future and - are quite arbitary */ - if (sscanf - (p, - "%" MSFLENS "[\x21-\xFF] %" MSFLENS "[0-9] %" MSFLENS - "[0-9] %2s %3s %" MSFLENS "s", fsdp_buf[0], fsdp_buf[1], - fsdp_buf[2], fsdp_buf[3], fsdp_buf[4], fsdp_buf[5]) != 6) - return FSDPE_INVALID_OWNER; - dsc->o_username = mp_strdup (fsdp_buf[0]); - dsc->o_session_id = mp_strdup (fsdp_buf[1]); - dsc->o_announcement_version = mp_strdup (fsdp_buf[2]); - if (!strncmp (fsdp_buf[3], "IN", 2)) - { - dsc->o_network_type = FSDP_NETWORK_TYPE_INET; - if (!strncmp (fsdp_buf[4], "IP4", 3)) - dsc->o_address_type = FSDP_ADDRESS_TYPE_IPV4; - else if (!strncmp (fsdp_buf[4], "IP6", 3)) - dsc->o_address_type = FSDP_ADDRESS_TYPE_IPV6; - else - return FSDPE_INVALID_OWNER; - } - else - { - return FSDPE_INVALID_OWNER; - } - /* TODO? check valid unicast address/FQDN */ - dsc->o_address = mp_strdup (fsdp_buf[5]); - } - else - { - return FSDPE_MISSING_OWNER; - } - NEXT_LINE (p); - - /* `s=' line (session name) -note that the name string cannot be empty */ - /* s=<session name> */ - if (!strncmp (p, "s=", 2)) - { - if (sscanf (p, "s=%" MLFLENS "[^\r\n]", longfsdp_buf) < 1) - return FSDPE_EMPTY_NAME; - dsc->s_name = mp_strdup (longfsdp_buf); - } - else - { - return FSDPE_MISSING_NAME; - } - NEXT_LINE (p); - - /* `i=' line (session information) [optional] */ - /* i=<session description> */ - if (!strncmp (p, "i=", 2) - && sscanf (p, "i=%" MLFLENS "[^\r\n]", longfsdp_buf)) - { - dsc->i_information = mp_strdup (longfsdp_buf); - NEXT_LINE (p); - } - else - { - /* (optional) information absent */ - } - - /* `u=' line (URI of description) [optional] */ - /* u=<URI> */ - if (!strncmp (p, "u=", 2) - && sscanf (p, "u=%" MLFLENS "[^\r\n]", longfsdp_buf)) - { - /* TODO? check valid uri */ - dsc->u_uri = mp_strdup (longfsdp_buf); - NEXT_LINE (p); - } - else - { - /* (optional) uri absent */ - } - - /* `e=' lines (email address) [zero or more] */ - /* e=<email address> */ - p2 = p; - j = 0; - while (!strncmp (p2, "e=", 2)) - { - /* First, count how many emails are there */ - j++; - NEXT_LINE (p2); - } - dsc->emails_count = j; - if (dsc->emails_count > 0) - { - /* Then, build the array of emails */ - dsc->emails = mp_calloc (j, sizeof (const char *)); - for (j = 0; j < dsc->emails_count; j++) - { - sscanf (p, "e=%" MLFLENS "[^\r\n]", longfsdp_buf); - /* TODO? check valid email-address. */ - dsc->emails[j] = mp_strdup (longfsdp_buf); - NEXT_LINE (p); - } - } - - /* `p=' lines (phone number) [zero or more] */ - /* p=<phone number> */ - j = 0; - /* assert ( p2 == p ); */ - while (!strncmp (p2, "p=", 2)) - { - j++; - NEXT_LINE (p2); - } - dsc->phones_count = j; - if (dsc->phones_count > 0) - { - dsc->phones = mp_calloc (j, sizeof (const char *)); - for (j = 0; j < dsc->phones_count; j++) - { - sscanf (p, "p=%" MLFLENS "[^\r\n]", longfsdp_buf); - /* TODO? check valid phone-number. */ - dsc->phones[j] = mp_strdup (longfsdp_buf); - NEXT_LINE (p); - } - } - - /* `c=' line (connection information - not required if included in all media) [optional] */ - /* c=<network type> <address type> <connection address> */ - result = fsdp_parse_c (&p, &(dsc->c_network_type), &(dsc->c_address_type), - &(dsc->c_address)); - if (FSDPE_OK != result) - return result; - - /* `b=' lines (bandwidth information) [optional] */ - /* b=<modifier>:<bandwidth-value> */ - result = - fsdp_parse_b (&p, &(dsc->bw_modifiers), &(dsc->bw_modifiers_count)); - if (FSDPE_OK != result) - return result; - - /* A.1) Time descriptions: */ - - /* `t=' lines (time the session is active) [1 or more] */ - /* t=<start time> <stop time> */ - j = 0; - p2 = p; - while (!strncmp (p2, "t=", 2)) - { - j++; - NEXT_LINE (p2); - while (!strncmp (p2, "r=", 2)) - NEXT_LINE (p2); - } - dsc->time_periods_count = j; - if (dsc->time_periods_count == 0) - return FSDPE_MISSING_TIME; - dsc->time_periods = mp_calloc (dsc->time_periods_count, - sizeof (fsdp_time_period_t *)); - _index = 0; - for (j = 0; j < dsc->time_periods_count; j++) - { - unsigned int h = 0; - if (sscanf (p, "t=%10lu %10lu", &wuint[0], &wuint[1]) != 2) - { - /* not all periods have been successfully parsed */ - dsc->time_periods_count = j; - return FSDPE_INVALID_TIME; - } - dsc->time_periods[j] = mp_calloc (1, sizeof (fsdp_time_period_t)); - - /* convert from NTP to time_t time */ - if (wuint[0] != 0) - wuint[0] -= NTP_EPOCH_OFFSET; - if (wuint[1] != 0) - wuint[1] -= NTP_EPOCH_OFFSET; - dsc->time_periods[j]->start = wuint[0]; - dsc->time_periods[j]->stop = wuint[1]; - NEXT_LINE (p); - - /* `r' lines [zero or more repeat times for each t=] */ - /*r=<repeat interval> <active duration> <list of offsets from - start-time> */ - p2 = p; - while (!strncmp (p2, "r=", 2)) - { - h++; - NEXT_LINE (p2); - } - dsc->time_periods[j]->repeats_count = h; - if (h > 0) - { - unsigned int _index2 = 0; - dsc->time_periods[j]->repeats = - mp_calloc (h, sizeof (fsdp_repeat_t *)); - for (h = 0; h < dsc->time_periods[j]->repeats_count; h++) - { - /* - get_repeat_values(p,&(dsc->time_periods[_index].repeats[_index2])); - fsdp_error_t get_repeat_values (const char *r, fsdp_repeat_t - *repeat); - */ - if (sscanf (p, "r=%10s %10s %" MLFLENS "[^\r\n]", - fsdp_buf[0], fsdp_buf[1], longfsdp_buf) == 3) - { - fsdp_repeat_t *repeat; - dsc->time_periods[j]->repeats[h] = - mp_calloc (1, sizeof (fsdp_repeat_t)); - repeat = dsc->time_periods[j]->repeats[h]; - /* get interval, duration and list of offsets */ - result = - fsdp_repeat_time_to_uint (fsdp_buf[0], - &(repeat->interval)); - if (result == FSDPE_OK) - { - result = - fsdp_repeat_time_to_uint (fsdp_buf[1], - &(repeat->duration)); - if (result == FSDPE_OK) - { - unsigned int k = 1; - const char *i = longfsdp_buf; - while (NULL != (i = strchr (i, ' '))) - { - k++; - if (NULL != i) - i++; - } - repeat->offsets_count = k; - repeat->offsets = mp_calloc (k, sizeof (time_t)); - i = longfsdp_buf; - for (k = 0; - (k < repeat->offsets_count) - && (result == FSDPE_OK); k++) - { - result = - fsdp_repeat_time_to_uint (i, - &(repeat-> - offsets[k])); - i = strchr (i, ' '); - if (NULL != i) - i++; - } - if (k < repeat->offsets_count) - { - /* there where invalid repeat offsets */ - dsc->time_periods[j]->repeats_count = k; - return FSDPE_INVALID_REPEAT; - } - } - } - if (result != FSDPE_OK) - { - /* not all repeats have been succesfully parsed */ - dsc->time_periods[j]->repeats_count = h; - return FSDPE_INVALID_REPEAT; - } - NEXT_LINE (p); - } - else - { - /* not all repeats have been succesfully parsed */ - dsc->time_periods[j]->repeats_count = h; - return FSDPE_INVALID_REPEAT; - } - _index2++; - } - } - } - - /* `z=' line (time zone adjustments) [zero or more] */ - /* z=<adjustment time> <offset> <adjustment time> <offset> .... */ - if (!strncmp (p, "z=", 2)) - { - if (sscanf (p, "z=%" MLFLENS "[^\r\n]", longfsdp_buf)) - { - /* TODO: guess how many pairs are there and process them */ - dsc->timezone_adj = mp_strdup (longfsdp_buf); - NEXT_LINE (p); - } - else - { - return FSDPE_INVALID_TIMEZONE; - } - } - - /* `k=' line (encryption key) [optional] */ - /* k=<method> - k=<method>:<encryption key> */ - result = fsdp_parse_k (&p, &(dsc->k_encryption_method), - &(dsc->k_encryption_content)); - if (result != FSDPE_OK) - return result; - - /* A.2) Attributes */ - /* `a=' lines (session attribute) [0 or more] */ - /* a=<attribute> - a=<attribute>:<value> */ - while (!strncmp (p, "a=", 2)) - { - /* The "9" length specifier of the first string is subject to - changes */ - if (sscanf - (p, "a=%9[^:\r\n]:%" MSFLENS "[^\r\n]", fsdp_buf[0], - fsdp_buf[1]) == 2) - { - /* session-level value attributes */ - if (!strncmp (fsdp_buf[0], "cat", 3)) - dsc->a_category = mp_strdup (fsdp_buf[1]); - else if (!strncmp (fsdp_buf[0], "keywds", 6)) - dsc->a_keywords = mp_strdup (fsdp_buf[1]); - else if (!strncmp (fsdp_buf[0], "tool", 4)) - dsc->a_keywords = mp_strdup (fsdp_buf[1]); - else if (!strncmp (fsdp_buf[0], "rtpmap", 6)) - fsdp_parse_rtpmap (&(dsc->a_rtpmaps), - &(dsc->a_rtpmaps_count), fsdp_buf[1]); - else if (!strncmp (fsdp_buf[0], "type", 4)) - { - if (!strncmp (fsdp_buf[1], "broadcast", 9)) - dsc->a_type = FSDP_SESSION_TYPE_BROADCAST; - else if (!strncmp (fsdp_buf[1], "meeting", 7)) - dsc->a_type = FSDP_SESSION_TYPE_MEETING; - else if (!strncmp (fsdp_buf[1], "moderated", 9)) - dsc->a_type = FSDP_SESSION_TYPE_MODERATED; - else if (!strncmp (fsdp_buf[1], "test", 4)) - dsc->a_type = FSDP_SESSION_TYPE_TEST; - else if (!strncmp (fsdp_buf[1], "H332", 4)) - dsc->a_type = FSDP_SESSION_TYPE_H332; - else - return FSDPE_INVALID_SESSION_TYPE; - } - else if (!strncmp (fsdp_buf[0], "charset", 7)) - dsc->a_charset = mp_strdup (fsdp_buf[1]); - else if (!strncmp (fsdp_buf[0], "sdplang", 7)) - { - if (NULL == dsc->a_sdplangs) - { - dsc->a_sdplangs_count = 0; - dsc->a_sdplangs = - mp_calloc (SDPLANGS_MAX_COUNT, sizeof (char *)); - } - if (dsc->a_sdplangs_count < SDPLANGS_MAX_COUNT) - { - dsc->a_sdplangs[dsc->a_sdplangs_count] = - mp_strdup (fsdp_buf[1]); - dsc->a_sdplangs_count++; - } - } - else if (!strncmp (fsdp_buf[0], "lang", 4)) - { - if (NULL == dsc->a_langs) - { - dsc->a_langs_count = 0; - dsc->a_langs = mp_calloc (SDPLANGS_MAX_COUNT, sizeof (char *)); - } - if (dsc->a_langs_count < SDPLANGS_MAX_COUNT) - { - dsc->a_langs[dsc->a_langs_count] = mp_strdup (fsdp_buf[1]); - dsc->a_langs_count++; - } - } - else if (!strncmp (fsdp_buf[0], "control", 7)) - { - if (NULL == dsc->a_controls) - { - dsc->a_controls_count = 0; - dsc->a_controls = - mp_calloc (SDPCONTROLS_MAX_COUNT, sizeof (char *)); - } - if (dsc->a_controls_count < SDPCONTROLS_MAX_COUNT) - { - dsc->a_controls[dsc->a_controls_count] = - mp_strdup (fsdp_buf[1]); - dsc->a_controls_count++; - } - } - else if (!strncmp (fsdp_buf[0], "range", 5)) - { - if (dsc->a_range) - mp_free (dsc->a_range); - dsc->a_range = mp_strdup (fsdp_buf[1]); - } - else - { - /* ignore unknown attributes, but provide access to them */ - *longfsdp_buf = '\0'; - strncat (longfsdp_buf, fsdp_buf[0], MAXLONGFIELDLEN-1); - strncat (longfsdp_buf, ":", MAXLONGFIELDLEN-strlen(longfsdp_buf)-1); - strncat (longfsdp_buf, fsdp_buf[1], MAXLONGFIELDLEN-strlen(longfsdp_buf)-1); - if (NULL == dsc->unidentified_attributes) - { - dsc->unidentified_attributes_count = 0; - dsc->unidentified_attributes = - mp_calloc (UNIDENTIFIED_ATTRIBUTES_MAX_COUNT, - sizeof (char *)); - } - if (dsc->unidentified_attributes_count < - UNIDENTIFIED_ATTRIBUTES_MAX_COUNT) - { - dsc->unidentified_attributes - [dsc->unidentified_attributes_count] = - mp_strdup (longfsdp_buf); - dsc->unidentified_attributes_count++; - } - } - NEXT_LINE (p); - } - else if (sscanf (p, "a=%20s", fsdp_buf[0]) == 1) - { - /* session-level property attributes */ - if (!strncmp (fsdp_buf[0], "recvonly", 8)) - dsc->a_sendrecv_mode = FSDP_SENDRECV_RECVONLY; - else if (!strncmp (fsdp_buf[0], "sendonly", 8)) - dsc->a_sendrecv_mode = FSDP_SENDRECV_SENDONLY; - else if (!strncmp (fsdp_buf[0], "inactive", 8)) - dsc->a_sendrecv_mode = FSDP_SENDRECV_INACTIVE; - else if (!strncmp (fsdp_buf[0], "sendrecv", 8)) - dsc->a_sendrecv_mode = FSDP_SENDRECV_SENDRECV; - else - { - /* ignore unknown attributes, but provide access to them */ - *longfsdp_buf = '\0'; - strncat (longfsdp_buf, fsdp_buf[0], MAXLONGFIELDLEN-1); - if (NULL == dsc->unidentified_attributes) - { - dsc->unidentified_attributes_count = 0; - dsc->unidentified_attributes = - mp_calloc (UNIDENTIFIED_ATTRIBUTES_MAX_COUNT, - sizeof (char *)); - } - if (dsc->unidentified_attributes_count < - UNIDENTIFIED_ATTRIBUTES_MAX_COUNT) - { - dsc->unidentified_attributes - [dsc->unidentified_attributes_count] = - mp_strdup (longfsdp_buf); - dsc->unidentified_attributes_count++; - } - } - NEXT_LINE (p); - } - else - return FSDPE_INVALID_ATTRIBUTE; - } - - /***************************************************************************/ - /* B) parse media-level descriptions */ - /***************************************************************************/ - p2 = p; - j = 0; - while ((*p2 != '\0') && !strncmp (p2, "m=", 2)) - { - char c; - j++; - NEXT_LINE (p2); - while (sscanf (p2, "%c=", &c) == 1) - { - if (c == 'i' || c == 'c' || c == 'b' || c == 'k' || c == 'a') - { - NEXT_LINE (p2); - } - else if (c == 'm') - { - break; - } - else - { - return FSDPE_INVALID_LINE; - } - } - } - dsc->media_announcements_count = j; - if (dsc->media_announcements_count == 0) - { - ; - /*return FSDPE_MISSING_MEDIA; */ - } - else - { /* dsc->media_announcements_count > 0 */ - dsc->media_announcements = - mp_calloc (j, sizeof (fsdp_media_announcement_t *)); - for (j = 0; j < dsc->media_announcements_count; j++) - { - fsdp_media_announcement_t *media = NULL; - /* `m=' line (media name, transport address and format list) */ - /* m=<media> <port> <transport> <fmt list> */ - /* The max. string lengths are subject to change */ - if (sscanf (p, "m=%11s %8s %7s %" MLFLENS "[^\r\n]", - fsdp_buf[0], fsdp_buf[1], fsdp_buf[2], - longfsdp_buf) != 4) - { - return FSDPE_INVALID_MEDIA; - } - else - { - dsc->media_announcements[j] = - mp_calloc (1, sizeof (fsdp_media_announcement_t)); - media = dsc->media_announcements[j]; - if (!strncmp (fsdp_buf[0], "audio", 5)) - media->media_type = FSDP_MEDIA_AUDIO; - else if (!strncmp (fsdp_buf[0], "video", 5)) - media->media_type = FSDP_MEDIA_VIDEO; - else if (!strncmp (fsdp_buf[0], "application", 11)) - media->media_type = FSDP_MEDIA_APPLICATION; - else if (!strncmp (fsdp_buf[0], "data", 4)) - media->media_type = FSDP_MEDIA_DATA; - else if (!strncmp (fsdp_buf[0], "control", 7)) - media->media_type = FSDP_MEDIA_CONTROL; - else - return FSDPE_UNKNOWN_MEDIA_TYPE; - { /* try to get port specification as port/number */ - char *slash; - if ((slash = strchr (fsdp_buf[1], '/'))) - { - *slash = '\0'; - slash++; - media->port = strtol (fsdp_buf[1], NULL, 10); - media->port_count = strtol (slash, NULL, 10); - } - else - { - media->port = strtol (fsdp_buf[1], NULL, 10); - media->port_count = 0; - } - } - if (!strncmp (fsdp_buf[2], "RTP/AVP", 7)) - media->transport = FSDP_TP_RTP_AVP; - else if (!strncmp (fsdp_buf[2], "udp", 3)) - media->transport = FSDP_TP_UDP; - else if (!strncmp (fsdp_buf[2], "TCP", 3)) - media->transport = FSDP_TP_TCP; - else if (!strncmp (fsdp_buf[2], "UDPTL", 5)) - media->transport = FSDP_TP_UDPTL; - else if (!strncmp (fsdp_buf[2], "vat", 3)) - media->transport = FSDP_TP_VAT; - else if (!strncmp (fsdp_buf[2], "rtp", 3)) - media->transport = FSDP_TP_OLD_RTP; - else - return FSDPE_UNKNOWN_MEDIA_TRANSPORT; - { - unsigned int k = 0; - char *s = longfsdp_buf; - while (NULL != (s = strchr (s, ' '))) - { - k++; - if (NULL != s) - s++; - } - k++; /* when there is no space left, count the last format */ - media->formats_count = k; - media->formats = mp_calloc (k, sizeof (char *)); - s = longfsdp_buf; - for (k = 0; k < media->formats_count; k++) - { - char *space = strchr (s, ' '); - if (NULL != space) - *space = '\0'; - media->formats[k] = mp_strdup (s); - s = space + 1; - } - } - NEXT_LINE (p); - } - - /* `i=' line (media title) [optional] */ - /* i=<media title> */ - if (!strncmp (p, "i=", 2) - && sscanf (p, "i=%" MLFLENS "[^\r\n]", longfsdp_buf)) - { - media->i_title = mp_strdup (longfsdp_buf); - NEXT_LINE (p); - } - else - { - /* (optional) information absent */ - } - - /* `c=' line (connection information - overrides session-level - line) [optional if provided at session-level] */ - /* c=<network type> <address type> <connection address> */ - result = fsdp_parse_c (&p, &(media->c_network_type), - &(media->c_address_type), - &(media->c_address)); - if (result != FSDPE_OK) - return result; - - /* `b=' lines (bandwidth information) [optional] */ - /* b=<modifier>:<bandwidth-value> */ - result = fsdp_parse_b (&p, &(media->bw_modifiers), - &(media->bw_modifiers_count)); - if (FSDPE_OK != result) - return result; - - /* `k=' line (encryption key) [optional] */ - /* k=<method> - k=<method>:<encryption key> */ - result = fsdp_parse_k (&p, &(media->k_encryption_method), - &(media->k_encryption_content)); - if (result != FSDPE_OK) - return result; - - /* B.1) Attributes */ - - /* `a=' lines (zero or more media attribute lines) [optional] */ - /* a=<attribute> - a=<attribute>:<value> */ - while (!strncmp (p, "a=", 2)) - { - if (sscanf - (p, "a=%9[^:\r\n]:%" MLFLENS "[^\r\n]", fsdp_buf[0], - longfsdp_buf) == 2) - { - /* media-level value attributes */ - if (!strncmp (fsdp_buf[0], "ptime", 5)) - media->a_ptime = strtoul (longfsdp_buf, NULL, 10); - else if (!strncmp (fsdp_buf[0], "maxptime", 8)) - media->a_maxptime = strtoul (longfsdp_buf, NULL, 10); - else if (!strncmp (fsdp_buf[0], "rtpmap", 6)) - fsdp_parse_rtpmap (&(media->a_rtpmaps), - &(media->a_rtpmaps_count), - longfsdp_buf); - else if (!strncmp (fsdp_buf[0], "orient", 6)) - { - if (!strncmp (longfsdp_buf, "portrait", 8)) - media->a_orient = FSDP_ORIENT_PORTRAIT; - else if (!strncmp (longfsdp_buf, "landscape", 9)) - media->a_orient = FSDP_ORIENT_LANDSCAPE; - else if (!strncmp (longfsdp_buf, "seascape", 9)) - media->a_orient = FSDP_ORIENT_SEASCAPE; - } - else if (!strncmp (fsdp_buf[0], "sdplang", 7)) - { - if (NULL == dsc->a_sdplangs) - { - media->a_sdplangs_count = 0; - media->a_sdplangs = - mp_calloc (SDPLANGS_MAX_COUNT, sizeof (char *)); - } - if (media->a_sdplangs_count < SDPLANGS_MAX_COUNT) - { - media->a_sdplangs[dsc->a_sdplangs_count] = - mp_strdup (longfsdp_buf); - media->a_sdplangs_count++; - } - } - else if (!strncmp (fsdp_buf[0], "lang", 4)) - { - if (NULL == dsc->a_langs) - { - media->a_langs_count = 0; - media->a_langs = - mp_calloc (SDPLANGS_MAX_COUNT, sizeof (char *)); - } - if (media->a_langs_count < SDPLANGS_MAX_COUNT) - { - media->a_langs[dsc->a_langs_count] = - mp_strdup (longfsdp_buf); - media->a_langs_count++; - } - } - else if (!strncmp (fsdp_buf[0], "control", 7)) - { - if (NULL == media->a_controls) - { - media->a_controls_count = 0; - media->a_controls = - mp_calloc (SDPCONTROLS_MAX_COUNT, sizeof (char *)); - } - if (media->a_controls_count < SDPCONTROLS_MAX_COUNT) - { - media->a_controls[media->a_controls_count] = - mp_strdup (longfsdp_buf); - media->a_controls_count++; - } - } - else if (!strncmp (fsdp_buf[0], "range", 5)) - { - if (media->a_range) - mp_free (media->a_range); - media->a_range = mp_strdup (fsdp_buf[1]); - } - else if (!strncmp (fsdp_buf[0], "framerate", 9)) - media->a_framerate = strtod (longfsdp_buf, NULL); - else if (!strncmp (fsdp_buf[0], "fmtp", 4)) - { - if (NULL == media->a_fmtps) - { - media->a_fmtps_count = 0; - media->a_fmtps = - mp_calloc (SDPLANGS_MAX_COUNT, sizeof (char *)); - } - if (media->a_fmtps_count < SDPLANGS_MAX_COUNT) - { - media->a_fmtps[media->a_fmtps_count] = - mp_strdup (longfsdp_buf); - media->a_fmtps_count++; - } - } - else if (!strncmp (fsdp_buf[0], "rtcp", 4)) - { - int opts = 0; - /* rtcp attribute: a=rtcp:<port> <nettype> <addrtype> <address> */ - opts = - sscanf (longfsdp_buf, "%lu %2s %3s %" MSFLENS "s", - &wuint[0], fsdp_buf[0], fsdp_buf[1], - fsdp_buf[2]); - if (opts >= 1) - { - media->a_rtcp_port = wuint[0]; - if (opts >= 2) - { - if (!strncmp (fsdp_buf[0], "IN", 2)) - { - media->a_rtcp_network_type = - FSDP_NETWORK_TYPE_INET; - } /* else - ; TODO: define error code? */ - if (opts >= 3) - { - if (!strncmp (fsdp_buf[1], "IP4", 3)) - media->a_rtcp_address_type = - FSDP_ADDRESS_TYPE_IPV4; - else if (!strncmp (fsdp_buf[1], "IP6", 3)) - media->a_rtcp_address_type = - FSDP_ADDRESS_TYPE_IPV6; - else - return FSDPE_INVALID_CONNECTION_NETTYPE; - /*add specific code? */ - if (opts >= 4) - media->a_rtcp_address = - mp_strdup (fsdp_buf[2]); - } - } - } - } - else - { - /* ignore unknown attributes, but provide access to them */ - *fsdp_buf[1] = '\0'; - strncat (fsdp_buf[1], fsdp_buf[0], MAXSHORTFIELDLEN-1); - strncat (fsdp_buf[1], ":", MAXSHORTFIELDLEN-strlen(fsdp_buf[1])-1); - strncat (fsdp_buf[1], longfsdp_buf, MAXSHORTFIELDLEN-strlen(fsdp_buf[1])-1); - if (NULL == media->unidentified_attributes) - { - media->unidentified_attributes_count = 0; - media->unidentified_attributes = - mp_calloc (UNIDENTIFIED_ATTRIBUTES_MAX_COUNT, - sizeof (char *)); - } - if (media->unidentified_attributes_count < - UNIDENTIFIED_ATTRIBUTES_MAX_COUNT) - { - media->unidentified_attributes - [media->unidentified_attributes_count] = - mp_strdup (fsdp_buf[1]); - media->unidentified_attributes_count++; - } - } - NEXT_LINE (p); - } - else if (sscanf (p, "a=%8s", fsdp_buf[0]) == 1) - { - /* media-level property attributes */ - if (!strncmp (fsdp_buf[0], "recvonly", 8)) - media->a_sendrecv_mode = FSDP_SENDRECV_RECVONLY; - else if (!strncmp (fsdp_buf[0], "sendonly", 8)) - media->a_sendrecv_mode = FSDP_SENDRECV_SENDONLY; - else if (!strncmp (fsdp_buf[0], "inactive", 8)) - media->a_sendrecv_mode = FSDP_SENDRECV_INACTIVE; - else if (!strncmp (fsdp_buf[0], "sendrecv", 8)) - media->a_sendrecv_mode = FSDP_SENDRECV_SENDRECV; - else - { - /* ignore unknown attributes, but provide access to them */ - *longfsdp_buf = '\0'; - strncat (longfsdp_buf, fsdp_buf[0], MAXLONGFIELDLEN-1); - if (NULL == media->unidentified_attributes) - { - media->unidentified_attributes_count = 0; - media->unidentified_attributes = - mp_calloc (UNIDENTIFIED_ATTRIBUTES_MAX_COUNT, - sizeof (char *)); - } - if (media->unidentified_attributes_count < - UNIDENTIFIED_ATTRIBUTES_MAX_COUNT) - { - media->unidentified_attributes - [media->unidentified_attributes_count] = - mp_strdup (longfsdp_buf); - media->unidentified_attributes_count++; - } - } - NEXT_LINE (p); - } - else - return FSDPE_INVALID_ATTRIBUTE; - } - } /* end of for */ - } - - /* Check c= has been given at session level or at media level for - all media */ - if (NULL == dsc->c_address.address) - { - unsigned int c; - for (c = 0; c < dsc->media_announcements_count; c++) - if (NULL == dsc->media_announcements[c]->c_address.address) - return FSDPE_MISSING_CONNECTION_INFO; - } - - /* finish */ - if (*p == '\0') - return FSDPE_OK; - else - return FSDPE_OVERFILLED; -} - -static fsdp_error_t -fsdp_parse_c (const char **p, fsdp_network_type_t * ntype, - fsdp_address_type_t * atype, - fsdp_connection_address_t * address) -{ - const unsigned int TEMPCHARS = 3; - char fsdp_buf[TEMPCHARS][MAXSHORTFIELDLEN]; - - if (!strncmp (*p, "c=", 2)) - { - if (sscanf (*p, "c=%2s %3s %" MSFLENS "s", - fsdp_buf[0], fsdp_buf[1], fsdp_buf[2])) - { - if (!strncmp (fsdp_buf[0], "IN", 2)) - { - *ntype = FSDP_NETWORK_TYPE_INET; - if (!strncmp (fsdp_buf[1], "IP4", 3)) - *atype = FSDP_ADDRESS_TYPE_IPV4; - else if (!strncmp (fsdp_buf[1], "IP6", 3)) - *atype = FSDP_ADDRESS_TYPE_IPV6; - else - return FSDPE_INVALID_CONNECTION_NETTYPE; - } - else - { - return FSDPE_INVALID_CONNECTION_ADDRTYPE; - } - { - char *slash = strchr (fsdp_buf[2], '/'); - if (NULL == slash) - { - address->address = mp_strdup (fsdp_buf[2]); - address->address_ttl = 0; - address->address_count = 0; - } - else - { - /* address is IP4 multicast */ - char *slash2; - *slash = '\0'; - slash++; - address->address = mp_strdup (fsdp_buf[2]); - slash2 = strchr (slash + 1, '/'); - if (NULL == slash2) - { - address->address_ttl = strtol (slash, NULL, 10); - address->address_count = 0; - } - else - { - *slash2 = '\0'; - slash2++; - address->address_ttl = strtol (slash, NULL, 10); - address->address_count = strtol (slash2, NULL, 10); - } - } - } - NEXT_LINE (*p); - } - else - { - return FSDPE_INVALID_CONNECTION; - } - } - return FSDPE_OK; -} - -static fsdp_error_t -fsdp_parse_b (const char **p, fsdp_bw_modifier_t ** bw_modifiers, - unsigned int *bw_modifiers_count) -{ - char fsdp_buf[MAXSHORTFIELDLEN]; - unsigned long int wuint; - unsigned int i = 0; - const char *lp = *p; - - /* count b= lines */ - while (!strncmp (lp, "b=", 2)) - { - NEXT_LINE (lp); - i++; - } - *bw_modifiers = mp_calloc (i, sizeof (fsdp_bw_modifier_t)); - *bw_modifiers_count = i; - - while (i > 0) - { - unsigned int _index = *bw_modifiers_count - i; - if (2 == sscanf (*p, "b=%20[^:\r\n]:%lu", fsdp_buf, &wuint)) - { - if (!strncmp (fsdp_buf, "CT", 2)) - (*bw_modifiers)[_index].b_mod_type = - FSDP_BW_MOD_TYPE_CONFERENCE_TOTAL; - else if (!strncmp (fsdp_buf, "AS", 2)) - (*bw_modifiers)[_index].b_mod_type = - FSDP_BW_MOD_TYPE_APPLICATION_SPECIFIC; - else if (!strncmp (fsdp_buf, "RS", 2)) - (*bw_modifiers)[_index].b_mod_type = FSDP_BW_MOD_TYPE_RTCP_SENDERS; - else if (!strncmp (fsdp_buf, "RR", 2)) - (*bw_modifiers)[_index].b_mod_type = - FSDP_BW_MOD_TYPE_RTCP_RECEIVERS; - else - { - (*bw_modifiers)[_index].b_mod_type = FSDP_BW_MOD_TYPE_UNKNOWN; - (*bw_modifiers)[_index].b_unknown_bw_modt = - (char *) mp_strdup (fsdp_buf); - } - (*bw_modifiers)[_index].b_value = wuint; - NEXT_LINE (*p); - } - else - { - *bw_modifiers_count -= i; - return FSDPE_INVALID_BANDWIDTH; - } - i--; - } - return FSDPE_OK; -} - -static fsdp_error_t -fsdp_parse_k (const char **p, fsdp_encryption_method_t * method, - char **content) -{ - char fsdp_buf[MAXSHORTFIELDLEN]; - char longfsdp_buf[MAXLONGFIELDLEN]; - - if (!strncmp (*p, "k=", 2)) - { - if (sscanf (*p, "k=prompt")) - { - *method = FSDP_ENCRYPTION_METHOD_PROMPT; - *content = NULL; - NEXT_LINE (*p); - } - else - { - if (sscanf - (*p, "k=%6[^:\r\n]:%" MLFLENS "s", fsdp_buf, longfsdp_buf)) - { - if (!strncmp (fsdp_buf, "clear", 5)) - *method = FSDP_ENCRYPTION_METHOD_CLEAR; - else if (!strncmp (fsdp_buf, "base64", 6)) - *method = FSDP_ENCRYPTION_METHOD_BASE64; - else if (!strncmp (fsdp_buf, "uri", 3)) - *method = FSDP_ENCRYPTION_METHOD_URI; - else - return FSDPE_INVALID_ENCRYPTION_METHOD; - *content = mp_strdup (longfsdp_buf); - NEXT_LINE (*p); - } - } - } - return FSDPE_OK; -} - -static fsdp_error_t -fsdp_parse_rtpmap (fsdp_rtpmap_t *** rtpmap, unsigned int *counter, - const char *value) -{ - fsdp_error_t result = FSDPE_OK; - - if (0 == *counter) - { - *counter = 0; - *rtpmap = mp_calloc (MEDIA_RTPMAPS_MAX_COUNT, sizeof (fsdp_rtpmap_t *)); - } - if (*counter < MEDIA_RTPMAPS_MAX_COUNT) - { - unsigned int c = *counter; - fsdp_rtpmap_t **map = *rtpmap; - char fsdp_buf[MAXSHORTFIELDLEN]; - char longfsdp_buf[MAXLONGFIELDLEN]; - map[c] = mp_calloc (1, sizeof (fsdp_rtpmap_t)); - - /* a=rtpmap:<payload type> <encoding name>/<clock rate>[/<encoding - parameters]> */ - if (2 == sscanf (value, "%s %s", fsdp_buf, longfsdp_buf)) - { - char *slash1; - map[c]->pt = mp_strdup (fsdp_buf); - /* parse <encoding name>/<clock rate>[/<encoding parameters>] */ - slash1 = strchr (longfsdp_buf, '/'); - if (NULL == slash1) - { - result = FSDPE_INVALID_ATTRIBUTE_RTPMAP; - } - else - { - char *slash2; - *slash1 = '\0'; - slash1++; - map[c]->encoding_name = mp_strdup (longfsdp_buf); - slash2 = strchr (slash1, '/'); - if (NULL != slash2) - { - *slash2 = '\0'; - slash2++; - map[c]->parameters = mp_strdup (slash2); - } - map[c]->clock_rate = strtol (slash1, NULL, 10); - } - (*counter)++; - } - } - return result; -} - -static fsdp_error_t -fsdp_repeat_time_to_uint (const char *_time, unsigned long int *seconds) -{ - const unsigned long SECONDS_PER_DAY = 86400; - const unsigned long SECONDS_PER_HOUR = 3600; - const unsigned long SECONDS_PER_MINUTE = 60; - char c; - unsigned long int wuint; - - if (sscanf (_time, "%lu%c", &wuint, &c) == 2) - { - /* time with unit specification character */ - switch (c) - { - case 'd': - *seconds = wuint * SECONDS_PER_DAY; - break; - case 'h': - *seconds = wuint * SECONDS_PER_HOUR; - break; - case 'm': - *seconds = wuint * SECONDS_PER_MINUTE; - break; - case 's': - *seconds = wuint; - break; - default: - return FSDPE_INVALID_REPEAT; - break; - } - } - else if (sscanf (_time, "%lu", &wuint) == 1) - { - /* time without unit specification character */ - *seconds = wuint; - } - else - { - return FSDPE_INVALID_REPEAT; - } - return FSDPE_OK; -} - -unsigned int -fsdp_get_version (const fsdp_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->version; -} - -const char * -fsdp_get_owner_username (const fsdp_description_t * dsc) -{ - if (!dsc) - return NULL; - return dsc->o_username; -} - -const char * -fsdp_get_session_id (const fsdp_description_t * dsc) -{ - if (!dsc) - return NULL; - return dsc->o_session_id; -} - -const char * -fsdp_get_announcement_version (const fsdp_description_t * dsc) -{ - if (!dsc) - return NULL; - return dsc->o_announcement_version; -} - -fsdp_network_type_t -fsdp_get_owner_network_type (const fsdp_description_t * dsc) -{ - if (!dsc) - return FSDP_NETWORK_TYPE_UNDEFINED; - return dsc->o_network_type; -} - -fsdp_address_type_t -fsdp_get_owner_address_type (const fsdp_description_t * dsc) -{ - if (!dsc) - return FSDP_ADDRESS_TYPE_UNDEFINED; - return dsc->o_address_type; -} - -const char * -fsdp_get_owner_address (const fsdp_description_t * dsc) -{ - if (!dsc) - return NULL; - return dsc->o_address; -} - -const char * -fsdp_get_name (const fsdp_description_t * dsc) -{ - if (!dsc) - return NULL; - return dsc->s_name; -} - -const char * -fsdp_get_information (const fsdp_description_t * dsc) -{ - if (!dsc) - return NULL; - return dsc->i_information; -} - -const char * -fsdp_get_uri (const fsdp_description_t * dsc) -{ - if (!dsc) - return NULL; - return dsc->u_uri; -} - -unsigned int -fsdp_get_emails_count (const fsdp_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->emails_count; -} - -const char * -fsdp_get_email (const fsdp_description_t * dsc, unsigned int _index) -{ - if ((!dsc) || (_index >= dsc->emails_count)) - return NULL; - return dsc->emails[_index]; -} - -unsigned int -fsdp_get_phones_count (const fsdp_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->phones_count; -} - -const char * -fsdp_get_phone (const fsdp_description_t * dsc, unsigned int _index) -{ - if ((!dsc) || (_index >= dsc->phones_count)) - return NULL; - return dsc->phones[_index]; -} - -fsdp_network_type_t -fsdp_get_global_conn_network_type (const fsdp_description_t * dsc) -{ - if (!dsc) - return FSDP_NETWORK_TYPE_UNDEFINED; - return dsc->c_network_type; -} - -fsdp_address_type_t -fsdp_get_global_conn_address_type (const fsdp_description_t * dsc) -{ - if (!dsc) - return FSDP_ADDRESS_TYPE_UNDEFINED; - return dsc->c_address_type; -} - -const char * -fsdp_get_global_conn_address (const fsdp_description_t * dsc) -{ - if (!dsc) - return NULL; - return dsc->c_address.address; -} - -unsigned int -fsdp_get_global_conn_address_ttl (const fsdp_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->c_address.address_ttl; -} - -unsigned int -fsdp_get_global_conn_address_count (const fsdp_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->c_address.address_count; -} - -unsigned int -fsdp_get_bw_modifier_count (const fsdp_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->bw_modifiers_count; -} - -fsdp_bw_modifier_type_t -fsdp_get_bw_modifier_type (const fsdp_description_t * dsc, unsigned int _index) -{ - if ((!dsc) || (_index >= dsc->bw_modifiers_count)) - return FSDP_BW_MOD_TYPE_UNDEFINED; - return dsc->bw_modifiers[_index].b_mod_type; -} - -const char * -fsdp_get_bw_modifier_type_unknown (const fsdp_description_t * dsc, - unsigned int _index) -{ - if ((!dsc) || (_index >= dsc->bw_modifiers_count) || - (dsc->bw_modifiers[_index].b_mod_type != FSDP_BW_MOD_TYPE_UNKNOWN)) - return NULL; - return dsc->bw_modifiers[_index].b_unknown_bw_modt; -} - -unsigned long int -fsdp_get_bw_value (const fsdp_description_t * dsc, unsigned int _index) -{ - if ((!dsc) || (_index >= dsc->bw_modifiers_count)) - return 0; - return dsc->bw_modifiers[_index].b_value; -} - -time_t -fsdp_get_period_start (const fsdp_description_t * dsc, unsigned int _index) -{ - if ((!dsc) || (_index >= dsc->time_periods_count)) - return 0; - return dsc->time_periods[_index]->start; -} - -time_t -fsdp_get_period_stop (const fsdp_description_t * dsc, unsigned int _index) -{ - if ((!dsc) || (_index >= dsc->time_periods_count)) - return 0; - return dsc->time_periods[_index]->stop; -} - -unsigned int -fsdp_get_period_repeats_count (const fsdp_description_t * dsc, - unsigned int _index) -{ - if ((!dsc) || (_index >= dsc->time_periods_count)) - return 0; - return dsc->time_periods[_index]->repeats_count; -} - -unsigned long int -fsdp_get_period_repeat_interval (const fsdp_description_t * dsc, - unsigned int _index, unsigned int r_index) -{ - if ((!dsc) || (_index >= dsc->time_periods_count)) - return 0; - return dsc->time_periods[_index]->repeats[r_index]->interval; -} - -unsigned long int -fsdp_get_period_repeat_duration (const fsdp_description_t * dsc, - unsigned int _index, unsigned int r_index) -{ - if ((!dsc) || (_index >= dsc->time_periods_count)) - return 0; - return dsc->time_periods[_index]->repeats[r_index]->duration; -} - -const unsigned long int * -fsdp_get_period_repeat_offsets (const fsdp_description_t * dsc, - unsigned int _index, unsigned int r_index) -{ - if ((!dsc) || (_index >= dsc->time_periods_count)) - return NULL; - return dsc->time_periods[_index]->repeats[r_index]->offsets; -} - -const char * -fsdp_get_timezone_adj (const fsdp_description_t * dsc) -{ - if (!dsc) - return NULL; - return dsc->timezone_adj; -} - -unsigned int -fsdp_get_unidentified_attribute_count (const fsdp_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->unidentified_attributes_count; -} - -const char * -fsdp_get_unidentified_attribute (const fsdp_description_t * dsc, - unsigned int _index) -{ - if (!dsc || (_index < dsc->unidentified_attributes_count)) - return NULL; - return dsc->unidentified_attributes[_index]; -} - -fsdp_encryption_method_t -fsdp_get_encryption_method (const fsdp_description_t * dsc) -{ - if (!dsc) - return FSDP_ENCRYPTION_METHOD_UNDEFINED; - return dsc->k_encryption_method; -} - -const char * -fsdp_get_encryption_content (const fsdp_description_t * dsc) -{ - if (!dsc || (dsc->k_encryption_method == FSDP_ENCRYPTION_METHOD_UNDEFINED)) - return NULL; - return dsc->k_encryption_content; -} - -unsigned int -fsdp_get_rtpmap_count (const fsdp_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->a_rtpmaps_count; -} - -const char * -fsdp_get_rtpmap_payload_type (const fsdp_description_t * dsc, - unsigned int _index) -{ - if ((!dsc) || (_index >= dsc->a_rtpmaps_count)) - return NULL; - return dsc->a_rtpmaps[_index]->pt; -} - -const char * -fsdp_get_rtpmap_encoding_name (const fsdp_description_t * dsc, - unsigned int _index) -{ - if ((!dsc) || (_index >= dsc->a_rtpmaps_count)) - return NULL; - return dsc->a_rtpmaps[_index]->encoding_name; -} - -unsigned int -fsdp_get_rtpmap_clock_rate (const fsdp_description_t * dsc, - unsigned int _index) -{ - if ((!dsc) || (_index >= dsc->a_rtpmaps_count)) - return 0; - return dsc->a_rtpmaps[_index]->clock_rate; -} - -const char * -fsdp_get_rtpmap_encoding_parameters (const fsdp_description_t * dsc, - unsigned int _index) -{ - if ((!dsc) || (_index >= dsc->a_rtpmaps_count)) - return NULL; - return dsc->a_rtpmaps[_index]->parameters; -} - -const char * -fsdp_get_str_att (const fsdp_description_t * dsc, fsdp_session_str_att_t att) -{ - /*TODO: change these individual attributes with a table, thus - avoiding this slow switch */ - char *result; - - if (!dsc) - return NULL; - - switch (att) - { - case FSDP_SESSION_STR_ATT_CATEGORY: - result = dsc->a_category; - break; - case FSDP_SESSION_STR_ATT_KEYWORDS: - result = dsc->a_keywords; - break; - case FSDP_SESSION_STR_ATT_TOOL: - result = dsc->a_tool; - break; - case FSDP_SESSION_STR_ATT_CHARSET: - result = dsc->a_charset; - break; - default: - result = NULL; - } - return result; -} - -unsigned int -fsdp_get_sdplang_count (const fsdp_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->a_sdplangs_count; -} - -const char * -fsdp_get_sdplang (const fsdp_description_t * dsc, unsigned int _index) -{ - if ((!dsc) || (_index >= dsc->a_sdplangs_count)) - return NULL; - return dsc->a_sdplangs[_index]; -} - -unsigned int -fsdp_get_lang_count (const fsdp_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->a_langs_count; -} - -const char * -fsdp_get_lang (const fsdp_description_t * dsc, unsigned int _index) -{ - if ((!dsc) || (_index >= dsc->a_langs_count)) - return NULL; - return dsc->a_langs[_index]; -} - -unsigned int -fsdp_get_control_count (const fsdp_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->a_controls_count; -} - -const char * -fsdp_get_control (const fsdp_description_t * dsc, unsigned int _index) -{ - if ((!dsc) || (_index >= dsc->a_controls_count)) - return NULL; - return dsc->a_controls[_index]; -} - -const char * -fsdp_get_range (const fsdp_description_t * dsc) -{ - return dsc->a_range; -} - -fsdp_sendrecv_mode_t -fsdp_get_sendrecv_mode (const fsdp_description_t * dsc) -{ - if (!dsc) - return FSDP_SENDRECV_UNDEFINED; - return dsc->a_sendrecv_mode; -} - -fsdp_session_type_t -fsdp_get_session_type (const fsdp_description_t * dsc) -{ - if (!dsc) - return FSDP_SESSION_TYPE_UNDEFINED; - return dsc->a_type; -} - -unsigned int -fsdp_get_media_count (const fsdp_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->media_announcements_count; -} - -const fsdp_media_description_t * -fsdp_get_media (const fsdp_description_t * dsc, unsigned int _index) -{ - if ((_index >= dsc->media_announcements_count)) - return NULL; - return dsc->media_announcements[_index]; -} - -fsdp_media_t -fsdp_get_media_type (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return FSDP_MEDIA_UNDEFINED; - return dsc->media_type; -} - -unsigned int -fsdp_get_media_port (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->port; -} - -unsigned int -fsdp_get_media_port_count (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->port_count; -} - -fsdp_transport_protocol_t -fsdp_get_media_transport_protocol (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return FSDP_TP_UNDEFINED; - return dsc->transport; -} - -unsigned int -fsdp_get_media_formats_count (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->formats_count; -} - -const char * -fsdp_get_media_format (const fsdp_media_description_t * dsc, - unsigned int _index) -{ - if (!dsc && (_index < dsc->formats_count)) - return NULL; - return dsc->formats[_index]; -} - -const char * -fsdp_get_media_title (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return NULL; - return dsc->i_title; -} - -fsdp_network_type_t -fsdp_get_media_network_type (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return FSDP_NETWORK_TYPE_UNDEFINED; - return dsc->c_network_type; -} - -fsdp_address_type_t -fsdp_get_media_address_type (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return FSDP_ADDRESS_TYPE_UNDEFINED; - return dsc->c_address_type; -} - -const char * -fsdp_get_media_address (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return NULL; - return dsc->c_address.address; -} - -unsigned int -fsdp_get_media_address_ttl (const fsdp_media_description_t * mdsc) -{ - if (!mdsc) - return 0; - return mdsc->c_address.address_ttl; -} - -unsigned int -fsdp_get_media_address_count (const fsdp_media_description_t * mdsc) -{ - if (!mdsc) - return 0; - return mdsc->c_address.address_count; -} - -fsdp_bw_modifier_type_t -fsdp_get_media_bw_modifier_type (const fsdp_media_description_t * dsc, - unsigned int _index) -{ - if (!dsc || (_index >= dsc->bw_modifiers_count)) - return FSDP_BW_MOD_TYPE_UNDEFINED; - return dsc->bw_modifiers[_index].b_mod_type; -} - -const char * -fsdp_get_media_bw_modifier_type_unknown (const fsdp_media_description_t * dsc, - unsigned int _index) -{ - if (!dsc || (_index >= dsc->bw_modifiers_count) || - (FSDP_BW_MOD_TYPE_UNKNOWN != dsc->bw_modifiers[_index].b_mod_type)) - return NULL; - return dsc->bw_modifiers[_index].b_unknown_bw_modt; -} - -unsigned long int -fsdp_get_media_bw_value (const fsdp_media_description_t * dsc, - unsigned int _index) -{ - if (!dsc || (_index >= dsc->bw_modifiers_count)) - return 0; - return dsc->bw_modifiers[_index].b_value; -} - -fsdp_encryption_method_t -fsdp_get_media_encryption_method (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return FSDP_ENCRYPTION_METHOD_UNDEFINED; - return dsc->k_encryption_method; -} - -const char * -fsdp_get_media_encryption_content (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return NULL; - return dsc->k_encryption_content; -} - -unsigned int -fsdp_get_media_ptime (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->a_ptime; -} - -unsigned int -fsdp_get_media_maxptime (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->a_maxptime; -} - -unsigned int -fsdp_get_media_rtpmap_count (const fsdp_media_description_t * mdsc) -{ - if (!mdsc) - return 0; - return mdsc->a_rtpmaps_count; -} - -const char * -fsdp_get_media_rtpmap_payload_type (const fsdp_media_description_t * mdsc, - unsigned int _index) -{ - if (!mdsc || (_index >= mdsc->a_rtpmaps_count)) - return NULL; - return mdsc->a_rtpmaps[_index]->pt; -} - -const char * -fsdp_get_media_rtpmap_encoding_name (const fsdp_media_description_t * mdsc, - unsigned int _index) -{ - if (!mdsc || (_index >= mdsc->a_rtpmaps_count)) - return NULL; - return mdsc->a_rtpmaps[_index]->encoding_name; -} - -unsigned int -fsdp_get_media_rtpmap_clock_rate (const fsdp_media_description_t * mdsc, - unsigned int _index) -{ - if (!mdsc || (_index >= mdsc->a_rtpmaps_count)) - return 0; - return mdsc->a_rtpmaps[_index]->clock_rate; -} - -const char * -fsdp_get_media_rtpmap_encoding_parameters (const fsdp_description_t * mdsc, - unsigned int _index) -{ - if (!mdsc || (_index >= mdsc->a_rtpmaps_count)) - return NULL; - return mdsc->a_rtpmaps[_index]->parameters; -} - -unsigned int -fsdp_get_media_sdplang_count (const fsdp_media_description_t * mdsc) -{ - if (!mdsc) - return 0; - return mdsc->a_sdplangs_count; -} - -const char * -fsdp_get_media_sdplang (const fsdp_media_description_t * mdsc, - unsigned int _index) -{ - if (!mdsc || (_index >= mdsc->a_sdplangs_count)) - return NULL; - return mdsc->a_sdplangs[_index]; -} - -unsigned int -fsdp_get_media_lang_count (const fsdp_media_description_t * mdsc) -{ - if (!mdsc) - return 0; - return mdsc->a_langs_count; -} - -const char * -fsdp_get_media_lang (const fsdp_media_description_t * mdsc, - unsigned int _index) -{ - if (!mdsc || (_index >= mdsc->a_langs_count)) - return NULL; - return mdsc->a_langs[_index]; -} - -unsigned int -fsdp_get_media_control_count (const fsdp_media_description_t * mdsc) -{ - if (!mdsc) - return 0; - return mdsc->a_controls_count; -} - -char * -fsdp_get_media_control (const fsdp_media_description_t * mdsc, - unsigned int _index) -{ - if (!mdsc || (_index >= mdsc->a_controls_count)) - return NULL; - return mdsc->a_controls[_index]; -} - -char * -fsdp_get_media_range (const fsdp_media_description_t * mdsc) -{ - return mdsc->a_range; -} - -unsigned int -fsdp_get_media_fmtp_count (const fsdp_media_description_t * mdsc) -{ - if (!mdsc) - return 0; - return mdsc->a_fmtps_count; -} - -const char * -fsdp_get_media_fmtp (const fsdp_media_description_t * mdsc, - unsigned int _index) -{ - if (!mdsc || (_index >= mdsc->a_fmtps_count)) - return NULL; - return mdsc->a_fmtps[_index]; -} - -fsdp_orient_t -fsdp_get_media_orient (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return FSDP_ORIENT_UNDEFINED; - return dsc->a_orient; -} - -fsdp_sendrecv_mode_t -fsdp_get_media_sendrecv (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return FSDP_SENDRECV_UNDEFINED; - return dsc->a_sendrecv_mode; -} - -float -fsdp_get_media_framerate (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->a_framerate; -} - -unsigned int -fsdp_get_media_quality (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->a_quality; -} - -unsigned int -fsdp_get_media_rtcp_port (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return 0; - return dsc->a_rtcp_port; -} - -fsdp_network_type_t -fsdp_get_media_rtcp_network_type (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return FSDP_NETWORK_TYPE_UNDEFINED; - return dsc->a_rtcp_network_type; -} - -fsdp_address_type_t -fsdp_get_media_rtcp_address_type (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return FSDP_ADDRESS_TYPE_UNDEFINED; - return dsc->a_rtcp_address_type; -} - -const char * -fsdp_get_media_rtcp_address (const fsdp_media_description_t * dsc) -{ - if (!dsc) - return NULL; - return dsc->a_rtcp_address; -} - -unsigned int -fsdp_get_media_unidentified_attribute_count (const fsdp_media_description_t - * mdsc) -{ - if (!mdsc) - return 0; - return mdsc->unidentified_attributes_count; -} - -const char * -fsdp_get_media_unidentified_attribute (const fsdp_media_description_t * mdsc, - unsigned int _index) -{ - if (!mdsc || (_index < mdsc->unidentified_attributes_count)) - return NULL; - return mdsc->unidentified_attributes[_index]; -} Copied: mplayerxp/libmpdemux/freesdp/parser.cpp (from rev 369, mplayerxp/libmpdemux/freesdp/parser.c) =================================================================== --- mplayerxp/libmpdemux/freesdp/parser.cpp (rev 0) +++ mplayerxp/libmpdemux/freesdp/parser.cpp 2012-11-16 12:13:37 UTC (rev 385) @@ -0,0 +1,1938 @@ +/* + This file is part of FreeSDP + Copyright (C) 2001,2002,2003 Federico Montesino Pouzols <fe...@al...> + + FreeSDP is mp_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. + + 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 + + Benjamin Zores, (C) 2006 + added support in parser for the a=control: lines. + added support in parser for the a=range: lines. +*/ + +/** + * @file parser.c + * + * @short Parsing module implementation. + * + * This file implements the parsing routine <code>fsdp_parse</code> + * and the <code>fsdp_get_xxxx</code> routines that allow to get the + * session properties from a session description object build through + * the application of <code>fsdp_parse</code> to a textual SDP session + * description. + **/ + +#include "parserpriv.h" +#include "osdep/mplib.h" + +/** + * \brief find the start of the next line + * \param c pointer to current position in string + * \return pointer to start of next line or NULL if illegal (i.e. + * a '\r' is not followed by a '\n' + */ +static const char *next_line(const char *c) { + c += strcspn(c, "\n\r"); + if (*c == 0) return c; + if (*c == '\r') c++; + if (*c == '\n') + return c + 1; + return NULL; +} + +/** + * Moves the <code>c<code> pointer up to the beginning of the next + * line. + * + * @param c char pointer to pointer + * @retval FSDPE_ILLEGAL_CHARACTER, when an illegal '\r' character + * (not followed by a '\n') is found, returns + */ +#define NEXT_LINE(c) do { if (!(c = next_line(c))) return FSDPE_ILLEGAL_CHARACTER; } while (0); + +fsdp_error_t +fsdp_parse (const char *text_description, fsdp_description_t * dsc) +{ + fsdp_error_t result; + const char *p = text_description, *p2; + unsigned int _index, j; + /* temps for sscanf */ + const unsigned int TEMPCHARS = 6; + char fsdp_buf[TEMPCHARS][MAXSHORTFIELDLEN]; + char longfsdp_buf[MAXLONGFIELDLEN]; + const unsigned int TEMPINTS = 2; + unsigned long int wuint[TEMPINTS]; + + if ((NULL == text_description) || (NULL == dsc)) + return FSDPE_INVALID_PARAMETER; + + /***************************************************************************/ + /* A) parse session-level description */ + /***************************************************************************/ + + /* `v=' line (protocol version) */ + /* according to the RFC, only `v=0' is valid */ + if (sscanf (p, "v=%1lu", &wuint[0])) + { + if (wuint[0] != 0) + return FSDPE_INVALID_VERSION; + } + else + { + return FSDPE_MISSING_VERSION; + } + NEXT_LINE (p); + + /* `o=' line (owner/creator and session identifier) */ + /* o=<username> <session id> <version> <network type> <address type> + <address> */ + if (!strncmp (p, "o=", 2)) + { + p += 2; + /* note that the following max lengths may vary in the future and + are quite arbitary */ + if (sscanf + (p, + "%" MSFLENS "[\x21-\xFF] %" MSFLENS "[0-9] %" MSFLENS + "[0-9] %2s %3s %" MSFLENS "s", fsdp_buf[0], fsdp_buf[1], + fsdp_buf[2], fsdp_buf[3], fsdp_buf[4], fsdp_buf[5]) != 6) + return FSDPE_INVALID_OWNER; + dsc->o_username = mp_strdup (fsdp_buf[0]); + dsc->o_session_id = mp_strdup (fsdp_buf[1]); + dsc->o_announcement_version = mp_strdup (fsdp_buf[2]); + if (!strncmp (fsdp_buf[3], "IN", 2)) + { + dsc->o_network_type = FSDP_NETWORK_TYPE_INET; + if (!strncmp (fsdp_buf[4], "IP4", 3)) + dsc->o_address_type = FSDP_ADDRESS_TYPE_IPV4; + else if (!strncmp (fsdp_buf[4], "IP6", 3)) + dsc->o_address_type = FSDP_ADDRESS_TYPE_IPV6; + else + return FSDPE_INVALID_OWNER; + } + else + { + return FSDPE_INVALID_OWNER; + } + /* TODO? check valid unicast address/FQDN */ + dsc->o_address = mp_strdup (fsdp_buf[5]); + } + else + { + return FSDPE_MISSING_OWNER; + } + NEXT_LINE (p); + + /* `s=' line (session name) -note that the name string cannot be empty */ + /* s=<session name> */ + if (!strncmp (p, "s=", 2)) + { + if (sscanf (p, "s=%" MLFLENS "[^\r\n]", longfsdp_buf) < 1) + return FSDPE_EMPTY_NAME; + dsc->s_name = mp_strdup (longfsdp_buf); + } + else + { + return FSDPE_MISSING_NAME; + } + NEXT_LINE (p); + + /* `i=' line (session information) [optional] */ + /* i=<session description> */ + if (!strncmp (p, "i=", 2) + && sscanf (p, "i=%" MLFLENS "[^\r\n]", longfsdp_buf)) + { + dsc->i_information = mp_strdup (longfsdp_buf); + NEXT_LINE (p); + } + else + { + /* (optional) information absent */ + } + + /* `u=' line (URI of description) [optional] */ + /* u=<URI> */ + if (!strncmp (p, "u=", 2) + && sscanf (p, "u=%" MLFLENS "[^\r\n]", longfsdp_buf)) + { + /* TODO? check valid uri */ + dsc->u_uri = mp_strdup (longfsdp_buf); + NEXT_LINE (p); + } + else + { + /* (optional) uri absent */ + } + + /* `e=' lines (email address) [zero or more] */ + /* e=<email address> */ + p2 = p; + j = 0; + while (!strncmp (p2, "e=", 2)) + { + /* First, count how many emails are there */ + j++; + NEXT_LINE (p2); + } + dsc->emails_count = j; + if (dsc->emails_count > 0) + { + /* Then, build the array of emails */ + dsc->emails = new(zeromem) const char *[j]; + for (j = 0; j < dsc->emails_count; j++) + { + sscanf (p, "e=%" MLFLENS "[^\r\n]", longfsdp_buf); + /* TODO? check valid email-address. */ + dsc->emails[j] = mp_strdup (longfsdp_buf); + NEXT_LINE (p); + } + } + + /* `p=' lines (phone number) [zero or more] */ + /* p=<phone number> */ + j = 0; + /* assert ( p2 == p ); */ + while (!strncmp (p2, "p=", 2)) + { + j++; + NEXT_LINE (p2); + } + dsc->phones_count = j; + if (dsc->phones_count > 0) + { + dsc->phones = new(zeromem) const char *[j]; + for (j = 0; j < dsc->phones_count; j++) + { + sscanf (p, "p=%" MLFLENS "[^\r\n]", longfsdp_buf); + /* TODO? check valid phone-number. */ + dsc->phones[j] = mp_strdup (longfsdp_buf); + NEXT_LINE (p); + } + } + + /* `c=' line (connection information - not required if included in all media) [optional] */ + /* c=<network type> <address type> <connection address> */ + result = fsdp_parse_c (&p, &(dsc->c_network_type), &(dsc->c_address_type), + &(dsc->c_address)); + if (FSDPE_OK != result) + return result; + + /* `b=' lines (bandw... [truncated message content] |
From: <nic...@us...> - 2012-11-16 13:12:55
|
Revision: 386 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=386&view=rev Author: nickols_k Date: 2012-11-16 13:12:42 +0000 (Fri, 16 Nov 2012) Log Message: ----------- more C++ sources Modified Paths: -------------- mplayerxp/libmpcodecs/Makefile mplayerxp/libmpcodecs/ad_internal.h mplayerxp/libmpcodecs/liba52/Makefile mplayerxp/libmpcodecs/liba52/a52.h mplayerxp/libmpcodecs/liba52/a52_internal.h mplayerxp/libmpdemux/librtsp/Makefile mplayerxp/libmpdemux/librtsp/rtsp.h mplayerxp/libmpdemux/realrtsp/Makefile Added Paths: ----------- mplayerxp/libmpcodecs/ad_a52.cpp mplayerxp/libmpcodecs/ad_hwac3.cpp mplayerxp/libmpcodecs/liba52/bit_allocate.cpp mplayerxp/libmpcodecs/liba52/bitstream.cpp mplayerxp/libmpcodecs/liba52/crc.cpp mplayerxp/libmpcodecs/liba52/downmix.cpp mplayerxp/libmpcodecs/liba52/imdct.cpp mplayerxp/libmpcodecs/liba52/parse.cpp mplayerxp/libmpcodecs/liba52/resample.cpp mplayerxp/libmpcodecs/liba52/resample_c.h mplayerxp/libmpcodecs/liba52/resample_mmx.h mplayerxp/libmpdemux/librtsp/rtsp.cpp mplayerxp/libmpdemux/realrtsp/real.cpp mplayerxp/libmpdemux/realrtsp/xbuffer.cpp Removed Paths: ------------- mplayerxp/libmpcodecs/ad_a52.c mplayerxp/libmpcodecs/ad_hwac3.c mplayerxp/libmpcodecs/liba52/bit_allocate.c mplayerxp/libmpcodecs/liba52/bitstream.c mplayerxp/libmpcodecs/liba52/crc.c mplayerxp/libmpcodecs/liba52/downmix.c mplayerxp/libmpcodecs/liba52/imdct.c mplayerxp/libmpcodecs/liba52/parse.c mplayerxp/libmpcodecs/liba52/resample.c mplayerxp/libmpcodecs/liba52/resample_c.c mplayerxp/libmpcodecs/liba52/resample_mmx.c mplayerxp/libmpdemux/librtsp/rtsp.c mplayerxp/libmpdemux/realrtsp/real.c mplayerxp/libmpdemux/realrtsp/xbuffer.c Modified: mplayerxp/libmpcodecs/Makefile =================================================================== --- mplayerxp/libmpcodecs/Makefile 2012-11-16 12:13:37 UTC (rev 385) +++ mplayerxp/libmpcodecs/Makefile 2012-11-16 13:12:42 UTC (rev 386) @@ -6,6 +6,7 @@ DO_ALL = @ for i in $(SUBDIRS); do $(MAKE) -C $$i all || exit; done CXXSRCS=dec_video.cpp vd.cpp ad.cpp dec_audio.cpp +CXXSRCS+=ad_a52.cpp ad_hwac3.cpp SRCS=vd_null.c \ vd_ffmpeg.c \ @@ -18,11 +19,9 @@ ad_null.c \ ad_ffmpeg.c \ ad_mp3.c \ - ad_hwac3.c \ ad_pcm.c \ ad_dvdpcm.c \ ad_faad.c \ - ad_a52.c \ ad_dca.c \ codecs_ld.c Deleted: mplayerxp/libmpcodecs/ad_a52.c =================================================================== --- mplayerxp/libmpcodecs/ad_a52.c 2012-11-16 12:13:37 UTC (rev 385) +++ mplayerxp/libmpcodecs/ad_a52.c 2012-11-16 13:12:42 UTC (rev 386) @@ -1,258 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#define __USE_XOPEN 1 -#include <unistd.h> -#include <assert.h> -#include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ -#include "ad_internal.h" -#include "codecs_ld.h" - -#include "mp_config.h" -#include "mplayerxp.h" -#include "help_mp.h" -#include "osdep/cpudetect.h" - -#include "osdep/mm_accel.h" -#include "mplayerxp.h" -#include "liba52/a52.h" -#include "libao2/afmt.h" -#include "libao2/audio_out.h" -#include "postproc/af.h" - -typedef struct priv_s { - float last_pts; -}priv_t; - -#define MAX_AC3_FRAME 3840 - -a52_state_t* mpxp_a52_state; -uint32_t mpxp_a52_accel=0; -uint32_t mpxp_a52_flags=0; - -#include "osdep/bswap.h" -#include "osdep/mplib.h" - -static const ad_info_t info = -{ - "liba52 AC3 driver", - "liba52", - "Nickols_K", - "build-in" -}; - -static const config_t options[] = { - { NULL, NULL, 0, 0, 0, 0, NULL} -}; - -LIBAD_EXTERN(a52) - -static const audio_probe_t probes[] = { - { "liba52", "liba52", 0x2000, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, - { "liba52", "liba52", 0x20736D, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, - { "liba52", "liba52", FOURCC_TAG('A','C','_','3'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, - { "liba52", "liba52", FOURCC_TAG('D','N','E','T'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, - { "liba52", "liba52", FOURCC_TAG('S','A','C','3'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, - { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} -}; - -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { - unsigned i; - for(i=0;probes[i].driver;i++) - if(wtag==probes[i].wtag) - return &probes[i]; - return NULL; -} - -int a52_fillbuff(sh_audio_t *sh_audio,float *pts){ - int length=0; - int flags=0; - int sample_rate=0; - int bit_rate=0; - float apts=0.,null_pts; - priv_t *priv=sh_audio->context; - - sh_audio->a_in_buffer_len=0; - /* sync frame:*/ - while(1){ - while(sh_audio->a_in_buffer_len<8){ - int c=demux_getc_r(sh_audio->ds,apts?&null_pts:&apts); - if(c<0) { priv->last_pts=*pts=apts; return -1; } /* EOF*/ - sh_audio->a_in_buffer[sh_audio->a_in_buffer_len++]=c; - } - if(sh_audio->wtag!=0x2000) swab(sh_audio->a_in_buffer,sh_audio->a_in_buffer,8); - length = a52_syncinfo (sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate); - if(length>=7 && length<=MAX_AC3_FRAME) break; /* we're done.*/ - /* bad file => resync*/ - if(sh_audio->wtag!=0x2000) swab(sh_audio->a_in_buffer,sh_audio->a_in_buffer,8); - memmove(sh_audio->a_in_buffer,sh_audio->a_in_buffer+1,7); - --sh_audio->a_in_buffer_len; - apts=0; - } - MSG_DBG2("a52: len=%d flags=0x%X %d Hz %d bit/s\n",length,flags,sample_rate,bit_rate); - sh_audio->rate=sample_rate; - sh_audio->i_bps=bit_rate/8; - demux_read_data_r(sh_audio->ds,sh_audio->a_in_buffer+8,length-8,apts?&null_pts:&apts); - if(sh_audio->wtag!=0x2000) swab(sh_audio->a_in_buffer+8,sh_audio->a_in_buffer+8,length-8); - priv->last_pts=*pts=apts; - if(crc16_block(sh_audio->a_in_buffer+2,length-2)!=0) - MSG_STATUS("a52: CRC check failed! \n"); - return length; -} - -/* returns: number of available channels*/ -static int a52_printinfo(sh_audio_t *sh_audio){ - int flags, sample_rate, bit_rate; - char* mode="unknown"; - int channels=0; - a52_syncinfo (sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate); - switch(flags&A52_CHANNEL_MASK){ - case A52_CHANNEL: mode="channel"; channels=2; break; - case A52_MONO: mode="mono"; channels=1; break; - case A52_STEREO: mode="stereo"; channels=2; break; - case A52_3F: mode="3f";channels=3;break; - case A52_2F1R: mode="2f+1r";channels=3;break; - case A52_3F1R: mode="3f+1r";channels=4;break; - case A52_2F2R: mode="2f+2r";channels=4;break; - case A52_3F2R: mode="3f+2r";channels=5;break; - case A52_CHANNEL1: mode="channel1"; channels=2; break; - case A52_CHANNEL2: mode="channel2"; channels=2; break; - case A52_DOLBY: mode="dolby"; channels=2; break; - } - MSG_INFO("AC3: %d.%d (%s%s) %d Hz %3.1f kbit/s Out: %u-bit\n", - channels, (flags&A52_LFE)?1:0, - mode, (flags&A52_LFE)?"+lfe":"", - sample_rate, bit_rate*0.001f, - afmt2bps(sh_audio->afmt)*8); - return (flags&A52_LFE) ? (channels+1) : channels; -} - -MPXP_Rc preinit(sh_audio_t *sh) -{ - /* Dolby AC3 audio: */ - /* however many channels, 2 bytes in a word, 256 samples in a block, 6 blocks in a frame */ -#ifdef WORDS_BIGENDIAN -#define A52_FMT32 AFMT_S32_BE -#define A52_FMT24 AFMT_S24_BE -#else -#define A52_FMT32 AFMT_S32_LE -#define A52_FMT24 AFMT_S24_LE -#endif - sh->afmt=bps2afmt(2); - if(af_query_fmt(sh->afilter,AFMT_FLOAT32) == MPXP_Ok|| - af_query_fmt(sh->afilter,A52_FMT32) == MPXP_Ok || - af_query_fmt(sh->afilter,A52_FMT24) == MPXP_Ok) { - sh->afmt=AFMT_FLOAT32; - } - sh->audio_out_minsize=mp_conf.ao_channels*afmt2bps(sh->afmt)*256*6; - sh->audio_in_minsize=MAX_AC3_FRAME; - sh->context=mp_malloc(sizeof(priv_t)); - return MPXP_Ok; -} - -MPXP_Rc init(sh_audio_t *sh_audio) -{ - sample_t level=1, bias=384; - float pts; - int flags=0; - /* Dolby AC3 audio:*/ - mpxp_a52_accel = MPXPCtx->mplayer_accel; - mpxp_a52_state=a52_init (mpxp_a52_accel); - if (mpxp_a52_state == NULL) { - MSG_ERR("A52 init failed\n"); - return MPXP_False; - } - if(a52_fillbuff(sh_audio,&pts)<0){ - MSG_ERR("A52 sync failed\n"); - return MPXP_False; - } - /* 'a52 cannot upmix' hotfix:*/ - a52_printinfo(sh_audio); - sh_audio->nch=mp_conf.ao_channels; - while(sh_audio->nch>0){ - switch(sh_audio->nch){ - case 1: mpxp_a52_flags=A52_MONO; break; -/* case 2: mpxp_a52_flags=A52_STEREO; break; */ - case 2: mpxp_a52_flags=A52_DOLBY; break; -/* case 3: mpxp_a52_flags=A52_3F; break;*/ - case 3: mpxp_a52_flags=A52_2F1R; break; - case 4: mpxp_a52_flags=A52_2F2R; break; /* 2+2*/ - case 5: mpxp_a52_flags=A52_3F2R; break; - case 6: mpxp_a52_flags=A52_3F2R|A52_LFE; break; /* 5.1*/ - } - /* test:*/ - flags=mpxp_a52_flags|A52_ADJUST_LEVEL; - MSG_V("A52 flags before a52_frame: 0x%X\n",flags); - if (a52_frame (mpxp_a52_state, sh_audio->a_in_buffer, &flags, &level, bias)){ - MSG_ERR("a52: error decoding frame -> nosound\n"); - return MPXP_False; - } - MSG_V("A52 flags after a52_frame: 0x%X\n",flags); - /* frame decoded, let's init resampler:*/ - if(afmt2bps(sh_audio->afmt)==4) { - if(a52_resample_init_float(mpxp_a52_state,mpxp_a52_accel,flags,sh_audio->nch)) break; - } else { - if(a52_resample_init(mpxp_a52_state,mpxp_a52_accel,flags,sh_audio->nch)) break; - } - --sh_audio->nch; /* try to decrease no. of channels*/ - } - if(sh_audio->nch<=0){ - MSG_ERR("a52: no resampler. try different channel setup!\n"); - return MPXP_False; - } - return MPXP_Ok; -} - -void uninit(sh_audio_t *sh) -{ - mp_free(sh->context); -} - -MPXP_Rc control(sh_audio_t *sh,int cmd,any_t* arg, ...) -{ - UNUSED(arg); - switch(cmd) { - case ADCTRL_RESYNC_STREAM: - sh->a_in_buffer_len=0; // reset ACM/DShow audio buffer - return MPXP_True; - case ADCTRL_SKIP_FRAME: { - float pts; - a52_fillbuff(sh,&pts); // skip AC3 frame - return MPXP_True; - } - default: - return MPXP_Unknown; - } - return MPXP_Unknown; -} - -unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) -{ - sample_t level=1, bias=384; - int flags=mpxp_a52_flags|A52_ADJUST_LEVEL; - unsigned i; - unsigned len=0; - UNUSED(minlen); - UNUSED(maxlen); - priv_t *priv=sh_audio->context; - if(!sh_audio->a_in_buffer_len) { - if(a52_fillbuff(sh_audio,pts)<0) return len; /* EOF */ - } else *pts=priv->last_pts; - sh_audio->a_in_buffer_len=0; - if (a52_frame (mpxp_a52_state, sh_audio->a_in_buffer, &flags, &level, bias)){ - MSG_WARN("a52: error decoding frame\n"); - return len; - } -// a52_dynrng(&mpxp_a52_state, NULL, NULL); - len=0; - for (i = 0; i < 6; i++) { - if (a52_block (mpxp_a52_state)){ - MSG_WARN("a52: error at resampling\n"); - break; - } - if(afmt2bps(sh_audio->afmt)==4) - len+=4*a52_resample32(a52_samples(mpxp_a52_state),(float *)&buf[len]); - else - len+=2*a52_resample(a52_samples(mpxp_a52_state),(int16_t *)&buf[len]); - } - return len; -} Copied: mplayerxp/libmpcodecs/ad_a52.cpp (from rev 374, mplayerxp/libmpcodecs/ad_a52.c) =================================================================== --- mplayerxp/libmpcodecs/ad_a52.cpp (rev 0) +++ mplayerxp/libmpcodecs/ad_a52.cpp 2012-11-16 13:12:42 UTC (rev 386) @@ -0,0 +1,258 @@ +#include <stdio.h> +#include <stdlib.h> +#define __USE_XOPEN 1 +#include <unistd.h> +#include <assert.h> +#include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ +#include "ad_internal.h" +#include "codecs_ld.h" + +#include "mp_config.h" +#include "mplayerxp.h" +#include "help_mp.h" +#include "osdep/cpudetect.h" + +#include "osdep/mm_accel.h" +#include "mplayerxp.h" +#include "liba52/a52.h" +#include "libao2/afmt.h" +#include "libao2/audio_out.h" +#include "postproc/af.h" + +typedef struct priv_s { + float last_pts; +}priv_t; + +#define MAX_AC3_FRAME 3840 + +a52_state_t* mpxp_a52_state; +uint32_t mpxp_a52_accel=0; +uint32_t mpxp_a52_flags=0; + +#include "osdep/bswap.h" +#include "osdep/mplib.h" + +static const ad_info_t info = +{ + "liba52 AC3 driver", + "liba52", + "Nickols_K", + "build-in" +}; + +static const config_t options[] = { + { NULL, NULL, 0, 0, 0, 0, NULL} +}; + +LIBAD_EXTERN(a52) + +static const audio_probe_t probes[] = { + { "liba52", "liba52", 0x2000, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, + { "liba52", "liba52", 0x20736D, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, + { "liba52", "liba52", FOURCC_TAG('A','C','_','3'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, + { "liba52", "liba52", FOURCC_TAG('D','N','E','T'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, + { "liba52", "liba52", FOURCC_TAG('S','A','C','3'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, + { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} +}; + +static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { + unsigned i; + for(i=0;probes[i].driver;i++) + if(wtag==probes[i].wtag) + return &probes[i]; + return NULL; +} + +int a52_fillbuff(sh_audio_t *sh_audio,float *pts){ + int length=0; + int flags=0; + int sample_rate=0; + int bit_rate=0; + float apts=0.,null_pts; + priv_t *priv=reinterpret_cast<priv_t*>(sh_audio->context); + + sh_audio->a_in_buffer_len=0; + /* sync frame:*/ + while(1){ + while(sh_audio->a_in_buffer_len<8){ + int c=demux_getc_r(sh_audio->ds,apts?&null_pts:&apts); + if(c<0) { priv->last_pts=*pts=apts; return -1; } /* EOF*/ + sh_audio->a_in_buffer[sh_audio->a_in_buffer_len++]=c; + } + if(sh_audio->wtag!=0x2000) swab(sh_audio->a_in_buffer,sh_audio->a_in_buffer,8); + length = a52_syncinfo ((uint8_t*)sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate); + if(length>=7 && length<=MAX_AC3_FRAME) break; /* we're done.*/ + /* bad file => resync*/ + if(sh_audio->wtag!=0x2000) swab(sh_audio->a_in_buffer,sh_audio->a_in_buffer,8); + memmove(sh_audio->a_in_buffer,sh_audio->a_in_buffer+1,7); + --sh_audio->a_in_buffer_len; + apts=0; + } + MSG_DBG2("a52: len=%d flags=0x%X %d Hz %d bit/s\n",length,flags,sample_rate,bit_rate); + sh_audio->rate=sample_rate; + sh_audio->i_bps=bit_rate/8; + demux_read_data_r(sh_audio->ds,(uint8_t*)sh_audio->a_in_buffer+8,length-8,apts?&null_pts:&apts); + if(sh_audio->wtag!=0x2000) swab(sh_audio->a_in_buffer+8,sh_audio->a_in_buffer+8,length-8); + priv->last_pts=*pts=apts; + if(crc16_block((uint8_t*)sh_audio->a_in_buffer+2,length-2)!=0) + MSG_STATUS("a52: CRC check failed! \n"); + return length; +} + +/* returns: number of available channels*/ +static int a52_printinfo(sh_audio_t *sh_audio){ + int flags, sample_rate, bit_rate; + const char* mode="unknown"; + int channels=0; + a52_syncinfo ((uint8_t*)sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate); + switch(flags&A52_CHANNEL_MASK){ + case A52_CHANNEL: mode="channel"; channels=2; break; + case A52_MONO: mode="mono"; channels=1; break; + case A52_STEREO: mode="stereo"; channels=2; break; + case A52_3F: mode="3f";channels=3;break; + case A52_2F1R: mode="2f+1r";channels=3;break; + case A52_3F1R: mode="3f+1r";channels=4;break; + case A52_2F2R: mode="2f+2r";channels=4;break; + case A52_3F2R: mode="3f+2r";channels=5;break; + case A52_CHANNEL1: mode="channel1"; channels=2; break; + case A52_CHANNEL2: mode="channel2"; channels=2; break; + case A52_DOLBY: mode="dolby"; channels=2; break; + } + MSG_INFO("AC3: %d.%d (%s%s) %d Hz %3.1f kbit/s Out: %u-bit\n", + channels, (flags&A52_LFE)?1:0, + mode, (flags&A52_LFE)?"+lfe":"", + sample_rate, bit_rate*0.001f, + afmt2bps(sh_audio->afmt)*8); + return (flags&A52_LFE) ? (channels+1) : channels; +} + +MPXP_Rc preinit(sh_audio_t *sh) +{ + /* Dolby AC3 audio: */ + /* however many channels, 2 bytes in a word, 256 samples in a block, 6 blocks in a frame */ +#ifdef WORDS_BIGENDIAN +#define A52_FMT32 AFMT_S32_BE +#define A52_FMT24 AFMT_S24_BE +#else +#define A52_FMT32 AFMT_S32_LE +#define A52_FMT24 AFMT_S24_LE +#endif + sh->afmt=bps2afmt(2); + if(af_query_fmt(sh->afilter,mpaf_format_e(AFMT_FLOAT32)) == MPXP_Ok|| + af_query_fmt(sh->afilter,mpaf_format_e(A52_FMT32)) == MPXP_Ok || + af_query_fmt(sh->afilter,mpaf_format_e(A52_FMT24)) == MPXP_Ok) { + sh->afmt=AFMT_FLOAT32; + } + sh->audio_out_minsize=mp_conf.ao_channels*afmt2bps(sh->afmt)*256*6; + sh->audio_in_minsize=MAX_AC3_FRAME; + sh->context=mp_malloc(sizeof(priv_t)); + return MPXP_Ok; +} + +MPXP_Rc init(sh_audio_t *sh_audio) +{ + sample_t level=1, bias=384; + float pts; + int flags=0; + /* Dolby AC3 audio:*/ + mpxp_a52_accel = MPXPCtx->mplayer_accel; + mpxp_a52_state=a52_init (mpxp_a52_accel); + if (mpxp_a52_state == NULL) { + MSG_ERR("A52 init failed\n"); + return MPXP_False; + } + if(a52_fillbuff(sh_audio,&pts)<0){ + MSG_ERR("A52 sync failed\n"); + return MPXP_False; + } + /* 'a52 cannot upmix' hotfix:*/ + a52_printinfo(sh_audio); + sh_audio->nch=mp_conf.ao_channels; + while(sh_audio->nch>0){ + switch(sh_audio->nch){ + case 1: mpxp_a52_flags=A52_MONO; break; +/* case 2: mpxp_a52_flags=A52_STEREO; break; */ + case 2: mpxp_a52_flags=A52_DOLBY; break; +/* case 3: mpxp_a52_flags=A52_3F; break;*/ + case 3: mpxp_a52_flags=A52_2F1R; break; + case 4: mpxp_a52_flags=A52_2F2R; break; /* 2+2*/ + case 5: mpxp_a52_flags=A52_3F2R; break; + case 6: mpxp_a52_flags=A52_3F2R|A52_LFE; break; /* 5.1*/ + } + /* test:*/ + flags=mpxp_a52_flags|A52_ADJUST_LEVEL; + MSG_V("A52 flags before a52_frame: 0x%X\n",flags); + if (a52_frame (mpxp_a52_state, (uint8_t*)sh_audio->a_in_buffer, &flags, &level, bias)){ + MSG_ERR("a52: error decoding frame -> nosound\n"); + return MPXP_False; + } + MSG_V("A52 flags after a52_frame: 0x%X\n",flags); + /* frame decoded, let's init resampler:*/ + if(afmt2bps(sh_audio->afmt)==4) { + if(a52_resample_init_float(mpxp_a52_state,mpxp_a52_accel,flags,sh_audio->nch)) break; + } else { + if(a52_resample_init(mpxp_a52_state,mpxp_a52_accel,flags,sh_audio->nch)) break; + } + --sh_audio->nch; /* try to decrease no. of channels*/ + } + if(sh_audio->nch<=0){ + MSG_ERR("a52: no resampler. try different channel setup!\n"); + return MPXP_False; + } + return MPXP_Ok; +} + +void uninit(sh_audio_t *sh) +{ + mp_free(sh->context); +} + +MPXP_Rc control(sh_audio_t *sh,int cmd,any_t* arg, ...) +{ + UNUSED(arg); + switch(cmd) { + case ADCTRL_RESYNC_STREAM: + sh->a_in_buffer_len=0; // reset ACM/DShow audio buffer + return MPXP_True; + case ADCTRL_SKIP_FRAME: { + float pts; + a52_fillbuff(sh,&pts); // skip AC3 frame + return MPXP_True; + } + default: + return MPXP_Unknown; + } + return MPXP_Unknown; +} + +unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +{ + sample_t level=1, bias=384; + int flags=mpxp_a52_flags|A52_ADJUST_LEVEL; + unsigned i; + unsigned len=0; + UNUSED(minlen); + UNUSED(maxlen); + priv_t *priv=reinterpret_cast<priv_t*>(sh_audio->context); + if(!sh_audio->a_in_buffer_len) { + if(a52_fillbuff(sh_audio,pts)<0) return len; /* EOF */ + } else *pts=priv->last_pts; + sh_audio->a_in_buffer_len=0; + if (a52_frame (mpxp_a52_state, (uint8_t*)sh_audio->a_in_buffer, &flags, &level, bias)){ + MSG_WARN("a52: error decoding frame\n"); + return len; + } +// a52_dynrng(&mpxp_a52_state, NULL, NULL); + len=0; + for (i = 0; i < 6; i++) { + if (a52_block (mpxp_a52_state)){ + MSG_WARN("a52: error at resampling\n"); + break; + } + if(afmt2bps(sh_audio->afmt)==4) + len+=4*a52_resample32(a52_samples(mpxp_a52_state),(float *)&buf[len]); + else + len+=2*a52_resample(a52_samples(mpxp_a52_state),(int16_t *)&buf[len]); + } + return len; +} Deleted: mplayerxp/libmpcodecs/ad_hwac3.c =================================================================== --- mplayerxp/libmpcodecs/ad_hwac3.c 2012-11-16 12:13:37 UTC (rev 385) +++ mplayerxp/libmpcodecs/ad_hwac3.c 2012-11-16 13:12:42 UTC (rev 386) @@ -1,252 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#define __USE_XOPEN 1 -#include <unistd.h> -#include <string.h> -#include <assert.h> -#include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ -#include "ad_internal.h" - -#include "mp_config.h" -#include "help_mp.h" -#include "codecs_ld.h" -#include "osdep/cpudetect.h" -#include "osdep/bswap.h" - -#include "libao2/afmt.h" - -#define IEC61937_DATA_TYPE_AC3 1 - -typedef struct priv_s { - float last_pts; -}priv_t; - -struct hwac3info { - unsigned bitrate, framesize, samplerate, bsmod; -}; - -struct frmsize_s { - unsigned short bit_rate; - unsigned short frm_size[3]; -}; - -static const struct frmsize_s frmsizecod_tbl[64] = { - { 32 ,{64 ,69 ,96 } }, - { 32 ,{64 ,70 ,96 } }, - { 40 ,{80 ,87 ,120 } }, - { 40 ,{80 ,88 ,120 } }, - { 48 ,{96 ,104 ,144 } }, - { 48 ,{96 ,105 ,144 } }, - { 56 ,{112 ,121 ,168 } }, - { 56 ,{112 ,122 ,168 } }, - { 64 ,{128 ,139 ,192 } }, - { 64 ,{128 ,140 ,192 } }, - { 80 ,{160 ,174 ,240 } }, - { 80 ,{160 ,175 ,240 } }, - { 96 ,{192 ,208 ,288 } }, - { 96 ,{192 ,209 ,288 } }, - { 112 ,{224 ,243 ,336 } }, - { 112 ,{224 ,244 ,336 } }, - { 128 ,{256 ,278 ,384 } }, - { 128 ,{256 ,279 ,384 } }, - { 160 ,{320 ,348 ,480 } }, - { 160 ,{320 ,349 ,480 } }, - { 192 ,{384 ,417 ,576 } }, - { 192 ,{384 ,418 ,576 } }, - { 224 ,{448 ,487 ,672 } }, - { 224 ,{448 ,488 ,672 } }, - { 256 ,{512 ,557 ,768 } }, - { 256 ,{512 ,558 ,768 } }, - { 320 ,{640 ,696 ,960 } }, - { 320 ,{640 ,697 ,960 } }, - { 384 ,{768 ,835 ,1152 } }, - { 384 ,{768 ,836 ,1152 } }, - { 448 ,{896 ,975 ,1344 } }, - { 448 ,{896 ,976 ,1344 } }, - { 512 ,{1024 ,1114 ,1536 } }, - { 512 ,{1024 ,1115 ,1536 } }, - { 576 ,{1152 ,1253 ,1728 } }, - { 576 ,{1152 ,1254 ,1728 } }, - { 640 ,{1280 ,1393 ,1920 } }, - { 640 ,{1280 ,1394 ,1920 } } -}; - -struct syncframe { - struct syncinfo { - unsigned char syncword[2]; - unsigned char crc1[2]; - unsigned char code; - } syncinfo; - struct bsi { - unsigned char bsidmod; - unsigned char acmod; - } bsi; -}; - -unsigned ac3_iec958_build_burst(unsigned length, unsigned data_type, unsigned big_endian, unsigned char * data, unsigned char * out) -{ - out[0] = 0x72; - out[1] = 0xF8; - out[2] = 0x1F; - out[3] = 0x4E; - out[4] = (length) ? data_type : 0; /* & 0x1F; */ - out[5] = 0x00; - out[6] = (length << 3) & 0xFF; - out[7] = (length >> 5) & 0xFF; - if (big_endian) - swab(data, out + 8, length); - else - memcpy(out + 8, data, length); - memset(out + 8 + length, 0, 6144 - 8 - length); - return 6144; -} - -int ac3_iec958_parse_syncinfo(unsigned char *buf, unsigned size, struct hwac3info *ai, unsigned *skipped) -{ - int samplerates[4] = { 48000, 44100, 32000, -1 }; - unsigned short _sync = 0; - unsigned char *ptr = buf; - int fscod, frmsizecod; - struct syncframe *sf; - - _sync = buf[0] << 8; - _sync |= buf[1]; - ptr = buf + 2; - *skipped = 0; - while (_sync != 0xb77 && *skipped < size - 8) { - _sync <<= 8; - _sync |= *ptr; - ptr++; - *skipped += 1; - } - if (_sync != 0xb77) - return -1; - ptr -= 2; - sf = (struct syncframe *) ptr; - fscod = (sf->syncinfo.code >> 6) & 0x03; - ai->samplerate = samplerates[fscod]; - if ((int)ai->samplerate == -1) - return -1; - frmsizecod = sf->syncinfo.code & 0x3f; - ai->framesize = 2 * frmsizecod_tbl[frmsizecod].frm_size[fscod]; - ai->bitrate = frmsizecod_tbl[frmsizecod].bit_rate; - if (((sf->bsi.bsidmod >> 3) & 0x1f) != 0x08) - return -1; - ai->bsmod = sf->bsi.bsidmod & 0x7; - - return 0; -} - -typedef struct a52_state_s a52_state_t; -extern a52_state_t *mpxp_a52_state; -extern uint32_t mpxp_a52_accel; -extern uint32_t mpxp_a52_flags; -int a52_fillbuff(sh_audio_t *sh_audio,float *pts); - -static const ad_info_t info = { - "AC3/DTS pass-through S/PDIF", - "hwac3", - "Nickols_K", - "build-in" -}; - -static const config_t options[] = { - { NULL, NULL, 0, 0, 0, 0, NULL} -}; - -LIBAD_EXTERN(hwac3) -extern ad_functions_t mpcodecs_ad_a52; - -static a52_state_t * (*a52_init_ptr) (uint32_t mm_accel); -#define a52_init(a) (*a52_init_ptr)(a) - -static const audio_probe_t probes[] = { - { "hwac3", "hwac3", 0x2000, ACodecStatus_Working, {AFMT_AC3} }, - { "hwac3", "hwac3", 0x2001, ACodecStatus_Working, {AFMT_AC3} }, - { "hwac3", "hwac3", FOURCC_TAG('A','C','_','3'), ACodecStatus_Working, {AFMT_AC3} }, - { "hwac3", "hwac3", FOURCC_TAG('D','N','E','T'), ACodecStatus_Working, {AFMT_AC3} }, - { "hwac3", "hwac3", FOURCC_TAG('S','A','C','3'), ACodecStatus_Working, {AFMT_AC3} }, - { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} -}; - -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { - unsigned i; - for(i=0;probes[i].driver;i++) - if(wtag==probes[i].wtag) - return &probes[i]; - return NULL; -} - - -MPXP_Rc preinit(sh_audio_t *sh) -{ - /* Dolby AC3 audio: */ - mpcodecs_ad_a52.preinit(sh); - sh->audio_out_minsize=4*256*6; - sh->audio_in_minsize=3840; - sh->nch=2; - sh->afmt=AFMT_AC3; - return MPXP_Ok; -} - -MPXP_Rc init(sh_audio_t *sh_audio) -{ - /* Dolby AC3 passthrough:*/ - float pts; - mpxp_a52_state=a52_init (mpxp_a52_accel); /* doesn't require mmx optimzation */ - if (mpxp_a52_state == NULL) { - MSG_ERR("A52 init failed\n"); - return MPXP_False; - } - if(a52_fillbuff(sh_audio,&pts)<0) { - MSG_ERR("A52 sync failed\n"); - return 0; - } - /* - sh_audio->samplerate=ai.samplerate; // SET by a52_fillbuff() - sh_audio->samplesize=ai.framesize; - sh_audio->i_bps=ai.bitrate*(1000/8); // SET by a52_fillbuff() - sh_audio->ac3_frame=mp_malloc(6144); - sh_audio->o_bps=sh_audio->i_bps; // XXX FIXME!!! XXX - - o_bps is calculated from samplesize*channels*samplerate - a single ac3 frame is always translated to 6144 byte packet. (zero padding)*/ - sh_audio->nch=2; - sh_audio->afmt=bps2afmt(2); /* 2*2*(6*256) = 6144 (very TRICKY!)*/ - return MPXP_Ok; -} - -void uninit(sh_audio_t *sh) -{ - mpcodecs_ad_a52.uninit(sh); -} - -MPXP_Rc control(sh_audio_t *sh,int cmd,any_t* arg, ...) -{ - UNUSED(arg); - switch(cmd) { - case ADCTRL_RESYNC_STREAM: - sh->a_in_buffer_len=0; // reset ACM/DShow audio buffer - return MPXP_True; - case ADCTRL_SKIP_FRAME: { - float pts; - a52_fillbuff(sh,&pts); // skip AC3 frame - return MPXP_True; - } - default: - return MPXP_Unknown; - } - return MPXP_Unknown; -} - -unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) -{ - unsigned len=0; - UNUSED(minlen); - UNUSED(maxlen); - if(!sh_audio->a_in_buffer_len) - if((int)(len=a52_fillbuff(sh_audio,pts))<0) return 0; /*EOF*/ - sh_audio->a_in_buffer_len=0; - len = ac3_iec958_build_burst(len, 0x01, 1, sh_audio->a_in_buffer, buf); - return len; -} Copied: mplayerxp/libmpcodecs/ad_hwac3.cpp (from rev 369, mplayerxp/libmpcodecs/ad_hwac3.c) =================================================================== --- mplayerxp/libmpcodecs/ad_hwac3.cpp (rev 0) +++ mplayerxp/libmpcodecs/ad_hwac3.cpp 2012-11-16 13:12:42 UTC (rev 386) @@ -0,0 +1,252 @@ +#include <stdio.h> +#include <stdlib.h> +#define __USE_XOPEN 1 +#include <unistd.h> +#include <string.h> +#include <assert.h> +#include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ +#include "ad_internal.h" + +#include "mp_config.h" +#include "help_mp.h" +#include "codecs_ld.h" +#include "osdep/cpudetect.h" +#include "osdep/bswap.h" + +#include "libao2/afmt.h" + +#define IEC61937_DATA_TYPE_AC3 1 + +typedef struct priv_s { + float last_pts; +}priv_t; + +struct hwac3info { + unsigned bitrate, framesize, samplerate, bsmod; +}; + +struct frmsize_s { + unsigned short bit_rate; + unsigned short frm_size[3]; +}; + +static const struct frmsize_s frmsizecod_tbl[64] = { + { 32 ,{64 ,69 ,96 } }, + { 32 ,{64 ,70 ,96 } }, + { 40 ,{80 ,87 ,120 } }, + { 40 ,{80 ,88 ,120 } }, + { 48 ,{96 ,104 ,144 } }, + { 48 ,{96 ,105 ,144 } }, + { 56 ,{112 ,121 ,168 } }, + { 56 ,{112 ,122 ,168 } }, + { 64 ,{128 ,139 ,192 } }, + { 64 ,{128 ,140 ,192 } }, + { 80 ,{160 ,174 ,240 } }, + { 80 ,{160 ,175 ,240 } }, + { 96 ,{192 ,208 ,288 } }, + { 96 ,{192 ,209 ,288 } }, + { 112 ,{224 ,243 ,336 } }, + { 112 ,{224 ,244 ,336 } }, + { 128 ,{256 ,278 ,384 } }, + { 128 ,{256 ,279 ,384 } }, + { 160 ,{320 ,348 ,480 } }, + { 160 ,{320 ,349 ,480 } }, + { 192 ,{384 ,417 ,576 } }, + { 192 ,{384 ,418 ,576 } }, + { 224 ,{448 ,487 ,672 } }, + { 224 ,{448 ,488 ,672 } }, + { 256 ,{512 ,557 ,768 } }, + { 256 ,{512 ,558 ,768 } }, + { 320 ,{640 ,696 ,960 } }, + { 320 ,{640 ,697 ,960 } }, + { 384 ,{768 ,835 ,1152 } }, + { 384 ,{768 ,836 ,1152 } }, + { 448 ,{896 ,975 ,1344 } }, + { 448 ,{896 ,976 ,1344 } }, + { 512 ,{1024 ,1114 ,1536 } }, + { 512 ,{1024 ,1115 ,1536 } }, + { 576 ,{1152 ,1253 ,1728 } }, + { 576 ,{1152 ,1254 ,1728 } }, + { 640 ,{1280 ,1393 ,1920 } }, + { 640 ,{1280 ,1394 ,1920 } } +}; + +struct syncframe { + struct syncinfo { + unsigned char syncword[2]; + unsigned char crc1[2]; + unsigned char code; + } syncinfo; + struct bsi { + unsigned char bsidmod; + unsigned char acmod; + } bsi; +}; + +unsigned ac3_iec958_build_burst(unsigned length, unsigned data_type, unsigned big_endian, unsigned char * data, unsigned char * out) +{ + out[0] = 0x72; + out[1] = 0xF8; + out[2] = 0x1F; + out[3] = 0x4E; + out[4] = (length) ? data_type : 0; /* & 0x1F; */ + out[5] = 0x00; + out[6] = (length << 3) & 0xFF; + out[7] = (length >> 5) & 0xFF; + if (big_endian) + swab(data, out + 8, length); + else + memcpy(out + 8, data, length); + memset(out + 8 + length, 0, 6144 - 8 - length); + return 6144; +} + +int ac3_iec958_parse_syncinfo(unsigned char *buf, unsigned size, struct hwac3info *ai, unsigned *skipped) +{ + int samplerates[4] = { 48000, 44100, 32000, -1 }; + unsigned short _sync = 0; + unsigned char *ptr = buf; + int fscod, frmsizecod; + struct syncframe *sf; + + _sync = buf[0] << 8; + _sync |= buf[1]; + ptr = buf + 2; + *skipped = 0; + while (_sync != 0xb77 && *skipped < size - 8) { + _sync <<= 8; + _sync |= *ptr; + ptr++; + *skipped += 1; + } + if (_sync != 0xb77) + return -1; + ptr -= 2; + sf = (struct syncframe *) ptr; + fscod = (sf->syncinfo.code >> 6) & 0x03; + ai->samplerate = samplerates[fscod]; + if ((int)ai->samplerate == -1) + return -1; + frmsizecod = sf->syncinfo.code & 0x3f; + ai->framesize = 2 * frmsizecod_tbl[frmsizecod].frm_size[fscod]; + ai->bitrate = frmsizecod_tbl[frmsizecod].bit_rate; + if (((sf->bsi.bsidmod >> 3) & 0x1f) != 0x08) + return -1; + ai->bsmod = sf->bsi.bsidmod & 0x7; + + return 0; +} + +typedef struct a52_state_s a52_state_t; +extern a52_state_t *mpxp_a52_state; +extern uint32_t mpxp_a52_accel; +extern uint32_t mpxp_a52_flags; +int a52_fillbuff(sh_audio_t *sh_audio,float *pts); + +static const ad_info_t info = { + "AC3/DTS pass-through S/PDIF", + "hwac3", + "Nickols_K", + "build-in" +}; + +static const config_t options[] = { + { NULL, NULL, 0, 0, 0, 0, NULL} +}; + +LIBAD_EXTERN(hwac3) +extern ad_functions_t mpcodecs_ad_a52; + +static a52_state_t * (*a52_init_ptr) (uint32_t mm_accel); +#define a52_init(a) (*a52_init_ptr)(a) + +static const audio_probe_t probes[] = { + { "hwac3", "hwac3", 0x2000, ACodecStatus_Working, {AFMT_AC3} }, + { "hwac3", "hwac3", 0x2001, ACodecStatus_Working, {AFMT_AC3} }, + { "hwac3", "hwac3", FOURCC_TAG('A','C','_','3'), ACodecStatus_Working, {AFMT_AC3} }, + { "hwac3", "hwac3", FOURCC_TAG('D','N','E','T'), ACodecStatus_Working, {AFMT_AC3} }, + { "hwac3", "hwac3", FOURCC_TAG('S','A','C','3'), ACodecStatus_Working, {AFMT_AC3} }, + { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} +}; + +static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { + unsigned i; + for(i=0;probes[i].driver;i++) + if(wtag==probes[i].wtag) + return &probes[i]; + return NULL; +} + + +MPXP_Rc preinit(sh_audio_t *sh) +{ + /* Dolby AC3 audio: */ + mpcodecs_ad_a52.preinit(sh); + sh->audio_out_minsize=4*256*6; + sh->audio_in_minsize=3840; + sh->nch=2; + sh->afmt=AFMT_AC3; + return MPXP_Ok; +} + +MPXP_Rc init(sh_audio_t *sh_audio) +{ + /* Dolby AC3 passthrough:*/ + float pts; + mpxp_a52_state=a52_init (mpxp_a52_accel); /* doesn't require mmx optimzation */ + if (mpxp_a52_state == NULL) { + MSG_ERR("A52 init failed\n"); + return MPXP_False; + } + if(a52_fillbuff(sh_audio,&pts)<0) { + MSG_ERR("A52 sync failed\n"); + return MPXP_False; + } + /* + sh_audio->samplerate=ai.samplerate; // SET by a52_fillbuff() + sh_audio->samplesize=ai.framesize; + sh_audio->i_bps=ai.bitrate*(1000/8); // SET by a52_fillbuff() + sh_audio->ac3_frame=mp_malloc(6144); + sh_audio->o_bps=sh_audio->i_bps; // XXX FIXME!!! XXX + + o_bps is calculated from samplesize*channels*samplerate + a single ac3 frame is always translated to 6144 byte packet. (zero padding)*/ + sh_audio->nch=2; + sh_audio->afmt=bps2afmt(2); /* 2*2*(6*256) = 6144 (very TRICKY!)*/ + return MPXP_Ok; +} + +void uninit(sh_audio_t *sh) +{ + mpcodecs_ad_a52.uninit(sh); +} + +MPXP_Rc control(sh_audio_t *sh,int cmd,any_t* arg, ...) +{ + UNUSED(arg); + switch(cmd) { + case ADCTRL_RESYNC_STREAM: + sh->a_in_buffer_len=0; // reset ACM/DShow audio buffer + return MPXP_True; + case ADCTRL_SKIP_FRAME: { + float pts; + a52_fillbuff(sh,&pts); // skip AC3 frame + return MPXP_True; + } + default: + return MPXP_Unknown; + } + return MPXP_Unknown; +} + +unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +{ + unsigned len=0; + UNUSED(minlen); + UNUSED(maxlen); + if(!sh_audio->a_in_buffer_len) + if((int)(len=a52_fillbuff(sh_audio,pts))<0) return 0; /*EOF*/ + sh_audio->a_in_buffer_len=0; + len = ac3_iec958_build_burst(len, 0x01, 1, (unsigned char *)sh_audio->a_in_buffer, buf); + return len; +} Modified: mplayerxp/libmpcodecs/ad_internal.h =================================================================== --- mplayerxp/libmpcodecs/ad_internal.h 2012-11-16 12:13:37 UTC (rev 385) +++ mplayerxp/libmpcodecs/ad_internal.h 2012-11-16 13:12:42 UTC (rev 386) @@ -19,9 +19,9 @@ static MPXP_Rc control(sh_audio_t *sh,int cmd,any_t* arg, ...); static unsigned __FASTCALL__ decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts); -#define LIBAD_EXTERN(x) const ad_functions_t mpcodecs_ad_##x = {\ +#define LIBAD_EXTERN(x) extern const ad_functions_t mpcodecs_ad_##x = {\ &info,\ - &options,\ + options,\ probe, \ preinit,\ init,\ Modified: mplayerxp/libmpcodecs/liba52/Makefile =================================================================== --- mplayerxp/libmpcodecs/liba52/Makefile 2012-11-16 12:13:37 UTC (rev 385) +++ mplayerxp/libmpcodecs/liba52/Makefile 2012-11-16 13:12:42 UTC (rev 386) @@ -1,9 +1,12 @@ include ../../mp_config.mak -SRCS = crc.c bit_allocate.c bitstream.c downmix.c imdct.c parse.c resample.c +CXXSRCS = parse.cpp bitstream.cpp imdct.cpp downmix.cpp bit_allocate.cpp crc.cpp resample.cpp +SRCS = OBJS = $(SRCS:.c=.o) +CXXOBJS = $(CXXSRCS:.cpp=.o) CFLAGS = $(MLIB_INC) $(OPTFLAGS) -W -Wall +CXXFLAGS = $(MLIB_INC) $(OPTXXFLAGS) -W -Wall .SUFFIXES: .c .o @@ -11,8 +14,10 @@ .c.o: $(CC) -c $(CFLAGS) -o $@ $< +.cpp.o: + $(CC) -c $(CXXFLAGS) -o $@ $< -all: $(OBJS) +all: $(OBJS) $(CXXOBJS) clean: rm -f *.o *.a *~ @@ -23,7 +28,7 @@ dep: depend depend: - $(CC) -MM $(CFLAGS) $(SRCS) 1>.depend + $(CC) -MM $(CFLAGS) $(SRCS) $(CXXSRCS) 1>.depend # # include dependency files if they exist Modified: mplayerxp/libmpcodecs/liba52/a52.h =================================================================== --- mplayerxp/libmpcodecs/liba52/a52.h 2012-11-16 12:13:37 UTC (rev 385) +++ mplayerxp/libmpcodecs/liba52/a52.h 2012-11-16 13:12:42 UTC (rev 386) @@ -51,6 +51,9 @@ A52_ADJUST_LEVEL=32 }; +typedef int (*a52_resample_t) (float * _f, int16_t * s16); +typedef int (*a52_resample32_t) (float * _f, float * s16); + a52_state_t * a52_init (uint32_t mm_accel); sample_t * a52_samples (a52_state_t * state); extern int a52_syncinfo (uint8_t * buf, int * flags, @@ -62,8 +65,9 @@ extern int a52_block (a52_state_t * state); extern void a52_free (a52_state_t * state); extern uint16_t crc16_block(uint8_t *data,uint32_t num_bytes); -extern any_t* a52_resample_init_float(a52_state_t * state,uint32_t mm_accel,int flags,int chans); -extern any_t* a52_resample_init(a52_state_t * state,uint32_t mm_accel,int flags,int chans); +extern a52_resample32_t a52_resample_init_float(a52_state_t * state,uint32_t mm_accel,int flags,int chans); +extern a52_resample_t a52_resample_init(a52_state_t * state,uint32_t mm_accel,int flags,int chans); + extern int (* a52_resample) (float * _f, int16_t * s16); extern int (* a52_resample32) (float * _f, float * s16); Modified: mplayerxp/libmpcodecs/liba52/a52_internal.h =================================================================== --- mplayerxp/libmpcodecs/liba52/a52_internal.h 2012-11-16 12:13:37 UTC (rev 385) +++ mplayerxp/libmpcodecs/liba52/a52_internal.h 2012-11-16 13:12:42 UTC (rev 386) @@ -117,6 +117,6 @@ sample_t clev, sample_t slev); void a52_upmix (sample_t * samples, int acmod, int output); -char * a52_imdct_init (void); +const char * a52_imdct_init (void); void a52_imdct_256 (sample_t * data, sample_t * delay, sample_t bias); void a52_imdct_512 (sample_t * data, sample_t * delay, sample_t bias); Deleted: mplayerxp/libmpcodecs/liba52/bit_allocate.c =================================================================== --- mplayerxp/libmpcodecs/liba52/bit_allocate.c 2012-11-16 12:13:37 UTC (rev 385) +++ mplayerxp/libmpcodecs/liba52/bit_allocate.c 2012-11-16 13:12:42 UTC (rev 386) @@ -1,265 +0,0 @@ -/* - * bit_allocate.c - * Copyright (C) 2000-2002 Michel Lespinasse <wa...@zo...> - * Copyright (C) 1999-2000 Aaron Holtzman <aho...@es...> - * - * This file is part of a52dec, a mp_free ATSC A-52 stream decoder. - * See http://liba52.sourceforge.net/ for updates. - * - * a52dec is mp_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. - * - * a52dec 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 - */ - -#include "../../mp_config.h" - -#include <inttypes.h> - -#include "a52.h" -#include "a52_internal.h" - -static int hthtab[3][50] = { - {0x730, 0x730, 0x7c0, 0x800, 0x820, 0x840, 0x850, 0x850, 0x860, 0x860, - 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x890, 0x890, - 0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900, - 0x910, 0x910, 0x910, 0x910, 0x900, 0x8f0, 0x8c0, 0x870, 0x820, 0x7e0, - 0x7a0, 0x770, 0x760, 0x7a0, 0x7c0, 0x7c0, 0x6e0, 0x400, 0x3c0, 0x3c0}, - {0x710, 0x710, 0x7a0, 0x7f0, 0x820, 0x830, 0x840, 0x850, 0x850, 0x860, - 0x860, 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880, - 0x890, 0x890, 0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8e0, 0x8f0, - 0x900, 0x910, 0x910, 0x910, 0x910, 0x900, 0x8e0, 0x8b0, 0x870, 0x820, - 0x7e0, 0x7b0, 0x760, 0x770, 0x7a0, 0x7c0, 0x780, 0x5d0, 0x3c0, 0x3c0}, - {0x680, 0x680, 0x750, 0x7b0, 0x7e0, 0x810, 0x820, 0x830, 0x840, 0x850, - 0x850, 0x850, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, - 0x870, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880, 0x890, 0x8a0, 0x8b0, - 0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900, 0x910, 0x910, 0x910, 0x900, 0x8f0, - 0x8d0, 0x8b0, 0x840, 0x7f0, 0x790, 0x760, 0x7a0, 0x7c0, 0x7b0, 0x720} -}; - -static int8_t baptab[305] = { - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* 93 padding elems */ - - 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 14, 14, 14, 14, 14, - 14, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, - 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, - 5, 4, 4, -3, -3, 3, 3, 3, -2, -2, -1, -1, -1, -1, -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, 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, 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, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0 /* 148 padding elems */ -}; - -static int bndtab[30] = {21, 22, 23, 24, 25, 26, 27, 28, 31, 34, - 37, 40, 43, 46, 49, 55, 61, 67, 73, 79, - 85, 97, 109, 121, 133, 157, 181, 205, 229, 253}; - -static int8_t latab[256] = { - -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, - -52, -52, -51, -50, -49, -48, -47, -47, -46, -45, -44, -44, - -43, -42, -41, -41, -40, -39, -38, -38, -37, -36, -36, -35, - -35, -34, -33, -33, -32, -32, -31, -30, -30, -29, -29, -28, - -28, -27, -27, -26, -26, -25, -25, -24, -24, -23, -23, -22, - -22, -21, -21, -21, -20, -20, -19, -19, -19, -18, -18, -18, - -17, -17, -17, -16, -16, -16, -15, -15, -15, -14, -14, -14, - -13, -13, -13, -13, -12, -12, -12, -12, -11, -11, -11, -11, - -10, -10, -10, -10, -10, -9, -9, -9, -9, -9, -8, -8, - -8, -8, -8, -8, -7, -7, -7, -7, -7, -7, -6, -6, - -6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5, -5, - -5, -5, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, - -4, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, - -3, -3, -3, -2, -2, -2, -2, -2, -2, -2, -2, -2, - -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -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, 0, 0, 0 -}; - -#define UPDATE_LEAK() \ -do { \ - fastleak += fdecay; \ - if (fastleak > psd + fgain) \ - fastleak = psd + fgain; \ - slowleak += sdecay; \ - if (slowleak > psd + sgain) \ - slowleak = psd + sgain; \ -} while (0) - -#define COMPUTE_MASK() \ -do { \ - if (psd > dbknee) \ - mask -= (psd - dbknee) >> 2; \ - if (mask > hth [i >> halfrate]) \ - mask = hth [i >> halfrate]; \ - mask -= snroffset + 128 * deltba[i]; \ - mask = (mask > 0) ? 0 : ((-mask) >> 5); \ - mask -= floor; \ -} while (0) - -void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart, - int start, int end, int fastleak, int slowleak, - expbap_t * expbap) -{ - static int slowgain[4] = {0x540, 0x4d8, 0x478, 0x410}; - static int dbpbtab[4] = {0xc00, 0x500, 0x300, 0x100}; - static int floortab[8] = {0x910, 0x950, 0x990, 0x9d0, - 0xa10, 0xa90, 0xb10, 0x1400}; - - int i, j; - uint8_t * exp; - int8_t * bap; - int fdecay, fgain, sdecay, sgain, dbknee, floor, snroffset; - int psd, mask; - int8_t * deltba; - int * hth; - int halfrate; - - halfrate = state->halfrate; - fdecay = (63 + 20 * ((state->bai >> 7) & 3)) >> halfrate; /* fdcycod */ - fgain = 128 + 128 * (ba->bai & 7); /* fgaincod */ - sdecay = (15 + 2 * (state->bai >> 9)) >> halfrate; /* sdcycod */ - sgain = slowgain[(state->bai >> 5) & 3]; /* sgaincod */ - dbknee = dbpbtab[(state->bai >> 3) & 3]; /* dbpbcod */ - hth = hthtab[state->fscod]; - /* - * if there is no delta bit allocation, make deltba point to an area - * known to contain zeroes. baptab+156 here. - */ - deltba = (ba->deltbae == DELTA_BIT_NONE) ? baptab + 156 : ba->deltba; - floor = floortab[state->bai & 7]; /* floorcod */ - snroffset = 960 - 64 * state->csnroffst - 4 * (ba->bai >> 3) + floor; - floor >>= 5; - - exp = expbap->exp; - bap = expbap->bap; - - i = bndstart; - j = start; - if (start == 0) { /* not the coupling channel */ - int lowcomp; - - lowcomp = 0; - j = end - 1; - do { - if (i < j) { - if (exp[i+1] == exp[i] - 2) - lowcomp = 384; - else if (lowcomp && (exp[i+1] > exp[i])) - lowcomp -= 64; - } - psd = 128 * exp[i]; - mask = psd + fgain + lowcomp; - COMPUTE_MASK (); - bap[i] = (baptab+156)[mask + 4 * exp[i]]; - i++; - } while ((i < 3) || ((i < 7) && (exp[i] > exp[i-1]))); - fastleak = psd + fgain; - slowleak = psd + sgain; - - while (i < 7) { - if (i < j) { - if (exp[i+1] == exp[i] - 2) - lowcomp = 384; - else if (lowcomp && (exp[i+1] > exp[i])) - lowcomp -= 64; - } - psd = 128 * exp[i]; - UPDATE_LEAK (); - mask = ((fastleak + lowcomp < slowleak) ? - fastleak + lowcomp : slowleak); - COMPUTE_MASK (); - bap[i] = (baptab+156)[mask + 4 * exp[i]]; - i++; - } - - if (end == 7) /* lfe channel */ - return; - - do { - if (exp[i+1] == exp[i] - 2) - lowcomp = 320; - else if (lowcomp && (exp[i+1] > exp[i])) - lowcomp -= 64; - psd = 128 * exp[i]; - UPDATE_LEAK (); - mask = ((fastleak + lowcomp < slowleak) ? - fastleak + lowcomp : slowleak); - COMPUTE_MASK (); - bap[i] = (baptab+156)[mask + 4 * exp[i]]; - i++; - } while (i < 20); - - while (lowcomp > 128) { /* two iterations maximum */ - lowcomp -= 128; - psd = 128 * exp[i]; - UPDATE_LEAK (); - mask = ((fastleak + lowcomp < slowleak) ? - fastleak + lowcomp : slowleak); - COMPUTE_MASK (); - bap[i] = (baptab+156)[mask + 4 * exp[i]]; - i++; - } - j = i; - } - - do { - int startband, endband; - - startband = j; - endband = (bndtab[i-20] < end) ? bndtab[i-20] : end; - psd = 128 * exp[j++]; - while (j < endband) { - int next, delta; - - next = 128 * exp[j++]; - delta = next - psd; - switch (delta >> 9) { - case -6: case -5: case -4: case -3: case -2: - psd = next; - break; - case -1: - psd = next + latab[(-delta) >> 1]; - break; - case 0: - psd += latab[delta >> 1]; - break; - } - } - /* minpsd = -289 */ - UPDATE_LEAK (); - mask = (fastleak < slowleak) ? fastleak : slowleak; - COMPUTE_MASK (); - i++; - j = startband; - do { - /* max(mask+4*exp)=147=-(minpsd+fgain-deltba-snroffset)>>5+4*exp */ - /* min(mask+4*exp)=-156=-(sgain-deltba-snroffset)>>5 */ - bap[j] = (baptab+156)[mask + 4 * exp[j]]; - } while (++j < endband); - } while (j < end); -} Copied: mplayerxp/libmpcodecs/liba52/bit_allocate.cpp (from rev 369, mplayerxp/libmpcodecs/liba52/bit_allocate.c) =================================================================== --- mplayerxp/libmpcodecs/liba52/bit_allocate.cpp (rev 0) +++ mplayerxp/libmpcodecs/liba52/bit_allocate.cpp 2012-11-16 13:12:42 UTC (rev 386) @@ -0,0 +1,265 @@ +/* + * bit_allocate.c + * Copyright (C) 2000-2002 Michel Lespinasse <wa...@zo...> + * Copyright (C) 1999-2000 Aaron Holtzman <aho...@es...> + * + * This file is part of a52dec, a mp_free ATSC A-52 stream decoder. + * See http://liba52.sourceforge.net/ for updates. + * + * a52dec is mp_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. + * + * a52dec 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 + */ + +#include "../../mp_config.h" + +#include <inttypes.h> + +#include "a52.h" +#include "a52_internal.h" + +static int hthtab[3][50] = { + {0x730, 0x730, 0x7c0, 0x800, 0x820, 0x840, 0x850, 0x850, 0x860, 0x860, + 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x890, 0x890, + 0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900, + 0x910, 0x910, 0x910, 0x910, 0x900, 0x8f0, 0x8c0, 0x870, 0x820, 0x7e0, + 0x7a0, 0x770, 0x760, 0x7a0, 0x7c0, 0x7c0, 0x6e0, 0x400, 0x3c0, 0x3c0}, + {0x710, 0x710, 0x7a0, 0x7f0, 0x820, 0x830, 0x840, 0x850, 0x850, 0x860, + 0x860, 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880, + 0x890, 0x890, 0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8e0, 0x8f0, + 0x900, 0x910, 0x910, 0x910, 0x910, 0x900, 0x8e0, 0x8b0, 0x870, 0x820, + 0x7e0, 0x7b0, 0x760, 0x770, 0x7a0, 0x7c0, 0x780, 0x5d0, 0x3c0, 0x3c0}, + {0x680, 0x680, 0x750, 0x7b0, 0x7e0, 0x810, 0x820, 0x830, 0x840, 0x850, + 0x850, 0x850, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, + 0x870, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880, 0x890, 0x8a0, 0x8b0, + 0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900, 0x910, 0x910, 0x910, 0x900, 0x8f0, + 0x8d0, 0x8b0, 0x840, 0x7f0, 0x790, 0x760, 0x7a0, 0x7c0, 0x7b0, 0x720} +}; + +static int8_t baptab[305] = { + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* 93 padding elems */ + + 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 14, 14, 14, 14, 14, + 14, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, + 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, + 5, 4, 4, -3, -3, 3, 3, 3, -2, -2, -1, -1, -1, -1, -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, 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, 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, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 /* 148 padding elems */ +}; + +static int bndtab[30] = {21, 22, 23, 24, 25, 26, 27, 28, 31, 34, + 37, 40, 43, 46, 49, 55, 61, 67, 73, 79, + 85, 97, 109, 121, 133, 157, 181, 205, 229, 253}; + +static int8_t latab[256] = { + -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, + -52, -52, -51, -50, -49, -48, -47, -47, -46, -45, -44, -44, + -43, -42, -41, -41, -40, -39, -38, -38, -37, -36, -36, -35, + -35, -34, -33, -33, -32, -32, -31, -30, -30, -29, -29, -28, + -28, -27, -27, -26, -26, -25, -25, -24, -24, -23, -23, -22, + -22, -21, -21, -21, -20, -20, -19, -19, -19, -18, -18, -18, + -17, -17, -17, -16, -16, -16, -15, -15, -15, -14, -14, -14, + -13, -13, -13, -13, -12, -12, -12, -12, -11, -11, -11, -11, + -10, -10, -10, -10, -10, -9, -9, -9, -9, -9, -8, -8, + -8, -8, -8, -8, -7, -7, -7, -7, -7, -7, -6, -6, + -6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5, -5, + -5, -5, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, + -4, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, + -3, -3, -3, -2, -2, -2, -2, -2, -2, -2, -2, -2, + -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -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, 0, 0, 0 +}; + +#define UPDATE_LEAK() \ +do { \ + fastleak += fdecay; \ + if (fastleak > psd + fgain) \ + fastleak = psd + fgain; \ + slowleak += sdecay; \ + if (slowleak > psd + sgain) \ + slowleak = psd + sgain; \ +} while (0) + +#define COMPUTE_MASK() \ +do { \ + if (psd > dbknee) \ + mask -= (psd - dbknee) >> 2; \ + if (mask > hth [i >> halfrate]) \ + mask = hth [i >> halfrate]; \ + mask -= snroffset + 128 * deltba[i]; \ + mask = (mask > 0) ? 0 : ((-mask) >> 5); \ + mask -= floor; \ +} while (0) + +void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart, + int start, int end, int fastleak, int slowleak, + expbap_t * expbap) +{ + static int slowgain[4] = {0x540, 0x4d8, 0x478, 0x410}; + static int dbpbtab[4] = {0xc00, 0x500, 0x300, 0x100}; + static int floortab[8] = {0x910, 0x950, 0x990, 0x9d0, + 0xa10, 0xa90, 0xb10, 0x1400}; + + int i, j; + uint8_t * exp; + int8_t * bap; + int fdecay, fgain, sdecay, sgain, dbknee, floor, snroffset; + int psd, mask; + int8_t * deltba; + int * hth; + int halfrate; + + halfrate = state->halfrate; + fdecay = (63 + 20 * ((state->bai >> 7) & 3)) >> halfrate; /* fdcycod */ + fgain = 128 + 128 * (ba->bai & 7); /* fgaincod */ + sdecay = (15 + 2 * (state->bai >> 9)) >> halfrate; /* sdcycod */ + sgain = slowgain[(state->bai >> 5) & 3]; /* sgaincod */ + dbknee = dbpbtab[(state->bai >> 3) & 3]; /* dbpbcod */ + hth = hthtab[state->fscod]; + /* + * if there is no delta bit allocation, make deltba point to an area + * known to contain zeroes. baptab+156 here. + */ + deltba = (ba->deltbae == DELTA_BIT_NONE) ? baptab + 156 : ba->deltba; + floor = floortab[state->bai & 7]; /* floorcod */ + snroffset = 960 - 64 * state->csnroffst - 4 * (ba->bai >> 3) + floor; + floor >>= 5; + + exp = expbap->exp; + bap = expbap->bap; + + i = bndstart; + j = start; + if (start == 0) { /* not the coupling channel */ + int lowcomp; + + lowcomp = 0; + j = end - 1; + do { + if (i < j) { + if (exp[i+1] == exp[i] - 2) + lowcomp = 384; + else if (lowcomp && (exp[i+1] > exp[i])) + lowcomp -= 64; + } + psd = 128 * exp[i]; + mask = psd + fgain + lowcomp; + COMPUTE_MASK (); + bap[i] = (baptab+156)[mask + 4 * exp[i]]; + i++; + } while ((i < 3) || ((i < 7) && (exp[i] > exp[i-1]))); + fastleak = psd + fgain; + slowleak = psd + sgain; + + while (i < 7) { + if (i < j) { + if (exp[i+1] == exp[i] - 2) + lowcomp = 384; + else if (lowcomp && (exp[i+1] > exp[i])) + lowcomp -= 64; + } + psd = 128 * exp[i]; + UPDATE_LEAK (); + mask = ((fastleak + lowcomp < slowleak) ? + fastleak + lowcomp : slowleak); + COMPUTE_MASK (); + bap[i] = (baptab+156)[mask + 4 * exp[i]]; + i++; + } + + if (end == 7) /* lfe channel */ + return; + + do { + if (exp[i+1] == exp[i] - 2) + lowcomp = 320; + else if (lowcomp && (exp[i+1] > exp[i])) + lowcomp -= 64; + psd = 128 * exp[i]; + UPDATE_LEAK (); + mask = ((fastleak + lowcomp < slowleak) ? + fastleak + lowcomp : slowleak); + COMPUTE_MASK (); + bap[i] = (baptab+156)[mask + 4 * exp[i]]; + i++; + } while (i < 20); + + while (lowcomp > 128) { /* two iterations maximum */ + lowcomp -= 128; + psd = 128 * exp[i]; + UPDATE_LEAK (); + mask = ((fastleak + lowcomp < slowleak) ? + fastleak + lowcomp : slowleak); + COMPUTE_MASK (); + bap[i] = (baptab+156)[mask + 4 * exp[i]]; + i++; + } + j = i; + } + + do { + int startband, endband; + + startband = j; + endband = (bndtab[i-20] < end) ? bndtab[i-20] : end; + psd = 128 * exp[j++]; + while (j < endband) { + int next, delta; + + next = 128 * exp[j++]; + delta = next - psd; + switch (delta >> 9) { + case -6: case -5: case -4: case -3: case -2: + psd = next; + break; + case -1: + psd = next + latab[(-delta) >> 1]; + break; + case 0: + psd += latab[delta >> 1]; + break; + } + } + /* minpsd = -289 */ + UPDATE_LEAK (); + mask = (fastleak < slowleak) ? fastleak : slowleak; + COMPUTE_MASK (); + i++; + j = startband; + do { + /* max(mask+4*exp)=147=-(minpsd+fgain-deltba-snroffset)>>5+4*exp */ + /* min(mask+4*exp)=-156=-(sgain-deltba-snroffset)>>5 */ + bap[j] = (baptab+156)[mask + 4 * exp[j]]; + } while (++j < endband); + } while (j < end); +} Deleted: mplayerxp/libmpcodecs/liba52/bitstream.c =================================================================== --- mplayerxp/libmpcodecs/liba52/bitstream.c 2012-11-16 12:13:37 UTC (rev 385) +++ mplayerxp/libmpcodecs/liba52/bitstream.c 2012-11-16 13:12:42 UTC (rev 386) @@ -1,96 +0,0 @@ -/* - * bitstream.c - * Copyright (C) 2000-2002 Michel Lespinasse <wa...@zo...> - * Copyright (C) 1999-2000 Aaron Holtzman <aho...@es...> - * - * This file is part of a52dec, a mp_free ATSC A-52 stream decoder. - * See http://liba52.sourceforge.net/ for updates. - * - * a52dec is mp_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. - * - * a52dec 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 - */ - -#include "../../mp_config.h" - -#include <inttypes.h> - -#include "a52.h" -#include "a52_internal.h" -#include "bitstream.h" - -#define BUFFER_SIZE 4096 - -void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf) -{ - int align; - - align = (long)buf & 3; - state->buffer_start = (uint32_t *) (buf - align); - state->bits_left = 0; - state->current_word = 0; - bitstream_get (state, align * 8); -} - -static inline void bitstream_fill_current (a52_state_t * state) -{ - uint32_t tmp; - - tmp = *(state->buffer_start++); - state->current_word = swab32 (tmp); -} - -/* - * The fast paths for _get is in the - * bitstream.h header file so it can be inlined. - * - * The "bottom half" of this routine is suffixed _bh - * - * -ah - */ - -uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits) -{ - uint32_t result; - - num_bits -= state->bits_left; - result = ((state->current_word << (32 - state->bits_left)) >> - (32 - state->bits_left)); - - bitstream_fill_current (state); - - if (num_bits != 0) - result = (result << num_bits) | (state->current_word >> (32 - num_bits)); - - state->bits_left = 32 - num_bits; - - return result; -} - -... [truncated message content] |
From: <nic...@us...> - 2012-11-17 13:59:01
|
Revision: 392 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=392&view=rev Author: nickols_k Date: 2012-11-17 13:58:55 +0000 (Sat, 17 Nov 2012) Log Message: ----------- flexibility dureing configure malloc-debug Modified Paths: -------------- mplayerxp/cfg-mplayerxp.h mplayerxp/mplayerxp.cpp Modified: mplayerxp/cfg-mplayerxp.h =================================================================== --- mplayerxp/cfg-mplayerxp.h 2012-11-17 13:57:45 UTC (rev 391) +++ mplayerxp/cfg-mplayerxp.h 2012-11-17 13:58:55 UTC (rev 392) @@ -35,7 +35,7 @@ {"speed", &mp_conf.playbackspeed_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0.01, 100.0, "sets playback speed factor"}, {"benchmark", &mp_conf.benchmark, CONF_TYPE_FLAG, 0, 0, 1, "performs benchmarking to estimate performance of MPlayerXP"}, {"test-av", &mp_conf.test_av, CONF_TYPE_FLAG, 0, 0, 1, "test antiviral protection of MPlayerXP"}, - {"malloc-debug", &mp_conf.malloc_debug, CONF_TYPE_FLAG, 0, 0, 1, "debugs malloc() calls in MPlayerXP"}, + {"malloc-debug", &mp_conf.malloc_debug, CONF_TYPE_INT, CONF_RANGE, 0, 3, "debugs malloc() calls in MPlayerXP"}, {"max-trace", &mp_conf.max_trace, CONF_TYPE_INT, CONF_RANGE, 1, 1024, "maximal number of backtrace stack"}, {NULL, NULL, 0, 0, 0, 0, NULL}, }; Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-11-17 13:57:45 UTC (rev 391) +++ mplayerxp/mplayerxp.cpp 2012-11-17 13:58:55 UTC (rev 392) @@ -1650,6 +1650,30 @@ } return eof; } + +static void mpxp_config_malloc(int argc,char *argv[]) +{ + int i,level; + mp_conf.malloc_debug=0; + mp_malloc_e flg=MPA_FLG_RANDOMIZER; + for(i=0;i<argc;i++) { + if(strncmp(argv[i],"-core.malloc-debug",18)==0) { + char *p; + if((p=strchr(argv[i],'='))!=NULL) { + mp_conf.malloc_debug=atoi(p+1); + } + switch(mp_conf.malloc_debug) { + default: + case 0: flg=MPA_FLG_RANDOMIZER; break; + case 1: flg=MPA_FLG_BOUNDS_CHECK; break; + case 2: flg=MPA_FLG_BEFORE_CHECK; break; + case 3: flg=MPA_FLG_BACKTRACE; break; + } + break; + } + } + mp_init_malloc(argv[0],1000,10,flg); +} /******************************************\ * MAIN MPLAYERXP FUNCTION !!! * \******************************************/ @@ -1669,11 +1693,7 @@ int forced_subs_only=0; seek_args_t seek_args = { 0, DEMUX_SEEK_CUR|DEMUX_SEEK_SECONDS }; - mp_conf.malloc_debug=0; - for(i=0;i<argc;i++) if(strcmp(argv[i],"-core.malloc-debug")==0) { mp_conf.malloc_debug=1; break; } - mp_init_malloc(argv[0],1000,10,mp_conf.malloc_debug?MPA_FLG_BACKTRACE:MPA_FLG_RANDOMIZER); -// mp_init_malloc(argv[0],1000,10,MPA_FLG_BOUNDS_CHECK); -// mp_init_malloc(argv[0],1000,10,MPA_FLG_BEFORE_CHECK); + mpxp_config_malloc(argc,argv); // Yes, it really must be placed in stack or in very secret place xmpcore::PointerProtector<MPXPSecureKeys> ptr_protector; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-11-17 14:55:23
|
Revision: 398 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=398&view=rev Author: nickols_k Date: 2012-11-17 14:55:17 +0000 (Sat, 17 Nov 2012) Log Message: ----------- add test for backtrace efficiency Modified Paths: -------------- mplayerxp/mplayerxp.cpp mplayerxp/osdep/mplib.h Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-11-17 14:33:48 UTC (rev 397) +++ mplayerxp/mplayerxp.cpp 2012-11-17 14:55:17 UTC (rev 398) @@ -207,6 +207,12 @@ return MPXP_Virus; } +static volatile void __attribute__ ((noinline)) mpxp_test_backtrace(void) { + any_t* caller = get_caller_address(); + goto *caller; + kill(getpid(), SIGILL); +} + unsigned xp_num_cpu; static unsigned get_number_cpu(void) { #ifdef _OPENMP @@ -1679,6 +1685,7 @@ \******************************************/ int MPlayerXP(int argc,char* argv[], char *envp[]){ mpxp_init_antiviral_protection(1); + mpxp_test_backtrace(); int i; stream_t* stream=NULL; int stream_dump_type=0; Modified: mplayerxp/osdep/mplib.h =================================================================== --- mplayerxp/osdep/mplib.h 2012-11-17 14:33:48 UTC (rev 397) +++ mplayerxp/osdep/mplib.h 2012-11-17 14:55:17 UTC (rev 398) @@ -75,6 +75,12 @@ print_backtrace(why,stack,ncalls); } +static inline any_t* get_caller_address(void) { + any_t* stack[2]; + unsigned ncalls; + ncalls=backtrace(stack,2); + return stack[1]; +} extern any_t* __FASTCALL__ SECURE_NAME0(_mp_malloc)(size_t size); extern any_t* __FASTCALL__ SECURE_NAME1(_mp_mallocz)(size_t size); extern void __FASTCALL__ SECURE_NAME2(_mp_free)(any_t* ptr); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-11-17 16:25:35
|
Revision: 399 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=399&view=rev Author: nickols_k Date: 2012-11-17 16:25:28 +0000 (Sat, 17 Nov 2012) Log Message: ----------- minor optimization Modified Paths: -------------- mplayerxp/mplayerxp.cpp mplayerxp/osdep/mplib.cpp mplayerxp/osdep/mplib.h Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-11-17 14:55:17 UTC (rev 398) +++ mplayerxp/mplayerxp.cpp 2012-11-17 16:25:28 UTC (rev 399) @@ -207,9 +207,8 @@ return MPXP_Virus; } -static volatile void __attribute__ ((noinline)) mpxp_test_backtrace(void) { - any_t* caller = get_caller_address(); - goto *caller; +static void __attribute__ ((noinline)) mpxp_test_backtrace(void) { + goto *(reinterpret_cast<any_t*>(get_caller_address())); kill(getpid(), SIGILL); } @@ -2026,6 +2025,8 @@ /* display clip info */ demux_info_print(MPXPSys->demuxer(),filename); +// TODO: rewrite test backtrace in .asm +// mpxp_test_backtrace(); mpxp_run_ahead_engine(); fflush(stdout); @@ -2038,6 +2039,8 @@ if(sh_video) dae_wait_decoder_outrun(xp_core->video); +// TODO: rewrite test backtrace in .asm +// mpxp_test_backtrace(); if(xmp_run_players()!=0) exit_player("Can't run xp players!\n"); MSG_OK("Using the next %i threads:\n",xp_core->num_threads); unsigned idx; Modified: mplayerxp/osdep/mplib.cpp =================================================================== --- mplayerxp/osdep/mplib.cpp 2012-11-17 14:55:17 UTC (rev 398) +++ mplayerxp/osdep/mplib.cpp 2012-11-17 16:25:28 UTC (rev 399) @@ -22,3 +22,9 @@ } return buffer; } + +any_t* get_caller_address(unsigned num_caller) { + any_t* stack[3+num_caller]; + backtrace(stack,3+num_caller); + return stack[2+num_caller]; +} Modified: mplayerxp/osdep/mplib.h =================================================================== --- mplayerxp/osdep/mplib.h 2012-11-17 14:55:17 UTC (rev 398) +++ mplayerxp/osdep/mplib.h 2012-11-17 16:25:28 UTC (rev 399) @@ -75,12 +75,6 @@ print_backtrace(why,stack,ncalls); } -static inline any_t* get_caller_address(void) { - any_t* stack[2]; - unsigned ncalls; - ncalls=backtrace(stack,2); - return stack[1]; -} extern any_t* __FASTCALL__ SECURE_NAME0(_mp_malloc)(size_t size); extern any_t* __FASTCALL__ SECURE_NAME1(_mp_mallocz)(size_t size); extern void __FASTCALL__ SECURE_NAME2(_mp_free)(any_t* ptr); @@ -99,6 +93,8 @@ inline any_t *operator new[](size_t size,const std::nothrow_t&) { return mp_malloc(size); } inline void operator delete(any_t* p) { SECURE_NAME2(_mp_free)(p); } inline void operator delete[](any_t* p) { SECURE_NAME2(_mp_free)(p); } + + extern any_t* get_caller_address(unsigned num_caller=0); } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-11-18 12:13:22
|
Revision: 403 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=403&view=rev Author: nickols_k Date: 2012-11-18 12:13:12 +0000 (Sun, 18 Nov 2012) Log Message: ----------- more c++ sources + constantization Modified Paths: -------------- mplayerxp/Makefile mplayerxp/configure mplayerxp/input2/input.h mplayerxp/libmpcodecs/Makefile mplayerxp/libmpcodecs/ad.cpp mplayerxp/libmpcodecs/codecs_ld.h mplayerxp/libmpcodecs/libdca/Makefile mplayerxp/libmpcodecs/libdca/dca.h mplayerxp/libmpcodecs/vd.cpp mplayerxp/libmpcodecs/vd_internal.h mplayerxp/libmpconf/Makefile mplayerxp/libmpconf/cfgparser.h mplayerxp/libmpconf/codec-cfg.h mplayerxp/libmpconf/m_option.h mplayerxp/libmpconf/m_property.h mplayerxp/libmpconf/m_struct.h mplayerxp/libmpconf/subopt-helper.h mplayerxp/libmpdemux/Makefile mplayerxp/libmpdemux/cdd.h mplayerxp/libplaytree/Makefile mplayerxp/libplaytree/asxparser.cpp mplayerxp/libplaytree/asxparser.h mplayerxp/libplaytree/playtree.h mplayerxp/libplaytree/playtreeparser.h mplayerxp/mplayerxp.cpp mplayerxp/osdep/timer.h mplayerxp/postproc/Makefile mplayerxp/postproc/af.h mplayerxp/postproc/af_export.cpp mplayerxp/postproc/aflib.cpp mplayerxp/postproc/aflib.h mplayerxp/postproc/libmenu/Makefile mplayerxp/postproc/libmenu/menu.cpp mplayerxp/postproc/libmenu/menu.h mplayerxp/postproc/libmenu/menu_list.h mplayerxp/postproc/postprocess.h mplayerxp/postproc/swscale.h mplayerxp/postproc/vf.h mplayerxp/postproc/vf_scale.h mplayerxp/xmpcore/mp_aframe.cpp mplayerxp/xmpcore/mp_aframe.h Added Paths: ----------- mplayerxp/libmpcodecs/ad_dca.cpp mplayerxp/libmpcodecs/ad_faad.cpp mplayerxp/libmpcodecs/ad_ffmpeg.cpp mplayerxp/libmpcodecs/libdca/bitstream.cpp mplayerxp/libmpcodecs/libdca/downmix.cpp mplayerxp/libmpcodecs/libdca/parse.cpp mplayerxp/libmpcodecs/libdca/resample.cpp mplayerxp/libmpcodecs/libdca/resample_c.h mplayerxp/libmpcodecs/libdca/resample_mmx.h mplayerxp/libmpcodecs/vd_ffmpeg.cpp mplayerxp/libmpconf/codec-cfg.cpp mplayerxp/libmpconf/m_option.cpp mplayerxp/libmpconf/m_property.cpp mplayerxp/libmpconf/m_struct.cpp mplayerxp/libmpconf/subopt-helper.cpp mplayerxp/libmpdemux/cdda.cpp mplayerxp/libmpdemux/cddb.cpp mplayerxp/libmpdemux/mpdemux.cpp mplayerxp/libplaytree/playtree.cpp mplayerxp/libplaytree/playtreeparser.cpp mplayerxp/postproc/af_ao2.cpp mplayerxp/postproc/af_channels.cpp mplayerxp/postproc/af_crystality.cpp mplayerxp/postproc/af_delay.cpp mplayerxp/postproc/af_dyn.cpp mplayerxp/postproc/af_echo3d.cpp mplayerxp/postproc/af_equalizer.cpp mplayerxp/postproc/af_extrastereo.cpp mplayerxp/postproc/af_ffenc.cpp mplayerxp/postproc/af_format.cpp mplayerxp/postproc/af_hrtf.cpp mplayerxp/postproc/af_karaoke.cpp mplayerxp/postproc/af_lp.cpp mplayerxp/postproc/af_null.cpp mplayerxp/postproc/af_pan.cpp mplayerxp/postproc/af_raw.cpp mplayerxp/postproc/af_resample.cpp mplayerxp/postproc/af_scaletempo.cpp mplayerxp/postproc/af_sinesuppress.cpp mplayerxp/postproc/af_sub.cpp mplayerxp/postproc/af_surround.cpp mplayerxp/postproc/af_tools.cpp mplayerxp/postproc/af_volnorm.cpp mplayerxp/postproc/af_volume.cpp mplayerxp/postproc/libmenu/menu_cmdlist.cpp mplayerxp/postproc/libmenu/menu_console.cpp mplayerxp/postproc/libmenu/menu_filesel.cpp mplayerxp/postproc/libmenu/menu_list.cpp mplayerxp/postproc/libmenu/menu_param.cpp mplayerxp/postproc/libmenu/menu_pt.cpp mplayerxp/postproc/libmenu/menu_txt.cpp mplayerxp/postproc/postprocess.cpp mplayerxp/postproc/swscale.cpp mplayerxp/postproc/vf_1bpp.cpp mplayerxp/postproc/vf_2xsai.cpp mplayerxp/postproc/vf_aspect.cpp mplayerxp/postproc/vf_delogo.cpp mplayerxp/postproc/vf_denoise3d.cpp mplayerxp/postproc/vf_dint.cpp mplayerxp/postproc/vf_down3dright.cpp mplayerxp/postproc/vf_eq.cpp mplayerxp/postproc/vf_expand.cpp mplayerxp/postproc/vf_flip.cpp mplayerxp/postproc/vf_format.cpp mplayerxp/postproc/vf_framestep.cpp mplayerxp/postproc/vf_il.cpp mplayerxp/postproc/vf_menu.cpp mplayerxp/postproc/vf_mirror.cpp mplayerxp/postproc/vf_noise.cpp mplayerxp/postproc/vf_null.cpp mplayerxp/postproc/vf_ow.cpp mplayerxp/postproc/vf_palette.cpp mplayerxp/postproc/vf_panscan.cpp mplayerxp/postproc/vf_perspective.cpp mplayerxp/postproc/vf_pp.cpp mplayerxp/postproc/vf_raw.cpp mplayerxp/postproc/vf_rectangle.cpp mplayerxp/postproc/vf_rgb2bgr.cpp mplayerxp/postproc/vf_rotate.cpp mplayerxp/postproc/vf_scale.cpp mplayerxp/postproc/vf_smartblur.cpp mplayerxp/postproc/vf_softpulldown.cpp mplayerxp/postproc/vf_swapuv.cpp mplayerxp/postproc/vf_test.cpp mplayerxp/postproc/vf_unsharp.cpp mplayerxp/postproc/vf_vo.cpp mplayerxp/postproc/vf_yuvcsp.cpp mplayerxp/postproc/vf_yuy2.cpp mplayerxp/postproc/vf_yvu9.cpp Removed Paths: ------------- mplayerxp/libmpcodecs/ad_dca.c mplayerxp/libmpcodecs/ad_faad.c mplayerxp/libmpcodecs/ad_ffmpeg.c mplayerxp/libmpcodecs/libdca/bitstream.c mplayerxp/libmpcodecs/libdca/downmix.c mplayerxp/libmpcodecs/libdca/parse.c mplayerxp/libmpcodecs/libdca/resample.c mplayerxp/libmpcodecs/libdca/resample_c.c mplayerxp/libmpcodecs/libdca/resample_mmx.c mplayerxp/libmpcodecs/vd_ffmpeg.c mplayerxp/libmpconf/codec-cfg.c mplayerxp/libmpconf/m_option.c mplayerxp/libmpconf/m_property.c mplayerxp/libmpconf/m_struct.c mplayerxp/libmpconf/subopt-helper.c mplayerxp/libmpdemux/cdda.c mplayerxp/libmpdemux/cddb.c mplayerxp/libmpdemux/mpdemux.c mplayerxp/libplaytree/playtree.c mplayerxp/libplaytree/playtreeparser.c mplayerxp/postproc/af_ao2.c mplayerxp/postproc/af_channels.c mplayerxp/postproc/af_crystality.c mplayerxp/postproc/af_delay.c mplayerxp/postproc/af_dyn.c mplayerxp/postproc/af_echo3d.c mplayerxp/postproc/af_equalizer.c mplayerxp/postproc/af_extrastereo.c mplayerxp/postproc/af_ffenc.c mplayerxp/postproc/af_format.c mplayerxp/postproc/af_hrtf.c mplayerxp/postproc/af_karaoke.c mplayerxp/postproc/af_lp.c mplayerxp/postproc/af_null.c mplayerxp/postproc/af_pan.c mplayerxp/postproc/af_raw.c mplayerxp/postproc/af_resample.c mplayerxp/postproc/af_scaletempo.c mplayerxp/postproc/af_sinesuppress.c mplayerxp/postproc/af_sub.c mplayerxp/postproc/af_surround.c mplayerxp/postproc/af_tools.c mplayerxp/postproc/af_volnorm.c mplayerxp/postproc/af_volume.c mplayerxp/postproc/libmenu/menu_cmdlist.c mplayerxp/postproc/libmenu/menu_console.c mplayerxp/postproc/libmenu/menu_filesel.c mplayerxp/postproc/libmenu/menu_list.c mplayerxp/postproc/libmenu/menu_param.c mplayerxp/postproc/libmenu/menu_pt.c mplayerxp/postproc/libmenu/menu_txt.c mplayerxp/postproc/postprocess.c mplayerxp/postproc/swscale.c mplayerxp/postproc/vf_1bpp.c mplayerxp/postproc/vf_2xsai.c mplayerxp/postproc/vf_aspect.c mplayerxp/postproc/vf_delogo.c mplayerxp/postproc/vf_denoise3d.c mplayerxp/postproc/vf_dint.c mplayerxp/postproc/vf_down3dright.c mplayerxp/postproc/vf_eq.c mplayerxp/postproc/vf_expand.c mplayerxp/postproc/vf_flip.c mplayerxp/postproc/vf_format.c mplayerxp/postproc/vf_framestep.c mplayerxp/postproc/vf_il.c mplayerxp/postproc/vf_menu.c mplayerxp/postproc/vf_mirror.c mplayerxp/postproc/vf_noise.c mplayerxp/postproc/vf_null.c mplayerxp/postproc/vf_ow.c mplayerxp/postproc/vf_palette.c mplayerxp/postproc/vf_panscan.c mplayerxp/postproc/vf_perspective.c mplayerxp/postproc/vf_pp.c mplayerxp/postproc/vf_raw.c mplayerxp/postproc/vf_rectangle.c mplayerxp/postproc/vf_rgb2bgr.c mplayerxp/postproc/vf_rotate.c mplayerxp/postproc/vf_scale.c mplayerxp/postproc/vf_smartblur.c mplayerxp/postproc/vf_softpulldown.c mplayerxp/postproc/vf_swapuv.c mplayerxp/postproc/vf_test.c mplayerxp/postproc/vf_unsharp.c mplayerxp/postproc/vf_vo.c mplayerxp/postproc/vf_yuvcsp.c mplayerxp/postproc/vf_yuy2.c mplayerxp/postproc/vf_yvu9.c Modified: mplayerxp/Makefile =================================================================== --- mplayerxp/Makefile 2012-11-18 06:17:26 UTC (rev 402) +++ mplayerxp/Makefile 2012-11-18 12:13:12 UTC (rev 403) @@ -99,7 +99,7 @@ $(DO_MAKE) -rm -f *~ $(TARGET_EXE) $(OBJS) -rm -f *.o *.a .depend configure.log - -rm -f mp_config.h mp_config.mak version.h + -rm -f mp_config.h mp_config.mak mp_conf_lavc.h version.h -rm -f cpuinfo help_mp.h version.h: Modified: mplayerxp/configure =================================================================== --- mplayerxp/configure 2012-11-18 06:17:26 UTC (rev 402) +++ mplayerxp/configure 2012-11-18 12:13:12 UTC (rev 403) @@ -288,9 +288,12 @@ fi srcdir=`pwd` +cd .. +topdir=`pwd` +cd $srcdir + #checking for pkg-config test $($pkg_config --version 2>/dev/null) || die "no pkg-config found" - ############################################################################# enabled profile && disable fastcall print_config __USE mp_config.h mp_config.mak fastcall @@ -1117,6 +1120,31 @@ #include "nls/help_mp-en.h" EOF +echo "Creating mp_conf_lavc.h" +cat > mp_conf_lavc.h << EOF +#ifndef __MP_CONF_LAVC_H_INCLUDED__ +#define __MP_CONF_LAVC_H_INCLUDED__ 1 +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define UINT64_C __UINT64_C +#define FF_API_OLD_DECODE_AUDIO 1 +#include "$srcdir/../ffmpeg/libavcodec/avcodec.h" +#include "$srcdir/../ffmpeg/libpostproc/postprocess.h" +#include "$srcdir/../ffmpeg/libswscale/swscale.h" +#include "$srcdir/../ffmpeg/libswscale/rgb2rgb.h" +#include "$srcdir/../ffmpeg/libavutil/audioconvert.h" +#include "$srcdir/../ffmpeg/libswresample/swresample.h" +#include "$srcdir/../ffmpeg/libavformat/riff.h" + +#ifdef __cplusplus +} +#endif +#endif +EOF ############################################################################# #FIXME: add something like "Optimizing for: i686 mmx mmx2 sse" Modified: mplayerxp/input2/input.h =================================================================== --- mplayerxp/input2/input.h 2012-11-18 06:17:26 UTC (rev 402) +++ mplayerxp/input2/input.h 2012-11-18 12:13:12 UTC (rev 403) @@ -3,9 +3,6 @@ #include "mp_config.h" #include "xmpcore/xmp_enums.h" -#ifdef __cplusplus -extern "C" { -#endif // All commands id enum { MP_CMD_SEEK =0, @@ -155,14 +152,16 @@ extern any_t* RND_RENAME0(mp_input_open)(void); extern void mp_input_close(any_t* handle); -// Interruptible usleep: (used by libmpdemux) -extern MPXP_Rc mp_input_check_interrupt(any_t* handle,int time); - extern void mp_input_print_keys(any_t*handle); extern void mp_input_print_cmds(any_t*handle); extern void mp_input_print_binds(any_t*handle); #ifdef __cplusplus +extern "C" { +#endif +// Interruptible usleep: (used by libmpdemux) +extern MPXP_Rc mp_input_check_interrupt(any_t* handle,int time); +#ifdef __cplusplus } #endif #endif Modified: mplayerxp/libmpcodecs/Makefile =================================================================== --- mplayerxp/libmpcodecs/Makefile 2012-11-18 06:17:26 UTC (rev 402) +++ mplayerxp/libmpcodecs/Makefile 2012-11-18 12:13:12 UTC (rev 403) @@ -8,8 +8,9 @@ CXXSRCS=dec_video.cpp vd.cpp ad.cpp dec_audio.cpp CXXSRCS+=ad_a52.cpp ad_hwac3.cpp +CXXSRCS+=vd_ffmpeg.cpp ad_dca.cpp ad_faad.cpp ad_ffmpeg.cpp + SRCS=vd_null.c \ - vd_ffmpeg.c \ vd_raw.c \ vd_nuv.c \ vd_libmpeg2.c \ @@ -17,12 +18,9 @@ vd_mpegpes.c \ vd_huffyuv.c \ ad_null.c \ - ad_ffmpeg.c \ ad_mp3.c \ ad_pcm.c \ ad_dvdpcm.c \ - ad_faad.c \ - ad_dca.c \ codecs_ld.c ifeq ($(ENABLE_GPL_ONLY),no) Modified: mplayerxp/libmpcodecs/ad.cpp =================================================================== --- mplayerxp/libmpcodecs/ad.cpp 2012-11-18 06:17:26 UTC (rev 402) +++ mplayerxp/libmpcodecs/ad.cpp 2012-11-18 12:13:12 UTC (rev 403) @@ -90,6 +90,7 @@ unsigned i; const audio_probe_t* rv; for (i=0; mpcodecs_ad_drivers[i] != &mpcodecs_ad_null; i++) { + MSG_V("Probing: %s\n",mpcodecs_ad_drivers[i]->info->driver_name); if((rv=mpcodecs_ad_drivers[i]->probe(sh,sh->wtag))!=NULL) return rv; } return NULL; Deleted: mplayerxp/libmpcodecs/ad_dca.c =================================================================== --- mplayerxp/libmpcodecs/ad_dca.c 2012-11-18 06:17:26 UTC (rev 402) +++ mplayerxp/libmpcodecs/ad_dca.c 2012-11-18 12:13:12 UTC (rev 403) @@ -1,258 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#define __USE_XOPEN 1 -#include <unistd.h> -#include <assert.h> -#include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ -#include "ad_internal.h" -#include "codecs_ld.h" - -#include "mp_config.h" -#include "mplayerxp.h" -#include "help_mp.h" -#include "osdep/cpudetect.h" - -#include "libdca/dca.h" -#include "osdep/mm_accel.h" -#include "mplayerxp.h" -#include "osdep/bswap.h" -#include "libao2/afmt.h" -#include "libao2/audio_out.h" -#include "postproc/af.h" -#include "osdep/mplib.h" - -#define MAX_AC5_FRAME 4096 - -dca_state_t* mpxp_dca_state; -uint32_t mpxp_dca_accel=0; -uint32_t mpxp_dca_flags=0; - -typedef struct priv_s { - float last_pts; -}priv_t; - - -static const ad_info_t info = { - "DTS Coherent Acoustics", - "libdca", - "Nickols_K", - "build-in" -}; - -static const config_t options[] = { - { NULL, NULL, 0, 0, 0, 0, NULL} -}; - -LIBAD_EXTERN(dca) - -static const audio_probe_t probes[] = { - { "libdca", "libdca", 0x86, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "libdca", "libdca", 0x2001, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "libdca", "libdca", FOURCC_TAG('D','T','S',' '), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "libdca", "libdca", FOURCC_TAG('D','T','S','B'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "libdca", "libdca", FOURCC_TAG('D','T','S','C'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "libdca", "libdca", FOURCC_TAG('D','T','S','E'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "libdca", "libdca", FOURCC_TAG('D','T','S','H'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "libdca", "libdca", FOURCC_TAG('D','T','S','L'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} -}; - -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { - unsigned i; - for(i=0;probes[i].driver;i++) - if(wtag==probes[i].wtag) - return &probes[i]; - return NULL; -} - -int dca_fillbuff(sh_audio_t *sh_audio,float *pts){ - int length=0,flen=0; - int flags=0; - int sample_rate=0; - int bit_rate=0; - float apts=0.,null_pts; - priv_t *priv=sh_audio->context; - - sh_audio->a_in_buffer_len=0; - /* sync frame:*/ - while(1){ - while(sh_audio->a_in_buffer_len<16){ - int c=demux_getc_r(sh_audio->ds,apts?&null_pts:&apts); - if(c<0) { priv->last_pts=*pts=apts; return -1; } /* EOF*/ - sh_audio->a_in_buffer[sh_audio->a_in_buffer_len++]=c; - } - length = dca_syncinfo (mpxp_dca_state,sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate, &flen); - if(length>=16 && length<=MAX_AC5_FRAME) break; /* we're done.*/ - /* bad file => resync*/ - memmove(sh_audio->a_in_buffer,sh_audio->a_in_buffer+1,15); - --sh_audio->a_in_buffer_len; - apts=0; - } - MSG_DBG2("dca[%08X]: len=%d flags=0x%X %d Hz %d bit/s frame=%u\n",*((long *)sh_audio->a_in_buffer),length,flags,sample_rate,bit_rate,flen); - sh_audio->rate=sample_rate; - sh_audio->i_bps=bit_rate/8; - demux_read_data_r(sh_audio->ds,sh_audio->a_in_buffer+16,length-16,apts?&null_pts:&apts); - priv->last_pts=*pts=apts; - - return length; -} - -/* returns: number of available channels*/ -static int dca_printinfo(sh_audio_t *sh_audio){ - int flags, sample_rate, bit_rate,flen,length; - char* mode="unknown"; - int channels=0; - length=dca_syncinfo (mpxp_dca_state,sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate,&flen); - switch(flags&DCA_CHANNEL_MASK){ - case DCA_CHANNEL: mode="channel"; channels=2; break; - case DCA_MONO: mode="mono"; channels=1; break; - case DCA_STEREO: mode="stereo"; channels=2; break; - case DCA_3F: mode="3f"; channels=3;break; - case DCA_2F1R: mode="2f+1r"; channels=3;break; - case DCA_3F1R: mode="3f+1r"; channels=4;break; - case DCA_2F2R: mode="2f+2r"; channels=4;break; - case DCA_3F2R: mode="3f+2r"; channels=5;break; - case DCA_4F2R: mode="4f+2r"; channels=6;break; - case DCA_DOLBY: mode="dolby"; channels=2; break; - default: channels=0; break; - } - MSG_INFO("DCA: %d.%d (%s%s) %d Hz %3.1f kbit/s Out: %u-bit\n", - channels, (flags&DCA_LFE)?1:0, - mode, (flags&DCA_LFE)?"+lfe":"", - sample_rate, bit_rate*0.001f, - afmt2bps(sh_audio->afmt)*8); - return (flags&DCA_LFE) ? (channels+1) : channels; -} - - -MPXP_Rc preinit(sh_audio_t *sh) -{ - /* DTS audio: - however many channels, 2 bytes in a word, 256 samples in a block, 6 blocks in a frame */ -#ifdef WORDS_BIGENDIAN -#define DCA_FMT32 AFMT_S32_BE -#define DCA_FMT24 AFMT_S24_BE -#else -#define DCA_FMT32 AFMT_S32_LE -#define DCA_FMT24 AFMT_S24_LE -#endif - sh->afmt=bps2afmt(2); - if( af_query_fmt(sh->afilter,AFMT_FLOAT32) == MPXP_Ok|| - af_query_fmt(sh->afilter,DCA_FMT32) == MPXP_Ok || - af_query_fmt(sh->afilter,DCA_FMT24) == MPXP_Ok) - { - sh->afmt=AFMT_FLOAT32; - } - sh->audio_out_minsize=mp_conf.ao_channels*afmt2bps(sh->afmt)*256*8; - sh->audio_in_minsize=MAX_AC5_FRAME; - sh->context=mp_malloc(sizeof(priv_t)); - return MPXP_Ok; -} - -MPXP_Rc init(sh_audio_t *sh_audio) -{ - sample_t level=1, bias=384; - float pts; - int flags=0; - /* Dolby AC3 audio:*/ - mpxp_dca_accel = MPXPCtx->mplayer_accel; - mpxp_dca_state = dca_init(mpxp_dca_accel); - if (mpxp_dca_state == NULL) { - MSG_ERR("dca init failed\n"); - return MPXP_False; - } - if(dca_fillbuff(sh_audio,&pts)<0){ - MSG_ERR("dca sync failed\n"); - return MPXP_False; - } - /* 'dca cannot upmix' hotfix:*/ - dca_printinfo(sh_audio); - sh_audio->nch=mp_conf.ao_channels; - while(sh_audio->nch>0){ - switch(sh_audio->nch){ - case 1: mpxp_dca_flags=DCA_MONO; break; - case 2: mpxp_dca_flags=DCA_STEREO; break; -/* case 2: mpxp_dca_flags=DCA_DOLBY; break; */ -/* case 3: mpxp_dca_flags=DCA_3F; break; */ - case 3: mpxp_dca_flags=DCA_2F1R; break; - case 4: mpxp_dca_flags=DCA_2F2R; break; /* 2+2*/ - case 5: mpxp_dca_flags=DCA_3F2R; break; - case 6: mpxp_dca_flags=DCA_3F2R|DCA_LFE; break; /* 5.1*/ - } - /* test:*/ - flags=mpxp_dca_flags|DCA_ADJUST_LEVEL; - MSG_V("dca flags before dca_frame: 0x%X\n",flags); - if (dca_frame (mpxp_dca_state, sh_audio->a_in_buffer, &flags, &level, bias)){ - MSG_ERR("dca: error decoding frame -> nosound\n"); - return MPXP_False; - } - MSG_V("dca flags after dca_frame: 0x%X\n",flags); - if(afmt2bps(sh_audio->afmt)==4) { - if(dca_resample_init_float(mpxp_dca_state,mpxp_dca_accel,flags,sh_audio->nch)) break; - } else { - if(dca_resample_init(mpxp_dca_state,mpxp_dca_accel,flags,sh_audio->nch)) break; - } - --sh_audio->nch; /* try to decrease no. of channels*/ - } - if(sh_audio->nch<=0){ - MSG_ERR("dca: no resampler. try different channel setup!\n"); - return MPXP_False; - } - return MPXP_Ok; -} - -void uninit(sh_audio_t *sh) -{ - mp_free(sh->context); -} - -MPXP_Rc control(sh_audio_t *sh,int cmd,any_t* arg, ...) -{ - UNUSED(arg); - switch(cmd) { - case ADCTRL_RESYNC_STREAM: - sh->a_in_buffer_len=0; // reset ACM/DShow audio buffer - return MPXP_True; - case ADCTRL_SKIP_FRAME: { - float pts; - dca_fillbuff(sh,&pts); // skip AC3 frame - return MPXP_True; - } - default: - return MPXP_Unknown; - } - return MPXP_Unknown; -} - -unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) -{ - sample_t level=1, bias=384; - unsigned i,nblocks,flags=mpxp_dca_flags|DCA_ADJUST_LEVEL; - unsigned len=0; - priv_t *priv=sh_audio->context; - UNUSED(minlen); - UNUSED(maxlen); - if(!sh_audio->a_in_buffer_len) { - if(dca_fillbuff(sh_audio,pts)<0) return len; /* EOF */ - } - else *pts=priv->last_pts; - sh_audio->a_in_buffer_len=0; - if (dca_frame (mpxp_dca_state, sh_audio->a_in_buffer, &flags, &level, bias)!=0){ - MSG_WARN("dca: error decoding frame\n"); - return len; - } -// dca_dynrng(&mpxp_dca_state, NULL, NULL); - len=0; - nblocks=dca_blocks_num(mpxp_dca_state); - for (i = 0; i < nblocks; i++) { - if (dca_block (mpxp_dca_state)){ - MSG_WARN("dca: error at deblock\n"); - break; - } - if(afmt2bps(sh_audio->afmt)==4) - len+=4*dca_resample32(dca_samples(mpxp_dca_state),(float *)&buf[len]); - else - len+=2*dca_resample(dca_samples(mpxp_dca_state),(int16_t *)&buf[len]); - } - return len; -} Copied: mplayerxp/libmpcodecs/ad_dca.cpp (from rev 374, mplayerxp/libmpcodecs/ad_dca.c) =================================================================== --- mplayerxp/libmpcodecs/ad_dca.cpp (rev 0) +++ mplayerxp/libmpcodecs/ad_dca.cpp 2012-11-18 12:13:12 UTC (rev 403) @@ -0,0 +1,258 @@ +#include <stdio.h> +#include <stdlib.h> +#define __USE_XOPEN 1 +#include <unistd.h> +#include <assert.h> +#include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ +#include "ad_internal.h" +#include "codecs_ld.h" + +#include "mp_config.h" +#include "mplayerxp.h" +#include "help_mp.h" +#include "osdep/cpudetect.h" + +#include "libdca/dca.h" +#include "osdep/mm_accel.h" +#include "mplayerxp.h" +#include "osdep/bswap.h" +#include "libao2/afmt.h" +#include "libao2/audio_out.h" +#include "postproc/af.h" +#include "osdep/mplib.h" + +#define MAX_AC5_FRAME 4096 + +dca_state_t* mpxp_dca_state; +uint32_t mpxp_dca_accel=0; +uint32_t mpxp_dca_flags=0; + +typedef struct priv_s { + float last_pts; +}priv_t; + + +static const ad_info_t info = { + "DTS Coherent Acoustics", + "libdca", + "Nickols_K", + "build-in" +}; + +static const config_t options[] = { + { NULL, NULL, 0, 0, 0, 0, NULL} +}; + +LIBAD_EXTERN(dca) + +static const audio_probe_t probes[] = { + { "libdca", "libdca", 0x86, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "libdca", "libdca", 0x2001, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "libdca", "libdca", FOURCC_TAG('D','T','S',' '), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "libdca", "libdca", FOURCC_TAG('D','T','S','B'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "libdca", "libdca", FOURCC_TAG('D','T','S','C'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "libdca", "libdca", FOURCC_TAG('D','T','S','E'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "libdca", "libdca", FOURCC_TAG('D','T','S','H'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "libdca", "libdca", FOURCC_TAG('D','T','S','L'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} +}; + +static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { + unsigned i; + for(i=0;probes[i].driver;i++) + if(wtag==probes[i].wtag) + return &probes[i]; + return NULL; +} + +int dca_fillbuff(sh_audio_t *sh_audio,float *pts){ + int length=0,flen=0; + int flags=0; + int sample_rate=0; + int bit_rate=0; + float apts=0.,null_pts; + priv_t *priv=reinterpret_cast<priv_t*>(sh_audio->context); + + sh_audio->a_in_buffer_len=0; + /* sync frame:*/ + while(1){ + while(sh_audio->a_in_buffer_len<16){ + int c=demux_getc_r(sh_audio->ds,apts?&null_pts:&apts); + if(c<0) { priv->last_pts=*pts=apts; return -1; } /* EOF*/ + sh_audio->a_in_buffer[sh_audio->a_in_buffer_len++]=c; + } + length = dca_syncinfo (mpxp_dca_state,reinterpret_cast<uint8_t*>(sh_audio->a_in_buffer), reinterpret_cast<int *>(&flags), &sample_rate, &bit_rate, &flen); + if(length>=16 && length<=MAX_AC5_FRAME) break; /* we're done.*/ + /* bad file => resync*/ + memmove(sh_audio->a_in_buffer,sh_audio->a_in_buffer+1,15); + --sh_audio->a_in_buffer_len; + apts=0; + } + MSG_DBG2("dca[%08X]: len=%d flags=0x%X %d Hz %d bit/s frame=%u\n",*((long *)sh_audio->a_in_buffer),length,flags,sample_rate,bit_rate,flen); + sh_audio->rate=sample_rate; + sh_audio->i_bps=bit_rate/8; + demux_read_data_r(sh_audio->ds,reinterpret_cast<unsigned char*>(sh_audio->a_in_buffer+16),length-16,apts?&null_pts:&apts); + priv->last_pts=*pts=apts; + + return length; +} + +/* returns: number of available channels*/ +static int dca_printinfo(sh_audio_t *sh_audio){ + int flags, sample_rate, bit_rate,flen,length; + const char* mode="unknown"; + int channels=0; + length=dca_syncinfo (mpxp_dca_state,reinterpret_cast<uint8_t*>(sh_audio->a_in_buffer), reinterpret_cast<int*>(&flags), &sample_rate, &bit_rate,&flen); + switch(flags&DCA_CHANNEL_MASK){ + case DCA_CHANNEL: mode="channel"; channels=2; break; + case DCA_MONO: mode="mono"; channels=1; break; + case DCA_STEREO: mode="stereo"; channels=2; break; + case DCA_3F: mode="3f"; channels=3;break; + case DCA_2F1R: mode="2f+1r"; channels=3;break; + case DCA_3F1R: mode="3f+1r"; channels=4;break; + case DCA_2F2R: mode="2f+2r"; channels=4;break; + case DCA_3F2R: mode="3f+2r"; channels=5;break; + case DCA_4F2R: mode="4f+2r"; channels=6;break; + case DCA_DOLBY: mode="dolby"; channels=2; break; + default: channels=0; break; + } + MSG_INFO("DCA: %d.%d (%s%s) %d Hz %3.1f kbit/s Out: %u-bit\n", + channels, (flags&DCA_LFE)?1:0, + mode, (flags&DCA_LFE)?"+lfe":"", + sample_rate, bit_rate*0.001f, + afmt2bps(sh_audio->afmt)*8); + return (flags&DCA_LFE) ? (channels+1) : channels; +} + + +MPXP_Rc preinit(sh_audio_t *sh) +{ + /* DTS audio: + however many channels, 2 bytes in a word, 256 samples in a block, 6 blocks in a frame */ +#ifdef WORDS_BIGENDIAN +#define DCA_FMT32 AFMT_S32_BE +#define DCA_FMT24 AFMT_S24_BE +#else +#define DCA_FMT32 AFMT_S32_LE +#define DCA_FMT24 AFMT_S24_LE +#endif + sh->afmt=bps2afmt(2); + if( af_query_fmt(sh->afilter,mpaf_format_decode(AFMT_FLOAT32)) == MPXP_Ok|| + af_query_fmt(sh->afilter,mpaf_format_decode(DCA_FMT32)) == MPXP_Ok || + af_query_fmt(sh->afilter,mpaf_format_decode(DCA_FMT24)) == MPXP_Ok) + { + sh->afmt=AFMT_FLOAT32; + } + sh->audio_out_minsize=mp_conf.ao_channels*afmt2bps(sh->afmt)*256*8; + sh->audio_in_minsize=MAX_AC5_FRAME; + sh->context=mp_malloc(sizeof(priv_t)); + return MPXP_Ok; +} + +MPXP_Rc init(sh_audio_t *sh_audio) +{ + sample_t level=1, bias=384; + float pts; + int flags=0; + /* Dolby AC3 audio:*/ + mpxp_dca_accel = MPXPCtx->mplayer_accel; + mpxp_dca_state = dca_init(mpxp_dca_accel); + if (mpxp_dca_state == NULL) { + MSG_ERR("dca init failed\n"); + return MPXP_False; + } + if(dca_fillbuff(sh_audio,&pts)<0){ + MSG_ERR("dca sync failed\n"); + return MPXP_False; + } + /* 'dca cannot upmix' hotfix:*/ + dca_printinfo(sh_audio); + sh_audio->nch=mp_conf.ao_channels; + while(sh_audio->nch>0){ + switch(sh_audio->nch){ + case 1: mpxp_dca_flags=DCA_MONO; break; + case 2: mpxp_dca_flags=DCA_STEREO; break; +/* case 2: mpxp_dca_flags=DCA_DOLBY; break; */ +/* case 3: mpxp_dca_flags=DCA_3F; break; */ + case 3: mpxp_dca_flags=DCA_2F1R; break; + case 4: mpxp_dca_flags=DCA_2F2R; break; /* 2+2*/ + case 5: mpxp_dca_flags=DCA_3F2R; break; + case 6: mpxp_dca_flags=DCA_3F2R|DCA_LFE; break; /* 5.1*/ + } + /* test:*/ + flags=mpxp_dca_flags|DCA_ADJUST_LEVEL; + MSG_V("dca flags before dca_frame: 0x%X\n",flags); + if (dca_frame (mpxp_dca_state, reinterpret_cast<uint8_t*>(sh_audio->a_in_buffer), reinterpret_cast<int*>(&flags), &level, bias)){ + MSG_ERR("dca: error decoding frame -> nosound\n"); + return MPXP_False; + } + MSG_V("dca flags after dca_frame: 0x%X\n",flags); + if(afmt2bps(sh_audio->afmt)==4) { + if(dca_resample_init_float(mpxp_dca_state,mpxp_dca_accel,flags,sh_audio->nch)) break; + } else { + if(dca_resample_init(mpxp_dca_state,mpxp_dca_accel,flags,sh_audio->nch)) break; + } + --sh_audio->nch; /* try to decrease no. of channels*/ + } + if(sh_audio->nch<=0){ + MSG_ERR("dca: no resampler. try different channel setup!\n"); + return MPXP_False; + } + return MPXP_Ok; +} + +void uninit(sh_audio_t *sh) +{ + mp_free(sh->context); +} + +MPXP_Rc control(sh_audio_t *sh,int cmd,any_t* arg, ...) +{ + UNUSED(arg); + switch(cmd) { + case ADCTRL_RESYNC_STREAM: + sh->a_in_buffer_len=0; // reset ACM/DShow audio buffer + return MPXP_True; + case ADCTRL_SKIP_FRAME: { + float pts; + dca_fillbuff(sh,&pts); // skip AC3 frame + return MPXP_True; + } + default: + return MPXP_Unknown; + } + return MPXP_Unknown; +} + +unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +{ + sample_t level=1, bias=384; + unsigned i,nblocks,flags=mpxp_dca_flags|DCA_ADJUST_LEVEL; + unsigned len=0; + priv_t *priv=reinterpret_cast<priv_t *>(sh_audio->context); + UNUSED(minlen); + UNUSED(maxlen); + if(!sh_audio->a_in_buffer_len) { + if(dca_fillbuff(sh_audio,pts)<0) return len; /* EOF */ + } + else *pts=priv->last_pts; + sh_audio->a_in_buffer_len=0; + if (dca_frame (mpxp_dca_state, reinterpret_cast<uint8_t *>(sh_audio->a_in_buffer), reinterpret_cast<int *>(&flags), &level, bias)!=0){ + MSG_WARN("dca: error decoding frame\n"); + return len; + } +// dca_dynrng(&mpxp_dca_state, NULL, NULL); + len=0; + nblocks=dca_blocks_num(mpxp_dca_state); + for (i = 0; i < nblocks; i++) { + if (dca_block (mpxp_dca_state)){ + MSG_WARN("dca: error at deblock\n"); + break; + } + if(afmt2bps(sh_audio->afmt)==4) + len+=4*dca_resample32(dca_samples(mpxp_dca_state),(float *)&buf[len]); + else + len+=2*dca_resample(dca_samples(mpxp_dca_state),(int16_t *)&buf[len]); + } + return len; +} Deleted: mplayerxp/libmpcodecs/ad_faad.c =================================================================== --- mplayerxp/libmpcodecs/ad_faad.c 2012-11-18 06:17:26 UTC (rev 402) +++ mplayerxp/libmpcodecs/ad_faad.c 2012-11-18 12:13:12 UTC (rev 403) @@ -1,359 +0,0 @@ -/* ad_faad.c - MPlayer AAC decoder using libfaad2 - * This file is part of MPlayer, see http://mplayerhq.hu/ for info. - * (c)2002 by Felix Buenemann <atmosfear at users.sourceforge.net> - * File licensed under the GPL, see http://www.fsf.org/ for more info. - */ -#include "mp_config.h" - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - -#include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ -#include "help_mp.h" -#include "osdep/bswap.h" -#include "codecs_ld.h" -#include "mp_config.h" -#include "ad_internal.h" -#include "mplayerxp.h" -#include "osdep/cpudetect.h" -#include "osdep/mm_accel.h" -#include "osdep/mplib.h" -#include "libao2/afmt.h" -#include "libao2/audio_out.h" -#include "postproc/af.h" - -static const ad_info_t info = { - "AAC (MPEG2/4 Advanced Audio Coding)", - "faad", - "Felix Buenemann", - "http://www.audiocoding.com/faad2.html" -}; - -static const config_t options[] = { - { NULL, NULL, 0, 0, 0, 0, NULL} -}; - -LIBAD_EXTERN(faad) - -typedef struct faad_priv_s { - float pts; -}priv_t; - -static const audio_probe_t probes[] = { - { "faad", "libfaad", 0xFF, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "faad", "libfaad", 0x4143, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "faad", "libfaad", 0x706D, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "faad", "libfaad", 0xA106, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "faad", "libfaad", 0xAAC0, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "faad", "libfaad", FOURCC_TAG('A','A','C',' '), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "faad", "libfaad", FOURCC_TAG('A','A','C','P'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "faad", "libfaad", FOURCC_TAG('M','P','4','A'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "faad", "libfaad", FOURCC_TAG('M','P','4','L'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "faad", "libfaad", FOURCC_TAG('M','P','4','A'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "faad", "libfaad", FOURCC_TAG('R','A','A','C'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "faad", "libfaad", FOURCC_TAG('R','A','A','P'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { "faad", "libfaad", FOURCC_TAG('V','L','B',' '), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, - { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} -}; - -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { - unsigned i; - for(i=0;probes[i].driver;i++) - if(wtag==probes[i].wtag) - return &probes[i]; - return NULL; -} - -typedef any_t*NeAACDecHandle; -typedef struct NeAACDecConfiguration { - unsigned char defObjectType; - unsigned long defSampleRate; - unsigned char outputFormat; - unsigned char downMatrix; - unsigned char useOldADTSFormat; - unsigned char dontUpSampleImplicitSBR; -} NeAACDecConfiguration, *NeAACDecConfigurationPtr; -struct NeAACDecFrameInfo; - -typedef struct NeAACDecFrameInfo { - unsigned long bytesconsumed; - unsigned long samples; - unsigned char channels; - unsigned char error; - unsigned long samplerate; - - /* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */ - unsigned char sbr; - - /* MPEG-4 ObjectType */ - unsigned char object_type; - - /* AAC header type; MP4 will be signalled as RAW also */ - unsigned char header_type; - - /* multichannel configuration */ - unsigned char num_front_channels; - unsigned char num_side_channels; - unsigned char num_back_channels; - unsigned char num_lfe_channels; - unsigned char channel_position[64]; - - /* PS: 0: off, 1: on */ - unsigned char ps; -} NeAACDecFrameInfo; -#define FAAD_MIN_STREAMSIZE 768 /* 6144 bits/channel */ -/* configure maximum supported channels, * - * this is theoretically max. 64 chans */ -#define FAAD_MAX_CHANNELS 6 -#define FAAD_BUFFLEN (FAAD_MIN_STREAMSIZE*FAAD_MAX_CHANNELS) -#ifdef _WIN32 - #pragma pack(push, 8) - #ifndef NEAACDECAPI - #define NEAACDECAPI __cdecl - #endif -#else - #ifndef NEAACDECAPI - #define NEAACDECAPI - #endif -#endif -/* library output formats */ -#define FAAD_FMT_16BIT 1 -#define FAAD_FMT_24BIT 2 -#define FAAD_FMT_32BIT 3 -#define FAAD_FMT_FLOAT 4 -#define FAAD_FMT_FIXED FAAD_FMT_FLOAT -#define FAAD_FMT_DOUBLE 5 - - -static NeAACDecHandle (*NEAACDECAPI NeAACDecOpen_ptr)(unsigned); -#define NeAACDecOpen(a) (*NeAACDecOpen_ptr)(a) -static NeAACDecConfigurationPtr (*NEAACDECAPI NeAACDecGetCurrentConfiguration_ptr)(NeAACDecHandle hDecoder); -#define NeAACDecGetCurrentConfiguration(a) (*NeAACDecGetCurrentConfiguration_ptr)(a) -static unsigned char NEAACDECAPI (*NeAACDecSetConfiguration_ptr)(NeAACDecHandle hDecoder, - NeAACDecConfigurationPtr config); -#define NeAACDecSetConfiguration(a,b) (*NeAACDecSetConfiguration_ptr)(a,b) -static long (*NEAACDECAPI NeAACDecInit_ptr)(NeAACDecHandle hDecoder, - unsigned char *buffer, - unsigned long buffer_size, - unsigned long *samplerate, - unsigned char *channels); -#define NeAACDecInit(a,b,c,d,e) (*NeAACDecInit_ptr)(a,b,c,d,e) -static char (*NEAACDECAPI NeAACDecInit2_ptr)(NeAACDecHandle hDecoder, unsigned char *pBuffer, - unsigned long SizeOfDecoderSpecificInfo, - unsigned long *samplerate, unsigned char *channels); -#define NeAACDecInit2(a,b,c,d,e) (*NeAACDecInit2_ptr)(a,b,c,d,e) - -static void (*NEAACDECAPI NeAACDecClose_ptr)(NeAACDecHandle hDecoder); -#define NeAACDecClose(a) (*NeAACDecClose_ptr)(a) -static any_t* (*NEAACDECAPI NeAACDecDecode_ptr)(NeAACDecHandle hDecoder, - NeAACDecFrameInfo *hInfo, - unsigned char *buffer, - unsigned long buffer_size); -#define NeAACDecDecode(a,b,c,d) (*NeAACDecDecode_ptr)(a,b,c,d) -static char* (*NEAACDECAPI NeAACDecGetErrorMessage_ptr)(unsigned char errcode); -#define NeAACDecGetErrorMessage(a) (*NeAACDecGetErrorMessage_ptr)(a) - -//#define AAC_DUMP_COMPRESSED - -static NeAACDecHandle NeAAC_hdec; -static NeAACDecFrameInfo NeAAC_finfo; - -static any_t*dll_handle; -static MPXP_Rc load_dll(const char *libname) -{ - if(!(dll_handle=ld_codec(libname,mpcodecs_ad_faad.info->url))) return 0; - NeAACDecOpen_ptr = ld_sym(dll_handle,"NeAACDecOpen"); - NeAACDecGetCurrentConfiguration_ptr = ld_sym(dll_handle,"NeAACDecGetCurrentConfiguration"); - NeAACDecSetConfiguration_ptr = ld_sym(dll_handle,"NeAACDecSetConfiguration"); - NeAACDecInit_ptr = ld_sym(dll_handle,"NeAACDecInit"); - NeAACDecInit2_ptr = ld_sym(dll_handle,"NeAACDecInit2"); - NeAACDecClose_ptr = ld_sym(dll_handle,"NeAACDecClose"); - NeAACDecDecode_ptr = ld_sym(dll_handle,"NeAACDecDecode"); - NeAACDecGetErrorMessage_ptr = ld_sym(dll_handle,"NeAACDecGetErrorMessage"); - return (NeAACDecOpen_ptr && NeAACDecGetCurrentConfiguration_ptr && - NeAACDecInit_ptr && NeAACDecInit2_ptr && NeAACDecGetCurrentConfiguration_ptr && - NeAACDecClose_ptr && NeAACDecDecode_ptr && NeAACDecGetErrorMessage_ptr)? - MPXP_Ok:MPXP_False; - -} - -static MPXP_Rc preinit(sh_audio_t *sh) -{ - sh->audio_out_minsize=8192*FAAD_MAX_CHANNELS; - sh->audio_in_minsize=FAAD_BUFFLEN; - if(!(sh->context=mp_malloc(sizeof(priv_t)))) return MPXP_False; - return load_dll("libfaad"SLIBSUFFIX); -} - -static MPXP_Rc init(sh_audio_t *sh) -{ - unsigned long NeAAC_samplerate; - unsigned char NeAAC_channels; - float pts; - int NeAAC_init; - NeAACDecConfigurationPtr NeAAC_conf; - if(!(NeAAC_hdec = NeAACDecOpen(MPXPCtx->mplayer_accel))) { - MSG_WARN("FAAD: Failed to open the decoder!\n"); // XXX: deal with cleanup! - return MPXP_False; - } - // If we don't get the ES descriptor, try manual config - if(!sh->codecdata_len && sh->wf) { - sh->codecdata_len = sh->wf->cbSize; - sh->codecdata = (char*)(sh->wf+1); - MSG_DBG2("FAAD: codecdata extracted from WAVEFORMATEX\n"); - } - NeAAC_conf = NeAACDecGetCurrentConfiguration(NeAAC_hdec); - if(sh->rate) NeAAC_conf->defSampleRate = sh->rate; -#ifdef WORDS_BIGENDIAN -#define NeAAC_FMT32 AFMT_S32_BE -#define NeAAC_FMT24 AFMT_S24_BE -#define NeAAC_FMT16 AFMT_S16_BE -#else -#define NeAAC_FMT32 AFMT_S32_LE -#define NeAAC_FMT24 AFMT_S24_LE -#define NeAAC_FMT16 AFMT_S16_LE -#endif - /* Set the maximal quality */ - /* This is useful for expesive audio cards */ - if(af_query_fmt(sh->afilter,AFMT_FLOAT32) == MPXP_Ok || - af_query_fmt(sh->afilter,NeAAC_FMT32) == MPXP_Ok || - af_query_fmt(sh->afilter,NeAAC_FMT24) == MPXP_Ok) { - sh->afmt=AFMT_FLOAT32; - NeAAC_conf->outputFormat=FAAD_FMT_FLOAT; - } else { - sh->afmt=NeAAC_FMT16; - NeAAC_conf->outputFormat=FAAD_FMT_16BIT; - } - /* Set the default object type and samplerate */ - NeAACDecSetConfiguration(NeAAC_hdec, NeAAC_conf); - if(!sh->codecdata_len) { - sh->a_in_buffer_len = demux_read_data_r(sh->ds, sh->a_in_buffer, sh->a_in_buffer_size,&pts); - /* init the codec */ - NeAAC_init = NeAACDecInit(NeAAC_hdec, sh->a_in_buffer, - sh->a_in_buffer_len, &NeAAC_samplerate, - &NeAAC_channels); - sh->a_in_buffer_len -= (NeAAC_init > 0)?NeAAC_init:0; // how many bytes init consumed - // XXX FIXME: shouldn't we memcpy() here in a_in_buffer ?? --A'rpi - } else { // We have ES DS in codecdata - NeAAC_init = NeAACDecInit2(NeAAC_hdec, sh->codecdata, - sh->codecdata_len, - &NeAAC_samplerate, - &NeAAC_channels); - } - if(NeAAC_init < 0) { - MSG_WARN("FAAD: Failed to initialize the decoder!\n"); // XXX: deal with cleanup! - NeAACDecClose(NeAAC_hdec); - // XXX: mp_free a_in_buffer here or in uninit? - return MPXP_False; - } else { - NeAAC_conf = NeAACDecGetCurrentConfiguration(NeAAC_hdec); - sh->nch = NeAAC_channels; - sh->rate = NeAAC_samplerate; - switch(NeAAC_conf->outputFormat){ - default: - case FAAD_FMT_16BIT: sh->afmt=bps2afmt(2); break; - case FAAD_FMT_24BIT: sh->afmt=bps2afmt(3); break; - case FAAD_FMT_FLOAT: - case FAAD_FMT_32BIT: sh->afmt=bps2afmt(4); break; - } - MSG_V("FAAD: Decoder init done (%dBytes)!\n", sh->a_in_buffer_len); // XXX: remove or move to debug! - MSG_V("FAAD: Negotiated samplerate: %dHz channels: %d bps: %d\n", NeAAC_samplerate, NeAAC_channels,afmt2bps(sh->afmt)); - //sh->o_bps = sh->samplesize*NeAAC_channels*NeAAC_samplerate; - if(!sh->i_bps) { - MSG_WARN("FAAD: compressed input bitrate missing, assuming 128kbit/s!\n"); - sh->i_bps = 128*1000/8; // XXX: HACK!!! ::atmos - } else MSG_V("FAAD: got %dkbit/s bitrate from MP4 header!\n",sh->i_bps*8/1000); - } - return MPXP_Ok; -} - -static void uninit(sh_audio_t *sh) -{ - MSG_V("FAAD: Closing decoder!\n"); - NeAACDecClose(NeAAC_hdec); - mp_free(sh->context); -} - -static MPXP_Rc control(sh_audio_t *sh,int cmd,any_t* arg, ...) -{ - UNUSED(sh); - UNUSED(cmd); - UNUSED(arg); - return MPXP_Unknown; -} - -static unsigned decode(sh_audio_t *sh,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) -{ - priv_t *priv=sh->context; - int j = 0; - unsigned len = 0; - any_t*NeAAC_sample_buffer; - UNUSED(maxlen); - while(len < minlen) { - - /* update buffer for raw aac streams: */ - if(!sh->codecdata_len) - { - if(sh->a_in_buffer_len < sh->a_in_buffer_size){ - sh->a_in_buffer_len += - demux_read_data_r(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len], - sh->a_in_buffer_size - sh->a_in_buffer_len,pts); - *pts=FIX_APTS(sh,*pts,-sh->a_in_buffer_len); - priv->pts=*pts; - } - else *pts=priv->pts; -#ifdef DUMP_AAC_COMPRESSED - {unsigned i; - for (i = 0; i < 16; i++) - printf ("%02X ", sh->a_in_buffer[i]); - printf ("\n");} -#endif - } - if(!sh->codecdata_len){ - // raw aac stream: - do { - NeAAC_sample_buffer = NeAACDecDecode(NeAAC_hdec, &NeAAC_finfo, sh->a_in_buffer+j, sh->a_in_buffer_len); - - /* update buffer index after NeAACDecDecode */ - if(NeAAC_finfo.bytesconsumed >= (unsigned)sh->a_in_buffer_len) { - sh->a_in_buffer_len=0; - } else { - sh->a_in_buffer_len-=NeAAC_finfo.bytesconsumed; - memcpy(sh->a_in_buffer,&sh->a_in_buffer[NeAAC_finfo.bytesconsumed],sh->a_in_buffer_len); - priv->pts=FIX_APTS(sh,priv->pts,NeAAC_finfo.bytesconsumed); - } - - if(NeAAC_finfo.error > 0) { - MSG_WARN("FAAD: error: %s, trying to resync!\n", - NeAACDecGetErrorMessage(NeAAC_finfo.error)); - j++; - } else - break; - } while(j < FAAD_BUFFLEN); - } else { - // packetized (.mp4) aac stream: - unsigned char* bufptr=NULL; - int buflen=ds_get_packet_r(sh->ds, &bufptr,pts); - if(buflen<=0) break; - NeAAC_sample_buffer = NeAACDecDecode(NeAAC_hdec, &NeAAC_finfo, bufptr, buflen); -// printf("NeAAC decoded %d of %d (err: %d) \n",NeAAC_finfo.bytesconsumed,buflen,NeAAC_finfo.error); - } - - if(NeAAC_finfo.error > 0) { - MSG_WARN("FAAD: Failed to decode frame: %s \n", - NeAACDecGetErrorMessage(NeAAC_finfo.error)); - } else if (NeAAC_finfo.samples == 0) { - MSG_DBG2("FAAD: Decoded zero samples!\n"); - } else { - /* XXX: samples already multiplied by channels! */ - MSG_DBG2("FAAD: Successfully decoded frame (%d Bytes)!\n", - afmt2bps(sh->afmt)*NeAAC_finfo.samples); - memcpy(buf+len,NeAAC_sample_buffer, afmt2bps(sh->afmt)*NeAAC_finfo.samples); - len += afmt2bps(sh->afmt)*NeAAC_finfo.samples; - //printf("FAAD: buffer: %d bytes consumed: %d \n", k, NeAAC_finfo.bytesconsumed); - } - } - return len; -} - Copied: mplayerxp/libmpcodecs/ad_faad.cpp (from rev 374, mplayerxp/libmpcodecs/ad_faad.c) =================================================================== --- mplayerxp/libmpcodecs/ad_faad.cpp (rev 0) +++ mplayerxp/libmpcodecs/ad_faad.cpp 2012-11-18 12:13:12 UTC (rev 403) @@ -0,0 +1,360 @@ +/* ad_faad.c - MPlayer AAC decoder using libfaad2 + * This file is part of MPlayer, see http://mplayerhq.hu/ for info. + * (c)2002 by Felix Buenemann <atmosfear at users.sourceforge.net> + * File licensed under the GPL, see http://www.fsf.org/ for more info. + */ +#include "mp_config.h" + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ +#include "help_mp.h" +#include "osdep/bswap.h" +#include "codecs_ld.h" +#include "mp_config.h" +#include "ad_internal.h" +#include "mplayerxp.h" +#include "osdep/cpudetect.h" +#include "osdep/mm_accel.h" +#include "osdep/mplib.h" +#include "libao2/afmt.h" +#include "libao2/audio_out.h" +#include "postproc/af.h" + +static const ad_info_t info = { + "AAC (MPEG2/4 Advanced Audio Coding)", + "faad", + "Felix Buenemann", + "http://www.audiocoding.com/faad2.html" +}; + +static const config_t options[] = { + { NULL, NULL, 0, 0, 0, 0, NULL} +}; + +LIBAD_EXTERN(faad) + +typedef struct faad_priv_s { + float pts; +}priv_t; + +static const audio_probe_t probes[] = { + { "faad", "libfaad", 0xFF, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "faad", "libfaad", 0x4143, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "faad", "libfaad", 0x706D, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "faad", "libfaad", 0xA106, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "faad", "libfaad", 0xAAC0, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "faad", "libfaad", FOURCC_TAG('A','A','C',' '), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "faad", "libfaad", FOURCC_TAG('A','A','C','P'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "faad", "libfaad", FOURCC_TAG('M','P','4','A'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "faad", "libfaad", FOURCC_TAG('M','P','4','L'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "faad", "libfaad", FOURCC_TAG('M','P','4','A'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "faad", "libfaad", FOURCC_TAG('R','A','A','C'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "faad", "libfaad", FOURCC_TAG('R','A','A','P'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { "faad", "libfaad", FOURCC_TAG('V','L','B',' '), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, + { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} +}; + +static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { + UNUSED(sh); + unsigned i; + for(i=0;probes[i].driver;i++) + if(wtag==probes[i].wtag) + return &probes[i]; + return NULL; +} + +typedef any_t*NeAACDecHandle; +typedef struct NeAACDecConfiguration { + unsigned char defObjectType; + unsigned long defSampleRate; + unsigned char outputFormat; + unsigned char downMatrix; + unsigned char useOldADTSFormat; + unsigned char dontUpSampleImplicitSBR; +} NeAACDecConfiguration, *NeAACDecConfigurationPtr; +struct NeAACDecFrameInfo; + +typedef struct NeAACDecFrameInfo { + unsigned long bytesconsumed; + unsigned long samples; + unsigned char channels; + unsigned char error; + unsigned long samplerate; + + /* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */ + unsigned char sbr; + + /* MPEG-4 ObjectType */ + unsigned char object_type; + + /* AAC header type; MP4 will be signalled as RAW also */ + unsigned char header_type; + + /* multichannel configuration */ + unsigned char num_front_channels; + unsigned char num_side_channels; + unsigned char num_back_channels; + unsigned char num_lfe_channels; + unsigned char channel_position[64]; + + /* PS: 0: off, 1: on */ + unsigned char ps; +} NeAACDecFrameInfo; +#define FAAD_MIN_STREAMSIZE 768 /* 6144 bits/channel */ +/* configure maximum supported channels, * + * this is theoretically max. 64 chans */ +#define FAAD_MAX_CHANNELS 6 +#define FAAD_BUFFLEN (FAAD_MIN_STREAMSIZE*FAAD_MAX_CHANNELS) +#ifdef _WIN32 + #pragma pack(push, 8) + #ifndef NEAACDECAPI + #define NEAACDECAPI __cdecl + #endif +#else + #ifndef NEAACDECAPI + #define NEAACDECAPI + #endif +#endif +/* library output formats */ +#define FAAD_FMT_16BIT 1 +#define FAAD_FMT_24BIT 2 +#define FAAD_FMT_32BIT 3 +#define FAAD_FMT_FLOAT 4 +#define FAAD_FMT_FIXED FAAD_FMT_FLOAT +#define FAAD_FMT_DOUBLE 5 + + +static NeAACDecHandle (*NEAACDECAPI NeAACDecOpen_ptr)(unsigned); +#define NeAACDecOpen(a) (*NeAACDecOpen_ptr)(a) +static NeAACDecConfigurationPtr (*NEAACDECAPI NeAACDecGetCurrentConfiguration_ptr)(NeAACDecHandle hDecoder); +#define NeAACDecGetCurrentConfiguration(a) (*NeAACDecGetCurrentConfiguration_ptr)(a) +static unsigned char NEAACDECAPI (*NeAACDecSetConfiguration_ptr)(NeAACDecHandle hDecoder, + NeAACDecConfigurationPtr config); +#define NeAACDecSetConfiguration(a,b) (*NeAACDecSetConfiguration_ptr)(a,b) +static long (*NEAACDECAPI NeAACDecInit_ptr)(NeAACDecHandle hDecoder, + unsigned char *buffer, + unsigned long buffer_size, + unsigned long *samplerate, + unsigned char *channels); +#define NeAACDecInit(a,b,c,d,e) (*NeAACDecInit_ptr)(a,b,c,d,e) +static char (*NEAACDECAPI NeAACDecInit2_ptr)(NeAACDecHandle hDecoder, unsigned char *pBuffer, + unsigned long SizeOfDecoderSpecificInfo, + unsigned long *samplerate, unsigned char *channels); +#define NeAACDecInit2(a,b,c,d,e) (*NeAACDecInit2_ptr)(a,b,c,d,e) + +static void (*NEAACDECAPI NeAACDecClose_ptr)(NeAACDecHandle hDecoder); +#define NeAACDecClose(a) (*NeAACDecClose_ptr)(a) +static any_t* (*NEAACDECAPI NeAACDecDecode_ptr)(NeAACDecHandle hDecoder, + NeAACDecFrameInfo *hInfo, + unsigned char *buffer, + unsigned long buffer_size); +#define NeAACDecDecode(a,b,c,d) (*NeAACDecDecode_ptr)(a,b,c,d) +static char* (*NEAACDECAPI NeAACDecGetErrorMessage_ptr)(unsigned char errcode); +#define NeAACDecGetErrorMessage(a) (*NeAACDecGetErrorMessage_ptr)(a) + +//#define AAC_DUMP_COMPRESSED + +static NeAACDecHandle NeAAC_hdec; +static NeAACDecFrameInfo NeAAC_finfo; + +static any_t*dll_handle; +static MPXP_Rc load_dll(const char *libname) +{ + if(!(dll_handle=ld_codec(libname,mpcodecs_ad_faad.info->url))) return MPXP_False; + NeAACDecOpen_ptr = (any_t* (*)(unsigned))ld_sym(dll_handle,"NeAACDecOpen"); + NeAACDecGetCurrentConfiguration_ptr = (NeAACDecConfiguration* (*)(any_t*))ld_sym(dll_handle,"NeAACDecGetCurrentConfiguration"); + NeAACDecSetConfiguration_ptr = (unsigned char (*)(any_t*,NeAACDecConfiguration*))ld_sym(dll_handle,"NeAACDecSetConfiguration"); + NeAACDecInit_ptr = (long (*)(any_t*,unsigned char*,unsigned long,unsigned long*,unsigned char*))ld_sym(dll_handle,"NeAACDecInit"); + NeAACDecInit2_ptr = (char (*)(any_t*,unsigned char *,unsigned long,unsigned long*,unsigned char*))ld_sym(dll_handle,"NeAACDecInit2"); + NeAACDecClose_ptr = (void (*)(any_t*))ld_sym(dll_handle,"NeAACDecClose"); + NeAACDecDecode_ptr = (any_t* (*)(any_t*,NeAACDecFrameInfo*,unsigned char *,unsigned long))ld_sym(dll_handle,"NeAACDecDecode"); + NeAACDecGetErrorMessage_ptr = (char* (*)(unsigned char))ld_sym(dll_handle,"NeAACDecGetErrorMessage"); + return (NeAACDecOpen_ptr && NeAACDecGetCurrentConfiguration_ptr && + NeAACDecInit_ptr && NeAACDecInit2_ptr && NeAACDecGetCurrentConfiguration_ptr && + NeAACDecClose_ptr && NeAACDecDecode_ptr && NeAACDecGetErrorMessage_ptr)? + MPXP_Ok:MPXP_False; + +} + +static MPXP_Rc preinit(sh_audio_t *sh) +{ + sh->audio_out_minsize=8192*FAAD_MAX_CHANNELS; + sh->audio_in_minsize=FAAD_BUFFLEN; + if(!(sh->context=mp_malloc(sizeof(priv_t)))) return MPXP_False; + return load_dll("libfaad"SLIBSUFFIX); +} + +static MPXP_Rc init(sh_audio_t *sh) +{ + unsigned long NeAAC_samplerate; + unsigned char NeAAC_channels; + float pts; + int NeAAC_init; + NeAACDecConfigurationPtr NeAAC_conf; + if(!(NeAAC_hdec = NeAACDecOpen(MPXPCtx->mplayer_accel))) { + MSG_WARN("FAAD: Failed to open the decoder!\n"); // XXX: deal with cleanup! + return MPXP_False; + } + // If we don't get the ES descriptor, try manual config + if(!sh->codecdata_len && sh->wf) { + sh->codecdata_len = sh->wf->cbSize; + sh->codecdata = (unsigned char*)(sh->wf+1); + MSG_DBG2("FAAD: codecdata extracted from WAVEFORMATEX\n"); + } + NeAAC_conf = NeAACDecGetCurrentConfiguration(NeAAC_hdec); + if(sh->rate) NeAAC_conf->defSampleRate = sh->rate; +#ifdef WORDS_BIGENDIAN +#define NeAAC_FMT32 AFMT_S32_BE +#define NeAAC_FMT24 AFMT_S24_BE +#define NeAAC_FMT16 AFMT_S16_BE +#else +#define NeAAC_FMT32 AFMT_S32_LE +#define NeAAC_FMT24 AFMT_S24_LE +#define NeAAC_FMT16 AFMT_S16_LE +#endif + /* Set the maximal quality */ + /* This is useful for expesive audio cards */ + if(af_query_fmt(sh->afilter,mpaf_format_decode(AFMT_FLOAT32)) == MPXP_Ok || + af_query_fmt(sh->afilter,mpaf_format_decode(NeAAC_FMT32)) == MPXP_Ok || + af_query_fmt(sh->afilter,mpaf_format_decode(NeAAC_FMT24)) == MPXP_Ok) { + sh->afmt=AFMT_FLOAT32; + NeAAC_conf->outputFormat=FAAD_FMT_FLOAT; + } else { + sh->afmt=NeAAC_FMT16; + NeAAC_conf->outputFormat=FAAD_FMT_16BIT; + } + /* Set the default object type and samplerate */ + NeAACDecSetConfiguration(NeAAC_hdec, NeAAC_conf); + if(!sh->codecdata_len) { + sh->a_in_buffer_len = demux_read_data_r(sh->ds, reinterpret_cast<unsigned char*>(sh->a_in_buffer), sh->a_in_buffer_size,&pts); + /* init the codec */ + NeAAC_init = NeAACDecInit(NeAAC_hdec, reinterpret_cast<unsigned char*>(sh->a_in_buffer), + sh->a_in_buffer_len, &NeAAC_samplerate, + &NeAAC_channels); + sh->a_in_buffer_len -= (NeAAC_init > 0)?NeAAC_init:0; // how many bytes init consumed + // XXX FIXME: shouldn't we memcpy() here in a_in_buffer ?? --A'rpi + } else { // We have ES DS in codecdata + NeAAC_init = NeAACDecInit2(NeAAC_hdec, sh->codecdata, + sh->codecdata_len, + &NeAAC_samplerate, + &NeAAC_channels); + } + if(NeAAC_init < 0) { + MSG_WARN("FAAD: Failed to initialize the decoder!\n"); // XXX: deal with cleanup! + NeAACDecClose(NeAAC_hdec); + // XXX: mp_free a_in_buffer here or in uninit? + return MPXP_False; + } else { + NeAAC_conf = NeAACDecGetCurrentConfiguration(NeAAC_hdec); + sh->nch = NeAAC_channels; + sh->rate = NeAAC_samplerate; + switch(NeAAC_conf->outputFormat){ + default: + case FAAD_FMT_16BIT: sh->afmt=bps2afmt(2); break; + case FAAD_FMT_24BIT: sh->afmt=bps2afmt(3); break; + case FAAD_FMT_FLOAT: + case FAAD_FMT_32BIT: sh->afmt=bps2afmt(4); break; + } + MSG_V("FAAD: Decoder init done (%dBytes)!\n", sh->a_in_buffer_len); // XXX: remove or move to debug! + MSG_V("FAAD: Negotiated samplerate: %dHz channels: %d bps: %d\n", NeAAC_samplerate, NeAAC_channels,afmt2bps(sh->afmt)); + //sh->o_bps = sh->samplesize*NeAAC_channels*NeAAC_samplerate; + if(!sh->i_bps) { + MSG_WARN("FAAD: compressed input bitrate missing, assuming 128kbit/s!\n"); + sh->i_bps = 128*1000/8; // XXX: HACK!!! ::atmos + } else MSG_V("FAAD: got %dkbit/s bitrate from MP4 header!\n",sh->i_bps*8/1000); + } + return MPXP_Ok; +} + +static void uninit(sh_audio_t *sh) +{ + MSG_V("FAAD: Closing decoder!\n"); + NeAACDecClose(NeAAC_hdec); + mp_free(sh->context); +} + +static MPXP_Rc control(sh_audio_t *sh,int cmd,any_t* arg, ...) +{ + UNUSED(sh); + UNUSED(cmd); + UNUSED(arg); + return MPXP_Unknown; +} + +static unsigned decode(sh_audio_t *sh,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +{ + priv_t *priv=reinterpret_cast<priv_t*>(sh->context); + int j = 0; + unsigned len = 0; + any_t*NeAAC_sample_buffer; + UNUSED(maxlen); + while(len < minlen) { + + /* update buffer for raw aac streams: */ + if(!sh->codecdata_len) + { + if(sh->a_in_buffer_len < sh->a_in_buffer_size){ + sh->a_in_buffer_len += + demux_read_data_r(sh->ds,reinterpret_cast<unsigned char*>(&sh->a_in_buffer[sh->a_in_buffer_len]), + sh->a_in_buffer_size - sh->a_in_buffer_len,pts); + *pts=FIX_APTS(sh,*pts,-sh->a_in_buffer_len); + priv->pts=*pts; + } + else *pts=priv->pts; +#ifdef DUMP_AAC_COMPRESSED + {unsigned i; + for (i = 0; i < 16; i++) + printf ("%02X ", sh->a_in_buffer[i]); + printf ("\n");} +#endif + } + if(!sh->codecdata_len){ + // raw aac stream: + do { + NeAAC_sample_buffer = NeAACDecDecode(NeAAC_hdec, &NeAAC_finfo, reinterpret_cast<unsigned char *>(sh->a_in_buffer+j), sh->a_in_buffer_len); + + /* update buffer index after NeAACDecDecode */ + if(NeAAC_finfo.bytesconsumed >= (unsigned)sh->a_in_buffer_len) { + sh->a_in_buffer_len=0; + } else { + sh->a_in_buffer_len-=NeAAC_finfo.bytesconsumed; + memcpy(sh->a_in_buffer,&sh->a_in_buffer[NeAAC_finfo.bytesconsumed],sh->a_in_buffer_len); + priv->pts=FIX_APTS(sh,priv->pts,NeAAC_finfo.bytesconsumed); + } + + if(NeAAC_finfo.error > 0) { + MSG_WARN("FAAD: error: %s, trying to resync!\n", + NeAACDecGetErrorMessage(NeAAC_finfo.error)); + j++; + } else + break; + } while(j < FAAD_BUFFLEN); + } else { + // packetized (.mp4) aac stream: + unsigned char* bufptr=NULL; + int buflen=ds_get_packet_r(sh->ds, &bufptr,pts); + if(buflen<=0) break; + NeAAC_sample_buffer = NeAACDecDecode(NeAAC_hdec, &NeAAC_finfo, bufptr, buflen); +// printf("NeAAC decoded %d of %d (err: %d) \n",NeAAC_finfo.bytesconsumed,buflen,NeAAC_finfo.error); + } + + if(NeAAC_finfo.error > 0) { + MSG_WARN("FAAD: Failed to decode frame: %s \n", + NeAACDecGetErrorMessage(NeAAC_finfo.error)); + } else if (NeAAC_finfo.samples == 0) { + MSG_DBG2("FAAD: Decoded zero samples!\n"); + } else { + /* XXX: samples already multiplied by channels! */ + MSG_DBG2("FAAD: Successfully decoded frame (%d Bytes)!\n", + afmt2bps(sh->afmt)*NeAAC_finfo.samples); + memcpy(buf+len,NeAAC_sample_buffer, afmt2bps(sh->afmt)*NeAAC_finfo.samples); + len += afmt2bps(sh->afmt)*NeAAC_finfo.samples; + //printf("FAAD: buffer: %d bytes consumed: %d \n", k, NeAAC_finfo.bytesconsumed); + } + } + return len; +} + Deleted: mplayerxp/libmpcodecs/ad_ffmpeg.c =================================================================== --- mplayerxp/libmpcodecs/ad_ffmpeg.c 2012-11-18 06:17:26 UTC (rev 402) +++ mplayerxp/libmpcodecs/ad_ffmpeg.c 2012-11-18 12:13:12 UTC (rev 403) @@ -1,231 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#define __USE_GNU 1 -#define __USE_XOPEN 1 -#include <unistd.h> -#include <assert.h> -#include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ -#include "libao2/afmt.h" -#include "ad_internal.h" - -#include "mp_config.h" -#include "help_mp.h" -#include "osdep/bswap.h" -#include "osdep/mplib.h" -#include "libmpconf/codec-cfg.h" - -#define FF_API_OLD_DECODE_AUDIO 1 -#include "libavcodec/avcodec.h" -#include "libavformat/riff.h" -#include "codecs_ld.h" - -typedef struct priv_s { - AVCodecContext *lavc_ctx; - audio_probe_t* probe; -}priv_t; - -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { - unsigned i; - audio_probe_t* acodec = NULL; - const char *what="AVCodecID"; - priv_t* priv=sh->context; - enum AVCodecID id = ff_codec_get_id(ff_codec_wav_tags,wtag); - if (id <= 0) { - prn_err: - MSG_ERR("Cannot find %s for '0x%X' tag! Try force -ac option\n" - ,what - ,sh->wtag); - return NULL; - } - if(!priv){ - priv=mp_mallocz(sizeof(priv_t)); - sh->context=priv; -// avcodec_init(); - avcodec_register_all(); - } - AVCodec *codec=avcodec_find_decoder(id); - if(!codec) { what="AVCodec"; goto prn_err; } - - acodec=mp_mallocz(sizeof(audio_probe_t)); - acodec->codec_dll=mp_strdup(avcodec_get_name(id)); - acodec->driver="ffmpeg"; - acodec->wtag=wtag; - if(codec->sample_fmts) - for(i=0;i<Audio_MaxOutSample;i++) { - if(codec->sa... [truncated message content] |
From: <nic...@us...> - 2012-11-18 12:16:44
|
Revision: 404 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=404&view=rev Author: nickols_k Date: 2012-11-18 12:16:37 +0000 (Sun, 18 Nov 2012) Log Message: ----------- formating Modified Paths: -------------- mplayerxp/libao2/ao_null.c mplayerxp/libvo/vo_null.c Modified: mplayerxp/libao2/ao_null.c =================================================================== --- mplayerxp/libao2/ao_null.c 2012-11-18 12:13:12 UTC (rev 403) +++ mplayerxp/libao2/ao_null.c 2012-11-18 12:16:37 UTC (rev 404) @@ -15,12 +15,11 @@ #include "audio_out_internal.h" #include "ao_msg.h" -static ao_info_t info = -{ - "Null audio output", - "null", - "Tobias Diedrich", - "" +static ao_info_t info = { + "Null audio output", + "null", + "Tobias Diedrich", + "" }; LIBAO_EXTERN(null) @@ -59,20 +58,20 @@ /* init with default values */ static struct WaveHeader wavhdr = { - WAV_ID_RIFF, - /* same conventions than in sox/wav.c/wavwritehdr() */ - 0, //le2me_32(0x7ffff024), - WAV_ID_WAVE, - WAV_ID_FMT, - 16, - WAV_ID_PCM, - 2, - 44100, - 192000, - 4, - 16, - WAV_ID_DATA, - 0, //le2me_32(0x7ffff000) + WAV_ID_RIFF, + /* same conventions than in sox/wav.c/wavwritehdr() */ + 0, //le2me_32(0x7ffff024), + WAV_ID_WAVE, + WAV_ID_FMT, + 16, + WAV_ID_PCM, + 2, + 44100, + 192000, + 4, + 16, + WAV_ID_DATA, + 0, //le2me_32(0x7ffff000) }; static void drain(const ao_data_t* ao){ Modified: mplayerxp/libvo/vo_null.c =================================================================== --- mplayerxp/libvo/vo_null.c 2012-11-18 12:13:12 UTC (rev 403) +++ mplayerxp/libvo/vo_null.c 2012-11-18 12:16:37 UTC (rev 404) @@ -1,7 +1,7 @@ /* * video_out_null.c * - * Copyright (C) Aaron Holtzman - June 2000 + * Copyright (C) Aaron Holtzman - June 2000 * * This file is part of mpeg2dec, a mp_free MPEG-2 video stream decoder. * @@ -40,12 +40,11 @@ LIBVO_EXTERN(null) -static vo_info_t vo_info = -{ - "Null video output", - "null", - "Aaron Holtzman <aho...@es...>", - "" +static vo_info_t vo_info = { + "Null video output", + "null", + "Aaron Holtzman <aho...@es...>", + "" }; typedef struct priv_s { @@ -226,7 +225,7 @@ static MPXP_Rc __FASTCALL__ control(vo_data_t*vo,uint32_t request, any_t*data) { priv_t*priv=(priv_t*)vo->priv; - switch (request) { + switch (request) { case VOCTRL_QUERY_FORMAT: return null_query_format(data); case VOCTRL_GET_NUM_FRAMES: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-11-18 12:37:19
|
Revision: 406 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=406&view=rev Author: nickols_k Date: 2012-11-18 12:37:12 +0000 (Sun, 18 Nov 2012) Log Message: ----------- improve readability Modified Paths: -------------- mplayerxp/libmpcodecs/ad_dca.cpp mplayerxp/libmpcodecs/ad_faad.cpp mplayerxp/libmpcodecs/dec_audio.cpp mplayerxp/libmpdemux/s_oss.c mplayerxp/postproc/af.cpp mplayerxp/postproc/af_ao2.cpp mplayerxp/postproc/af_ffenc.cpp mplayerxp/xmpcore/mp_aframe.cpp mplayerxp/xmpcore/mp_aframe.h Modified: mplayerxp/libmpcodecs/ad_dca.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dca.cpp 2012-11-18 12:30:09 UTC (rev 405) +++ mplayerxp/libmpcodecs/ad_dca.cpp 2012-11-18 12:37:12 UTC (rev 406) @@ -137,9 +137,9 @@ #define DCA_FMT24 AFMT_S24_LE #endif sh->afmt=bps2afmt(2); - if( af_query_fmt(sh->afilter,mpaf_format_decode(AFMT_FLOAT32)) == MPXP_Ok|| - af_query_fmt(sh->afilter,mpaf_format_decode(DCA_FMT32)) == MPXP_Ok || - af_query_fmt(sh->afilter,mpaf_format_decode(DCA_FMT24)) == MPXP_Ok) + if( af_query_fmt(sh->afilter,afmt2mpaf(AFMT_FLOAT32)) == MPXP_Ok|| + af_query_fmt(sh->afilter,afmt2mpaf(DCA_FMT32)) == MPXP_Ok || + af_query_fmt(sh->afilter,afmt2mpaf(DCA_FMT24)) == MPXP_Ok) { sh->afmt=AFMT_FLOAT32; } Modified: mplayerxp/libmpcodecs/ad_faad.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_faad.cpp 2012-11-18 12:30:09 UTC (rev 405) +++ mplayerxp/libmpcodecs/ad_faad.cpp 2012-11-18 12:37:12 UTC (rev 406) @@ -217,9 +217,9 @@ #endif /* Set the maximal quality */ /* This is useful for expesive audio cards */ - if(af_query_fmt(sh->afilter,mpaf_format_decode(AFMT_FLOAT32)) == MPXP_Ok || - af_query_fmt(sh->afilter,mpaf_format_decode(NeAAC_FMT32)) == MPXP_Ok || - af_query_fmt(sh->afilter,mpaf_format_decode(NeAAC_FMT24)) == MPXP_Ok) { + if(af_query_fmt(sh->afilter,afmt2mpaf(AFMT_FLOAT32)) == MPXP_Ok || + af_query_fmt(sh->afilter,afmt2mpaf(NeAAC_FMT32)) == MPXP_Ok || + af_query_fmt(sh->afilter,afmt2mpaf(NeAAC_FMT24)) == MPXP_Ok) { sh->afmt=AFMT_FLOAT32; NeAAC_conf->outputFormat=FAAD_FMT_FLOAT; } else { Modified: mplayerxp/libmpcodecs/dec_audio.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_audio.cpp 2012-11-18 12:30:09 UTC (rev 405) +++ mplayerxp/libmpcodecs/dec_audio.cpp 2012-11-18 12:37:12 UTC (rev 406) @@ -188,12 +188,12 @@ // input format: same as codec's output format: afs->input.rate = in_samplerate; afs->input.nch = in_channels; - afs->input.format = mpaf_format_decode(in_format); + afs->input.format = afmt2mpaf(in_format); // output format: same as ao driver's input format (if missing, fallback to input) afs->output.rate = *out_samplerate ? *out_samplerate : afs->input.rate; afs->output.nch = *out_channels ? *out_channels : afs->input.nch; - if(*out_format) afs->output.format = mpaf_format_decode(*out_format); + if(*out_format) afs->output.format = afmt2mpaf(*out_format); else afs->output.format = afs->input.format; // filter config: @@ -210,7 +210,7 @@ *out_samplerate=afs->output.rate; *out_channels=afs->output.nch; - *out_format=mpaf_format_encode(afs->output.format); + *out_format=mpaf2afmt(afs->output.format); sh_audio->af_bps = afs->output.rate*afs->output.nch*(afs->output.format&MPAF_BPS_MASK); @@ -235,19 +235,19 @@ // input format: same as codec's output format: afs->input.rate = in_samplerate; afs->input.nch = in_channels; - afs->input.format = mpaf_format_decode(in_format); + afs->input.format = afmt2mpaf(in_format); // output format: same as ao driver's input format (if missing, fallback to input) afs->output.rate = out_samplerate ? out_samplerate : afs->input.rate; afs->output.nch = out_channels ? out_channels : afs->input.nch; - afs->output.format = mpaf_format_decode(out_format ? out_format : afs->input.format); + afs->output.format = afmt2mpaf(out_format ? out_format : afs->input.format); // filter config: memcpy(&afs->cfg,&af_cfg,sizeof(af_cfg_t)); MSG_V("Building audio filter chain for %dHz/%dch/%dbit (%s) -> %dHz/%dch/%dbit (%s)...\n", - afs->input.rate,afs->input.nch,(afs->input.format&MPAF_BPS_MASK)*8,ao_format_name(mpaf_format_encode(afs->input.format)), - afs->output.rate,afs->output.nch,(afs->output.format&MPAF_BPS_MASK)*8,ao_format_name(mpaf_format_encode(afs->output.format))); + afs->input.rate,afs->input.nch,(afs->input.format&MPAF_BPS_MASK)*8,ao_format_name(mpaf2afmt(afs->input.format)), + afs->output.rate,afs->output.nch,(afs->output.format&MPAF_BPS_MASK)*8,ao_format_name(mpaf2afmt(afs->output.format))); // let's autoprobe it! if(MPXP_Ok != RND_RENAME7(af_init)(afs,1)){ @@ -331,7 +331,7 @@ mp_aframe_t* pafd; // filter output afd=new_mp_aframe( sh_audio->rate, sh_audio->nch, - mpaf_format_decode(sh_audio->afmt) + afmt2mpaf(sh_audio->afmt) ,0); // xp_idx afd->audio=buf; afd->len=len; Modified: mplayerxp/libmpdemux/s_oss.c =================================================================== --- mplayerxp/libmpdemux/s_oss.c 2012-11-18 12:30:09 UTC (rev 405) +++ mplayerxp/libmpdemux/s_oss.c 2012-11-18 12:37:12 UTC (rev 406) @@ -99,7 +99,7 @@ afd.rate=oss_priv->samplerate; afd.nch=oss_priv->nchannels; afd.format=oss_priv->sampleformat; - oss_fmt=mpaf_format_encode(oss_priv->sampleformat); + oss_fmt=mpaf2afmt(oss_priv->sampleformat); tmp=oss_fmt; if(ioctl(stream->fd, SNDCTL_DSP_SETFMT, &oss_fmt)<0) MSG_ERR("[s_oss] Can't set format %s (will use %s)\n",ao_format_name(tmp),ao_format_name(oss_fmt)); Modified: mplayerxp/postproc/af.cpp =================================================================== --- mplayerxp/postproc/af.cpp 2012-11-18 12:30:09 UTC (rev 405) +++ mplayerxp/postproc/af.cpp 2012-11-18 12:37:12 UTC (rev 406) @@ -577,7 +577,7 @@ af_instance_t* filt = s?s->first:NULL; const char *filt_name=filt?filt->info->name:"ao2"; if(strcmp(filt_name,"ao2")==0) return RND_RENAME7(ao_control)(ao_data,AOCONTROL_QUERY_FORMAT,fmt); - else if(mpaf_format_decode(fmt)==filt->conf.format) return MPXP_True; + else if(afmt2mpaf(fmt)==filt->conf.format) return MPXP_True; return MPXP_False; } Modified: mplayerxp/postproc/af_ao2.cpp =================================================================== --- mplayerxp/postproc/af_ao2.cpp 2012-11-18 12:30:09 UTC (rev 405) +++ mplayerxp/postproc/af_ao2.cpp 2012-11-18 12:37:12 UTC (rev 406) @@ -117,7 +117,7 @@ if(!arg) return MPXP_Error; s->rate = af->conf.rate = find_best_rate(arg->rate); s->nch = af->conf.nch = find_best_ch(arg->nch); - s->format = af->conf.format = mpaf_format_decode(find_best_fmt(mpaf_format_encode(arg->format))); + s->format = af->conf.format = afmt2mpaf(find_best_fmt(mpaf2afmt(arg->format))); return af_test_output(af,arg); } Modified: mplayerxp/postproc/af_ffenc.cpp =================================================================== --- mplayerxp/postproc/af_ffenc.cpp 2012-11-18 12:30:09 UTC (rev 405) +++ mplayerxp/postproc/af_ffenc.cpp 2012-11-18 12:37:12 UTC (rev 406) @@ -109,7 +109,7 @@ /* correct in format */ af->conf.rate = arg->rate; af->conf.nch = arg->nch; - af->conf.format = mpaf_format_decode(find_atag(s->cname)<<16); + af->conf.format = afmt2mpaf(find_atag(s->cname)<<16); MSG_V("[af_ffenc] Was reinitialized, rate=%iHz, nch = %i, format = 0x%08X\n" ,af->conf.rate,af->conf.nch,af->conf.format); return MPXP_Ok; Modified: mplayerxp/xmpcore/mp_aframe.cpp =================================================================== --- mplayerxp/xmpcore/mp_aframe.cpp 2012-11-18 12:30:09 UTC (rev 405) +++ mplayerxp/xmpcore/mp_aframe.cpp 2012-11-18 12:37:12 UTC (rev 406) @@ -10,7 +10,7 @@ enum { AFMT_AF_FLAGS=0x70000000 }; /* Decodes the format from mplayer format to libaf format */ -mpaf_format_e __FASTCALL__ mpaf_format_decode(unsigned ifmt) +mpaf_format_e __FASTCALL__ afmt2mpaf(unsigned ifmt) { mpaf_format_e ofmt = mpaf_format_e(0); // Check input ifmt @@ -47,7 +47,7 @@ } /* Encodes the format from libaf format to mplayer (OSS) format */ -unsigned __FASTCALL__ mpaf_format_encode(mpaf_format_e fmt) +unsigned __FASTCALL__ mpaf2afmt(mpaf_format_e fmt) { switch(fmt&MPAF_SPECIAL_MASK) { case 0: // PCM: Modified: mplayerxp/xmpcore/mp_aframe.h =================================================================== --- mplayerxp/xmpcore/mp_aframe.h 2012-11-18 12:30:09 UTC (rev 405) +++ mplayerxp/xmpcore/mp_aframe.h 2012-11-18 12:37:12 UTC (rev 406) @@ -56,8 +56,8 @@ #endif /* Decodes the format from mplayer format to libaf format */ -extern mpaf_format_e __FASTCALL__ mpaf_format_decode(unsigned format); -extern unsigned __FASTCALL__ mpaf_format_encode(mpaf_format_e fmt); +extern mpaf_format_e __FASTCALL__ afmt2mpaf(unsigned format); +extern unsigned __FASTCALL__ mpaf2afmt(mpaf_format_e fmt); extern char* __FASTCALL__ mpaf_fmt2str(mpaf_format_e format, char* str, size_t size); extern mpaf_format_e __FASTCALL__ mpaf_str2fmt(const char *str); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-11-18 15:23:48
|
Revision: 408 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=408&view=rev Author: nickols_k Date: 2012-11-18 15:23:42 +0000 (Sun, 18 Nov 2012) Log Message: ----------- use universal mp_conf_lavc.h Modified Paths: -------------- mplayerxp/libmpcodecs/dec_video.cpp mplayerxp/libmpsub/spudec.cpp mplayerxp/libvo/screenshot.cpp mplayerxp/libvo/video_out.cpp mplayerxp/mplayerxp.cpp Modified: mplayerxp/libmpcodecs/dec_video.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_video.cpp 2012-11-18 13:04:09 UTC (rev 407) +++ mplayerxp/libmpcodecs/dec_video.cpp 2012-11-18 15:23:42 UTC (rev 408) @@ -32,14 +32,13 @@ #include "libmpsub/spudec.h" #include "libmpsub/vobsub.h" -// =================================================================== -vf_cfg_t vf_cfg; // Configuration for audio filters - -#define UINT64_C __UINT64_C -#include "postproc/postprocess.h" +#include "mp_conf_lavc.h" #include "osdep/cpudetect.h" #include "vd_msg.h" +// =================================================================== +vf_cfg_t vf_cfg; // Configuration for audio filters + extern int v_bright; extern int v_cont; extern int v_hue; Modified: mplayerxp/libmpsub/spudec.cpp =================================================================== --- mplayerxp/libmpsub/spudec.cpp 2012-11-18 13:04:09 UTC (rev 407) +++ mplayerxp/libmpsub/spudec.cpp 2012-11-18 15:23:42 UTC (rev 408) @@ -23,10 +23,7 @@ #include "xmpcore/xmp_core.h" #include "spudec.h" -extern "C" { -#define UINT64_C __UINT64_C -#include "postproc/swscale.h" -} +#include "mp_conf_lavc.h" #include "osdep/mplib.h" #define MSGT_CLASS MSGT_SPUDEC #include "mp_msg.h" Modified: mplayerxp/libvo/screenshot.cpp =================================================================== --- mplayerxp/libvo/screenshot.cpp 2012-11-18 13:04:09 UTC (rev 407) +++ mplayerxp/libvo/screenshot.cpp 2012-11-18 15:23:42 UTC (rev 408) @@ -25,8 +25,7 @@ #include "screenshot.h" #include "img_format.h" -#define UINT64_C __UINT64_C -#include "postproc/swscale.h" +#include "mp_conf_lavc.h" #include "postproc/vf_scale.h" #include "osdep/mplib.h" #include "vo_msg.h" Modified: mplayerxp/libvo/video_out.cpp =================================================================== --- mplayerxp/libvo/video_out.cpp 2012-11-18 13:04:09 UTC (rev 407) +++ mplayerxp/libvo/video_out.cpp 2012-11-18 15:23:42 UTC (rev 408) @@ -32,8 +32,7 @@ #include "video_out.h" #include "osdep/shmem.h" -#define UINT64_C __UINT64_C -#include "postproc/swscale.h" +#include "mp_conf_lavc.h" #include "postproc/vf.h" #include "xmpcore/xmp_core.h" #include "osdep/mplib.h" Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-11-18 13:04:09 UTC (rev 407) +++ mplayerxp/mplayerxp.cpp 2012-11-18 15:23:42 UTC (rev 408) @@ -28,7 +28,6 @@ #include "osdep/mplib.h" #include "xmpcore/sig_hand.h" -#define UINT64_C __UINT64_C #include "postproc/swscale.h" #include "postproc/af.h" #include "postproc/vf.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-11-19 12:50:53
|
Revision: 409 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=409&view=rev Author: nickols_k Date: 2012-11-19 12:50:35 +0000 (Mon, 19 Nov 2012) Log Message: ----------- separate libmpdemux and libmpstream Modified Paths: -------------- mplayerxp/Makefile mplayerxp/configure mplayerxp/dump.cpp mplayerxp/input2/input.cpp mplayerxp/libao2/ao_alsa9.c mplayerxp/libao2/ao_null.c mplayerxp/libmpcodecs/ad.cpp mplayerxp/libmpcodecs/ad_internal.h mplayerxp/libmpcodecs/ad_libdv.c mplayerxp/libmpcodecs/dec_audio.cpp mplayerxp/libmpcodecs/dec_video.cpp mplayerxp/libmpcodecs/dec_video.h mplayerxp/libmpcodecs/vd.cpp mplayerxp/libmpcodecs/vd_internal.h mplayerxp/libmpcodecs/vd_libdv.c mplayerxp/libmpconf/cfgparser.cpp mplayerxp/libmpconf/m_option.cpp mplayerxp/libmpdemux/Makefile mplayerxp/libmpdemux/aviprint.c mplayerxp/libmpdemux/demux_aiff.c mplayerxp/libmpdemux/demux_asf.c mplayerxp/libmpdemux/demux_audio.c mplayerxp/libmpdemux/demux_avi.c mplayerxp/libmpdemux/demux_bmp.c mplayerxp/libmpdemux/demux_demuxers.c mplayerxp/libmpdemux/demux_dv.c mplayerxp/libmpdemux/demux_film.c mplayerxp/libmpdemux/demux_fli.c mplayerxp/libmpdemux/demux_lavf.c mplayerxp/libmpdemux/demux_mkv.c mplayerxp/libmpdemux/demux_mov.c mplayerxp/libmpdemux/demux_mpg.c mplayerxp/libmpdemux/demux_mpxp64.c mplayerxp/libmpdemux/demux_nsv.c mplayerxp/libmpdemux/demux_null.c mplayerxp/libmpdemux/demux_nuv.c mplayerxp/libmpdemux/demux_ogg.c mplayerxp/libmpdemux/demux_pva.c mplayerxp/libmpdemux/demux_ra.c mplayerxp/libmpdemux/demux_rawaudio.c mplayerxp/libmpdemux/demux_rawvideo.c mplayerxp/libmpdemux/demux_real.c mplayerxp/libmpdemux/demux_roq.c mplayerxp/libmpdemux/demux_smjpeg.c mplayerxp/libmpdemux/demux_ts.c mplayerxp/libmpdemux/demux_ty.c mplayerxp/libmpdemux/demux_viv.c mplayerxp/libmpdemux/demux_vqf.c mplayerxp/libmpdemux/demuxer.cpp mplayerxp/libmpdemux/demuxer.h mplayerxp/libmpdemux/demuxer_r.cpp mplayerxp/libmpdemux/demuxer_r.h mplayerxp/libmpdemux/mux_lavf.c mplayerxp/libmpdemux/mux_mpxp64.c mplayerxp/libmpdemux/parse_es.c mplayerxp/libmpdemux/parse_mp4.c mplayerxp/libmpdemux/test.c mplayerxp/libmpdemux/video.c mplayerxp/libmpdemux/yuv4mpeg.h mplayerxp/libmpstream/librtsp/rtsp.cpp mplayerxp/libmpstream/librtsp/rtsp_rtp.c mplayerxp/libmpstream/librtsp/rtsp_session.c mplayerxp/libmpstream/realrtsp/asmrp.c mplayerxp/libmpstream/realrtsp/real.cpp mplayerxp/libmpstream/realrtsp/rmff.c mplayerxp/libmpstream/realrtsp/sdpplin.c mplayerxp/libmpsub/vobsub.c mplayerxp/libplaytree/asxparser.cpp mplayerxp/libplaytree/playtree.cpp mplayerxp/libplaytree/playtree.h mplayerxp/libplaytree/playtreeparser.cpp mplayerxp/libplaytree/playtreeparser.h mplayerxp/libvo/sub.c mplayerxp/libvo/vo_fbdev.c mplayerxp/mp-opt-reg.cpp mplayerxp/mp_msg.h mplayerxp/mplayerxp.cpp mplayerxp/postproc/af_crystality.cpp mplayerxp/postproc/libmenu/menu.cpp mplayerxp/postproc/libmenu/menu_cmdlist.cpp mplayerxp/postproc/libmenu/menu_console.cpp mplayerxp/postproc/libmenu/menu_filesel.cpp mplayerxp/postproc/libmenu/menu_param.cpp mplayerxp/postproc/libmenu/menu_pt.cpp mplayerxp/postproc/libmenu/menu_txt.cpp mplayerxp/postproc/vf.h mplayerxp/pvector/pvector_f32_x86.h mplayerxp/pvector/pvector_int_x86.h mplayerxp/xmpcore/xmp_core.h Added Paths: ----------- mplayerxp/libmpstream/ mplayerxp/libmpstream/Makefile mplayerxp/libmpstream/asf_mmst_streaming.c mplayerxp/libmpstream/asf_streaming.c mplayerxp/libmpstream/asf_streaming.h mplayerxp/libmpstream/cache2.cpp mplayerxp/libmpstream/cdd.h mplayerxp/libmpstream/cdda.cpp mplayerxp/libmpstream/cddb.cpp mplayerxp/libmpstream/cookies.c mplayerxp/libmpstream/cookies.h mplayerxp/libmpstream/freesdp/ mplayerxp/libmpstream/frequencies.c mplayerxp/libmpstream/frequencies.h mplayerxp/libmpstream/http.c mplayerxp/libmpstream/http.h mplayerxp/libmpstream/librtsp/ mplayerxp/libmpstream/mrl.c mplayerxp/libmpstream/mrl.h mplayerxp/libmpstream/network.c mplayerxp/libmpstream/network.h mplayerxp/libmpstream/pnm.c mplayerxp/libmpstream/pnm.h mplayerxp/libmpstream/realrtsp/ mplayerxp/libmpstream/rtp.c mplayerxp/libmpstream/rtp.h mplayerxp/libmpstream/s_cdd.c mplayerxp/libmpstream/s_dvdnav.c mplayerxp/libmpstream/s_dvdread.c mplayerxp/libmpstream/s_ffmpeg.c mplayerxp/libmpstream/s_file.c mplayerxp/libmpstream/s_ftp.c mplayerxp/libmpstream/s_network.c mplayerxp/libmpstream/s_null.c mplayerxp/libmpstream/s_oss.c mplayerxp/libmpstream/s_rtsp.c mplayerxp/libmpstream/s_tv.c mplayerxp/libmpstream/s_udp.c mplayerxp/libmpstream/s_vcdnav.c mplayerxp/libmpstream/stream.cpp mplayerxp/libmpstream/stream.h mplayerxp/libmpstream/stream_msg.h mplayerxp/libmpstream/tcp.c mplayerxp/libmpstream/tcp.h mplayerxp/libmpstream/tv.h mplayerxp/libmpstream/tvi_bsdbt848.c mplayerxp/libmpstream/tvi_def.h mplayerxp/libmpstream/tvi_dummy.c mplayerxp/libmpstream/tvi_v4l.c mplayerxp/libmpstream/udp.c mplayerxp/libmpstream/udp.h mplayerxp/libmpstream/url.c mplayerxp/libmpstream/url.h Removed Paths: ------------- mplayerxp/libmpdemux/asf_mmst_streaming.c mplayerxp/libmpdemux/asf_streaming.c mplayerxp/libmpdemux/asf_streaming.h mplayerxp/libmpdemux/cache2.cpp mplayerxp/libmpdemux/cdd.h mplayerxp/libmpdemux/cdda.cpp mplayerxp/libmpdemux/cddb.cpp mplayerxp/libmpdemux/cookies.c mplayerxp/libmpdemux/cookies.h mplayerxp/libmpdemux/freesdp/ mplayerxp/libmpdemux/frequencies.c mplayerxp/libmpdemux/frequencies.h mplayerxp/libmpdemux/http.c mplayerxp/libmpdemux/http.h mplayerxp/libmpdemux/librtsp/ mplayerxp/libmpdemux/mrl.c mplayerxp/libmpdemux/mrl.h mplayerxp/libmpdemux/network.c mplayerxp/libmpdemux/network.h mplayerxp/libmpdemux/pnm.c mplayerxp/libmpdemux/pnm.h mplayerxp/libmpdemux/realrtsp/ mplayerxp/libmpdemux/rtp.c mplayerxp/libmpdemux/rtp.h mplayerxp/libmpdemux/s_cdd.c mplayerxp/libmpdemux/s_dvdnav.c mplayerxp/libmpdemux/s_dvdread.c mplayerxp/libmpdemux/s_ffmpeg.c mplayerxp/libmpdemux/s_file.c mplayerxp/libmpdemux/s_ftp.c mplayerxp/libmpdemux/s_network.c mplayerxp/libmpdemux/s_null.c mplayerxp/libmpdemux/s_oss.c mplayerxp/libmpdemux/s_rtsp.c mplayerxp/libmpdemux/s_tv.c mplayerxp/libmpdemux/s_udp.c mplayerxp/libmpdemux/s_vcdnav.c mplayerxp/libmpdemux/stream.cpp mplayerxp/libmpdemux/stream.h mplayerxp/libmpdemux/tcp.c mplayerxp/libmpdemux/tcp.h mplayerxp/libmpdemux/tv.h mplayerxp/libmpdemux/tvi_bsdbt848.c mplayerxp/libmpdemux/tvi_def.h mplayerxp/libmpdemux/tvi_dummy.c mplayerxp/libmpdemux/tvi_v4l.c mplayerxp/libmpdemux/udp.c mplayerxp/libmpdemux/udp.h mplayerxp/libmpdemux/url.c mplayerxp/libmpdemux/url.h Modified: mplayerxp/Makefile =================================================================== --- mplayerxp/Makefile 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/Makefile 2012-11-19 12:50:35 UTC (rev 409) @@ -11,7 +11,7 @@ TARGET_EXE = $(PROGNAME) # these subdirectories required installation due binaries within them -SUBDIRS = libmpdemux libmpsub libplaytree libmpcodecs libmpconf libao2 osdep postproc input2 nls libvo xmpcore +SUBDIRS = libmpdemux libmpstream libmpsub libplaytree libmpcodecs libmpconf libao2 osdep postproc input2 nls libvo xmpcore ifeq ($(ENABLE_WIN32LOADER),yes) SUBDIRS+=loader endif @@ -32,7 +32,8 @@ ../ffmpeg/libavformat/libavformat$(FF_SUFFIX).a \ ../ffmpeg/libavutil/libavutil$(FF_SUFFIX).a -MP_LIBS = libmpdemux/libmpdemux.a \ +MP_LIBS = libmpstream/libmpstream.a \ + libmpdemux/libmpdemux.a \ libmpcodecs/libmpcodecs.a \ libmpsub/libmpsub.a \ libplaytree/libplaytree.a \ Modified: mplayerxp/configure =================================================================== --- mplayerxp/configure 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/configure 2012-11-19 12:50:35 UTC (rev 409) @@ -1139,6 +1139,9 @@ #include "$srcdir/../ffmpeg/libavutil/audioconvert.h" #include "$srcdir/../ffmpeg/libswresample/swresample.h" #include "$srcdir/../ffmpeg/libavformat/riff.h" +#include "$srcdir/../ffmpeg/libavformat/avformat.h" +#include "$srcdir/../ffmpeg/libavformat/avio.h" +#include "$srcdir/../ffmpeg/libavformat/url.h" #ifdef __cplusplus } Modified: mplayerxp/dump.cpp =================================================================== --- mplayerxp/dump.cpp 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/dump.cpp 2012-11-19 12:50:35 UTC (rev 409) @@ -14,7 +14,7 @@ #include "input2/input.h" #include "mplayerxp.h" #include "libmpdemux/muxer.h" -#include "libmpdemux/mrl.h" +#include "libmpstream/mrl.h" #include "osdep/mplib.h" #define MSGT_CLASS MSGT_GLOBAL #include "mp_msg.h" Modified: mplayerxp/input2/input.cpp =================================================================== --- mplayerxp/input2/input.cpp 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/input2/input.cpp 2012-11-19 12:50:35 UTC (rev 409) @@ -15,7 +15,6 @@ #ifdef MP_DEBUG #include <assert.h> #endif -#include "libmpdemux/stream.h" #include "osdep/keycodes.h" #include "osdep/get_path.h" #include "osdep/timer.h" Modified: mplayerxp/libao2/ao_alsa9.c =================================================================== --- mplayerxp/libao2/ao_alsa9.c 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/libao2/ao_alsa9.c 2012-11-19 12:50:35 UTC (rev 409) @@ -27,7 +27,7 @@ #include "audio_out_internal.h" #include "afmt.h" #include "ao_msg.h" -#include "libmpdemux/mrl.h" +#include "libmpstream/mrl.h" #include "osdep/mplib.h" static ao_info_t info = Modified: mplayerxp/libao2/ao_null.c =================================================================== --- mplayerxp/libao2/ao_null.c 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/libao2/ao_null.c 2012-11-19 12:50:35 UTC (rev 409) @@ -9,7 +9,7 @@ #include "osdep/bswap.h" #include "osdep/mplib.h" -#include "libmpdemux/mrl.h" +#include "libmpstream/mrl.h" #include "afmt.h" #include "audio_out.h" #include "audio_out_internal.h" Modified: mplayerxp/libmpcodecs/ad.cpp =================================================================== --- mplayerxp/libmpcodecs/ad.cpp 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/libmpcodecs/ad.cpp 2012-11-19 12:50:35 UTC (rev 409) @@ -8,7 +8,7 @@ #include "mp_config.h" -#include "libmpdemux/stream.h" +#include "libmpstream/stream.h" #include "libmpdemux/demuxer.h" #include "libmpdemux/stheader.h" #include "ad.h" Modified: mplayerxp/libmpcodecs/ad_internal.h =================================================================== --- mplayerxp/libmpcodecs/ad_internal.h 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/libmpcodecs/ad_internal.h 2012-11-19 12:50:35 UTC (rev 409) @@ -3,8 +3,7 @@ #endif #include "libmpconf/codec-cfg.h" -#include "libmpdemux/stream.h" -#include "libmpdemux/demuxer.h" +#include "libmpstream/stream.h" #include "libmpdemux/demuxer_r.h" #include "libmpdemux/stheader.h" Modified: mplayerxp/libmpcodecs/ad_libdv.c =================================================================== --- mplayerxp/libmpcodecs/ad_libdv.c 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/libmpcodecs/ad_libdv.c 2012-11-19 12:50:35 UTC (rev 409) @@ -12,7 +12,7 @@ #include <libdv/dv.h> #include <libdv/dv_types.h> -#include "libmpdemux/stream.h" +#include "libmpstream/stream.h" #include "libmpdemux/demuxer.h" #include "libmpdemux/stheader.h" #include "libao2/afmt.h" Modified: mplayerxp/libmpcodecs/dec_audio.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_audio.cpp 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/libmpcodecs/dec_audio.cpp 2012-11-19 12:50:35 UTC (rev 409) @@ -10,7 +10,7 @@ #include "mplayerxp.h" #include "xmpcore/xmp_core.h" -#include "libmpdemux/stream.h" +#include "libmpstream/stream.h" #include "libmpdemux/demuxer.h" #include "libmpdemux/stheader.h" #include "libmpconf/codec-cfg.h" Modified: mplayerxp/libmpcodecs/dec_video.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_video.cpp 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/libmpcodecs/dec_video.cpp 2012-11-19 12:50:35 UTC (rev 409) @@ -15,7 +15,7 @@ #include "osdep/shmem.h" #include "osdep/mplib.h" -#include "libmpdemux/stream.h" +#include "libmpstream/stream.h" #include "libmpdemux/demuxer.h" #include "libmpdemux/parse_es.h" #include "libmpdemux/stheader.h" Modified: mplayerxp/libmpcodecs/dec_video.h =================================================================== --- mplayerxp/libmpcodecs/dec_video.h 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/libmpcodecs/dec_video.h 2012-11-19 12:50:35 UTC (rev 409) @@ -2,7 +2,7 @@ #define DEC_VIDEO_H_INCLUDED 1 #include "xmpcore/xmp_enums.h" #include "libmpdemux/demuxer_r.h" -#include "libmpdemux/stream.h" +#include "libmpstream/stream.h" #include "libmpdemux/stheader.h" #ifdef __cplusplus extern "C" { Modified: mplayerxp/libmpcodecs/vd.cpp =================================================================== --- mplayerxp/libmpcodecs/vd.cpp 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/libmpcodecs/vd.cpp 2012-11-19 12:50:35 UTC (rev 409) @@ -10,7 +10,7 @@ #include "libvo/img_format.h" -#include "libmpdemux/stream.h" +#include "libmpstream/stream.h" #include "libmpdemux/demuxer.h" #include "libmpdemux/stheader.h" #include "osdep/mplib.h" Modified: mplayerxp/libmpcodecs/vd_internal.h =================================================================== --- mplayerxp/libmpcodecs/vd_internal.h 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/libmpcodecs/vd_internal.h 2012-11-19 12:50:35 UTC (rev 409) @@ -2,8 +2,7 @@ #include "libmpconf/codec-cfg.h" #include "libvo/img_format.h" -#include "libmpdemux/stream.h" -#include "libmpdemux/demuxer.h" +#include "libmpstream/stream.h" #include "libmpdemux/demuxer_r.h" #include "libmpdemux/stheader.h" Modified: mplayerxp/libmpcodecs/vd_libdv.c =================================================================== --- mplayerxp/libmpcodecs/vd_libdv.c 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/libmpcodecs/vd_libdv.c 2012-11-19 12:50:35 UTC (rev 409) @@ -13,7 +13,7 @@ #include <libdv/dv.h> #include <libdv/dv_types.h> -#include "libmpdemux/stream.h" +#include "libmpstream/stream.h" #include "libmpdemux/demuxer.h" #include "libmpdemux/stheader.h" Modified: mplayerxp/libmpconf/cfgparser.cpp =================================================================== --- mplayerxp/libmpconf/cfgparser.cpp 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/libmpconf/cfgparser.cpp 2012-11-19 12:50:35 UTC (rev 409) @@ -36,7 +36,6 @@ #include <assert.h> #endif -#include "libmpdemux/stream.h" #include "cfgparser.h" #include "osdep/mplib.h" #define MSGT_CLASS MSGT_CFGPARSER Modified: mplayerxp/libmpconf/m_option.cpp =================================================================== --- mplayerxp/libmpconf/m_option.cpp 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/libmpconf/m_option.cpp 2012-11-19 12:50:35 UTC (rev 409) @@ -12,10 +12,9 @@ #include <inttypes.h> #include <unistd.h> -#include "libmpdemux/stream.h" #include "cfgparser.h" #include "m_option.h" -#include "libmpdemux/url.h" +#include "libmpstream/url.h" #include "osdep/mplib.h" #define MSGT_CLASS MSGT_CPLAYER #include "mp_msg.h" Modified: mplayerxp/libmpdemux/Makefile =================================================================== --- mplayerxp/libmpdemux/Makefile 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/libmpdemux/Makefile 2012-11-19 12:50:35 UTC (rev 409) @@ -3,36 +3,15 @@ include ../mp_config.mak +SUBDIRS = DO_MAKE = @ for i in $(SUBDIRS); do $(MAKE) -C $$i $@ || exit; done DO_ALL = @ for i in $(SUBDIRS); do $(MAKE) -C $$i all || exit; done CXXSRCS= -SRCS = s_file.c s_ffmpeg.c s_null.c -ifeq ($(HAVE_LIBCDIO_CDDA),yes) -SRCS += s_cdd.c -CXXSRCS += cdda.cpp -ifeq ($(HAVE_STREAMING),yes) -CXXSRCS += cddb.cpp -endif -endif -ifeq ($(USE_DVDNAV),yes) -SRCS += s_dvdnav.c -endif -ifeq ($(USE_DVDREAD),yes) -SRCS += s_dvdread.c -endif -SRCS += s_tv.c url.c -ifeq ($(USE_OSS_AUDIO),yes) -SRCS += s_oss.c -endif -ifeq ($(USE_LIBVCD),yes) -SRCS += s_vcdnav.c -endif +SRCS= ifeq ($(HAVE_LIBDV),yes) SRCS += demux_dv.c endif -SRCS += tvi_dummy.c tvi_v4l.c -SRCS += tvi_bsdbt848.c frequencies.c mrl.c SRCS += mp3_hdr.c video.c mpeg_hdr.c aviprint.c demux_asf.c SRCS += demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_viv.c @@ -48,14 +27,8 @@ SRCS += mux_mpxp64.c mux_raw.c #SRCS+= mux_lavf.c -ifeq ($(HAVE_STREAMING),yes) -SUBDIRS = freesdp librtsp realrtsp -SRCS += asf_streaming.c asf_mmst_streaming.c cookies.c http.c network.c rtp.c pnm.c s_ftp.c s_udp.c s_rtsp.c s_network.c tcp.c udp.c -else -SUBDIRS = -endif -CXXSRCS+= demuxer.cpp demuxer_r.cpp stream.cpp cache2.cpp mpdemux.cpp +CXXSRCS+= demuxer.cpp demuxer_r.cpp mpdemux.cpp CXXSRCS+= muxer.cpp OBJS = $(SRCS:.c=.o) Deleted: mplayerxp/libmpdemux/asf_mmst_streaming.c =================================================================== --- mplayerxp/libmpdemux/asf_mmst_streaming.c 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/libmpdemux/asf_mmst_streaming.c 2012-11-19 12:50:35 UTC (rev 409) @@ -1,664 +0,0 @@ -// mmst implementation taken from the xine-mms plugin made by majormms (http://geocities.com/majormms/) -// -// ported to mplayer by Abhijeet Phatak <abh...@ya...> -// date : 16 April 2002 -// -// information about the mms protocol can be find at http://get.to/sdp -// - - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <errno.h> -#include <inttypes.h> - -#include "mp_config.h" -#include "mplayerxp.h" - -#include "tcp.h" -#include "url.h" -#include "asf.h" -#include "stream.h" - -#include "network.h" - -#ifndef HAVE_WINSOCK2 -#define closesocket close -#else -#include <winsock2.h> -#endif -#ifndef USE_SETLOCALE -#undef USE_ICONV -#endif - -#ifdef USE_ICONV -#ifdef HAVE_GICONV -#include <giconv.h> -#else -#include <iconv.h> -#endif -#ifdef USE_LANGINFO -#include <langinfo.h> -#endif -#endif -#include "demux_msg.h" -#include "osdep/mplib.h" - -#define BUF_SIZE 102400 -#define HDR_BUF_SIZE 8192 -#define MAX_STREAMS 20 - -typedef struct -{ - uint8_t buf[BUF_SIZE]; - int num_bytes; - -} command_t; - -static int seq_num; -static int num_stream_ids; -static int stream_ids[MAX_STREAMS]; - -static int get_data (int s, char *buf, size_t count); - -static void put_32 (command_t *cmd, uint32_t value) -{ - cmd->buf[cmd->num_bytes ] = value % 256; - value = value >> 8; - cmd->buf[cmd->num_bytes+1] = value % 256 ; - value = value >> 8; - cmd->buf[cmd->num_bytes+2] = value % 256 ; - value = value >> 8; - cmd->buf[cmd->num_bytes+3] = value % 256 ; - - cmd->num_bytes += 4; -} - -static uint32_t get_32 (unsigned char *cmd, int offset) -{ - uint32_t ret; - - ret = cmd[offset] ; - ret |= cmd[offset+1]<<8 ; - ret |= cmd[offset+2]<<16 ; - ret |= cmd[offset+3]<<24 ; - - return ret; -} - -static void send_command (int s, int command, uint32_t switches, - uint32_t extra, int length, - char *data) -{ - command_t cmd; - int len8; - - len8 = (length + 7) / 8; - - cmd.num_bytes = 0; - - put_32 (&cmd, 0x00000001); /* start sequence */ - put_32 (&cmd, 0xB00BFACE); /* #-)) */ - put_32 (&cmd, len8*8 + 32); - put_32 (&cmd, 0x20534d4d); /* protocol type "MMS " */ - put_32 (&cmd, len8 + 4); - put_32 (&cmd, seq_num); - seq_num++; - put_32 (&cmd, 0x0); /* unknown */ - put_32 (&cmd, 0x0); - put_32 (&cmd, len8+2); - put_32 (&cmd, 0x00030000 | command); /* dir | command */ - put_32 (&cmd, switches); - put_32 (&cmd, extra); - - memcpy (&cmd.buf[48], data, length); - if (length & 7) - memset(&cmd.buf[48 + length], 0, 8 - (length & 7)); - - if (send (s, cmd.buf, len8*8+48, 0) != (len8*8+48)) { - MSG_ERR ("write error\n"); - } -} - -#ifdef USE_ICONV -static iconv_t url_conv; -#endif - -static void string_utf16(char *dest, char *src, int len) -{ - int i; -#ifdef USE_ICONV - size_t len1, len2; - char *ip, *op; - - if (url_conv != (iconv_t)(-1)) - { - memset(dest, 0, 1000); - len1 = len; len2 = 1000; - ip = src; op = dest; - - iconv(url_conv, &ip, &len1, &op, &len2); - } - else - { -#endif - if (len > 499) len = 499; - for (i=0; i<len; i++) { - dest[i*2] = src[i]; - dest[i*2+1] = 0; - } - /* trailing zeroes */ - dest[i*2] = 0; - dest[i*2+1] = 0; -#ifdef USE_ICONV - } -#endif -} - -static void get_answer (int s) -{ - char data[BUF_SIZE]; - int command = 0x1b; - - while (command == 0x1b) { - int len; - - len = recv (s, data, BUF_SIZE, 0) ; - if (!len) { - MSG_ERR ("\nalert! eof\n"); - return; - } - - command = get_32 (data, 36) & 0xFFFF; - - if (command == 0x1b) - send_command (s, 0x1b, 0, 0, 0, data); - } -} - -static int get_data (int s, char *buf, size_t count) -{ - ssize_t len; - size_t total = 0; - - while (total < count) { - - len = recv (s, &buf[total], count-total, 0); - - if (len<=0) { - MSG_ERR ("read error:"); - return 0; - } - - total += len; - - if (len != 0) { -// printf ("[%d/%d]", total, count); - fflush (stdout); - } - - } - - return 1; - -} - -static int get_header (int s, uint8_t *header, streaming_ctrl_t *streaming_ctrl) -{ - unsigned char pre_header[8]; - int header_len; - - header_len = 0; - - while (1) { - if (!get_data (s, pre_header, 8)) { - MSG_ERR ("pre-header read failed\n"); - return 0; - } - if (pre_header[4] == 0x02) { - - int packet_len; - - packet_len = (pre_header[7] << 8 | pre_header[6]) - 8; - -// printf ("asf header packet detected, len=%d\n", packet_len); - - if (packet_len < 0 || packet_len > HDR_BUF_SIZE - header_len) { - MSG_FATAL("Invalid header size, giving up\n"); - return 0; - } - - if (!get_data (s, &header[header_len], packet_len)) { - MSG_ERR("header data read failed\n"); - return 0; - } - - header_len += packet_len; - - if ( (header[header_len-1] == 1) && (header[header_len-2]==1)) { - - - if( streaming_bufferize( streaming_ctrl, header, header_len )<0 ) { - return -1; - } - - // printf ("get header packet finished\n"); - - return (header_len); - - } - - } else { - - int32_t packet_len; - int command; - char data[BUF_SIZE]; - - if (!get_data (s, (char*)&packet_len, 4)) { - MSG_ERR ("packet_len read failed\n"); - return 0; - } - - packet_len = get_32 ((unsigned char*)&packet_len, 0) + 4; - -// printf ("command packet detected, len=%d\n", packet_len); - - if (packet_len < 0 || packet_len > BUF_SIZE) { - MSG_FATAL("Invalid rtsp packet size, giving up\n"); - return 0; - } - - if (!get_data (s, data, packet_len)) { - MSG_ERR ("command data read failed\n"); - return 0; - } - - command = get_32 (data, 24) & 0xFFFF; - -// printf ("command: %02x\n", command); - - if (command == 0x1b) - send_command (s, 0x1b, 0, 0, 0, data); - - } - -// printf ("get header packet succ\n"); - } -} - -static int interp_header (uint8_t *header, int header_len) -{ - int i; - int packet_length=-1; - - /* - * parse header - */ - - i = 30; - while (i<header_len) { - - uint64_t guid_1, guid_2, length; - - guid_2 = (uint64_t)header[i] | ((uint64_t)header[i+1]<<8) - | ((uint64_t)header[i+2]<<16) | ((uint64_t)header[i+3]<<24) - | ((uint64_t)header[i+4]<<32) | ((uint64_t)header[i+5]<<40) - | ((uint64_t)header[i+6]<<48) | ((uint64_t)header[i+7]<<56); - i += 8; - - guid_1 = (uint64_t)header[i] | ((uint64_t)header[i+1]<<8) - | ((uint64_t)header[i+2]<<16) | ((uint64_t)header[i+3]<<24) - | ((uint64_t)header[i+4]<<32) | ((uint64_t)header[i+5]<<40) - | ((uint64_t)header[i+6]<<48) | ((uint64_t)header[i+7]<<56); - i += 8; - -// printf ("guid found: %016llx%016llx\n", guid_1, guid_2); - - length = (uint64_t)header[i] | ((uint64_t)header[i+1]<<8) - | ((uint64_t)header[i+2]<<16) | ((uint64_t)header[i+3]<<24) - | ((uint64_t)header[i+4]<<32) | ((uint64_t)header[i+5]<<40) - | ((uint64_t)header[i+6]<<48) | ((uint64_t)header[i+7]<<56); - - i += 8; - - if ( (guid_1 == 0x6cce6200aa00d9a6ULL) && (guid_2 == 0x11cf668e75b22630ULL) ) { - MSG_V ("header object\n"); - } else if ((guid_1 == 0x6cce6200aa00d9a6ULL) && (guid_2 == 0x11cf668e75b22636ULL)) { - MSG_V ("data object\n"); - } else if ((guid_1 == 0x6553200cc000e48eULL) && (guid_2 == 0x11cfa9478cabdca1ULL)) { - - packet_length = get_32(header, i+92-24); - - MSG_V ("file object, packet length = %d (%d)\n", - packet_length, get_32(header, i+96-24)); - - - } else if ((guid_1 == 0x6553200cc000e68eULL) && (guid_2 == 0x11cfa9b7b7dc0791ULL)) { - - int stream_id = header[i+48] | header[i+49] << 8; - - MSG_V ("stream object, stream id: %d\n", stream_id); - - if (num_stream_ids < MAX_STREAMS) { - stream_ids[num_stream_ids] = stream_id; - num_stream_ids++; - } else { - MSG_ERR("asf_mmst: too many id, stream skipped"); - } - - } else { - MSG_V ("unknown object\n"); - } - -// printf ("length : %lld\n", length); - - i += length-24; - - } - - return packet_length; - -} - - -static int get_media_packet (int s, int padding, streaming_ctrl_t *stream_ctrl) { - unsigned char pre_header[8]; - char data[BUF_SIZE]; - - if (!get_data (s, pre_header, 8)) { - MSG_ERR ("pre-header read failed\n"); - return 0; - } - -// for (i=0; i<8; i++) -// printf ("pre_header[%d] = %02x (%d)\n", -// i, pre_header[i], pre_header[i]); - - if (pre_header[4] == 0x04) { - - int packet_len; - - packet_len = (pre_header[7] << 8 | pre_header[6]) - 8; - -// printf ("asf media packet detected, len=%d\n", packet_len); - - if (packet_len < 0 || packet_len > BUF_SIZE) { - MSG_FATAL("Invalid rtsp packet size, giving up\n"); - return 0; - } - - if (!get_data (s, data, packet_len)) { - MSG_ERR ("media data read failed\n"); - return 0; - } - - streaming_bufferize(stream_ctrl, data, padding); - - } else { - - int32_t packet_len; - int command; - - if (!get_data (s, (char*)&packet_len, 4)) { - MSG_ERR ("packet_len read failed\n"); - return 0; - } - - packet_len = get_32 ((unsigned char*)&packet_len, 0) + 4; - - if (packet_len < 0 || packet_len > BUF_SIZE) { - MSG_FATAL("Invalid rtsp packet size, giving up\n"); - return 0; - } - - if (!get_data (s, data, packet_len)) { - MSG_ERR ("command data read failed\n"); - return 0; - } - - if ( (pre_header[7] != 0xb0) || (pre_header[6] != 0x0b) - || (pre_header[5] != 0xfa) || (pre_header[4] != 0xce) ) { - - MSG_ERR ("missing signature\n"); - return -1; - } - - command = get_32 (data, 24) & 0xFFFF; - -// printf ("\ncommand packet detected, len=%d cmd=0x%X\n", packet_len, command); - - if (command == 0x1b) - send_command (s, 0x1b, 0, 0, 0, data); - else if (command == 0x1e) { - MSG_OK ("everything done. Thank you for downloading a media file containing proprietary and patentend technology.\n"); - return 0; - } - else if (command == 0x21 ) { - // Looks like it's new in WMS9 - // Unknown command, but ignoring it seems to work. - return 0; - } - else if (command != 0x05) { - MSG_ERR ("unknown command %02x\n", command); - return -1; - } - } - -// printf ("get media packet succ\n"); - - return 1; -} - - -static int packet_length1; - -static int asf_mmst_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *stream_ctrl ) -{ - int len; - - while( stream_ctrl->buffer_size==0 ) { - // buffer is empty - fill it! - int ret = get_media_packet( fd, packet_length1, stream_ctrl); - if( ret<0 ) { - MSG_ERR("get_media_packet error : %s\n",strerror(errno)); - return -1; - } else if (ret==0) //EOF? - return ret; - } - - len = stream_ctrl->buffer_size-stream_ctrl->buffer_pos; - if(len>size) len=size; - memcpy( buffer, (stream_ctrl->buffer)+(stream_ctrl->buffer_pos), len ); - stream_ctrl->buffer_pos += len; - if( stream_ctrl->buffer_pos>=stream_ctrl->buffer_size ) { - mp_free( stream_ctrl->buffer ); - stream_ctrl->buffer = NULL; - stream_ctrl->buffer_size = 0; - stream_ctrl->buffer_pos = 0; - } - return len; - -} - -static int asf_mmst_streaming_seek( int fd, off_t pos, streaming_ctrl_t *streaming_ctrl ) -{ - return -1; - // Shut up gcc warning - fd++; - pos++; - streaming_ctrl=NULL; -} - -int asf_mmst_streaming_start(any_t* libinput,stream_t *stream) -{ - char str[1024]; - char data[BUF_SIZE]; - uint8_t asf_header[HDR_BUF_SIZE]; - int asf_header_len; - int len, i, packet_length; - char *path, *unescpath; - URL_t *url1 = stream->streaming_ctrl->url; - int s = stream->fd; - - if( s>0 ) { - closesocket( stream->fd ); - stream->fd = -1; - } - - /* parse url */ - path = strchr(url1->file,'/') + 1; - - /* mmst filename are not url_escaped by MS MediaPlayer and are expected as - * "plain text" by the server, so need to decode it here - */ - unescpath=mp_malloc(strlen(path)+1); - if (!unescpath) { - MSG_FATAL("Memory allocation failed!\n"); - return -1; - } - url_unescape_string(unescpath,path); - path=unescpath; - - if( url1->port==0 ) { - url1->port=1755; - } - s = tcp_connect2Server(libinput, url1->hostname, url1->port, 0); - if( s<0 ) { - mp_free(path); - return s; - } - MSG_INFO ("connected\n"); - - seq_num=0; - - /* - * Send the initial connect info including player version no. Client GUID (random) and the host address being connected to. - * This command is sent at the very start of protocol initiation. It sends local information to the serve - * cmd 1 0x01 - * */ - - /* prepare for the url encoding conversion */ -#ifdef USE_ICONV -#ifdef USE_LANGINFO - url_conv = iconv_open("UTF-16LE",nl_langinfo(CODESET)); -#else - url_conv = iconv_open("UTF-16LE", NULL); -#endif -#endif - - snprintf (str, 1023, "\034\003NSPlayer/7.0.0.1956; {33715801-BAB3-9D85-24E9-03B90328270A}; Host: %s", url1->hostname); - string_utf16 (data, str, strlen(str)); -// send_command(s, commandno ....) - send_command (s, 1, 0, 0x0004000b, strlen(str) * 2+2, data); - - len = recv (s, data, BUF_SIZE, 0) ; - - /*This sends details of the local machine IP address to a Funnel system at the server. - * Also, the TCP or UDP transport selection is sent. - * - * here 192.168.0.129 is local ip address TCP/UDP states the tronsport we r using - * and 1037 is the local TCP or UDP socket number - * cmd 2 0x02 - * */ - - string_utf16 (&data[8], "\002\000\\\\192.168.0.1\\TCP\\1037", 24); - memset (data, 0, 8); - send_command (s, 2, 0, 0, 24*2+10, data); - - len = recv (s, data, BUF_SIZE, 0) ; - - /* This command sends file path (at server) and file name request to the server. - * 0x5 */ - - string_utf16 (&data[8], path, strlen(path)); - memset (data, 0, 8); - send_command (s, 5, 0, 0, strlen(path)*2+10, data); - mp_free(path); - - get_answer (s); - - /* The ASF header chunk request. Includes ?session' variable for pre header value. - * After this command is sent, - * the server replies with 0x11 command and then the header chunk with header data follows. - * 0x15 */ - - memset (data, 0, 40); - data[32] = 2; - - send_command (s, 0x15, 1, 0, 40, data); - - num_stream_ids = 0; - /* get_headers(s, asf_header); */ - - asf_header_len = get_header (s, asf_header, stream->streaming_ctrl); -// printf("---------------------------------- asf_header %d\n",asf_header); - if (asf_header_len==0) { //error reading header - closesocket(s); - return -1; - } - packet_length = interp_header (asf_header, asf_header_len); - - - /* - * This command is the media stream MBR selector. Switches are always 6 bytes in length. - * After all switch elements, data ends with bytes [00 00] 00 20 ac 40 [02]. - * Where: - * [00 00] shows 0x61 0x00 (on the first 33 sent) or 0xff 0xff for ASF files, and with no ending data for WMV files. - * It is not yet understood what all this means. - * And the last [02] byte is probably the header ?session' value. - * - * 0x33 */ - - memset (data, 0, 40); - - if (mp_conf.audio_id > 0) { - data[2] = 0xFF; - data[3] = 0xFF; - data[4] = mp_conf.audio_id; - send_command(s, 0x33, num_stream_ids, 0xFFFF | mp_conf.audio_id << 16, 8, data); - } else { - for (i=1; i<num_stream_ids; i++) { - data [ (i-1) * 6 + 2 ] = 0xFF; - data [ (i-1) * 6 + 3 ] = 0xFF; - data [ (i-1) * 6 + 4 ] = stream_ids[i]; - data [ (i-1) * 6 + 5 ] = 0x00; - } - - send_command (s, 0x33, num_stream_ids, 0xFFFF | stream_ids[0] << 16, (num_stream_ids-1)*6+2 , data); - } - - get_answer (s); - - /* Start sending file from packet xx. - * This command is also used for resume downloads or requesting a lost packet. - * Also used for seeking by sending a play point value which seeks to the media time point. - * Includes ?session' value in pre header and the maximum media stream time. - * 0x07 */ - - memset (data, 0, 40); - - for (i=8; i<16; i++) - data[i] = 0xFF; - - data[20] = 0x04; - - send_command (s, 0x07, 1, 0xFFFF | stream_ids[0] << 16, 24, data); - - stream->fd = s; - stream->streaming_ctrl->streaming_read = asf_mmst_streaming_read; - stream->streaming_ctrl->streaming_seek = asf_mmst_streaming_seek; - stream->streaming_ctrl->buffering = 1; - stream->streaming_ctrl->status = streaming_playing_e; - - packet_length1 = packet_length; - MSG_V("mmst packet_length = %d\n",packet_length); - -#ifdef USE_ICONV - if (url_conv != (iconv_t)(-1)) - iconv_close(url_conv); -#endif - - return 0; -} Deleted: mplayerxp/libmpdemux/asf_streaming.c =================================================================== --- mplayerxp/libmpdemux/asf_streaming.c 2012-11-18 15:23:42 UTC (rev 408) +++ mplayerxp/libmpdemux/asf_streaming.c 2012-11-19 12:50:35 UTC (rev 409) @@ -1,878 +0,0 @@ -#include <stdio.h> -#include <limits.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <errno.h> - -#include "mp_config.h" -#include "mplayerxp.h" -#ifndef HAVE_WINSOCK2 -#define closesocket close -#else -#include <winsock2.h> -#endif - -#include "url.h" -#include "tcp.h" -#include "http.h" -#include "asf.h" - -#include "stream.h" - -#include "network.h" -#include "demux_msg.h" -#include "osdep/mplib.h" - -#if defined( ARCH_X86 ) || defined(ARCH_X86_64) -#define ASF_LOAD_GUID_PREFIX(guid) (*(uint32_t *)(guid)) -#else -#define ASF_LOAD_GUID_PREFIX(guid) \ - ((guid)[3] << 24 | (guid)[2] << 16 | (guid)[1] << 8 | (guid)[0]) -#endif - -// ASF streaming support several network protocol. -// One use UDP, not known, yet! -// Another is HTTP, this one is known. -// So for now, we use the HTTP protocol. -// -// We can try several protocol for asf streaming -// * first the UDP protcol, if there is a firewall, UDP -// packets will not come back, so the mmsu will failed. -// * Then we can try TCP, but if there is a proxy for -// internet connection, the TCP connection will not get -// through -// * Then we can try HTTP. -// -// Note: MMS/HTTP support is now a "well known" support protocol, -// it has been tested for while, not like MMST support. -// WMP sequence is MMSU then MMST and then HTTP. -// In MPlayer case since HTTP support is more reliable, -// we are doing HTTP first then we try MMST if HTTP fail. -static int asf_http_streaming_start(any_t*,stream_t *stream, int *demuxer_type ); -int asf_mmst_streaming_start(stream_t *stream ); - -/* - ASF streaming support several network protocol. - One use UDP, not known, yet! - Another is HTTP, this one is known. - So for now, we use the HTTP protocol. - - We can try several protocol for asf streaming - * first the UDP protcol, if there is a firewall, UDP - packets will not come back, so the mmsu will failed. - * Then we can try TCP, but if there is a proxy for - internet connection, the TCP connection will not get - through - * Then we can try HTTP. - - Note: MMS/HTTP support is now a "well known" support protocol, - it has been tested for while, not like MMST support. - WMP sequence is MMSU then MMST and then HTTP. - In MPlayer case since HTTP support is more reliable, - we are doing HTTP first then we try MMST if HTTP fail. -*/ -int asf_streaming_start(any_t* libinput, stream_t *stream, int *demuxer_type) { - char *proto = stream->streaming_ctrl->url->protocol; - int fd = -1; - int port = stream->streaming_ctrl->url->port; - - // Is protocol even valid mms,mmsu,mmst,http,http_proxy? - if (!(!strncasecmp(proto, "mmst", 4) || !strncasecmp(proto, "mmsu", 4) || - !strncasecmp(proto, "http_proxy", 10) || !strncasecmp(proto, "mms", 3) || - !strncasecmp(proto, "http", 4))) - { - MSG_ERR("Unknown protocol: %s\n", proto ); - return -1; - } - - // Is protocol mms or mmsu? - if (!strncasecmp(proto, "mmsu", 4) || !strncasecmp(proto, "mms", 3)) - { - MSG_V("Trying ASF/UDP...\n"); - //fd = asf_mmsu_streaming_start( stream ); - if( fd>-1 ) return fd; //mmsu support is not implemented yet - using this code - MSG_V(" ===> ASF/UDP failed\n"); - if( fd==-2 ) return -1; - } - - //Is protocol mms or mmst? - if (!strncasecmp(proto, "mmst", 4) || !strncasecmp(proto, "mms", 3)) - { - MSG_V("Trying ASF/TCP...\n"); - fd = asf_mmst_streaming_start( stream ); - stream->streaming_ctrl->url->port = port; - if( fd>-1 ) return fd; - MSG_V(" ===> ASF/TCP failed\n"); - if( fd==-2 ) return -1; - } - - //Is protocol http, http_proxy, or mms? - if (!strncasecmp(proto, "http_proxy", 10) || !strncasecmp(proto, "http", 4) || - !strncasecmp(proto, "mms", 3)) - { - MSG_V("Trying ASF/HTTP...\n"); - fd = asf_http_streaming_start(libinput, stream, demuxer_type ); - stream->streaming_ctrl->url->port = port; - if( fd>-1 ) return fd; - MSG_V(" ===> ASF/HTTP failed\n"); - if( fd==-2 ) return -1; - } - - //everything failed - return -1; -} - -int -asf_streaming(ASF_stream_chunck_t *stream_chunck, int *drop_packet ) { - if( drop_packet!=NULL ) *drop_packet = 0; - - if( stream_chunck->size<8 ) { - MSG_ERR("Ahhhh, stream_chunck size is too small: %d\n", stream_chunck->size); - return -1; - } - if( stream_chunck->size!=stream_chunck->size_confirm ) { - MSG_ERR("size_confirm mismatch!: %d %d\n", stream_chunck->size, stream_chunck->size_confirm); - return -1; - } - switch(stream_chunck->type) { - case ASF_STREAMING_CLEAR: // $C Clear ASF configuration - MSG_V("=====> Clearing ASF stream configuration!\n"); - if( drop_packet!=NULL ) *drop_packet = 1; - return stream_chunck->size; - break; - case ASF_STREAMING_DATA: // $D Data follows - break; - case ASF_STREAMING_END_TRANS: // $E Transfer complete - MSG_V("=====> Transfer complete\n"); - if( drop_packet!=NULL ) *drop_packet = 1; - return stream_chunck->size; - break; - case ASF_STREAMING_HEADER: // $H ASF header chunk follows - MSG_V("=====> ASF header chunk follows\n"); - break; - default: - MSG_V("=====> Unknown stream type 0x%x\n", stream_chunck->type ); - } - return stream_chunck->size+4; -} - -static const char asf_stream_header_guid[16] = {0x91, 0x07, 0xdc, 0xb7, - 0xb7, 0xa9, 0xcf, 0x11, 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}; -static const char asf_file_header_guid[16] = {0xa1, 0xdc, 0xab, 0x8c, - 0x47, 0xa9, 0xcf, 0x11, 0x8e, 0xe4, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}; -static const char asf_content_desc_guid[16] = {0x33, 0x26, 0xb2, 0x75, - 0x8e, 0x66, 0xcf, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}; -static const char asf_stream_group_guid[16] = {0xce, 0x75, 0xf8, 0x7b, - 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2}; -static const char asf_data_chunk_guid[16] = {0x36, 0x26, 0xb2, 0x75, - 0x8e, 0x66, 0xcf, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}; -static int find_asf_guid(char *buf, const char *guid, int cur_pos, int buf_len) -{ - int i; - for (i = cur_pos; i < buf_len - 19; i++) { - if (memcmp(&buf[i], guid, 16) == 0) - return i + 16 + 8; // point after guid + length - } - return -1; -} - -static int max_idx(int s_count, int *s_rates, int bound) { - int i, best = -1, rate = -1; - for (i = 0; i < s_count; i++) { - if (s_rates[i] > rate && s_rates[i] <= bound) { - rate = s_rates[i]; - best = i; - } - } - return best; -} - -static int -asf_streaming_parse_header(int fd, streaming_ctrl_t* streaming_ctrl) { - ASF_header_t asfh; - ASF_stream_chunck_t chunk; - asf_http_streaming_ctrl_t* asf_ctrl = (asf_http_streaming_ctrl_t*) streaming_ctrl->data; - char* buffer=NULL, *chunk_buffer=NULL; - int i,r,size,pos = 0; - int start; - int buffer_size = 0; - int chunk_size2read = 0; - int bw = streaming_ctrl->bandwidth; - int *v_rates = NULL, *a_rates = NULL; - int v_rate = 0, a_rate = 0, a_idx = -1, v_idx = -1; - - if(asf_ctrl == NULL) return -1; - - // The ASF header can be in several network chunks. For example if the content description - // is big, the ASF header will be split in 2 network chunk. - // So we need to retrieve all the chunk before starting to parse the header. - do { - for( r=0; r < (int)sizeof(ASF_stream_chunck_t) ; ) { - i = nop_streaming_read(fd,((char*)&chunk)+r,sizeof(ASF_stream_chunck_t) - r,streaming_ctrl); - if(i <= 0) return -1; - r += i; - } - // Endian handling of the stream chunk - le2me_ASF_stream_chunck_t(&chunk); - size = asf_streaming( &chunk, &r) - sizeof(ASF_stream_chunck_t); - if(r) MSG_WARN("Warning : drop header ????\n"); - if(size < 0){ - MSG_ERR("Error while parsing chunk header\n"); - return -1; - } - if (chunk.type != ASF_STREAMING_HEADER) { - MSG_ERR("Don't got a header as first chunk !!!!\n"); - return -1; - } - - // audit: do not overflow buffer_size - if (size > SIZE_MAX - buffer_size) return -1; - buffer = (char*) mp_malloc(size+buffer_size); - if(buffer == NULL) { - MSG_FATAL("Error can't allocate %d bytes buffer\n",size+buffer_size); - return -1; - } - if( chunk_buffer!=NULL ) { - memcpy( buffer, chunk_buffer, buffer_size ); - mp_free( chunk_buffer ); - } - chunk_buffer = buffer; - buffer += buffer_size; - buffer_size += size; - - for(r = 0; r < size;) { - i = nop_streaming_read(fd,buffer+r,size-r,streaming_ctrl); - if(i < 0) { - MSG_ERR("Error while reading network stream\n"); - return -1; - } - r += i; - } - - if( chunk_size2read==0 ) { - if(size < (int)sizeof(asfh)) { - MSG_ERR("Error chunk is too small\n"); - return -1; - } else MSG_DBG2("Got chunk\n"); - memcpy(&asfh,buffer,sizeof(asfh)); - le2me_ASF_header_t(&asfh); - chunk_size2read = asfh.objh.size; - MSG_DBG2("Size 2 read=%d\n", chunk_size2read); - } - } while( buffer_size<chunk_size2read); - buffer = chunk_buffer; - size = buffer_size; - - if(asfh.cno > 256) { - MSG_ERR("Error sub chunks number is invalid\n"); - return -1; - } - - start = sizeof(asfh); - - pos = find_asf_guid(buffer, asf_file_header_guid, start, size); - if (pos >= 0) { - ASF_file_header_t *fileh = (ASF_file_header_t *) &buffer[pos]; - pos += sizeof(ASF_file_header_t); - if (pos > size) goto len_err_out; - le2me_ASF_file_header_t(fileh); -/* - if(fileh.packetsize != fileh.packetsize2) { - printf("Error packetsize check don't match\n"); - return -1; - } -*/ - asf_ctrl->packet_size = fileh->max_packet_size; - // before playing. - // preroll: time in ms to bufferize before playing - streaming_ctrl->prebuffer_size = (unsigned int)(((double)fileh->preroll/1000.0)*((double)fileh->max_bitrate/8.0)); - } - - pos = start; - while ((pos = find_asf_guid(buffer, asf_stream_header_guid, pos, size)) >= 0) - { - ASF_stream_header_t *streamh = (ASF_stream_header_t *)&buffer[pos]; - pos += sizeof(ASF_stream_header_t); - if (pos > size) goto len_err_out; - le2me_ASF_stream_header_t(streamh); - switch(ASF_LOAD_GUID_PREFIX(streamh->type)) { - case 0xF8699E40 : // audio stream - if(asf_ctrl->audio_streams == NULL){ - asf_ctrl->audio_streams = (int*)mp_malloc(sizeof(int)); - asf_ctrl->n_audio = 1; - } else { - asf_ctrl->n_audio++; - asf_ctrl->audio_streams = (int*)mp_realloc(asf_ctrl->audio_streams, - asf_ctrl->n_audio*sizeof(int)); - } - asf_ctrl->audio_streams[asf_ctrl->n_audio-1] = streamh->stream_no; - break; - case 0xBC19EFC0 : // video stream - if(asf_ctrl->video_streams == NULL){ - asf_ctrl->video_streams = (int*)mp_malloc(sizeof(int)); - asf_ctrl->n_video = 1; - } else { - asf_ctrl->n_video++; - asf_ctrl->video_streams = (int*)mp_realloc(asf_ctrl->video_streams, - asf_ctrl->n_video*sizeof(int)); - } - asf_ctrl->video_streams[asf_ctrl->n_video-1] = streamh->stream_no; - break; - } - } - - // always allocate to avoid lots of ifs later - v_rates = mp_calloc(asf_ctrl->n_video, sizeof(int)); - a_rates = mp_calloc(asf_ctrl->n_audio, sizeof(int)); - - pos = find_asf_guid(buffer, asf_stream_group_guid, start, size); - if (pos >= 0) { - // stream bitrate properties object - int stream_count; - char *ptr = &buffer[pos]; - - MSG_V("Stream bitrate properties object\n"); - stream_count = le2me_16(*(uint16_t*)ptr); - ptr += sizeof(uint16_t); - if (ptr > &buffer[size]) goto len_err_out; - MSG_V(" stream count=[0x%x][%u]\n", - stream_count, stream_count ); - for( i=0 ; i<stream_count ; i++ ) { - uint32_t rate; - int id; - int j; - id = le2me_16(*(uint16_t*)ptr); - ptr += sizeof(uint16_t); - if (ptr > &buffer[size]) goto len_err_out; - memcpy(&rate, ptr, sizeof(uint32_t));// workaround unaligment bug on sparc - ptr += sizeof(uint32_t); - if (ptr > &buffer[size]) goto len_err_out; - rate = le2me_32(rate); - MSG_V( - " stream id=[0x%x][%u]\n", id, id); - MSG_V( - " max bitrate=[0x%x][%u]\n", rate, rate); - for (j = 0; j < asf_ctrl->n_video; j++) { - if (id == asf_ctrl->video_streams[j]) { - MSG_V(" is video stream\n"); - v_rates[j] = rate; - break; - } - } - for (j = 0; j < asf_ctrl->n_audio; j++) { - if (id == asf_ctrl->audio_streams[j]) { - MSG_V( " is audio stream\n"); - a_rates[j] = rate; - break; - } - } - } - } - mp_free(buffer); - - // automatic stream selection based on bandwidth - if (bw == 0) bw = INT_MAX; - MSG_V( "Max bandwidth set to %d\n", bw); - - if (asf_ctrl->n_audio) { - // find lowest-bitrate audio stream - a_rate = a_rates[0]; - a_idx = 0; - for (i = 0; i < asf_ctrl->n_audio; i++) { - if (a_rates[i] < a_rate) { - a_rate = a_rates[i]; - a_idx = i; - } - } - if (max_idx(asf_ctrl->n_video, v_rates, bw - a_rate) < 0) { - // both audio and video are not possible, try video only next - a_idx = -1; - a_rate = 0; - } - } - // find best video stream - v_idx = max_idx(asf_ctrl->n_video, v_rates, bw - a_rate); - if (v_idx >= 0) - v_rate = v_rates[v_idx]; - - // find best audio stream - a_idx = max_idx(asf_ctrl->n_audio, a_rates, bw - v_rate); - - mp_free(v_rates); - mp_free(a_rates); - - if (a_idx < 0 && v_idx < 0) { - MSG_FATAL( "bandwidth too small, " - "file cannot be played!\n"); - return -1; - } - - if (mp_conf.audio_id > 0) - // a audio stream was forced - asf_ctrl->audio_id = mp_conf.audio_id; - else if (a_idx >= 0) - asf_ctrl->audio_id = asf_ctrl->audio_streams[a_idx]; - else if (asf_ctrl->n_audio) { - MSG_WARN( "bandwidth too small, " - "deselected audio stream\n"); - mp_conf.audio_id = -2; - } - - if (mp_conf.video_id > 0) - // a video stream was forced - asf_ctrl->video_id = mp_conf.video_id; - else if (v_idx >= 0) - asf_ctrl->video_id = asf_ctrl->video_streams[v_idx]; - else if (asf_ctrl->n_video) { - MSG_WARN( "bandwidth too small, " - "deselected video stream\n"); - mp_conf.video_id = -2; - } - - return 1; - -len_err_out: - MSG_FATAL( "Invalid length in ASF header!\n"); - if (buffer) mp_free(buffer); - if (v_rates) mp_free(v_rates); - if (a_rates) mp_free(a_rates); - return -1; -} - -int -asf_http_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *streaming_ctrl ) { - static ASF_stream_chunck_t chunk; - int read,chunk_size = 0; - static int rest = 0, drop_chunk = 0, waiting = 0; - asf_http_streaming_ctrl_t *asf_http_ctrl = (asf_http_streaming_ctrl_t*)streaming_ctrl->data; - - while(1) { - if (rest == 0 && waiting == 0) { - read = 0; - while(read < (int)sizeof(ASF_stream_chunck_t)){ - int r = nop_streaming_read( fd, ((char*)&chunk) + read, - sizeof(ASF_stream_chunck_t)-read, - streaming_ctrl ); - if(r <= 0){ - if( r < 0) - MSG_ERR("Error while reading chunk header\n"); - return -1; - } - read += r; - } - - // Endian handling of the stream chunk - le2me_ASF_stream_chunck_t(&chunk); - chunk_size = asf_streaming( &chunk, &drop_chunk ); - if(chunk_size < 0) { - MSG_ERR("Error while parsing chunk header\n"); - return -1; - } - chunk_size -= sizeof(ASF_stream_chunck_t); - - if(chunk.type != ASF_STREAMING_HEADER && (!drop_chunk)) { - if (asf_http_ctrl->packet_size < chunk_size) { - MSG_ERR("Error chunk_size > packet_size\n"); - return -1; - } - waiting = asf_http_ctrl->packet_size; - } else { - waiting = chunk_size; - } - - } else if (rest){ - chunk_size = rest; - rest = 0; - } - - read = 0; - if ( waiting >= chunk_size) { - if (chunk_size > size){ - rest = chunk_size - size; - chunk_size = size; - } - while(read < chunk_size) { - int got = nop_streaming_read( fd,buffer+read,chunk_size-read,streaming_ctrl ); - if(got <= 0) { - if(got < 0) - MSG_ERR("Error while reading chunk\n"); - return -1; - } - read += got; - } - waiting -= read; - if (drop_chunk) continue; - } - if (rest == 0 && waiting > 0 && size-read > 0) { - int s = MIN(waiting,size-read); - memset(buffer+read,0,s); - waiting -= s; - read += s; - } - break; - } - - return read; -} - -int -asf_http_streaming_seek( int fd, off_t pos, streaming_ctrl_t *streaming_ctrl ) { - return -1; - // to shut up gcc warning - fd++; - pos++; - streaming_ctrl=NULL; -} - -int -asf_header_check( HTTP_header_t *http_hdr ) { - ASF_obj_header_t *objh; - if( http_hdr==NULL ) return -1; - if( http_hdr->body==NULL || http_hdr->body_size<sizeof(ASF_obj_header_t) ) return -1; - - objh = (ASF_obj_header_t*)http_hdr->body; - if( ASF_LOAD_GUID_PREFIX(objh->guid)==0x75B22630 ) return 0; - return -1; -} - -int -asf_http_streaming_type(char *content_type, char *features, HTTP_header_t *http_hdr ) { - if( content_type==NULL ) return ASF_Unknown_e; - if( !strcasecmp(content_type, "application/octet-stream") || - !strcasecmp(content_type, "application/vnd.ms.wms-hdr.asfv1") || // New in Corona, first request - !strcasecmp(content_type, "application/x-mms-framed") || // New in Corana, second request - !strcasecmp(content_type, "video/x-ms-asf")) { - - if( strstr(features, "broadcast") ) { - MSG_V("=====> ASF Live stream\n"); - return ASF_Live_e; - } else { - MSG_V("=====> ASF Prerecorded\n"); - return ASF_Prerecorded_e; - } - } else { - // Ok in a perfect world, web servers should be well configured - // so we could used mime type to know the stream type, - // but guess what? All of them are not well configured. - // So we have to check for an asf header :(, but it works :p - if( http_hdr->body_size>sizeof(ASF_obj_header_t) ) { - if( asf_header_check( http_hdr )==0 ) { - MSG_V("=====> ASF Plain text\n"); - return ASF_PlainText_e; - } else if( (!strcasecmp(content_type, "text/html")) ) { - MSG_V("=====> HTML, mplayer is not a browser...yet!\n"); - return ASF_Unknown_e; - } else { - MSG_V("=====> ASF Redirector\n"); - return ASF_Redirector_e; - } - } else { - if( (!strcasecmp(content_type, "audio/x-ms-wax")) || - (!strcasecmp(content_type, "audio/x-ms-wma")) || - (!strcasecmp(content_type, "video/x-ms-asf")) || - (!strcasecmp(content_type, "video/x-ms-afs")) || - (!strcasecmp(content_type, "video/x-ms-wvx")) || - (!strcasecmp(content_type, "video/x-ms-wmv")) || - (!strcasecmp(content_type, "video/x-ms-wma")) ) { - MSG_ERR("=====> ASF Redirector\n"); - return ASF_Redirector_e; - } else if( !strcasecmp(content_type, "text/plain") ) { - MSG_V("=====> ASF Plain text\n"); - return ASF_PlainText_e; - } else { - MSG_V("=====> ASF unknown content-type: %s\n", content_type ); - return ASF_Unknown_e; - } - } - } - return ASF_Unknown_e; -} - -HTTP_header_t * -asf_http_request(streaming_ctrl_t *streaming_ctrl) { - HTTP_header_t *http_hdr; - URL_t *url = NULL; - URL_t *server_url = NULL; - asf_http_streaming_ctrl_t *asf_http_ctrl; - char str[250]; - char *ptr; - int i, enable; - - int offset_hi=0, offset_lo=0, length=0; - int asf_nb_stream=0, stream_id; - - // Sanity check - if( streaming_ctrl==NULL ) return NULL; - url = streaming_ctrl->url; - asf_http_ctrl = (asf_http_streaming_ctrl_t*)streaming_ctrl->data; - if( url==NULL || asf_http_ctrl==NULL ) return NULL; - - // Common header for all requests. - http_hdr = http_new_header(); - http_set_field( http_hdr, "Accept: */*" ); - http_set_field( http_hdr, "User-Agent: NSPlayer/4.1.0.3856" ); - http_add_basic_authentication( http_hdr, url->username, url->password ); - - // Check if we are using a proxy - if( !strcasecmp( url->protocol, "http_proxy" ) ) { - server_url = url_new( (url->file)+1 ); - if( server_url==NULL ) { - MSG_ERR("Invalid proxy URL\n"); - http_free( http_hdr ); - return NULL; - } - http_set_uri( http_hdr, server_url->url ); - sprintf( str, "Host: %.220s:%d", server_url->hostname, server_url->port ); - url_free( server_url ); - } else { - http_set_uri( http_hdr, url->file ); - sprintf( str, "Host: %.220s:%d", url->hostname, url->port ); - } - - http_set_field( http_hdr, str ); - http_set_field( http_hdr, "Pragma: xClientGUID={c77e7400-738a-11d2-9add-0020af0a3278}" ); - sprintf(str, - "Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=%u:%u,request-context=%d,max-duration=%u", - offset_hi, offset_lo, asf_http_ctrl->request, length ); - http_set_field( http_hdr, str ); - - switch( asf_http_ctrl->streaming_type ) { - case ASF_Live_e: - case ASF_Prerecorded_e: - http_set_field( http_hdr, "Pragma: xPlayStrm=1" ); - ptr = str; - ptr += sprintf( ptr, "Pragma: stream-switch-entry="); - if(asf_http_ctrl->n_audio > 0) { - for( i=0; i<asf_http_ctrl->n_audio ; i++ ) { - stream_id = asf_http_ctrl->audio_streams[i]; - if(stream_id == asf_http_ctrl->audio_id) { - enable = 0; - } else { - enable = 2; - continue; - } - asf_nb_stream++; - ptr += sprintf(ptr, "ffff:%d:%d ", stream_id, enable); - } - } - if(asf_http_ctrl->n_video > 0) { - for( i=0; i<asf_http_ctrl->n_video ; i++ ) { - stream_id = asf_http_ctrl->video_streams[i]; - if(stream_id == asf_http_ctrl->video_id) { - enable = 0; - } else { - enable = 2; - continue; - } - asf_nb_stream++; - ptr += sprintf(ptr, "ffff:%d:%d ", stream_id, enable); - } - } - http_set_field( http_hdr, str ); - sprintf( str, "Pragma: stream-switch-count=%d", asf_nb_stream ); - http_set_field( http_hdr, str ); - break; - case ASF_Redirector_e: - break; - case ASF_Unknown_e: - // First request goes here. - break; - default: - MSG_ERR("Unknown asf stream type\n"); - } - - http_set_field( http_hdr, "Connection: Close" ); - http_build_request( http_hdr ); - - return http_hdr; -} - -int -asf_http_parse_response(asf_http_streaming_ctrl_t *asf_http_ctrl, HTTP_header_t *http_hdr ) { - char *content_type, *pragma; - char features[64] = "\0"; - size_t len; - if( http_response_parse(http_hdr)<0 ) { - MSG_ERR("Failed to parse HTTP response\n"); - return -1; - } - switch( http_hdr->status_code ) { - case 200: - break; - case 401: // Authentication required - return ASF_Authenticate_e; - default: - MSG_ERR("Server return %d:%s\n", http_hdr->status_code, http_hdr->reason_phrase); - return -1; - } - - content_type = http_get_field( http_hdr, "Content-Type"); - - pragma = http_get_field( http_hdr, "Pragma"); - while( pragma!=NULL ) { - char *comma_ptr=NULL; - char *end; - // The pragma line can get severals attributes - // separeted with a comma ','. - do { - if( !strncasecmp( pragma, "features=", 9) ) { - pragma += 9; - end = strstr( pragma, "," ); - if( end==NULL ) { - size_t s = strlen(pragma); - if(s > sizeof(features)) { - MSG_WARN("ASF HTTP PARSE WARNING : Pragma %s cuted from %d bytes to %d\n",pragma,s,sizeof(features)); - len = sizeof(features); - } else { - len = s; - } - } else { - len = MIN((unsigned int)(end-pragma),sizeof(features)); - } - strncpy( features, pragma, len ); - features[len]='\0'; - break; - } - comma_ptr = strstr( pragma, "," ); - if( comma_ptr!=NULL ) { - pragma = comma_ptr+1; - if( pragma[0]==' ' ) pragma++; - } - } while( comma_ptr!=NULL ); - pragma = http_get_next_field( http_hdr ); - } - asf_http_ctrl->streaming_type = asf_http_streaming_type( content_type, features, http_hdr ); - return 0; -} - -static int asf_http_streaming_start(any_t*libinput, stream_t *stream, int *demuxer_type ) { - HTTP_header_t *http_hdr=NULL; - URL_t *url = stream->streaming_ctrl->url; - asf_http_streaming_ctrl_t *asf_http_ctrl; - char buffer[BUFFER_SIZE]; - int i, ret; - int fd = stream->fd; - int done; - int auth_retry = 0; - - asf_http_ctrl = (asf_http_streaming_ctrl_t*)mp_malloc(sizeof(asf_http_streaming_ctrl_t)); - if( asf_http_ctrl==NULL ) { - MSG_FATAL("Memory allocation failed\n"); - return -1; - } - asf_http_ctrl->streaming_type = ASF_Unknown_e; - asf_http_ctrl->request = 1; - asf_http_ctrl->audio_streams = asf_http_ctrl->video_streams = NULL; - asf_http_ctrl->n_audio = asf_http_ctrl->n_video = 0; - stream->streaming_ctrl->data = (any_t*)asf_http_ctrl; - - do { - done = 1; - if( fd>0 ) closesocket( fd ); - - if( !strcasecmp( url->protocol, "http_proxy" ) ) { - if( url->port==0 ) url->port = 8080; - } else { - if( url->port==0 ) url->port = 80; - } - fd = tcp_connect2Server(libinput, url->hostname, url->port, 0); - if( fd<0 ) return fd; - - http_hdr = asf_http_request( stream->streaming_ctrl ); - MSG_DBG2("Request [%s]\n", http_hdr->buffer ); - for(i=0; i < (int)http_hdr->buffer_size ; ) { - int r = send( fd, http_hdr->buffer+i, http_hdr->buffer_size-i, 0); - if(r <0) { - MSG_ERR("Socket write error : %s\n",strerror(errno)); - return -1; - } - i += r; - } - http_free( http_hdr ); - http_hdr = http_new_header(); - do { - i = recv( fd, buffer, BUFFER_SIZE, 0); - if( i<=0 ) { - perror("read"); - http_free( http_hdr ); - return -1; - } - http_response_append( http_hdr, buffer, i ); - } while( !http_is_header_entire( http_hdr ) ); - if( mp_conf.verbose>0 ) { - http_hdr->buffer[http_hdr->buffer_size]='\0'; - MSG_DBG2("Response [%s]\n", http_hdr->buffer ); - } - ret = asf_http_parse_response(asf_http_ctrl, http_hdr); - if( ret<0 ) { - MSG_ERR("Failed to parse header\n"); - http_free( http_hdr ); - return -1; - } - switch( asf_http_ctrl->streaming_type ) { - case ASF_Live_e: - case ASF_Prerecorded_e: - case ASF_PlainText_e: - if( http_hdr->body_size>0 ) { - if( streaming_bufferize( stream->streaming_ctrl, http_hdr->body, http_hdr->body_size )<0 ) { - http_free( http_hdr ); - return -1; - } - } - if( asf_http_ctrl->request==1 ) { - if( asf_http_ctrl->streaming_type!=ASF_PlainText_e ) { - // First request, we only got the ASF header. - ret = asf_streaming_parse_header(fd,stream->streaming_ctrl); - if(ret < 0) return -1; - if(asf_http_ctrl->n_audio == 0 && asf_http_ctrl->n_video == 0) { - MSG_ERR("No stream found\n");... [truncated message content] |
From: <nic...@us...> - 2012-11-19 13:14:31
|
Revision: 410 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=410&view=rev Author: nickols_k Date: 2012-11-19 13:14:21 +0000 (Mon, 19 Nov 2012) Log Message: ----------- cleanups Modified Paths: -------------- mplayerxp/libmpdemux/Makefile mplayerxp/libmpstream/mrl.c mplayerxp/libmpstream/realrtsp/md5.c mplayerxp/libmpsub/subreader.c mplayerxp/libvo/jpeg_enc.c mplayerxp/loader/dshow/Makefile Added Paths: ----------- TOOLS/examples/ TOOLS/examples/demux_test.c TOOLS/examples/dshow_test.c TOOLS/examples/dump_subs.c TOOLS/examples/test.divx TOOLS/examples/test_av_md5.c TOOLS/examples/test_jpegenc.c TOOLS/examples/test_mrl.c Removed Paths: ------------- mplayerxp/libmpdemux/test.c mplayerxp/loader/dshow/test.c mplayerxp/loader/dshow/test.divx Copied: TOOLS/examples/demux_test.c (from rev 409, mplayerxp/libmpdemux/test.c) =================================================================== --- TOOLS/examples/demux_test.c (rev 0) +++ TOOLS/examples/demux_test.c 2012-11-19 13:14:21 UTC (rev 410) @@ -0,0 +1,58 @@ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "../mp_config.h" + +#include "libmpstream/stream.h" +#include "demuxer.h" +#include "stheader.h" +#include "demux_msg.h" + +//-------------------------- + +// audio stream skip/resync functions requires only for seeking. +// (they should be implemented in the audio codec layer) +void mpca_skip_frame(sh_audio_t *sh_audio){ +} +void mpca_resync_stream(sh_audio_t *sh_audio){ +} + +int verbose=5; // must be global! + +//--------------- + +extern stream_t* open_stream(amy_t*libinput,char* filename,int* file_format); + +int main(int argc,char* argv[]){ + +stream_t* stream=NULL; +demuxer_t* demuxer=NULL; +int file_format=DEMUXER_TYPE_UNKNOWN; + + mp_msg_init(verbose+MSGL_STATUS); + + if(argc>1) + stream=open_stream(NULL,argv[1],0,&file_format); + else +// stream=open_stream("/3d/divx/405divx_sm_v2[1].avi",0,&file_format); + stream=open_stream(NULL,"/dev/cdrom",2,&file_format); // VCD track 2 + + if(!stream){ + printf("Cannot open file/device\n"); + exit(1); + } + + printf("success: format: %d data: 0x%X - 0x%X\n",file_format, (int)(stream->start_pos),(int)(stream->end_pos)); + + stream_enable_cache(stream,NULL,2048*1024,0,0); + + demuxer=demux_open(stream,file_format,-1,-1,-1); + if(!demuxer){ + printf("Cannot open demuxer\n"); + exit(1); + } + + +} Copied: TOOLS/examples/dshow_test.c (from rev 409, mplayerxp/loader/dshow/test.c) =================================================================== --- TOOLS/examples/dshow_test.c (rev 0) +++ TOOLS/examples/dshow_test.c 2012-11-19 13:14:21 UTC (rev 410) @@ -0,0 +1,67 @@ +#include <stdio.h> +#include <stdlib.h> + +#include "formats.h" +#include "com.h" + +#include "DS_VideoDec.h" + +int main(int argc,char* argv[]){ + FILE *f; + BITMAPINFOHEADER bih; + int len; + char *src; + char *dst=0; + GUID CLSID_DivxDecompressorCF={0x82CCd3E0, 0xF71A, 0x11D0, + { 0x9f, 0xe5, 0x00, 0x60, 0x97, 0x78, 0xaa, 0xaa}}; + + f=fopen("test.divx","rb"); + + fread(&bih,sizeof(BITMAPINFOHEADER),1,f); + printf("frame dim: %d x %d \n",(int)bih.biWidth,(int)bih.biHeight); + + src=(char*)mp_malloc(512000); + len=fread(src,1,512000,f); + printf("frame len = %d\n",len); + + DS_VideoDecoder_Open("divx_c32.ax", &CLSID_DivxDecompressorCF, &bih, 0, &dst); + +// DS_VideoDecoder_SetDestFmt(16,fccYUY2); + DS_VideoDecoder_SetDestFmt(24,0); + + printf("DivX setting result = %d\n", DS_SetAttr_DivX("Quality",4) ); + + DS_VideoDecoder_Start(); + + printf("DivX setting result = %d\n", DS_SetValue_DivX("Brightness",60) ); + + DS_VideoDecoder_DecodeFrame(src, len, 1, 1); + +#if 0 + f2=fopen("test.yuy2","wb"); + fwrite(dst,bih.biWidth*bih.biHeight*2,1,f2); + fclose(f2); +#endif + + { unsigned char raw_head[32]; + FILE *f3=fopen("test.raw","wb"); + + strcpy((char*)raw_head,"mhwanh"); + raw_head[7]=4; + raw_head[8]=bih.biWidth>>8; + raw_head[9]=bih.biWidth&0xFF; + raw_head[10]=bih.biHeight>>8; + raw_head[11]=bih.biHeight&0xFF; + raw_head[12]=raw_head[13]=0; // 24bit + raw_head[14]=1;raw_head[15]=0x2C; + raw_head[16]=1;raw_head[17]=0x2C; + memset(raw_head+18,0,32-18); + fwrite(raw_head,32,1,f3); + + fwrite(dst,bih.biWidth*bih.biHeight*3,1,f3); + fclose(f3); + } + + fclose(f); + return 0; +} Added: TOOLS/examples/dump_subs.c =================================================================== --- TOOLS/examples/dump_subs.c (rev 0) +++ TOOLS/examples/dump_subs.c 2012-11-19 13:14:21 UTC (rev 410) @@ -0,0 +1,25 @@ +#include "libmpsub/subreader.h" + +#ifdef DUMPSUBS +int main(int argc, char **argv) { // for testing + + int i,j; + subtitle *subs; + subtitle *egysub; + + if(argc<2){ + printf("\nUsage: subreader filename.sub\n\n"); + exit(1); + } + sub_cp = argv[2]; + subs=sub_read_file(argv[1]); + if(!subs){ + printf("Couldn't load file.\n"); + exit(1); + } + + list_sub_file(subs); + + return 0; +} +#endif Property changes on: TOOLS/examples/dump_subs.c ___________________________________________________________________ Added: svn:eol-style + native Copied: TOOLS/examples/test.divx (from rev 409, mplayerxp/loader/dshow/test.divx) =================================================================== (Binary files differ) Added: TOOLS/examples/test_av_md5.c =================================================================== --- TOOLS/examples/test_av_md5.c (rev 0) +++ TOOLS/examples/test_av_md5.c 2012-11-19 13:14:21 UTC (rev 410) @@ -0,0 +1,17 @@ +#ifdef TEST +#include <stdio.h> +#undef printf +main(){ + uint64_t md5val; + int i; + uint8_t in[1000]; + + for(i=0; i<1000; i++) in[i]= i*i; + av_md5_sum( (uint8_t*)&md5val, in, 1000); printf("%"PRId64"\n", md5val); + av_md5_sum( (uint8_t*)&md5val, in, 63); printf("%"PRId64"\n", md5val); + av_md5_sum( (uint8_t*)&md5val, in, 64); printf("%"PRId64"\n", md5val); + av_md5_sum( (uint8_t*)&md5val, in, 65); printf("%"PRId64"\n", md5val); + for(i=0; i<1000; i++) in[i]= i % 127; + av_md5_sum( (uint8_t*)&md5val, in, 999); printf("%"PRId64"\n", md5val); +} +#endif Property changes on: TOOLS/examples/test_av_md5.c ___________________________________________________________________ Added: svn:eol-style + native Added: TOOLS/examples/test_jpegenc.c =================================================================== --- TOOLS/examples/test_jpegenc.c (rev 0) +++ TOOLS/examples/test_jpegenc.c 2012-11-19 13:14:21 UTC (rev 410) @@ -0,0 +1,22 @@ +#define W 32 +#define H 32 + +int quant_store[MBR+1][MBC+1]; +unsigned char buf[W*H*3/2]; +char code[256*1024]; + + +main() { + int i, size; + FILE *fp; + + memset(buf, 0, W*H); + memset(buf+W*H, 255, W*H/4); + memset(buf+5*W*H/4, 0, W*H/4); + mjpeg_encoder_init(W, H, 1, W, 1, W/2, 1, W/2, 1, 1, 0); + + size = mjpeg_encode_frame(buf, buf+W*H, buf+5*W*H/4, code); + fp = fopen("test.jpg", "w"); + fwrite(code, 1, size, fp); + fclose(fp); +} Property changes on: TOOLS/examples/test_jpegenc.c ___________________________________________________________________ Added: svn:eol-style + native Added: TOOLS/examples/test_mrl.c =================================================================== --- TOOLS/examples/test_mrl.c (rev 0) +++ TOOLS/examples/test_mrl.c 2012-11-19 13:14:21 UTC (rev 410) @@ -0,0 +1,33 @@ +#include "mrl.h" + +#ifdef TEST_MRL +int main(int argc, char *argv[]) +{ + char *user,*pass,*ms,*port; + const char *param; + if(argc < 2) + { + fprintf(stderr,"Needs argument\n"); + return EXIT_FAILURE; + } + if(memcmp(argv[1],"mrl://",6)!=0) + { + fprintf(stderr,"argument's line doesn't start from 'mrl://'!\n"); + return EXIT_FAILURE; + } + param=mrl_parse_line(&argv[1][6],&user,&pass,&ms,&port); + printf("Source line: '%s'\n",argv[1]); + printf("user: '%s'\n",user); + printf("pass: '%s'\n",pass); + printf("ms: '%s'\n",ms); + printf("port: '%s'\n",port); + printf("arguments: '%s'\n",param); + param=mrl_parse_params(param,NULL); + printf("unparsed params: '%s'\n",param); + if(user) mp_free(user); + if(pass) mp_free(pass); + if(ms) mp_free(ms); + if(port) mp_free(port); + return EXIT_SUCCESS; +} +#endif Property changes on: TOOLS/examples/test_mrl.c ___________________________________________________________________ Added: svn:eol-style + native Modified: mplayerxp/libmpdemux/Makefile =================================================================== --- mplayerxp/libmpdemux/Makefile 2012-11-19 12:50:35 UTC (rev 409) +++ mplayerxp/libmpdemux/Makefile 2012-11-19 13:14:21 UTC (rev 410) @@ -60,9 +60,6 @@ $(wildcard realrtsp/*.o) endif -test: $(LIBNAME) test.c - $(CC) $(CFLAGS) test.c ../mp_msg.c ../linux/shmem.c -o test -L. -lmpdemux -ldvdread -lz -lpthread - clean: $(DO_MAKE) rm -f *.o *.a *~ @@ -75,7 +72,7 @@ depend: $(DO_MAKE) - $(CC) -MM $(CFLAGS) test.c $(SRCS) $(CXXSRCS) 1>.depend + $(CC) -MM $(CFLAGS) $(SRCS) $(CXXSRCS) 1>.depend # # include dependency files if they exist Deleted: mplayerxp/libmpdemux/test.c =================================================================== --- mplayerxp/libmpdemux/test.c 2012-11-19 12:50:35 UTC (rev 409) +++ mplayerxp/libmpdemux/test.c 2012-11-19 13:14:21 UTC (rev 410) @@ -1,58 +0,0 @@ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "../mp_config.h" - -#include "libmpstream/stream.h" -#include "demuxer.h" -#include "stheader.h" -#include "demux_msg.h" - -//-------------------------- - -// audio stream skip/resync functions requires only for seeking. -// (they should be implemented in the audio codec layer) -void mpca_skip_frame(sh_audio_t *sh_audio){ -} -void mpca_resync_stream(sh_audio_t *sh_audio){ -} - -int verbose=5; // must be global! - -//--------------- - -extern stream_t* open_stream(amy_t*libinput,char* filename,int* file_format); - -int main(int argc,char* argv[]){ - -stream_t* stream=NULL; -demuxer_t* demuxer=NULL; -int file_format=DEMUXER_TYPE_UNKNOWN; - - mp_msg_init(verbose+MSGL_STATUS); - - if(argc>1) - stream=open_stream(NULL,argv[1],0,&file_format); - else -// stream=open_stream("/3d/divx/405divx_sm_v2[1].avi",0,&file_format); - stream=open_stream(NULL,"/dev/cdrom",2,&file_format); // VCD track 2 - - if(!stream){ - printf("Cannot open file/device\n"); - exit(1); - } - - printf("success: format: %d data: 0x%X - 0x%X\n",file_format, (int)(stream->start_pos),(int)(stream->end_pos)); - - stream_enable_cache(stream,NULL,2048*1024,0,0); - - demuxer=demux_open(stream,file_format,-1,-1,-1); - if(!demuxer){ - printf("Cannot open demuxer\n"); - exit(1); - } - - -} Modified: mplayerxp/libmpstream/mrl.c =================================================================== --- mplayerxp/libmpstream/mrl.c 2012-11-19 12:50:35 UTC (rev 409) +++ mplayerxp/libmpstream/mrl.c 2012-11-19 13:14:21 UTC (rev 410) @@ -177,35 +177,3 @@ if(value) mp_free(value); return param; } - -#ifdef TEST_MRL -int main(int argc, char *argv[]) -{ - char *user,*pass,*ms,*port; - const char *param; - if(argc < 2) - { - fprintf(stderr,"Needs argument\n"); - return EXIT_FAILURE; - } - if(memcmp(argv[1],"mrl://",6)!=0) - { - fprintf(stderr,"argument's line doesn't start from 'mrl://'!\n"); - return EXIT_FAILURE; - } - param=mrl_parse_line(&argv[1][6],&user,&pass,&ms,&port); - printf("Source line: '%s'\n",argv[1]); - printf("user: '%s'\n",user); - printf("pass: '%s'\n",pass); - printf("ms: '%s'\n",ms); - printf("port: '%s'\n",port); - printf("arguments: '%s'\n",param); - param=mrl_parse_params(param,NULL); - printf("unparsed params: '%s'\n",param); - if(user) mp_free(user); - if(pass) mp_free(pass); - if(ms) mp_free(ms); - if(port) mp_free(port); - return EXIT_SUCCESS; -} -#endif Modified: mplayerxp/libmpstream/realrtsp/md5.c =================================================================== --- mplayerxp/libmpstream/realrtsp/md5.c 2012-11-19 12:50:35 UTC (rev 409) +++ mplayerxp/libmpstream/realrtsp/md5.c 2012-11-19 13:14:21 UTC (rev 410) @@ -160,21 +160,3 @@ av_md5_update(ctx, src, len); av_md5_final(ctx, dst); } - -#ifdef TEST -#include <stdio.h> -#undef printf -main(){ - uint64_t md5val; - int i; - uint8_t in[1000]; - - for(i=0; i<1000; i++) in[i]= i*i; - av_md5_sum( (uint8_t*)&md5val, in, 1000); printf("%"PRId64"\n", md5val); - av_md5_sum( (uint8_t*)&md5val, in, 63); printf("%"PRId64"\n", md5val); - av_md5_sum( (uint8_t*)&md5val, in, 64); printf("%"PRId64"\n", md5val); - av_md5_sum( (uint8_t*)&md5val, in, 65); printf("%"PRId64"\n", md5val); - for(i=0; i<1000; i++) in[i]= i % 127; - av_md5_sum( (uint8_t*)&md5val, in, 999); printf("%"PRId64"\n", md5val); -} -#endif Modified: mplayerxp/libmpsub/subreader.c =================================================================== --- mplayerxp/libmpsub/subreader.c 2012-11-19 12:50:35 UTC (rev 409) +++ mplayerxp/libmpsub/subreader.c 2012-11-19 13:14:21 UTC (rev 410) @@ -858,27 +858,3 @@ mp_free( subs ); subs=NULL; } - -#ifdef DUMPSUBS -int main(int argc, char **argv) { // for testing - - int i,j; - subtitle *subs; - subtitle *egysub; - - if(argc<2){ - printf("\nUsage: subreader filename.sub\n\n"); - exit(1); - } - sub_cp = argv[2]; - subs=sub_read_file(argv[1]); - if(!subs){ - printf("Couldn't load file.\n"); - exit(1); - } - - list_sub_file(subs); - - return 0; -} -#endif Modified: mplayerxp/libvo/jpeg_enc.c =================================================================== --- mplayerxp/libvo/jpeg_enc.c 2012-11-19 12:50:35 UTC (rev 409) +++ mplayerxp/libvo/jpeg_enc.c 2012-11-19 13:14:21 UTC (rev 410) @@ -452,28 +452,3 @@ mp_free(j); } -#if 0 - -#define W 32 -#define H 32 - -int quant_store[MBR+1][MBC+1]; -unsigned char buf[W*H*3/2]; -char code[256*1024]; - - -main() { - int i, size; - FILE *fp; - - memset(buf, 0, W*H); - memset(buf+W*H, 255, W*H/4); - memset(buf+5*W*H/4, 0, W*H/4); - mjpeg_encoder_init(W, H, 1, W, 1, W/2, 1, W/2, 1, 1, 0); - - size = mjpeg_encode_frame(buf, buf+W*H, buf+5*W*H/4, code); - fp = fopen("test.jpg", "w"); - fwrite(code, 1, size, fp); - fclose(fp); -} -#endif Modified: mplayerxp/loader/dshow/Makefile =================================================================== --- mplayerxp/loader/dshow/Makefile 2012-11-19 12:50:35 UTC (rev 409) +++ mplayerxp/loader/dshow/Makefile 2012-11-19 13:14:21 UTC (rev 410) @@ -30,7 +30,7 @@ rm -f *.o $(LIBNAME) *~ distclean: - rm -f Makefile.bak *.o $(LIBNAME) *~ .depend test test.raw + rm -f Makefile.bak *.o $(LIBNAME) *~ .depend dep: depend Deleted: mplayerxp/loader/dshow/test.c =================================================================== --- mplayerxp/loader/dshow/test.c 2012-11-19 12:50:35 UTC (rev 409) +++ mplayerxp/loader/dshow/test.c 2012-11-19 13:14:21 UTC (rev 410) @@ -1,67 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -#include "formats.h" -#include "com.h" - -#include "DS_VideoDec.h" - -int main(int argc,char* argv[]){ - FILE *f; - BITMAPINFOHEADER bih; - int len; - char *src; - char *dst=0; - GUID CLSID_DivxDecompressorCF={0x82CCd3E0, 0xF71A, 0x11D0, - { 0x9f, 0xe5, 0x00, 0x60, 0x97, 0x78, 0xaa, 0xaa}}; - - f=fopen("test.divx","rb"); - - fread(&bih,sizeof(BITMAPINFOHEADER),1,f); - printf("frame dim: %d x %d \n",(int)bih.biWidth,(int)bih.biHeight); - - src=(char*)mp_malloc(512000); - len=fread(src,1,512000,f); - printf("frame len = %d\n",len); - - DS_VideoDecoder_Open("divx_c32.ax", &CLSID_DivxDecompressorCF, &bih, 0, &dst); - -// DS_VideoDecoder_SetDestFmt(16,fccYUY2); - DS_VideoDecoder_SetDestFmt(24,0); - - printf("DivX setting result = %d\n", DS_SetAttr_DivX("Quality",4) ); - - DS_VideoDecoder_Start(); - - printf("DivX setting result = %d\n", DS_SetValue_DivX("Brightness",60) ); - - DS_VideoDecoder_DecodeFrame(src, len, 1, 1); - -#if 0 - f2=fopen("test.yuy2","wb"); - fwrite(dst,bih.biWidth*bih.biHeight*2,1,f2); - fclose(f2); -#endif - - { unsigned char raw_head[32]; - FILE *f3=fopen("test.raw","wb"); - - strcpy((char*)raw_head,"mhwanh"); - raw_head[7]=4; - raw_head[8]=bih.biWidth>>8; - raw_head[9]=bih.biWidth&0xFF; - raw_head[10]=bih.biHeight>>8; - raw_head[11]=bih.biHeight&0xFF; - raw_head[12]=raw_head[13]=0; // 24bit - raw_head[14]=1;raw_head[15]=0x2C; - raw_head[16]=1;raw_head[17]=0x2C; - memset(raw_head+18,0,32-18); - fwrite(raw_head,32,1,f3); - - fwrite(dst,bih.biWidth*bih.biHeight*3,1,f3); - fclose(f3); - } - - fclose(f); - return 0; -} Deleted: mplayerxp/loader/dshow/test.divx =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-11-20 17:02:11
|
Revision: 417 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=417&view=rev Author: nickols_k Date: 2012-11-20 17:01:59 +0000 (Tue, 20 Nov 2012) Log Message: ----------- more c++ sources + constantization Modified Paths: -------------- mplayerxp/libmpstream/Makefile mplayerxp/libmpstream/cdd.h mplayerxp/libmpsub/Makefile mplayerxp/libmpsub/spudec.h mplayerxp/libmpsub/subreader.h mplayerxp/libmpsub/vobsub.h mplayerxp/libvo/Makefile mplayerxp/mp-opt-reg.cpp mplayerxp/mplayerxp.cpp mplayerxp/mplayerxp.h mplayerxp/nls/nls.h Added Paths: ----------- mplayerxp/libmpstream/s_cdd.cpp mplayerxp/libmpstream/s_dvdnav.cpp mplayerxp/libmpstream/s_ffmpeg.cpp mplayerxp/libmpstream/s_file.cpp mplayerxp/libmpstream/s_null.cpp mplayerxp/libmpsub/find_sub.cpp mplayerxp/libmpsub/subreader.cpp mplayerxp/libmpsub/vobsub.cpp mplayerxp/libvo/osd.cpp mplayerxp/libvo/sub.cpp Removed Paths: ------------- mplayerxp/libmpstream/s_cdd.c mplayerxp/libmpstream/s_dvdnav.c mplayerxp/libmpstream/s_ffmpeg.c mplayerxp/libmpstream/s_file.c mplayerxp/libmpstream/s_null.c mplayerxp/libmpsub/find_sub.c mplayerxp/libmpsub/subreader.c mplayerxp/libmpsub/vobsub.c mplayerxp/libvo/osd.c mplayerxp/libvo/sub.c Modified: mplayerxp/libmpstream/Makefile =================================================================== --- mplayerxp/libmpstream/Makefile 2012-11-20 16:18:38 UTC (rev 416) +++ mplayerxp/libmpstream/Makefile 2012-11-20 17:01:59 UTC (rev 417) @@ -7,16 +7,16 @@ DO_ALL = @ for i in $(SUBDIRS); do $(MAKE) -C $$i all || exit; done CXXSRCS=s_tv.cpp -SRCS = s_file.c s_ffmpeg.c s_null.c +CXXSRCS+= s_file.cpp s_ffmpeg.cpp s_null.cpp ifeq ($(HAVE_LIBCDIO_CDDA),yes) -SRCS += s_cdd.c +CXXSRCS += s_cdd.cpp CXXSRCS += cdda.cpp ifeq ($(HAVE_STREAMING),yes) CXXSRCS += cddb.cpp endif endif ifeq ($(USE_DVDNAV),yes) -SRCS += s_dvdnav.c +CXXSRCS += s_dvdnav.cpp endif ifeq ($(USE_DVDREAD),yes) SRCS += s_dvdread.c Modified: mplayerxp/libmpstream/cdd.h =================================================================== --- mplayerxp/libmpstream/cdd.h 2012-11-20 16:18:38 UTC (rev 416) +++ mplayerxp/libmpstream/cdd.h 2012-11-20 17:01:59 UTC (rev 417) @@ -3,10 +3,6 @@ #include <cdio/cdda.h> #include "libmpconf/cfgparser.h" -#ifdef __cplusplus -extern "C" { -#endif - typedef struct { char cddb_hello[1024]; unsigned long disc_id; @@ -80,7 +76,4 @@ off_t __FASTCALL__ tell_cdda(const stream_t* s); void __FASTCALL__ close_cdda(stream_t* s); void cdda_register_options(m_config_t* cfg); -#ifdef __cplusplus -} -#endif #endif // __CDD_H__ Deleted: mplayerxp/libmpstream/s_cdd.c =================================================================== --- mplayerxp/libmpstream/s_cdd.c 2012-11-20 16:18:38 UTC (rev 416) +++ mplayerxp/libmpstream/s_cdd.c 2012-11-20 17:01:59 UTC (rev 417) @@ -1,133 +0,0 @@ -/* - s_cdd - cdda & cddb streams interface -*/ -#include "mp_config.h" -#include "mplayerxp.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "stream.h" -#include "osdep/mplib.h" -#include "stream_msg.h" - -#ifdef HAVE_LIBCDIO -#include "cdd.h" -#include "mrl.h" - -static track_t track_idx=255; -static MPXP_Rc __FASTCALL__ _cdda_open(any_t*libinput,stream_t *stream,const char *filename,unsigned flags) -{ - const char *param; - char *device; - int retval; - UNUSED(libinput); - UNUSED(flags); - stream->type=STREAMTYPE_RAWAUDIO|STREAMTYPE_SEEKABLE; - stream->sector_size=CD_FRAMESIZE_RAW; - if(strcmp(filename,"help") == 0) { - MSG_HINT("Usage: cdda://<@device><#trackno>\n"); - return MPXP_False; - } - param=mrl_parse_line(filename,NULL,NULL,&device,NULL); - retval = open_cdda(stream,device ? device : DEFAULT_CDROM_DEVICE,param); - if(device) mp_free(device); - check_pin("stream",stream->pin,STREAM_PIN); - return retval; -} - -static MPXP_Rc __FASTCALL__ _cddb_open(any_t*libinput,stream_t *stream,const char *filename,unsigned flags) -{ - const char *param; - char *device; - int retval; - UNUSED(flags); - stream->type=STREAMTYPE_RAWAUDIO|STREAMTYPE_SEEKABLE; - stream->sector_size=CD_FRAMESIZE_RAW; - if(strcmp(filename,"help") == 0) { - MSG_HINT("Usage: cddb://<@device><#trackno>\n"); - return MPXP_False; - } - param=mrl_parse_line(filename,NULL,NULL,&device,NULL); - retval = open_cddb(stream,device ? device : DEFAULT_CDROM_DEVICE,param); - if(device) mp_free(device); - check_pin("stream",stream->pin,STREAM_PIN); - return retval; -} - -static int __FASTCALL__ cdd_read(stream_t*stream,stream_packet_t*sp) -{ - sp->type=0; - sp->len=read_cdda(stream,sp->buf,&track_idx); - return sp->len; -} - -static off_t __FASTCALL__ cdd_seek(stream_t*stream,off_t pos) -{ - seek_cdda(stream,pos,&track_idx); - return pos; -} - -static off_t __FASTCALL__ cdd_tell(const stream_t*stream) -{ - return tell_cdda(stream); -} - -static void __FASTCALL__ cdd_close(stream_t*stream) -{ - close_cdda(stream); -} - -static MPXP_Rc __FASTCALL__ cdd_ctrl(const stream_t *s,unsigned cmd,any_t*args) -{ - cdda_priv *p=s->priv; - switch(cmd) { - case SCTRL_TXT_GET_STREAM_NAME: { - if(track_idx!=255) - sprintf((char *)args,"Track %d",track_idx); - return MPXP_Ok; - } - break; - case SCTRL_AUD_GET_CHANNELS: - *(int *)args=cdio_cddap_track_channels(p->cd, track_idx); - if(*(int *)args<=0) *(int *)args=2; - MSG_V("cdda channels: %u\n",*(int *)args); - return MPXP_Ok; - case SCTRL_AUD_GET_SAMPLERATE: - *(int *)args = 44100; - return MPXP_Ok; - case SCTRL_AUD_GET_SAMPLESIZE: - *(int *)args=2; - return MPXP_Ok; - case SCTRL_AUD_GET_FORMAT: - *(int *)args=0x01; /* Raw PCM */ - return MPXP_Ok; - default: break; - } - return MPXP_False; -} - -const stream_driver_t cdda_stream= -{ - "cdda://", - "reads multimedia stream directly from Digital Audio Compact Disc [CD-DA]", - _cdda_open, - cdd_read, - cdd_seek, - cdd_tell, - cdd_close, - cdd_ctrl -}; - -const stream_driver_t cddb_stream= -{ - "cddb://", - "reads multimedia stream from CD-DA but tracks names from CDDB servers", - _cddb_open, - cdd_read, - cdd_seek, - cdd_tell, - cdd_close, - cdd_ctrl -}; -#endif Copied: mplayerxp/libmpstream/s_cdd.cpp (from rev 414, mplayerxp/libmpstream/s_cdd.c) =================================================================== --- mplayerxp/libmpstream/s_cdd.cpp (rev 0) +++ mplayerxp/libmpstream/s_cdd.cpp 2012-11-20 17:01:59 UTC (rev 417) @@ -0,0 +1,133 @@ +/* + s_cdd - cdda & cddb streams interface +*/ +#include "mp_config.h" +#include "mplayerxp.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "stream.h" +#include "osdep/mplib.h" +#include "stream_msg.h" + +#ifdef HAVE_LIBCDIO +#include "cdd.h" +#include "mrl.h" + +static track_t track_idx=255; +static MPXP_Rc __FASTCALL__ _cdda_open(any_t*libinput,stream_t *stream,const char *filename,unsigned flags) +{ + const char *param; + char *device; + MPXP_Rc retval; + UNUSED(libinput); + UNUSED(flags); + stream->type=STREAMTYPE_RAWAUDIO|STREAMTYPE_SEEKABLE; + stream->sector_size=CD_FRAMESIZE_RAW; + if(strcmp(filename,"help") == 0) { + MSG_HINT("Usage: cdda://<@device><#trackno>\n"); + return MPXP_False; + } + param=mrl_parse_line(filename,NULL,NULL,&device,NULL); + retval = open_cdda(stream,device ? device : DEFAULT_CDROM_DEVICE,param); + if(device) mp_free(device); + check_pin("stream",stream->pin,STREAM_PIN); + return retval; +} + +static MPXP_Rc __FASTCALL__ _cddb_open(any_t*libinput,stream_t *stream,const char *filename,unsigned flags) +{ + const char *param; + char *device; + MPXP_Rc retval; + UNUSED(flags); + stream->type=STREAMTYPE_RAWAUDIO|STREAMTYPE_SEEKABLE; + stream->sector_size=CD_FRAMESIZE_RAW; + if(strcmp(filename,"help") == 0) { + MSG_HINT("Usage: cddb://<@device><#trackno>\n"); + return MPXP_False; + } + param=mrl_parse_line(filename,NULL,NULL,&device,NULL); + retval = open_cddb(stream,device ? device : DEFAULT_CDROM_DEVICE,param); + if(device) mp_free(device); + check_pin("stream",stream->pin,STREAM_PIN); + return retval; +} + +static int __FASTCALL__ cdd_read(stream_t*stream,stream_packet_t*sp) +{ + sp->type=0; + sp->len=read_cdda(stream,sp->buf,&track_idx); + return sp->len; +} + +static off_t __FASTCALL__ cdd_seek(stream_t*stream,off_t pos) +{ + seek_cdda(stream,pos,&track_idx); + return pos; +} + +static off_t __FASTCALL__ cdd_tell(const stream_t*stream) +{ + return tell_cdda(stream); +} + +static void __FASTCALL__ cdd_close(stream_t*stream) +{ + close_cdda(stream); +} + +static MPXP_Rc __FASTCALL__ cdd_ctrl(const stream_t *s,unsigned cmd,any_t*args) +{ + cdda_priv *p=reinterpret_cast<cdda_priv*>(s->priv); + switch(cmd) { + case SCTRL_TXT_GET_STREAM_NAME: { + if(track_idx!=255) + sprintf((char *)args,"Track %d",track_idx); + return MPXP_Ok; + } + break; + case SCTRL_AUD_GET_CHANNELS: + *(int *)args=cdio_cddap_track_channels(p->cd, track_idx); + if(*(int *)args<=0) *(int *)args=2; + MSG_V("cdda channels: %u\n",*(int *)args); + return MPXP_Ok; + case SCTRL_AUD_GET_SAMPLERATE: + *(int *)args = 44100; + return MPXP_Ok; + case SCTRL_AUD_GET_SAMPLESIZE: + *(int *)args=2; + return MPXP_Ok; + case SCTRL_AUD_GET_FORMAT: + *(int *)args=0x01; /* Raw PCM */ + return MPXP_Ok; + default: break; + } + return MPXP_False; +} + +extern const stream_driver_t cdda_stream= +{ + "cdda://", + "reads multimedia stream directly from Digital Audio Compact Disc [CD-DA]", + _cdda_open, + cdd_read, + cdd_seek, + cdd_tell, + cdd_close, + cdd_ctrl +}; + +extern const stream_driver_t cddb_stream= +{ + "cddb://", + "reads multimedia stream from CD-DA but tracks names from CDDB servers", + _cddb_open, + cdd_read, + cdd_seek, + cdd_tell, + cdd_close, + cdd_ctrl +}; +#endif Deleted: mplayerxp/libmpstream/s_dvdnav.c =================================================================== --- mplayerxp/libmpstream/s_dvdnav.c 2012-11-20 16:18:38 UTC (rev 416) +++ mplayerxp/libmpstream/s_dvdnav.c 2012-11-20 17:01:59 UTC (rev 417) @@ -1,660 +0,0 @@ -/* - s_dvdnav - DVDNAV's stream interface -*/ -#include "mp_config.h" -#ifdef USE_DVDNAV -#include <stdlib.h> -#include <string.h> -#include <math.h> -#include "stream.h" -#include "help_mp.h" -#include "libmpdemux/demuxer.h" -#include "libmpsub/spudec.h" -#include "libvo/sub.h" -#include "input2/input.h" -#include "mplayerxp.h" -#include "stream_msg.h" - -#include <dvdnav/dvdnav.h> -#include <stdio.h> -#include <unistd.h> -#include "osdep/timer.h" -#include "osdep/mplib.h" -#include "mrl.h" -#define DVD_BLOCK_SIZE 2048 - -#ifndef min -#define min(a,b) ((a)<(b)?(a):(b)) -#endif -#ifndef max -#define max(a,b) ((a)>(b)?(a):(b)) -#endif - -extern vo_data_t* vo_data; - -typedef struct { - dvdnav_t * dvdnav; /* handle to libdvdnav stuff */ - char * filename; /* path */ - int ignore_timers; /* should timers be skipped? */ - int sleeping; /* are we sleeping? */ - unsigned int sleep_until; /* timer */ - int started; /* Has mplayer initialization finished? */ - unsigned char prebuf[STREAM_BUFFER_SIZE]; /* prefill buffer */ - int prelen; /* length of prefill buffer */ - off_t cpos; - float vobu_s_pts,vobu_e_pts; - int menu_mode; - dvdnav_highlight_event_t hlev; -} dvdnav_priv_t; - -typedef struct { - int event; /* event number fromd dvdnav_events.h */ - any_t* details; /* event details */ - int len; /* bytes in details */ -} dvdnav_event_t; - -static int dvd_nav_still=0; /* are we on a still picture? */ -static int dvd_nav_skip_opening=0; /* skip opening stalls? */ - -static void __FASTCALL__ dvdnav_stream_ignore_timers(stream_t * stream, int ignore) { - dvdnav_priv_t *dvdnav_priv=stream->priv; - dvdnav_priv->ignore_timers=ignore; -} - -static dvdnav_priv_t * __FASTCALL__ new_dvdnav_stream(stream_t *stream,char * filename) { - const char * title_str; - dvdnav_priv_t *dvdnav_priv; - - if (!filename) - return NULL; - - if (!(dvdnav_priv=(dvdnav_priv_t*)mp_calloc(1,sizeof(*dvdnav_priv)))) - return NULL; - - if (!(dvdnav_priv->filename=mp_strdup(filename))) { - mp_free(dvdnav_priv); - return NULL; - } - - if(dvdnav_open(&(dvdnav_priv->dvdnav),dvdnav_priv->filename)!=DVDNAV_STATUS_OK) - { - mp_free(dvdnav_priv->filename); - mp_free(dvdnav_priv); - return NULL; - } - - if (!dvdnav_priv->dvdnav) { - mp_free(dvdnav_priv); - return NULL; - } - - stream->priv=dvdnav_priv; - dvdnav_stream_ignore_timers(stream,dvd_nav_skip_opening); - - if(1) //from vlc: if not used dvdnav from cvs will fail - { - int len, event; - char buf[2048]; - - dvdnav_get_next_block(dvdnav_priv->dvdnav,buf,&event,&len); - dvdnav_sector_search(dvdnav_priv->dvdnav, 0, SEEK_SET); - } - - /* turn on/off dvdnav caching */ - dvdnav_set_readahead_flag(dvdnav_priv->dvdnav,mp_conf.s_cache_size?0:1); - - /* report the title?! */ - if (dvdnav_get_title_string(dvdnav_priv->dvdnav,&title_str)==DVDNAV_STATUS_OK) { - MSG_INFO("Title: '%s'\n",title_str); - } - check_pin("stream",stream->pin,STREAM_PIN); - return dvdnav_priv; -} - -static void __FASTCALL__ dvdnav_stream_sleep(const stream_t * stream, int seconds) { - dvdnav_priv_t *dvdnav_priv=stream->priv; - - if (!dvdnav_priv->started) return; - - dvdnav_priv->sleeping=0; - switch (seconds) { - case 0: - return; - case 0xff: - MSG_V( "Sleeping indefinately\n" ); - dvdnav_priv->sleeping=2; - break; - default: - MSG_V( "Sleeping %d sec(s)\n", seconds ); - dvdnav_priv->sleep_until = GetTimer();// + seconds*1000000; - dvdnav_priv->sleeping=1; - break; - } - //if (dvdnav_priv->started) dvd_nav_still=1; -} - -static int __FASTCALL__ dvdnav_stream_sleeping(const stream_t * stream) { - dvdnav_priv_t *dvdnav_priv=stream->priv; - unsigned int now; - - if (!dvdnav_priv) return 0; - - if(dvdnav_priv->sleeping) - { - now=GetTimer(); - while(dvdnav_priv->sleeping>1 || now<dvdnav_priv->sleep_until) { -// usec_sleep(1000); /* 1ms granularity */ - return 1; - } - dvdnav_still_skip(dvdnav_priv->dvdnav); // continue past... - dvdnav_priv->sleeping=0; - MSG_V("%s: woke up!\n",__FUNCTION__); - } - dvd_nav_still=0; - MSG_V("%s: active\n",__FUNCTION__); - return 0; -} - -static unsigned int * __FASTCALL__ dvdnav_stream_get_palette(const stream_t * stream) { -#if 0 /* latest versions if libdvdnav don't provide such info */ - dvdnav_priv_t *dvdnav_priv=stream->priv; - if (!dvdnav_priv) { - MSG_V("%s: NULL dvdnav_priv\n",__FUNCTION__); - return NULL; - } - if (!dvdnav_priv->dvdnav) { - MSG_V("%s: NULL dvdnav_priv->dvdnav\n",__FUNCTION__); - return NULL; - } - if (!dvdnav_priv->dvdnav->vm) { - MSG_V("%s: NULL dvdnav_priv->dvdnav->vm\n",__FUNCTION__); - return NULL; - } - if (!dvdnav_priv->dvdnav->vm->state.pgc) { - MSG_V("%s: NULL dvdnav_priv->dvdnav->vm->state.pgc\n",__FUNCTION__); - return NULL; - } - return dvdnav_priv->dvdnav->vm->state.pgc->palette; -#else - UNUSED(stream); -#endif - return 0; -} - -static dvdnav_event_t *tevent; -static int tevent_full=0; -static int dvd_title=-1,dvd_chapter=-1; - -static const mrl_config_t dvdnavopts_conf[]={ - { "skipopening", &dvd_nav_skip_opening, MRL_TYPE_BOOL, 0, 1 }, - { "T", &dvd_title, MRL_TYPE_INT, 0, 999 }, - { "C", &dvd_chapter, MRL_TYPE_INT, 0, 999 }, - { NULL, NULL, 0, 0, 0 } -}; - -static MPXP_Rc __FASTCALL__ __dvdnav_open(any_t*libinput,stream_t *stream,const char *filename,unsigned flags) -{ - const char *param; - char *dvd_device; - int ntitles; - UNUSED(flags); - UNUSED(libinput); - stream->type = STREAMTYPE_SEEKABLE|STREAMTYPE_PROGRAM; - param=mrl_parse_line(filename,NULL,NULL,&dvd_device,NULL); - if(strcmp(param,"help") == 0) { - MSG_HINT("Usage: dvdnav://<title>,<chapter>\n"); - return MPXP_False; - } - param=mrl_parse_params(param,dvdnavopts_conf); - if (!(stream->priv=new_dvdnav_stream(stream,dvd_device?dvd_device:DEFAULT_DVD_DEVICE))) { - MSG_ERR(MSGTR_CantOpenDVD,dvd_device?dvd_device:DEFAULT_DVD_DEVICE); - if(!dvd_device) { - if (!(stream->priv=new_dvdnav_stream(stream,DEFAULT_CDROM_DEVICE))) - MSG_ERR(MSGTR_CantOpenDVD,DEFAULT_CDROM_DEVICE); - else - goto dvd_ok; - } - mp_free(stream->priv); - if(dvd_device) mp_free(dvd_device); - return MPXP_False; - } - dvd_ok: - if(dvd_device) mp_free(dvd_device); - ((dvdnav_priv_t *)stream->priv)->started=1; - if(mp_conf.s_cache_size) { - tevent = mp_malloc(sizeof(dvdnav_event_t)); - if(tevent) - if((tevent->details=mp_malloc(DVD_BLOCK_SIZE))==NULL) { - mp_free(tevent); - tevent=NULL; - } - } - tevent_full=0; - /* By rumours 1 PGC == whole movie */ - dvdnav_set_PGC_positioning_flag(((dvdnav_priv_t *)stream->priv)->dvdnav,1); - ntitles=0; - dvdnav_get_number_of_titles(((dvdnav_priv_t *)stream->priv)->dvdnav,&ntitles); - MSG_INFO(MSGTR_DVDnumTitles,ntitles); - if(dvd_title != -1) { - int nparts; - dvdnav_get_number_of_parts(((dvdnav_priv_t *)stream->priv)->dvdnav,dvd_title,&nparts); - MSG_INFO(MSGTR_DVDnumChapters,dvd_title,nparts); - if(dvd_chapter != -1) dvdnav_part_play(((dvdnav_priv_t *)stream->priv)->dvdnav,dvd_title,dvd_chapter); - else dvdnav_title_play(((dvdnav_priv_t *)stream->priv)->dvdnav,dvd_title); - ((dvdnav_priv_t *)stream->priv)->cpos=stream->start_pos=2048; /* disallow dvdnav_reset */ - dvdnav_current_title_info(((dvdnav_priv_t *)stream->priv)->dvdnav,&dvd_title,&dvd_chapter); - MSG_INFO("Playing %i part of %i title\n",dvd_chapter,dvd_title); - } - stream->sector_size=tevent?DVD_BLOCK_SIZE*10:DVD_BLOCK_SIZE; - if( dvdnav_is_domain_vmgm(((dvdnav_priv_t *)stream->priv)->dvdnav) || - dvdnav_is_domain_vtsm(((dvdnav_priv_t *)stream->priv)->dvdnav)) - stream->type = STREAMTYPE_MENU|STREAMTYPE_SEEKABLE; - check_pin("stream",stream->pin,STREAM_PIN); - return MPXP_Ok; -} - -static void __FASTCALL__ dvdnav_stream_read(stream_t * stream, dvdnav_event_t*de) { - dvdnav_priv_t *dvdnav_priv=stream->priv; - int event = DVDNAV_NOP; - int done; - - if (!de->len) return; - de->len=-1; - if (!dvdnav_priv) return; - if (!de->details) return; - - if (dvd_nav_still) { - MSG_V("%s: got a stream_read while I should be asleep!\n",__FUNCTION__); - de->event=DVDNAV_STILL_FRAME; - de->len=0; - return; - } - done=0; - while(!done) - { - if (dvdnav_get_next_block(dvdnav_priv->dvdnav,de->details,&event,&de->len)!=DVDNAV_STATUS_OK) - { - MSG_ERR( "Error getting next block from DVD (%s)\n",dvdnav_err_to_string(dvdnav_priv->dvdnav) ); - de->len=-1; - } - if(event == DVDNAV_STILL_FRAME) - { - dvdnav_still_skip(dvdnav_priv->dvdnav); /* don't let dvdnav stall on this image */ - while (dvdnav_stream_sleeping(stream)) usleep(1000); /* 1ms */ - } -#ifdef DVDNAV_WAIT - else - if(event == DVDNAV_WAIT) - { - usleep(1000); - dvdnav_wait_skip(dvdnav_priv->dvdnav); /* don't let dvdnav stall on this image */ - } -#endif - else - if(event == DVDNAV_NAV_PACKET) - { - /* Try to suppress PTS discontinuity here!!! */ - pci_t *_this; - float vobu_s_pts,vobu_e_pts; - _this=dvdnav_get_current_nav_pci(dvdnav_priv->dvdnav); - vobu_s_pts=_this->pci_gi.vobu_s_ptm/90000.; - vobu_e_pts=_this->pci_gi.vobu_e_ptm/90000.; - MSG_V("Handling NAV_PACKET: vobu_s_ptm=%f vobu_e_ptm=%f e_eltm=%f\n" - ,vobu_s_pts - ,vobu_e_pts - ,(float)_this->pci_gi.e_eltm.second+_this->pci_gi.e_eltm.minute*60.+_this->pci_gi.e_eltm.hour*3600.); - if(vobu_s_pts < dvdnav_priv->vobu_e_pts) - { - stream->stream_pts += dvdnav_priv->vobu_e_pts-vobu_s_pts; - MSG_V("DVD's discontinuities found! Applying delta: %f\n",stream->stream_pts); - } - else stream->stream_pts = vobu_s_pts; - dvdnav_priv->vobu_s_pts = vobu_s_pts; - dvdnav_priv->vobu_e_pts = vobu_e_pts; - } - else - if(event == DVDNAV_CELL_CHANGE) - { - int ct,cc; - dvdnav_current_title_info(dvdnav_priv->dvdnav, &ct, &cc); - if(ct<=0) { - dvdnav_priv->menu_mode=1; - MSG_V("entering menu mode: %i %i\n",ct,cc); - MSG_V("vmgm: %i vtsm: %i\n", - dvdnav_is_domain_vmgm(dvdnav_priv->dvdnav), - dvdnav_is_domain_vtsm(dvdnav_priv->dvdnav)); - } - else { - dvdnav_priv->menu_mode=0; - MSG_V("leaving menu mode: %i %i\n",ct,cc); - } - /**/ - if(dvdnav_priv->menu_mode) - stream->type = STREAMTYPE_MENU|STREAMTYPE_SEEKABLE; - else stream->type = STREAMTYPE_SEEKABLE|STREAMTYPE_PROGRAM; - } - else done=1; - } - if(!event) dvdnav_priv->cpos += DVD_BLOCK_SIZE; - de->event=event; -} - -static int __FASTCALL__ __dvdnav_read(stream_t *stream,stream_packet_t *sp) -{ - dvdnav_event_t de; - unsigned len=sp->len; - if(tevent && tevent_full) - { - sp->len=tevent->len; - sp->type=tevent->event; - memcpy(sp->buf,tevent->details,tevent->len); - tevent_full=0; - return sp->len; - } - de.len=sp->len; - de.details=sp->buf; - dvdnav_stream_read(stream,&de); - sp->len=de.len; - sp->type=de.event; - if(tevent && !sp->type) - { - len -= sp->len; - while(len) - { - de.len=len; - de.details=&sp->buf[sp->len]; - dvdnav_stream_read(stream,&de); - if(de.event) - { - tevent->len=de.len; - tevent->event=de.event; - memcpy(tevent->details,de.details,de.len); - tevent_full=1; - break; - } - if(de.len<0 || (!de.event&&de.len==0)) break; - sp->len += de.len; - len-=de.len; - } - } - return sp->len; -} - -static off_t __FASTCALL__ __dvdnav_seek(stream_t *stream,off_t pos) -{ - dvdnav_priv_t *dvdnav_priv=stream->priv; - uint32_t newpos=0; - uint32_t length=1; - uint32_t sector; - - if (pos==0) - { - dvdnav_priv->started=0; - dvdnav_priv->cpos=0; - return 0; - } - sector=pos/DVD_BLOCK_SIZE; - dvdnav_sector_search(dvdnav_priv->dvdnav,sector,SEEK_SET); - usleep(0); /* wait for HOP_CHANNEL event */ - dvdnav_get_position(dvdnav_priv->dvdnav, &newpos, &length); - if(newpos > sector) newpos=sector; - dvdnav_priv->cpos = (newpos)*2048; - /* reset pts_fix after seeking */ - { - dvdnav_priv->vobu_s_pts= - dvdnav_priv->vobu_e_pts= - stream->stream_pts=0; - } - return dvdnav_priv->cpos; -} - -static off_t __FASTCALL__ __dvdnav_tell(const stream_t *stream) -{ - dvdnav_priv_t *dvdnav_priv=stream->priv; - return (off_t)dvdnav_priv->cpos; -} - -static void __FASTCALL__ __dvdnav_close(stream_t *stream) -{ - dvdnav_priv_t *dvdnav_priv=stream->priv; - dvdnav_close(dvdnav_priv->dvdnav); - mp_free(dvdnav_priv); - if(tevent) { mp_free(tevent->details); mp_free(tevent); } -} - -/** - * \brief mp_dvdnav_get_highlight() get dvdnav highlight struct - * \param stream: - stream pointer - * \param hl : - highlight struct pointer - */ -static void mp_dvdnav_get_highlight (const stream_t *stream, rect_highlight_t *hl) { - dvdnav_priv_t *priv = (dvdnav_priv_t *) stream->priv; - int button; - dvdnav_highlight_area_t ha; - pci_t *pnavpci = NULL; - - dvdnav_get_current_highlight(priv->dvdnav, &button); - pnavpci = dvdnav_get_current_nav_pci (priv->dvdnav); - /* highlight mode: 0 - hide, 1 - show, 2 - activate, currently always 1 */ - dvdnav_get_highlight_area(pnavpci, button, 1, &ha); - - hl->sx = ha.sx; - hl->sy = ha.sy; - hl->ex = ha.ex; - hl->ey = ha.ey; -} - -static void __FASTCALL__ dvdnav_event_handler(const stream_t* s,const stream_packet_t*sp) -{ - demux_stream_t *d_audio=s->demuxer->audio; - dvdnav_priv_t *priv=s->priv; - switch(sp->type) { - case DVDNAV_BLOCK_OK: /* be silent about this one */ - break; - case DVDNAV_HIGHLIGHT: { - pci_t *pnavpci = NULL; - dvdnav_highlight_event_t *_hlev = (dvdnav_highlight_event_t*)(sp->buf); - int btnum; - int display_mode=1; - MSG_V("DVDNAV_HIGHLIGHT: %i %i %i %i\n",_hlev->sx,_hlev->sy,_hlev->ex,_hlev->ey); - if (!priv || !priv->dvdnav) return; - memcpy(&priv->hlev,_hlev,sizeof(dvdnav_highlight_event_t)); - pnavpci = dvdnav_get_current_nav_pci (priv->dvdnav); - if (!pnavpci) return; - - dvdnav_get_current_highlight (priv->dvdnav, &(priv->hlev.buttonN)); - priv->hlev.display = display_mode; /* show */ - - if (priv->hlev.buttonN > 0 && pnavpci->hli.hl_gi.btn_ns > 0 && priv->hlev.display) { - for (btnum = 0; btnum < pnavpci->hli.hl_gi.btn_ns; btnum++) { - btni_t *btni = &(pnavpci->hli.btnit[btnum]); - - if (priv->hlev.buttonN == (unsigned)btnum + 1) { - priv->hlev.sx = min (btni->x_start, btni->x_end); - priv->hlev.ex = max (btni->x_start, btni->x_end); - priv->hlev.sy = min (btni->y_start, btni->y_end); - priv->hlev.ey = max (btni->y_start, btni->y_end); - - priv->hlev.palette = (btni->btn_coln == 0) ? 0 : - pnavpci->hli.btn_colit.btn_coli[btni->btn_coln - 1][0]; - break; - } - } - } else { /* hide button or no button */ - priv->hlev.sx = priv->hlev.ex = 0; - priv->hlev.sy = priv->hlev.ey = 0; - priv->hlev.palette = priv->hlev.buttonN = 0; - } - break; - } - case DVDNAV_STILL_FRAME: { - const dvdnav_still_event_t *still_event = (const dvdnav_still_event_t*)(sp->buf); - MSG_DBG2( "######## DVDNAV Event: Still Frame: %d sec(s)\n", still_event->length ); - while (dvdnav_stream_sleeping(s)) { - usleep(1000); /* 1ms */ - } - dvdnav_stream_sleep(s,still_event->length); - break; - } - case DVDNAV_STOP: - MSG_DBG2( "DVDNAV Event: Nav Stop\n" ); - break; - case DVDNAV_NOP: - MSG_V("DVDNAV Event: Nav NOP\n"); - break; -#if 0 - case DVDNAV_SPU_STREAM_CHANGE: { - const dvdnav_spu_stream_change_event_t * stream_change=(const dvdnav_spu_stream_change_event_t*)(sp->buf); - MSG_DBG2("DVDNAV Event: Nav SPU Stream Change: phys_wide: %d phys_letterbox: %d phys_panscan: %d logical: %d\n", - stream_change->physical_wide, - stream_change->physical_letterbox, - stream_change->physical_pan_scan, - stream_change->logical); - if (vo_data->spudec && mp_conf.dvdsub_id!=stream_change->physical_wide) { - MSG_DBG2("d_dvdsub->id change: was %d is now %d\n", - d_dvdsub->id,stream_change->physical_wide); - // FIXME: need a better way to change SPU id - d_dvdsub->id=mp_conf.dvdsub_id=stream_change->physical_wide; - if (vo_data->spudec) spudec_reset(vo_data->spudec); - } - break; - } -#endif - case DVDNAV_AUDIO_STREAM_CHANGE: { - int aid_temp; - const dvdnav_audio_stream_change_event_t *stream_change = (const dvdnav_audio_stream_change_event_t*)(sp->buf); - MSG_DBG2("DVDNAV Event: Nav Audio Stream Change: phys: %d logical: %d\n", - stream_change->physical, - stream_change->logical); - aid_temp=stream_change->physical; - if (aid_temp>=0) aid_temp+=128; // FIXME: is this sane? - if (d_audio && mp_conf.audio_id!=aid_temp) { - MSG_DBG2("d_audio->id change: was %d is now %d\n", - d_audio->id,aid_temp); - // FIXME: need a bettery way to change audio stream id - d_audio->id=mp_conf.dvdsub_id=aid_temp; - mpxp_resync_audio_stream(); - } - break; - } - case DVDNAV_VTS_CHANGE:{ - const dvdnav_vts_change_event_t *evts = (const dvdnav_vts_change_event_t *)(sp->buf); - MSG_V("DVDNAV Event: Nav VTS Change %u\n",evts->new_domain); - } - break; - case DVDNAV_CELL_CHANGE: { - const dvdnav_cell_change_event_t *ecell=(const dvdnav_cell_change_event_t*)(sp->buf); - MSG_V("DVDNAV_CELL_CHANGE: N=%i pgN=%i cell_start=%f pg_start=%f cell_length=%f pg_length=%f pgc_length=%f\n" - ,ecell->cellN - ,ecell->pgN - ,ecell->cell_start/90000. - ,ecell->pg_start/90000. - ,ecell->cell_length/90000. - ,ecell->pg_length/90000. - ,ecell->pgc_length/90000.); - } - break; - case DVDNAV_NAV_PACKET: - MSG_V("DVDNAV Event: Nav Packet\n"); - break; - case DVDNAV_SPU_CLUT_CHANGE: - MSG_DBG2("DVDNAV Event: Nav SPU CLUT Change\n"); - if(sp->len!=64) MSG_WARN("DVDNAV Event: Nav SPU CLUT Change: %i bytes <> 64\n",sp->len); - // send new palette to SPU decoder - if (vo_data->spudec) spudec_update_palette(vo_data->spudec,(const unsigned int *)(sp->buf)); - break; - } -} - -static void __FASTCALL__ dvdnav_cmd_handler(const stream_t* s,unsigned cmd) -{ - dvdnav_priv_t *dvdnav_priv=s->priv; - int button; - pci_t *pci = dvdnav_get_current_nav_pci(dvdnav_priv->dvdnav); - switch (cmd) { - case MP_CMD_DVDNAV_UP: - dvdnav_upper_button_select(dvdnav_priv->dvdnav,pci); - break; - case MP_CMD_DVDNAV_DOWN: - dvdnav_lower_button_select(dvdnav_priv->dvdnav,pci); - break; - case MP_CMD_DVDNAV_LEFT: - dvdnav_left_button_select(dvdnav_priv->dvdnav,pci); - break; - case MP_CMD_DVDNAV_RIGHT: - dvdnav_right_button_select(dvdnav_priv->dvdnav,pci); - break; - case MP_CMD_DVDNAV_MENU: { - int title,part; - MSG_V("Menu call\n"); - dvdnav_current_title_info(dvdnav_priv->dvdnav, &title, &part); - if(title>0) { - if(dvdnav_menu_call(dvdnav_priv->dvdnav, DVD_MENU_Part) == DVDNAV_STATUS_OK - || dvdnav_menu_call(dvdnav_priv->dvdnav, DVD_MENU_Title) == DVDNAV_STATUS_OK) - break; - } - dvdnav_menu_call(dvdnav_priv->dvdnav, DVD_MENU_Root); - dvdnav_button_select(dvdnav_priv->dvdnav, pci, 1); - } - break; - case MP_CMD_DVDNAV_SELECT: - dvdnav_button_activate(dvdnav_priv->dvdnav,pci); - break; - default: - MSG_V("Weird DVD Nav cmd %d\n",cmd); - break; - } - dvdnav_get_current_highlight(dvdnav_priv->dvdnav, &button); - dvdnav_button_select(dvdnav_priv->dvdnav,pci,button); -} - -static MPXP_Rc __FASTCALL__ __dvdnav_ctrl(const stream_t *s,unsigned cmd,any_t*args) -{ - dvdnav_priv_t *dvdnav_priv=s->priv; - switch(cmd) { - case SCTRL_TXT_GET_STREAM_NAME: { - const char *title_str; - if (dvdnav_get_title_string(dvdnav_priv->dvdnav,&title_str)==DVDNAV_STATUS_OK) { - strncpy(args,title_str,256); - ((char *)args)[255]=0; - return MPXP_Ok; - } - } - break; - case SCTRL_VID_GET_PALETTE: { - unsigned* pal; - pal=dvdnav_stream_get_palette(s); - *((unsigned **)args)=pal; - return MPXP_Ok; - } - break; - case SCTRL_VID_GET_HILIGHT: { - mp_dvdnav_get_highlight (s,args); - return MPXP_Ok; - } - case SCRTL_EVT_HANDLE: { - dvdnav_event_handler(s,args); - return MPXP_Ok; - } - break; - case SCRTL_MPXP_CMD: { - dvdnav_cmd_handler(s,(unsigned)args); - return MPXP_Ok; - } - default: break; - } - return MPXP_False; -} - -const stream_driver_t dvdnav_stream= -{ - "dvdnav://", - "reads multimedia stream with using of libdvdnav library", - __dvdnav_open, - __dvdnav_read, - __dvdnav_seek, - __dvdnav_tell, - __dvdnav_close, - __dvdnav_ctrl -}; -#endif Copied: mplayerxp/libmpstream/s_dvdnav.cpp (from rev 414, mplayerxp/libmpstream/s_dvdnav.c) =================================================================== --- mplayerxp/libmpstream/s_dvdnav.cpp (rev 0) +++ mplayerxp/libmpstream/s_dvdnav.cpp 2012-11-20 17:01:59 UTC (rev 417) @@ -0,0 +1,660 @@ +/* + s_dvdnav - DVDNAV's stream interface +*/ +#include "mp_config.h" +#ifdef USE_DVDNAV +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include "stream.h" +#include "help_mp.h" +#include "libmpdemux/demuxer.h" +#include "libmpsub/spudec.h" +#include "libvo/sub.h" +#include "input2/input.h" +#include "mplayerxp.h" +#include "stream_msg.h" + +#include <dvdnav/dvdnav.h> +#include <stdio.h> +#include <unistd.h> +#include "osdep/timer.h" +#include "osdep/mplib.h" +#include "mrl.h" +#define DVD_BLOCK_SIZE 2048 + +#ifndef min +#define min(a,b) ((a)<(b)?(a):(b)) +#endif +#ifndef max +#define max(a,b) ((a)>(b)?(a):(b)) +#endif + +extern vo_data_t* vo_data; + +typedef struct { + dvdnav_t * dvdnav; /* handle to libdvdnav stuff */ + char * filename; /* path */ + int ignore_timers; /* should timers be skipped? */ + int sleeping; /* are we sleeping? */ + unsigned int sleep_until; /* timer */ + int started; /* Has mplayer initialization finished? */ + unsigned char prebuf[STREAM_BUFFER_SIZE]; /* prefill buffer */ + int prelen; /* length of prefill buffer */ + off_t cpos; + float vobu_s_pts,vobu_e_pts; + int menu_mode; + dvdnav_highlight_event_t hlev; +} dvdnav_priv_t; + +typedef struct { + int event; /* event number fromd dvdnav_events.h */ + any_t* details; /* event details */ + int len; /* bytes in details */ +} dvdnav_event_t; + +static int dvd_nav_still=0; /* are we on a still picture? */ +static int dvd_nav_skip_opening=0; /* skip opening stalls? */ + +static void __FASTCALL__ dvdnav_stream_ignore_timers(stream_t * stream, int ignore) { + dvdnav_priv_t *dvdnav_priv=reinterpret_cast<dvdnav_priv_t*>(stream->priv); + dvdnav_priv->ignore_timers=ignore; +} + +static dvdnav_priv_t * __FASTCALL__ new_dvdnav_stream(stream_t *stream,const char * filename) { + const char * title_str; + dvdnav_priv_t *dvdnav_priv; + + if (!filename) + return NULL; + + if (!(dvdnav_priv=(dvdnav_priv_t*)mp_calloc(1,sizeof(*dvdnav_priv)))) + return NULL; + + if (!(dvdnav_priv->filename=mp_strdup(filename))) { + mp_free(dvdnav_priv); + return NULL; + } + + if(dvdnav_open(&(dvdnav_priv->dvdnav),dvdnav_priv->filename)!=DVDNAV_STATUS_OK) + { + mp_free(dvdnav_priv->filename); + mp_free(dvdnav_priv); + return NULL; + } + + if (!dvdnav_priv->dvdnav) { + mp_free(dvdnav_priv); + return NULL; + } + + stream->priv=dvdnav_priv; + dvdnav_stream_ignore_timers(stream,dvd_nav_skip_opening); + + if(1) //from vlc: if not used dvdnav from cvs will fail + { + int len, event; + uint8_t buf[2048]; + + dvdnav_get_next_block(dvdnav_priv->dvdnav,buf,&event,&len); + dvdnav_sector_search(dvdnav_priv->dvdnav, 0, SEEK_SET); + } + + /* turn on/off dvdnav caching */ + dvdnav_set_readahead_flag(dvdnav_priv->dvdnav,mp_conf.s_cache_size?0:1); + + /* report the title?! */ + if (dvdnav_get_title_string(dvdnav_priv->dvdnav,&title_str)==DVDNAV_STATUS_OK) { + MSG_INFO("Title: '%s'\n",title_str); + } + check_pin("stream",stream->pin,STREAM_PIN); + return dvdnav_priv; +} + +static void __FASTCALL__ dvdnav_stream_sleep(const stream_t * stream, int seconds) { + dvdnav_priv_t *dvdnav_priv=reinterpret_cast<dvdnav_priv_t*>(stream->priv); + + if (!dvdnav_priv->started) return; + + dvdnav_priv->sleeping=0; + switch (seconds) { + case 0: + return; + case 0xff: + MSG_V( "Sleeping indefinately\n" ); + dvdnav_priv->sleeping=2; + break; + default: + MSG_V( "Sleeping %d sec(s)\n", seconds ); + dvdnav_priv->sleep_until = GetTimer();// + seconds*1000000; + dvdnav_priv->sleeping=1; + break; + } + //if (dvdnav_priv->started) dvd_nav_still=1; +} + +static int __FASTCALL__ dvdnav_stream_sleeping(const stream_t * stream) { + dvdnav_priv_t *dvdnav_priv=reinterpret_cast<dvdnav_priv_t*>(stream->priv); + unsigned int now; + + if (!dvdnav_priv) return 0; + + if(dvdnav_priv->sleeping) + { + now=GetTimer(); + while(dvdnav_priv->sleeping>1 || now<dvdnav_priv->sleep_until) { +// usec_sleep(1000); /* 1ms granularity */ + return 1; + } + dvdnav_still_skip(dvdnav_priv->dvdnav); // continue past... + dvdnav_priv->sleeping=0; + MSG_V("%s: woke up!\n",__FUNCTION__); + } + dvd_nav_still=0; + MSG_V("%s: active\n",__FUNCTION__); + return 0; +} + +static unsigned int * __FASTCALL__ dvdnav_stream_get_palette(const stream_t * stream) { +#if 0 /* latest versions if libdvdnav don't provide such info */ + dvdnav_priv_t *dvdnav_priv=stream->priv; + if (!dvdnav_priv) { + MSG_V("%s: NULL dvdnav_priv\n",__FUNCTION__); + return NULL; + } + if (!dvdnav_priv->dvdnav) { + MSG_V("%s: NULL dvdnav_priv->dvdnav\n",__FUNCTION__); + return NULL; + } + if (!dvdnav_priv->dvdnav->vm) { + MSG_V("%s: NULL dvdnav_priv->dvdnav->vm\n",__FUNCTION__); + return NULL; + } + if (!dvdnav_priv->dvdnav->vm->state.pgc) { + MSG_V("%s: NULL dvdnav_priv->dvdnav->vm->state.pgc\n",__FUNCTION__); + return NULL; + } + return dvdnav_priv->dvdnav->vm->state.pgc->palette; +#else + UNUSED(stream); +#endif + return 0; +} + +static dvdnav_event_t *tevent; +static int tevent_full=0; +static int dvd_title=-1,dvd_chapter=-1; + +static const mrl_config_t dvdnavopts_conf[]={ + { "skipopening", &dvd_nav_skip_opening, MRL_TYPE_BOOL, 0, 1 }, + { "T", &dvd_title, MRL_TYPE_INT, 0, 999 }, + { "C", &dvd_chapter, MRL_TYPE_INT, 0, 999 }, + { NULL, NULL, 0, 0, 0 } +}; + +static MPXP_Rc __FASTCALL__ __dvdnav_open(any_t*libinput,stream_t *stream,const char *filename,unsigned flags) +{ + const char *param; + char *dvd_device; + int ntitles; + UNUSED(flags); + UNUSED(libinput); + stream->type = STREAMTYPE_SEEKABLE|STREAMTYPE_PROGRAM; + param=mrl_parse_line(filename,NULL,NULL,&dvd_device,NULL); + if(strcmp(param,"help") == 0) { + MSG_HINT("Usage: dvdnav://<title>,<chapter>\n"); + return MPXP_False; + } + param=mrl_parse_params(param,dvdnavopts_conf); + if (!(stream->priv=new_dvdnav_stream(stream,dvd_device?dvd_device:DEFAULT_DVD_DEVICE))) { + MSG_ERR(MSGTR_CantOpenDVD,dvd_device?dvd_device:DEFAULT_DVD_DEVICE); + if(!dvd_device) { + if (!(stream->priv=new_dvdnav_stream(stream,DEFAULT_CDROM_DEVICE))) + MSG_ERR(MSGTR_CantOpenDVD,DEFAULT_CDROM_DEVICE); + else + goto dvd_ok; + } + mp_free(stream->priv); + if(dvd_device) mp_free(dvd_device); + return MPXP_False; + } + dvd_ok: + if(dvd_device) mp_free(dvd_device); + ((dvdnav_priv_t *)stream->priv)->started=1; + if(mp_conf.s_cache_size) { + tevent = new(zeromem) dvdnav_event_t; + if(tevent) + if((tevent->details=mp_malloc(DVD_BLOCK_SIZE))==NULL) { + mp_free(tevent); + tevent=NULL; + } + } + tevent_full=0; + /* By rumours 1 PGC == whole movie */ + dvdnav_set_PGC_positioning_flag(((dvdnav_priv_t *)stream->priv)->dvdnav,1); + ntitles=0; + dvdnav_get_number_of_titles(((dvdnav_priv_t *)stream->priv)->dvdnav,&ntitles); + MSG_INFO(MSGTR_DVDnumTitles,ntitles); + if(dvd_title != -1) { + int nparts; + dvdnav_get_number_of_parts(((dvdnav_priv_t *)stream->priv)->dvdnav,dvd_title,&nparts); + MSG_INFO(MSGTR_DVDnumChapters,dvd_title,nparts); + if(dvd_chapter != -1) dvdnav_part_play(((dvdnav_priv_t *)stream->priv)->dvdnav,dvd_title,dvd_chapter); + else dvdnav_title_play(((dvdnav_priv_t *)stream->priv)->dvdnav,dvd_title); + ((dvdnav_priv_t *)stream->priv)->cpos=stream->start_pos=2048; /* disallow dvdnav_reset */ + dvdnav_current_title_info(((dvdnav_priv_t *)stream->priv)->dvdnav,&dvd_title,&dvd_chapter); + MSG_INFO("Playing %i part of %i title\n",dvd_chapter,dvd_title); + } + stream->sector_size=tevent?DVD_BLOCK_SIZE*10:DVD_BLOCK_SIZE; + if( dvdnav_is_domain_vmgm(((dvdnav_priv_t *)stream->priv)->dvdnav) || + dvdnav_is_domain_vtsm(((dvdnav_priv_t *)stream->priv)->dvdnav)) + stream->type = STREAMTYPE_MENU|STREAMTYPE_SEEKABLE; + check_pin("stream",stream->pin,STREAM_PIN); + return MPXP_Ok; +} + +static void __FASTCALL__ dvdnav_stream_read(stream_t * stream, dvdnav_event_t*de) { + dvdnav_priv_t *dvdnav_priv=reinterpret_cast<dvdnav_priv_t*>(stream->priv); + int event = DVDNAV_NOP; + int done; + + if (!de->len) return; + de->len=-1; + if (!dvdnav_priv) return; + if (!de->details) return; + + if (dvd_nav_still) { + MSG_V("%s: got a stream_read while I should be asleep!\n",__FUNCTION__); + de->event=DVDNAV_STILL_FRAME; + de->len=0; + return; + } + done=0; + while(!done) + { + if (dvdnav_get_next_block(dvdnav_priv->dvdnav,reinterpret_cast<uint8_t*>(de->details),&event,&de->len)!=DVDNAV_STATUS_OK) + { + MSG_ERR( "Error getting next block from DVD (%s)\n",dvdnav_err_to_string(dvdnav_priv->dvdnav) ); + de->len=-1; + } + if(event == DVDNAV_STILL_FRAME) + { + dvdnav_still_skip(dvdnav_priv->dvdnav); /* don't let dvdnav stall on this image */ + while (dvdnav_stream_sleeping(stream)) usleep(1000); /* 1ms */ + } +#ifdef DVDNAV_WAIT + else + if(event == DVDNAV_WAIT) + { + usleep(1000); + dvdnav_wait_skip(dvdnav_priv->dvdnav); /* don't let dvdnav stall on this image */ + } +#endif + else + if(event == DVDNAV_NAV_PACKET) + { + /* Try to suppress PTS discontinuity here!!! */ + pci_t *_this; + float vobu_s_pts,vobu_e_pts; + _this=dvdnav_get_current_nav_pci(dvdnav_priv->dvdnav); + vobu_s_pts=_this->pci_gi.vobu_s_ptm/90000.; + vobu_e_pts=_this->pci_gi.vobu_e_ptm/90000.; + MSG_V("Handling NAV_PACKET: vobu_s_ptm=%f vobu_e_ptm=%f e_eltm=%f\n" + ,vobu_s_pts + ,vobu_e_pts + ,(float)_this->pci_gi.e_eltm.second+_this->pci_gi.e_eltm.minute*60.+_this->pci_gi.e_eltm.hour*3600.); + if(vobu_s_pts < dvdnav_priv->vobu_e_pts) + { + stream->stream_pts += dvdnav_priv->vobu_e_pts-vobu_s_pts; + MSG_V("DVD's discontinuities found! Applying delta: %f\n",stream->stream_pts); + } + else stream->stream_pts = vobu_s_pts; + dvdnav_priv->vobu_s_pts = vobu_s_pts; + dvdnav_priv->vobu_e_pts = vobu_e_pts; + } + else + if(event == DVDNAV_CELL_CHANGE) + { + int ct,cc; + dvdnav_current_title_info(dvdnav_priv->dvdnav, &ct, &cc); + if(ct<=0) { + dvdnav_priv->menu_mode=1; + MSG_V("entering menu mode: %i %i\n",ct,cc); + MSG_V("vmgm: %i vtsm: %i\n", + dvdnav_is_domain_vmgm(dvdnav_priv->dvdnav), + dvdnav_is_domain_vtsm(dvdnav_priv->dvdnav)); + } + else { + dvdnav_priv->menu_mode=0; + MSG_V("leaving menu mode: %i %i\n",ct,cc); + } + /**/ + if(dvdnav_priv->menu_mode) + stream->type = STREAMTYPE_MENU|STREAMTYPE_SEEKABLE; + else stream->type = STREAMTYPE_SEEKABLE|STREAMTYPE_PROGRAM; + } + else done=1; + } + if(!event) dvdnav_priv->cpos += DVD_BLOCK_SIZE; + de->event=event; +} + +static int __FASTCALL__ __dvdnav_read(stream_t *stream,stream_packet_t *sp) +{ + dvdnav_event_t de; + unsigned len=sp->len; + if(tevent && tevent_full) + { + sp->len=tevent->len; + sp->type=tevent->event; + memcpy(sp->buf,tevent->details,tevent->len); + tevent_full=0; + return sp->len; + } + de.len=sp->len; + de.details=sp->buf; + dvdnav_stream_read(stream,&de); + sp->len=de.len; + sp->type=de.event; + if(tevent && !sp->type) + { + len -= sp->len; + while(len) + { + de.len=len; + de.details=&sp->buf[sp->len]; + dvdnav_stream_read(stream,&de); + if(de.event) + { + tevent->len=de.len; + tevent->event=de.event; + memcpy(tevent->details,de.details,de.len); + tevent_full=1; + break; + } + if(de.len<0 || (!de.event&&de.len==0)) break; + sp->len += de.len; + len-=de.len; + } + } + return sp->len; +} + +static off_t __FASTCALL__ __dvdnav_seek(stream_t *stream,off_t pos) +{ + dvdnav_priv_t *dvdnav_priv=reinterpret_cast<dvdnav_priv_t*>(stream->priv); + uint32_t newpos=0; + uint32_t length=1; + uint32_t sector; + + if (pos==0) + { + dvdnav_priv->started=0; + dvdnav_priv->cpos=0; + return 0; + } + sector=pos/DVD_BLOCK_SIZE; + dvdnav_sector_search(dvdnav_priv->dvdnav,sector,SEEK_SET); + usleep(0); /* wait for HOP_CHANNEL event */ + dvdnav_get_position(dvdnav_priv->dvdnav, &newpos, &length); + if(newpos > sector) newpos=sector; + dvdnav_priv->cpos = (newpos)*2048; + /* reset pts_fix after seeking */ + { + dvdnav_priv->vobu_s_pts= + dvdnav_priv->vobu_e_pts= + stream->stream_pts=0; + } + return dvdnav_priv->cpos; +} + +static off_t __FASTCALL__ __dvdnav_tell(const stream_t *stream) +{ + dvdnav_priv_t *dvdnav_priv=reinterpret_cast<dvdnav_priv_t*>(stream->priv); + return (off_t)dvdnav_priv->cpos; +} + +static void __FASTCALL__ __dvdnav_close(stream_t *stream) +{ + dvdnav_priv_t *dvdnav_priv=reinterpret_cast<dvdnav_priv_t*>(stream->priv); + dvdnav_close(dvdnav_priv->dvdnav); + mp_free(dvdnav_priv); + if(tevent) { mp_free(tevent->details); mp_free(tevent); } +} + +/** + * \brief mp_dvdnav_get_highlight() get dvdnav highlight struct + * \param stream: - stream pointer + * \param hl : - highlight struct pointer + */ +static void mp_dvdnav_get_highlight (const stream_t *stream, rect_highlight_t *hl) { + dvdnav_priv_t *priv = reinterpret_cast<dvdnav_priv_t*>(stream->priv); + int button; + dvdnav_highlight_area_t ha; + pci_t *pnavpci = NULL; + + dvdnav_get_current_highlight(priv->dvdnav, &button); + pnavpci = dvdnav_get_current_nav_pci (priv->dvdnav); + /* highlight mode: 0 - hide, 1 - show, 2 - activate, currently always 1 */ + dvdnav_get_highlight_area(pnavpci, button, 1, &ha); + + hl->sx = ha.sx; + hl->sy = ha.sy; + hl->ex = ha.ex; + hl->ey = ha.ey; +} + +static void __FASTCALL__ dvdnav_event_handler(const stream_t* s,const stream_packet_t*sp) +{ + demux_stream_t *d_audio=s->demuxer->audio; + dvdnav_priv_t *priv=reinterpret_cast<dvdnav_priv_t*>(s->priv); + switch(sp->type) { + case DVDNAV_BLOCK_OK: /* be silent about this one */ + break; + case DVDNAV_HIGHLIGHT: { + pci_t *pnavpci = NULL; + dvdnav_highlight_event_t *_hlev = (dvdnav_highlight_event_t*)(sp->buf); + int btnum; + int display_mode=1; + MSG_V("DVDNAV_HIGHLIGHT: %i %i %i %i\n",_hlev->sx,_hlev->sy,_hlev->ex,_hlev->ey); + if (!priv || !priv->dvdnav) return; + memcpy(&priv->hlev,_hlev,sizeof(dvdnav_highlight_event_t)); + pnavpci = dvdnav_get_current_nav_pci (priv->dvdnav); + if (!pnavpci) return; + + dvdnav_get_current_highlight (priv->dvdnav, reinterpret_cast<int32_t*>(&(priv->hlev.buttonN))); + priv->hlev.display = display_mode; /* show */ + + if (priv->hlev.buttonN > 0 && pnavpci->hli.hl_gi.btn_ns > 0 && priv->hlev.display) { + for (btnum = 0; btnum < pnavpci->hli.hl_gi.btn_ns; btnum++) { + btni_t *btni = &(pnavpci->hli.btnit[btnum]); + + if (priv->hlev.buttonN == (unsigned)btnum + 1) { + priv->hlev.sx = min (btni->x_start, btni->x_end); + priv->hlev.ex = max (btni->x_start, btni->x_end); + priv->hlev.sy = min (btni->y_start, btni->y_end); + priv->hlev.ey = max (btni->y_start, btni->y_end); + + priv->hlev.palette = (btni->btn_coln == 0) ? 0 : + pnavpci->hli.btn_colit.btn_coli[btni->btn_coln - 1][0]; + break; + } + } + } else { /* hide button or no button */ + priv->hlev.sx = priv->hlev.ex = 0; + priv->hlev.sy = priv->hlev.ey = 0; + priv->hlev.palette = priv->hlev.buttonN = 0; + } + break; + } + case DVDNAV_STILL_FRAME: { + const dvdnav_still_event_t *still_event = (const dvdnav_still_event_t*)(sp->buf); + MSG_DBG2( "######## DVDNAV Event: Still Frame: %d sec(s)\n", still_event->length ); + while (dvdnav_stream_sleeping(s)) { + usleep(1000); /* 1ms */ + } + dvdnav_stream_sleep(s,still_event->length); + break; + } + case DVDNAV_STOP: + MSG_DBG2( "DVDNAV Event: Nav Stop\n" ); + break; + case DVDNAV_NOP: + MSG_V("DVDNAV Event: Nav NOP\n"); + break; +#if 0 + case DVDNAV_SPU_STREAM_CHANGE: { + const dvdnav_spu_stream_change_event_t * stream_change=(const dvdnav_spu_stream_change_event_t*)(sp->buf); + MSG_DBG2("DVDNAV Event: Nav SPU Stream Change: phys_wide: %d phys_letterbox: %d phys_panscan: %d logical: %d\n", + stream_change->physical_wide, + stream_change->physical_letterbox, + stream_change->physical_pan_scan, + stream_change->logical); + if (vo_data->spudec && mp_conf.dvdsub_id!=stream_change->physical_wide) { + MSG_DBG2("d_dvdsub->id change: was %d is now %d\n", + d_dvdsub->id,stream_change->physical_wide); + // FIXME: need a better way to change SPU id + d_dvdsub->id=mp_conf.dvdsub_id=stream_change->physical_wide; + if (vo_data->spudec) spudec_reset(vo_data->spudec); + } + break; + } +#endif + case DVDNAV_AUDIO_STREAM_CHANGE: { + int aid_temp; + const dvdnav_audio_stream_change_event_t *stream_change = (const dvdnav_audio_stream_change_event_t*)(sp->buf); + MSG_DBG2("DVDNAV Event: Nav Audio Stream Change: phys: %d logical: %d\n", + stream_change->physical, + stream_change->logical); + aid_temp=stream_change->physical; + if (aid_temp>=0) aid_temp+=128; // FIXME: is this sane? + if (d_audio && mp_conf.audio_id!=aid_temp) { + MSG_DBG2("d_audio->id change: was %d is now %d\n", + d_audio->id,aid_temp); + // FIXME: need a bettery way to change audio stream id + d_audio->id=mp_conf.dvdsub_id=aid_temp; + mpxp_resync_audio_stream(); + } + break; + } + case DVDNAV_VTS_CHANGE:{ + const dvdnav_vts_change_event_t *evts = (const dvdnav_vts_change_event_t *)(sp->buf); + MSG_V("DVDNAV Event: Nav VTS Change %u\n",evts->new_domain); + } + break; + case DVDNAV_CELL_CHANGE: { + const dvdnav_cell_change_event_t *ecell=(const dvdnav_cell_change_event_t*)(sp->buf); + MSG_V("DVDNAV_CELL_CHANGE: N=%i pgN=%i cell_start=%f pg_start=%f cell_length=%f pg_length=%f pgc_length=%f\n" + ,ecell->cellN + ,ecell->pgN + ,ecell->cell_start/90000. + ,ecell->pg_start/90000. + ,ecell->cell_length/90000. + ,ecell->pg_length/90000. + ,ecell->pgc_length/90000.); + } + break; + case DVDNAV_NAV_PACKET: + MSG_V("DVDNAV Event: Nav Packet\n"); + break; + case DVDNAV_SPU_CLUT_CHANGE: + MSG_DBG2("DVDNAV Event: Nav SPU CLUT Change\n"); + if(sp->len!=64) MSG_WARN("DVDNAV Event: Nav SPU CLUT Change: %i bytes <> 64\n",sp->len); + // send new palette to SPU decoder + if (vo_data->spudec) spudec_update_palette(vo_data->spudec,(const unsigned int *)(sp->buf)); + break; + } +} + +static void __FASTCALL__ dvdnav_cmd_handler(const stream_t* s,unsigned cmd) +{ + dvdnav_priv_t *dvdnav_priv=reinterpret_cast<dvdnav_priv_t*>(s->priv); + int button; + pci_t *pci = dvdnav_get_current_nav_pci(dvdnav_priv->dvdnav); + switch (cmd) { + case MP_CMD_DVDNAV_UP: + dvdnav_upper_button_select(dvdnav_priv->dvdnav,pci); + break; + case MP_CMD_DVDNAV_DOWN: + dvdnav_lower_button_select(dvdnav_priv->dvdnav,pci); + break; + case MP_CMD_DVDNAV_LEFT: + dvdnav_left_button_select(dvdnav_priv->dvdnav,pci); + break; + case MP_CMD_DVDNAV_RIGHT: + dvdnav_right_button_select(dvdnav_priv->dvdnav,pci); + break; + case MP_CMD_DVDNAV_MENU: { + int title,part; + MSG_V("Menu call\n"); + dvdnav_current_title_info(dvdnav_priv->dvdnav, &title, &part); + if(title>0) { + if(dvdnav_menu_call(dvdnav_priv->dvdnav, DVD_MENU_Part) == DVDNAV_STATUS_OK + || dvdnav_menu_call(dvdnav_priv->dvdnav, DVD_MENU_Title) == DVDNAV_STATUS_OK) + break; + } + dvdnav_menu_call(dvdnav_priv->dvdnav, DVD_MENU_Root); + dvdnav_button_select(dvdnav_priv->dvdnav, pci, 1); + } + break; + case MP_CMD_DVDNAV_SELECT: + dvdnav_button_activate(dvdnav_priv->dvdnav,pci); + break; + default: + MSG_V("Weird DVD Nav cmd %d\n",cmd); + break; + } + dvdnav_get_current_highlight(dvdnav_priv->dvdnav, &button); + dvdnav_button_select(dvdnav_priv->dvdnav,pci,button); +} + +static MPXP_Rc __FASTCALL__ __dvdnav_ctrl(const stream_t *s,unsigned cmd,any_t*args) +{ + dvdnav_priv_t *dvdnav_priv=reinterpret_cast<dvdnav_priv_t*>(s->priv); + switch(cmd) { + case SCTRL_TXT_GET_STREAM_NAME: { + const char *title_str; + if (dvdnav_get_title_string(dvdnav_priv->dvdnav,&title_str)==DVDNAV_STATUS_OK) { + strncpy(reinterpret_cast<char*>(args),title_str,256); + ((char *)args)[255]=0; + return MPXP_Ok; + } + } + break; + case SCTRL_VID_GET_PALETTE: { + unsigned* pal; + pal=dvdnav_stream_get_palette(s); + *((unsigned **)args)=pal; + return MPXP_Ok; + } + break; + case SCTRL_VID_GET_HILIGHT: { + mp_dvdnav_get_highlight (s,reinterpret_cast<rect_highlight_t*>(args)); + return MPXP_Ok; + } + case SCRTL_EVT_HANDLE: { + dvdnav_event_handler(s,reinterpret_cast<stream_packet_t*>(args)); + return MPXP_Ok; + } + break; + case SCRTL_MPXP_CMD: { + dvdnav_cmd_handler(s,(long)args); + return MPXP_Ok; + } + default: break; + } + return MPXP_False; +} + +extern const stream_driver_t dvdnav_stream= +{ + "dvdnav://", + "reads multimedia stream with using of libdvdnav library", + __dvdnav_open, + __dvdnav_read, + __dvdnav_seek, + __dvdnav_tell, + __dvdnav_close, + __dvdnav_ctrl +}; +#endif Deleted: mplayerxp/libmpstream/s_ffmpeg.c =================================================================== --- mplayerxp/libmpstream/s_ffmpeg.c 2012-11-20 16:18:38 UTC (rev 416) +++ mplayerxp/libmpstream/s_ffmpeg.c 2012-11-20 17:01:59 UTC (rev 417) @@ -1,94 +0,0 @@ -#include "mp_config.h" -#include "mplayerxp.h" - -#include <dlfcn.h> -#include "mp_conf_lavc.h" -#include "libmpcodecs/codecs_ld.h" -#include "osdep/mplib.h" -#include "stream.h" -#include "stream_msg.h" - -typedef struct ffmpeg_priv_s -{ - URLContext *ctx; - off_t spos; -}ffmpeg_priv_t; - -static int ffmpeg_int_cb(any_t*op) { return 0; } /* non interrupt blicking */ -static AVIOInterruptCB int_cb = { ffmpeg_int_cb, NULL }; - -static int __FASTCALL__ ffmpeg_read(stream_t *s, stream_packet_t*sp) -{ - ffmpeg_priv_t*p=s->priv; - sp->len = ffurl_read_complete(p->ctx, sp->buf, sp->len); - if(sp->len>0) p->spos += sp->len; - return sp->len; -} - -static off_t __FASTCALL__ ffmpeg_seek(stream_t *s, off_t newpos) -{ - ffmpeg_priv_t*p=s->priv; - p->spos = newpos; - p->spos = ffurl_seek(p->ctx, newpos, SEEK_SET); - return p->spos; -} - -static off_t ffmpeg_tell(const stream_t *s) -{ - ffmpeg_priv_t*p=s->priv; - return p->spos; -} - -static MPXP_Rc __FASTCALL__ ffmpeg_ctrl(const stream_t *s, unsigned cmd, any_t*arg) -{ - UNUSED(s); - UNUSED(cmd); - UNUSED(arg); - return MPXP_Unknown; -} - -static void __FASTCALL__ ffmpeg_close(stream_t *stream) -{ - ffmpeg_priv_t*p=stream->priv; - ffurl_close(p->ctx); - mp_free(p); -} - -static const char prefix[] = "ffmpeg://"; - -static MPXP_Rc __FASTCALL__ ffmpeg_open(any_t*libinput,stream_t *stream,const char *filename,unsigned flags) -{ - URLContext *ctx = NULL; - ffmpeg_priv_t *p; - int64_t size; - - UNUSED(flags); - UNUSED(libinput); - av_register_all(); - MSG_V("[ffmpeg] Opening %s\n", filename); - - if (ffurl_open(&ctx, filename, 0, &int_cb, NULL) < 0) return MPXP_False; - p = mp_malloc(sizeof(ffmpeg_priv_t)); - p->ctx = ctx; - p->spos = 0; - size = ffurl_size(ctx); - if (size >= 0) - stream->end_pos = size; - stream->type = STREAMTYPE_SEEKABLE; - stream->priv = p; - if (ctx->is_streamed) stream->type = STREAMTYPE_STREAM; - check_pin("stream",stream->pin,STREAM_PIN); - return MPXP_Ok; -} - -const stream_driver_t ffmpeg_stream = -{ - "ffmpeg:", - "reads multimedia stream through ffmpeg library", - ffmpeg_open, - ffmpeg_read, - ffmpeg_seek, - ffmpeg_tell, - ffmpeg_close, - ffmpeg_ctrl -}; Copied: mplayerxp/libmpstream/s_ffmpeg.cpp (from rev 414, mplayerxp/libmpstream/s_ffmpeg.c) =================================================================== --- mplayerxp/libmpstream/s_ffmpeg.cpp (rev 0) +++ mplayerxp/libmpstream/s_ffmpeg.cpp 2012-11-20 17:01:59 UTC (rev 417) @@ -0,0 +1,94 @@ +#include "mp_config.h" +#include "mplayerxp.h" + +#include <dlfcn.h> +#include "mp_conf_lavc.h" +#include "libmpcodecs/codecs_ld.h" +#include "osdep/mplib.h" +#include "stream.h" +#include "stream_msg.h" + +typedef struct ffmpeg_priv_s +{ + URLContext *ctx; + off_t spos; +}ffmpeg_priv_t; + +static int ffmpeg_int_cb(any_t*op) { return 0; } /* non interrupt blicking */ +static AVIOInterruptCB int_cb = { ffmpeg_int_cb, NULL }; + +static int __FASTCALL__ ffmpeg_read(stream_t *s, stream_packet_t*sp) +{ + ffmpeg_priv_t*p=reinterpret_cast<ffmpeg_priv_t*>(s->priv); + sp->len = ffurl_read_complete(p->ctx, reinterpret_cast<unsigned char*>(sp->buf), sp->len); + if(sp->len>0) p->spos += sp->len; + return sp->len; +} + +static off_t __FASTCALL__ ffmpeg_seek(stream_t *s, off_t newpos) +{ + ffmpeg_priv_t*p=reinterpret_cast<ffmpeg_priv_t*>(s->priv); + p->spos = newpos; + p->spos = ffurl_seek(p->ctx, newpos, SEEK_SET); + return p->spos; +} + +static off_t ffmpeg_tell(const stream_t *s) +{ + ffmpeg_priv_t*p=reinterpret_cast<ffmpeg_priv_t*>(s->priv); + return p->spos; +} + +static MPXP_Rc __FASTCALL__ ffmpeg_ctrl(const stream_t *s, unsigned cmd, any_t*arg) +{ + UNUSED(s); + UNUSED(cmd); + UNUSED(arg); + return MPXP_Unknown; +} + +static void __FASTCALL__ ffmpeg_close(stream_t *stream) +{ + ffmpeg_priv_t*p=reinterpret_cast<ffmpeg_priv_t*>(stream->priv); + ffurl_close(p->ctx); + mp_free(p); +} + +static const char prefix[] = "ffmpeg://"; + +static MPXP_Rc __FASTCALL__ ffmpeg_open(any_t*libinput,stream_t *stream,const char *filename,unsigned flags) +{ + URLContext *ctx = NULL; + ffmpeg_priv_t *p; + int64_t size; + + UNUSED(flags); + UNUSED(libinput); + av_register_all(); + MSG_V("[ffmpeg] Opening %s\n", filename); + + if (ffurl_open(&ctx, filename, 0, &int_cb, NULL) < 0) return MPXP_False; + p = new(zeromem) ffmpeg_priv_t; + p->ctx = ctx; + p->spos = 0; + size = ffurl_size(ctx); + if (size >= 0) + stream->end_pos = size; + stream->type = STREAMTYPE_SEEKABLE; + stream->priv = p; + if (ctx->is_streamed) stream->type = STREAMTYPE_STREAM; + check_pin("stream",stream->pin,STREAM_PIN); + return MPXP_Ok; +} + +extern const stream_driver_t ffmpeg_stream = +{ + "ffmpeg:", + "reads multimedia stream through ffmpeg library", + ffmpeg_open, + ffmpeg_read, + ffmpeg_seek, + ffmpeg_tell, + ffmpeg_close, + ffmpeg_ctrl +}; Deleted: mplayerxp/libmpstream/s_file.c =================================================================== --- mplayerxp/libmpstream/s_file.c 2012-11-20 16:18:38 UTC (rev 416) +++ mplayerxp/libmpstream/s_file.c 2012-11-20 17:01:59 UTC (rev 417) @@ -1,124 +0,0 @@ -/* - s_file - stream interface for file i/o. -*/ -#include <errno.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#ifndef __USE_GNU -#define __USE_GNU -#endif -#include <unistd.h> -#include <fcntl.h> - -#include "mplayerxp.h" -#include "stream.h" -#include "osdep/mplib.h" - -typedef struct file_priv_s -{ - int was_open; - off_t spos; -}file_priv_t; - - -static MPXP_Rc __FASTCALL__ file_open(any_t*libinput,stream_t *stream,const char *filename,unsigned flags) -{ - UNUSED(flags); - UNUSED(libinput); - if(!(stream->priv = mp_malloc(sizeof(file_priv_t)))) return MPXP_False; - if(strcmp(filename,"-")==0) stream->fd=0; - else stream->fd=open(filename,O_RDONLY); - if(stream->fd<0) { mp_free(stream->priv); return MPXP_False; } - ((file_priv_t*)stream->priv)->was_open = stream->fd==0?0:1; - stream->end_pos = lseek(stream->fd,0,SEEK_END); - lseek(stream->fd,0,SEEK_SET); - if(stream->end_pos == -1) stream->type = STREAMTYPE_STREAM; - else stream->type = STREAMTYPE_SEEKABLE; - /* decreasing number of packet from 256 to 10 speedups cache2 from 3.27% to 1.26% - with full speed 1.04% for -nocache */ - /* Note: Please locate sector_size changinf after all read/write operations of open() function */ - stream->sector_size=mp_conf.s_cache_size?mp_conf.s_cache_size*1024/10:STREAM_BUFFER_SIZE; - ((file_priv_t*)stream->priv)->spos = 0; - check_pin("stream",stream->pin,STREAM_PIN); - return MPXP_Ok; -} - -static MPXP_Rc __FASTCALL__ stdin_open(stream_t *stream,const char *filename,unsigned flags) { - UNUSED(filename); - return file_open(NULL,stream,"-",flags); -} - -#ifndef TEMP_FAILURE_RETRY -#define TEMP_FAILURE_RETRY(x) (x) -#endif - -static int __FASTCALL__ file_read(stream_t*stream,stream_packet_t*sp) -{ -/* - Should we repeate read() again on these errno: `EAGAIN', `EIO' ??? -*/ - file_priv_t*p=stream->priv; - sp->type=0; - sp->len = TEMP_FAILURE_RETRY(read(stream->fd,sp->buf,sp->len)); - if(sp->len>0) p->spos += sp->len; - return sp->len; -} - -# define TEMP_FAILURE_RETRY64(expression) \ - (__extension__ \ - ({ long long int __result; \ - do __result = (long long int) (expression); \ - while (__result == -1LL && errno == EINTR); \ - __result; })) - -static off_t __FASTCALL__ file_seek(stream_t*stream,off_t pos) -{ - file_priv_t*p=stream->priv; - p->spos=TEMP_FAILURE_RETRY64(lseek(stream->fd,pos,SEEK_SET)); - return p->spos; -} - -static off_t __FASTCALL__ file_tell(const stream_... [truncated message content] |
From: <nic...@us...> - 2012-11-21 09:25:06
|
Revision: 419 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=419&view=rev Author: nickols_k Date: 2012-11-21 09:24:56 +0000 (Wed, 21 Nov 2012) Log Message: ----------- more c++ sources + constantization Modified Paths: -------------- mplayerxp/configure mplayerxp/libao2/Makefile mplayerxp/libao2/afmt.cpp mplayerxp/libao2/afmt.h mplayerxp/libao2/audio_out.h mplayerxp/libao2/audio_out_internal.h mplayerxp/libmpstream/Makefile mplayerxp/xmpcore/mp_aframe.h Added Paths: ----------- mplayerxp/libao2/ao_alsa9.cpp mplayerxp/libao2/ao_arts.cpp mplayerxp/libao2/ao_esd.cpp mplayerxp/libao2/ao_jack.cpp mplayerxp/libao2/ao_nas.cpp mplayerxp/libao2/ao_null.cpp mplayerxp/libao2/ao_openal.cpp mplayerxp/libao2/ao_oss.cpp mplayerxp/libao2/ao_sdl.cpp mplayerxp/libao2/ao_wav.cpp mplayerxp/libmpstream/s_oss.cpp Removed Paths: ------------- mplayerxp/libao2/ao_alsa9.c mplayerxp/libao2/ao_arts.c mplayerxp/libao2/ao_esd.c mplayerxp/libao2/ao_jack.c mplayerxp/libao2/ao_nas.c mplayerxp/libao2/ao_null.c mplayerxp/libao2/ao_openal.c mplayerxp/libao2/ao_oss.c mplayerxp/libao2/ao_sdl.c mplayerxp/libao2/ao_wav.c mplayerxp/libmpstream/s_oss.c Modified: mplayerxp/configure =================================================================== --- mplayerxp/configure 2012-11-21 08:27:41 UTC (rev 418) +++ mplayerxp/configure 2012-11-21 09:24:56 UTC (rev 419) @@ -1136,6 +1136,7 @@ #include "$srcdir/../ffmpeg/libpostproc/postprocess.h" #include "$srcdir/../ffmpeg/libswscale/swscale.h" #include "$srcdir/../ffmpeg/libswscale/rgb2rgb.h" +#include "$srcdir/../ffmpeg/libavutil/fifo.h" #include "$srcdir/../ffmpeg/libavutil/audioconvert.h" #include "$srcdir/../ffmpeg/libswresample/swresample.h" #include "$srcdir/../ffmpeg/libavformat/riff.h" Modified: mplayerxp/libao2/Makefile =================================================================== --- mplayerxp/libao2/Makefile 2012-11-21 08:27:41 UTC (rev 418) +++ mplayerxp/libao2/Makefile 2012-11-21 09:24:56 UTC (rev 419) @@ -4,31 +4,31 @@ LIBNAME = libao2.a # TODO: moveout ao_sdl.c so it's only used when SDL is detected -CXXSRCS=audio_out.cpp mixer.cpp afmt.cpp -SRCS=ao_null.c ao_wav.c +CXXSRCS=audio_out.cpp mixer.cpp afmt.cpp +CXXSRCS+=ao_null.cpp ao_wav.cpp ifeq ($(HAVE_SDL),yes) -SRCS+=ao_sdl.c +CXXSRCS+=ao_sdl.cpp endif ifeq ($(USE_OSS_AUDIO),yes) -SRCS+=ao_oss.c +CXXSRCS+=ao_oss.cpp endif ifeq ($(HAVE_ALSA),yes) -SRCS+=ao_alsa9.c +CXXSRCS+=ao_alsa9.cpp endif ifeq ($(HAVE_ARTS),yes) -SRCS+=ao_arts.c +CXXSRCS+=ao_arts.cpp endif ifeq ($(HAVE_ESD),yes) -SRCS+=ao_esd.c +CXXSRCS+=ao_esd.cpp endif ifeq ($(HAVE_OPENAL),yes) -SRCS+=ao_openal.c +CXXSRCS+=ao_openal.cpp endif ifeq ($(HAVE_NAS),yes) -SRCS+=ao_nas.c +CXXSRCS+=ao_nas.cpp endif ifeq ($(HAVE_JACK),yes) -SRCS+=ao_jack.c +CXXSRCS+=ao_jack.cpp endif OBJS=$(SRCS:.c=.o) Modified: mplayerxp/libao2/afmt.cpp =================================================================== --- mplayerxp/libao2/afmt.cpp 2012-11-21 08:27:41 UTC (rev 418) +++ mplayerxp/libao2/afmt.cpp 2012-11-21 09:24:56 UTC (rev 419) @@ -1,5 +1,28 @@ #include "afmt.h" +const char* afmt2str(unsigned fmt) { + const char* rs = "AFMT_Unknown"; + switch (fmt) { + default: rs = "AFMT_Special"; break; + case AFMT_U8: return "AFMT_U8"; + case AFMT_S8: return "AFMT_S8"; + case AFMT_S16_LE: return "AFMT_S16_LE"; + case AFMT_S16_BE: return "AFMT_S16_BE"; + case AFMT_U16_LE: return "AFMT_U16_LE"; + case AFMT_U16_BE: return "AFMT_U16_BE"; + case AFMT_S24_LE: return "AFMT_S24_LE"; + case AFMT_S24_BE: return "AFMT_S24_BE"; + case AFMT_U24_LE: return "AFMT_U24_LE"; + case AFMT_U24_BE: return "AFMT_U24_BE"; + case AFMT_FLOAT32:return "AFMT_FLOAT32"; + case AFMT_S32_LE: return "AFMT_S32_LE"; + case AFMT_S32_BE: return "AFMT_S32_BE"; + case AFMT_U32_LE: return "AFMT_U32_LE"; + case AFMT_U32_BE: return "AFMT_U32_BE"; + } + return rs; +} + unsigned afmt2bps(unsigned fmt) { unsigned rc; switch (fmt) { Modified: mplayerxp/libao2/afmt.h =================================================================== --- mplayerxp/libao2/afmt.h 2012-11-21 08:27:41 UTC (rev 418) +++ mplayerxp/libao2/afmt.h 2012-11-21 09:24:56 UTC (rev 419) @@ -46,13 +46,8 @@ # define AFMT_FLOAT32 0x00100000 -#ifdef __cplusplus -extern "C" { -#endif +extern const char*__FASTCALL__ afmt2str(unsigned fmt); extern unsigned __FASTCALL__ afmt2bps(unsigned fmt); extern unsigned __FASTCALL__ bps2afmt(unsigned bps); /**< very approximate prediction */ -#ifdef __cplusplus -} -#endif #endif Deleted: mplayerxp/libao2/ao_alsa9.c =================================================================== --- mplayerxp/libao2/ao_alsa9.c 2012-11-21 08:27:41 UTC (rev 418) +++ mplayerxp/libao2/ao_alsa9.c 2012-11-21 09:24:56 UTC (rev 419) @@ -1,1049 +0,0 @@ -/* - ao_alsa9 - ALSA-0.9.x output plugin for MPlayer - - (C) Alex Beregszaszi <al...@na...> - - modified for real alsa-0.9.0-support by Joy Winter <jo...@pi...> - additional AC3 passthrough support by Andy Lo A Foe <an...@al...> - 08/22/2002 iec958-init rewritten and merged with common init, joy - - Any bugreports regarding to this driver are welcome. -*/ - -#include <errno.h> -#include <sys/time.h> -#include <stdlib.h> -#include <math.h> -#include <string.h> -#include <sys/poll.h> - -#include "mp_config.h" -#include "mplayerxp.h" -#define ALSA_PCM_NEW_HW_PARAMS_API -#define ALSA_PCM_NEW_SW_PARAMS_API -#include <alsa/asoundlib.h> - -#include "audio_out.h" -#include "audio_out_internal.h" -#include "afmt.h" -#include "ao_msg.h" -#include "libmpstream/mrl.h" -#include "osdep/mplib.h" - -static ao_info_t info = -{ - "ALSA-1.x audio output", - "alsa", - "Alex Beregszaszi <al...@na...>, Joy Winter <jo...@pi...>", - "under developement" -}; - -LIBAO_EXTERN(alsa) - -typedef struct priv_s { - snd_pcm_t* handler; - snd_pcm_format_t format; - snd_pcm_hw_params_t*hwparams; - snd_pcm_sw_params_t*swparams; - size_t bytes_per_sample; - int first; -}priv_t; - -typedef struct priv_conf_s { - int mmap; - int noblock; -}priv_conf_t; -static priv_conf_t priv_conf; -static const mrl_config_t alsaconf[]={ - { "mmap", &priv_conf.mmap, MRL_TYPE_BOOL, 0, 1 }, - { "noblock", &priv_conf.noblock, MRL_TYPE_BOOL, 0, 1 }, - { NULL, NULL, 0, 0, 0 } -}; - -#define ALSA_DEVICE_SIZE 48 - -#define BUFFERTIME // else SET_CHUNK_SIZE -#undef USE_POLL - -static int __FASTCALL__ fmt2alsa(int format) -{ - switch (format) - { - case AFMT_S8: - return SND_PCM_FORMAT_S8; - break; - case AFMT_U8: - return SND_PCM_FORMAT_U8; - break; - case AFMT_U16_LE: - return SND_PCM_FORMAT_U16_LE; - break; - case AFMT_U16_BE: - return SND_PCM_FORMAT_U16_BE; - break; -#ifndef WORDS_BIGENDIAN - case AFMT_AC3: -#endif - case AFMT_S16_LE: - return SND_PCM_FORMAT_S16_LE; - break; -#ifdef WORDS_BIGENDIAN - case AFMT_AC3: -#endif - case AFMT_S16_BE: - return SND_PCM_FORMAT_S16_BE; - break; - case AFMT_S32_LE: - return SND_PCM_FORMAT_S32_LE; - break; - case AFMT_S32_BE: - return SND_PCM_FORMAT_S32_BE; - break; - case AFMT_U32_LE: - return SND_PCM_FORMAT_U32_LE; - break; - case AFMT_U32_BE: - return SND_PCM_FORMAT_U32_BE; - break; - case AFMT_S24_LE: - return SND_PCM_FORMAT_S24_LE; - break; - case AFMT_S24_BE: - return SND_PCM_FORMAT_S24_BE; - break; - case AFMT_U24_LE: - return SND_PCM_FORMAT_U24_LE; - break; - case AFMT_U24_BE: - return SND_PCM_FORMAT_U24_BE; - break; - case AFMT_FLOAT32: -#ifdef WORDS_BIGENDIAN - return SND_PCM_FORMAT_FLOAT_BE; -#else - return SND_PCM_FORMAT_FLOAT_LE; -#endif - break; - default: - return SND_PCM_FORMAT_MPEG; - break; - } -} - -/* to set/get/query special features/parameters */ -static MPXP_Rc __FASTCALL__ control(const ao_data_t* ao,int cmd, long arg) -{ - priv_t*priv=ao->priv; - int rval; - switch(cmd) { - case AOCONTROL_QUERY_FORMAT: - rval=fmt2alsa(arg); - return snd_pcm_hw_params_test_format(priv->handler, priv->hwparams,rval)==0? - MPXP_True:MPXP_False; - case AOCONTROL_QUERY_CHANNELS: - rval=arg; - return snd_pcm_hw_params_test_channels(priv->handler, priv->hwparams,rval)==0? - MPXP_True:MPXP_False; - case AOCONTROL_QUERY_RATE: - rval=arg; - return snd_pcm_hw_params_test_rate(priv->handler, priv->hwparams,rval,0)==0? - MPXP_True:MPXP_False; - case AOCONTROL_GET_VOLUME: - case AOCONTROL_SET_VOLUME: -#ifndef WORDS_BIGENDIAN - { //seems to be a problem on macs? - ao_control_vol_t *vol = (ao_control_vol_t *)arg; - - int err; - snd_mixer_t *handle; - snd_mixer_elem_t *elem; - snd_mixer_selem_id_t *sid; - - const char *mix_name = "PCM"; - char *card = "default"; - - long pmin, pmax; - long get_vol, set_vol; - float calc_vol, diff, f_multi; - - if(ao->format == AFMT_AC3) return MPXP_True; - - //allocate simple id - snd_mixer_selem_id_alloca(&sid); - - //sets simple-mixer index and name - snd_mixer_selem_id_set_index(sid, 0); - snd_mixer_selem_id_set_name(sid, mix_name); - - if ((err = snd_mixer_open(&handle, 0)) < 0) { - MSG_ERR("alsa-control: mixer open error: %s\n", snd_strerror(err)); - return MPXP_Error; - } - - if ((err = snd_mixer_attach(handle, card)) < 0) { - MSG_ERR("alsa-control: mixer attach %s error: %s", card, snd_strerror(err)); - snd_mixer_close(handle); - return MPXP_Error; - } - - if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0) { - MSG_ERR("alsa-control: mixer register error: %s", snd_strerror(err)); - snd_mixer_close(handle); - return MPXP_Error; - } - if ((err = snd_mixer_load(handle)) < 0) { - MSG_ERR("alsa-control: mixer load error: %s", snd_strerror(err)); - snd_mixer_close(handle); - return MPXP_Error; - } - - elem = snd_mixer_find_selem(handle, sid); - if (!elem) { - MSG_ERR("alsa-control: unable to find simple control '%s',%i\n", snd_mixer_selem_id_get_name(sid), snd_mixer_selem_id_get_index(sid)); - snd_mixer_close(handle); - return MPXP_Error; - } - - snd_mixer_selem_get_playback_volume_range(elem,&pmin,&pmax); - f_multi = (100 / (float)pmax); - - if (cmd == AOCONTROL_SET_VOLUME) { - - diff = (vol->left+vol->right) / 2; - set_vol = rint(diff / f_multi); - - if (set_vol < 0) set_vol = 0; - else if (set_vol > pmax) set_vol = pmax; - - //setting channels - if ((err = snd_mixer_selem_set_playback_volume(elem, 0, set_vol)) < 0) { - MSG_ERR("alsa-control: error setting left channel, %s",snd_strerror(err)); - return MPXP_Error; - } - if ((err = snd_mixer_selem_set_playback_volume(elem, 1, set_vol)) < 0) { - MSG_ERR("alsa-control: error setting right channel, %s",snd_strerror(err)); - return MPXP_Error; - } - } else { - snd_mixer_selem_get_playback_volume(elem, 0, &get_vol); - calc_vol = get_vol; - calc_vol = rintf(calc_vol * f_multi); - - vol->left = vol->right = (int)calc_vol; - - //printf("get_vol = %i, calc=%i\n",get_vol, calc_vol); - } - snd_mixer_close(handle); - return MPXP_Ok; - } -#else // end big-endian - return MPXP_Unknown; -#endif - } //end witch - return MPXP_Unknown; -} - -static void __FASTCALL__ show_caps(unsigned device) -{ - snd_pcm_info_t *alsa_info; - snd_pcm_t *pcm; - snd_pcm_hw_params_t *hw_params; - snd_output_t *sout; - int err,cards=-1; - unsigned rmin,rmax; - unsigned j,sdmin,sdmax; - char adevice[ALSA_DEVICE_SIZE]; - if ((err = snd_card_next(&cards)) < 0 || cards < 0) - { - MSG_ERR("AO-INFO: alsa-init: no soundcards found: %s\n", snd_strerror(err)); - return; - } - snd_pcm_info_malloc(&alsa_info); - snd_pcm_info_set_device(alsa_info,device); - sdmin=snd_pcm_info_get_subdevice(alsa_info); - sdmax=sdmin+snd_pcm_info_get_subdevices_count(alsa_info); - MSG_INFO("AO-INFO: show caps for device %i:%i-%i\n",device,sdmin,sdmax); - for(j=sdmin;j<=sdmax;j++) - { - int i; - snd_pcm_info_set_subdevice(alsa_info,j); - sprintf(adevice,"hw:%u,%u",snd_pcm_info_get_device(alsa_info),snd_pcm_info_get_subdevice(alsa_info)); - MSG_INFO("AO-INFO: %s %s.%s.%s\n\n",adevice,snd_pcm_info_get_id(alsa_info),snd_pcm_info_get_name(alsa_info),snd_pcm_info_get_subdevice_name(alsa_info)); - if(snd_pcm_open(&pcm,adevice,SND_PCM_STREAM_PLAYBACK,SND_PCM_NONBLOCK)<0) - { - MSG_ERR("alsa-init: playback open error: %s\n", snd_strerror(err)); - return; - } - snd_pcm_hw_params_malloc(&hw_params); - if(snd_pcm_hw_params_any(pcm, hw_params)<0) - { - MSG_ERR("alsa-init: can't get initial parameters: %s\n", snd_strerror(err)); - return; - } - MSG_INFO(" AO-INFO: List of access type: "); - for(i=0;i<SND_PCM_ACCESS_LAST;i++) - if(!snd_pcm_hw_params_test_access(pcm,hw_params,i)) - MSG_INFO("%s ",snd_pcm_access_name(i)); - MSG_INFO("\n"); - MSG_INFO(" AO-INFO: List of supported formats: "); - for(i=0;i<SND_PCM_FORMAT_LAST;i++) - if(!snd_pcm_hw_params_test_format(pcm,hw_params,i)) - MSG_INFO("%s ",snd_pcm_format_name(i)); - MSG_INFO("\n"); - MSG_INFO(" AO-INFO: List of supported channels: "); - for(i=0;i<64;i++) - if(!snd_pcm_hw_params_test_format(pcm,hw_params,i)) - MSG_INFO("%u ",i); - MSG_INFO("\n"); - snd_pcm_hw_params_get_rate_min(hw_params,&rmin,&err); - snd_pcm_hw_params_get_rate_max(hw_params,&rmax,&err); - MSG_INFO(" AO-INFO: Rates range: %u %u\n",rmin,rmax); - snd_output_stdio_attach(&sout, stderr, 0); - snd_pcm_hw_params_dump(hw_params, sout); - if(hw_params) snd_pcm_hw_params_free(hw_params); - if(pcm) snd_pcm_close(pcm); - } - snd_pcm_info_free(alsa_info); -} - -/* - open & setup audio device - return: 1=success 0=fail -*/ -static MPXP_Rc __FASTCALL__ init(ao_data_t* ao,unsigned flags) -{ - int err; - int cards = -1; - snd_pcm_info_t *alsa_info; - char *str_block_mode; - char *alsa_dev=NULL; - char *alsa_port=NULL; - char alsa_device[ALSA_DEVICE_SIZE]; - UNUSED(flags); - ao->priv=mp_mallocz(sizeof(priv_t)); - priv_t*priv=ao->priv; - priv->first=1; - - priv->handler = NULL; - alsa_device[0]='\0'; - - MSG_V("alsa-init: compiled for ALSA-%s\n", SND_LIB_VERSION_STR); - - if (ao->subdevice) { - const char *param; - char *p; - // example: -ao alsa:hw:0#mmap=1 - param=mrl_parse_line(ao->subdevice,NULL,NULL,&alsa_dev,&alsa_port); - mrl_parse_params(param,alsaconf); - if(alsa_port) { - p=strchr(alsa_port,','); - if(p) { - if(strcmp(p+1,"-1")==0) { - *p='\0'; - show_caps(atoi(alsa_port)); - return MPXP_False; - } - } - if(alsa_port) snprintf(alsa_device,sizeof(alsa_device),"%s:%s",alsa_dev,alsa_port); - else strncpy(alsa_device,alsa_dev,sizeof(alsa_device)); - MSG_V("alsa-init: soundcard set to %s\n", alsa_device); - } //end parsing ao->subdevice - } - - if ((err = snd_card_next(&cards)) < 0 || cards < 0) { - MSG_ERR("alsa-init: no soundcards found: %s\n", snd_strerror(err)); - return MPXP_False; - } - - if (alsa_device[0] == '\0') { - int tmp_device, tmp_subdevice; - - if ((err = snd_pcm_info_malloc(&alsa_info)) < 0) { - MSG_ERR("alsa-init: memory allocation error: %s\n", snd_strerror(err)); - return MPXP_False; - } - - if ((tmp_device = snd_pcm_info_get_device(alsa_info)) < 0) { - MSG_ERR("alsa-init: cant get device\n"); - return MPXP_False; - } - - if ((tmp_subdevice = snd_pcm_info_get_subdevice(alsa_info)) < 0) { - MSG_ERR("alsa-init: cant get subdevice\n"); - return MPXP_False; - } - MSG_V("alsa-init: got device=%i, subdevice=%i\n", tmp_device, tmp_subdevice); - - if ((err = snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%1d,%1d", tmp_device, tmp_subdevice)) <= 0) { - MSG_ERR("alsa-init: cant wrote device-id\n"); - } - snd_pcm_info_free(alsa_info); - } - - MSG_WARN("alsa-init: Testing & bugs are welcome. Found %d cards, use: %s\n",cards+1,alsa_device); - //setting modes for block or nonblock-mode - int open_mode,block_mode; - if (priv_conf.noblock) { - open_mode = SND_PCM_NONBLOCK; - block_mode = 1; - str_block_mode = "nonblock-mode"; - } else { - open_mode = 0; - block_mode = 0; - str_block_mode = "block-mode"; - } - - if (!priv->handler) { - //modes = 0, SND_PCM_NONBLOCK, SND_PCM_ASYNC - if ((err = snd_pcm_open(&priv->handler, alsa_device, SND_PCM_STREAM_PLAYBACK, open_mode)) < 0) { - if (priv_conf.noblock) { - MSG_ERR("alsa-init: open in nonblock-mode failed, trying to open in block-mode\n"); - if ((err = snd_pcm_open(&priv->handler, alsa_device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) { - MSG_ERR("alsa-init: playback open error: %s\n", snd_strerror(err)); - alsa_device[0]='\0'; - return MPXP_False; - } else { - block_mode = 0; - str_block_mode = "block-mode"; - } - } else { - MSG_ERR("alsa-init: playback open error: %s\n", snd_strerror(err)); - alsa_device[0]='\0'; - return MPXP_False; - } - } - alsa_device[0]='\0'; - if ((err = snd_pcm_nonblock(priv->handler, block_mode)) < 0) { - MSG_ERR("alsa-init: error set block-mode %s\n", snd_strerror(err)); - } - else MSG_V("alsa-init: pcm opend in %s\n", str_block_mode); - - snd_pcm_hw_params_malloc(&priv->hwparams); - snd_pcm_sw_params_malloc(&priv->swparams); - - // setting hw-parameters - if ((err = snd_pcm_hw_params_any(priv->handler, priv->hwparams)) < 0) - { - MSG_ERR("alsa-init: unable to get initial parameters: %s\n", - snd_strerror(err)); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_params_any()\n"); - if (priv_conf.mmap) { - snd_pcm_access_mask_t *mask = alloca(snd_pcm_access_mask_sizeof()); - snd_pcm_access_mask_none(mask); - snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_INTERLEAVED); - snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED); - snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_COMPLEX); - err = snd_pcm_hw_params_set_access_mask(priv->handler, priv->hwparams, mask); - MSG_ERR("alsa-init: mmap set\n"); - } else { - err = snd_pcm_hw_params_set_access(priv->handler, priv->hwparams,SND_PCM_ACCESS_RW_INTERLEAVED); - MSG_DBG2("snd_pcm_hw_params_set_access(SND_PCM_ACCESS_RW_INTERLEAVED)\n"); - } - if (err < 0) { - MSG_ERR("alsa-init: unable to set access type: %s\n", snd_strerror(err)); - return MPXP_False; - } - } // end switch priv->handler (spdif) - return MPXP_Ok; -} // end init - -static MPXP_Rc __FASTCALL__ configure(ao_data_t* ao,unsigned rate_hz,unsigned channels,unsigned format) -{ - priv_t*priv=ao->priv; - int err,i; - size_t chunk_size=0,chunk_bytes,bits_per_sample,bits_per_frame; - snd_pcm_uframes_t dummy; - - MSG_V("alsa-conf: requested format: %d Hz, %d channels, %s\n", rate_hz, - channels, ao_format_name(format)); - - ao->samplerate = rate_hz; - ao->bps = channels * rate_hz; - ao->format = format; - ao->channels = channels; - ao->outburst = OUTBURST; - //ao->buffersize = MAX_OUTBURST; // was 16384 - - priv->format=fmt2alsa(format); - - switch(priv->format) { - case SND_PCM_FORMAT_S16_LE: - case SND_PCM_FORMAT_U16_LE: - case SND_PCM_FORMAT_S16_BE: - case SND_PCM_FORMAT_U16_BE: - ao->bps *= 2; - break; - case SND_PCM_FORMAT_S32_LE: - case SND_PCM_FORMAT_S32_BE: - case SND_PCM_FORMAT_U32_LE: - case SND_PCM_FORMAT_U32_BE: - case SND_PCM_FORMAT_FLOAT_BE: - case SND_PCM_FORMAT_FLOAT_LE: - ao->bps *= 4; - break; - case SND_PCM_FORMAT_S24_LE: - case SND_PCM_FORMAT_S24_BE: - case SND_PCM_FORMAT_U24_LE: - case SND_PCM_FORMAT_U24_BE: - ao->bps *= 3; - break; - case -1: - MSG_ERR("alsa-conf: invalid format (%s) requested - output disabled\n", - ao_format_name(format)); - return MPXP_False; - default: - break; - } - priv->bytes_per_sample = ao->bps / ao->samplerate; - - if ((err = snd_pcm_hw_params_set_format(priv->handler, priv->hwparams, - priv->format)) < 0) { - MSG_ERR("alsa-conf: unable to set format(%s): %s\n", - snd_pcm_format_name(priv->format), - snd_strerror(err)); - MSG_HINT("Please try one of: "); - for(i=0;i<SND_PCM_FORMAT_LAST;i++) - if (!(snd_pcm_hw_params_test_format(priv->handler, priv->hwparams, i))) - MSG_HINT("%s ",snd_pcm_format_name(i)); - MSG_HINT("\n"); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_params_set_format(%i)\n",priv->format); - - if ((err = snd_pcm_hw_params_set_rate_near(priv->handler, priv->hwparams, &ao->samplerate, 0)) < 0) { - MSG_ERR("alsa-conf: unable to set samplerate %u: %s\n", - ao->samplerate, - snd_strerror(err)); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_params_set_rate_near(%i)\n",ao->samplerate); - - if ((err = snd_pcm_hw_params_set_channels(priv->handler, priv->hwparams, - ao->channels)) < 0) { - MSG_ERR("alsa-conf: unable to set %u channels: %s\n", - ao->channels, - snd_strerror(err)); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_params_set_channels(%i)\n",ao->channels); -#ifdef BUFFERTIME - { - int dir; - unsigned period_time,alsa_buffer_time = 500000; /* buffer time in us */ - - if ((err = snd_pcm_hw_params_set_buffer_time_near(priv->handler, priv->hwparams, &alsa_buffer_time, &dir)) < 0) { - MSG_ERR("alsa-init: unable to set buffer time near: %s\n", - snd_strerror(err)); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_set_buffer_time_near(%i)\n",alsa_buffer_time); - - period_time = alsa_buffer_time/4; - if ((err = snd_pcm_hw_params_set_period_time_near(priv->handler, priv->hwparams, &period_time, &dir)) < 0) { - /* original: alsa_buffer_time/ao->bps */ - MSG_ERR("alsa-init: unable to set period time: %s\n", - snd_strerror(err)); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_set_period_time_near(%i)\n",period_time); - MSG_V("alsa-init: buffer_time: %d, period_time :%d\n",alsa_buffer_time, period_time); - } -#else - { - int dir=0; - unsigned period_time=100000; /* period time in us */ - snd_pcm_uframes_t size; - if ((err = snd_pcm_hw_params_set_period_time_near(priv->handler, priv->hwparams, &period_time, &dir)) < 0) { - MSG_ERR("alsa-init: unable to set period_time: %s\n", snd_strerror(err)); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_set_period_time(%i)\n",period_time); - - //get chunksize - if ((err = snd_pcm_hw_params_get_period_size(priv->hwparams, &size, &dir)) < 0) { - MSG_ERR("alsa-init: unable to get period_size: %s\n", snd_strerror(err)); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_get_period_size(%i)\n",size); - chunk_size=size; - } -#endif - // gets buffersize for control - if ((err = snd_pcm_hw_params_get_buffer_size(priv->hwparams,&dummy)) < 0) { - MSG_ERR("alsa-conf: unable to get buffersize: %s\n", snd_strerror(err)); - return MPXP_False; - } else { - ao->buffersize = dummy * priv->bytes_per_sample; - MSG_V("alsa-conf: got buffersize=%i\n", ao->buffersize); - } - MSG_DBG2("snd_pcm_hw_params_get_buffer_size(%i)\n",dummy); - bits_per_sample = snd_pcm_format_physical_width(priv->format); - MSG_DBG2("%i=snd_pcm_hw_format_pohysical_width()\n",bits_per_sample); - bits_per_frame = bits_per_sample * channels; - chunk_bytes = chunk_size * bits_per_frame / 8; - - MSG_V("alsa-conf: bits per sample (bps)=%i, bits per frame (bpf)=%i, chunk_bytes=%i\n",bits_per_sample,bits_per_frame,chunk_bytes); - - /* finally install hardware parameters */ - if ((err = snd_pcm_hw_params(priv->handler, priv->hwparams)) < 0) { - MSG_ERR("alsa-conf: unable to set hw-parameters: %s\n", - snd_strerror(err)); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_params()\n"); - // setting sw-params (only avail-min) if noblocking mode was choosed - if (priv_conf.noblock) { - if ((err = snd_pcm_sw_params_current(priv->handler, priv->swparams)) < 0) { - MSG_ERR("alsa-conf: unable to get parameters: %s\n",snd_strerror(err)); - return MPXP_False; - } - - //set min available frames to consider pcm ready (4) - //increased for nonblock-mode should be set dynamically later - if ((err = snd_pcm_sw_params_set_avail_min(priv->handler, priv->swparams, 4)) < 0) { - MSG_ERR("alsa-conf: unable to set avail_min %s\n",snd_strerror(err)); - return MPXP_False; - } - - if ((err = snd_pcm_sw_params(priv->handler, priv->swparams)) < 0) { - MSG_ERR("alsa-conf: unable to install sw-params\n"); - return MPXP_False; - } - - }//end swparams - - if ((err = snd_pcm_prepare(priv->handler)) < 0) { - MSG_ERR("alsa-conf: pcm prepare error: %s\n", snd_strerror(err)); - return MPXP_False; - } - // end setting hw-params - MSG_V("alsa-conf: %d Hz/%d channels/%d bpf/%d bytes buffer/%s\n", - ao->samplerate, ao->channels, priv->bytes_per_sample, ao->buffersize, - snd_pcm_format_description(priv->format)); - return MPXP_Ok; -} // end configure - -/* close audio device */ -static void uninit(ao_data_t* ao) -{ - int err; - priv_t*priv=ao->priv; - if(!priv->handler) { - MSG_ERR("alsa-uninit: no handler defined!\n"); - mp_free(priv); - return; - } - - if (!priv_conf.noblock) { - if ((err = snd_pcm_drain(priv->handler)) < 0) { - MSG_ERR("alsa-uninit: pcm drain error: %s\n", snd_strerror(err)); - mp_free(priv); - return; - } - } - - if ((err = snd_pcm_close(priv->handler)) < 0) { - MSG_ERR("alsa-uninit: pcm close error: %s\n", snd_strerror(err)); - mp_free(priv); - return; - } else { - priv->handler = NULL; - MSG_V("alsa-uninit: pcm closed\n"); - } - snd_pcm_hw_params_free(priv->hwparams); - snd_pcm_sw_params_free(priv->swparams); - mp_free(priv); -} - -static void audio_pause(ao_data_t* ao) -{ - priv_t*priv=ao->priv; - int err; - - if (!priv_conf.noblock) { - //drain causes error in nonblock-mode! - if ((err = snd_pcm_drain(priv->handler)) < 0) { - MSG_ERR("alsa-pause: pcm drain error: %s\n", snd_strerror(err)); - return; - } - } else { - MSG_V("alsa-pause: paused nonblock\n"); - return; - } -} - -static void audio_resume(ao_data_t* ao) -{ - priv_t*priv=ao->priv; - int err; - - if ((err = snd_pcm_prepare(priv->handler)) < 0) { - MSG_ERR("alsa-resume: pcm prepare error: %s\n", snd_strerror(err)); - return; - } -} - -/* stop playing and empty buffers (for seeking/pause) */ -static void reset(ao_data_t* ao) -{ - priv_t*priv=ao->priv; - int err; - - if ((err = snd_pcm_drop(priv->handler)) < 0) { - MSG_ERR("alsa-reset: pcm drop error: %s\n", snd_strerror(err)); - return; - } - if ((err = snd_pcm_prepare(priv->handler)) < 0) { - MSG_ERR("alsa-reset: pcm prepare error: %s\n", snd_strerror(err)); - return; - } - return; -} - -#ifdef USE_POLL -static int __FASTCALL__ wait_for_poll(snd_pcm_t *handle, struct pollfd *ufds, unsigned int count) -{ - unsigned short revents; - - while (1) { - poll(ufds, count, -1); - snd_pcm_poll_descriptors_revents(handle, ufds, count, &revents); - if (revents & POLLERR) return -EIO; - if (revents & POLLOUT) return 0; - } -} -#endif - -#ifndef timersub -#define timersub(a, b, result) \ -do { \ - (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ - (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ - if ((result)->tv_usec < 0) { \ - --(result)->tv_sec; \ - (result)->tv_usec += 1000000; \ - } \ -} while (0) -#endif - -/* I/O error handler */ -static int __FASTCALL__ xrun(const ao_data_t* ao,const char *str_mode) -{ - priv_t*priv=ao->priv; - int err; - snd_pcm_status_t *status; - - snd_pcm_status_alloca(&status); - - if ((err = snd_pcm_status(priv->handler, status))<0) { - MSG_ERR("status error: %s", snd_strerror(err)); - return 0; - } - - if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) { - struct timeval now, diff, tstamp; - gettimeofday(&now, 0); - snd_pcm_status_get_trigger_tstamp(status, &tstamp); - timersub(&now, &tstamp, &diff); - MSG_V("alsa-%s: xrun of at least %.3f msecs. resetting stream\n", - str_mode, - diff.tv_sec * 1000 + diff.tv_usec / 1000.0); - } - - if ((err = snd_pcm_prepare(priv->handler))<0) { - MSG_ERR("xrun: prepare error: %s", snd_strerror(err)); - return 0; - } - - return 1; /* ok, data should be accepted again */ -} - -static unsigned __FASTCALL__ play_normal(ao_data_t* ao,const any_t* data, unsigned len); -static unsigned __FASTCALL__ play_mmap(ao_data_t* ao,const any_t* data, unsigned len); - -static unsigned __FASTCALL__ play(ao_data_t* ao,const any_t* data, unsigned len, unsigned flags) -{ - unsigned result; - UNUSED(flags); - MSG_DBG2("[ao_alsa] %s playing %i bytes\n",priv_conf.mmap?"mmap":"normal",len); - if (priv_conf.mmap) result = play_mmap(ao,data, len); - else result = play_normal(ao,data, len); - return result; -} - -/* - plays 'len' bytes of 'data' - returns: number of bytes played - modified last at 29.06.02 by jp - thanxs for marius <ma...@ro...> for giving us the light ;) -*/ - -static unsigned __FASTCALL__ play_normal(ao_data_t* ao,const any_t* data, unsigned len) -{ - priv_t*priv=ao->priv; - //priv->bytes_per_sample is always 4 for 2 chn S16_LE - unsigned num_frames = len / priv->bytes_per_sample; - char *output_samples = (char *)data; - snd_pcm_sframes_t res = 0; - - //fprintf(stderr,"alsa-play: frames=%i, len=%i\n",num_frames,len); - - if (!priv->handler) { - MSG_ERR("alsa-play: device configuration error"); - return 0; - } - - while (num_frames > 0) { - res = snd_pcm_writei(priv->handler, (any_t*)output_samples, num_frames); - if (res == -EAGAIN) { - snd_pcm_wait(priv->handler, 1000); - } else if (res == -EPIPE) { /* underrun */ - if (xrun(ao,"play") <= 0) { - MSG_ERR("alsa-play: xrun reset error"); - return 0; - } - } else if (res == -ESTRPIPE) { /* suspend */ - MSG_WARN("alsa-play: pcm in suspend mode. trying to resume\n"); - while ((res = snd_pcm_resume(priv->handler)) == -EAGAIN) sleep(1); - } else if (res < 0) { - MSG_ERR("alsa-play: unknown status, trying to reset soundcard\n"); - if ((res = snd_pcm_prepare(priv->handler)) < 0) { - MSG_ERR("alsa-play: snd prepare error"); - return 0; - break; - } - } - - if (res > 0) { - /* output_samples += ao->channels * res; */ - output_samples += res * priv->bytes_per_sample; - num_frames -= res; - } - } //end while - - if (res < 0) { - MSG_ERR("alsa-play: write error %s", snd_strerror(res)); - return 0; - } - return res < 0 ? 0 : len; -} - -/* mmap-mode mainly based on descriptions by Joshua Haberman <jo...@ha...> - * 'An overview of the ALSA API' http://people.debian.org/~joshua/x66.html - * and some help by Paul Davis <pb...@op...> */ - -static unsigned __FASTCALL__ play_mmap(ao_data_t* ao,const any_t* data, unsigned len) -{ - priv_t*priv=ao->priv; - snd_pcm_sframes_t commitres, frames_available; - snd_pcm_uframes_t frames_transmit, size, offset; - const snd_pcm_channel_area_t *area; - any_t*outbuffer; - unsigned result; - -#ifdef USE_POLL //seems not really be needed - struct pollfd *ufds; - int count; - - count = snd_pcm_poll_descriptors_count (priv->handler); - ufds = mp_malloc(sizeof(struct pollfd) * count); - snd_pcm_poll_descriptors(priv->handler, ufds, count); - - //first wait_for_poll - if (err = (wait_for_poll(priv->handler, ufds, count) < 0)) { - if (snd_pcm_state(priv->handler) == SND_PCM_STATE_XRUN || - snd_pcm_state(priv->handler) == SND_PCM_STATE_SUSPENDED) { - xrun("play"); - } - } -#endif - - outbuffer = alloca(ao->buffersize); - - //don't trust get_space() ;) - frames_available = snd_pcm_avail_update(priv->handler) * priv->bytes_per_sample; - if (frames_available < 0) xrun(ao,"play"); - - if (frames_available < 4) { - if (priv->first) { - priv->first = 0; - snd_pcm_start(priv->handler); - } else { //FIXME should break and return 0? - snd_pcm_wait(priv->handler, -1); - priv->first = 1; - } - } - - /* len is simply the available bufferspace got by get_space() - * but real avail_buffer in frames is ab/priv->bytes_per_sample */ - size = len / priv->bytes_per_sample; - - //if (verbose) - //printf("len: %i size %i, f_avail %i, bps %i ...\n", len, size, frames_available, priv->bytes_per_sample); - - frames_transmit = size; - - /* prepare areas and set sw-pointers - * frames_transmit returns the real available buffer-size - * sometimes != frames_available cause of ringbuffer 'emulation' */ - snd_pcm_mmap_begin(priv->handler, &area, &offset, &frames_transmit); - - /* this is specific to interleaved streams (or non-interleaved - * streams with only one channel) */ - outbuffer = ((char *) area->addr + (area->first + area->step * offset) / 8); //8 - - //write data - memcpy(outbuffer, data, (frames_transmit * priv->bytes_per_sample)); - commitres = snd_pcm_mmap_commit(priv->handler, offset, frames_transmit); - - if (commitres < 0 || (snd_pcm_uframes_t)commitres != frames_transmit) { - if (snd_pcm_state(priv->handler) == SND_PCM_STATE_XRUN || - snd_pcm_state(priv->handler) == SND_PCM_STATE_SUSPENDED) { - xrun(ao,"play"); - } - } - - //if (verbose) - //printf("mmap ft: %i, cres: %i\n", frames_transmit, commitres); - - /* err = snd_pcm_area_copy(&area, offset, &data, offset, len, priv->format); */ - /* if (err < 0) { */ - /* printf("area-copy-error\n"); */ - /* return 0; */ - /* } */ - - //calculate written frames! - result = commitres * priv->bytes_per_sample; - - - /* if (verbose) { */ - /* if (len == result) */ - /* printf("result: %i, frames written: %i ...\n", result, frames_transmit); */ - /* else */ - /* printf("result: %i, frames written: %i, result != len ...\n", result, frames_transmit); */ - /* } */ - - //mplayer doesn't like -result - if ((int)result < 0) result = 0; - -#ifdef USE_POLL - mp_free(ufds); -#endif - - return result; -} - -typedef enum space_status_e { - GET_SPACE_OPEN, - GET_SPACE_PREPARED, - GET_SPACE_RUNNING, - GET_SPACE_PAUSED, - GET_SPACE_XRUN, - GET_SPACE_UNDEFINED -}space_status; -/* how many byes are mp_free in the buffer */ -static unsigned get_space(const ao_data_t* ao) -{ - priv_t*priv=ao->priv; - snd_pcm_status_t *status; - int ret,st; - space_status e_status=GET_SPACE_UNDEFINED; - - //snd_pcm_sframes_t avail_frames = 0; - - if ((ret = snd_pcm_status_malloc(&status)) < 0) { - MSG_ERR("alsa-space: memory allocation error: %s\n", snd_strerror(ret)); - return 0; - } - - if ((ret = snd_pcm_status(priv->handler, status)) < 0) { - MSG_ERR("alsa-space: cannot get pcm status: %s\n", snd_strerror(ret)); - return 0; - } - - switch((st=snd_pcm_status_get_state(status))) { - case SND_PCM_STATE_OPEN: - e_status = GET_SPACE_OPEN; - case SND_PCM_STATE_PREPARED: - if (e_status!=GET_SPACE_OPEN) { - e_status = GET_SPACE_PREPARED; - priv->first = 1; - ret = snd_pcm_status_get_avail(status) * priv->bytes_per_sample; - if (ret == 0) //ugly workaround for hang in mmap-mode - ret = 10; - break; - } - case SND_PCM_STATE_RUNNING: - ret = snd_pcm_status_get_avail(status) * priv->bytes_per_sample; - //avail_frames = snd_pcm_avail_update(priv->handler) * priv->bytes_per_sample; - if (e_status!=GET_SPACE_OPEN && e_status!=GET_SPACE_PREPARED) - e_status = GET_SPACE_RUNNING; - break; - case SND_PCM_STATE_PAUSED: - MSG_V("alsa-space: paused"); - e_status = GET_SPACE_PAUSED; - ret = 0; - break; - case SND_PCM_STATE_XRUN: - xrun(ao,"space"); - e_status = GET_SPACE_XRUN; - priv->first = 1; - ret = 0; - break; - default: - e_status = GET_SPACE_UNDEFINED; - ret = snd_pcm_status_get_avail(status) * priv->bytes_per_sample; - if (ret <= 0) { - xrun(ao,"space"); - } - } - - if (e_status!=GET_SPACE_RUNNING) - MSG_V("alsa-space: mp_free space = %i, status=%i, %i --\n", ret, st, e_status); - snd_pcm_status_free(status); - - if (ret < 0) { - MSG_ERR("negative value!!\n"); - ret = 0; - } - - return ret; -} - -/* delay in seconds between first and last sample in buffer */ -static float get_delay(const ao_data_t* ao) -{ - priv_t*priv=ao->priv; - if (priv->handler) { - snd_pcm_status_t *status; - int r; - float ret; - - if ((ret = snd_pcm_status_malloc(&status)) < 0) { - MSG_ERR("alsa-delay: memory allocation error: %s\n", snd_strerror(ret)); - return 0; - } - - if ((ret = snd_pcm_status(priv->handler, status)) < 0) { - MSG_ERR("alsa-delay: cannot get pcm status: %s\n", snd_strerror(ret)); - return 0; - } - - switch(snd_pcm_status_get_state(status)) { - case SND_PCM_STATE_OPEN: - case SND_PCM_STATE_PREPARED: - case SND_PCM_STATE_RUNNING: - r=snd_pcm_status_get_delay(status); - ret = (float)r/(float)ao->samplerate; - break; - default: - ret = 0; - } - snd_pcm_status_free(status); - - if (ret < 0) ret = 0; - return ret; - } else return 0; -} Copied: mplayerxp/libao2/ao_alsa9.cpp (from rev 417, mplayerxp/libao2/ao_alsa9.c) =================================================================== --- mplayerxp/libao2/ao_alsa9.cpp (rev 0) +++ mplayerxp/libao2/ao_alsa9.cpp 2012-11-21 09:24:56 UTC (rev 419) @@ -0,0 +1,1050 @@ +/* + ao_alsa9 - ALSA-0.9.x output plugin for MPlayer + + (C) Alex Beregszaszi <al...@na...> + + modified for real alsa-0.9.0-support by Joy Winter <jo...@pi...> + additional AC3 passthrough support by Andy Lo A Foe <an...@al...> + 08/22/2002 iec958-init rewritten and merged with common init, joy + + Any bugreports regarding to this driver are welcome. +*/ + +#include <errno.h> +#include <sys/time.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> +#include <sys/poll.h> + +#include "mp_config.h" +#include "mplayerxp.h" +#define ALSA_PCM_NEW_HW_PARAMS_API +#define ALSA_PCM_NEW_SW_PARAMS_API +#include <alsa/asoundlib.h> + +#include "audio_out.h" +#include "audio_out_internal.h" +#include "afmt.h" +#include "ao_msg.h" +#include "libmpstream/mrl.h" +#include "osdep/mplib.h" + +static ao_info_t info = +{ + "ALSA-1.x audio output", + "alsa", + "Alex Beregszaszi <al...@na...>, Joy Winter <jo...@pi...>", + "under developement" +}; + +LIBAO_EXTERN(alsa) + +typedef struct priv_s { + snd_pcm_t* handler; + snd_pcm_format_t format; + snd_pcm_hw_params_t*hwparams; + snd_pcm_sw_params_t*swparams; + size_t bytes_per_sample; + int first; +}priv_t; + +typedef struct priv_conf_s { + int mmap; + int noblock; +}priv_conf_t; +static priv_conf_t priv_conf; +static const mrl_config_t alsaconf[]={ + { "mmap", &priv_conf.mmap, MRL_TYPE_BOOL, 0, 1 }, + { "noblock", &priv_conf.noblock, MRL_TYPE_BOOL, 0, 1 }, + { NULL, NULL, 0, 0, 0 } +}; + +#define ALSA_DEVICE_SIZE 48 + +#define BUFFERTIME // else SET_CHUNK_SIZE +#undef USE_POLL + +static snd_pcm_format_t __FASTCALL__ fmt2alsa(unsigned format) +{ + switch (format) + { + case AFMT_S8: + return SND_PCM_FORMAT_S8; + break; + case AFMT_U8: + return SND_PCM_FORMAT_U8; + break; + case AFMT_U16_LE: + return SND_PCM_FORMAT_U16_LE; + break; + case AFMT_U16_BE: + return SND_PCM_FORMAT_U16_BE; + break; +#ifndef WORDS_BIGENDIAN + case AFMT_AC3: +#endif + case AFMT_S16_LE: + return SND_PCM_FORMAT_S16_LE; + break; +#ifdef WORDS_BIGENDIAN + case AFMT_AC3: +#endif + case AFMT_S16_BE: + return SND_PCM_FORMAT_S16_BE; + break; + case AFMT_S32_LE: + return SND_PCM_FORMAT_S32_LE; + break; + case AFMT_S32_BE: + return SND_PCM_FORMAT_S32_BE; + break; + case AFMT_U32_LE: + return SND_PCM_FORMAT_U32_LE; + break; + case AFMT_U32_BE: + return SND_PCM_FORMAT_U32_BE; + break; + case AFMT_S24_LE: + return SND_PCM_FORMAT_S24_LE; + break; + case AFMT_S24_BE: + return SND_PCM_FORMAT_S24_BE; + break; + case AFMT_U24_LE: + return SND_PCM_FORMAT_U24_LE; + break; + case AFMT_U24_BE: + return SND_PCM_FORMAT_U24_BE; + break; + case AFMT_FLOAT32: +#ifdef WORDS_BIGENDIAN + return SND_PCM_FORMAT_FLOAT_BE; +#else + return SND_PCM_FORMAT_FLOAT_LE; +#endif + break; + default: + return SND_PCM_FORMAT_MPEG; + break; + } +} + +/* to set/get/query special features/parameters */ +static MPXP_Rc __FASTCALL__ control(const ao_data_t* ao,int cmd, long arg) +{ + priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); + int rval; + switch(cmd) { + case AOCONTROL_QUERY_FORMAT: + rval=fmt2alsa(arg); + return snd_pcm_hw_params_test_format(priv->handler, priv->hwparams,snd_pcm_format_t(rval))==0? + MPXP_True:MPXP_False; + case AOCONTROL_QUERY_CHANNELS: + rval=arg; + return snd_pcm_hw_params_test_channels(priv->handler, priv->hwparams,rval)==0? + MPXP_True:MPXP_False; + case AOCONTROL_QUERY_RATE: + rval=arg; + return snd_pcm_hw_params_test_rate(priv->handler, priv->hwparams,rval,0)==0? + MPXP_True:MPXP_False; + case AOCONTROL_GET_VOLUME: + case AOCONTROL_SET_VOLUME: +#ifndef WORDS_BIGENDIAN + { //seems to be a problem on macs? + ao_control_vol_t *vol = (ao_control_vol_t *)arg; + + int err; + snd_mixer_t *handle; + snd_mixer_elem_t *elem; + snd_mixer_selem_id_t *sid; + + const char *mix_name = "PCM"; + const char *card = "default"; + + long pmin, pmax; + long get_vol, set_vol; + float calc_vol, diff, f_multi; + + if(ao->format == AFMT_AC3) return MPXP_True; + + //allocate simple id + snd_mixer_selem_id_alloca(&sid); + + //sets simple-mixer index and name + snd_mixer_selem_id_set_index(sid, 0); + snd_mixer_selem_id_set_name(sid, mix_name); + + if ((err = snd_mixer_open(&handle, 0)) < 0) { + MSG_ERR("alsa-control: mixer open error: %s\n", snd_strerror(err)); + return MPXP_Error; + } + + if ((err = snd_mixer_attach(handle, card)) < 0) { + MSG_ERR("alsa-control: mixer attach %s error: %s", card, snd_strerror(err)); + snd_mixer_close(handle); + return MPXP_Error; + } + + if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0) { + MSG_ERR("alsa-control: mixer register error: %s", snd_strerror(err)); + snd_mixer_close(handle); + return MPXP_Error; + } + if ((err = snd_mixer_load(handle)) < 0) { + MSG_ERR("alsa-control: mixer load error: %s", snd_strerror(err)); + snd_mixer_close(handle); + return MPXP_Error; + } + + elem = snd_mixer_find_selem(handle, sid); + if (!elem) { + MSG_ERR("alsa-control: unable to find simple control '%s',%i\n", snd_mixer_selem_id_get_name(sid), snd_mixer_selem_id_get_index(sid)); + snd_mixer_close(handle); + return MPXP_Error; + } + + snd_mixer_selem_get_playback_volume_range(elem,&pmin,&pmax); + f_multi = (100 / (float)pmax); + + if (cmd == AOCONTROL_SET_VOLUME) { + + diff = (vol->left+vol->right) / 2; + set_vol = rint(diff / f_multi); + + if (set_vol < 0) set_vol = 0; + else if (set_vol > pmax) set_vol = pmax; + + //setting channels + if ((err = snd_mixer_selem_set_playback_volume(elem, snd_mixer_selem_channel_id_t(0), set_vol)) < 0) { + MSG_ERR("alsa-control: error setting left channel, %s",snd_strerror(err)); + return MPXP_Error; + } + if ((err = snd_mixer_selem_set_playback_volume(elem, snd_mixer_selem_channel_id_t(1), set_vol)) < 0) { + MSG_ERR("alsa-control: error setting right channel, %s",snd_strerror(err)); + return MPXP_Error; + } + } else { + snd_mixer_selem_get_playback_volume(elem, snd_mixer_selem_channel_id_t(0), &get_vol); + calc_vol = get_vol; + calc_vol = rintf(calc_vol * f_multi); + + vol->left = vol->right = (int)calc_vol; + + //printf("get_vol = %i, calc=%i\n",get_vol, calc_vol); + } + snd_mixer_close(handle); + return MPXP_Ok; + } +#else // end big-endian + return MPXP_Unknown; +#endif + } //end witch + return MPXP_Unknown; +} + +static void __FASTCALL__ show_caps(unsigned device) +{ + snd_pcm_info_t *alsa_info; + snd_pcm_t *pcm; + snd_pcm_hw_params_t *hw_params; + snd_output_t *sout; + int err,cards=-1; + unsigned rmin,rmax; + unsigned j,sdmin,sdmax; + char adevice[ALSA_DEVICE_SIZE]; + if ((err = snd_card_next(&cards)) < 0 || cards < 0) + { + MSG_ERR("AO-INFO: alsa-init: no soundcards found: %s\n", snd_strerror(err)); + return; + } + snd_pcm_info_malloc(&alsa_info); + snd_pcm_info_set_device(alsa_info,device); + sdmin=snd_pcm_info_get_subdevice(alsa_info); + sdmax=sdmin+snd_pcm_info_get_subdevices_count(alsa_info); + MSG_INFO("AO-INFO: show caps for device %i:%i-%i\n",device,sdmin,sdmax); + for(j=sdmin;j<=sdmax;j++) + { + int i; + snd_pcm_info_set_subdevice(alsa_info,j); + sprintf(adevice,"hw:%u,%u",snd_pcm_info_get_device(alsa_info),snd_pcm_info_get_subdevice(alsa_info)); + MSG_INFO("AO-INFO: %s %s.%s.%s\n\n",adevice,snd_pcm_info_get_id(alsa_info),snd_pcm_info_get_name(alsa_info),snd_pcm_info_get_subdevice_name(alsa_info)); + if(snd_pcm_open(&pcm,adevice,SND_PCM_STREAM_PLAYBACK,SND_PCM_NONBLOCK)<0) + { + MSG_ERR("alsa-init: playback open error: %s\n", snd_strerror(err)); + return; + } + snd_pcm_hw_params_malloc(&hw_params); + if(snd_pcm_hw_params_any(pcm, hw_params)<0) + { + MSG_ERR("alsa-init: can't get initial parameters: %s\n", snd_strerror(err)); + return; + } + MSG_INFO(" AO-INFO: List of access type: "); + for(i=0;i<SND_PCM_ACCESS_LAST;i++) + if(!snd_pcm_hw_params_test_access(pcm,hw_params,snd_pcm_access_t(i))) + MSG_INFO("%s ",snd_pcm_access_name(snd_pcm_access_t(i))); + MSG_INFO("\n"); + MSG_INFO(" AO-INFO: List of supported formats: "); + for(i=0;i<SND_PCM_FORMAT_LAST;i++) + if(!snd_pcm_hw_params_test_format(pcm,hw_params,snd_pcm_format_t(i))) + MSG_INFO("%s ",snd_pcm_format_name(snd_pcm_format_t(i))); + MSG_INFO("\n"); + MSG_INFO(" AO-INFO: List of supported channels: "); + for(i=0;i<64;i++) + if(!snd_pcm_hw_params_test_format(pcm,hw_params,snd_pcm_format_t(i))) + MSG_INFO("%u ",i); + MSG_INFO("\n"); + snd_pcm_hw_params_get_rate_min(hw_params,&rmin,&err); + snd_pcm_hw_params_get_rate_max(hw_params,&rmax,&err); + MSG_INFO(" AO-INFO: Rates range: %u %u\n",rmin,rmax); + snd_output_stdio_attach(&sout, stderr, 0); + snd_pcm_hw_params_dump(hw_params, sout); + if(hw_params) snd_pcm_hw_params_free(hw_params); + if(pcm) snd_pcm_close(pcm); + } + snd_pcm_info_free(alsa_info); +} + +/* + open & setup audio device + return: 1=success 0=fail +*/ +static MPXP_Rc __FASTCALL__ init(ao_data_t* ao,unsigned flags) +{ + int err; + int cards = -1; + snd_pcm_info_t *alsa_info; + const char *str_block_mode; + char *alsa_dev=NULL; + char *alsa_port=NULL; + char alsa_device[ALSA_DEVICE_SIZE]; + UNUSED(flags); + priv_t*priv; + priv=new(zeromem) priv_t; + ao->priv=priv; + priv->first=1; + + priv->handler = NULL; + alsa_device[0]='\0'; + + MSG_V("alsa-init: compiled for ALSA-%s\n", SND_LIB_VERSION_STR); + + if (ao->subdevice) { + const char *param; + char *p; + // example: -ao alsa:hw:0#mmap=1 + param=mrl_parse_line(ao->subdevice,NULL,NULL,&alsa_dev,&alsa_port); + mrl_parse_params(param,alsaconf); + if(alsa_port) { + p=strchr(alsa_port,','); + if(p) { + if(strcmp(p+1,"-1")==0) { + *p='\0'; + show_caps(atoi(alsa_port)); + return MPXP_False; + } + } + if(alsa_port) snprintf(alsa_device,sizeof(alsa_device),"%s:%s",alsa_dev,alsa_port); + else strncpy(alsa_device,alsa_dev,sizeof(alsa_device)); + MSG_V("alsa-init: soundcard set to %s\n", alsa_device); + } //end parsing ao->subdevice + } + + if ((err = snd_card_next(&cards)) < 0 || cards < 0) { + MSG_ERR("alsa-init: no soundcards found: %s\n", snd_strerror(err)); + return MPXP_False; + } + + if (alsa_device[0] == '\0') { + int tmp_device, tmp_subdevice; + + if ((err = snd_pcm_info_malloc(&alsa_info)) < 0) { + MSG_ERR("alsa-init: memory allocation error: %s\n", snd_strerror(err)); + return MPXP_False; + } + + if ((tmp_device = snd_pcm_info_get_device(alsa_info)) < 0) { + MSG_ERR("alsa-init: cant get device\n"); + return MPXP_False; + } + + if ((tmp_subdevice = snd_pcm_info_get_subdevice(alsa_info)) < 0) { + MSG_ERR("alsa-init: cant get subdevice\n"); + return MPXP_False; + } + MSG_V("alsa-init: got device=%i, subdevice=%i\n", tmp_device, tmp_subdevice); + + if ((err = snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%1d,%1d", tmp_device, tmp_subdevice)) <= 0) { + MSG_ERR("alsa-init: cant wrote device-id\n"); + } + snd_pcm_info_free(alsa_info); + } + + MSG_WARN("alsa-init: Testing & bugs are welcome. Found %d cards, use: %s\n",cards+1,alsa_device); + //setting modes for block or nonblock-mode + int open_mode,block_mode; + if (priv_conf.noblock) { + open_mode = SND_PCM_NONBLOCK; + block_mode = 1; + str_block_mode = "nonblock-mode"; + } else { + open_mode = 0; + block_mode = 0; + str_block_mode = "block-mode"; + } + + if (!priv->handler) { + //modes = 0, SND_PCM_NONBLOCK, SND_PCM_ASYNC + if ((err = snd_pcm_open(&priv->handler, alsa_device, SND_PCM_STREAM_PLAYBACK, open_mode)) < 0) { + if (priv_conf.noblock) { + MSG_ERR("alsa-init: open in nonblock-mode failed, trying to open in block-mode\n"); + if ((err = snd_pcm_open(&priv->handler, alsa_device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) { + MSG_ERR("alsa-init: playback open error: %s\n", snd_strerror(err)); + alsa_device[0]='\0'; + return MPXP_False; + } else { + block_mode = 0; + str_block_mode = "block-mode"; + } + } else { + MSG_ERR("alsa-init: playback open error: %s\n", snd_strerror(err)); + alsa_device[0]='\0'; + return MPXP_False; + } + } + alsa_device[0]='\0'; + if ((err = snd_pcm_nonblock(priv->handler, block_mode)) < 0) { + MSG_ERR("alsa-init: error set block-mode %s\n", snd_strerror(err)); + } + else MSG_V("alsa-init: pcm opend in %s\n", str_block_mode); + + snd_pcm_hw_params_malloc(&priv->hwparams); + snd_pcm_sw_params_malloc(&priv->swparams); + + // setting hw-parameters + if ((err = snd_pcm_hw_params_any(priv->handler, priv->hwparams)) < 0) + { + MSG_ERR("alsa-init: unable to get initial parameters: %s\n", + snd_strerror(err)); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_params_any()\n"); + if (priv_conf.mmap) { + snd_pcm_access_mask_t *mask = (snd_pcm_access_mask_t*)alloca(snd_pcm_access_mask_sizeof()); + snd_pcm_access_mask_none(mask); + snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_INTERLEAVED); + snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED); + snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_COMPLEX); + err = snd_pcm_hw_params_set_access_mask(priv->handler, priv->hwparams, mask); + MSG_ERR("alsa-init: mmap set\n"); + } else { + err = snd_pcm_hw_params_set_access(priv->handler, priv->hwparams,SND_PCM_ACCESS_RW_INTERLEAVED); + MSG_DBG2("snd_pcm_hw_params_set_access(SND_PCM_ACCESS_RW_INTERLEAVED)\n"); + } + if (err < 0) { + MSG_ERR("alsa-init: unable to set access type: %s\n", snd_strerror(err)); + return MPXP_False; + } + } // end switch priv->handler (spdif) + return MPXP_Ok; +} // end init + +static MPXP_Rc __FASTCALL__ configure(ao_data_t* ao,unsigned rate_hz,unsigned channels,unsigned format) +{ + priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); + int err,i; + size_t chunk_size=0,chunk_bytes,bits_per_sample,bits_per_frame; + snd_pcm_uframes_t dummy; + + MSG_V("alsa-conf: requested format: %d Hz, %d channels, %s\n", rate_hz, + channels, ao_format_name(format)); + + ao->samplerate = rate_hz; + ao->bps = channels * rate_hz; + ao->format = format; + ao->channels = channels; + ao->outburst = OUTBURST; + //ao->buffersize = MAX_OUTBURST; // was 16384 + + priv->format=fmt2alsa(format); + + switch(priv->format) { + case SND_PCM_FORMAT_S16_LE: + case SND_PCM_FORMAT_U16_LE: + case SND_PCM_FORMAT_S16_BE: + case SND_PCM_FORMAT_U16_BE: + ao->bps *= 2; + break; + case SND_PCM_FORMAT_S32_LE: + case SND_PCM_FORMAT_S32_BE: + case SND_PCM_FORMAT_U32_LE: + case SND_PCM_FORMAT_U32_BE: + case SND_PCM_FORMAT_FLOAT_BE: + case SND_PCM_FORMAT_FLOAT_LE: + ao->bps *= 4; + break; + case SND_PCM_FORMAT_S24_LE: + case SND_PCM_FORMAT_S24_BE: + case SND_PCM_FORMAT_U24_LE: + case SND_PCM_FORMAT_U24_BE: + ao->bps *= 3; + break; + case -1: + MSG_ERR("alsa-conf: invalid format (%s) requested - output disabled\n", + ao_format_name(format)); + return MPXP_False; + default: + break; + } + priv->bytes_per_sample = ao->bps / ao->samplerate; + + if ((err = snd_pcm_hw_params_set_format(priv->handler, priv->hwparams, + priv->format)) < 0) { + MSG_ERR("alsa-conf: unable to set format(%s): %s\n", + snd_pcm_format_name(priv->format), + snd_strerror(err)); + MSG_HINT("Please try one of: "); + for(i=0;i<SND_PCM_FORMAT_LAST;i++) + if (!(snd_pcm_hw_params_test_format(priv->handler, priv->hwparams, snd_pcm_format_t(i)))) + MSG_HINT("%s ",snd_pcm_format_name(snd_pcm_format_t(i))); + MSG_HINT("\n"); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_params_set_format(%i)\n",priv->format); + + if ((err = snd_pcm_hw_params_set_rate_near(priv->handler, priv->hwparams, &ao->samplerate, 0)) < 0) { + MSG_ERR("alsa-conf: unable to set samplerate %u: %s\n", + ao->samplerate, + snd_strerror(err)); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_params_set_rate_near(%i)\n",ao->samplerate); + + if ((err = snd_pcm_hw_params_set_channels(priv->handler, priv->hwparams, + ao->channels)) < 0) { + MSG_ERR("alsa-conf: unable to set %u channels: %s\n", + ao->channels, + snd_strerror(err)); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_params_set_channels(%i)\n",ao->channels); +#ifdef BUFFERTIME + { + int dir; + unsigned period_time,alsa_buffer_time = 500000; /* buffer time in us */ + + if ((err = snd_pcm_hw_params_set_buffer_time_near(priv->handler, priv->hwparams, &alsa_buffer_time, &dir)) < 0) { + MSG_ERR("alsa-init: unable to set buffer time near: %s\n", + snd_strerror(err)); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_set_buffer_time_near(%i)\n",alsa_buffer_time); + + period_time = alsa_buffer_time/4; + if ((err = snd_pcm_hw_params_set_period_time_near(priv->handler, priv->hwparams, &period_time, &dir)) < 0) { + /* original: alsa_buffer_time/ao->bps */ + MSG_ERR("alsa-init: unable to set period time: %s\n", + snd_strerror(err)); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_set_period_time_near(%i)\n",period_time); + MSG_V("alsa-init: buffer_time: %d, period_time :%d\n",alsa_buffer_time, period_time); + } +#else + { + int dir=0; + unsigned period_time=100000; /* period time in us */ + snd_pcm_uframes_t size; + if ((err = snd_pcm_hw_params_set_period_time_near(priv->handler, priv->hwparams, &period_time, &dir)) < 0) { + MSG_ERR("alsa-init: unable to set period_time: %s\n", snd_strerror(err)); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_set_period_time(%i)\n",period_time); + + //get chunksize + if ((err = snd_pcm_hw_params_get_period_size(priv->hwparams, &size, &dir)) < 0) { + MSG_ERR("alsa-init: unable to get period_size: %s\n", snd_strerror(err)); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_get_period_size(%i)\n",size); + chunk_size=size; + } +#endif + // gets buffersize for control + if ((err = snd_pcm_hw_params_get_buffer_size(priv->hwparams,&dummy)) < 0) { + MSG_ERR("alsa-conf: unable to get buffersize: %s\n", snd_strerror(err)); + return MPXP_False; + } else { + ao->buffersize = dummy * priv->bytes_per_sample; + MSG_V("alsa-conf: got buffersize=%i\n", ao->buffersize); + } + MSG_DBG2("snd_pcm_hw_params_get_buffer_size(%i)\n",dummy); + bits_per_sample = snd_pcm_format_physical_width(priv->format); + MSG_DBG2("%i=snd_pcm_hw_format_pohysical_width()\n",bits_per_sample); + bits_per_frame = bits_per_sample * channels; + chunk_bytes = chunk_size * bits_per_frame / 8; + + MSG_V("alsa-conf: bits per sample (bps)=%i, bits per frame (bpf)=%i, chunk_bytes=%i\n",bits_per_sample,bits_per_frame,chunk_bytes); + + /* finally install hardware parameters */ + if ((err = snd_pcm_hw_params(priv->handler, priv->hwparams)) < 0) { + MSG_ERR("alsa-conf: unable to set hw-parameters: %s\n", + snd_strerror(err)); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_params()\n"); + // setting sw-params (only avail-min) if noblocking mode was choosed + if (priv_conf.noblock) { + if ((err = snd_pcm_sw_params_current(priv->handler, priv->swparams)) < 0) { + MSG_ERR("alsa-conf: unable to get parameters: %s\n",snd_strerror(err)); + return MPXP_False; + } + + //set min available frames to consider pcm ready (4) + //increased for nonblock-mode should be set dynamically later + if ((err = snd_pcm_sw_params_set_avail_min(priv->handler, priv->swparams, 4)) < 0) { + MSG_ERR("alsa-conf: unable to set avail_min %s\n",snd_strerror(err)); + return MPXP_False; + } + + if ((err = snd_pcm_sw_params(priv->handler, priv->swparams)) < 0) { + MSG_ERR("alsa-conf: unable to install sw-params\n"); + return MPXP_False; + } + + }//end swparams + + if ((err = snd_pcm_prepare(priv->handler)) < 0) { + MSG_ERR("alsa-conf: pcm prepare error: %s\n", snd_strerror(err)); + return MPXP_False; + } + // end setting hw-params + MSG_V("alsa-conf: %d Hz/%d channels/%d bpf/%d bytes buffer/%s\n", + ao->samplerate, ao->channels, priv->bytes_per_sample, ao->buffersize, + snd_pcm_format_description(priv->format)); + return MPXP_Ok; +} // end configure + +/* close audio device */ +static void uninit(ao_data_t* ao) +{ + int err; + priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); + if(!priv->handler) { + MSG_ERR("alsa-uninit: no handler defined!\n"); + mp_free(priv); + return; + } + + if (!priv_conf.noblock) { + if ((err = snd_pcm_drain(priv->handler)) < 0) { + MSG_ERR("alsa-uninit: pcm drain error: %s\n", snd_strerror(err)); + mp_free(priv); + return; + } + } + + if ((err = snd_pcm_close(priv->handler)) < 0) { + MSG_ERR("alsa-uninit: pcm close error: %s\n", snd_strerror(err)); + mp_free(priv); + return; + } else { + priv->handler = NULL; + MSG_V("alsa-uninit: pcm closed\n"); + } + snd_pcm_hw_params_free(priv->hwparams); + snd_pcm_sw_params_free(priv->swparams); + mp_free(priv); +} + +static void audio_pause(ao_data_t* ao) +{ + priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); + int err; + + if (!priv_conf.noblock) { + //drain causes error in nonblock-mode! + if ((err = snd_pcm_drain(priv->handler)) < 0) { + MSG_ERR("alsa-pause: pcm drain error: %s\n", snd_strerror(err)); + return; + } + } else { + MSG_V("alsa-pause: paused nonblock\n"); + return; + } +} + +static void audio_resume(ao_data_t* ao) +{ + priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); + int err; + + if ((err = snd_pcm_prepare(priv->handler)) < 0) { + MSG_ERR("alsa-resume: pcm prepare error: %s\n", snd_strerror(err)); + return; + } +} + +/* stop playing and empty buffers (for seeking/pause) */ +static void reset(ao_data_t* ao) +{ + priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); + int err; + + if ((err = snd_pcm_drop(priv->handler)) < 0) { + MSG_ERR("alsa-reset: pcm drop error: %s\n", snd_strerror(err)); + return; + } + if ((err = snd_pcm_prepare(priv->handler)) < 0) { + MSG_ERR("alsa-reset: pcm prepare error: %s\n", snd_strerror(err)); + return; + } + return; +} + +#ifdef USE_POLL +static int __FASTCALL__ wait_for_poll(snd_pcm_t *handle, struct pollfd *ufds, unsigned int count) +{ + unsigned short revents; + + while (1) { + poll(ufds, count, -1); + snd_pcm_poll_descriptors_revents(handle, ufds, count, &revents); + if (revents & POLLERR) return -EIO; + if (revents & POLLOUT) return 0; + } +} +#endif + +#ifndef timersub +#define timersub(a, b, result) \ +do { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ + if ((result)->tv_usec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_usec += 1000000; \ + } \ +} while (0) +#endif + +/* I/O error handler */ +static int __FASTCALL__ xrun(const ao_data_t* ao,const char *str_mode) +{ + priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); + int err; + snd_pcm_status_t *status; + + snd_pcm_status_alloca(&status); + + if ((err = snd_pcm_status(priv->handler, status))<0) { + MSG_ERR("status error: %s", snd_strerror(err)); + return 0; + } + + if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) { + struct timeval now, diff, tstamp; + gettimeof... [truncated message content] |
From: <nic...@us...> - 2012-11-21 13:21:14
|
Revision: 422 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=422&view=rev Author: nickols_k Date: 2012-11-21 13:21:00 +0000 (Wed, 21 Nov 2012) Log Message: ----------- more c++ sources + constantization + redesign query_format + redesign vosub_vidix Modified Paths: -------------- mplayerxp/libao2/Makefile mplayerxp/libvo/Makefile mplayerxp/libvo/img_format.h mplayerxp/libvo/osd.cpp mplayerxp/libvo/sub.h mplayerxp/libvo/video_out.cpp mplayerxp/libvo/video_out.h mplayerxp/libvo/video_out_internal.h mplayerxp/libvo/vosub_vidix.h mplayerxp/libvo/x11_common.h mplayerxp/postproc/vf_vo.cpp mplayerxp/xmpcore/mp_image.h Added Paths: ----------- mplayerxp/libvo/aspect.cpp mplayerxp/libvo/jpeg_enc.cpp mplayerxp/libvo/osd_template.h mplayerxp/libvo/vo_dga.cpp mplayerxp/libvo/vo_fbdev.cpp mplayerxp/libvo/vo_null.cpp mplayerxp/libvo/vo_opengl.cpp mplayerxp/libvo/vo_sdl.cpp mplayerxp/libvo/vo_vesa.cpp mplayerxp/libvo/vo_x11.cpp mplayerxp/libvo/vo_xv.cpp mplayerxp/libvo/vosub_vidix.cpp mplayerxp/libvo/x11_common.cpp Removed Paths: ------------- mplayerxp/libvo/aspect.c mplayerxp/libvo/jpeg_enc.c mplayerxp/libvo/osd_template.c mplayerxp/libvo/vo_dga.c mplayerxp/libvo/vo_fbdev.c mplayerxp/libvo/vo_null.c mplayerxp/libvo/vo_opengl.c mplayerxp/libvo/vo_sdl.c mplayerxp/libvo/vo_vesa.c mplayerxp/libvo/vo_x11.c mplayerxp/libvo/vo_xv.c mplayerxp/libvo/vosub_vidix.c mplayerxp/libvo/x11_common.c Modified: mplayerxp/libao2/Makefile =================================================================== --- mplayerxp/libao2/Makefile 2012-11-21 12:54:43 UTC (rev 421) +++ mplayerxp/libao2/Makefile 2012-11-21 13:21:00 UTC (rev 422) @@ -60,7 +60,7 @@ dep: depend depend: - $(CC) -MM $(CFLAGS) $(SRCS) $(CXXSRCS) 1>.depend + $(CXX) -MM $(CXXFLAGS) $(SRCS) $(CXXSRCS) 1>.depend # # include dependency files if they exist Modified: mplayerxp/libvo/Makefile =================================================================== --- mplayerxp/libvo/Makefile 2012-11-21 12:54:43 UTC (rev 421) +++ mplayerxp/libvo/Makefile 2012-11-21 13:21:00 UTC (rev 422) @@ -3,30 +3,30 @@ LIBNAME = libvo.a CXXSRCS=video_out.cpp font_load.cpp img_format.cpp screenshot.cpp sub.cpp osd.cpp -SRCS=aspect.c vo_null.c +CXXSRCS+=aspect.cpp vo_null.cpp ifeq ($(HAVE_SDL),yes) -SRCS+=vo_sdl.c +CXXSRCS+=vo_sdl.cpp endif ifeq ($(HAVE_OPENGL),yes) -SRCS+=vo_opengl.c +CXXSRCS+=vo_opengl.cpp endif ifeq ($(HAVE_X11),yes) -SRCS+=vo_x11.c x11_common.c +CXXSRCS+=vo_x11.cpp x11_common.cpp endif ifeq ($(HAVE_XV),yes) -SRCS+=vo_xv.c +CXXSRCS+=vo_xv.cpp endif ifeq ($(HAVE_DGA),yes) -SRCS+=vo_dga.c +CXXSRCS+=vo_dga.cpp endif ifeq ($(HAVE_FBDEV),yes) -SRCS+=vo_fbdev.c +CXXSRCS+=vo_fbdev.cpp endif ifeq ($(HAVE_VESA),yes) -SRCS += vo_vesa.c +CXXSRCS += vo_vesa.cpp endif ifeq ($(CONFIG_VIDIX),yes) -SRCS += vosub_vidix.c +CXXSRCS += vosub_vidix.cpp endif CFLAGS = $(OPTFLAGS) -I. -I.. -DMPG12PLAY -Wall -W @@ -63,7 +63,7 @@ dep: depend depend: - $(CC) -MM $(CFLAGS) $(SRCS) $(CXXSRCS) 1>.depend + $(CXX) -MM $(CXXFLAGS) $(SRCS) $(CXXSRCS) 1>.depend # # include dependency files if they exist Deleted: mplayerxp/libvo/aspect.c =================================================================== --- mplayerxp/libvo/aspect.c 2012-11-21 12:54:43 UTC (rev 421) +++ mplayerxp/libvo/aspect.c 2012-11-21 13:21:00 UTC (rev 422) @@ -1,90 +0,0 @@ -/* Stuff for correct aspect scaling. */ -#include "aspect.h" - -//#define ASPECT_DEBUG - -#ifdef ASPECT_DEBUG -#include <stdio.h> -#endif -#include "vo_msg.h" - -float monitor_aspect=0; - -static struct { - uint32_t orgw; // real width - uint32_t orgh; // real height - uint32_t prew; // prescaled width - uint32_t preh; // prescaled height - uint32_t scrw; // horizontal resolution - uint32_t scrh; // vertical resolution -} aspdat; - -void __FASTCALL__ aspect_save_orig(uint32_t orgw, uint32_t orgh){ - aspdat.orgw = orgw; - aspdat.orgh = orgh; -} - -void __FASTCALL__ aspect_save_prescale(uint32_t prew, uint32_t preh){ - aspdat.prew = prew; - aspdat.preh = preh; -} - -void __FASTCALL__ aspect_save_screenres(uint32_t scrw, uint32_t scrh){ - aspdat.scrw = scrw; - aspdat.scrh = scrh; - monitor_aspect = mp_conf.monitor_pixel_aspect * scrw / scrh; -} - -/* aspect is called with the source resolution and the - * resolution, that the scaled image should fit into - */ - -void __FASTCALL__ aspect(uint32_t *srcw, uint32_t *srch, int zoom){ - uint32_t tmpw; - -#ifdef ASPECT_DEBUG - MSG_DBG2("aspect(0) fitin: %dx%d zoom: %d \n",aspdat.scrw,aspdat.scrh,zoom); - MSG_DBG2("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh); -#endif - if(zoom){ - if(aspdat.prew >= aspdat.preh) - { - /* Landscape mode */ - *srcw = aspdat.scrw; - *srch = (uint32_t)(((float)aspdat.scrw / (float)aspdat.prew * (float)aspdat.preh) - * ((float)aspdat.scrh / ((float)aspdat.scrw / monitor_aspect))); - } - else - { - /* Portrait mode */ - *srch = aspdat.scrh; - *srcw = (uint32_t)(((float)aspdat.scrh / (float)aspdat.preh * (float)aspdat.prew) - * ((float)aspdat.scrw / ((float)aspdat.scrh * monitor_aspect))); - } - }else{ - *srcw = aspdat.prew; - *srch = (uint32_t)((float)aspdat.preh - * ((float)aspdat.scrh / ((float)aspdat.scrw / monitor_aspect))); - } - (*srch)+= (*srch)%2; // round -#ifdef ASPECT_DEBUG - MSG_DBG2("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh); -#endif - if(*srch>aspdat.scrh || *srch<aspdat.orgh){ - if(zoom) - tmpw = (uint32_t)(((float)aspdat.scrh / (float)aspdat.preh * (float)aspdat.prew) - * ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect)))); - else - tmpw = (uint32_t)((float)aspdat.prew - * ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect)))); - if(tmpw<=aspdat.scrw && tmpw>=aspdat.orgw){ - *srch = zoom?aspdat.scrh:aspdat.preh; - *srcw = tmpw; - *srcw+= *srcw%2; // round - } - } -#ifdef ASPECT_DEBUG - MSG_DBG2("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh); -#endif -} - Copied: mplayerxp/libvo/aspect.cpp (from rev 417, mplayerxp/libvo/aspect.c) =================================================================== --- mplayerxp/libvo/aspect.cpp (rev 0) +++ mplayerxp/libvo/aspect.cpp 2012-11-21 13:21:00 UTC (rev 422) @@ -0,0 +1,90 @@ +/* Stuff for correct aspect scaling. */ +#include "aspect.h" + +//#define ASPECT_DEBUG + +#ifdef ASPECT_DEBUG +#include <stdio.h> +#endif +#include "vo_msg.h" + +float monitor_aspect=0; + +static struct { + uint32_t orgw; // real width + uint32_t orgh; // real height + uint32_t prew; // prescaled width + uint32_t preh; // prescaled height + uint32_t scrw; // horizontal resolution + uint32_t scrh; // vertical resolution +} aspdat; + +void __FASTCALL__ aspect_save_orig(uint32_t orgw, uint32_t orgh){ + aspdat.orgw = orgw; + aspdat.orgh = orgh; +} + +void __FASTCALL__ aspect_save_prescale(uint32_t prew, uint32_t preh){ + aspdat.prew = prew; + aspdat.preh = preh; +} + +void __FASTCALL__ aspect_save_screenres(uint32_t scrw, uint32_t scrh){ + aspdat.scrw = scrw; + aspdat.scrh = scrh; + monitor_aspect = mp_conf.monitor_pixel_aspect * scrw / scrh; +} + +/* aspect is called with the source resolution and the + * resolution, that the scaled image should fit into + */ + +void __FASTCALL__ aspect(uint32_t *srcw, uint32_t *srch, int zoom){ + uint32_t tmpw; + +#ifdef ASPECT_DEBUG + MSG_DBG2("aspect(0) fitin: %dx%d zoom: %d \n",aspdat.scrw,aspdat.scrh,zoom); + MSG_DBG2("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh); +#endif + if(zoom){ + if(aspdat.prew >= aspdat.preh) + { + /* Landscape mode */ + *srcw = aspdat.scrw; + *srch = (uint32_t)(((float)aspdat.scrw / (float)aspdat.prew * (float)aspdat.preh) + * ((float)aspdat.scrh / ((float)aspdat.scrw / monitor_aspect))); + } + else + { + /* Portrait mode */ + *srch = aspdat.scrh; + *srcw = (uint32_t)(((float)aspdat.scrh / (float)aspdat.preh * (float)aspdat.prew) + * ((float)aspdat.scrw / ((float)aspdat.scrh * monitor_aspect))); + } + }else{ + *srcw = aspdat.prew; + *srch = (uint32_t)((float)aspdat.preh + * ((float)aspdat.scrh / ((float)aspdat.scrw / monitor_aspect))); + } + (*srch)+= (*srch)%2; // round +#ifdef ASPECT_DEBUG + MSG_DBG2("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh); +#endif + if(*srch>aspdat.scrh || *srch<aspdat.orgh){ + if(zoom) + tmpw = (uint32_t)(((float)aspdat.scrh / (float)aspdat.preh * (float)aspdat.prew) + * ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect)))); + else + tmpw = (uint32_t)((float)aspdat.prew + * ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect)))); + if(tmpw<=aspdat.scrw && tmpw>=aspdat.orgw){ + *srch = zoom?aspdat.scrh:aspdat.preh; + *srcw = tmpw; + *srcw+= *srcw%2; // round + } + } +#ifdef ASPECT_DEBUG + MSG_DBG2("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh); +#endif +} + Modified: mplayerxp/libvo/img_format.h =================================================================== --- mplayerxp/libvo/img_format.h 2012-11-21 12:54:43 UTC (rev 421) +++ mplayerxp/libvo/img_format.h 2012-11-21 13:21:00 UTC (rev 422) @@ -4,12 +4,8 @@ #include <inttypes.h> #include <stdint.h> #include "mp_config.h" -#include "libavutil/pixfmt.h" +#include "mp_conf_lavc.h" -#ifdef __cplusplus -extern "C" { -#endif - /* RGB/BGR Formats */ enum { IMGFMT_RGB_MASK =0xFFFFFF00, @@ -161,8 +157,5 @@ enum PixelFormat pixfmt_from_fourcc(uint32_t fourcc); uint32_t fourcc_from_pixfmt(enum PixelFormat pixfmt); extern unsigned rgbfmt_depth(unsigned fmt); -#ifdef __cplusplus -} -#endif #endif Deleted: mplayerxp/libvo/jpeg_enc.c =================================================================== --- mplayerxp/libvo/jpeg_enc.c 2012-11-21 12:54:43 UTC (rev 421) +++ mplayerxp/libvo/jpeg_enc.c 2012-11-21 13:21:00 UTC (rev 422) @@ -1,451 +0,0 @@ -/* Straightforward (to be) optimized JPEG encoder for the YUV422 format - * based on mjpeg code from ffmpeg. - * - * Copyright (c) 2002, Rik Snel - * Parts from ffmpeg Copyright (c) 2000, 2001 Gerard Lantau - * - * This program is mp_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. - * - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * For an excellent introduction to the JPEG format, see: - * http://www.ece.purdue.edu/~bouman/grad-labs/lab8/pdf/lab.pdf - */ - - - -#include <sys/types.h> -#include <stdio.h> -#include <stdlib.h> -#include "mp_config.h" -#ifdef USE_FASTMEMCPY -#include "fastmemcpy.h" -#endif -/* We need this #define because we need ../libavcodec/common.h to #define - * be2me_32, otherwise the linker will complain that it doesn't exist */ -#include "mp_conf_lavc.h" - -#include "jpeg_enc.h" -#include "vo_msg.h" - -/* zr_mjpeg_encode_mb needs access to these tables for the black & white - * option */ -typedef struct MJpegContext { - UINT8 huff_size_dc_luminance[12]; - UINT16 huff_code_dc_luminance[12]; - UINT8 huff_size_dc_chrominance[12]; - UINT16 huff_code_dc_chrominance[12]; - - UINT8 huff_size_ac_luminance[256]; - UINT16 huff_code_ac_luminance[256]; - UINT8 huff_size_ac_chrominance[256]; - UINT16 huff_code_ac_chrominance[256]; -} MJpegContext; - - -/* A very important function pointer */ -extern int (*dct_quantize)(MpegEncContext *s, - DCTELEM *block, int n, int qscale); - - -/* Begin excessive code duplication ************************************/ -/* Code coming from mpegvideo.c and mjpeg.c in ../libavcodec ***********/ - -static const unsigned short aanscales[64] = { - /* precomputed values scaled up by 14 bits */ - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, - 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, - 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, - 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, - 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 -}; - -static void convert_matrix(int *qmat, UINT16 *qmat16, const UINT16 *quant_matrix, int qscale) -{ - int i; - - if (av_fdct == jpeg_fdct_ifast) { - for(i=0;i<64;i++) { - /* 16 <= qscale * quant_matrix[i] <= 7905 */ - /* 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026 */ - /* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */ - /* 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */ - - qmat[block_permute_op(i)] = (int)((UINT64_C(1) << (QMAT_SHIFT + 11)) / - (aanscales[i] * qscale * quant_matrix[block_permute_op(i)])); - } - } else { - for(i=0;i<64;i++) { - /* We can safely suppose that 16 <= quant_matrix[i] <= 255 - So 16 <= qscale * quant_matrix[i] <= 7905 - so (1<<19) / 16 >= (1<<19) / (qscale * quant_matrix[i]) >= (1<<19) / 7905 - so 32768 >= (1<<19) / (qscale * quant_matrix[i]) >= 67 - */ - qmat[i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[i]); - qmat16[i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[block_permute_op(i)]); - } - } -} - -static inline void encode_dc(MpegEncContext *s, int val, - UINT8 *huff_size, UINT16 *huff_code) -{ - int mant, nbits; - - if (val == 0) { - jput_bits(&s->pb, huff_size[0], huff_code[0]); - } else { - mant = val; - if (val < 0) { - val = -val; - mant--; - } - - /* compute the log (XXX: optimize) */ - nbits = 0; - while (val != 0) { - val = val >> 1; - nbits++; - } - - jput_bits(&s->pb, huff_size[nbits], huff_code[nbits]); - - jput_bits(&s->pb, nbits, mant & ((1 << nbits) - 1)); - } -} - -static void encode_block(MpegEncContext *s, DCTELEM *block, int n) -{ - int mant, nbits, code, i, j; - int component, dc, run, last_index, val; - MJpegContext *m = s->mjpeg_ctx; - UINT8 *huff_size_ac; - UINT16 *huff_code_ac; - - /* DC coef */ - component = (n <= 3 ? 0 : n - 4 + 1); - dc = block[0]; /* overflow is impossible */ - val = dc - s->last_dc[component]; - if (n < 4) { - encode_dc(s, val, m->huff_size_dc_luminance, m->huff_code_dc_luminance); - huff_size_ac = m->huff_size_ac_luminance; - huff_code_ac = m->huff_code_ac_luminance; - } else { - encode_dc(s, val, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); - huff_size_ac = m->huff_size_ac_chrominance; - huff_code_ac = m->huff_code_ac_chrominance; - } - s->last_dc[component] = dc; - - /* AC coefs */ - - run = 0; - last_index = s->block_last_index[n]; - for(i=1;i<=last_index;i++) { - j = zigzag_direct[i]; - val = block[j]; - if (val == 0) { - run++; - } else { - while (run >= 16) { - jput_bits(&s->pb, huff_size_ac[0xf0], huff_code_ac[0xf0]); - run -= 16; - } - mant = val; - if (val < 0) { - val = -val; - mant--; - } - - /* compute the log (XXX: optimize) */ - nbits = 0; - while (val != 0) { - val = val >> 1; - nbits++; - } - code = (run << 4) | nbits; - - jput_bits(&s->pb, huff_size_ac[code], huff_code_ac[code]); - - jput_bits(&s->pb, nbits, mant & ((1 << nbits) - 1)); - run = 0; - } - } - - /* output EOB only if not already 64 values */ - if (last_index < 63 || run != 0) - jput_bits(&s->pb, huff_size_ac[0], huff_code_ac[0]); -} - -/* End excessive code duplication **************************************/ - -/* this function is a reproduction of the one in mjpeg, it includes two - * changes, it allows for black&white encoding (it skips the U and V - * macroblocks and it outputs the huffman code for 'no change' (dc) and - * 'all zero' (ac)) and it takes 4 macroblocks (422) instead of 6 (420) */ -static void zr_mjpeg_encode_mb(jpeg_enc_t *j) { - - MJpegContext *m = j->s->mjpeg_ctx; - - encode_block(j->s, j->s->block[0], 0); - encode_block(j->s, j->s->block[1], 1); - if (j->bw) { - /* U */ - jput_bits(&j->s->pb, m->huff_size_dc_chrominance[0], - m->huff_code_dc_chrominance[0]); - jput_bits(&j->s->pb, m->huff_size_ac_chrominance[0], - m->huff_code_ac_chrominance[0]); - /* V */ - jput_bits(&j->s->pb, m->huff_size_dc_chrominance[0], - m->huff_code_dc_chrominance[0]); - jput_bits(&j->s->pb, m->huff_size_ac_chrominance[0], - m->huff_code_ac_chrominance[0]); - } else { - /* we trick encode_block here so that it uses - * chrominance huffman tables instead of luminance ones - * (see the effect of second argument of encode_block) */ - encode_block(j->s, j->s->block[2], 4); - encode_block(j->s, j->s->block[3], 5); - } -} - -/* this function can take all kinds of YUV colorspaces - * YV12, YVYU, UYVY. The necesary parameters must be set up by the caller - * y_ps means "y pixel size", y_rs means "y row size". - * For YUYV, for example, is u_buf = y_buf + 1, v_buf = y_buf + 3, - * y_ps = 2, u_ps = 4, v_ps = 4, y_rs = u_rs = v_rs. - * - * The actual buffers must be passed with mjpeg_encode_frame, this is - * to make it possible to call encode on the buffer provided by the - * codec in draw_frame. - * - * The data is straightened out at the moment it is put in DCT - * blocks, there are therefore no spurious memcopies involved */ -/* Notice that w must be a multiple of 16 and h must be a multiple of 8 */ -/* We produce YUV422 jpegs, the colors must be subsampled horizontally, - * if the colors are also subsampled vertically, then this function - * performs cheap upsampling (better solution will be: a DCT that is - * optimized in the case that every two rows are the same) */ -/* cu = 0 means 'No cheap upsampling' - * cu = 1 means 'perform cheap upsampling' */ -/* The encoder doesn't know anything about interlacing, the halve height - * needs to be passed and the double rowstride. Which field gets encoded - * is decided by what buffers are passed to mjpeg_encode_frame */ -jpeg_enc_t *jpeg_enc_init(int w, int h, int y_psize, int y_rsize, - int u_psize, int u_rsize, int v_psize, int v_rsize, - int cu, int q, int b) { - jpeg_enc_t *j; - int i = 0; - MSGL_V( "JPEnc init: %dx%d %d %d %d %d %d %d\n", - w, h, y_psize, y_rsize, u_psize, - u_rsize, v_psize, v_rsize); - - j = mp_malloc(sizeof(jpeg_enc_t)); - if (j == NULL) return NULL; - - j->s = mp_malloc(sizeof(MpegEncContext)); - if (j->s == NULL) { - mp_free(j); - return NULL; - } - - /* info on how to access the pixels */ - j->y_ps = y_psize; - j->u_ps = u_psize; - j->v_ps = v_psize; - j->y_rs = y_rsize; - j->u_rs = u_rsize; - j->v_rs = v_rsize; - - j->s->width = w; - j->s->height = h; - j->s->qscale = q; - - j->s->out_format = FMT_MJPEG; - j->s->intra_only = 1; - j->s->encoding = 1; - j->s->pict_type = I_TYPE; - j->s->y_dc_scale = 8; - j->s->c_dc_scale = 8; - - j->s->mjpeg_write_tables = 1; - j->s->mjpeg_vsample[0] = 1; - j->s->mjpeg_vsample[1] = 1; - j->s->mjpeg_vsample[2] = 1; - j->s->mjpeg_hsample[0] = 2; - j->s->mjpeg_hsample[1] = 1; - j->s->mjpeg_hsample[2] = 1; - - j->cheap_upsample = cu; - j->bw = b; - - /* if libavcodec is used by the decoder then we must not - * initialize again, but if it is not initialized then we must - * initialize it here. There must be a better way to find out - * if it is initialized */ - if (av_fdct != jpeg_fdct_ifast -#ifdef CAN_COMPILE_MMX - && av_fdct != fdct_mmx -#endif - ) { - /* we need to initialize libavcodec */ - avcodec_init(); - } - - if (mjpeg_init(j->s) < 0) { - mp_free(j->s); - mp_free(j); - return NULL; - } - - if (MPV_common_init(j->s) < 0) { - mp_free(j->s); - mp_free(j); - return NULL; - } - - /* correct the value for sc->mb_height */ - j->s->mb_height = j->s->height/8; - j->s->mb_intra = 1; - - j->s->intra_matrix[0] = default_intra_matrix[0]; - for (i = 1; i < 64; i++) - j->s->intra_matrix[i] = - (default_intra_matrix[i]*j->s->qscale) >> 3; - convert_matrix(j->s->q_intra_matrix, j->s->q_intra_matrix16, - j->s->intra_matrix, 8); - return j; -} - -int jpeg_enc_frame(jpeg_enc_t *j, unsigned char *y_data, - unsigned char *u_data, unsigned char *v_data, char *bufr) { - int i, k, mb_x, mb_y; - short int *dest; - unsigned char *source; - /* initialize the buffer */ - - init_put_bits(&j->s->pb, bufr, 1024*256, NULL, NULL); - - mjpeg_picture_header(j->s); - - j->s->last_dc[0] = 128; - j->s->last_dc[1] = 128; - j->s->last_dc[2] = 128; - - for (mb_y = 0; mb_y < j->s->mb_height; mb_y++) { - for (mb_x = 0; mb_x < j->s->mb_width; mb_x++) { - /* conversion 8 to 16 bit and filling of blocks - * must be mmx optimized */ - /* fill 2 Y macroblocks and one U and one V */ - source = mb_y * 8 * j->y_rs + - 16 * j->y_ps * mb_x + y_data; - dest = j->s->block[0]; - for (i = 0; i < 8; i++) { - for (k = 0; k < 8; k++) { - dest[k] = source[k*j->y_ps]; - } - dest += 8; - source += j->y_rs; - } - source = mb_y * 8 * j->y_rs + - (16*mb_x + 8)*j->y_ps + y_data; - dest = j->s->block[1]; - for (i = 0; i < 8; i++) { - for (k = 0; k < 8; k++) { - dest[k] = source[k*j->y_ps]; - } - dest += 8; - source += j->y_rs; - } - if (!j->bw && j->cheap_upsample) { - source = mb_y*4*j->u_rs + - 8*mb_x*j->u_ps + u_data; - dest = j->s->block[2]; - for (i = 0; i < 4; i++) { - for (k = 0; k < 8; k++) { - dest[k] = source[k*j->u_ps]; - dest[k+8] = source[k*j->u_ps]; - } - dest += 16; - source += j->u_rs; - } - source = mb_y*4*j->v_rs + - 8*mb_x*j->v_ps + v_data; - dest = j->s->block[3]; - for (i = 0; i < 4; i++) { - for (k = 0; k < 8; k++) { - dest[k] = source[k*j->v_ps]; - dest[k+8] = source[k*j->v_ps]; - } - dest += 16; - source += j->u_rs; - } - } else if (!j->bw && !j->cheap_upsample) { - source = mb_y*8*j->u_rs + - 8*mb_x*j->u_ps + u_data; - dest = j->s->block[2]; - for (i = 0; i < 8; i++) { - for (k = 0; k < 8; k++) - dest[k] = source[k*j->u_ps]; - dest += 8; - source += j->u_rs; - } - source = mb_y*8*j->v_rs + - 8*mb_x*j->v_ps + v_data; - dest = j->s->block[3]; - for (i = 0; i < 8; i++) { - for (k = 0; k < 8; k++) - dest[k] = source[k*j->v_ps]; - dest += 8; - source += j->u_rs; - } - } - emms_c(); /* is this really needed? */ - - j->s->block_last_index[0] = - dct_quantize(j->s, j->s->block[0], - 0, j->s->qscale); - j->s->block_last_index[1] = - dct_quantize(j->s, j->s->block[1], - 1, j->s->qscale); - - if (!j->bw) { - j->s->block_last_index[4] = - dct_quantize(j->s, j->s->block[2], - 4, j->s->qscale); - j->s->block_last_index[5] = - dct_quantize(j->s, j->s->block[3], - 5, j->s->qscale); - } - zr_mjpeg_encode_mb(j); - } - } - emms_c(); - mjpeg_picture_trailer(j->s); - flush_put_bits(&j->s->pb); - - if (j->s->mjpeg_write_tables == 1) - j->s->mjpeg_write_tables = 0; - - return pbBufPtr(&(j->s->pb)) - j->s->pb.buf; -} - -void jpeg_enc_uninit(jpeg_enc_t *j) { - mjpeg_close(j->s); - mp_free(j->s); - mp_free(j); -} - Copied: mplayerxp/libvo/jpeg_enc.cpp (from rev 417, mplayerxp/libvo/jpeg_enc.c) =================================================================== --- mplayerxp/libvo/jpeg_enc.cpp (rev 0) +++ mplayerxp/libvo/jpeg_enc.cpp 2012-11-21 13:21:00 UTC (rev 422) @@ -0,0 +1,451 @@ +/* Straightforward (to be) optimized JPEG encoder for the YUV422 format + * based on mjpeg code from ffmpeg. + * + * Copyright (c) 2002, Rik Snel + * Parts from ffmpeg Copyright (c) 2000, 2001 Gerard Lantau + * + * This program is mp_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. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * For an excellent introduction to the JPEG format, see: + * http://www.ece.purdue.edu/~bouman/grad-labs/lab8/pdf/lab.pdf + */ + + + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include "mp_config.h" +#ifdef USE_FASTMEMCPY +#include "fastmemcpy.h" +#endif +/* We need this #define because we need ../libavcodec/common.h to #define + * be2me_32, otherwise the linker will complain that it doesn't exist */ +#include "mp_conf_lavc.h" + +#include "jpeg_enc.h" +#include "vo_msg.h" + +/* zr_mjpeg_encode_mb needs access to these tables for the black & white + * option */ +typedef struct MJpegContext { + UINT8 huff_size_dc_luminance[12]; + UINT16 huff_code_dc_luminance[12]; + UINT8 huff_size_dc_chrominance[12]; + UINT16 huff_code_dc_chrominance[12]; + + UINT8 huff_size_ac_luminance[256]; + UINT16 huff_code_ac_luminance[256]; + UINT8 huff_size_ac_chrominance[256]; + UINT16 huff_code_ac_chrominance[256]; +} MJpegContext; + + +/* A very important function pointer */ +extern int (*dct_quantize)(MpegEncContext *s, + DCTELEM *block, int n, int qscale); + + +/* Begin excessive code duplication ************************************/ +/* Code coming from mpegvideo.c and mjpeg.c in ../libavcodec ***********/ + +static const unsigned short aanscales[64] = { + /* precomputed values scaled up by 14 bits */ + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, + 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, + 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, + 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, + 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 +}; + +static void convert_matrix(int *qmat, UINT16 *qmat16, const UINT16 *quant_matrix, int qscale) +{ + int i; + + if (av_fdct == jpeg_fdct_ifast) { + for(i=0;i<64;i++) { + /* 16 <= qscale * quant_matrix[i] <= 7905 */ + /* 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026 */ + /* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */ + /* 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */ + + qmat[block_permute_op(i)] = (int)((UINT64_C(1) << (QMAT_SHIFT + 11)) / + (aanscales[i] * qscale * quant_matrix[block_permute_op(i)])); + } + } else { + for(i=0;i<64;i++) { + /* We can safely suppose that 16 <= quant_matrix[i] <= 255 + So 16 <= qscale * quant_matrix[i] <= 7905 + so (1<<19) / 16 >= (1<<19) / (qscale * quant_matrix[i]) >= (1<<19) / 7905 + so 32768 >= (1<<19) / (qscale * quant_matrix[i]) >= 67 + */ + qmat[i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[i]); + qmat16[i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[block_permute_op(i)]); + } + } +} + +static inline void encode_dc(MpegEncContext *s, int val, + UINT8 *huff_size, UINT16 *huff_code) +{ + int mant, nbits; + + if (val == 0) { + jput_bits(&s->pb, huff_size[0], huff_code[0]); + } else { + mant = val; + if (val < 0) { + val = -val; + mant--; + } + + /* compute the log (XXX: optimize) */ + nbits = 0; + while (val != 0) { + val = val >> 1; + nbits++; + } + + jput_bits(&s->pb, huff_size[nbits], huff_code[nbits]); + + jput_bits(&s->pb, nbits, mant & ((1 << nbits) - 1)); + } +} + +static void encode_block(MpegEncContext *s, DCTELEM *block, int n) +{ + int mant, nbits, code, i, j; + int component, dc, run, last_index, val; + MJpegContext *m = s->mjpeg_ctx; + UINT8 *huff_size_ac; + UINT16 *huff_code_ac; + + /* DC coef */ + component = (n <= 3 ? 0 : n - 4 + 1); + dc = block[0]; /* overflow is impossible */ + val = dc - s->last_dc[component]; + if (n < 4) { + encode_dc(s, val, m->huff_size_dc_luminance, m->huff_code_dc_luminance); + huff_size_ac = m->huff_size_ac_luminance; + huff_code_ac = m->huff_code_ac_luminance; + } else { + encode_dc(s, val, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); + huff_size_ac = m->huff_size_ac_chrominance; + huff_code_ac = m->huff_code_ac_chrominance; + } + s->last_dc[component] = dc; + + /* AC coefs */ + + run = 0; + last_index = s->block_last_index[n]; + for(i=1;i<=last_index;i++) { + j = zigzag_direct[i]; + val = block[j]; + if (val == 0) { + run++; + } else { + while (run >= 16) { + jput_bits(&s->pb, huff_size_ac[0xf0], huff_code_ac[0xf0]); + run -= 16; + } + mant = val; + if (val < 0) { + val = -val; + mant--; + } + + /* compute the log (XXX: optimize) */ + nbits = 0; + while (val != 0) { + val = val >> 1; + nbits++; + } + code = (run << 4) | nbits; + + jput_bits(&s->pb, huff_size_ac[code], huff_code_ac[code]); + + jput_bits(&s->pb, nbits, mant & ((1 << nbits) - 1)); + run = 0; + } + } + + /* output EOB only if not already 64 values */ + if (last_index < 63 || run != 0) + jput_bits(&s->pb, huff_size_ac[0], huff_code_ac[0]); +} + +/* End excessive code duplication **************************************/ + +/* this function is a reproduction of the one in mjpeg, it includes two + * changes, it allows for black&white encoding (it skips the U and V + * macroblocks and it outputs the huffman code for 'no change' (dc) and + * 'all zero' (ac)) and it takes 4 macroblocks (422) instead of 6 (420) */ +static void zr_mjpeg_encode_mb(jpeg_enc_t *j) { + + MJpegContext *m = j->s->mjpeg_ctx; + + encode_block(j->s, j->s->block[0], 0); + encode_block(j->s, j->s->block[1], 1); + if (j->bw) { + /* U */ + jput_bits(&j->s->pb, m->huff_size_dc_chrominance[0], + m->huff_code_dc_chrominance[0]); + jput_bits(&j->s->pb, m->huff_size_ac_chrominance[0], + m->huff_code_ac_chrominance[0]); + /* V */ + jput_bits(&j->s->pb, m->huff_size_dc_chrominance[0], + m->huff_code_dc_chrominance[0]); + jput_bits(&j->s->pb, m->huff_size_ac_chrominance[0], + m->huff_code_ac_chrominance[0]); + } else { + /* we trick encode_block here so that it uses + * chrominance huffman tables instead of luminance ones + * (see the effect of second argument of encode_block) */ + encode_block(j->s, j->s->block[2], 4); + encode_block(j->s, j->s->block[3], 5); + } +} + +/* this function can take all kinds of YUV colorspaces + * YV12, YVYU, UYVY. The necesary parameters must be set up by the caller + * y_ps means "y pixel size", y_rs means "y row size". + * For YUYV, for example, is u_buf = y_buf + 1, v_buf = y_buf + 3, + * y_ps = 2, u_ps = 4, v_ps = 4, y_rs = u_rs = v_rs. + * + * The actual buffers must be passed with mjpeg_encode_frame, this is + * to make it possible to call encode on the buffer provided by the + * codec in draw_frame. + * + * The data is straightened out at the moment it is put in DCT + * blocks, there are therefore no spurious memcopies involved */ +/* Notice that w must be a multiple of 16 and h must be a multiple of 8 */ +/* We produce YUV422 jpegs, the colors must be subsampled horizontally, + * if the colors are also subsampled vertically, then this function + * performs cheap upsampling (better solution will be: a DCT that is + * optimized in the case that every two rows are the same) */ +/* cu = 0 means 'No cheap upsampling' + * cu = 1 means 'perform cheap upsampling' */ +/* The encoder doesn't know anything about interlacing, the halve height + * needs to be passed and the double rowstride. Which field gets encoded + * is decided by what buffers are passed to mjpeg_encode_frame */ +jpeg_enc_t *jpeg_enc_init(int w, int h, int y_psize, int y_rsize, + int u_psize, int u_rsize, int v_psize, int v_rsize, + int cu, int q, int b) { + jpeg_enc_t *j; + int i = 0; + MSGL_V( "JPEnc init: %dx%d %d %d %d %d %d %d\n", + w, h, y_psize, y_rsize, u_psize, + u_rsize, v_psize, v_rsize); + + j = mp_malloc(sizeof(jpeg_enc_t)); + if (j == NULL) return NULL; + + j->s = mp_malloc(sizeof(MpegEncContext)); + if (j->s == NULL) { + mp_free(j); + return NULL; + } + + /* info on how to access the pixels */ + j->y_ps = y_psize; + j->u_ps = u_psize; + j->v_ps = v_psize; + j->y_rs = y_rsize; + j->u_rs = u_rsize; + j->v_rs = v_rsize; + + j->s->width = w; + j->s->height = h; + j->s->qscale = q; + + j->s->out_format = FMT_MJPEG; + j->s->intra_only = 1; + j->s->encoding = 1; + j->s->pict_type = I_TYPE; + j->s->y_dc_scale = 8; + j->s->c_dc_scale = 8; + + j->s->mjpeg_write_tables = 1; + j->s->mjpeg_vsample[0] = 1; + j->s->mjpeg_vsample[1] = 1; + j->s->mjpeg_vsample[2] = 1; + j->s->mjpeg_hsample[0] = 2; + j->s->mjpeg_hsample[1] = 1; + j->s->mjpeg_hsample[2] = 1; + + j->cheap_upsample = cu; + j->bw = b; + + /* if libavcodec is used by the decoder then we must not + * initialize again, but if it is not initialized then we must + * initialize it here. There must be a better way to find out + * if it is initialized */ + if (av_fdct != jpeg_fdct_ifast +#ifdef CAN_COMPILE_MMX + && av_fdct != fdct_mmx +#endif + ) { + /* we need to initialize libavcodec */ + avcodec_init(); + } + + if (mjpeg_init(j->s) < 0) { + mp_free(j->s); + mp_free(j); + return NULL; + } + + if (MPV_common_init(j->s) < 0) { + mp_free(j->s); + mp_free(j); + return NULL; + } + + /* correct the value for sc->mb_height */ + j->s->mb_height = j->s->height/8; + j->s->mb_intra = 1; + + j->s->intra_matrix[0] = default_intra_matrix[0]; + for (i = 1; i < 64; i++) + j->s->intra_matrix[i] = + (default_intra_matrix[i]*j->s->qscale) >> 3; + convert_matrix(j->s->q_intra_matrix, j->s->q_intra_matrix16, + j->s->intra_matrix, 8); + return j; +} + +int jpeg_enc_frame(jpeg_enc_t *j, unsigned char *y_data, + unsigned char *u_data, unsigned char *v_data, char *bufr) { + int i, k, mb_x, mb_y; + short int *dest; + unsigned char *source; + /* initialize the buffer */ + + init_put_bits(&j->s->pb, bufr, 1024*256, NULL, NULL); + + mjpeg_picture_header(j->s); + + j->s->last_dc[0] = 128; + j->s->last_dc[1] = 128; + j->s->last_dc[2] = 128; + + for (mb_y = 0; mb_y < j->s->mb_height; mb_y++) { + for (mb_x = 0; mb_x < j->s->mb_width; mb_x++) { + /* conversion 8 to 16 bit and filling of blocks + * must be mmx optimized */ + /* fill 2 Y macroblocks and one U and one V */ + source = mb_y * 8 * j->y_rs + + 16 * j->y_ps * mb_x + y_data; + dest = j->s->block[0]; + for (i = 0; i < 8; i++) { + for (k = 0; k < 8; k++) { + dest[k] = source[k*j->y_ps]; + } + dest += 8; + source += j->y_rs; + } + source = mb_y * 8 * j->y_rs + + (16*mb_x + 8)*j->y_ps + y_data; + dest = j->s->block[1]; + for (i = 0; i < 8; i++) { + for (k = 0; k < 8; k++) { + dest[k] = source[k*j->y_ps]; + } + dest += 8; + source += j->y_rs; + } + if (!j->bw && j->cheap_upsample) { + source = mb_y*4*j->u_rs + + 8*mb_x*j->u_ps + u_data; + dest = j->s->block[2]; + for (i = 0; i < 4; i++) { + for (k = 0; k < 8; k++) { + dest[k] = source[k*j->u_ps]; + dest[k+8] = source[k*j->u_ps]; + } + dest += 16; + source += j->u_rs; + } + source = mb_y*4*j->v_rs + + 8*mb_x*j->v_ps + v_data; + dest = j->s->block[3]; + for (i = 0; i < 4; i++) { + for (k = 0; k < 8; k++) { + dest[k] = source[k*j->v_ps]; + dest[k+8] = source[k*j->v_ps]; + } + dest += 16; + source += j->u_rs; + } + } else if (!j->bw && !j->cheap_upsample) { + source = mb_y*8*j->u_rs + + 8*mb_x*j->u_ps + u_data; + dest = j->s->block[2]; + for (i = 0; i < 8; i++) { + for (k = 0; k < 8; k++) + dest[k] = source[k*j->u_ps]; + dest += 8; + source += j->u_rs; + } + source = mb_y*8*j->v_rs + + 8*mb_x*j->v_ps + v_data; + dest = j->s->block[3]; + for (i = 0; i < 8; i++) { + for (k = 0; k < 8; k++) + dest[k] = source[k*j->v_ps]; + dest += 8; + source += j->u_rs; + } + } + emms_c(); /* is this really needed? */ + + j->s->block_last_index[0] = + dct_quantize(j->s, j->s->block[0], + 0, j->s->qscale); + j->s->block_last_index[1] = + dct_quantize(j->s, j->s->block[1], + 1, j->s->qscale); + + if (!j->bw) { + j->s->block_last_index[4] = + dct_quantize(j->s, j->s->block[2], + 4, j->s->qscale); + j->s->block_last_index[5] = + dct_quantize(j->s, j->s->block[3], + 5, j->s->qscale); + } + zr_mjpeg_encode_mb(j); + } + } + emms_c(); + mjpeg_picture_trailer(j->s); + flush_put_bits(&j->s->pb); + + if (j->s->mjpeg_write_tables == 1) + j->s->mjpeg_write_tables = 0; + + return pbBufPtr(&(j->s->pb)) - j->s->pb.buf; +} + +void jpeg_enc_uninit(jpeg_enc_t *j) { + mjpeg_close(j->s); + mp_free(j->s); + mp_free(j); +} + Modified: mplayerxp/libvo/osd.cpp =================================================================== --- mplayerxp/libvo/osd.cpp 2012-11-21 12:54:43 UTC (rev 421) +++ mplayerxp/libvo/osd.cpp 2012-11-21 13:21:00 UTC (rev 422) @@ -23,7 +23,7 @@ static const unsigned long long mask24hl __attribute__((used)) __attribute__((aligned(8))) = 0x0000FFFFFFFFFFFFULL; #endif -#define PVECTOR_ACCEL_H "osd_template.c" +#define PVECTOR_ACCEL_H "osd_template.h" #include "pvector/pvector_inc.h" #ifdef FAST_OSD_TABLE Deleted: mplayerxp/libvo/osd_template.c =================================================================== --- mplayerxp/libvo/osd_template.c 2012-11-21 12:54:43 UTC (rev 421) +++ mplayerxp/libvo/osd_template.c 2012-11-21 13:21:00 UTC (rev 422) @@ -1,318 +0,0 @@ -// Generic alpha renderers for all YUV modes and RGB depths. -// Optimized by Nick and Michael -// Code from Michael Niedermayer (mic...@gm...) is under GPL -#include "pvector/pvector.h" - -#ifdef HAVE_INT_PVECTOR -static __inline __m64 __attribute__((__gnu_inline__, __always_inline__)) -PVECTOR_RENAME(_m_load)(const any_t*__P) -{ - return *(const __m64 *)__P; -} -#undef _m_load -#define _m_load PVECTOR_RENAME(_m_load) - -static __inline __m64 __attribute__((__gnu_inline__, __always_inline__)) -PVECTOR_RENAME(_m_load_half)(const any_t*__P) -{ - return _mm_cvtsi32_si64 (*(const int *)__P); -} -#undef _m_load_half -#define _m_load_half PVECTOR_RENAME(_m_load_half) - -static __inline void __attribute__((__gnu_inline__, __always_inline__)) -PVECTOR_RENAME(_m_store)(any_t*__P, __m64 src) -{ - *(__m64 *)__P = src; -} -#undef _m_store -#define _m_store PVECTOR_RENAME(_m_store) - -static __inline void __attribute__((__gnu_inline__, __always_inline__)) -PVECTOR_RENAME(_m_store_half)(any_t*__P, __m64 src) -{ - *(int *)__P = _mm_cvtsi64_si32(src); -} -#undef _m_store_half -#define _m_store_half PVECTOR_RENAME(_m_store_half) - -static __inline void __attribute__((__gnu_inline__, __always_inline__)) -PVECTOR_RENAME(_m_movntq)(any_t*__P, __m64 src) -{ -#ifdef HAVE_MMX2 - _mm_stream_pi(__P,src); -#else - _m_store(__P,src); -#endif -} -#undef _m_movntq -#define _m_movntq PVECTOR_RENAME(_m_movntq) - -#endif - -static inline void PVECTOR_RENAME(vo_draw_alpha_yv12)(int w,int h,const unsigned char* src,const unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride,int finalize){ - unsigned y; -#ifdef HAVE_INT_PVECTOR - __ivec vzero = _ivec_setzero(); -#endif -PROFILE_START(); - for(y=0;y<(unsigned)h;y++){ - int x; - x=0; -#ifdef HAVE_INT_PVECTOR - _ivec_prefetchw(&dstbase[x]); - _ivec_prefetch(&src[x]); - _ivec_prefetch(&srca[x]); - /* MOVNTDQ: #GP(0) - If memory operand is not aligned on a 16-byte boundary */ - if(!_ivec_aligned(dstbase)) - for(;x<w;x++){ - unsigned char *dst=&dstbase[x]; - if(srca[x]) *dst=((dstbase[x]*srca[x])>>8)+src[x]; - if(_ivec_aligned(dst)) break; /* align on sizeof(MMREG) boundary */ - } - if((w-x)>=_ivec_size()) - for(;x<w;x+=_ivec_size()){ - __ivec vmsk,vdest,vsrc,vsrca,vt[4]; - _ivec_prefetchw(&dstbase[x+_ivec_size()*4]); - _ivec_prefetch(&src[x+_ivec_size()*4]); - _ivec_prefetch(&srca[x+_ivec_size()*4]); - vdest = _ivec_loada(&dstbase[x]); - if(_ivec_aligned(&src[x])) - vsrc = _ivec_loada(&src[x]); - else - vsrc = _ivec_loadu(&src[x]); - if(_ivec_aligned(&srca[x])) - vsrca = _ivec_loada(&srca[x]); - else - vsrca = _ivec_loadu(&srca[x]); - vmsk = _ivec_not(_ivec_cmpeq_s8(vsrca,vzero)); - vt[0] = _ivec_u16_from_u8(vdest,&vt[1]); - vt[2] = _ivec_u16_from_u8(vsrca,&vt[3]); - vt[0] = _ivec_srl_s16_imm(_ivec_mullo_s16(vt[0],vt[2]),8); - vt[1] = _ivec_srl_s16_imm(_ivec_mullo_s16(vt[1],vt[3]),8); - vt[0] = _ivec_add_s8(_ivec_u8_from_u16(vt[0],vt[1]),vsrc); - vt[1] = _ivec_blend_u8(vdest,vt[0],vmsk); - if(finalize) - _ivec_stream(&dstbase[x],vt[1]); - else - _ivec_storea(&dstbase[x],vt[1]); - } -#endif - for(;x<w;x++){ - if(srca[x]) dstbase[x]=((dstbase[x]*srca[x])>>8)+src[x]; - } - src+=srcstride; - srca+=srcstride; - dstbase+=dststride; - } -#ifdef HAVE_INT_PVECTOR - _ivec_empty(); - if(finalize) _ivec_sfence(); -#endif -PROFILE_END("vo_draw_alpha_yv12"); - return; -} - -static inline void PVECTOR_RENAME(vo_draw_alpha_yuy2)(int w,int h,const unsigned char* src,const unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride,int finalize){ - int y; -#if defined(FAST_OSD) && !defined(HAVE_MMX) - w=w>>1; -#endif -PROFILE_START(); - for(y=0;y<h;y++){ - register int x=0; -#ifdef HAVE_INT_PVECTOR - /* TODO: port this stuff on PVector */ - __m64 mm[8]; - _ivec_prefetchw(&dstbase[x]); - _ivec_prefetch(&src[x]); - _ivec_prefetch(&srca[x]); - mm[7]=_mm_setzero_si64(); - mm[5]=_mm_set1_pi8(0xFF); - mm[4]=mm[5]; - mm[5]=_m_psllwi(mm[5],8); - mm[4]=_m_psrlwi(mm[4],8); - for(;x<w;x+=4){ - _ivec_prefetchw(&dstbase[x+_ivec_size()*4]); - _ivec_prefetch(&src[x+_ivec_size()*4]); - _ivec_prefetch(&srca[x+_ivec_size()*4]); - mm[0]=_m_load(&(((char *)dstbase)[x*2])); - mm[1]=mm[0]; - mm[0]=_m_pand(mm[0],mm[4]); - mm[2]=_m_load_half(&(((char *)srca)[x])); - mm[2]=_m_paddb(mm[2],_m_load(&bFF)); - mm[2]=_m_punpcklbw(mm[2],mm[7]); - mm[0]=_m_pmullw(mm[0],mm[2]); - mm[0]=_m_psrlwi(mm[0],8); - mm[1]=_m_pand(mm[1],mm[5]); - mm[2]=_m_load_half(&(((char *)src)[x])); - mm[2]=_m_punpcklbw(mm[2],mm[7]); - mm[0]=_m_por(mm[0],mm[1]); - mm[0]=_m_paddb(mm[0],mm[2]); - if(finalize) - _m_movntq(&(((char *)dstbase)[x*2]),mm[0]); - else - _m_store(&(((char *)dstbase)[x*2]),mm[0]); - } -#endif - for(;x<w;x++){ -#ifdef FAST_OSD - if(srca[2*x+0]) dstbase[4*x+0]=src[2*x+0]; - if(srca[2*x+1]) dstbase[4*x+2]=src[2*x+1]; -#else - if(srca[x]) { - dstbase[2*x]=((dstbase[2*x]*srca[x])>>8)+src[x]; - dstbase[2*x+1]=((((signed)dstbase[2*x+1]-128)*srca[x])>>8)+128; - } -#endif - } - src+=srcstride; - srca+=srcstride; - dstbase+=dststride; - } -#ifdef HAVE_INT_PVECTOR - _ivec_empty(); - if(finalize) _ivec_sfence(); -#endif -PROFILE_END("vo_draw_alpha_yuy2"); - return; -} - -static inline void PVECTOR_RENAME(vo_draw_alpha_rgb24)(int w,int h,const unsigned char* src,const unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride,int finalize){ - int y; - for(y=0;y<h;y++){ - register unsigned char *dst = dstbase; - register int x=0; -#ifdef HAVE_INT_PVECTOR - __m64 mm[8]; - _ivec_prefetchw(&dstbase[x]); - _ivec_prefetch(&src[x]); - _ivec_prefetch(&srca[x]); - mm[7]=_mm_setzero_si64(); - mm[6]=_mm_set1_pi8(0xFF); - for(;x<w;x+=2){ - if(srca[x] || srca[x+1]) { - _ivec_prefetchw(&dstbase[x+_ivec_size()*4]); - _ivec_prefetch(&src[x+_ivec_size()*4]); - _ivec_prefetch(&srca[x+_ivec_size()*4]); - mm[0]=_m_load(&dstbase[0]); - mm[1]=mm[0]; - mm[5]=mm[0]; - mm[0]=_m_punpcklbw(mm[0],mm[7]); - mm[1]=_m_punpckhbw(mm[1],mm[7]); - mm[2]=_m_load_half(&srca[x]); - mm[2]=_m_paddb(mm[2],mm[6]); - mm[2]=_m_punpcklbw(mm[2],mm[2]); - mm[2]=_m_punpcklbw(mm[2],mm[2]); - mm[3]=mm[2]; - mm[2]=_m_punpcklbw(mm[2],mm[7]); - mm[3]=_m_punpckhbw(mm[3],mm[7]); - mm[0]=_m_pmullw(mm[0],mm[2]); - mm[1]=_m_pmullw(mm[1],mm[3]); - mm[0]=_m_psrlwi(mm[0],8); - mm[1]=_m_psrlwi(mm[1],8); - mm[0]=_m_packuswb(mm[0],mm[1]); - mm[2]=_m_load_half(&src[x]); - mm[2]=_m_punpcklbw(mm[2],mm[2]); - mm[2]=_m_punpcklbw(mm[2],mm[2]); - mm[0]=_m_paddb(mm[0],mm[2]); - mm[5]=_m_pand(mm[5],_m_load(&mask24lh)); - mm[0]=_m_pand(mm[0],_m_load(&mask24hl)); - mm[5]=_m_por(mm[5],mm[0]); - if(finalize) - _m_movntq(&dstbase[0],mm[5]); - else - _m_store(&dstbase[0],mm[5]); - } - dst += 6; - } -#endif /* arch_x86 */ - for(;x<w;x++){ - if(srca[x]){ -#ifdef FAST_OSD - dst[0]=dst[1]=dst[2]=src[x]; -#else - dst[0]=((dst[0]*srca[x])>>8)+src[x]; - dst[1]=((dst[1]*srca[x])>>8)+src[x]; - dst[2]=((dst[2]*srca[x])>>8)+src[x]; -#endif - } - dst+=3; // 24bpp - } - src+=srcstride; - srca+=srcstride; - dstbase+=dststride; - } -#ifdef HAVE_INT_PVECTOR - _ivec_empty(); - if(finalize) _ivec_sfence(); -#endif - return; -} - -static inline void PVECTOR_RENAME(vo_draw_alpha_rgb32)(int w,int h,const unsigned char* src,const unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride,int finalize){ - int y; -PROFILE_START(); - for(y=0;y<h;y++){ - register int x=0; -#ifdef HAVE_INT_PVECTOR - __m64 mm[8]; - _ivec_prefetchw(&dstbase[x]); - _ivec_prefetch(&src[x]); - _ivec_prefetch(&srca[x]); - mm[7]=_mm_setzero_si64(); - mm[6]=_mm_set1_pi8(0xFF); - for(;x<w;x+=2){ - if(srca[x] || srca[x+1]) { - _ivec_prefetchw(&dstbase[x+_ivec_size()*4]); - _ivec_prefetch(&src[x+_ivec_size()*4]); - _ivec_prefetch(&srca[x+_ivec_size()*4]); - mm[0]=_m_load(&dstbase[4*x]); - mm[1]=mm[0]; - mm[0]=_m_punpcklbw(mm[0],mm[7]); - mm[1]=_m_punpckhbw(mm[1],mm[7]); - mm[2]=_m_load_half(&srca[x]); - mm[2]=_m_paddb(mm[2],mm[6]); - mm[2]=_m_punpcklbw(mm[2],mm[2]); - mm[2]=_m_punpcklbw(mm[2],mm[2]); - mm[3]=mm[2]; - mm[2]=_m_punpcklbw(mm[2],mm[7]); - mm[3]=_m_punpckhbw(mm[3],mm[7]); - mm[0]=_m_pmullw(mm[0],mm[2]); - mm[1]=_m_pmullw(mm[1],mm[3]); - mm[0]=_m_psrlwi(mm[0],8); - mm[1]=_m_psrlwi(mm[1],8); - mm[0]=_m_packuswb(mm[0],mm[1]); - mm[2]=_m_load_half(&src[x]); - mm[2]=_m_punpcklbw(mm[2],mm[2]); - mm[2]=_m_punpcklbw(mm[2],mm[2]); - mm[0]=_m_paddb(mm[0],mm[2]); - if(finalize) - _m_movntq(&dstbase[4*x],mm[0]); - else - _m_store(&dstbase[4*x],mm[0]); - } - } -#endif /* arch_x86 */ - for(;x<w;x++){ - if(srca[x]){ -#ifdef FAST_OSD - dstbase[4*x+0]=dstbase[4*x+1]=dstbase[4*x+2]=src[x]; -#else - dstbase[4*x+0]=((dstbase[4*x+0]*srca[x])>>8)+src[x]; - dstbase[4*x+1]=((dstbase[4*x+1]*srca[x])>>8)+src[x]; - dstbase[4*x+2]=((dstbase[4*x+2]*srca[x])>>8)+src[x]; -#endif - } - } - src+=srcstride; - srca+=srcstride; - dstbase+=dststride; - } -#ifdef HAVE_INT_PVECTOR - _ivec_empty(); - if(finalize) _ivec_sfence(); -#endif -PROFILE_END("vo_draw_alpha_rgb32"); - return; -} Copied: mplayerxp/libvo/osd_template.h (from rev 417, mplayerxp/libvo/osd_template.c) =================================================================== --- mplayerxp/libvo/osd_template.h (rev 0) +++ mplayerxp/libvo/osd_template.h 2012-11-21 13:21:00 UTC (rev 422) @@ -0,0 +1,318 @@ +// Generic alpha renderers for all YUV modes and RGB depths. +// Optimized by Nick and Michael +// Code from Michael Niedermayer (mic...@gm...) is under GPL +#include "pvector/pvector.h" + +#ifdef HAVE_INT_PVECTOR +static __inline __m64 __attribute__((__gnu_inline__, __always_inline__)) +PVECTOR_RENAME(_m_load)(const any_t*__P) +{ + return *(const __m64 *)__P; +} +#undef _m_load +#define _m_load PVECTOR_RENAME(_m_load) + +static __inline __m64 __attribute__((__gnu_inline__, __always_inline__)) +PVECTOR_RENAME(_m_load_half)(const any_t*__P) +{ + return _mm_cvtsi32_si64 (*(const int *)__P); +} +#undef _m_load_half +#define _m_load_half PVECTOR_RENAME(_m_load_half) + +static __inline void __attribute__((__gnu_inline__, __always_inline__)) +PVECTOR_RENAME(_m_store)(any_t*__P, __m64 src) +{ + *(__m64 *)__P = src; +} +#undef _m_store +#define _m_store PVECTOR_RENAME(_m_store) + +static __inline void __attribute__((__gnu_inline__, __always_inline__)) +PVECTOR_RENAME(_m_store_half)(any_t*__P, __m64 src) +{ + *(int *)__P = _mm_cvtsi64_si32(src); +} +#undef _m_store_half +#define _m_store_half PVECTOR_RENAME(_m_store_half) + +static __inline void __attribute__((__gnu_inline__, __always_inline__)) +PVECTOR_RENAME(_m_movntq)(any_t*__P, __m64 src) +{ +#ifdef HAVE_MMX2 + _mm_stream_pi(__P,src); +#else + _m_store(__P,src); +#endif +} +#undef _m_movntq +#define _m_movntq PVECTOR_RENAME(_m_movntq) + +#endif + +static inline void PVECTOR_RENAME(vo_draw_alpha_yv12)(int w,int h,const unsigned char* src,const unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride,int finalize){ + unsigned y; +#ifdef HAVE_INT_PVECTOR + __ivec vzero = _ivec_setzero(); +#endif +PROFILE_START(); + for(y=0;y<(unsigned)h;y++){ + int x; + x=0; +#ifdef HAVE_INT_PVECTOR + _ivec_prefetchw(&dstbase[x]); + _ivec_prefetch(&src[x]); + _ivec_prefetch(&srca[x]); + /* MOVNTDQ: #GP(0) - If memory operand is not aligned on a 16-byte boundary */ + if(!_ivec_aligned(dstbase)) + for(;x<w;x++){ + unsigned char *dst=&dstbase[x]; + if(srca[x]) *dst=((dstbase[x]*srca[x])>>8)+src[x]; + if(_ivec_aligned(dst)) break; /* align on sizeof(MMREG) boundary */ + } + if((w-x)>=_ivec_size()) + for(;x<w;x+=_ivec_size()){ + __ivec vmsk,vdest,vsrc,vsrca,vt[4]; + _ivec_prefetchw(&dstbase[x+_ivec_size()*4]); + _ivec_prefetch(&src[x+_ivec_size()*4]); + _ivec_prefetch(&srca[x+_ivec_size()*4]); + vdest = _ivec_loada(&dstbase[x]); + if(_ivec_aligned(&src[x])) + vsrc = _ivec_loada(&src[x]); + else + vsrc = _ivec_loadu(&src[x]); + if(_ivec_aligned(&srca[x])) + vsrca = _ivec_loada(&srca[x]); + else + vsrca = _ivec_loadu(&srca[x]); + vmsk = _ivec_not(_ivec_cmpeq_s8(vsrca,vzero)); + vt[0] = _ivec_u16_from_u8(vdest,&vt[1]); + vt[2] = _ivec_u16_from_u8(vsrca,&vt[3]); + vt[0] = _ivec_srl_s16_imm(_ivec_mullo_s16(vt[0],vt[2]),8); + vt[1] = _ivec_srl_s16_imm(_ivec_mullo_s16(vt[1],vt[3]),8); + vt[0] = _ivec_add_s8(_ivec_u8_from_u16(vt[0],vt[1]),vsrc); + vt[1] = _ivec_blend_u8(vdest,vt[0],vmsk); + if(finalize) + _ivec_stream(&dstbase[x],vt[1]); + else + _ivec_storea(&dstbase[x],vt[1]); + } +#endif + for(;x<w;x++){ + if(srca[x]) dstbase[x]=((dstbase[x]*srca[x])>>8)+src[x]; + } + src+=srcstride; + srca+=srcstride; + dstbase+=dststride; + } +#ifdef HAVE_INT_PVECTOR + _ivec_empty(); + if(finalize) _ivec_sfence(); +#endif +PROFILE_END("vo_draw_alpha_yv12"); + return; +} + +static inline void PVECTOR_RENAME(vo_draw_alpha_yuy2)(int w,int h,const unsigned char* src,const unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride,int finalize){ + int y; +#if defined(FAST_OSD) && !defined(HAVE_MMX) + w=w>>1; +#endif +PROFILE_START(); + for(y=0;y<h;y++){ + register int x=0; +#ifdef HAVE_INT_PVECTOR + /* TODO: port this stuff on PVector */ + __m64 mm[8]; + _ivec_prefetchw(&dstbase[x]); + _ivec_prefetch(&src[x]); + _ivec_prefetch(&srca[x]); + mm[7]=_mm_setzero_si64(); + mm[5]=_mm_set1_pi8(0xFF); + mm[4]=mm[5]; + mm[5]=_m_psllwi(mm[5],8); + mm[4]=_m_psrlwi(mm[4],8); + for(;x<w;x+=4){ + _ivec_prefetchw(&dstbase[x+_ivec_size()*4]); + _ivec_prefetch(&src[x+_ivec_size()*4]); + _ivec_prefetch(&srca[x+_ivec_size()*4]); + mm[0]=_m_load(&(((char *)dstbase)[x*2])); + mm[1]=mm[0]; + mm[0]=_m_pand(mm[0],mm[4]); + mm[2]=_m_load_half(&(((char *)srca)[x])); + mm[2]=_m_paddb(mm[2],_m_load(&bFF)); + mm[2]=_m_punpcklbw(mm[2],mm[7]); + mm[0]=_m_pmullw(mm[0],mm[2]); + mm[0]=_m_psrlwi(mm[0],8); + mm[1]=_m_pand(mm[1],mm[5]); + mm[2]=_m_load_half(&(((char *)src)[x])); + mm[2]=_m_punpcklbw(mm[2],mm[7]); + mm[0]=_m_por(mm[0],mm[1]); + mm[0]=_m_paddb(mm[0],mm[2]); + if(finalize) + _m_movntq(&(((char *)dstbase)[x*2]),mm[0]); + else + _m_store(&(((char *)dstbase)[x*2]),mm[0]); + } +#endif + for(;x<w;x++){ +#ifdef FAST_OSD + if(srca[2*x+0]) dstbase[4*x+0]=src[2*x+0]; + if(srca[2*x+1]) dstbase[4*x+2]=src[2*x+1]; +#else + if(srca[x]) { + dstbase[2*x]=((dstbase[2*x]*srca[x])>>8)+src[x]; + dstbase[2*x+1]=((((signed)dstbase[2*x+1]-128)*srca[x])>>8)+128; + } +#endif + } + src+=srcstride; + srca+=srcstride; + dstbase+=dststride; + } +#ifdef HAVE_INT_PVECTOR + _ivec_empty(); + if(finalize) _ivec_sfence(); +#endif +PROFILE_END("vo_draw_alpha_yuy2"); + return; +} + +static inline void PVECTOR_RENAME(vo_draw_alpha_rgb24)(int w,int h,const unsigned char* src,const unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride,int finalize){ + int y; + for(y=0;y<h;y++){ + register unsigned char *dst = dstbase; + register int x=0; +#ifdef HAVE_INT_PVECTOR + __m64 mm[8]; + _ivec_prefetchw(&dstbase[x]); + _ivec_prefetch(&src[x]); + _ivec_prefetch(&srca[x]); + mm[7]=_mm_setzero_si64(); + mm[6]=_mm_set1_pi8(0xFF); + for(;x<w;x+=2){ + if(srca[x] || srca[x+1]) { + _ivec_prefetchw(&dstbase[x+_ivec_size()*4]); + _ivec_prefetch(&src[x+_ivec_size()*4]); + _ivec_prefetch(&srca[x+_ivec_size()*4]); + mm[0]=_m_load(&dstbase[0]); + mm[1]=mm[0]; + mm[5]=mm[0]; + mm[0]=_m_punpcklbw(mm[0],mm[7]); + mm[1]=_m_punpckhbw(mm[1],mm[7]); + mm[2]=_m_load_half(&srca[x]); + mm[2]=_m_paddb(mm[2],mm[6]); + mm[2]=_m_punpcklbw(mm[2],mm[2]); + mm[2]=_m_punpcklbw(mm[2],mm[2]); + mm[3]=mm[2]; + mm[2]=_m_punpcklbw(mm[2],mm[7]); + mm[3]=_m_punpckhbw(mm[3],mm[7]); + mm[0]=_m_pmullw(mm[0],mm[2]); + mm[1]=_m_pmullw(mm[1],mm[3]); + mm[0]=_m_psrlwi(mm[0],8); + mm[1]=_m_psrlwi(mm[1],8); + mm[0]=_m_packuswb(mm[0],mm[1]); + mm[2]=_m_load_half(&src[x]); + mm[2]=_m_punpcklbw(mm[2],mm[2]); + mm[2]=_m_punpcklbw(mm[2],mm[2]); + mm[0]=_m_paddb(mm[0],mm[2]); + mm[5]=_m_pand(mm[5],_m_load(&mask24lh)); + mm[0]=_m_pand(mm[0],_m_load(&mask24hl)); + mm[5]=_m_por(mm[5],mm[0]); + if(finalize) + _m_movntq(&dstbase[0],mm[5]); + else + _m_store(&dstbase[0],mm[5]); + } + dst += 6; + } +#endif /* arch_x86 */ + for(;x<w;x++){ + if(srca[x]){ +#ifdef FAST_OSD + dst[0]=dst[1]=dst[2]=src[x]; +#else + dst[0]=((dst[0]*srca[x])>>8)+src[x]; + dst[1]=((dst[1]*srca[x])>>8)+src[x]; + dst[2]=((dst[2]*srca[x])>>8)+src[x]; +#endif + } + dst+=3; // 24bpp + } + src+=srcstride; + srca+=srcstride; + dstbase+=dststride; + } +#ifdef HAVE_INT_PVECTOR + _ivec_empty(); + if(finalize) _ivec_sfence(); +#endif + return; +} + +static inline void PVECTOR_RENAME(vo_draw_alpha_rgb32)(int w,int h,const unsigned char* src,const unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride,int finalize){ + int y; +PROFILE_START(); + for(y=0;y<h;y++){ + register int x=0; +#ifdef HAVE_INT_PVECTOR + __m64 mm[8]; + _ivec_prefetchw(&dstbase[x]); + _ivec_prefetch(&src[x]); + _ivec_prefetch(&srca[x]); + mm[7]=_mm_setzero_si64(); + mm[6]=_mm_set1_pi8(0xFF); + for(;x<w;x+=2){ + if(srca[x] || srca[x+1]) { + _ivec_prefetchw(&dstbase[x+_ivec_size()*4]); + _ivec_prefetch(&src[x+_ivec_size()*4]); + _ivec_prefetch(&srca[x+_ivec_size()*4]); + mm[0]=_m_load(&dstbase[4*x]); + mm[1]=mm[0]; + mm[0]=_m_punpcklbw(mm[0],mm[7]); + mm[1]=_m_punpckhbw(mm[1],mm[7]); + mm[2]=_m_load_half(&srca[x]); + mm[2]=_m_paddb(mm[2],mm[6]); + mm[2]=_m_punpcklbw(mm[2],mm[2]); + mm[2]=_m_punpcklbw(mm[2],mm[2]); + mm[3]=mm[2]; + mm[2]=_m_punpcklbw(mm[2],mm[7]); + mm[3]=_m_punpckhbw(mm[3],mm[7]); + mm[0]=_m_pmullw(mm[0],mm[2]); + mm[1]=_m_pmullw(mm[1],mm[3]); + mm[0]=_m_psrlwi(mm[0],8); + mm[1]=_m_psrlwi(mm[1],8); + mm[0]=_m_packuswb(mm[0],mm[1]); + mm[2]=_m_load_half(&src[x]); + mm[2]=_m_punpcklbw(mm[2],mm[2]); + mm[2]=_m_punpcklbw(mm[2],mm[2]); + mm[0]=_m_paddb(mm[0],mm[2]); + if(finalize) + _m_movntq(&dstbase[4*x],mm[0]); + else + _m_store(&dstbase[4*x],mm[0]); + } + } +#endif /* arch_x86 */ + for(;x<w;x++){ + if(srca[x]){ +#ifdef FAST_OSD + dstbase[4*x+0]=dstbase[4*x+1]=dstbase[4*x+2]=src[x]; +#else + dstbase[4*x+0]=((dstbase[4*x+0]*srca[x])>>8)+src[x]; + dstbase[4*x+1]=((dstbase[4*x+1]*srca[x])>>8)+src[x]; + dstbase[4*x+2]=((dstbase[4*x+2]*srca[x])>>8)+src[x]; +#endif + } + } + src+=srcstride; + srca+=srcstride; + dstbase+=dststride; + } +#ifdef HAVE_INT_PVECTOR + _ivec_empty(); + if(finalize) _ivec_sfence(); +#endif +PROFILE_END("vo_draw_alpha_rgb32"); + return; +} Modified: mplayerxp/libvo/sub.h =================================================================== --- mplayerxp/libvo/sub.h 2012-11-21 12:54:43 UTC (rev 421) +++ mplayerxp/libvo/sub.h 2012-11-21 13:21:00 UTC (rev 422) @@ -3,10 +3,6 @@ #include <inttypes.h> #include "osd.h" -#ifdef __cplusplus -extern "C" { -#endif - typedef struct mp_osd_bbox_s { int x1,y1,x2,y2; } mp_osd_bbox_t; @@ -104,8 +100,5 @@ int __FASTCALL__ vo_osd_changed(int new_value); int __FASTCALL__ get_osd_height(any_t* vo,int c,int h); void __FASTCALL__ osd_set_nav_box (uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey); -#ifdef __cplusplus -} -#endif #endif Modified: mplayerxp/libvo/video_out.cpp =================================================================== --- mplayerxp/libvo/video_out.cpp 2012-11-21 12:54:43 UTC (rev 421) +++ mplayerxp/libvo/video_out.cpp 2012-11-21 13:21:00 UTC (rev 422) @@ -51,18 +51,18 @@ // // Externally visible list of all vo drivers // -extern vo_functions_t video_out_x11; -extern vo_functions_t video_out_xv; -extern vo_functions_t video_out_dga; -extern vo_functions_t video_out_sdl; -extern vo_functions_t video_out_null; -extern vo_functions_t video_out_pgm; -extern vo_functions_t video_out_md5; -extern vo_functions_t video_out_fbdev; -extern vo_functions_t video_out_png; -extern vo_functions_t video_out_opengl; +extern const vo_functions_t video_out_x11; +extern const vo_functions_t video_out_xv; +extern const vo_functions_t video_out_dga; +extern const vo_functions_t video_out_sdl; +extern const vo_functions_t video_out_null; +extern const vo_functions_t video_out_pgm; +extern const vo_functions_t video_out_md5; +extern const vo_functions_t video_out_fbdev; +extern const vo_functions_t video_out_png; +extern const vo_functions_t video_out_opengl; #ifdef HAVE_VESA -extern vo_functions_t video_out_vesa; +extern const vo_functions_t video_out_vesa; #endif static const vo_functions_t* video_out_drivers[] = @@ -454,17 +454,18 @@ uint32_t __FASTCALL__ vo_query_format(vo_data_t*vo,uint32_t* fourcc, unsigned src_w, unsigned src_h) { vo_priv_t* priv=(vo_priv_t*)vo->vo_priv; - uint32_t retval,dri_forced_fourcc; + uint32_t dri_forced_fourcc; + MPXP_Rc retval; vo_query_fourcc_t qfourcc; MSG_DBG3("dri_vo_dbg: vo_query_format(%08lX)\n",*fourcc); qfourcc.fourcc = *fourcc; qfourcc.w = src_w; qfourcc.h = src_h; - retval = priv->video_out->control(vo,VOCTRL_QUERY_FORMAT,&qfourcc); - MSG_V("dri_vo: request for %s fourcc: %s\n",vo_format_name(*fourcc),retval?"OK":"False"); + if(priv->video_out->control(vo,VOCTRL_QUERY_FORMAT,&qfourcc)==MPXP_False) + qfourcc.flags=VOCAP_NA; + MSG_V("dri_vo: request for %s fourcc: %i\n",vo_format_name(*fourcc),qfourcc.flags); dri_forced_fourcc = *fourcc; - if(retval) retval = 0x3; /... [truncated message content] |
From: <nic...@us...> - 2012-11-21 13:39:59
|
Revision: 423 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=423&view=rev Author: nickols_k Date: 2012-11-21 13:39:45 +0000 (Wed, 21 Nov 2012) Log Message: ----------- cleanups Modified Paths: -------------- mplayerxp/libmpcodecs/vd_ffmpeg.cpp mplayerxp/libmpdemux/mpeg_hdr.cpp mplayerxp/libmpstream/cache2.cpp mplayerxp/libmpstream/s_dvdnav.cpp mplayerxp/libmpstream/stream.cpp mplayerxp/osdep/mp_malloc.cpp mplayerxp/postproc/vf_unsharp.cpp Modified: mplayerxp/libmpcodecs/vd_ffmpeg.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_ffmpeg.cpp 2012-11-21 13:21:00 UTC (rev 422) +++ mplayerxp/libmpcodecs/vd_ffmpeg.cpp 2012-11-21 13:39:45 UTC (rev 423) @@ -1,3 +1,5 @@ +#include <algorithm> + #include <ctype.h> #include <stdio.h> #include <stdlib.h> @@ -367,11 +369,11 @@ if (sh->bih->biSize-sizeof(BITMAPINFOHEADER)) /* Palette size in biSize */ memcpy(priv->ctx->palctrl->palette, sh->bih+1, - min(sh->bih->biSize-sizeof(BITMAPINFOHEADER), AVPALETTE_SIZE)); + std::min(sh->bih->biSize-sizeof(BITMAPINFOHEADER), AVPALETTE_SIZE)); else /* Palette size in biClrUsed */ memcpy(priv->ctx->palctrl->palette, sh->bih+1, - min(sh->bih->biClrUsed * 4, AVPALETTE_SIZE)); + std::min(sh->bih->biClrUsed * 4, AVPALETTE_SIZE)); } #endif if(sh->bih) Modified: mplayerxp/libmpdemux/mpeg_hdr.cpp =================================================================== --- mplayerxp/libmpdemux/mpeg_hdr.cpp 2012-11-21 13:21:00 UTC (rev 422) +++ mplayerxp/libmpdemux/mpeg_hdr.cpp 2012-11-21 13:39:45 UTC (rev 423) @@ -1,3 +1,5 @@ +#include <algorithm> + #include "../mp_config.h" // based on libmpeg2/header.c by Aaron Holtzman <aho...@es...> #include <inttypes.h> @@ -213,10 +215,6 @@ return n; } -#ifndef min -#define min(a, b) ((a) <= (b) ? (a) : (b)) -#endif - static unsigned int read_golomb(unsigned char *buffer, unsigned int *init) { unsigned int x, v = 0, v2 = 0, m, len = 0, n = *init; @@ -227,7 +225,7 @@ x = len + n; while(n < x) { - m = min(x - n, 8); + m = std::min(x - n, unsigned(8)); v |= getbits(buffer, n, m); n += m; if(x - n > 8) Modified: mplayerxp/libmpstream/cache2.cpp =================================================================== --- mplayerxp/libmpstream/cache2.cpp 2012-11-21 13:21:00 UTC (rev 422) +++ mplayerxp/libmpstream/cache2.cpp 2012-11-21 13:39:45 UTC (rev 423) @@ -1,3 +1,5 @@ +#include <algorithm> + #include "mp_config.h" #define READ_USLEEP_TIME 10000 @@ -26,10 +28,6 @@ #include "mplayerxp.h" #include "stream_msg.h" -#ifndef min -#define min(a,b) ((a)<(b)?(a):(b)) -#endif - #define CPF_EMPTY 0x00000001UL #define CPF_EOF 0x80000000UL #define CPF_DONE 0x40000000UL /* special case for dvd packets to exclude them from sending again */ @@ -512,7 +510,7 @@ if(mp_conf.verbose>2) { MSG_DBG2( "c2_stream_read got %u bytes ",total); - for(i=0;i<min(8,total);i++) MSG_DBG2("%02X ",(int)((unsigned char)_mem[i])); + for(i=0;i<std::min(8,total);i++) MSG_DBG2("%02X ",(int)((unsigned char)_mem[i])); MSG_DBG2("\n"); } return total; Modified: mplayerxp/libmpstream/s_dvdnav.cpp =================================================================== --- mplayerxp/libmpstream/s_dvdnav.cpp 2012-11-21 13:21:00 UTC (rev 422) +++ mplayerxp/libmpstream/s_dvdnav.cpp 2012-11-21 13:39:45 UTC (rev 423) @@ -13,6 +13,8 @@ #include "libvo/sub.h" #include "input2/input.h" #include "mplayerxp.h" +#include <algorithm> + #include "stream_msg.h" #include <dvdnav/dvdnav.h> @@ -23,13 +25,6 @@ #include "mrl.h" #define DVD_BLOCK_SIZE 2048 -#ifndef min -#define min(a,b) ((a)<(b)?(a):(b)) -#endif -#ifndef max -#define max(a,b) ((a)>(b)?(a):(b)) -#endif - extern vo_data_t* vo_data; typedef struct { @@ -470,10 +465,10 @@ btni_t *btni = &(pnavpci->hli.btnit[btnum]); if (priv->hlev.buttonN == (unsigned)btnum + 1) { - priv->hlev.sx = min (btni->x_start, btni->x_end); - priv->hlev.ex = max (btni->x_start, btni->x_end); - priv->hlev.sy = min (btni->y_start, btni->y_end); - priv->hlev.ey = max (btni->y_start, btni->y_end); + priv->hlev.sx = std::min (btni->x_start, btni->x_end); + priv->hlev.ex = std::max (btni->x_start, btni->x_end); + priv->hlev.sy = std::min (btni->y_start, btni->y_end); + priv->hlev.ey = std::max (btni->y_start, btni->y_end); priv->hlev.palette = (btni->btn_coln == 0) ? 0 : pnavpci->hli.btn_colit.btn_coli[btni->btn_coln - 1][0]; Modified: mplayerxp/libmpstream/stream.cpp =================================================================== --- mplayerxp/libmpstream/stream.cpp 2012-11-21 13:21:00 UTC (rev 422) +++ mplayerxp/libmpstream/stream.cpp 2012-11-21 13:39:45 UTC (rev 423) @@ -1,3 +1,5 @@ +#include <algorithm> + #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -21,10 +23,6 @@ #include "libmpdemux/demuxer.h" #include "stream_msg.h" -#ifndef min -#define min(a,b) ((a)<(b)?(a):(b)) -#endif - #ifdef HAVE_LIBCDIO_CDDA extern const stream_driver_t cdda_stream; extern const stream_driver_t cddb_stream; @@ -281,7 +279,7 @@ x=s->buf_len-s->buf_pos; if(x>0) { - ilen=min(_total,x); + ilen=std::min(_total,x); memcpy(mem,&s->buffer[s->buf_pos],ilen); MSG_DBG3("nc_stream_read: copy prefetched %u bytes\n",ilen); s->buf_pos+=ilen; @@ -312,10 +310,10 @@ s->buffer=(unsigned char *)mem; s->buf_len=rlen; nc_stream_read_cbuffer(s); - mem += min(rlen,(int)s->buf_len); + mem += std::min(rlen,(int)s->buf_len); tile=s->buf_len-rlen; - rlen -= min(rlen,(int)s->buf_len); - got_len += min(rlen,(int)s->buf_len); + rlen -= std::min(rlen,(int)s->buf_len); + got_len += std::min(rlen,(int)s->buf_len); eof=stream_eof(s); if(eof) break; stat++; @@ -330,8 +328,8 @@ /* should never happen. Store data back to native cache! */ MSG_DBG3("nc_stream_read: we have tile %u bytes\n",tile); s->buf_pos=0; - memcpy(s->buffer,&mem[s->buf_len-tile],min(STREAM_BUFFER_SIZE,tile)); - s->buf_len=min(STREAM_BUFFER_SIZE,tile); + memcpy(s->buffer,&mem[s->buf_len-tile],std::min(int(STREAM_BUFFER_SIZE),tile)); + s->buf_len=std::min(int(STREAM_BUFFER_SIZE),tile); } } ilen=_total-ilen; @@ -349,7 +347,7 @@ mem+=x; ilen-=x; } MSG_DBG3( "nc_stream_read got %u bytes ",total); - for(i=0;i<min(8,total);i++) MSG_DBG3("%02X ",(int)((unsigned char)mem[i])); + for(i=0;i<std::min(8,total);i++) MSG_DBG3("%02X ",(int)((unsigned char)mem[i])); MSG_DBG3("\n"); return total; } Modified: mplayerxp/osdep/mp_malloc.cpp =================================================================== --- mplayerxp/osdep/mp_malloc.cpp 2012-11-21 13:21:00 UTC (rev 422) +++ mplayerxp/osdep/mp_malloc.cpp 2012-11-21 13:39:45 UTC (rev 423) @@ -1,3 +1,5 @@ +#include <algorithm> + #include "mp_config.h" #include "mplib.h" #define MSGT_CLASS MSGT_OSDEP @@ -223,7 +225,6 @@ prot_free_slot(&priv->mallocs,page_ptr); } -#define min(a,b) ((a)<(b)?(a):(b)) static any_t* __prot_realloc_append(any_t*ptr,size_t size) { any_t* rp; if((rp=__prot_malloc_append(size))!=NULL && ptr) { @@ -234,7 +235,7 @@ __print_backtrace(10); kill(getpid(), SIGILL); } - memcpy(rp,ptr,min(slot->size,size)); + memcpy(rp,ptr,std::min(slot->size,size)); __prot_free_append(ptr); } return rp; @@ -283,7 +284,7 @@ __print_backtrace(10); kill(getpid(), SIGILL); } - memcpy(rp,ptr,min(slot->size,size)); + memcpy(rp,ptr,std::min(slot->size,size)); __prot_free_prepend(ptr); } return rp; @@ -379,14 +380,14 @@ int printable=1; MSG_INFO("address: %p size: %u dump: ",c->slots[i].page_ptr,c->slots[i].size); s=reinterpret_cast<char *>(c->slots[i].page_ptr); - for(j=0;j<min(c->slots[i].size,20);j++) { + for(j=0;j<std::min(c->slots[i].size,size_t(20));j++) { if(!isprint(s[j])) { printable=0; break; } } if(printable) MSG_INFO("%20s",s); - else for(j=0;j<min(c->slots[i].size,10);j++) { + else for(j=0;j<std::min(c->slots[i].size,size_t(10));j++) { MSG_INFO("%02X ",(unsigned char)s[j]); } MSG_INFO("\n"); Modified: mplayerxp/postproc/vf_unsharp.cpp =================================================================== --- mplayerxp/postproc/vf_unsharp.cpp 2012-11-21 13:21:00 UTC (rev 422) +++ mplayerxp/postproc/vf_unsharp.cpp 2012-11-21 13:39:45 UTC (rev 423) @@ -16,6 +16,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <algorithm> #include <stdio.h> #include <stdlib.h> @@ -37,13 +38,6 @@ #include "osdep/mplib.h" #include "pp_msg.h" -#ifndef MIN -#define MIN(a,b) (((a)<(b))?(a):(b)) -#endif -#ifndef MAX -#define MAX(a,b) (((a)>(b))?(a):(b)) -#endif - //===========================================================================// #define MIN_MATRIX_SIZE 3 @@ -297,8 +291,8 @@ fp->msizeY = ( z && z+1<max ) ? atoi( pos=z+1 ) : fp->msizeX; // min/max & odd - fp->msizeX = 1 | MIN( MAX( fp->msizeX, MIN_MATRIX_SIZE ), MAX_MATRIX_SIZE ); - fp->msizeY = 1 | MIN( MAX( fp->msizeY, MIN_MATRIX_SIZE ), MAX_MATRIX_SIZE ); + fp->msizeX = 1 | std::min( std::max( fp->msizeX, MIN_MATRIX_SIZE ), MAX_MATRIX_SIZE ); + fp->msizeY = 1 | std::min( std::max( fp->msizeY, MIN_MATRIX_SIZE ), MAX_MATRIX_SIZE ); // parse amount pos = strchr( pos+1, ':' ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-11-21 15:49:39
|
Revision: 425 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=425&view=rev Author: nickols_k Date: 2012-11-21 15:49:25 +0000 (Wed, 21 Nov 2012) Log Message: ----------- more c++ sources + constantization Modified Paths: -------------- mplayerxp/input2/input.h mplayerxp/libmpstream/Makefile mplayerxp/libmpstream/cddb.cpp mplayerxp/libmpstream/http.h mplayerxp/libmpstream/mrl.h mplayerxp/libmpstream/network.h mplayerxp/libmpstream/pnm.h mplayerxp/libmpstream/s_dvdread.c mplayerxp/libmpstream/s_vcdnav.c mplayerxp/libmpstream/stream.h mplayerxp/mplayerxp.h mplayerxp/osdep/timer-lx.cpp mplayerxp/osdep/timer.h mplayerxp/xmpcore/sig_hand.h mplayerxp/xmpcore/xmp_core.h Added Paths: ----------- mplayerxp/libmpstream/asf_mmst_streaming.cpp mplayerxp/libmpstream/asf_streaming.cpp mplayerxp/libmpstream/cookies.cpp mplayerxp/libmpstream/http.cpp mplayerxp/libmpstream/mrl.cpp mplayerxp/libmpstream/network.cpp mplayerxp/libmpstream/pnm.cpp mplayerxp/libmpstream/rtp.cpp mplayerxp/libmpstream/s_ftp.cpp mplayerxp/libmpstream/s_network.cpp mplayerxp/libmpstream/s_rtsp.cpp mplayerxp/libmpstream/s_udp.cpp mplayerxp/libmpstream/tcp.cpp mplayerxp/libmpstream/udp.cpp mplayerxp/libmpstream/url.cpp Removed Paths: ------------- mplayerxp/libmpstream/asf_mmst_streaming.c mplayerxp/libmpstream/asf_streaming.c mplayerxp/libmpstream/cookies.c mplayerxp/libmpstream/http.c mplayerxp/libmpstream/mrl.c mplayerxp/libmpstream/network.c mplayerxp/libmpstream/pnm.c mplayerxp/libmpstream/rtp.c mplayerxp/libmpstream/s_ftp.c mplayerxp/libmpstream/s_network.c mplayerxp/libmpstream/s_rtsp.c mplayerxp/libmpstream/s_udp.c mplayerxp/libmpstream/tcp.c mplayerxp/libmpstream/udp.c mplayerxp/libmpstream/url.c Modified: mplayerxp/input2/input.h =================================================================== --- mplayerxp/input2/input.h 2012-11-21 14:09:25 UTC (rev 424) +++ mplayerxp/input2/input.h 2012-11-21 15:49:25 UTC (rev 425) @@ -156,12 +156,6 @@ extern void mp_input_print_cmds(any_t*handle); extern void mp_input_print_binds(any_t*handle); -#ifdef __cplusplus -extern "C" { -#endif // Interruptible usleep: (used by libmpdemux) extern MPXP_Rc mp_input_check_interrupt(any_t* handle,int time); -#ifdef __cplusplus -} #endif -#endif Modified: mplayerxp/libmpstream/Makefile =================================================================== --- mplayerxp/libmpstream/Makefile 2012-11-21 14:09:25 UTC (rev 424) +++ mplayerxp/libmpstream/Makefile 2012-11-21 15:49:25 UTC (rev 425) @@ -21,19 +21,20 @@ ifeq ($(USE_DVDREAD),yes) SRCS += s_dvdread.c endif -SRCS += url.c +CXXSRCS += url.cpp ifeq ($(USE_OSS_AUDIO),yes) CXXSRCS += s_oss.cpp endif ifeq ($(USE_LIBVCD),yes) SRCS += s_vcdnav.c endif -SRCS += mrl.c +CXXSRCS += mrl.cpp SUBDIRS = tvi ifeq ($(HAVE_STREAMING),yes) SUBDIRS += freesdp librtsp realrtsp -SRCS += asf_streaming.c asf_mmst_streaming.c cookies.c http.c network.c rtp.c pnm.c s_ftp.c s_udp.c s_rtsp.c s_network.c tcp.c udp.c +CXXSRCS += asf_streaming.cpp asf_mmst_streaming.cpp s_ftp.cpp s_udp.cpp s_network.cpp +CXXSRCS+=s_rtsp.cpp network.cpp http.cpp cookies.cpp rtp.cpp pnm.cpp tcp.cpp udp.cpp endif CXXSRCS+= stream.cpp cache2.cpp Deleted: mplayerxp/libmpstream/asf_mmst_streaming.c =================================================================== --- mplayerxp/libmpstream/asf_mmst_streaming.c 2012-11-21 14:09:25 UTC (rev 424) +++ mplayerxp/libmpstream/asf_mmst_streaming.c 2012-11-21 15:49:25 UTC (rev 425) @@ -1,664 +0,0 @@ -// mmst implementation taken from the xine-mms plugin made by majormms (http://geocities.com/majormms/) -// -// ported to mplayer by Abhijeet Phatak <abh...@ya...> -// date : 16 April 2002 -// -// information about the mms protocol can be find at http://get.to/sdp -// - - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <errno.h> -#include <inttypes.h> - -#include "mp_config.h" -#include "mplayerxp.h" - -#include "tcp.h" -#include "url.h" -#include "libmpdemux/asf.h" -#include "stream.h" - -#include "network.h" - -#ifndef HAVE_WINSOCK2 -#define closesocket close -#else -#include <winsock2.h> -#endif -#ifndef USE_SETLOCALE -#undef USE_ICONV -#endif - -#ifdef USE_ICONV -#ifdef HAVE_GICONV -#include <giconv.h> -#else -#include <iconv.h> -#endif -#ifdef USE_LANGINFO -#include <langinfo.h> -#endif -#endif -#include "stream_msg.h" -#include "osdep/mplib.h" - -#define BUF_SIZE 102400 -#define HDR_BUF_SIZE 8192 -#define MAX_STREAMS 20 - -typedef struct -{ - uint8_t buf[BUF_SIZE]; - int num_bytes; - -} command_t; - -static int seq_num; -static int num_stream_ids; -static int stream_ids[MAX_STREAMS]; - -static int get_data (int s, char *buf, size_t count); - -static void put_32 (command_t *cmd, uint32_t value) -{ - cmd->buf[cmd->num_bytes ] = value % 256; - value = value >> 8; - cmd->buf[cmd->num_bytes+1] = value % 256 ; - value = value >> 8; - cmd->buf[cmd->num_bytes+2] = value % 256 ; - value = value >> 8; - cmd->buf[cmd->num_bytes+3] = value % 256 ; - - cmd->num_bytes += 4; -} - -static uint32_t get_32 (unsigned char *cmd, int offset) -{ - uint32_t ret; - - ret = cmd[offset] ; - ret |= cmd[offset+1]<<8 ; - ret |= cmd[offset+2]<<16 ; - ret |= cmd[offset+3]<<24 ; - - return ret; -} - -static void send_command (int s, int command, uint32_t switches, - uint32_t extra, int length, - char *data) -{ - command_t cmd; - int len8; - - len8 = (length + 7) / 8; - - cmd.num_bytes = 0; - - put_32 (&cmd, 0x00000001); /* start sequence */ - put_32 (&cmd, 0xB00BFACE); /* #-)) */ - put_32 (&cmd, len8*8 + 32); - put_32 (&cmd, 0x20534d4d); /* protocol type "MMS " */ - put_32 (&cmd, len8 + 4); - put_32 (&cmd, seq_num); - seq_num++; - put_32 (&cmd, 0x0); /* unknown */ - put_32 (&cmd, 0x0); - put_32 (&cmd, len8+2); - put_32 (&cmd, 0x00030000 | command); /* dir | command */ - put_32 (&cmd, switches); - put_32 (&cmd, extra); - - memcpy (&cmd.buf[48], data, length); - if (length & 7) - memset(&cmd.buf[48 + length], 0, 8 - (length & 7)); - - if (send (s, cmd.buf, len8*8+48, 0) != (len8*8+48)) { - MSG_ERR ("write error\n"); - } -} - -#ifdef USE_ICONV -static iconv_t url_conv; -#endif - -static void string_utf16(char *dest, char *src, int len) -{ - int i; -#ifdef USE_ICONV - size_t len1, len2; - char *ip, *op; - - if (url_conv != (iconv_t)(-1)) - { - memset(dest, 0, 1000); - len1 = len; len2 = 1000; - ip = src; op = dest; - - iconv(url_conv, &ip, &len1, &op, &len2); - } - else - { -#endif - if (len > 499) len = 499; - for (i=0; i<len; i++) { - dest[i*2] = src[i]; - dest[i*2+1] = 0; - } - /* trailing zeroes */ - dest[i*2] = 0; - dest[i*2+1] = 0; -#ifdef USE_ICONV - } -#endif -} - -static void get_answer (int s) -{ - char data[BUF_SIZE]; - int command = 0x1b; - - while (command == 0x1b) { - int len; - - len = recv (s, data, BUF_SIZE, 0) ; - if (!len) { - MSG_ERR ("\nalert! eof\n"); - return; - } - - command = get_32 (data, 36) & 0xFFFF; - - if (command == 0x1b) - send_command (s, 0x1b, 0, 0, 0, data); - } -} - -static int get_data (int s, char *buf, size_t count) -{ - ssize_t len; - size_t total = 0; - - while (total < count) { - - len = recv (s, &buf[total], count-total, 0); - - if (len<=0) { - MSG_ERR ("read error:"); - return 0; - } - - total += len; - - if (len != 0) { -// printf ("[%d/%d]", total, count); - fflush (stdout); - } - - } - - return 1; - -} - -static int get_header (int s, uint8_t *header, streaming_ctrl_t *streaming_ctrl) -{ - unsigned char pre_header[8]; - int header_len; - - header_len = 0; - - while (1) { - if (!get_data (s, pre_header, 8)) { - MSG_ERR ("pre-header read failed\n"); - return 0; - } - if (pre_header[4] == 0x02) { - - int packet_len; - - packet_len = (pre_header[7] << 8 | pre_header[6]) - 8; - -// printf ("asf header packet detected, len=%d\n", packet_len); - - if (packet_len < 0 || packet_len > HDR_BUF_SIZE - header_len) { - MSG_FATAL("Invalid header size, giving up\n"); - return 0; - } - - if (!get_data (s, &header[header_len], packet_len)) { - MSG_ERR("header data read failed\n"); - return 0; - } - - header_len += packet_len; - - if ( (header[header_len-1] == 1) && (header[header_len-2]==1)) { - - - if( streaming_bufferize( streaming_ctrl, header, header_len )<0 ) { - return -1; - } - - // printf ("get header packet finished\n"); - - return (header_len); - - } - - } else { - - int32_t packet_len; - int command; - char data[BUF_SIZE]; - - if (!get_data (s, (char*)&packet_len, 4)) { - MSG_ERR ("packet_len read failed\n"); - return 0; - } - - packet_len = get_32 ((unsigned char*)&packet_len, 0) + 4; - -// printf ("command packet detected, len=%d\n", packet_len); - - if (packet_len < 0 || packet_len > BUF_SIZE) { - MSG_FATAL("Invalid rtsp packet size, giving up\n"); - return 0; - } - - if (!get_data (s, data, packet_len)) { - MSG_ERR ("command data read failed\n"); - return 0; - } - - command = get_32 (data, 24) & 0xFFFF; - -// printf ("command: %02x\n", command); - - if (command == 0x1b) - send_command (s, 0x1b, 0, 0, 0, data); - - } - -// printf ("get header packet succ\n"); - } -} - -static int interp_header (uint8_t *header, int header_len) -{ - int i; - int packet_length=-1; - - /* - * parse header - */ - - i = 30; - while (i<header_len) { - - uint64_t guid_1, guid_2, length; - - guid_2 = (uint64_t)header[i] | ((uint64_t)header[i+1]<<8) - | ((uint64_t)header[i+2]<<16) | ((uint64_t)header[i+3]<<24) - | ((uint64_t)header[i+4]<<32) | ((uint64_t)header[i+5]<<40) - | ((uint64_t)header[i+6]<<48) | ((uint64_t)header[i+7]<<56); - i += 8; - - guid_1 = (uint64_t)header[i] | ((uint64_t)header[i+1]<<8) - | ((uint64_t)header[i+2]<<16) | ((uint64_t)header[i+3]<<24) - | ((uint64_t)header[i+4]<<32) | ((uint64_t)header[i+5]<<40) - | ((uint64_t)header[i+6]<<48) | ((uint64_t)header[i+7]<<56); - i += 8; - -// printf ("guid found: %016llx%016llx\n", guid_1, guid_2); - - length = (uint64_t)header[i] | ((uint64_t)header[i+1]<<8) - | ((uint64_t)header[i+2]<<16) | ((uint64_t)header[i+3]<<24) - | ((uint64_t)header[i+4]<<32) | ((uint64_t)header[i+5]<<40) - | ((uint64_t)header[i+6]<<48) | ((uint64_t)header[i+7]<<56); - - i += 8; - - if ( (guid_1 == 0x6cce6200aa00d9a6ULL) && (guid_2 == 0x11cf668e75b22630ULL) ) { - MSG_V ("header object\n"); - } else if ((guid_1 == 0x6cce6200aa00d9a6ULL) && (guid_2 == 0x11cf668e75b22636ULL)) { - MSG_V ("data object\n"); - } else if ((guid_1 == 0x6553200cc000e48eULL) && (guid_2 == 0x11cfa9478cabdca1ULL)) { - - packet_length = get_32(header, i+92-24); - - MSG_V ("file object, packet length = %d (%d)\n", - packet_length, get_32(header, i+96-24)); - - - } else if ((guid_1 == 0x6553200cc000e68eULL) && (guid_2 == 0x11cfa9b7b7dc0791ULL)) { - - int stream_id = header[i+48] | header[i+49] << 8; - - MSG_V ("stream object, stream id: %d\n", stream_id); - - if (num_stream_ids < MAX_STREAMS) { - stream_ids[num_stream_ids] = stream_id; - num_stream_ids++; - } else { - MSG_ERR("asf_mmst: too many id, stream skipped"); - } - - } else { - MSG_V ("unknown object\n"); - } - -// printf ("length : %lld\n", length); - - i += length-24; - - } - - return packet_length; - -} - - -static int get_media_packet (int s, int padding, streaming_ctrl_t *stream_ctrl) { - unsigned char pre_header[8]; - char data[BUF_SIZE]; - - if (!get_data (s, pre_header, 8)) { - MSG_ERR ("pre-header read failed\n"); - return 0; - } - -// for (i=0; i<8; i++) -// printf ("pre_header[%d] = %02x (%d)\n", -// i, pre_header[i], pre_header[i]); - - if (pre_header[4] == 0x04) { - - int packet_len; - - packet_len = (pre_header[7] << 8 | pre_header[6]) - 8; - -// printf ("asf media packet detected, len=%d\n", packet_len); - - if (packet_len < 0 || packet_len > BUF_SIZE) { - MSG_FATAL("Invalid rtsp packet size, giving up\n"); - return 0; - } - - if (!get_data (s, data, packet_len)) { - MSG_ERR ("media data read failed\n"); - return 0; - } - - streaming_bufferize(stream_ctrl, data, padding); - - } else { - - int32_t packet_len; - int command; - - if (!get_data (s, (char*)&packet_len, 4)) { - MSG_ERR ("packet_len read failed\n"); - return 0; - } - - packet_len = get_32 ((unsigned char*)&packet_len, 0) + 4; - - if (packet_len < 0 || packet_len > BUF_SIZE) { - MSG_FATAL("Invalid rtsp packet size, giving up\n"); - return 0; - } - - if (!get_data (s, data, packet_len)) { - MSG_ERR ("command data read failed\n"); - return 0; - } - - if ( (pre_header[7] != 0xb0) || (pre_header[6] != 0x0b) - || (pre_header[5] != 0xfa) || (pre_header[4] != 0xce) ) { - - MSG_ERR ("missing signature\n"); - return -1; - } - - command = get_32 (data, 24) & 0xFFFF; - -// printf ("\ncommand packet detected, len=%d cmd=0x%X\n", packet_len, command); - - if (command == 0x1b) - send_command (s, 0x1b, 0, 0, 0, data); - else if (command == 0x1e) { - MSG_OK ("everything done. Thank you for downloading a media file containing proprietary and patentend technology.\n"); - return 0; - } - else if (command == 0x21 ) { - // Looks like it's new in WMS9 - // Unknown command, but ignoring it seems to work. - return 0; - } - else if (command != 0x05) { - MSG_ERR ("unknown command %02x\n", command); - return -1; - } - } - -// printf ("get media packet succ\n"); - - return 1; -} - - -static int packet_length1; - -static int asf_mmst_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *stream_ctrl ) -{ - int len; - - while( stream_ctrl->buffer_size==0 ) { - // buffer is empty - fill it! - int ret = get_media_packet( fd, packet_length1, stream_ctrl); - if( ret<0 ) { - MSG_ERR("get_media_packet error : %s\n",strerror(errno)); - return -1; - } else if (ret==0) //EOF? - return ret; - } - - len = stream_ctrl->buffer_size-stream_ctrl->buffer_pos; - if(len>size) len=size; - memcpy( buffer, (stream_ctrl->buffer)+(stream_ctrl->buffer_pos), len ); - stream_ctrl->buffer_pos += len; - if( stream_ctrl->buffer_pos>=stream_ctrl->buffer_size ) { - mp_free( stream_ctrl->buffer ); - stream_ctrl->buffer = NULL; - stream_ctrl->buffer_size = 0; - stream_ctrl->buffer_pos = 0; - } - return len; - -} - -static int asf_mmst_streaming_seek( int fd, off_t pos, streaming_ctrl_t *streaming_ctrl ) -{ - return -1; - // Shut up gcc warning - fd++; - pos++; - streaming_ctrl=NULL; -} - -int asf_mmst_streaming_start(any_t* libinput,stream_t *stream) -{ - char str[1024]; - char data[BUF_SIZE]; - uint8_t asf_header[HDR_BUF_SIZE]; - int asf_header_len; - int len, i, packet_length; - char *path, *unescpath; - URL_t *url1 = stream->streaming_ctrl->url; - int s = stream->fd; - - if( s>0 ) { - closesocket( stream->fd ); - stream->fd = -1; - } - - /* parse url */ - path = strchr(url1->file,'/') + 1; - - /* mmst filename are not url_escaped by MS MediaPlayer and are expected as - * "plain text" by the server, so need to decode it here - */ - unescpath=mp_malloc(strlen(path)+1); - if (!unescpath) { - MSG_FATAL("Memory allocation failed!\n"); - return -1; - } - url_unescape_string(unescpath,path); - path=unescpath; - - if( url1->port==0 ) { - url1->port=1755; - } - s = tcp_connect2Server(libinput, url1->hostname, url1->port, 0); - if( s<0 ) { - mp_free(path); - return s; - } - MSG_INFO ("connected\n"); - - seq_num=0; - - /* - * Send the initial connect info including player version no. Client GUID (random) and the host address being connected to. - * This command is sent at the very start of protocol initiation. It sends local information to the serve - * cmd 1 0x01 - * */ - - /* prepare for the url encoding conversion */ -#ifdef USE_ICONV -#ifdef USE_LANGINFO - url_conv = iconv_open("UTF-16LE",nl_langinfo(CODESET)); -#else - url_conv = iconv_open("UTF-16LE", NULL); -#endif -#endif - - snprintf (str, 1023, "\034\003NSPlayer/7.0.0.1956; {33715801-BAB3-9D85-24E9-03B90328270A}; Host: %s", url1->hostname); - string_utf16 (data, str, strlen(str)); -// send_command(s, commandno ....) - send_command (s, 1, 0, 0x0004000b, strlen(str) * 2+2, data); - - len = recv (s, data, BUF_SIZE, 0) ; - - /*This sends details of the local machine IP address to a Funnel system at the server. - * Also, the TCP or UDP transport selection is sent. - * - * here 192.168.0.129 is local ip address TCP/UDP states the tronsport we r using - * and 1037 is the local TCP or UDP socket number - * cmd 2 0x02 - * */ - - string_utf16 (&data[8], "\002\000\\\\192.168.0.1\\TCP\\1037", 24); - memset (data, 0, 8); - send_command (s, 2, 0, 0, 24*2+10, data); - - len = recv (s, data, BUF_SIZE, 0) ; - - /* This command sends file path (at server) and file name request to the server. - * 0x5 */ - - string_utf16 (&data[8], path, strlen(path)); - memset (data, 0, 8); - send_command (s, 5, 0, 0, strlen(path)*2+10, data); - mp_free(path); - - get_answer (s); - - /* The ASF header chunk request. Includes ?session' variable for pre header value. - * After this command is sent, - * the server replies with 0x11 command and then the header chunk with header data follows. - * 0x15 */ - - memset (data, 0, 40); - data[32] = 2; - - send_command (s, 0x15, 1, 0, 40, data); - - num_stream_ids = 0; - /* get_headers(s, asf_header); */ - - asf_header_len = get_header (s, asf_header, stream->streaming_ctrl); -// printf("---------------------------------- asf_header %d\n",asf_header); - if (asf_header_len==0) { //error reading header - closesocket(s); - return -1; - } - packet_length = interp_header (asf_header, asf_header_len); - - - /* - * This command is the media stream MBR selector. Switches are always 6 bytes in length. - * After all switch elements, data ends with bytes [00 00] 00 20 ac 40 [02]. - * Where: - * [00 00] shows 0x61 0x00 (on the first 33 sent) or 0xff 0xff for ASF files, and with no ending data for WMV files. - * It is not yet understood what all this means. - * And the last [02] byte is probably the header ?session' value. - * - * 0x33 */ - - memset (data, 0, 40); - - if (mp_conf.audio_id > 0) { - data[2] = 0xFF; - data[3] = 0xFF; - data[4] = mp_conf.audio_id; - send_command(s, 0x33, num_stream_ids, 0xFFFF | mp_conf.audio_id << 16, 8, data); - } else { - for (i=1; i<num_stream_ids; i++) { - data [ (i-1) * 6 + 2 ] = 0xFF; - data [ (i-1) * 6 + 3 ] = 0xFF; - data [ (i-1) * 6 + 4 ] = stream_ids[i]; - data [ (i-1) * 6 + 5 ] = 0x00; - } - - send_command (s, 0x33, num_stream_ids, 0xFFFF | stream_ids[0] << 16, (num_stream_ids-1)*6+2 , data); - } - - get_answer (s); - - /* Start sending file from packet xx. - * This command is also used for resume downloads or requesting a lost packet. - * Also used for seeking by sending a play point value which seeks to the media time point. - * Includes ?session' value in pre header and the maximum media stream time. - * 0x07 */ - - memset (data, 0, 40); - - for (i=8; i<16; i++) - data[i] = 0xFF; - - data[20] = 0x04; - - send_command (s, 0x07, 1, 0xFFFF | stream_ids[0] << 16, 24, data); - - stream->fd = s; - stream->streaming_ctrl->streaming_read = asf_mmst_streaming_read; - stream->streaming_ctrl->streaming_seek = asf_mmst_streaming_seek; - stream->streaming_ctrl->buffering = 1; - stream->streaming_ctrl->status = streaming_playing_e; - - packet_length1 = packet_length; - MSG_V("mmst packet_length = %d\n",packet_length); - -#ifdef USE_ICONV - if (url_conv != (iconv_t)(-1)) - iconv_close(url_conv); -#endif - - return 0; -} Copied: mplayerxp/libmpstream/asf_mmst_streaming.cpp (from rev 417, mplayerxp/libmpstream/asf_mmst_streaming.c) =================================================================== --- mplayerxp/libmpstream/asf_mmst_streaming.cpp (rev 0) +++ mplayerxp/libmpstream/asf_mmst_streaming.cpp 2012-11-21 15:49:25 UTC (rev 425) @@ -0,0 +1,664 @@ +// mmst implementation taken from the xine-mms plugin made by majormms (http://geocities.com/majormms/) +// +// ported to mplayer by Abhijeet Phatak <abh...@ya...> +// date : 16 April 2002 +// +// information about the mms protocol can be find at http://get.to/sdp +// + + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> +#include <inttypes.h> + +#include "mp_config.h" +#include "mplayerxp.h" + +#include "tcp.h" +#include "url.h" +#include "libmpdemux/asf.h" +#include "stream.h" + +#include "network.h" + +#ifndef HAVE_WINSOCK2 +#define closesocket close +#else +#include <winsock2.h> +#endif +#ifndef USE_SETLOCALE +#undef USE_ICONV +#endif + +#ifdef USE_ICONV +#ifdef HAVE_GICONV +#include <giconv.h> +#else +#include <iconv.h> +#endif +#ifdef USE_LANGINFO +#include <langinfo.h> +#endif +#endif +#include "stream_msg.h" +#include "osdep/mplib.h" + +#define BUF_SIZE 102400 +#define HDR_BUF_SIZE 8192 +#define MAX_STREAMS 20 + +typedef struct +{ + uint8_t buf[BUF_SIZE]; + int num_bytes; + +} command_t; + +static int seq_num; +static int num_stream_ids; +static int stream_ids[MAX_STREAMS]; + +static int get_data (int s,unsigned char *buf, size_t count); + +static void put_32 (command_t *cmd, uint32_t value) +{ + cmd->buf[cmd->num_bytes ] = value % 256; + value = value >> 8; + cmd->buf[cmd->num_bytes+1] = value % 256 ; + value = value >> 8; + cmd->buf[cmd->num_bytes+2] = value % 256 ; + value = value >> 8; + cmd->buf[cmd->num_bytes+3] = value % 256 ; + + cmd->num_bytes += 4; +} + +static uint32_t get_32 (unsigned char *cmd, int offset) +{ + uint32_t ret; + + ret = cmd[offset] ; + ret |= cmd[offset+1]<<8 ; + ret |= cmd[offset+2]<<16 ; + ret |= cmd[offset+3]<<24 ; + + return ret; +} + +static void send_command (int s, int command, uint32_t switches, + uint32_t extra, int length, + unsigned char *data) +{ + command_t cmd; + int len8; + + len8 = (length + 7) / 8; + + cmd.num_bytes = 0; + + put_32 (&cmd, 0x00000001); /* start sequence */ + put_32 (&cmd, 0xB00BFACE); /* #-)) */ + put_32 (&cmd, len8*8 + 32); + put_32 (&cmd, 0x20534d4d); /* protocol type "MMS " */ + put_32 (&cmd, len8 + 4); + put_32 (&cmd, seq_num); + seq_num++; + put_32 (&cmd, 0x0); /* unknown */ + put_32 (&cmd, 0x0); + put_32 (&cmd, len8+2); + put_32 (&cmd, 0x00030000 | command); /* dir | command */ + put_32 (&cmd, switches); + put_32 (&cmd, extra); + + memcpy (&cmd.buf[48], data, length); + if (length & 7) + memset(&cmd.buf[48 + length], 0, 8 - (length & 7)); + + if (send (s, cmd.buf, len8*8+48, 0) != (len8*8+48)) { + MSG_ERR ("write error\n"); + } +} + +#ifdef USE_ICONV +static iconv_t url_conv; +#endif + +static void string_utf16(unsigned char *dest,const char *src, int len) +{ + int i; +#ifdef USE_ICONV + size_t len1, len2; + char *ip, *op; + + if (url_conv != (iconv_t)(-1)) + { + memset(dest, 0, 1000); + len1 = len; len2 = 1000; + ip = src; op = dest; + + iconv(url_conv, &ip, &len1, &op, &len2); + } + else + { +#endif + if (len > 499) len = 499; + for (i=0; i<len; i++) { + dest[i*2] = src[i]; + dest[i*2+1] = 0; + } + /* trailing zeroes */ + dest[i*2] = 0; + dest[i*2+1] = 0; +#ifdef USE_ICONV + } +#endif +} + +static void get_answer (int s) +{ + unsigned char data[BUF_SIZE]; + int command = 0x1b; + + while (command == 0x1b) { + int len; + + len = recv (s, data, BUF_SIZE, 0) ; + if (!len) { + MSG_ERR ("\nalert! eof\n"); + return; + } + + command = get_32 (data, 36) & 0xFFFF; + + if (command == 0x1b) + send_command (s, 0x1b, 0, 0, 0, data); + } +} + +static int get_data (int s,unsigned char *buf, size_t count) +{ + ssize_t len; + size_t total = 0; + + while (total < count) { + + len = recv (s, &buf[total], count-total, 0); + + if (len<=0) { + MSG_ERR ("read error:"); + return 0; + } + + total += len; + + if (len != 0) { +// printf ("[%d/%d]", total, count); + fflush (stdout); + } + + } + + return 1; + +} + +static int get_header (int s, uint8_t *header, streaming_ctrl_t *streaming_ctrl) +{ + unsigned char pre_header[8]; + int header_len; + + header_len = 0; + + while (1) { + if (!get_data (s, pre_header, 8)) { + MSG_ERR ("pre-header read failed\n"); + return 0; + } + if (pre_header[4] == 0x02) { + + int packet_len; + + packet_len = (pre_header[7] << 8 | pre_header[6]) - 8; + +// printf ("asf header packet detected, len=%d\n", packet_len); + + if (packet_len < 0 || packet_len > HDR_BUF_SIZE - header_len) { + MSG_FATAL("Invalid header size, giving up\n"); + return 0; + } + + if (!get_data (s, &header[header_len], packet_len)) { + MSG_ERR("header data read failed\n"); + return 0; + } + + header_len += packet_len; + + if ( (header[header_len-1] == 1) && (header[header_len-2]==1)) { + + + if( streaming_bufferize( streaming_ctrl, header, header_len )<0 ) { + return -1; + } + + // printf ("get header packet finished\n"); + + return (header_len); + + } + + } else { + + int32_t packet_len; + int command; + unsigned char data[BUF_SIZE]; + + if (!get_data (s, (unsigned char*)&packet_len, 4)) { + MSG_ERR ("packet_len read failed\n"); + return 0; + } + + packet_len = get_32 ((unsigned char*)&packet_len, 0) + 4; + +// printf ("command packet detected, len=%d\n", packet_len); + + if (packet_len < 0 || packet_len > BUF_SIZE) { + MSG_FATAL("Invalid rtsp packet size, giving up\n"); + return 0; + } + + if (!get_data (s, data, packet_len)) { + MSG_ERR ("command data read failed\n"); + return 0; + } + + command = get_32 (data, 24) & 0xFFFF; + +// printf ("command: %02x\n", command); + + if (command == 0x1b) + send_command (s, 0x1b, 0, 0, 0, data); + + } + +// printf ("get header packet succ\n"); + } +} + +static int interp_header (uint8_t *header, int header_len) +{ + int i; + int packet_length=-1; + + /* + * parse header + */ + + i = 30; + while (i<header_len) { + + uint64_t guid_1, guid_2, length; + + guid_2 = (uint64_t)header[i] | ((uint64_t)header[i+1]<<8) + | ((uint64_t)header[i+2]<<16) | ((uint64_t)header[i+3]<<24) + | ((uint64_t)header[i+4]<<32) | ((uint64_t)header[i+5]<<40) + | ((uint64_t)header[i+6]<<48) | ((uint64_t)header[i+7]<<56); + i += 8; + + guid_1 = (uint64_t)header[i] | ((uint64_t)header[i+1]<<8) + | ((uint64_t)header[i+2]<<16) | ((uint64_t)header[i+3]<<24) + | ((uint64_t)header[i+4]<<32) | ((uint64_t)header[i+5]<<40) + | ((uint64_t)header[i+6]<<48) | ((uint64_t)header[i+7]<<56); + i += 8; + +// printf ("guid found: %016llx%016llx\n", guid_1, guid_2); + + length = (uint64_t)header[i] | ((uint64_t)header[i+1]<<8) + | ((uint64_t)header[i+2]<<16) | ((uint64_t)header[i+3]<<24) + | ((uint64_t)header[i+4]<<32) | ((uint64_t)header[i+5]<<40) + | ((uint64_t)header[i+6]<<48) | ((uint64_t)header[i+7]<<56); + + i += 8; + + if ( (guid_1 == 0x6cce6200aa00d9a6ULL) && (guid_2 == 0x11cf668e75b22630ULL) ) { + MSG_V ("header object\n"); + } else if ((guid_1 == 0x6cce6200aa00d9a6ULL) && (guid_2 == 0x11cf668e75b22636ULL)) { + MSG_V ("data object\n"); + } else if ((guid_1 == 0x6553200cc000e48eULL) && (guid_2 == 0x11cfa9478cabdca1ULL)) { + + packet_length = get_32(header, i+92-24); + + MSG_V ("file object, packet length = %d (%d)\n", + packet_length, get_32(header, i+96-24)); + + + } else if ((guid_1 == 0x6553200cc000e68eULL) && (guid_2 == 0x11cfa9b7b7dc0791ULL)) { + + int stream_id = header[i+48] | header[i+49] << 8; + + MSG_V ("stream object, stream id: %d\n", stream_id); + + if (num_stream_ids < MAX_STREAMS) { + stream_ids[num_stream_ids] = stream_id; + num_stream_ids++; + } else { + MSG_ERR("asf_mmst: too many id, stream skipped"); + } + + } else { + MSG_V ("unknown object\n"); + } + +// printf ("length : %lld\n", length); + + i += length-24; + + } + + return packet_length; + +} + + +static int get_media_packet (int s, int padding, streaming_ctrl_t *stream_ctrl) { + unsigned char pre_header[8]; + unsigned char data[BUF_SIZE]; + + if (!get_data (s, pre_header, 8)) { + MSG_ERR ("pre-header read failed\n"); + return 0; + } + +// for (i=0; i<8; i++) +// printf ("pre_header[%d] = %02x (%d)\n", +// i, pre_header[i], pre_header[i]); + + if (pre_header[4] == 0x04) { + + int packet_len; + + packet_len = (pre_header[7] << 8 | pre_header[6]) - 8; + +// printf ("asf media packet detected, len=%d\n", packet_len); + + if (packet_len < 0 || packet_len > BUF_SIZE) { + MSG_FATAL("Invalid rtsp packet size, giving up\n"); + return 0; + } + + if (!get_data (s, data, packet_len)) { + MSG_ERR ("media data read failed\n"); + return 0; + } + + streaming_bufferize(stream_ctrl, data, padding); + + } else { + + int32_t packet_len; + int command; + + if (!get_data (s, (unsigned char*)&packet_len, 4)) { + MSG_ERR ("packet_len read failed\n"); + return 0; + } + + packet_len = get_32 ((unsigned char*)&packet_len, 0) + 4; + + if (packet_len < 0 || packet_len > BUF_SIZE) { + MSG_FATAL("Invalid rtsp packet size, giving up\n"); + return 0; + } + + if (!get_data (s, data, packet_len)) { + MSG_ERR ("command data read failed\n"); + return 0; + } + + if ( (pre_header[7] != 0xb0) || (pre_header[6] != 0x0b) + || (pre_header[5] != 0xfa) || (pre_header[4] != 0xce) ) { + + MSG_ERR ("missing signature\n"); + return -1; + } + + command = get_32 (data, 24) & 0xFFFF; + +// printf ("\ncommand packet detected, len=%d cmd=0x%X\n", packet_len, command); + + if (command == 0x1b) + send_command (s, 0x1b, 0, 0, 0, data); + else if (command == 0x1e) { + MSG_OK ("everything done. Thank you for downloading a media file containing proprietary and patentend technology.\n"); + return 0; + } + else if (command == 0x21 ) { + // Looks like it's new in WMS9 + // Unknown command, but ignoring it seems to work. + return 0; + } + else if (command != 0x05) { + MSG_ERR ("unknown command %02x\n", command); + return -1; + } + } + +// printf ("get media packet succ\n"); + + return 1; +} + + +static int packet_length1; + +static int asf_mmst_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *stream_ctrl ) +{ + int len; + + while( stream_ctrl->buffer_size==0 ) { + // buffer is empty - fill it! + int ret = get_media_packet( fd, packet_length1, stream_ctrl); + if( ret<0 ) { + MSG_ERR("get_media_packet error : %s\n",strerror(errno)); + return -1; + } else if (ret==0) //EOF? + return ret; + } + + len = stream_ctrl->buffer_size-stream_ctrl->buffer_pos; + if(len>size) len=size; + memcpy( buffer, (stream_ctrl->buffer)+(stream_ctrl->buffer_pos), len ); + stream_ctrl->buffer_pos += len; + if( stream_ctrl->buffer_pos>=stream_ctrl->buffer_size ) { + mp_free( stream_ctrl->buffer ); + stream_ctrl->buffer = NULL; + stream_ctrl->buffer_size = 0; + stream_ctrl->buffer_pos = 0; + } + return len; + +} + +static int asf_mmst_streaming_seek( int fd, off_t pos, streaming_ctrl_t *streaming_ctrl ) +{ + return -1; + // Shut up gcc warning + fd++; + pos++; + streaming_ctrl=NULL; +} + +int asf_mmst_streaming_start(any_t* libinput,stream_t *stream) +{ + char str[1024]; + unsigned char data[BUF_SIZE]; + uint8_t asf_header[HDR_BUF_SIZE]; + int asf_header_len; + int len, i, packet_length; + char *path, *unescpath; + URL_t *url1 = stream->streaming_ctrl->url; + int s = stream->fd; + + if( s>0 ) { + closesocket( stream->fd ); + stream->fd = -1; + } + + /* parse url */ + path = strchr(url1->file,'/') + 1; + + /* mmst filename are not url_escaped by MS MediaPlayer and are expected as + * "plain text" by the server, so need to decode it here + */ + unescpath=new char [strlen(path)+1]; + if (!unescpath) { + MSG_FATAL("Memory allocation failed!\n"); + return -1; + } + url_unescape_string(unescpath,path); + path=unescpath; + + if( url1->port==0 ) { + url1->port=1755; + } + s = tcp_connect2Server(libinput, url1->hostname, url1->port, 0); + if( s<0 ) { + mp_free(path); + return s; + } + MSG_INFO ("connected\n"); + + seq_num=0; + + /* + * Send the initial connect info including player version no. Client GUID (random) and the host address being connected to. + * This command is sent at the very start of protocol initiation. It sends local information to the serve + * cmd 1 0x01 + * */ + + /* prepare for the url encoding conversion */ +#ifdef USE_ICONV +#ifdef USE_LANGINFO + url_conv = iconv_open("UTF-16LE",nl_langinfo(CODESET)); +#else + url_conv = iconv_open("UTF-16LE", NULL); +#endif +#endif + + snprintf (str, 1023, "\034\003NSPlayer/7.0.0.1956; {33715801-BAB3-9D85-24E9-03B90328270A}; Host: %s", url1->hostname); + string_utf16 (data, str, strlen(str)); +// send_command(s, commandno ....) + send_command (s, 1, 0, 0x0004000b, strlen(str) * 2+2, data); + + len = recv (s, data, BUF_SIZE, 0) ; + + /*This sends details of the local machine IP address to a Funnel system at the server. + * Also, the TCP or UDP transport selection is sent. + * + * here 192.168.0.129 is local ip address TCP/UDP states the tronsport we r using + * and 1037 is the local TCP or UDP socket number + * cmd 2 0x02 + * */ + + string_utf16 (&data[8], "\002\000\\\\192.168.0.1\\TCP\\1037", 24); + memset (data, 0, 8); + send_command (s, 2, 0, 0, 24*2+10, data); + + len = recv (s, data, BUF_SIZE, 0) ; + + /* This command sends file path (at server) and file name request to the server. + * 0x5 */ + + string_utf16 (&data[8], path, strlen(path)); + memset (data, 0, 8); + send_command (s, 5, 0, 0, strlen(path)*2+10, data); + mp_free(path); + + get_answer (s); + + /* The ASF header chunk request. Includes ?session' variable for pre header value. + * After this command is sent, + * the server replies with 0x11 command and then the header chunk with header data follows. + * 0x15 */ + + memset (data, 0, 40); + data[32] = 2; + + send_command (s, 0x15, 1, 0, 40, data); + + num_stream_ids = 0; + /* get_headers(s, asf_header); */ + + asf_header_len = get_header (s, asf_header, stream->streaming_ctrl); +// printf("---------------------------------- asf_header %d\n",asf_header); + if (asf_header_len==0) { //error reading header + closesocket(s); + return -1; + } + packet_length = interp_header (asf_header, asf_header_len); + + + /* + * This command is the media stream MBR selector. Switches are always 6 bytes in length. + * After all switch elements, data ends with bytes [00 00] 00 20 ac 40 [02]. + * Where: + * [00 00] shows 0x61 0x00 (on the first 33 sent) or 0xff 0xff for ASF files, and with no ending data for WMV files. + * It is not yet understood what all this means. + * And the last [02] byte is probably the header ?session' value. + * + * 0x33 */ + + memset (data, 0, 40); + + if (mp_conf.audio_id > 0) { + data[2] = 0xFF; + data[3] = 0xFF; + data[4] = mp_conf.audio_id; + send_command(s, 0x33, num_stream_ids, 0xFFFF | mp_conf.audio_id << 16, 8, data); + } else { + for (i=1; i<num_stream_ids; i++) { + data [ (i-1) * 6 + 2 ] = 0xFF; + data [ (i-1) * 6 + 3 ] = 0xFF; + data [ (i-1) * 6 + 4 ] = stream_ids[i]; + data [ (i-1) * 6 + 5 ] = 0x00; + } + + send_command (s, 0x33, num_stream_ids, 0xFFFF | stream_ids[0] << 16, (num_stream_ids-1)*6+2 , data); + } + + get_answer (s); + + /* Start sending file from packet xx. + * This command is also used for resume downloads or requesting a lost packet. + * Also used for seeking by sending a play point value which seeks to the media time point. + * Includes ?session' value in pre header and the maximum media stream time. + * 0x07 */ + + memset (data, 0, 40); + + for (i=8; i<16; i++) + data[i] = 0xFF; + + data[20] = 0x04; + + send_command (s, 0x07, 1, 0xFFFF | stream_ids[0] << 16, 24, data); + + stream->fd = s; + stream->streaming_ctrl->streaming_read = asf_mmst_streaming_read; + stream->streaming_ctrl->streaming_seek = asf_mmst_streaming_seek; + stream->streaming_ctrl->buffering = 1; + stream->streaming_ctrl->status = streaming_playing_e; + + packet_length1 = packet_length; + MSG_V("mmst packet_length = %d\n",packet_length); + +#ifdef USE_ICONV + if (url_conv != (iconv_t)(-1)) + iconv_close(url_conv); +#endif + + return 0; +} Deleted: mplayerxp/libmpstream/asf_streaming.c =================================================================== --- mplayerxp/libmpstream/asf_streaming.c 2012-11-21 14:09:25 UTC (rev 424) +++ mplayerxp/libmpstream/asf_streaming.c 2012-11-21 15:49:25 UTC (rev 425) @@ -1,878 +0,0 @@ -#include <stdio.h> -#include <limits.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <errno.h> - -#include "mp_config.h" -#include "mplayerxp.h" -#ifndef HAVE_WINSOCK2 -#define closesocket close -#else -#include <winsock2.h> -#endif - -#include "url.h" -#include "tcp.h" -#include "http.h" -#include "libmpdemux/asf.h" - -#include "stream.h" - -#include "network.h" -#include "stream_msg.h" -#include "osdep/mplib.h" - -#if defined( ARCH_X86 ) || defined(ARCH_X86_64) -#define ASF_LOAD_GUID_PREFIX(guid) (*(uint32_t *)(guid)) -#else -#define ASF_LOAD_GUID_PREFIX(guid) \ - ((guid)[3] << 24 | (guid)[2] << 16 | (guid)[1] << 8 | (guid)[0]) -#endif - -// ASF streaming support several network protocol. -// One use UDP, not known, yet! -// Another is HTTP, this one is known. -// So for now, we use the HTTP protocol. -// -// We can try several protocol for asf streaming -// * first the UDP protcol, if there is a firewall, UDP -// packets will not come back, so the mmsu will failed. -// * Then we can try TCP, but if there is a proxy for -// internet connection, the TCP connection will not get -// through -// * Then we can try HTTP. -// -// Note: MMS/HTTP support is now a "well known" support protocol, -// it has been tested for while, not like MMST support. -// WMP sequence is MMSU then MMST and then HTTP. -// In MPlayer case since HTTP support is more reliable, -// we are doing HTTP first then we try MMST if HTTP fail. -static int asf_http_streaming_start(any_t*,stream_t *stream, int *demuxer_type ); -int asf_mmst_streaming_start(stream_t *stream ); - -/* - ASF streaming support several network protocol. - One use UDP, not known, yet! - Another is HTTP, this one is known. - So for now, we use the HTTP protocol. - - We can try several protocol for asf streaming - * first the UDP protcol, if there is a firewall, UDP - packets will not come back, so the mmsu will failed. - * Then we can try TCP, but if there is a proxy for - internet connection, the TCP connection will not get - through - * Then we can try HTTP. - - Note: MMS/HTTP support is now a "well known" support protocol, - it has been tested for while, not like MMST support. - WMP sequence is MMSU then MMST and then HTTP. - In MPlayer case since HTTP support is more reliable, - we are doing HTTP first then we try MMST if HTTP fail. -*/ -int asf_streaming_start(any_t* libinput, stream_t *stream, int *demuxer_type) { - char *proto = stream->streaming_ctrl->url->protocol; - int fd = -1; - int port = stream->streaming_ctrl->url->port; - - // Is protocol even valid mms,mmsu,mmst,http,http_proxy? - if (!(!strncasecmp(proto, "mmst", 4) || !strncasecmp(proto, "mmsu", 4) || - !strncasecmp(proto, "http_proxy", 10) || !strncasecmp(proto, "mms", 3) || - !strncasecmp(proto, "http", 4))) - { - MSG_ERR("Unknown protocol: %s\n", proto ); - return -1; - } - - // Is protocol mms or mmsu? - if (!strncasecmp(proto, "mmsu", 4) || !strncasecmp(proto, "mms", 3)) - { - MSG_V("Trying ASF/UDP...\n"); - //fd = asf_mmsu_streaming_start( stream ); - if( fd>-1 ) return fd; //mmsu support is not implemented yet - using this code - MSG_V(" ===> ASF/UDP failed\n"); - if( fd==-2 ) return -1; - } - - //Is protocol mms or mmst? - if (!strncasecmp(proto, "mmst", 4) || !strncasecmp(proto, "mms", 3)) - { - MSG_V("Trying ASF/TCP...\n"); - fd = asf_mmst_streaming_start( stream ); - stream->streaming_ctrl->url->port = port; - if( fd>-1 ) return fd; - MSG_V(" ===> ASF/TCP failed\n"); - if( fd==-2 ) return -1; - } - - //Is protocol http, http_proxy, or mms? - if (!strncasecmp(proto, "http_proxy", 10) || !strncasecmp(proto, "http", 4) || - !strncasecmp(proto, "mms", 3)) - { - MSG_V("Trying ASF/HTTP...\n"); - fd = asf_http_streaming_start(libinput, stream, demuxer_type ); - stream->streaming_ctrl->url->port = port; - if( fd>-1 ) return fd; - MSG_V(" ===> ASF/HTTP failed\n"); - if( fd==-2 ) return -1; - } - - //everything failed - return -1; -} - -int -asf_streaming(ASF_stream_chunck_t *stream_chunck, int *drop_packet ) { - if( drop_packet!=NULL ) *drop_packet = 0; - - if( stream_chunck->size<8 ) { - MSG_ERR("Ahhhh, stream_chunck size is too small: %d\n", stream_chunck->size); - return -1; - } - if( stream_chunck->size!=stream_chunck->size_confirm ) { - MSG_ERR("size_confirm mismatch!: %d %d\n", stream_chunck->size, stream_chunck->size_confirm); - return -1; - } - switch(stream_chunck->type) { - case ASF_STREAMING_CLEAR: // $C Clear ASF configuration - MSG_V("=====> Clearing ASF stream configuration!\n"); - if( drop_packet!=NULL ) *drop_packet = 1; - return stream_chunck->size; - break; - case ASF_STREAMING_DATA: // $D Data follows - break; - case ASF_STREAMING_END_TRANS: // $E Transfer complete - MSG_V("=====> Transfer complete\n"); - if( drop_packet!=NULL ) *drop_packet = 1; - return stream_chunck->size; - break; - case ASF_STREAMING_HEADER: // $H ASF header chunk follows - MSG_V("=====> ASF header chunk follows\n"); - break; - default: - MSG_V("=====> Unknown stream type 0x%x\n", stream_chunck->type ); - } - return stream_chunck->size+4; -} - -static const char asf_stream_header_guid[16] = {0x91, 0x07, 0xdc, 0xb7, - 0xb7, 0xa9, 0xcf, 0x11, 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}; -static const char asf_file_header_guid[16] = {0xa1, 0xdc, 0xab, 0x8c, - 0x47, 0xa9, 0xcf, 0x11, 0x8e, 0xe4, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}; -static const char asf_content_desc_guid[16] = {0x33, 0x26, 0xb2, 0x75, - 0x8e, 0x66, 0xcf, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}; -static const char asf_stream_group_guid[16] = {0xce, 0x75, 0xf8, 0x7b, - 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2}; -static const char asf_data_chunk_guid[16] = {0x36, 0x26, 0xb2, 0x75, - 0x8e, 0x66, 0xcf, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}; -static int find_asf_guid(char *buf, const char *guid, int cur_pos, int buf_len) -{ - int i; - for (i = cur_pos; i < buf_len - 19; i++) { - if (memcmp(&buf[i], guid, 16) == 0) - return i + 16 + 8; // point after guid + length - } - return -1; -} - -static int max_idx(int s_count, int *s_rates, int bound) { - int i, best = -1, rate = -1; - for (i = 0; i < s_count; i++) { - if (s_rates[i] > rate && s_rates[i] <= bound) { - rate = s_rates[i]; - best = i; - } - } - return best; -} - -static int -asf_streaming_parse_header(int fd, streaming_ctrl_t* streaming_ctrl) { - ASF_header_t asfh; - ASF_stream_chunck_t chunk; - asf_http_streaming_ctrl_t* asf_ctrl = (asf_http_streaming_ctrl_t*) streaming_ctrl->data; - char* buffer=NULL, *chunk_buffer=NULL; - int i,r,size,pos = 0; - int start; - int buffer_size = 0; - int chunk_size2read = 0; - int bw = streaming_ctrl->bandwidth; - int *v_rates = NULL, *a_rates = NULL; - int v_rate = 0, a_rate = 0, a_idx = -1, v_idx = -1; - - if(asf_ctrl == NULL) return -1; - - // The ASF header can be in several network chunks. For example if the content description - // is big, the ASF header will be split in 2 network chunk. - // So we need to retrieve all the chunk before starting to parse the header. - do { - for( r=0; r < (int)sizeof(ASF_stream_chunck_t) ; ) { - i = nop_streaming_read(fd,((char*)&chunk)+r,sizeof(ASF_stream_chunck_t) - r,streaming_ctrl); - if(i <= 0) return -1; - r += i; - } - // Endian handling of the stream chunk - le2me_ASF_stream_chunck_t(&chunk); - size = asf_streaming( &chunk, &r) - sizeof(ASF_stream_chunck_t); - if(r) MSG_WARN("Warning : drop header ????\n"); - if(size < 0){ - MSG_ERR("Error while parsing chunk header\n"); - return -1; - } - if (chunk.type != ASF_STREAMING_HEADER) { - MSG_ERR("Don't got a header as first chunk !!!!\n"); - return -1; - } - - // audit: do not overflow buffer_size - if (size > SIZE_MAX - buffer_size) return -1; - buffer = (char*) mp_malloc(size+buffer_size); - if(buffer == NULL) { - MSG_FATAL("Error can't allocate %d bytes buffer\n",size+buffer_size); - return -1; - } - if( chunk_buffer!=NULL ) { - memcpy( buffer, chunk_buffer, buffer_size ); - mp_free( chunk_buffer ); - } - chunk_buffer = buffer; - buffer += buffer_size; - buffer_size += size; - - for(r = 0; r < size;) { - i = nop_streaming_read(fd,buffer+r,size-r,streaming_ctrl); - if(i < 0) { - MSG_ERR("Error while reading network stream\n"); - return -1; - } - r += i; - } - - if( chunk_size2read==0 ) { - if(size < (int)sizeof(asfh)) { - MSG_ERR("Error chunk is too small\n"); - return -1; - } else MSG_DBG2("Got chunk\n"); - memcpy(&asfh,buffer,sizeof(asfh)); - le2me_ASF_header_t(&asfh); - chunk_size2read = asfh.objh.size; - MSG_DBG2("Size 2 read=%d\n", chunk_size2read); - } - } while( buffer_size<chunk_size2read); - buffer = chunk_buffer; - size = buffer_size; - - if(asfh.cno > 256) { - MSG_ERR("Error sub chunks number is invalid\n"); - return -1; - } - - start = sizeof(asfh); - - pos = find_asf_guid(buffer, asf_file_header_guid, start, size); - if (pos >= 0) { - ASF_file_header_t *fileh = (ASF_file_header_t *) &buffer[pos]; - pos += sizeof(ASF_file_header_t); - if (pos > size) goto len_err_out; - le2me_ASF_file_header_t(fileh); -/* - if(fileh.packetsize != fileh.packetsize2) { - printf("Error packetsize check don't match\n"); - return -1; - } -*/ - asf_ctrl->packet_size = fileh->max_packet_size; - // before playing. - // preroll: time in ms to bufferize before playing - streaming_ctrl->prebuffer_size = (unsigned int)(((double)fileh->preroll/1000.0)*((double)fileh->max_bitrate/8.0)); - } - - pos = start; - while ((pos = find_asf_guid(buffer, asf_stream_header_guid, pos, size)) >= 0) - { - ASF_stream_header_t *streamh = (ASF_stream_header_t *)&buffer[pos]; - pos += sizeof(ASF_stream_header_t); - if (pos > size) goto len_err_out; - le2me_ASF_stream_header_t(streamh); - switch(ASF_LOAD_GUID_PREFIX(streamh->type)) { - case 0xF8699E40 : // audio stream - if(asf_ctrl->audio_streams == NULL){ - asf_ctrl->audio_streams = (int*)mp_malloc(sizeof(int)); - asf_ctrl->n_audio = 1; - } else { - asf_ctrl->n_audio++; - asf_ctrl->audio_streams = (int*)mp_realloc(asf_ctrl->audio_streams, - asf_ctrl->n_audio*sizeof(int)); - } - asf_ctrl->audio_streams[asf_ctrl->n_audio-1] = streamh->stream_no; - break; - case 0xBC19EFC0 : // video stream - if(asf_ctrl->video_streams == NULL){ - asf_ctrl->video_streams = (int*)mp_malloc(sizeof(int)); - asf_ctrl->n_video = 1; - } else { - asf_ctrl->n_video++; - asf_ctrl->video_streams = (int*)mp_realloc(asf_ctrl->video_streams, - asf_ctrl->n_video*sizeof(int)); - } - asf_ctrl->video_streams[asf_ctrl->n_video-1] = streamh->stream_no; - break; - } - } - - // always allocate to avoid lots of ifs later - v_rates = mp_calloc(asf_ctrl->n_video, sizeof(int)); - a_rates = mp_calloc(asf_ctrl->n_audio, sizeof(int)); - - pos = find_asf_guid(buffer, asf_stream_group_guid, start, size); - if (pos >= 0) { - // stream bitrate properties object - int stream_count; - char *ptr = &buffer[pos]; - - MSG_V("Stream bitrate properties object\n"); - stream_count = le2me_16(*(uint16_t*)ptr); - ptr += sizeof(uint16_t); - if (ptr > &buffer[size]) goto len_err_out; - MSG_V(" stream count=[0x%x][%u]\n", - stream_count, stream_count ); - for( i=0 ; i<stream_count ; i++ ) { - uint32_t rate; - int id; - int j; - id = le2me_16(*(uint16_t*)ptr); - ptr += sizeof(uint16_t); - if (ptr > &buffer[size]) goto len_err_out; - memcpy(&rate, ptr, sizeof(uint32_t));// workaround unaligment bug on sparc - ptr += sizeof(uint32_t); - if (ptr > &buffer[size]) goto len_err_out; - rate = le2me_32(rate); - MSG_V( - " stream id=[0x%x][%u]\n", id, id); - MSG_V( - " max bitrate=[0x%x][%u]\n", rate, rate); - for (j = 0; j < asf_ctrl->n_video; j++) { - if (id == asf_ctrl->video_streams[j]) { - MSG_V(" is video stream\n"); - v_rates[j] = rate; - break; - } - } - for (j = 0; j < asf_ctrl->n_audio; j++) { - if (id == asf_ctrl->audio_streams[j]) { - MSG_V( " is audio stream\n"); - a_rates[j] = rate; - break; - } - } - } - } - mp_free(buffer); - - // automatic stream selection based on bandwidth - if (bw == 0) bw = INT_MAX; - MSG_V( "Max bandwidth set to %d\n", bw); - - if (asf_ctrl->n_audio) { - // find lowest-bitrate audio stream - a_rate = a_rates[0]; - a_idx = 0; - for (i = 0; i < asf_ctrl->n_audio; i++) { - if (a_rates[i] < a_rate) { - a_rate = a_rates[i]; - a_idx = i; - } - } - if (max_idx(asf_ctrl->n_video, v_rates, bw - a_rate) < 0) { - // both audio and video are not possible, try video only next - a_idx = -1; - a_rate = 0; - } - } - // find best video stream - v_idx = max_idx(asf_ctrl->n_video, v_rates, bw - a_rate); - if (v_idx >= 0) - v_rate = v_rates[v_idx]; - - // find best audio stream - a_idx = max_idx(asf_ctrl->n_audio, a_rates, bw - v_rate); - - mp_free(v_rates); - mp_free(a_rates); - - if (a_idx < 0 && v_idx < 0) { - MSG_FATAL( "bandwidth too small, " - "file cannot be played!\n"); - return -1; - } - - if (mp_conf.audio_id > 0) - // a audio stream was forced - asf_ctrl->audio_id = mp_conf.audio_id; - else if (a_idx >= 0) - asf_ctrl->audio_id = asf_ctrl->audio_streams[a_idx]; - else if (asf_ctrl->n_audio) { - MSG_WARN( "bandwidth too small, " - "deselected audio stream\n"); - mp_conf.audio_id = -2; - } - - if (mp_conf.video_id > 0) - // a video stream was forced - asf_ctrl->video_id = mp_conf.video_id; - else if (v_idx >= 0) - asf_ctrl->video_id = asf_ctrl->video_streams[v_idx]; - else if (asf_ctrl->n_video) { - MSG_WARN( "bandwidth too small, " - "deselected video stream\n"); - mp_conf.video_id = -2; - } - - return 1; - -len_err_out: - MSG_FATAL( "Invalid length in ASF header!\n"); - if (buffer) mp_free(buffer); - if (v_rates) mp_free(v_rates); - if (a_rates) mp_free(a_rates); - return -1; -} - -int -asf_http_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *streaming_ctrl ) { - static ASF_stream_chunck_t chunk; - int read,chunk_size = 0; - static int rest = 0, drop_chunk = 0, waiting = 0; - asf_http_streaming_ctrl_t *asf_http_ctrl = (asf_http_streaming_ctrl_t*)streaming_ctrl->data; - - while(1) { - if (rest == 0 && waiting == 0) { - read = 0; - while(read < (int)sizeof(ASF_stream_chunck_t)){ - int r = nop_streaming_read( fd, ((char*)&chunk) + read, - sizeof(ASF_stream_chunck_t)-read, - streaming_ctrl ); - if(r <= 0){ - if( r < 0) - MSG_ERR("Error while reading chunk header\n"); - return -1; - } - read += r; - } - - // Endian handling of the stream chunk - le2me_ASF_stream_chunck_t(&chunk); - chunk_size = asf_streaming( &chunk, &drop_chunk ); - if(chunk_size < 0) { - MSG_ERR("Error while parsing chunk header\n"); - return -1; - } - chunk_size -= sizeof(ASF_stream_chunck_t); - - if(chunk.type != ASF_STREAMING_HEADER && (!drop_chunk)) { - if (asf_http_ctrl->packet_size < chunk_size) { - MSG_ERR("Error chunk_size > packet_size\n"); - return -1; - } - waiting = asf_http_ctrl->packet_size; - } else { - waiting = chunk_size; - } - - } else if (rest){ - chunk_size = rest; - rest = 0; - } - - read = 0; - if ( waiting >= chunk_size) { - if (chunk_size > size){ - rest = chunk_size - size; - chunk_size = size; - } - while(read < chunk_size) { - int got = nop_streaming_read( fd,buffer+read,chunk_size-read,streaming_ctrl ); - if(got <= 0) { - if(got < 0) - MSG_ERR("Error while reading chunk\n"); - return -1; - } - read += got; - } - waiting -= read; - if (drop_chunk) continue; - } - if (rest == 0 && waiting > 0 && size-read > 0) { - int s = MIN(waiting,size-read); - memset(buffer+read,0,s); - waiting -= s; - read += s; - } - break; - } - - return read; -} - -int -asf_http_streaming_seek( int fd, off_t pos, streaming_ctrl_t *streaming_ctrl ) { - return -1; - // to shut up gcc warning - fd++; - pos++; - streaming_ctrl=NULL; -} - -int -asf_header_check( HTTP_header_t *http_hdr ) { - ASF_obj_header_t *objh; - if( http_hdr==NULL ) return -1; - if( http_hdr->body==NULL || http_hdr->body_size<sizeof(ASF_obj_header_t) ) return -1; - - objh = (ASF_obj_header_t*)http_hdr->body; - if( ASF_LOAD_GUID_PREFIX(objh->guid)==0x75B22630 ) return 0; - return -1; -} - -int -asf_http_streaming_type(char *content_type, char *features, HTTP_header_t *http_hdr ) { - if( content_type==NULL ) return ASF_Unknown_e; - if( !strcasecmp(content_type, "application/octet-stream") || - !strcasecmp(content_type, "application/vnd.ms.wms-hdr.asfv1") || // New in Corona, first request - !strcasecmp(content_type, "application/x-mms-framed") || // New in Corana, second request - !strcasecmp(content_type, "video/x-ms-asf")) { - - if( strstr(features, "broadcast") ) { - MSG_V("=====> ASF Live stream\n"); - return ASF_Live_e; - } else { - MSG_V("=====> ASF Prerecorded\n"); - return ASF_Prerecorded_e; - } - } else { - // Ok in a perfect world, web servers should be well configured - // so we could used mime type to know the stream type, - // but guess what? All of them are not well configured. - // So we have to check for an asf header :(, but it works :p - if( http_hdr->body_size>sizeof(ASF_obj_header_t) ) { - if( asf_header_check( http_hdr )==0 ) { - MSG_V("=====> ASF Plain text\n"); - return ASF_PlainText_e; - } else if( (!strcasecmp(content_type, "text/html")) ) { - MSG_V("=====> HTML, mplayer is not a browser...yet!\n"); - return ASF_Unknown_e; - } else { - MSG_V("=====> ASF Redirector\n"); - return ASF_Redirector_e; - } - } else { - if( (!strcasecmp(content_type, "audio/x-ms-wax")) || - (!strcasecmp(content_type, "audio/x-ms-wma")) || - (!strcasecmp(content_type, "video/x-ms-asf")) || - (!strcasecmp(content_type, "video/x-ms-afs")) || - (!strcasecmp(content_type, "video/x-ms-wvx")) || - (!strcasecmp(content_type, "video/x-ms-wmv")) || - (!strcasecmp(content_type, "video/x-ms-wma")) ) { - MSG_ERR("=====> ASF Redirector\n"); - return ASF_Redirector_e; - } else if( !strcasecmp(content_type, "text/plain") ) { - MSG_V("=====> ASF Plain text\n"); - return ASF_PlainText_e; - } else { - MSG_V("=====> ASF unknown content-type: %s\n", content_type ); - return ASF_Unknown_e; - } - } - } - return ASF_Unknown_e; -} - -HTTP_header_t * -asf_http_request(streaming_ctrl_t *streaming_ctrl) { - HTTP_header_t *http_hdr; - URL_t *url = NULL; - URL_t *server_url = NULL; - asf_http_streaming_ctrl_t *asf_http_ctrl; - char str[250]; - char *ptr; - int i, enable; - - int offset_hi=0, offset_lo=0, length=0; - int asf_nb_stream=0, stream_id; - - // Sanity check - if( streaming_ctrl==NULL ) return NULL; - url = streaming_ctrl->url; - asf_http_ctrl = (asf_http_streaming_ctrl_t*)streaming_ctrl->data; - if( url==NULL || asf_http_ctrl==NULL ) return NULL; - - // Common header for all requests. - http_hdr = http_new_header(); - http_set_field( http_hdr, "Accept: */*" ); - http_set_field( http_hdr, "User-Agent: NSPlayer/4.1.0.3856" ); - http_add_basic_authentication( http_hdr, url->username, url->password ); - - // Check if we are using a proxy - if( !strcasecmp( url->protocol, "http_proxy" ) ) { - server_url = url_new( (url->file)+1 ); - if( server_url==NULL ) { - MSG_ERR("Invalid proxy URL\n"); - http_free( http_hdr ); - return NULL; - } - http_set_uri( http_hdr, server_url->url ); - sprintf( str, "Host: %.220s:%d", server_url->hostname, server_url->port ); - url_free( server_url ); - } else { - http_set_uri( http_hdr, url->file ); - sprintf( str, "Host: %.220s:%d", url->hostname, url->port ); - } - - http_set_field( http_hdr, str ); - http_set_field( http_hdr, "Pragma: xClientGUID={c77e7400-738a-11d2-9add-0020af0a3278}" ); - sprintf(str, - "Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=%u:%u,request-context=%d,max-duration=%u", - offset_hi, offset_lo, asf_http_ctrl->request, length ); - http_set_field( http_hdr, str ); - - switch( asf_http_ctrl->streaming_type ) { - case ASF_Live_e: - case ASF_Prerecorded_e: - http_set_field( http_hdr, "Pragma: xPlayStrm=1" ); - ptr = str; - ptr += sprintf( ptr, "Pragma: stream-switch-entry="); - if(asf_http_ctrl->n_audio > 0) { - for( i=0; i<asf_http_ctrl->n_audio ; i++ ) { - stream_id = asf_http_ctrl->audio_streams[i]; - if(stream_id == asf_http_ctrl->audio_id) { - enable = 0; - } else { - enable = 2; - continue; - } - asf_nb_stream++; - ptr += sprintf(ptr, "ffff:%d:%d ", stream_id, enable); - } - } - if(asf_http_ctrl->n_video > 0) { - for( i=0; i<asf_http_ctrl->n_video ; i++ ) { - stream_id = asf_http_ctrl->video_streams[i]; - if(stream_id == asf_http_ctrl->video_id) { - enable = 0; - } else { - enable = 2; - continue; - } - asf_nb_stream++; - ptr += sprintf(ptr, "ffff:%d:%d ", stream_id, enable); - } - } - http_set_field( http_hdr, str ); - sprintf( str, "Pragma: stream-switch-count=%d", asf_nb_stream ); - http_set_field( http_hdr, str ); - break; - case ASF_Redirector_e: - break; - case ASF_Unknown_e: - // First request goes here. - break; - default: - MSG_ERR("Unknown asf stream type\n"); - } - - http_set_field( http_hdr, "Connection: Close" ); - http_build_request( http_hdr ); - - return http_hdr; -} - -int -asf_http_parse_response(asf_http_streaming_ctrl_t *asf_http_ctrl, HTTP_header_t *http_hdr ) { - char *content_type, *pragma; - char features[64] = "\0"; - size_t len; - if( http_response_parse(http_hdr)<0 ) { - MSG_ERR("Failed to parse HTTP response\n"); - return -1; - } - switch( http_hdr->status_code ) { - case 200: - break; - case 401: // Authentication required - return ASF_Authenticate_e; - default: - MSG_ERR("Server return %d:%s\n", http_hdr->status_code, http_hdr->reason_phrase); - return -1; - } - - content_type = http_get_field( http_hdr, "Content-Type"); - - pragma = http_get_field( http_hdr, "Pragma"); - while( pragma!=NULL ) { - char *comma_ptr=NULL; - char *end; - // The pragma line can get severals attributes - // separeted with a comma ','. - do { - if( !strncasecmp( pragma, "features=", 9) ) { - pragma += 9; - end = strstr( pragma, "," ); - if( end==NULL ) { - size_t s = strlen(pragma); - if(s > sizeof(features)) { - MSG_WARN("ASF HTTP PARSE WARNING : Pragma %s cuted from %d bytes to %d\n",pragma,s,sizeof(features)); - len = sizeof(features); - } else { - len = s; - } - } else { - len = MIN((unsigned int)(end-pragma),s... [truncated message content] |
From: <nic...@us...> - 2012-11-21 17:14:52
|
Revision: 427 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=427&view=rev Author: nickols_k Date: 2012-11-21 17:14:42 +0000 (Wed, 21 Nov 2012) Log Message: ----------- convert last .c source into .cpp and remove RND_RENAME. RND_NAMES much better to apply to classes but not to standalone functions Modified Paths: -------------- TODO mplayerxp/input2/input.cpp mplayerxp/input2/input.h mplayerxp/libao2/audio_out.cpp mplayerxp/libao2/audio_out.h mplayerxp/libao2/mixer.cpp mplayerxp/libmpcodecs/ad_vorbis.cpp mplayerxp/libmpcodecs/dec_audio.cpp mplayerxp/libmpcodecs/dec_audio.h mplayerxp/libmpcodecs/dec_video.cpp mplayerxp/libmpcodecs/dec_video.h mplayerxp/libmpdemux/demuxer.cpp mplayerxp/libmpstream/Makefile mplayerxp/libmpstream/mrl.h mplayerxp/libmpstream/stream.cpp mplayerxp/libmpstream/stream.h mplayerxp/libplaytree/asxparser.cpp mplayerxp/libplaytree/playtreeparser.cpp mplayerxp/libvo/video_out.cpp mplayerxp/libvo/video_out.h mplayerxp/mp_msg.h mplayerxp/mplayerxp.cpp mplayerxp/osdep/mp_malloc.cpp mplayerxp/osdep/mplib.cpp mplayerxp/osdep/mplib.h mplayerxp/postproc/af.cpp mplayerxp/postproc/af.h mplayerxp/postproc/af_ao2.cpp mplayerxp/postproc/vf.cpp mplayerxp/postproc/vf.h mplayerxp/postproc/vf_vo.cpp mplayerxp/xmpcore/xmp_adecoder.cpp mplayerxp/xmpcore/xmp_aplayer.cpp mplayerxp/xmpcore/xmp_vdecoder.cpp mplayerxp/xmpcore/xmp_vplayer.cpp Added Paths: ----------- mplayerxp/libmpstream/s_dvdread.cpp Removed Paths: ------------- mplayerxp/libmpstream/s_dvdread.c Modified: TODO =================================================================== --- TODO 2012-11-21 16:08:43 UTC (rev 426) +++ TODO 2012-11-21 17:14:42 UTC (rev 427) @@ -18,7 +18,6 @@ ... if(avcodec_open2(lavc_guard.unprotect(priv->ctx),priv->codec,NULL)<0){ ... -- use c++ instead of plain c - use libavfilter instead of some af_* vf_* - test frame-dropping - remove all #define with values (they maybe intercepted in other .h files) Modified: mplayerxp/input2/input.cpp =================================================================== --- mplayerxp/input2/input.cpp 2012-11-21 16:08:43 UTC (rev 426) +++ mplayerxp/input2/input.cpp 2012-11-21 17:14:42 UTC (rev 427) @@ -747,7 +747,7 @@ filter->ctx = ctx; filter->next = priv->cmd_filters; priv->cmd_filters = filter; - SECURE_NAME9(rnd_fill)(priv->antiviral_hole,offsetof(priv_t,cmd_binds)-offsetof(priv_t,antiviral_hole)); + rnd_fill(priv->antiviral_hole,offsetof(priv_t,cmd_binds)-offsetof(priv_t,antiviral_hole)); } static const char* mp_input_find_bind_for_key(const mp_cmd_bind_t* binds, int n,int* keys) { @@ -1345,7 +1345,7 @@ if(priv->in_file_fd==0) getch2_disable(); } -any_t* RND_RENAME0(mp_input_open)(void) { +any_t* mp_input_open(void) { priv_t* priv=new(zeromem) priv_t; priv->ar_state=-1; priv->in_file_fd=-1; Modified: mplayerxp/input2/input.h =================================================================== --- mplayerxp/input2/input.h 2012-11-21 16:08:43 UTC (rev 426) +++ mplayerxp/input2/input.h 2012-11-21 17:14:42 UTC (rev 427) @@ -149,7 +149,7 @@ extern void mp_cmd_free(mp_cmd_t* cmd); // When you create a new driver you should add it in this 2 functions. -extern any_t* RND_RENAME0(mp_input_open)(void); +extern any_t* mp_input_open(void); extern void mp_input_close(any_t* handle); extern void mp_input_print_keys(any_t*handle); Modified: mplayerxp/libao2/audio_out.cpp =================================================================== --- mplayerxp/libao2/audio_out.cpp 2012-11-21 16:08:43 UTC (rev 426) +++ mplayerxp/libao2/audio_out.cpp 2012-11-21 17:14:42 UTC (rev 427) @@ -185,7 +185,7 @@ MSG_INFO("\n"); } -MPXP_Rc __FASTCALL__ RND_RENAME4(ao_register)(ao_data_t* ao,const char *driver_name,unsigned flags) +MPXP_Rc __FASTCALL__ ao_register(ao_data_t* ao,const char *driver_name,unsigned flags) { priv_t* priv=reinterpret_cast<priv_t*>(ao->opaque); unsigned i; @@ -208,7 +208,7 @@ return priv->audio_out->info; } -ao_data_t* __FASTCALL__ RND_RENAME5(ao_init)(const char *subdevice) +ao_data_t* __FASTCALL__ ao_init(const char *subdevice) { ao_data_t* ao; ao=new(zeromem) ao_data_t; @@ -217,8 +217,8 @@ ao->buffersize=-1; ao->opaque=mp_malloc(sizeof(priv_t)); priv_t* priv=reinterpret_cast<priv_t*>(ao->opaque); - SECURE_NAME9(rnd_fill)(priv->antiviral_hole,sizeof(priv_t)); - SECURE_NAME9(rnd_fill)(ao->antiviral_hole,offsetof(ao_data_t,samplerate)-offsetof(ao_data_t,antiviral_hole)); + rnd_fill(priv->antiviral_hole,sizeof(priv_t)); + rnd_fill(ao->antiviral_hole,offsetof(ao_data_t,samplerate)-offsetof(ao_data_t,antiviral_hole)); priv->audio_out=NULL; return ao; } @@ -265,7 +265,7 @@ return 0; } -unsigned __FASTCALL__ RND_RENAME6(ao_play)(ao_data_t*ao,const any_t* data,unsigned len,unsigned flags) +unsigned __FASTCALL__ ao_play(ao_data_t*ao,const any_t* data,unsigned len,unsigned flags) { if(ao) { priv_t* priv=reinterpret_cast<priv_t*>(ao->opaque); @@ -289,7 +289,7 @@ } } -MPXP_Rc __FASTCALL__ RND_RENAME7(ao_control)(const ao_data_t*ao,int cmd,long arg) +MPXP_Rc __FASTCALL__ ao_control(const ao_data_t*ao,int cmd,long arg) { if(ao) { priv_t* priv=reinterpret_cast<priv_t*>(ao->opaque); Modified: mplayerxp/libao2/audio_out.h =================================================================== --- mplayerxp/libao2/audio_out.h 2012-11-21 16:08:43 UTC (rev 426) +++ mplayerxp/libao2/audio_out.h 2012-11-21 17:14:42 UTC (rev 427) @@ -101,17 +101,17 @@ extern int __FASTCALL__ ao_format_bits(int format); extern void ao_print_help( void ); -extern MPXP_Rc __FASTCALL__ RND_RENAME4(ao_register)(ao_data_t* ao,const char *driver_name,unsigned flags); +extern MPXP_Rc __FASTCALL__ ao_register(ao_data_t* ao,const char *driver_name,unsigned flags); extern const ao_info_t* ao_get_info( const ao_data_t* ao ); -extern ao_data_t* __FASTCALL__ RND_RENAME5(ao_init)(const char *subdevice); +extern ao_data_t* __FASTCALL__ ao_init(const char *subdevice); extern MPXP_Rc __FASTCALL__ ao_configure(ao_data_t* priv,unsigned rate,unsigned channels,unsigned format); extern void __FASTCALL__ ao_uninit(ao_data_t* priv); extern void __FASTCALL__ ao_reset(ao_data_t* priv); extern unsigned __FASTCALL__ ao_get_space(const ao_data_t* priv); -extern unsigned __FASTCALL__ RND_RENAME6(ao_play)(ao_data_t* priv,const any_t* data,unsigned len,unsigned flags); +extern unsigned __FASTCALL__ ao_play(ao_data_t* priv,const any_t* data,unsigned len,unsigned flags); extern float __FASTCALL__ ao_get_delay(const ao_data_t* priv); extern void __FASTCALL__ ao_pause(ao_data_t* priv); extern void __FASTCALL__ ao_resume(ao_data_t* priv); -extern MPXP_Rc __FASTCALL__ RND_RENAME7(ao_control)(const ao_data_t* priv,int cmd,long arg); +extern MPXP_Rc __FASTCALL__ ao_control(const ao_data_t* priv,int cmd,long arg); #endif Modified: mplayerxp/libao2/mixer.cpp =================================================================== --- mplayerxp/libao2/mixer.cpp 2012-11-21 16:08:43 UTC (rev 426) +++ mplayerxp/libao2/mixer.cpp 2012-11-21 17:14:42 UTC (rev 427) @@ -12,7 +12,7 @@ { ao_control_vol_t vol; *l=0; *r=0; - if(MPXP_Ok != RND_RENAME7(ao_control)(ao,AOCONTROL_GET_VOLUME,(long)&vol)) return; + if(MPXP_Ok != ao_control(ao,AOCONTROL_GET_VOLUME,(long)&vol)) return; *r=vol.right; *l=vol.left; } @@ -21,7 +21,7 @@ { ao_control_vol_t vol; vol.right=r; vol.left=l; - RND_RENAME7(ao_control)(ao,AOCONTROL_SET_VOLUME,(long)&vol); + ao_control(ao,AOCONTROL_SET_VOLUME,(long)&vol); } #define MIXER_CHANGE 3 Modified: mplayerxp/libmpcodecs/ad_vorbis.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_vorbis.cpp 2012-11-21 16:08:43 UTC (rev 426) +++ mplayerxp/libmpcodecs/ad_vorbis.cpp 2012-11-21 17:14:42 UTC (rev 427) @@ -114,7 +114,7 @@ #define OGG_FMT16 AFMT_S16_LE #endif sh->afmt=OGG_FMT16; - if(RND_RENAME7(ao_control)(ao_data,AOCONTROL_QUERY_FORMAT,OGG_FMT32) == MPXP_Ok) { + if(ao_control(ao_data,AOCONTROL_QUERY_FORMAT,OGG_FMT32) == MPXP_Ok) { sh->afmt=OGG_FMT32; } // assume 128kbit if bitrate not specified in the header Modified: mplayerxp/libmpcodecs/dec_audio.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_audio.cpp 2012-11-21 16:08:43 UTC (rev 426) +++ mplayerxp/libmpcodecs/dec_audio.cpp 2012-11-21 17:14:42 UTC (rev 427) @@ -33,7 +33,7 @@ const ad_functions_t* mpadec; }priv_t; -any_t* RND_RENAME2(mpca_init)(sh_audio_t *sh_audio) +any_t* mpca_init(sh_audio_t *sh_audio) { const char *afm=NULL,*ac=NULL; const audio_probe_t* aprobe=NULL; @@ -183,7 +183,7 @@ unsigned in_samplerate, unsigned in_channels, unsigned in_format, unsigned* out_samplerate, unsigned* out_channels, unsigned* out_format){ char strbuf[200]; - af_stream_t* afs=RND_RENAME6(af_new)(sh_audio); + af_stream_t* afs=af_new(sh_audio); // input format: same as codec's output format: afs->input.rate = in_samplerate; @@ -203,7 +203,7 @@ afs->input.rate,afs->input.nch,(afs->input.format&MPAF_BPS_MASK)*8); // let's autoprobe it! - if(MPXP_Ok != RND_RENAME7(af_init)(afs,0)){ + if(MPXP_Ok != af_init(afs,0)){ delete afs; return MPXP_False; // failed :( } @@ -230,7 +230,7 @@ unsigned out_minsize, unsigned out_maxsize){ char strbuf[200]; af_stream_t* afs=sh_audio->afilter; - if(!afs) afs = RND_RENAME6(af_new)(sh_audio); + if(!afs) afs = af_new(sh_audio); // input format: same as codec's output format: afs->input.rate = in_samplerate; @@ -250,7 +250,7 @@ afs->output.rate,afs->output.nch,(afs->output.format&MPAF_BPS_MASK)*8,ao_format_name(mpaf2afmt(afs->output.format))); // let's autoprobe it! - if(MPXP_Ok != RND_RENAME7(af_init)(afs,1)){ + if(MPXP_Ok != af_init(afs,1)){ sh_audio->afilter=NULL; delete afs; return MPXP_False; // failed :( @@ -295,7 +295,7 @@ out_minsize,out_maxsize); } -unsigned RND_RENAME3(mpca_decode)(any_t *opaque,unsigned char *buf,unsigned minlen,unsigned maxlen,unsigned buflen,float *pts) +unsigned mpca_decode(any_t *opaque,unsigned char *buf,unsigned minlen,unsigned maxlen,unsigned buflen,float *pts) { priv_t* priv = (priv_t*)opaque; sh_audio_t* sh_audio = priv->parent; @@ -335,7 +335,7 @@ ,0); // xp_idx afd->audio=buf; afd->len=len; - pafd=RND_RENAME8(af_play)(sh_audio->afilter,afd); + pafd=af_play(sh_audio->afilter,afd); afd->audio=NULL; // fake no buffer if(!pafd) { Modified: mplayerxp/libmpcodecs/dec_audio.h =================================================================== --- mplayerxp/libmpcodecs/dec_audio.h 2012-11-21 16:08:43 UTC (rev 426) +++ mplayerxp/libmpcodecs/dec_audio.h 2012-11-21 17:14:42 UTC (rev 427) @@ -6,9 +6,9 @@ // dec_audio.c: extern const ad_functions_t* __FASTCALL__ mpca_find_driver(const char *name); -extern any_t* __FASTCALL__ RND_RENAME2(mpca_init)(sh_audio_t *sh_audio); +extern any_t* __FASTCALL__ mpca_init(sh_audio_t *sh_audio); extern void __FASTCALL__ mpca_uninit(any_t *handle); -extern unsigned __FASTCALL__ RND_RENAME3(mpca_decode)(any_t *handle,unsigned char *buf,unsigned minlen,unsigned maxlen,unsigned buflen,float *pts); +extern unsigned __FASTCALL__ mpca_decode(any_t *handle,unsigned char *buf,unsigned minlen,unsigned maxlen,unsigned buflen,float *pts); extern void __FASTCALL__ mpca_resync_stream(any_t *handle); extern void __FASTCALL__ mpca_skip_frame(any_t *handle); struct codecs_st; Modified: mplayerxp/libmpcodecs/dec_video.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_video.cpp 2012-11-21 16:08:43 UTC (rev 426) +++ mplayerxp/libmpcodecs/dec_video.cpp 2012-11-21 17:14:42 UTC (rev 427) @@ -144,7 +144,7 @@ return priv; } -any_t * RND_RENAME3(mpcv_init)(sh_video_t *sh_video,const char* codecname,const char * vfm,int status,any_t*libinput){ +any_t * mpcv_init(sh_video_t *sh_video,const char* codecname,const char * vfm,int status,any_t*libinput){ int done=0; const video_probe_t* vprobe; sh_video->codec=NULL; @@ -280,7 +280,7 @@ extern vo_data_t* vo_data; static void update_subtitle(sh_video_t *sh_video,float v_pts,unsigned idx); -int RND_RENAME4(mpcv_decode)(any_t *opaque,const enc_frame_t* frame){ +int mpcv_decode(any_t *opaque,const enc_frame_t* frame){ priv_t* priv=(priv_t*)opaque; sh_video_t* sh_video = priv->parent; vf_instance_t* vf; @@ -465,13 +465,13 @@ MSG_WARN("'%s' ",vo_format_name(sh->codec->outfmt[ind])); } MSG_WARN("Trying -vf fmtcvt\n"); - sc=vf=RND_RENAME9(vf_open_filter)(vf,sh,"fmtcvt",NULL,libinput); + sc=vf=vf_open_filter(vf,sh,"fmtcvt",NULL,libinput); goto csp_again; } else if(palette==1){ MSG_V("vd: Trying -vf palette...\n"); palette=-1; - vf=RND_RENAME9(vf_open_filter)(vf,sh,"palette",NULL,libinput); + vf=vf_open_filter(vf,sh,"palette",NULL,libinput); goto csp_again; } else { // sws failed, if the last filter (vf_vo) support MPEGPES try to append vf_lavc @@ -505,7 +505,7 @@ if(vo_data->flags&VFCAP_FLIPPED) vo_FLIP_REVERT(vo_data); if(vo_FLIP(vo_data) && !(vo_data->flags&VFCAP_FLIP)){ // we need to flip, but no flipping filter avail. - sh->vfilter=vf=RND_RENAME9(vf_open_filter)(vf,sh,"flip",NULL,libinput); + sh->vfilter=vf=vf_open_filter(vf,sh,"flip",NULL,libinput); } // time to do aspect ratio corrections... Modified: mplayerxp/libmpcodecs/dec_video.h =================================================================== --- mplayerxp/libmpcodecs/dec_video.h 2012-11-21 16:08:43 UTC (rev 426) +++ mplayerxp/libmpcodecs/dec_video.h 2012-11-21 17:14:42 UTC (rev 427) @@ -6,10 +6,10 @@ #include "libmpdemux/stheader.h" // dec_video.c: -extern any_t* __FASTCALL__ RND_RENAME3(mpcv_init)(sh_video_t *sh_video, const char *codec_name,const char *family,int status,any_t*libinput); +extern any_t* __FASTCALL__ mpcv_init(sh_video_t *sh_video, const char *codec_name,const char *family,int status,any_t*libinput); extern void __FASTCALL__ mpcv_uninit(any_t *handle); extern any_t* __FASTCALL__ mpcv_ffmpeg_init(sh_video_t*,any_t* libinput); -extern int __FASTCALL__ RND_RENAME4(mpcv_decode)(any_t *handle,const enc_frame_t* frame); +extern int __FASTCALL__ mpcv_decode(any_t *handle,const enc_frame_t* frame); extern MPXP_Rc __FASTCALL__ mpcv_get_quality_max(any_t *handle,unsigned *qual); extern MPXP_Rc __FASTCALL__ mpcv_set_quality(any_t *handle,int quality); Modified: mplayerxp/libmpdemux/demuxer.cpp =================================================================== --- mplayerxp/libmpdemux/demuxer.cpp 2012-11-21 16:08:43 UTC (rev 426) +++ mplayerxp/libmpdemux/demuxer.cpp 2012-11-21 17:14:42 UTC (rev 427) @@ -115,7 +115,7 @@ demux_stream_t* new_demuxer_stream(struct demuxer_s *demuxer,int id){ demux_stream_t* ds=(demux_stream_t*)mp_malloc(sizeof(demux_stream_t)); - SECURE_NAME9(rnd_fill)(ds->antiviral_hole,offsetof(demux_stream_t,pin)-offsetof(demux_stream_t,antiviral_hole)); + rnd_fill(ds->antiviral_hole,offsetof(demux_stream_t,pin)-offsetof(demux_stream_t,antiviral_hole)); ds->pin=DS_PIN; ds->buffer_pos=ds->buffer_size=0; ds->buffer=NULL; @@ -143,7 +143,7 @@ demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id){ demuxer_t *d=(demuxer_t*)mp_mallocz(sizeof(demuxer_t)); - SECURE_NAME9(rnd_fill)(d->antiviral_hole,offsetof(demuxer_t,pin)-offsetof(demuxer_t,antiviral_hole)); + rnd_fill(d->antiviral_hole,offsetof(demuxer_t,pin)-offsetof(demuxer_t,antiviral_hole)); d->pin=DEMUX_PIN; d->stream=stream; d->movi_start=stream->start_pos; @@ -602,14 +602,14 @@ #endif if(audio_stream) { - as = RND_RENAME2(open_stream)(libinput,audio_stream,&afmt,NULL); + as = open_stream(libinput,audio_stream,&afmt,NULL); if(!as) { MSG_ERR("Can't open audio stream: %s\n",audio_stream); return NULL; } } if(sub_stream) { - ss = RND_RENAME2(open_stream)(libinput,sub_stream,&sfmt,NULL); + ss = open_stream(libinput,sub_stream,&sfmt,NULL); if(!ss) { MSG_ERR("Can't open subtitles stream: %s\n",sub_stream); return NULL; Modified: mplayerxp/libmpstream/Makefile =================================================================== --- mplayerxp/libmpstream/Makefile 2012-11-21 16:08:43 UTC (rev 426) +++ mplayerxp/libmpstream/Makefile 2012-11-21 17:14:42 UTC (rev 427) @@ -19,7 +19,7 @@ CXXSRCS += s_dvdnav.cpp endif ifeq ($(USE_DVDREAD),yes) -SRCS += s_dvdread.c +CXXSRCS += s_dvdread.cpp endif CXXSRCS += url.cpp ifeq ($(USE_OSS_AUDIO),yes) Modified: mplayerxp/libmpstream/mrl.h =================================================================== --- mplayerxp/libmpstream/mrl.h 2012-11-21 16:08:43 UTC (rev 426) +++ mplayerxp/libmpstream/mrl.h 2012-11-21 17:14:42 UTC (rev 427) @@ -3,9 +3,6 @@ #define __MPXP_MRL_H 1 #include "mp_config.h" -#ifdef __cplusplus -extern "C" { -#endif /** Parses line which contains MRL and splits it on components. * @param line source line to be parsed * @param user buffer which will contain username if present (maybe NULL) @@ -55,7 +52,4 @@ * @see mrl_parse_line **/ extern const char * mrl_parse_params(const char *param,const mrl_config_t * args); -#ifdef __cplusplus -} #endif -#endif Deleted: mplayerxp/libmpstream/s_dvdread.c =================================================================== --- mplayerxp/libmpstream/s_dvdread.c 2012-11-21 16:08:43 UTC (rev 426) +++ mplayerxp/libmpstream/s_dvdread.c 2012-11-21 17:14:42 UTC (rev 427) @@ -1,827 +0,0 @@ -/* - s_dvdread - DVDREAD stream interface -*/ - -#include "mp_config.h" -#include "mplayerxp.h" -#ifdef USE_DVDREAD -#include <stdlib.h> -#include <string.h> -#include <ctype.h> -#include "stream.h" -#include "help_mp.h" -#include "stream_msg.h" -#include "osdep/mplib.h" - -#include <dvdread/dvd_reader.h> -#include <dvdread/ifo_types.h> -#include <dvdread/ifo_read.h> -#include <dvdread/nav_read.h> -#include "mrl.h" - -#undef DVDREAD_VERSION -#define DVDREAD_VERSION(maj,min,micro) ((maj)*10000 + (min)*100 + (micro)) - -/* - * Try to autodetect the libdvd-0.9.0 library - * (0.9.0 removed the <dvdread/dvd_udf.h> header, and moved the two defines - * DVD_VIDEO_LB_LEN and MAX_UDF_FILE_NAME_LEN from it to - * <dvdread/dvd_reader.h>) - */ -#if defined(DVD_VIDEO_LB_LEN) && defined(MAX_UDF_FILE_NAME_LEN) -#define LIBDVDREAD_VERSION DVDREAD_VERSION(0,9,0) -#else -#define LIBDVDREAD_VERSION DVDREAD_VERSION(0,8,0) -#endif - -typedef struct { - int id; // 0 - 31 mpeg; 128 - 159 ac3; 160 - 191 pcm - int language; - int type; - int channels; -} stream_language_t; - -typedef struct { - dvd_reader_t *dvd; - dvd_file_t *title; - ifo_handle_t *vmg_file; - tt_srpt_t *tt_srpt; - ifo_handle_t *vts_file; - vts_ptt_srpt_t *vts_ptt_srpt; - pgc_t *cur_pgc; - /* title sets */ - unsigned first_title,cur_title,last_title; -// - int cur_cell; - int last_cell; - int cur_pack; - int cell_last_pack; -// Navi: - int packs_left; - dsi_t dsi_pack; - pci_t pci_pack; - int angle_seek; - float vobu_s_pts,vobu_e_pts; -// audio datas - int nr_of_channels; - stream_language_t audio_streams[32]; -// subtitles - int nr_of_subtitles; - stream_language_t subtitles[32]; - - off_t spos; -} dvd_priv_t; - -static int dvd_chapter=1; -static int dvd_last_chapter=0; -static int dvd_angle=1; /**< some DVD discs contain scenes that can be viewed from multiple angles */ - -static const char * dvd_audio_stream_types[8] = - { "ac3","unknown","mpeg1","mpeg2ext","lpcm","unknown","dts" }; - -static const char * dvd_audio_stream_channels[8] = - { "unknown", "stereo", "unknown", "unknown", "unknown", "5.1", "6.1", "7.1" }; - -static int __FASTCALL__ dvd_chapter_from_cell(dvd_priv_t* dvd,int title,int cell) -{ - pgc_t * cur_pgc; - ptt_info_t* ptt; - int chapter = cell; - int pgc_id,pgn; - if(title < 0 || cell < 0){ - return 0; - } - /* for most DVD's chapter == cell */ - /* but there are more complecated cases... */ - if(chapter >= dvd->vmg_file->tt_srpt->title[title].nr_of_ptts){ - chapter = dvd->vmg_file->tt_srpt->title[title].nr_of_ptts-1; - } - title = dvd->tt_srpt->title[title].vts_ttn-1; - ptt = dvd->vts_file->vts_ptt_srpt->title[title].ptt; - while(chapter >= 0){ - pgc_id = ptt[chapter].pgcn; - pgn = ptt[chapter].pgn; - cur_pgc = dvd->vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc; - if(cell >= cur_pgc->program_map[pgn-1]-1){ - return chapter; - } - --chapter; - } - /* didn't find a chapter ??? */ - return chapter; -} - -static int __FASTCALL__ dvd_number_of_subs(stream_t *stream) -{ - dvd_priv_t *d; - if (!stream) return -1; - d = stream->priv; - if (!d) return -1; - return d->nr_of_subtitles; -} - -static int __FASTCALL__ dvd_aid_from_lang(stream_t *stream, unsigned char* lang){ -dvd_priv_t *d=stream->priv; -int code,i; - while(lang && strlen(lang)>=2){ - code=lang[1]|(lang[0]<<8); - for(i=0;i<d->nr_of_channels;i++){ - if(d->audio_streams[i].language==code){ - MSG_V("Selected DVD audio channel: %d language: %c%c\n", - d->audio_streams[i].id, lang[0],lang[1]); - return d->audio_streams[i].id; - } - } - lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang; - } - MSG_WARN("No matching DVD audio language found!\n"); - return -1; -} - -static int __FASTCALL__ dvd_sid_from_lang(stream_t *stream, unsigned char* lang){ -dvd_priv_t *d=stream->priv; -int code,i; - while(lang && strlen(lang)>=2){ - code=lang[1]|(lang[0]<<8); - for(i=0;i<d->nr_of_subtitles;i++){ - if(d->subtitles[i].language==code){ - MSG_V("Selected DVD subtitle channel: %d language: %c%c\n", - d->subtitles[i].id, lang[0],lang[1]); - return d->subtitles[i].id; - } - } - lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang; - } - MSG_WARN("No matching DVD subtitle language found!\n"); - return -1; -} - -static int __FASTCALL__ dvd_lang_from_sid(stream_t *stream, int id) -{ - dvd_priv_t *d; - if (!stream) return 0; - d = stream->priv; - if (!d) return 0; - if (id >= d->nr_of_subtitles) return 0; - return d->subtitles[id].language; -} - -static int __FASTCALL__ dvd_next_title(dvd_priv_t *d,int dvd_title) -{ - int ttn,pgc_id,pgn; - dvd_reader_t *dvd; - dvd_file_t *title; - ifo_handle_t *vmg_file; - tt_srpt_t *tt_srpt; - ifo_handle_t *vts_file; - - MSG_V("dvd_next_title %d\n",dvd_title); - - tt_srpt = d->tt_srpt; - vmg_file = d->vmg_file; - dvd = d->dvd; - if(d->vts_file) ifoClose(d->vts_file); - if(d->title) DVDCloseFile(d->title); - /** - * Load the VTS information for the title set our title is in. - */ - vts_file = ifoOpen( dvd, tt_srpt->title[dvd_title].title_set_nr ); - if( !vts_file ) { - MSG_ERR( MSGTR_DVDnoIFO, - tt_srpt->title[dvd_title].title_set_nr ); - ifoClose( vmg_file ); - DVDClose( dvd ); - return 0; - } - /** - * We've got enough info, time to open the title set data. - */ - title = DVDOpenFile( dvd, tt_srpt->title[dvd_title].title_set_nr, - DVD_READ_TITLE_VOBS ); - if( !title ) { - MSG_ERR( MSGTR_DVDnoVOBs, - tt_srpt->title[dvd_title].title_set_nr ); - ifoClose( vts_file ); - ifoClose( vmg_file ); - DVDClose( dvd ); - return 0; - } - d->vts_file=vts_file; - d->title=title; - - ttn = tt_srpt->title[dvd_title].vts_ttn - 1; - - /** - * Check number of audio channels and types - */ - { - const int ac3aid = 128; - const int dtsaid = 136; - const int mpegaid = 0; - const int pcmaid = 160; - - d->nr_of_channels=0; - - if ( vts_file->vts_pgcit ) - { - int i; - for ( i=0;i<8;i++ ) - if ( vts_file->vts_pgcit->pgci_srp[0].pgc->audio_control[i] & 0x8000 ) - { - audio_attr_t * audio = &vts_file->vtsi_mat->vts_audio_attr[i]; - int language = 0; - char tmp[] = "unknown"; - - if ( audio->lang_type == 1 ) - { - language=audio->lang_code; - tmp[0]=language>>8; - tmp[1]=language&0xff; - tmp[2]=0; - } - - d->audio_streams[d->nr_of_channels].language=language; - d->audio_streams[d->nr_of_channels].id=vts_file->vts_pgcit->pgci_srp[ttn].pgc->audio_control[i] >> 8 & 7; - switch ( audio->audio_format ) - { - case 0: // ac3 - d->audio_streams[d->nr_of_channels].id+=ac3aid; - break; - case 6: // dts - d->audio_streams[d->nr_of_channels].id+=dtsaid; - break; - case 2: // mpeg layer 1/2/3 - case 3: // mpeg2 ext - d->audio_streams[d->nr_of_channels].id+=mpegaid; - break; - case 4: // lpcm - d->audio_streams[d->nr_of_channels].id+=pcmaid; - break; - } - - d->audio_streams[d->nr_of_channels].type=audio->audio_format; - // Pontscho: to my mind, tha channels: - // 1 - stereo - // 5 - 5.1 - d->audio_streams[d->nr_of_channels].channels=audio->channels; - MSG_V("[open] audio stream: %d audio format: %s (%s) language: %s aid: %d\n", - d->nr_of_channels, - dvd_audio_stream_types[ audio->audio_format ], - dvd_audio_stream_channels[ audio->channels ], - tmp, - d->audio_streams[d->nr_of_channels].id - ); - - d->nr_of_channels++; - } - } - MSG_V("[open] number of audio channels on disk: %d.\n",d->nr_of_channels ); - } - - /** - * Check number of subtitles and language - */ - { - int i; - - d->nr_of_subtitles=0; - for ( i=0;i<32;i++ ) - if ( vts_file->vts_pgcit->pgci_srp[0].pgc->subp_control[i] & 0x80000000 ) - { - subp_attr_t * subtitle = &vts_file->vtsi_mat->vts_subp_attr[i]; - video_attr_t *video = &vts_file->vtsi_mat->vts_video_attr; - int language = 0; - char tmp[] = "unknown"; - - if ( subtitle->type == 1 ) - { - language=subtitle->lang_code; - tmp[0]=language>>8; - tmp[1]=language&0xff; - tmp[2]=0; - } - - d->subtitles[ d->nr_of_subtitles ].language=language; - d->subtitles[ d->nr_of_subtitles ].id=d->nr_of_subtitles; - if(video->display_aspect_ratio == 0) /* 4:3 */ - d->subtitles[d->nr_of_subtitles].id = vts_file->vts_pgcit->pgci_srp[ttn].pgc->subp_control[i] >> 24 & 31; - else if(video->display_aspect_ratio == 3) /* 16:9 */ - d->subtitles[d->nr_of_subtitles].id = vts_file->vts_pgcit->pgci_srp[ttn].pgc->subp_control[i] >> 8 & 31; - - MSG_V("[open] subtitle ( sid ): %d language: %s\n", - d->nr_of_subtitles, - tmp - ); - d->nr_of_subtitles++; - } - MSG_V("[open] number of subtitles on disk: %d\n",d->nr_of_subtitles ); - } - - /** - * Determine which program chain we want to watch. This is based on the - * chapter number. - */ - pgc_id = vts_file->vts_ptt_srpt->title[ttn].ptt[dvd_chapter].pgcn; // local - pgn = vts_file->vts_ptt_srpt->title[ttn].ptt[dvd_chapter].pgn; // local - d->cur_pgc = vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc; - d->cur_cell = d->cur_pgc->program_map[pgn-1] - 1; // start playback here - d->packs_left=-1; // for Navi stuff - d->angle_seek=0; - /* XXX dvd_last_chapter is in the range 1..nr_of_ptts */ - if ( dvd_last_chapter > 0 && dvd_last_chapter < tt_srpt->title[dvd_title].nr_of_ptts ) { - pgn=vts_file->vts_ptt_srpt->title[ttn].ptt[dvd_last_chapter].pgn; - d->last_cell=d->cur_pgc->program_map[pgn-1] - 1; - } - else - d->last_cell=d->cur_pgc->nr_of_cells; - - if( d->cur_pgc->cell_playback[d->cur_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; - d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; - d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; - MSG_V( "DVD start cell: %d pack: 0x%X-0x%X \n",d->cur_cell,d->cur_pack,d->cell_last_pack); - - return 1; -} - -static int __FASTCALL__ dvd_next_cell(dvd_priv_t *d){ - int next_cell=d->cur_cell; - - MSG_V( "dvd_next_cell: next1=0x%X \n",next_cell); - - if( d->cur_pgc->cell_playback[ next_cell ].block_type - == BLOCK_TYPE_ANGLE_BLOCK ) { - while(next_cell<d->last_cell){ - if( d->cur_pgc->cell_playback[next_cell].block_mode - == BLOCK_MODE_LAST_CELL ) break; - ++next_cell; - } - } - MSG_V( "dvd_next_cell: next2=0x%X \n",next_cell); - - ++next_cell; - if(next_cell>=d->last_cell) return -1; // EOF - if( d->cur_pgc->cell_playback[next_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ){ - next_cell+=dvd_angle; - if(next_cell>=d->last_cell) return -1; // EOF - } - MSG_V( "dvd_next_cell: next3=0x%X \n",next_cell); - return next_cell; -} - -static void __FASTCALL__ dvd_seek(stream_t* stream,dvd_priv_t *d,int pos); -static int __FASTCALL__ dvd_read_sector(stream_t* stream,dvd_priv_t *d,unsigned char* data){ - int len; -read_first: - if(d->packs_left==0){ - /** - * If we're not at the end of this cell, we can determine the next - * VOBU to display using the VOBU_SRI information section of the - * DSI. Using this value correctly follows the current angle, - * avoiding the doubled scenes in The Matrix, and makes our life - * really happy. - * - * Otherwise, we set our next address past the end of this cell to - * force the code above to go to the next cell in the program. - */ - if( d->dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL ) { - d->cur_pack= d->dsi_pack.dsi_gi.nv_pck_lbn + - ( d->dsi_pack.vobu_sri.next_vobu & 0x3fffffff ); - MSG_V( "Navi new pos=0x%X \n",d->cur_pack); - } else { - // end of cell! find next cell! - MSG_V( "--- END OF CELL !!! ---\n"); - d->cur_pack=d->cell_last_pack+1; - } - } - -read_next: - - if(d->cur_pack>d->cell_last_pack){ - // end of cell! - int next=dvd_next_cell(d); - if(next>=0){ - d->cur_cell=next; - // if( d->cur_pgc->cell_playback[d->cur_cell].block_type - // == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; - d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; - d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; - MSG_V( "DVD next cell: %d pack: 0x%X-0x%X \n",d->cur_cell,d->cur_pack,d->cell_last_pack); - } else - if(d->cur_title<d->last_title) - { - d->cur_title++; - dvd_next_title(d,d->cur_title); - goto read_first; - } - else return -1; // EOF - } - - len = DVDReadBlocks( d->title, d->cur_pack, 1, data ); - if(!len) return -1; //error -/* -Navigation packets are PES packets with a stream id 0xbf, i.e. -private stream 2. It's made up of PCI, Presentation Control Information -and DSI, Data Search Information. - - 0 6 7 0x3d4+0x6 0x3d4+0xb 0x3d4+0xc - +------+---------+----------------------+------+---------+-----------------+ - |Packet|Substream| PCI |Packet|Substream| DSI | - |Header| ID | Data |Header| ID | Data | - +------+---------+----------------------+------+---------+-----------------+ - - The packet head is just a PES packet header, a packet start code, a stream id -and a packet length. The first packet lenght is 0x3d4, the length of the PCI data -plus one. The second packet length is 0x3fa, the length of DSI data plus one. -The substream id for PCI packet is 0x00 and 0x01 for DSI. -*/ - if(data[38]==0 && data[39]==0 && data[40]==1 && data[41]==0xBF && - data[1024]==0 && data[1025]==0 && data[1026]==1 && data[1027]==0xBF){ - // found a Navi packet!!! -#if LIBDVDREAD_VERSION >= DVDREAD_VERSION(0,9,0) - navRead_DSI( &d->dsi_pack, &(data[DSI_START_BYTE]) ); - navRead_PCI( &d->pci_pack, &(data[DSI_START_BYTE-0x3DA]) ); -#else - navRead_DSI( &d->dsi_pack, &(data[DSI_START_BYTE]), sizeof(dsi_t)); - navRead_PCI( &d->pci_pack, &(data[DSI_START_BYTE-0x3DA]), sizeof(pci_t)); -#endif - /* - TODO!: if num_angles!=0 and d->dsi_pack.sml_agli.data[dvd_angle].address - doesn't work :( - > Invalid NAVIpacket! lba=30 gsi_navi=8002F pci_navi=8002F angle=0 - */ - if(d->cur_pack != d->dsi_pack.dsi_gi.nv_pck_lbn){ - MSG_V( "Invalid NAVIpacket! lba=%X gsi_navi=%X pci_navi=%X angle=%X\n" - ,d->cur_pack - ,d->dsi_pack.dsi_gi.nv_pck_lbn - ,d->pci_pack.pci_gi.nv_pck_lbn - ,d->dsi_pack.sml_agli.data[dvd_angle].address - ); - } else { - // process! - float vobu_s_pts,vobu_e_pts; - vobu_s_pts=d->pci_pack.pci_gi.vobu_s_ptm/90000.; - vobu_e_pts=d->pci_pack.pci_gi.vobu_e_ptm/90000.; - d->packs_left = d->dsi_pack.dsi_gi.vobu_ea; - MSG_V( "Found NAVI packet! lba=%X angle=%X len=%d vobu_s_pts=%f vobu_e_pts=%f\n" - ,d->cur_pack,d->packs_left - ,d->dsi_pack.sml_agli.data[dvd_angle].address - ,vobu_s_pts,vobu_e_pts); - - if(d->angle_seek){ - int i,skip=0; -#if defined(__GNUC__) && ( defined(__sparc__) || defined(hpux) ) - // workaround for a bug in the sparc/hpux version of gcc 2.95.X ... 3.2, - // it generates incorrect code for unaligned access to a packed - // structure member, resulting in an mplayer crash with a SIGBUS - // signal. - // - // See also gcc problem report PR c/7847: - // http://gcc.gnu.org/cgi-bin/gnatsweb.pl?database=gcc&cmd=view+audit-trail&pr=7847 - for(i=0;i<9;i++){ // check if all values zero: - typeof(d->dsi_pack.sml_agli.data[i].address) tmp_addr; - memcpy(&tmp_addr,&d->dsi_pack.sml_agli.data[i].address,sizeof(tmp_addr)); - if((skip=tmp_addr)!=0) break; - } -#else - for(i=0;i<9;i++) // check if all values zero: - if((skip=d->dsi_pack.sml_agli.data[i].address)!=0) break; -#endif - if(skip){ - // sml_agli table has valid data (at least one non-zero): - d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+ - d->dsi_pack.sml_agli.data[dvd_angle].address; - d->angle_seek=0; - MSG_V("Angle-seek synced using sml_agli map! new_lba=0x%X\n",d->cur_pack); - } else { - // check if we're in the right cell, jump otherwise: - if( (d->dsi_pack.dsi_gi.vobu_c_idn==d->cur_pgc->cell_position[d->cur_cell].cell_nr) && - (d->dsi_pack.dsi_gi.vobu_vob_idn==d->cur_pgc->cell_position[d->cur_cell].vob_id_nr) ){ - d->angle_seek=0; - MSG_V("Angle-seek synced by cell/vob IDN search!\n"); - } else { - // wrong angle, skip this vobu: - d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+ - d->dsi_pack.dsi_gi.vobu_ea; - d->angle_seek=2; // DEBUG - } - } - } - if(vobu_s_pts < d->vobu_e_pts) - { - stream->stream_pts += d->vobu_e_pts-vobu_s_pts; - MSG_V("DVD's discontinuities found! Applying delta: %f\n",stream->stream_pts); - } - else stream->stream_pts = vobu_s_pts; - d->vobu_s_pts = vobu_s_pts; - d->vobu_e_pts = vobu_e_pts; - } - ++d->cur_pack; - goto read_next; - } - - ++d->cur_pack; - if(d->packs_left>=0) --d->packs_left; - - if(d->angle_seek) goto read_next; // searching for Navi packet - - return d->cur_pack-1; -} - -static void __FASTCALL__ dvd_seek(stream_t* stream,dvd_priv_t *d,int pos){ - int dir=1; - d->packs_left=-1; - if(d->cur_pack>pos) dir=-1; - d->cur_pack=pos; - - reseek: -// check if we stay in current cell (speedup things, and avoid angle skip) -if(d->cur_pack>d->cell_last_pack || - d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector){ - - // ok, cell change, find the right cell! - d->cur_cell=0; - if( d->cur_pgc->cell_playback[d->cur_cell].block_type - == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; - - while(1){ - int next; - d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; - if(d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector){ - d->cur_pack=d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; - break; - } - if(d->cur_pack<=d->cell_last_pack) break; // ok, we find it! :) - next=dvd_next_cell(d); - if(next<0){ - // we're after the last cell - if(dir>0) // FF - { - if(d->cur_title<d->last_title) - { - d->cur_title++; - dvd_next_title(d,d->cur_title); - goto reseek; - } - } - else // BACK - { - if(d->cur_title>d->first_title) - { - d->cur_title--; - dvd_next_title(d,d->cur_title); - goto reseek; - } - } - break; // EOF - } - d->cur_cell=next; - } - stream->stream_pts=d->vobu_s_pts=d->vobu_e_pts=0.; -} - -MSG_V( "DVD Seek! lba=0x%X cell=%d packs: 0x%X-0x%X \n", - d->cur_pack,d->cur_cell,d->cur_pgc->cell_playback[ d->cur_cell ].first_sector,d->cell_last_pack); - -// if we're in interleaved multi-angle cell, find the right angle chain! -// (read Navi block, and use the seamless angle jump table) -d->angle_seek=1; - -} - -static void __FASTCALL__ dvd_close(dvd_priv_t *d) { - ifoClose(d->vts_file); - ifoClose(d->vmg_file); - DVDCloseFile(d->title); - DVDClose(d->dvd); - /* for reenterability */ - dvd_chapter=1; - dvd_last_chapter=0; - dvd_angle=1; -} - -static MPXP_Rc __FASTCALL__ __dvdread_open(any_t*libinput,stream_t *stream,const char *filename,unsigned flags) -{ - int dvd_title,last_title=-1; - const char *args; - char *dvd_device,*tilde,*comma,*par; - char param[256]; -// int ret,ret2; - dvd_priv_t *d; - dvd_reader_t *dvd; - ifo_handle_t *vmg_file; - tt_srpt_t *tt_srpt; - UNUSED(libinput); - if(strcmp(filename,"help") == 0 || strlen(filename)==10) { - MSG_HINT("Usage: dvdread://<@device>#<titleno>-<lasttitle>,<chapter>-<lastchapter>,<angle>\n"); - return MPXP_False; - } - args=mrl_parse_line(filename,NULL,NULL,&dvd_device,NULL); - strncpy(param,args,sizeof(param)); - comma=strchr(param,','); - tilde=strchr(param,'-'); - if(comma) *comma=0; - if(tilde) *tilde=0; - dvd_title=atoi(param); - if(tilde) last_title=atoi(tilde+1); - else - if(comma) { - comma++; - par = comma; - tilde=strchr(comma,'-'); - comma=strchr(comma,','); - dvd_chapter=atoi(par); - if(tilde) { - tilde++; - dvd_last_chapter=atoi(tilde); - } - if(comma) { comma++; dvd_angle=atoi(comma); } - } - /** - * Open the disc. - */ - dvd = DVDOpen(dvd_device?dvd_device:DEFAULT_DVD_DEVICE); - if( !dvd ) { - MSG_ERR(MSGTR_CantOpenDVD,dvd_device?dvd_device:DEFAULT_DVD_DEVICE); - if(dvd_device) mp_free(dvd_device); - return MPXP_False; - } - if(dvd_device) mp_free(dvd_device); - MSG_V(MSGTR_DVDwait); - - /** - * Load the video manager to find out the information about the titles on - * this disc. - */ - vmg_file = ifoOpen( dvd, 0 ); - if( !vmg_file ) { - MSG_ERR( "Can't open VMG info!\n"); - DVDClose( dvd ); - return MPXP_False; - } - tt_srpt = vmg_file->tt_srpt; - /** - * Make sure our title number is valid. - */ - MSG_INFO( MSGTR_DVDnumTitles, - tt_srpt->nr_of_srpts ); - if( dvd_title < 1 || dvd_title > tt_srpt->nr_of_srpts ) { - MSG_ERR( MSGTR_DVDinvalidTitle, dvd_title); - ifoClose( vmg_file ); - DVDClose( dvd ); - return MPXP_False; - } - --dvd_title; // remap 1.. -> 0.. - --last_title;// remap 1.. -> 0.. - if( last_title < 0 || last_title >= tt_srpt->nr_of_srpts ) last_title=dvd_title; - /** - * Make sure the chapter number is valid for this title. - */ - MSG_INFO( MSGTR_DVDnumChapters, - tt_srpt->title[dvd_title].nr_of_ptts ); - if( dvd_chapter<1 || dvd_chapter>tt_srpt->title[dvd_title].nr_of_ptts ) { - MSG_ERR( MSGTR_DVDinvalidChapter, dvd_chapter); - ifoClose( vmg_file ); - DVDClose( dvd ); - return MPXP_False; - } - if( dvd_last_chapter>0 ) { - if ( dvd_last_chapter<dvd_chapter || dvd_last_chapter>tt_srpt->title[dvd_title].nr_of_ptts ) { - MSG_ERR( "Invalid DVD last chapter number: %d\n", dvd_last_chapter); - ifoClose( vmg_file ); - DVDClose( dvd ); - return MPXP_False; - } - } - --dvd_chapter; // remap 1.. -> 0.. - /* XXX No need to remap dvd_last_chapter */ - /** - * Make sure the angle number is valid for this title. - */ - MSG_V( MSGTR_DVDnumAngles, - tt_srpt->title[dvd_title].nr_of_angles ); - if( dvd_angle<1 || dvd_angle>tt_srpt->title[dvd_title].nr_of_angles ) { - MSG_ERR( MSGTR_DVDinvalidAngle, dvd_angle); - ifoClose( vmg_file ); - DVDClose( dvd ); - return MPXP_False; - } - --dvd_angle; // remap 1.. -> 0.. - - // store data - d=mp_mallocz(sizeof(dvd_priv_t)); - d->dvd=dvd; - d->title=0; - d->vmg_file=vmg_file; - d->tt_srpt=tt_srpt; - d->vts_file=0; - d->cur_title=d->first_title=dvd_title; - d->last_title=last_title; - - if(!dvd_next_title(d,dvd_title)) { - mp_free(d); - ifoClose( vmg_file ); - DVDClose( dvd ); - return MPXP_False; - } - - MSG_V( MSGTR_DVDopenOk); - - stream->start_pos=(off_t)d->cur_pack*2048; - stream->end_pos=(off_t)(d->cur_pgc->cell_playback[d->last_cell-1].last_sector)*2048; - if(dvd_next_title(d,last_title)) - stream->end_pos=(off_t)(d->cur_pgc->cell_playback[d->last_cell-1].last_sector)*2048; - MSG_V("DVD start=%d end=%d \n",d->cur_pack,d->cur_pgc->cell_playback[d->last_cell-1].last_sector); - dvd_next_title(d,dvd_title); - stream->priv=(any_t*)d; - stream->type = STREAMTYPE_SEEKABLE|STREAMTYPE_PROGRAM; - stream->sector_size=2048; - d->spos=0; -// check_pin("stream",stream->pin,STREAM_PIN); - return MPXP_Ok; -} - -static int __FASTCALL__ __dvdread_read(stream_t *stream,stream_packet_t *sp) -{ - dvd_priv_t *d=(dvd_priv_t *)stream->priv; - off_t pos=dvd_read_sector(stream,stream->priv,sp->buf); - sp->type=0; - if(pos>=0){ - sp->len=2048; // full sector - d->spos += 2048; - } else sp->len= -1; // error - return sp->len; -} - -static off_t __FASTCALL__ __dvdread_seek(stream_t *stream,off_t newpos) -{ - dvd_priv_t *d=(dvd_priv_t *)stream->priv; - off_t pos=newpos/2048; - dvd_seek(stream,stream->priv,pos); - d->spos=pos*2048; - return d->spos; -} - -static off_t __FASTCALL__ __dvdread_tell(const stream_t *stream) -{ - dvd_priv_t *d = (dvd_priv_t *)stream->priv; - return d->spos; -} - -static void __FASTCALL__ __dvdread_close(stream_t *stream) -{ - dvd_close(stream->priv); - mp_free(stream->priv); -} - -static unsigned int * __FASTCALL__ dvdread_stream_get_palette(stream_t *stream) -{ - dvd_priv_t *d=(dvd_priv_t *)stream->priv; - if(d) - if(d->cur_pgc) - return d->cur_pgc->palette; - return 0; -} - -static MPXP_Rc __FASTCALL__ __dvdread_ctrl(const stream_t *s,unsigned cmd,any_t*args) -{ - dvd_priv_t *dvd_priv=s->priv; - switch(cmd) { - case SCTRL_VID_GET_PALETTE: { - unsigned* pal; - pal=dvdread_stream_get_palette(s); - *((unsigned **)args)=pal; - return MPXP_Ok; - } - break; - case SCTRL_LNG_GET_AID: { - int aid; - aid=dvd_aid_from_lang(s,args); - *((int *)args)=aid; - return MPXP_Ok; - } - break; - case SCTRL_LNG_GET_SID: { - int aid; - aid=dvd_sid_from_lang(s,args); - *((int *)args)=aid; - return MPXP_Ok; - } - break; - default: break; - } - return MPXP_False; -} - -const stream_driver_t dvdread_stream = -{ - "dvdread://", - "reads multimedia stream using low-level libdvdread access", - __dvdread_open, - __dvdread_read, - __dvdread_seek, - __dvdread_tell, - __dvdread_close, - __dvdread_ctrl -}; -#endif - Copied: mplayerxp/libmpstream/s_dvdread.cpp (from rev 425, mplayerxp/libmpstream/s_dvdread.c) =================================================================== --- mplayerxp/libmpstream/s_dvdread.cpp (rev 0) +++ mplayerxp/libmpstream/s_dvdread.cpp 2012-11-21 17:14:42 UTC (rev 427) @@ -0,0 +1,834 @@ +/* + s_dvdread - DVDREAD stream interface +*/ +#include <limits> + +#include "mp_config.h" +#include "mplayerxp.h" + +/* fake stdint */ +#define UINT8_MAX std::numeric_limits<uint8_t>::max() +#define UINT16_MAX std::numeric_limits<uint16_t>::max() +#define INT32_MAX std::numeric_limits<int32_t>::max() +#ifdef USE_DVDREAD +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include "stream.h" +#include "help_mp.h" +#include "stream_msg.h" +#include "osdep/mplib.h" + +#include <dvdread/dvd_reader.h> +#include <dvdread/ifo_types.h> +#include <dvdread/ifo_read.h> +#include <dvdread/nav_read.h> +#include "mrl.h" + +#undef DVDREAD_VERSION +#define DVDREAD_VERSION(maj,min,micro) ((maj)*10000 + (min)*100 + (micro)) + +/* + * Try to autodetect the libdvd-0.9.0 library + * (0.9.0 removed the <dvdread/dvd_udf.h> header, and moved the two defines + * DVD_VIDEO_LB_LEN and MAX_UDF_FILE_NAME_LEN from it to + * <dvdread/dvd_reader.h>) + */ +#if defined(DVD_VIDEO_LB_LEN) && defined(MAX_UDF_FILE_NAME_LEN) +#define LIBDVDREAD_VERSION DVDREAD_VERSION(0,9,0) +#else +#define LIBDVDREAD_VERSION DVDREAD_VERSION(0,8,0) +#endif + +typedef struct { + int id; // 0 - 31 mpeg; 128 - 159 ac3; 160 - 191 pcm + int language; + int type; + int channels; +} stream_language_t; + +typedef struct { + dvd_reader_t *dvd; + dvd_file_t *title; + ifo_handle_t *vmg_file; + tt_srpt_t *tt_srpt; + ifo_handle_t *vts_file; + vts_ptt_srpt_t *vts_ptt_srpt; + pgc_t *cur_pgc; + /* title sets */ + unsigned first_title,cur_title,last_title; +// + int cur_cell; + int last_cell; + int cur_pack; + int cell_last_pack; +// Navi: + int packs_left; + dsi_t dsi_pack; + pci_t pci_pack; + int angle_seek; + float vobu_s_pts,vobu_e_pts; +// audio datas + int nr_of_channels; + stream_language_t audio_streams[32]; +// subtitles + int nr_of_subtitles; + stream_language_t subtitles[32]; + + off_t spos; +} dvd_priv_t; + +static int dvd_chapter=1; +static int dvd_last_chapter=0; +static int dvd_angle=1; /**< some DVD discs contain scenes that can be viewed from multiple angles */ + +static const char * dvd_audio_stream_types[8] = + { "ac3","unknown","mpeg1","mpeg2ext","lpcm","unknown","dts" }; + +static const char * dvd_audio_stream_channels[8] = + { "unknown", "stereo", "unknown", "unknown", "unknown", "5.1", "6.1", "7.1" }; + +static int __FASTCALL__ dvd_chapter_from_cell(dvd_priv_t* dvd,int title,int cell) +{ + pgc_t * cur_pgc; + ptt_info_t* ptt; + int chapter = cell; + int pgc_id,pgn; + if(title < 0 || cell < 0){ + return 0; + } + /* for most DVD's chapter == cell */ + /* but there are more complecated cases... */ + if(chapter >= dvd->vmg_file->tt_srpt->title[title].nr_of_ptts){ + chapter = dvd->vmg_file->tt_srpt->title[title].nr_of_ptts-1; + } + title = dvd->tt_srpt->title[title].vts_ttn-1; + ptt = dvd->vts_file->vts_ptt_srpt->title[title].ptt; + while(chapter >= 0){ + pgc_id = ptt[chapter].pgcn; + pgn = ptt[chapter].pgn; + cur_pgc = dvd->vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc; + if(cell >= cur_pgc->program_map[pgn-1]-1){ + return chapter; + } + --chapter; + } + /* didn't find a chapter ??? */ + return chapter; +} + +static int __FASTCALL__ dvd_number_of_subs(stream_t *stream) +{ + dvd_priv_t *d; + if (!stream) return -1; + d = reinterpret_cast<dvd_priv_t*>(stream->priv); + if (!d) return -1; + return d->nr_of_subtitles; +} + +static int __FASTCALL__ dvd_aid_from_lang(const stream_t *stream, const char* lang){ + dvd_priv_t *d=reinterpret_cast<dvd_priv_t*>(stream->priv); + int code,i; + while(lang && strlen(lang)>=2){ + code=lang[1]|(lang[0]<<8); + for(i=0;i<d->nr_of_channels;i++){ + if(d->audio_streams[i].language==code){ + MSG_V("Selected DVD audio channel: %d language: %c%c\n", + d->audio_streams[i].id, lang[0],lang[1]); + return d->audio_streams[i].id; + } + } + lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang; + } + MSG_WARN("No matching DVD audio language found!\n"); + return -1; +} + +static int __FASTCALL__ dvd_sid_from_lang(const stream_t *stream, const char* lang){ + dvd_priv_t *d=reinterpret_cast<dvd_priv_t*>(stream->priv); + int code,i; + while(lang && strlen(lang)>=2){ + code=lang[1]|(lang[0]<<8); + for(i=0;i<d->nr_of_subtitles;i++){ + if(d->subtitles[i].language==code){ + MSG_V("Selected DVD subtitle channel: %d language: %c%c\n", + d->subtitles[i].id, lang[0],lang[1]); + return d->subtitles[i].id; + } + } + lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang; + } + MSG_WARN("No matching DVD subtitle language found!\n"); + return -1; +} + +static int __FASTCALL__ dvd_lang_from_sid(stream_t *stream, int id) +{ + dvd_priv_t *d; + if (!stream) return 0; + d = reinterpret_cast<dvd_priv_t*>(stream->priv); + if (!d) return 0; + if (id >= d->nr_of_subtitles) return 0; + return d->subtitles[id].language; +} + +static int __FASTCALL__ dvd_next_title(dvd_priv_t *d,int dvd_title) +{ + int ttn,pgc_id,pgn; + dvd_reader_t *dvd; + dvd_file_t *title; + ifo_handle_t *vmg_file; + tt_srpt_t *tt_srpt; + ifo_handle_t *vts_file; + + MSG_V("dvd_next_title %d\n",dvd_title); + + tt_srpt = d->tt_srpt; + vmg_file = d->vmg_file; + dvd = d->dvd; + if(d->vts_file) ifoClose(d->vts_file); + if(d->title) DVDCloseFile(d->title); + /** + * Load the VTS information for the title set our title is in. + */ + vts_file = ifoOpen( dvd, tt_srpt->title[dvd_title].title_set_nr ); + if( !vts_file ) { + MSG_ERR( MSGTR_DVDnoIFO, + tt_srpt->title[dvd_title].title_set_nr ); + ifoClose( vmg_file ); + DVDClose( dvd ); + return 0; + } + /** + * We've got enough info, time to open the title set data. + */ + title = DVDOpenFile( dvd, tt_srpt->title[dvd_title].title_set_nr, + DVD_READ_TITLE_VOBS ); + if( !title ) { + MSG_ERR( MSGTR_DVDnoVOBs, + tt_srpt->title[dvd_title].title_set_nr ); + ifoClose( vts_file ); + ifoClose( vmg_file ); + DVDClose( dvd ); + return 0; + } + d->vts_file=vts_file; + d->title=title; + + ttn = tt_srpt->title[dvd_title].vts_ttn - 1; + + /** + * Check number of audio channels and types + */ + { + const int ac3aid = 128; + const int dtsaid = 136; + const int mpegaid = 0; + const int pcmaid = 160; + + d->nr_of_channels=0; + + if ( vts_file->vts_pgcit ) + { + int i; + for ( i=0;i<8;i++ ) + if ( vts_file->vts_pgcit->pgci_srp[0].pgc->audio_control[i] & 0x8000 ) + { + audio_attr_t * audio = &vts_file->vtsi_mat->vts_audio_attr[i]; + int language = 0; + char tmp[] = "unknown"; + + if ( audio->lang_type == 1 ) + { + language=audio->lang_code; + tmp[0]=language>>8; + tmp[1]=language&0xff; + tmp[2]=0; + } + + d->audio_streams[d->nr_of_channels].language=language; + d->audio_streams[d->nr_of_channels].id=vts_file->vts_pgcit->pgci_srp[ttn].pgc->audio_control[i] >> 8 & 7; + switch ( audio->audio_format ) + { + case 0: // ac3 + d->audio_streams[d->nr_of_channels].id+=ac3aid; + break; + case 6: // dts + d->audio_streams[d->nr_of_channels].id+=dtsaid; + break; + case 2: // mpeg layer 1/2/3 + case 3: // mpeg2 ext + d->audio_streams[d->nr_of_channels].id+=mpegaid; + break; + case 4: // lpcm + d->audio_streams[d->nr_of_channels].id+=pcmaid; + break; + } + + d->audio_streams[d->nr_of_channels].type=audio->audio_format; + // Pontscho: to my mind, tha channels: + // 1 - stereo + // 5 - 5.1 + d->audio_streams[d->nr_of_channels].channels=audio->channels; + MSG_V("[open] audio stream: %d audio format: %s (%s) language: %s aid: %d\n", + d->nr_of_channels, + dvd_audio_stream_types[ audio->audio_format ], + dvd_audio_stream_channels[ audio->channels ], + tmp, + d->audio_streams[d->nr_of_channels].id + ); + + d->nr_of_channels++; + } + } + MSG_V("[open] number of audio channels on disk: %d.\n",d->nr_of_channels ); + } + + /** + * Check number of subtitles and language + */ + { + int i; + + d->nr_of_subtitles=0; + for ( i=0;i<32;i++ ) + if ( vts_file->vts_pgcit->pgci_srp[0].pgc->subp_control[i] & 0x80000000 ) + { + subp_attr_t * subtitle = &vts_file->vtsi_mat->vts_subp_attr[i]; + video_attr_t *video = &vts_file->vtsi_mat->vts_video_attr; + int language = 0; + char tmp[] = "unknown"; + + if ( subtitle->type == 1 ) + { + language=subtitle->lang_code; + tmp[0]=language>>8; + tmp[1]=language&0xff; + tmp[2]=0; + } + + d->subtitles[ d->nr_of_subtitles ].language=language; + d->subtitles[ d->nr_of_subtitles ].id=d->nr_of_subtitles; + if(video->display_aspect_ratio == 0) /* 4:3 */ + d->subtitles[d->nr_of_subtitles].id = vts_file->vts_pgcit->pgci_srp[ttn].pgc->subp_control[i] >> 24 & 31; + else if(video->display_aspect_ratio == 3) /* 16:9 */ + d->subtitles[d->nr_of_subtitles].id = vts_file->vts_pgcit->pgci_srp[ttn].pgc->subp_control[i] >> 8 & 31; + + MSG_V("[open] subtitle ( sid ): %d language: %s\n", + d->nr_of_subtitles, + tmp + ); + d->nr_of_subtitles++; + } + MSG_V("[open] number of subtitles on disk: %d\n",d->nr_of_subtitles ); + } + + /** + * Determine which program chain we want to watch. This is based on the + * chapter number. + */ + pgc_id = vts_file->vts_ptt_srpt->title[ttn].ptt[dvd_chapter].pgcn; // local + pgn = vts_file->vts_ptt_srpt->title[ttn].ptt[dvd_chapter].pgn; // local + d->cur_pgc = vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc; + d->cur_cell = d->cur_pgc->program_map[pgn-1] - 1; // start playback here + d->packs_left=-1; // for Navi stuff + d->angle_seek=0; + /* XXX dvd_last_chapter is in the range 1..nr_of_ptts */ + if ( dvd_last_chapter > 0 && dvd_last_chapter < tt_srpt->title[dvd_title].nr_of_ptts ) { + pgn=vts_file->vts_ptt_srpt->title[ttn].ptt[dvd_last_chapter].pgn; + d->last_cell=d->cur_pgc->program_map[pgn-1] - 1; + } + else + d->last_cell=d->cur_pgc->nr_of_cells; + + if( d->cur_pgc->cell_playback[d->cur_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; + d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; + d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; + MSG_V( "DVD start cell: %d pack: 0x%X-0x%X \n",d->cur_cell,d->cur_pack,d->cell_last_pack); + + return 1; +} + +static int __FASTCALL__ dvd_next_cell(dvd_priv_t *d){ + int next_cell=d->cur_cell; + + MSG_V( "dvd_next_cell: next1=0x%X \n",next_cell); + + if( d->cur_pgc->cell_playback[ next_cell ].block_type + == BLOCK_TYPE_ANGLE_BLOCK ) { + while(next_cell<d->last_cell){ + if( d->cur_pgc->cell_playback[next_cell].block_mode + == BLOCK_MODE_LAST_CELL ) break; + ++next_cell; + } + } + MSG_V( "dvd_next_cell: next2=0x%X \n",next_cell); + + ++next_cell; + if(next_cell>=d->last_cell) return -1; // EOF + if( d->cur_pgc->cell_playback[next_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ){ + next_cell+=dvd_angle; + if(next_cell>=d->last_cell) return -1; // EOF + } + MSG_V( "dvd_next_cell: next3=0x%X \n",next_cell); + return next_cell; +} + +static void __FASTCALL__ dvd_seek(stream_t* stream,dvd_priv_t *d,int pos); +static int __FASTCALL__ dvd_read_sector(stream_t* stream,dvd_priv_t *d,unsigned char* data){ + int len; +read_first: + if(d->packs_left==0){ + /** + * If we're not at the end of this cell, we can determine the next + * VOBU to display using the VOBU_SRI information section of the + * DSI. Using this value correctly follows the current angle, + * avoiding the doubled scenes in The Matrix, and makes our life + * really happy. + * + * Otherwise, we set our next address past the end of this cell to + * force the code above to go to the next cell in the program. + */ + if( d->dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL ) { + d->cur_pack= d->dsi_pack.dsi_gi.nv_pck_lbn + + ( d->dsi_pack.vobu_sri.next_vobu & 0x3fffffff ); + MSG_V( "Navi new pos=0x%X \n",d->cur_pack); + } else { + // end of cell! find next cell! + MSG_V( "--- END OF CELL !!! ---\n"); + d->cur_pack=d->cell_last_pack+1; + } + } + +read_next: + + if(d->cur_pack>d->cell_last_pack){ + // end of cell! + int next=dvd_next_cell(d); + if(next>=0){ + d->cur_cell=next; + // if( d->cur_pgc->cell_playback[d->cur_cell].block_type + // == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; + d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; + d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; + MSG_V( "DVD next cell: %d pack: 0x%X-0x%X \n",d->cur_cell,d->cur_pack,d->cell_last_pack); + } else + if(d->cur_title<d->last_title) + { + d->cur_title++; + dvd_next_title(d,d->cur_title); + goto read_first; + } + else return -1; // EOF + } + + len = DVDReadBlocks( d->title, d->cur_pack, 1, data ); + if(!len) return -1; //error +/* +Navigation packets are PES packets with a stream id 0xbf, i.e. +private stream 2. It's made up of PCI, Presentation Control Information +and DSI, Data Search Information. + + 0 6 7 0x3d4+0x6 0x3d4+0xb 0x3d4+0xc + +------+---------+----------------------+------+---------+-----------------+ + |Packet|Substream| PCI |Packet|Substream| DSI | + |Header| ID | Data |Header| ID | Data | + +------+---------+----------------------+------+---------+-----------------+ + + The packet head is just a PES packet header, a packet start code, a stream id +and a packet length. The first packet lenght is 0x3d4, the length of the PCI data +plus one. The second packet length is 0x3fa, the length of DSI data plus one. +The substream id for PCI packet is 0x00 and 0x01 for DSI. +*/ + if(data[38]==0 && data[39]==0 && data[40]==1 && data[41]==0xBF && + data[1024]==0 && data[1025]==0 && data[1026]==1 && data[1027]==0xBF){ + // found a Navi packet!!! +#if LIBDVDREAD_VERSION >= DVDREAD_VERSION(0,9,0) + navRead_DSI( &d->dsi_pack, &(data[DSI_START_BYTE]) ); + navRead_PCI( &d->pci_pack, &(data[DSI_START_BYTE-0x3DA]) ); +#else + navRead_DSI( &d->dsi_pack, &(data[DSI_START_BYTE]), sizeof(dsi_t)); + navRead_PCI( &d->pci_pack, &(data[DSI_START_BYTE-0x3DA]), sizeof(pci_t)); +#endif + /* + TODO!: if num_angles!=0 and d->dsi_pack.sml_agli.data[dvd_angle].address + doesn't work :( + > Invalid NAVIpacket! lba=30 gsi_navi=8002F pci_navi=8002F angle=0 + */ + if(d->cur_pack != d->dsi_pack.dsi_gi.nv_pck_lbn){ + MSG_V( "Invalid NAVIpacket! lba=%X gsi_navi=%X pci_navi=%X angle=%X\n" + ,d->cur_pack + ,d->dsi_pack.dsi_gi.nv_pck_lbn + ,d->pci_pack.pci_gi.nv_pck_lbn + ,d->dsi_pack.sml_agli.data[dvd_angle].address + ); + } else { + // process! + float vobu_s_pts,vobu_e_pts; + vobu_s_pts=d->pci_pack.pci_gi.vobu_s_ptm/90000.; + vobu_e_pts=d->pci_pack.pci_gi.vobu_e_ptm/90000.; + d->packs_left = d->dsi_pack.dsi_gi.vobu_ea; + MSG_V( "Found NAVI packet! lba=%X angle=%X len=%d vobu_s_pts=%f vobu_e_pts=%f\n" + ,d->cur_pack,d->packs_left + ,d->dsi_pack.sml_agli.data[dvd_angle].address + ,vobu_s_pts,vobu_e_pts); + + if(d->angle_seek){ + int i,skip=0; +#if defined(__GNUC__) && ( defined(__sparc__) || defined(hpux) ) + // workaround for a bug in the sparc/hpux version of gcc 2.95.X ... 3.2, + // it generates incorrect code for unaligned access to a packed + // structure member, resulting in an mplayer crash with a SIGBUS + // signal. + // + // See also gcc problem report PR c/7847: + // http://gcc.gnu.org/cgi-bin/gnatsweb.pl?database=gcc&cmd=view+audit-trail&pr=7847 + for(i=0;i<9;i++){ // check if all values zero: + typeof(d->dsi_pack.sml_agli.data[i].address) tmp_addr; + memcpy(&tmp_addr,&d->dsi_pack.sml_agli.data[i].address,sizeof(tmp_addr)); + if((skip=tmp_addr)!=0) break; + } +#else + for(i=0;i<9;i++) // check if all values zero: + if((skip=d->dsi_pack.sml_agli.data[i].address)!=0) break; +#endif + if(skip){ + // sml_agli table has valid data (at least one non-zero): + d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+ + d->dsi_pack.sml_agli.data[dvd_angle].address; + d->angle_seek=0; + MSG_V("Angle-seek synced using sml_agli map! new_lba=0x%X\n",d->cur_pack); + } else { + // check if we're in the right cell, jump otherwise: + if( (d->dsi_pack.dsi_gi.vobu_c_idn==d->cur_pgc->cell_position[d->cur_cell].cell_nr) && + (d->dsi_pack.dsi_gi.vobu_vob_idn==d->cur_pgc->cell_position[d->cur_cell].vob_id_nr) ){ + d->angle_seek=0; + MSG_V("Angle-seek synced by cell/vob IDN search!\n"); + } else { + // wrong angle, skip this vobu: + d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+ + d->dsi_pack.dsi_gi.vobu_ea; + d->angle_seek=2; // DEBUG + } + } + } + if(vobu_s_pts < d->vobu_e_pts) + { + stream->stream_pts += d->vobu_e_pts-vobu_s_pts; + MSG_V("DVD's discontinuities found! Applying delta: %f\n",stream->stream_pts); + } + e... [truncated message content] |
From: <nic...@us...> - 2012-11-22 10:20:01
|
Revision: 429 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=429&view=rev Author: nickols_k Date: 2012-11-22 10:19:50 +0000 (Thu, 22 Nov 2012) Log Message: ----------- switch to vidix v1.5 Modified Paths: -------------- NEWS functions mplayerxp/configure mplayerxp/libvo/vo_null.cpp mplayerxp/libvo/vo_x11.cpp mplayerxp/libvo/vosub_vidix.cpp Modified: NEWS =================================================================== --- NEWS 2012-11-21 17:19:17 UTC (rev 428) +++ NEWS 2012-11-22 10:19:50 UTC (rev 429) @@ -13,6 +13,8 @@ libefence but with extended functionality. * Upgrade ffmpeg upto ffmpeg-1.0.0. Now MPlayerXP finds codecs within of libavcodec even they are unlisted in codecs.conf +* Project was rewritten in C++ +* Use vidix v1.5 with C++ support Version 0.7.96 Modified: functions =================================================================== --- functions 2012-11-21 17:19:17 UTC (rev 428) +++ functions 2012-11-22 10:19:50 UTC (rev 429) @@ -290,6 +290,10 @@ append CFLAGS "$@" } +add_cxxflags(){ + append CXXFLAGS "$@" +} + add_asflags(){ append ASFLAGS "$@" } @@ -298,6 +302,10 @@ append LDFLAGS "$@" } +add_ldxxflags(){ + append LDXXFLAGS "$@" +} + add_extralibs(){ append extralibs "$@" } @@ -314,6 +322,13 @@ check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC } +check_cxx(){ + log check_cxx "$@" + cat >$TMPC + log_file $TMPC + check_cmd $cxx $CXXFLAGS "$@" -c -o $TMPO $TMPC +} + check_cpp(){ log check_cpp "$@" cat >$TMPC @@ -344,6 +359,12 @@ check_cmd $cc $LDFLAGS -o $TMPE $TMPO $extralibs "$@" } +check_ldxx(){ + log check_ld "$@" + check_cxx || return + check_cmd $cxx $LDFLAGS $LDXXFLAGS -o $TMPE $TMPO $extralibs "$@" +} + test_cflags(){ log check_cflags "$@" check_cc "$@" <<EOF && return 0 || return 1 @@ -351,10 +372,21 @@ EOF } +test_cxxflags(){ + log check_cxxflags "$@" + check_cxx "$@" <<EOF && return 0 || return 1 +int x; +EOF +} + check_cflags(){ test_cflags "$@" && add_cflags "$@" } +check_cxxflags(){ + test_cxxflags "$@" && add_cxxflags "$@" +} + is_in_cflags(){ value=$1 shift @@ -365,6 +397,16 @@ return 1 } +is_in_cxxflags(){ + value=$1 + shift + for var in $CXXFLAGS; do + tmp=$(trim `echo $var | cut -d '=' -f 1`) + [ $tmp = $value ] && return 0 + done + return 1 +} + test_ldflags(){ log check_ldflags "$@" check_ld "$@" <<EOF && return 0 || return 1 @@ -378,6 +420,10 @@ test_ldflags "$@" && add_ldflags "$@" } +check_ldxxflags(){ + test_ldxxflags "$@" && add_ldxxflags "$@" +} + check_header(){ log check_header "$@" header=$1 @@ -509,6 +555,30 @@ enabled $func && return 0 || return 1 } +check_class2(){ + echocheck "$2" + log check_class2 "$@" + headers=$1 + class=$2 + shift 2 + disable $class + incs="" + for hdr in $headers; do + incs="$incs +#include <$hdr>" + done + check_ldxx "$@" <<EOF && enable $class +$incs +class $class; +int main(void){ + return 0; +} +EOF + enabled $class && answer="yes" || answer="no" + echores $answer + enabled $class && return 0 || return 1 +} + check_lfunc2(){ echocheck "$2" log check_lfunc2 "$@" @@ -603,6 +673,18 @@ return $err } +check_libxx2(){ + log check_libxx2 "$@" + headers="$1" + class="$2" + shift 2 + temp_extralibs "$@" + check_class2 "$headers" $class && add_extralibs "$@" + err=$? + restore_flags + return $err +} + check_llib(){ log check_lib "$@" header="$1" @@ -811,6 +893,19 @@ echores $answer } +xxrequire2(){ + echocheck "$1" + name="$1" + headers="$2" + class="$3" + shift 3 + disable $name + check_libxx2 "$headers" $class "$@" && enable $name + answer="no" + enabled $name && answer="yes" + echores $answer +} + lrequire(){ echocheck "$1" name="$1" @@ -889,6 +984,19 @@ return "$TMP" } +cxx_check() { + echo >> "$TMPLOG" + cat "$TMPC" >> "$TMPLOG" + echo >> "$TMPLOG" + ( check_cmd $cxx $CXXFLAGS $inc_extra $ld_static $ld_extra "$TMPC" -o "$TMPO" "$@" ) >> "$TMPLOG" 2>&1 + TMP="$?" + echo >> "$TMPLOG" + echo "ldd $TMPO" >> "$TMPLOG" + ( ldd "$TMPO" ) >> "$TMPLOG" 2>&1 + echo >> "$TMPLOG" + return "$TMP" +} + # Display error message, flushes tempfile, exit warning() { log "Warning: $@" Modified: mplayerxp/configure =================================================================== --- mplayerxp/configure 2012-11-21 17:19:17 UTC (rev 428) +++ mplayerxp/configure 2012-11-22 10:19:50 UTC (rev 429) @@ -769,7 +769,7 @@ enabled dbg23 def_debug='#define MP_DEBUG 1' || def_debug='#undef MP_DEBUG' # Checking for VIDIX -enabled vidix && require2 vidix vidix/vidixlib.h vdlAllocFourccS -lvidix +enabled vidix && xxrequire2 vidix "vidix/vidix.h vidix/vidixlibxx.h" Vidix -lvidixxx print_config CONFIG_ mp_config.h mp_config.mak vidix enabled x11 && enabled vidix && vomodules="vidix $vomodules" || novomodules="vidix $novomodules" Modified: mplayerxp/libvo/vo_null.cpp =================================================================== --- mplayerxp/libvo/vo_null.cpp 2012-11-21 17:19:17 UTC (rev 428) +++ mplayerxp/libvo/vo_null.cpp 2012-11-22 10:19:50 UTC (rev 429) @@ -34,7 +34,7 @@ #include "video_out_internal.h" #include "dri_vo.h" #ifdef CONFIG_VIDIX -#include <vidix/vidixlib.h> +#include <vidix/vidix.h> #endif #include "vo_msg.h" Modified: mplayerxp/libvo/vo_x11.cpp =================================================================== --- mplayerxp/libvo/vo_x11.cpp 2012-11-21 17:19:17 UTC (rev 428) +++ mplayerxp/libvo/vo_x11.cpp 2012-11-22 10:19:50 UTC (rev 429) @@ -47,7 +47,7 @@ #include "video_out.h" #ifdef CONFIG_VIDIX #include "vosub_vidix.h" -#include <vidix/vidixlib.h> +#include <vidix/vidix.h> #endif #include "dri_vo.h" #include "xmpcore/mp_image.h" @@ -310,16 +310,14 @@ } else MSG_V("vo_vesa: Using VIDIX\n"); if(vidix_start(vo)!=0) return MPXP_False; if (vidix_grkey_support(vo)) { - vidix_grkey_t *gr_key; - gr_key = vdlAllocGrKeyS(); - vidix_grkey_get(vo,gr_key); - gr_key->key_op = KEYS_PUT; - gr_key->ckey.op = CKEY_TRUE; - gr_key->ckey.red = 255; - gr_key->ckey.green = 0; - gr_key->ckey.blue = 255; - vidix_grkey_set(vo,gr_key); - vdlFreeGrKeyS(gr_key); + vidix_grkey_t gr_key; + vidix_grkey_get(vo,&gr_key); + gr_key.key_op = KEYS_PUT; + gr_key.ckey.op = CKEY_TRUE; + gr_key.ckey.red = 255; + gr_key.ckey.green = 0; + gr_key.ckey.blue = 255; + vidix_grkey_set(vo,&gr_key); } } #endif @@ -411,8 +409,9 @@ flags = 0; #ifdef CONFIG_VIDIX if(memcmp(sd,"vidix",5) == 0) priv->vidix_name = &sd[5]; /* priv->vidix_name will be valid within init() */ + else #endif - else { MSG_ERR("vo_vesa: Unknown subdevice: '%s'\n", sd); return 0xFFFFFFFFUL; } + { MSG_ERR("vo_vesa: Unknown subdevice: '%s'\n", sd); return 0xFFFFFFFFUL; } return flags; } Modified: mplayerxp/libvo/vosub_vidix.cpp =================================================================== --- mplayerxp/libvo/vosub_vidix.cpp 2012-11-21 17:19:17 UTC (rev 428) +++ mplayerxp/libvo/vosub_vidix.cpp 2012-11-22 10:19:50 UTC (rev 429) @@ -24,7 +24,8 @@ #include "mplayerxp.h" #include "osdep/mplib.h" -#include <vidix/vidixlib.h> +#include <vidix/vidix.h> +#include <vidix/vidixlibxx.h> #include "video_out.h" #include "vosub_vidix.h" @@ -36,32 +37,28 @@ #include "xmpcore/mp_image.h" #include "vo_msg.h" +using namespace vidix; + #define NUM_FRAMES MAX_DRI_BUFFERS /* Temporary: driver will overwrite it */ typedef struct priv_s { + priv_s(Vidix& it) : vidix(it) {} + virtual ~priv_s() {} + unsigned image_Bpp,image_height,image_width,src_format,forced_fourcc; - VDL_HANDLE handler; + Vidix& vidix; uint8_t * mem; int video_on; - vidix_capability_t* cap; - vidix_playback_t* play; - vidix_fourcc_t* fourcc; - vidix_yuv_t* dstrides; - const vo_functions_t*vo_server; int inited; - vidix_video_eq_t eq; /* bus mastering */ int bm_locked; /* requires root privelegies */ uint8_t * bm_buffs[NUM_FRAMES]; unsigned bm_total_frames,bm_slow_frames; - - vidix_dma_t vdma; - MPXP_Rc (* __FASTCALL__ server_control)(vo_data_t*,uint32_t request, any_t*data); }priv_t; static int __FASTCALL__ vidix_get_video_eq(const vo_data_t* vo,vo_videq_t *info); @@ -73,14 +70,14 @@ int vidix_start(vo_data_t* vo) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); int err; - if((err=vdlPlaybackOn(priv->handler))!=0) { + if((err=priv.vidix.playback_on())!=0) { MSG_FATAL("Can't start playback: %s\n",strerror(err)); return -1; } - priv->video_on=1; - if (priv->cap->flags & FLAG_EQUALIZER) { + priv.video_on=1; + if (priv.vidix.cap.flags & FLAG_EQUALIZER) { MSG_V("vo_gamma_brightness=%i\n" "vo_gamma_saturation=%i\n" "vo_gamma_contrast=%i\n" @@ -95,17 +92,17 @@ ,vo_conf.gamma.red_intensity ,vo_conf.gamma.green_intensity ,vo_conf.gamma.blue_intensity); - /* To use full set of priv->eq.cap */ - if(vdlPlaybackGetEq(priv->handler,&priv->eq) == 0) { - priv->eq.brightness = vo_conf.gamma.brightness; - priv->eq.saturation = vo_conf.gamma.saturation; - priv->eq.contrast = vo_conf.gamma.contrast; - priv->eq.hue = vo_conf.gamma.hue; - priv->eq.red_intensity = vo_conf.gamma.red_intensity; - priv->eq.green_intensity = vo_conf.gamma.green_intensity; - priv->eq.blue_intensity = vo_conf.gamma.blue_intensity; - priv->eq.flags = VEQ_FLG_ITU_R_BT_601; - vdlPlaybackSetEq(priv->handler,&priv->eq); + /* To use full set of priv.video_eq.cap */ + if(priv.vidix.get_eq() == 0) { + priv.vidix.video_eq.brightness = vo_conf.gamma.brightness; + priv.vidix.video_eq.saturation = vo_conf.gamma.saturation; + priv.vidix.video_eq.contrast = vo_conf.gamma.contrast; + priv.vidix.video_eq.hue = vo_conf.gamma.hue; + priv.vidix.video_eq.red_intensity = vo_conf.gamma.red_intensity; + priv.vidix.video_eq.green_intensity = vo_conf.gamma.green_intensity; + priv.vidix.video_eq.blue_intensity = vo_conf.gamma.blue_intensity; + priv.vidix.video_eq.flags = VEQ_FLG_ITU_R_BT_601; + priv.vidix.set_eq(); } } return 0; @@ -113,64 +110,63 @@ int vidix_stop(vo_data_t* vo) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); int err; - if((err=vdlPlaybackOff(priv->handler))!=0) { + if((err=priv.vidix.playback_off())!=0) { MSG_ERR("Can't stop playback: %s\n",strerror(err)); return -1; } - priv->video_on=0; + priv.video_on=0; return 0; } void vidix_term(vo_data_t* vo) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); size_t i; - priv->inited=0; + priv.inited=0; MSG_DBG2("vidix_term() was called\n"); vidix_stop(vo); - vdlClose(priv->handler); if(vo_conf.use_bm) { for(i=0;i<vo_conf.xp_buffs;i++) { - if(priv->bm_locked) munlock(priv->bm_buffs[i],priv->play->frame_size); - mp_free(priv->bm_buffs[i]); - priv->bm_buffs[i]=NULL; + if(priv.bm_locked) munlock(priv.bm_buffs[i],priv.vidix.playback.frame_size); + delete priv.bm_buffs[i]; + priv.bm_buffs[i]=NULL; } - if(priv->bm_slow_frames) + if(priv.bm_slow_frames) MSG_WARN("from %u frames %u were copied through memcpy()\n" - ,priv->bm_total_frames,priv->bm_slow_frames); + ,priv.bm_total_frames,priv.bm_slow_frames); } - vdlFreeCapabilityS(priv->cap); priv->cap=NULL; - vdlFreePlaybackS(priv->play); priv->play=NULL; - vdlFreeFourccS(priv->fourcc); priv->fourcc=NULL; - vdlFreeYUVS(priv->dstrides); priv->dstrides=NULL; } static void __FASTCALL__ vidix_copy_dma(const vo_data_t* vo,unsigned idx,int sync_mode) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); int err,i; int dma_busy; MSG_DBG2("vidix_copy_dma(%u,%i) was called\n",idx,sync_mode); - priv->bm_total_frames++; - if(idx > priv->play->num_frames-1 && priv->play->num_frames>1) { + priv.bm_total_frames++; + if(idx > priv.vidix.playback.num_frames-1 && priv.vidix.playback.num_frames>1) { MSG_FATAL("\nDetected internal error!\n" - "Request to copy %u frame into %u array\n",idx,priv->play->num_frames); + "Request to copy %u frame into %u array\n",idx,priv.vidix.playback.num_frames); return; } - dma_busy = vdlQueryDMAStatus(priv->handler); + dma_busy = priv.vidix.dma_status(); i=5; if(!sync_mode) - while(dma_busy && i) { usleep(0); dma_busy = vdlQueryDMAStatus(priv->handler); i--; } + while(dma_busy && i) { + usleep(0); + dma_busy = priv.vidix.dma_status(); + i--; + } if(!dma_busy || sync_mode) { - priv->vdma.src = priv->bm_buffs[idx]; - priv->vdma.dest_offset = priv->play->offsets[priv->play->num_frames>1?idx:0]; - priv->vdma.size = priv->play->frame_size; - priv->vdma.flags = sync_mode?BM_DMA_SYNC:BM_DMA_ASYNC; - if(priv->bm_locked) priv->vdma.flags = priv->vdma.flags | BM_DMA_FIXED_BUFFS; - priv->vdma.idx = idx; - err=vdlPlaybackCopyFrame(priv->handler,&priv->vdma); + priv.vidix.dma.src = priv.bm_buffs[idx]; + priv.vidix.dma.dest_offset = priv.vidix.playback.offsets[priv.vidix.playback.num_frames>1?idx:0]; + priv.vidix.dma.size = priv.vidix.playback.frame_size; + priv.vidix.dma.flags = sync_mode?BM_DMA_SYNC:BM_DMA_ASYNC; + if(priv.bm_locked) priv.vidix.dma.flags |= BM_DMA_FIXED_BUFFS; + priv.vidix.dma.idx = idx; + err=priv.vidix.dma_copy_frame(); if(err) { /* We can switch back to DR here but for now exit */ MSG_FATAL("\nerror '%s' occured during DMA transfer\n" @@ -181,131 +177,138 @@ printf("frame is DMA copied\n"); #endif } else { - memcpy(reinterpret_cast<any_t*>(reinterpret_cast<long>(priv->play->dga_addr)+priv->play->offsets[0]),priv->bm_buffs[idx],priv->play->frame_size); + memcpy(reinterpret_cast<any_t*>(reinterpret_cast<long>(priv.vidix.playback.dga_addr)+priv.vidix.playback.offsets[0]),priv.bm_buffs[idx],priv.vidix.playback.frame_size); MSG_WARN("DMA frame is memcpy() copied\n"); - priv->bm_slow_frames++; + priv.bm_slow_frames++; } } static void __FASTCALL__ vidix_select_frame(vo_data_t* vo,unsigned idx) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); MSG_DBG2("vidix_select_frame() was called\n"); if(vo_conf.use_bm == 1) vidix_copy_dma(vo,idx,0); - else vdlPlaybackFrameSelect(priv->handler,idx); + else priv.vidix.frame_select(idx); } static MPXP_Rc __FASTCALL__ vidix_query_fourcc(const vo_data_t* vo,vo_query_fourcc_t* format) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); MSG_DBG2("query_format was called: %x (%s)\n",format->fourcc,vo_format_name(format->fourcc)); - priv->fourcc->fourcc = format->fourcc; - priv->fourcc->srcw = format->w; - priv->fourcc->srch = format->h; - vdlQueryFourcc(priv->handler,priv->fourcc); - format->flags = (priv->fourcc->depth==VID_DEPTH_NONE)? VOCAP_NA : VOCAP_SUPPORTED|VOCAP_HWSCALER; + priv.vidix.fourcc.fourcc = format->fourcc; + priv.vidix.fourcc.srcw = format->w; + priv.vidix.fourcc.srch = format->h; + priv.vidix.query_fourcc(); + format->flags = (priv.vidix.fourcc.depth==VID_DEPTH_NONE)? VOCAP_NA : VOCAP_SUPPORTED|VOCAP_HWSCALER; return MPXP_Ok; } int __FASTCALL__ vidix_grkey_support(const vo_data_t* vo) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); - int retval = priv->fourcc->flags & VID_CAP_COLORKEY; + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); + int retval = priv.vidix.fourcc.flags & VID_CAP_COLORKEY; MSG_DBG2("query_grkey_support: %i\n",retval); return retval; } int __FASTCALL__ vidix_grkey_get(const vo_data_t* vo,vidix_grkey_t *gr_key) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); - return vdlGetGrKeys(priv->handler, gr_key); + int rc; + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); + rc=priv.vidix.get_gr_keys(); + *gr_key=priv.vidix.grkey; + return rc; } int __FASTCALL__ vidix_grkey_set(const vo_data_t* vo,const vidix_grkey_t *gr_key) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); - return vdlSetGrKeys(priv->handler, gr_key); + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); + priv.vidix.grkey=*gr_key; + return priv.vidix.set_gr_keys(); } static int __FASTCALL__ vidix_get_video_eq(const vo_data_t* vo,vo_videq_t *info) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); int rval; - vidix_video_eq_t eq; - if(!priv->video_on) return EPERM; - rval = vdlPlaybackGetEq(priv->handler, &eq); + if(!priv.video_on) return EPERM; + rval = priv.vidix.get_eq(); if(!rval) { - if(!strcmp(info->name,VO_EC_BRIGHTNESS) && eq.cap&VEQ_CAP_BRIGHTNESS) - info->value=eq.brightness; - else if(!strcmp(info->name,VO_EC_SATURATION) && eq.cap&VEQ_CAP_SATURATION) - info->value=eq.saturation; - else if(!strcmp(info->name,VO_EC_CONTRAST) && eq.cap&VEQ_CAP_CONTRAST) - info->value=eq.contrast; - else if(!strcmp(info->name,VO_EC_HUE) && eq.cap&VEQ_CAP_HUE) - info->value=eq.hue; - else if(!strcmp(info->name,VO_EC_RED_INTENSITY) && eq.cap&VEQ_CAP_RGB_INTENSITY) - info->value=eq.red_intensity; - else if(!strcmp(info->name,VO_EC_GREEN_INTENSITY) && eq.cap&VEQ_CAP_RGB_INTENSITY) - info->value=eq.green_intensity; - else if(!strcmp(info->name,VO_EC_BLUE_INTENSITY) && eq.cap&VEQ_CAP_RGB_INTENSITY) - info->value=eq.blue_intensity; + if(!strcmp(info->name,VO_EC_BRIGHTNESS) && priv.vidix.video_eq.cap&VEQ_CAP_BRIGHTNESS) + info->value=priv.vidix.video_eq.brightness; + else if(!strcmp(info->name,VO_EC_SATURATION) && priv.vidix.video_eq.cap&VEQ_CAP_SATURATION) + info->value=priv.vidix.video_eq.saturation; + else if(!strcmp(info->name,VO_EC_CONTRAST) && priv.vidix.video_eq.cap&VEQ_CAP_CONTRAST) + info->value=priv.vidix.video_eq.contrast; + else if(!strcmp(info->name,VO_EC_HUE) && priv.vidix.video_eq.cap&VEQ_CAP_HUE) + info->value=priv.vidix.video_eq.hue; + else if(!strcmp(info->name,VO_EC_RED_INTENSITY) && priv.vidix.video_eq.cap&VEQ_CAP_RGB_INTENSITY) + info->value=priv.vidix.video_eq.red_intensity; + else if(!strcmp(info->name,VO_EC_GREEN_INTENSITY) && priv.vidix.video_eq.cap&VEQ_CAP_RGB_INTENSITY) + info->value=priv.vidix.video_eq.green_intensity; + else if(!strcmp(info->name,VO_EC_BLUE_INTENSITY) && priv.vidix.video_eq.cap&VEQ_CAP_RGB_INTENSITY) + info->value=priv.vidix.video_eq.blue_intensity; } return rval; } static int __FASTCALL__ vidix_set_video_eq(const vo_data_t* vo,const vo_videq_t *info) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); int rval; - vidix_video_eq_t eq; - if(!priv->video_on) return EPERM; - rval= vdlPlaybackGetEq(priv->handler, &eq); + if(!priv.video_on) return EPERM; + rval = priv.vidix.get_eq(); if(!rval) { - if(!strcmp(info->name,VO_EC_BRIGHTNESS) && eq.cap&VEQ_CAP_BRIGHTNESS) - eq.brightness=info->value; - else if(!strcmp(info->name,VO_EC_SATURATION) && eq.cap&VEQ_CAP_SATURATION) - eq.saturation=info->value; - else if(!strcmp(info->name,VO_EC_CONTRAST) && eq.cap&VEQ_CAP_CONTRAST) - eq.contrast=info->value; - else if(!strcmp(info->name,VO_EC_HUE) && eq.cap&VEQ_CAP_HUE) - eq.hue=info->value; - else if(!strcmp(info->name,VO_EC_RED_INTENSITY) && eq.cap&VEQ_CAP_RGB_INTENSITY) - eq.red_intensity=info->value; - else if(!strcmp(info->name,VO_EC_GREEN_INTENSITY) && eq.cap&VEQ_CAP_RGB_INTENSITY) - eq.green_intensity=info->value; - else if(!strcmp(info->name,VO_EC_BLUE_INTENSITY) && eq.cap&VEQ_CAP_RGB_INTENSITY) - eq.blue_intensity=info->value; - rval= vdlPlaybackSetEq(priv->handler, &eq); + if(!strcmp(info->name,VO_EC_BRIGHTNESS) && priv.vidix.video_eq.cap&VEQ_CAP_BRIGHTNESS) + priv.vidix.video_eq.brightness=info->value; + else if(!strcmp(info->name,VO_EC_SATURATION) && priv.vidix.video_eq.cap&VEQ_CAP_SATURATION) + priv.vidix.video_eq.saturation=info->value; + else if(!strcmp(info->name,VO_EC_CONTRAST) && priv.vidix.video_eq.cap&VEQ_CAP_CONTRAST) + priv.vidix.video_eq.contrast=info->value; + else if(!strcmp(info->name,VO_EC_HUE) && priv.vidix.video_eq.cap&VEQ_CAP_HUE) + priv.vidix.video_eq.hue=info->value; + else if(!strcmp(info->name,VO_EC_RED_INTENSITY) && priv.vidix.video_eq.cap&VEQ_CAP_RGB_INTENSITY) + priv.vidix.video_eq.red_intensity=info->value; + else if(!strcmp(info->name,VO_EC_GREEN_INTENSITY) && priv.vidix.video_eq.cap&VEQ_CAP_RGB_INTENSITY) + priv.vidix.video_eq.green_intensity=info->value; + else if(!strcmp(info->name,VO_EC_BLUE_INTENSITY) && priv.vidix.video_eq.cap&VEQ_CAP_RGB_INTENSITY) + priv.vidix.video_eq.blue_intensity=info->value; + rval= priv.vidix.set_eq(); } return rval; } static int __FASTCALL__ vidix_get_num_fx(const vo_data_t* vo,unsigned *info) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); - if(!priv->video_on) return EPERM; - return vdlQueryNumOemEffects(priv->handler, info); + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); + if(!priv.video_on) return EPERM; + return priv.vidix.num_oemfx(*info); } static int __FASTCALL__ vidix_get_oem_fx(const vo_data_t* vo,vidix_oem_fx_t *info) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); - if(!priv->video_on) return EPERM; - return vdlGetOemEffect(priv->handler, info); + int rc; + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); + if(!priv.video_on) return EPERM; + rc=priv.vidix.get_oemfx(); + *info = priv.vidix.oemfx; + return rc; } static int __FASTCALL__ vidix_set_oem_fx(const vo_data_t* vo,const vidix_oem_fx_t *info) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); - if(!priv->video_on) return EPERM; - return vdlSetOemEffect(priv->handler, info); + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); + if(!priv.video_on) return EPERM; + priv.vidix.oemfx=*info; + return priv.vidix.set_oemfx(); } static int __FASTCALL__ vidix_set_deint(const vo_data_t* vo,const vidix_deinterlace_t *info) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); - if(!priv->video_on) return EPERM; - return vdlPlaybackSetDeint(priv->handler, info); + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); + if(!priv.video_on) return EPERM; + priv.vidix.deint=*info; + return priv.vidix.set_deint(); } #ifndef HAVE_MLOCK @@ -314,25 +317,12 @@ int munlock(const any_t*addr,size_t len) { return ENOSYS; } #endif -static MPXP_Rc alloc_vidix_structs(any_t* ctx) { - priv_t* priv=reinterpret_cast<priv_t*>(ctx); - if(!priv->cap) priv->cap = vdlAllocCapabilityS(); - if(!priv->play) priv->play = vdlAllocPlaybackS(); - if(!priv->fourcc) priv->fourcc = vdlAllocFourccS(); - if(!priv->dstrides) priv->dstrides = vdlAllocYUVS(); - if(!(priv->cap && priv->play && priv->fourcc && priv->dstrides)) { - MSG_FATAL("Can not alloc certain structures\n"); - return MPXP_False; - } - return MPXP_Ok; -} - MPXP_Rc __FASTCALL__ vidix_init(vo_data_t* vo,unsigned src_width,unsigned src_height, unsigned x_org,unsigned y_org,unsigned dst_width, unsigned dst_height,unsigned format,unsigned dest_bpp, unsigned vid_w,unsigned vid_h) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); size_t i; int err; static int video_clean=0; @@ -342,91 +332,90 @@ "format=%s dest_bpp=%u vid_w=%u vid_h=%u\n" ,src_width,src_height,x_org,y_org,dst_width,dst_height ,vo_format_name(format),dest_bpp,vid_w,vid_h); - if(((priv->cap->maxwidth != -1) && (vid_w > (unsigned)priv->cap->maxwidth)) || - ((priv->cap->minwidth != -1) && (vid_w < (unsigned)priv->cap->minwidth)) || - ((priv->cap->maxheight != -1) && (vid_h > (unsigned)priv->cap->maxheight)) || - ((priv->cap->minwidth != -1 ) && (vid_h < (unsigned)priv->cap->minheight))) { + if(((priv.vidix.cap.maxwidth != -1) && (vid_w > (unsigned)priv.vidix.cap.maxwidth)) || + ((priv.vidix.cap.minwidth != -1) && (vid_w < (unsigned)priv.vidix.cap.minwidth)) || + ((priv.vidix.cap.maxheight != -1) && (vid_h > (unsigned)priv.vidix.cap.maxheight)) || + ((priv.vidix.cap.minwidth != -1 ) && (vid_h < (unsigned)priv.vidix.cap.minheight))) { MSG_FATAL("video server has unsupported resolution (%dx%d), supported: %dx%d-%dx%d\n", - vid_w, vid_h, priv->cap->minwidth, priv->cap->minheight, - priv->cap->maxwidth, priv->cap->maxheight); + vid_w, vid_h, priv.vidix.cap.minwidth, priv.vidix.cap.minheight, + priv.vidix.cap.maxwidth, priv.vidix.cap.maxheight); return MPXP_False; } - priv->fourcc->fourcc = format; - vdlQueryFourcc(priv->handler,priv->fourcc); + priv.vidix.fourcc.fourcc = format; + priv.vidix.query_fourcc(); err = 0; switch(dest_bpp) { - case 1: err = ((priv->fourcc->depth & VID_DEPTH_1BPP) != VID_DEPTH_1BPP); break; - case 2: err = ((priv->fourcc->depth & VID_DEPTH_2BPP) != VID_DEPTH_2BPP); break; - case 4: err = ((priv->fourcc->depth & VID_DEPTH_4BPP) != VID_DEPTH_4BPP); break; - case 8: err = ((priv->fourcc->depth & VID_DEPTH_8BPP) != VID_DEPTH_8BPP); break; - case 12:err = ((priv->fourcc->depth & VID_DEPTH_12BPP) != VID_DEPTH_12BPP); break; - case 15:err = ((priv->fourcc->depth & VID_DEPTH_15BPP) != VID_DEPTH_15BPP); break; - case 16:err = ((priv->fourcc->depth & VID_DEPTH_16BPP) != VID_DEPTH_16BPP); break; - case 24:err = ((priv->fourcc->depth & VID_DEPTH_24BPP) != VID_DEPTH_24BPP); break; - case 32:err = ((priv->fourcc->depth & VID_DEPTH_32BPP) != VID_DEPTH_32BPP); break; + case 1: err = ((priv.vidix.fourcc.depth & VID_DEPTH_1BPP) != VID_DEPTH_1BPP); break; + case 2: err = ((priv.vidix.fourcc.depth & VID_DEPTH_2BPP) != VID_DEPTH_2BPP); break; + case 4: err = ((priv.vidix.fourcc.depth & VID_DEPTH_4BPP) != VID_DEPTH_4BPP); break; + case 8: err = ((priv.vidix.fourcc.depth & VID_DEPTH_8BPP) != VID_DEPTH_8BPP); break; + case 12:err = ((priv.vidix.fourcc.depth & VID_DEPTH_12BPP) != VID_DEPTH_12BPP); break; + case 15:err = ((priv.vidix.fourcc.depth & VID_DEPTH_15BPP) != VID_DEPTH_15BPP); break; + case 16:err = ((priv.vidix.fourcc.depth & VID_DEPTH_16BPP) != VID_DEPTH_16BPP); break; + case 24:err = ((priv.vidix.fourcc.depth & VID_DEPTH_24BPP) != VID_DEPTH_24BPP); break; + case 32:err = ((priv.vidix.fourcc.depth & VID_DEPTH_32BPP) != VID_DEPTH_32BPP); break; default: err=1; break; } if(err) { MSG_FATAL("video server has unsupported color depth by vidix (%d)\n" - ,priv->fourcc->depth); + ,priv.vidix.fourcc.depth); return MPXP_False; } - if((dst_width > src_width || dst_height > src_height) && (priv->cap->flags & FLAG_UPSCALER) != FLAG_UPSCALER) { + if((dst_width > src_width || dst_height > src_height) && (priv.vidix.cap.flags & FLAG_UPSCALER) != FLAG_UPSCALER) { MSG_FATAL("vidix driver can't upscale image (%d%d -> %d%d)\n", src_width, src_height, dst_width, dst_height); return MPXP_False; } - if((dst_width > src_width || dst_height > src_height) && (priv->cap->flags & FLAG_DOWNSCALER) != FLAG_DOWNSCALER) { + if((dst_width > src_width || dst_height > src_height) && (priv.vidix.cap.flags & FLAG_DOWNSCALER) != FLAG_DOWNSCALER) { MSG_FATAL("vidix driver can't downscale image (%d%d -> %d%d)\n", src_width, src_height, dst_width, dst_height); return MPXP_False; } - priv->image_width = src_width; - priv->image_height = src_height; - priv->src_format = format; - if(priv->forced_fourcc) format = priv->forced_fourcc; - memset(priv->play,0,sizeof(vidix_playback_t)); - priv->play->fourcc = format; - priv->play->capability = priv->cap->flags; /* every ;) */ - priv->play->blend_factor = 0; /* for now */ + priv.image_width = src_width; + priv.image_height = src_height; + priv.src_format = format; + if(priv.forced_fourcc) format = priv.forced_fourcc; + priv.vidix.playback.fourcc = format; + priv.vidix.playback.capability = priv.vidix.cap.flags; /* every ;) */ + priv.vidix.playback.blend_factor = 0; /* for now */ /* display the full picture. Nick: we could implement here zooming to a specified area -- alex */ - priv->play->src.x = priv->play->src.y = 0; - priv->play->src.w = src_width; - priv->play->src.h = src_height; - priv->play->dest.x = x_org; - priv->play->dest.y = y_org; - priv->play->dest.w = dst_width; - priv->play->dest.h = dst_height; - priv->play->num_frames=(vo_conf.use_bm!=1)?NUM_FRAMES-1:1; - if(priv->play->num_frames > vo_conf.xp_buffs) priv->play->num_frames = vo_conf.xp_buffs; - priv->play->src.pitch.y = priv->play->src.pitch.u = priv->play->src.pitch.v = 0; - if((err=vdlConfigPlayback(priv->handler,priv->play))!=0) { + priv.vidix.playback.src.x = priv.vidix.playback.src.y = 0; + priv.vidix.playback.src.w = src_width; + priv.vidix.playback.src.h = src_height; + priv.vidix.playback.dest.x = x_org; + priv.vidix.playback.dest.y = y_org; + priv.vidix.playback.dest.w = dst_width; + priv.vidix.playback.dest.h = dst_height; + priv.vidix.playback.num_frames=(vo_conf.use_bm!=1)?NUM_FRAMES-1:1; + if(priv.vidix.playback.num_frames > vo_conf.xp_buffs) priv.vidix.playback.num_frames = vo_conf.xp_buffs; + priv.vidix.playback.src.pitch.y = priv.vidix.playback.src.pitch.u = priv.vidix.playback.src.pitch.v = 0; + if((err=priv.vidix.config_playback())!=0) { MSG_FATAL("Can't configure playback: %s\n",strerror(err)); return MPXP_False; } - MSG_V("using %d buffers\n", priv->play->num_frames); + MSG_V("using %d buffers\n", priv.vidix.playback.num_frames); /* configure busmastering */ if(vo_conf.use_bm) { #ifdef HAVE_MEMALIGN - if(priv->cap->flags & FLAG_DMA) { + if(priv.vidix.cap.flags & FLAG_DMA) { int psize = getpagesize(); - priv->bm_locked=1; + priv.bm_locked=1; for(i=0;i<vo_conf.xp_buffs;i++) { - if(!priv->bm_buffs[i]) priv->bm_buffs[i] = new(alignmem,psize) uint8_t[priv->play->frame_size]; - if(!(priv->bm_buffs[i])) { + if(!priv.bm_buffs[i]) priv.bm_buffs[i] = new(alignmem,psize) uint8_t[priv.vidix.playback.frame_size]; + if(!(priv.bm_buffs[i])) { MSG_ERR("Can't allocate memory for busmastering\n"); return MPXP_False; } - if(mlock(priv->bm_buffs[i],priv->play->frame_size) != 0) { + if(mlock(priv.bm_buffs[i],priv.vidix.playback.frame_size) != 0) { unsigned j; MSG_WARN("Can't lock memory for busmastering\n"); - for(j=0;j<i;j++) munlock(priv->bm_buffs[i],priv->play->frame_size); - priv->bm_locked=0; + for(j=0;j<i;j++) munlock(priv.bm_buffs[i],priv.vidix.playback.frame_size); + priv.bm_locked=0; } } - memset(&priv->vdma,0,sizeof(vidix_dma_t)); - priv->bm_total_frames=priv->bm_slow_frames=0; + memset(&priv.vidix.dma,0,sizeof(vidix_dma_t)); + priv.bm_total_frames=priv.bm_slow_frames=0; } else #else @@ -436,16 +425,16 @@ vo_conf.use_bm = 0; } if(vo_conf.use_bm) MSG_OK("using BUSMASTERING\n"); - priv->mem = reinterpret_cast<uint8_t*>(priv->play->dga_addr); + priv.mem = reinterpret_cast<uint8_t*>(priv.vidix.playback.dga_addr); if(!video_clean) { /* clear every frame with correct address and frame_size only once per session */ - for (i = 0; i < priv->play->num_frames; i++) - memset(priv->mem + priv->play->offsets[i], 0x80, priv->play->frame_size); + for (i = 0; i < priv.vidix.playback.num_frames; i++) + memset(priv.mem + priv.vidix.playback.offsets[i], 0x80, priv.vidix.playback.frame_size); video_clean=1; } - MSG_DBG2("vidix returns pitches %u %u %u\n",priv->play->dest.pitch.y,priv->play->dest.pitch.u,priv->play->dest.pitch.v); + MSG_DBG2("vidix returns pitches %u %u %u\n",priv.vidix.playback.dest.pitch.y,priv.vidix.playback.dest.pitch.u,priv.vidix.playback.dest.pitch.v); switch(format) { case IMGFMT_Y800: case IMGFMT_YVU9: @@ -453,46 +442,46 @@ case IMGFMT_I420: case IMGFMT_IYUV: case IMGFMT_YV12: - apitch = priv->play->dest.pitch.y-1; - priv->dstrides->y = (priv->image_width + apitch) & ~apitch; - apitch = priv->play->dest.pitch.v-1; - priv->dstrides->v = (priv->image_width + apitch) & ~apitch; - apitch = priv->play->dest.pitch.u-1; - priv->dstrides->u = (priv->image_width + apitch) & ~apitch; - priv->image_Bpp=1; + apitch = priv.vidix.playback.dest.pitch.y-1; + priv.vidix.playback.offset.y = (priv.image_width + apitch) & ~apitch; + apitch = priv.vidix.playback.dest.pitch.v-1; + priv.vidix.playback.offset.v = (priv.image_width + apitch) & ~apitch; + apitch = priv.vidix.playback.dest.pitch.u-1; + priv.vidix.playback.offset.u = (priv.image_width + apitch) & ~apitch; + priv.image_Bpp=1; break; case IMGFMT_RGB32: case IMGFMT_BGR32: - apitch = priv->play->dest.pitch.y-1; - priv->dstrides->y = (priv->image_width*4 + apitch) & ~apitch; - priv->dstrides->u = priv->dstrides->v = 0; - priv->image_Bpp=4; + apitch = priv.vidix.playback.dest.pitch.y-1; + priv.vidix.playback.offset.y = (priv.image_width*4 + apitch) & ~apitch; + priv.vidix.playback.offset.u = priv.vidix.playback.offset.v = 0; + priv.image_Bpp=4; break; case IMGFMT_RGB24: case IMGFMT_BGR24: - apitch = priv->play->dest.pitch.y-1; - priv->dstrides->y = (priv->image_width*3 + apitch) & ~apitch; - priv->dstrides->u = priv->dstrides->v = 0; - priv->image_Bpp=3; + apitch = priv.vidix.playback.dest.pitch.y-1; + priv.vidix.playback.offset.y = (priv.image_width*3 + apitch) & ~apitch; + priv.vidix.playback.offset.u = priv.vidix.playback.offset.v = 0; + priv.image_Bpp=3; break; default: - apitch = priv->play->dest.pitch.y-1; - priv->dstrides->y = (priv->image_width*2 + apitch) & ~apitch; - priv->dstrides->u = priv->dstrides->v = 0; - priv->image_Bpp=2; + apitch = priv.vidix.playback.dest.pitch.y-1; + priv.vidix.playback.offset.y = (priv.image_width*2 + apitch) & ~apitch; + priv.vidix.playback.offset.u = priv.vidix.playback.offset.v = 0; + priv.image_Bpp=2; break; } switch(format) { case IMGFMT_YVU9: case IMGFMT_IF09: - priv->dstrides->u /= 4; - priv->dstrides->v /= 4; + priv.vidix.playback.offset.u /= 4; + priv.vidix.playback.offset.v /= 4; break; case IMGFMT_I420: case IMGFMT_IYUV: case IMGFMT_YV12: - priv->dstrides->u /= 2; - priv->dstrides->v /= 2; + priv.vidix.playback.offset.u /= 2; + priv.vidix.playback.offset.v /= 2; break; } return MPXP_Ok; @@ -500,55 +489,49 @@ static void __FASTCALL__ vidix_dri_get_surface_caps(const vo_data_t* vo,dri_surface_cap_t *caps) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); caps->caps = vo_conf.use_bm ? DRI_CAP_TEMP_VIDEO|DRI_CAP_BUSMASTERING : DRI_CAP_VIDEO_MMAPED; caps->caps |= DRI_CAP_HORZSCALER | DRI_CAP_VERTSCALER; - if((priv->cap->flags & FLAG_DOWNSCALER) == FLAG_DOWNSCALER) + if((priv.vidix.cap.flags & FLAG_DOWNSCALER) == FLAG_DOWNSCALER) caps->caps |= DRI_CAP_DOWNSCALER; - if((priv->cap->flags & FLAG_UPSCALER) == FLAG_UPSCALER) + if((priv.vidix.cap.flags & FLAG_UPSCALER) == FLAG_UPSCALER) caps->caps |= DRI_CAP_UPSCALER; - caps->fourcc = priv->play->fourcc; - caps->width=priv->play->src.w; - caps->height=priv->play->src.h; + caps->fourcc = priv.vidix.playback.fourcc; + caps->width=priv.vidix.playback.src.w; + caps->height=priv.vidix.playback.src.h; /* in case of vidix movie fit surface */ caps->x = caps->y=0; caps->w=caps->width; caps->h=caps->height; - if(priv->dstrides) { - caps->strides[0] = priv->dstrides->y; - caps->strides[1] = priv->dstrides->v; - caps->strides[2] = priv->dstrides->u; - caps->strides[3] = 0; - } + caps->strides[0] = priv.vidix.playback.offset.y; + caps->strides[1] = priv.vidix.playback.offset.v; + caps->strides[2] = priv.vidix.playback.offset.u; + caps->strides[3] = 0; } static void __FASTCALL__ vidix_dri_get_surface(const vo_data_t* vo,dri_surface_t *surf) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); if(vo_conf.use_bm) { - surf->planes[0] = priv->bm_buffs[surf->idx] + priv->play->offset.y; - surf->planes[1] = priv->bm_buffs[surf->idx] + priv->play->offset.v; - surf->planes[2] = priv->bm_buffs[surf->idx] + priv->play->offset.u; + surf->planes[0] = priv.bm_buffs[surf->idx] + priv.vidix.playback.offset.y; + surf->planes[1] = priv.bm_buffs[surf->idx] + priv.vidix.playback.offset.v; + surf->planes[2] = priv.bm_buffs[surf->idx] + priv.vidix.playback.offset.u; } else { - surf->planes[0] = priv->mem + priv->play->offsets[surf->idx] + priv->play->offset.y; - surf->planes[1] = priv->mem + priv->play->offsets[surf->idx] + priv->play->offset.v; - surf->planes[2] = priv->mem + priv->play->offsets[surf->idx] + priv->play->offset.u; + surf->planes[0] = priv.mem + priv.vidix.playback.offsets[surf->idx] + priv.vidix.playback.offset.y; + surf->planes[1] = priv.mem + priv.vidix.playback.offsets[surf->idx] + priv.vidix.playback.offset.v; + surf->planes[2] = priv.mem + priv.vidix.playback.offsets[surf->idx] + priv.vidix.playback.offset.u; } surf->planes[3] = 0; } MPXP_Rc __FASTCALL__ vidix_control(vo_data_t* vo,uint32_t request, any_t*data) { - priv_t*priv=reinterpret_cast<priv_t*>(vo->priv3); + priv_t& priv=*reinterpret_cast<priv_t*>(vo->priv3); switch (request) { case VOCTRL_QUERY_FORMAT: return vidix_query_fourcc(vo,reinterpret_cast<vo_query_fourcc_t*>(data)); - case VOCTRL_FULLSCREEN: - case VOCTRL_CHECK_EVENTS: - if(priv->inited) return (*priv->server_control)(vo,request,data); - break; case VOCTRL_GET_NUM_FRAMES: - *(uint32_t *)data = (vo_conf.use_bm == 1) ? vo_conf.xp_buffs : priv->play->num_frames; + *(uint32_t *)data = (vo_conf.use_bm == 1) ? vo_conf.xp_buffs : priv.vidix.playback.num_frames; return MPXP_True; case DRI_GET_SURFACE_CAPS: vidix_dri_get_surface_caps(vo,reinterpret_cast<dri_surface_cap_t*>(data)); @@ -575,36 +558,33 @@ int err; static int reent=0; MSG_DBG2("vidix_preinit(%s) was called\n",drvname); - priv_t* priv=new(zeromem) priv_t; - vo->priv3=priv; - if(alloc_vidix_structs(priv)!=MPXP_Ok) return NULL; - if(vdlGetVersion() != VIDIX_VERSION) { + Vidix& _vidix = *new Vidix(drvname ? drvname[0] == ':' ? &drvname[1] : drvname[0] ? drvname : NULL : NULL, + TYPE_OUTPUT, + mp_conf.verbose); + priv_t& priv=*new(zeromem) priv_t(_vidix); + vo->priv3=&priv; + if(priv.vidix.version() != VIDIX_VERSION) { MSG_FATAL("You have wrong version of VIDIX library\n"); - mp_free(priv); + delete &priv; return NULL; } - priv->handler = vdlOpen(VIDIX_PATH, - drvname ? drvname[0] == ':' ? &drvname[1] : drvname[0] ? drvname : NULL : NULL, - TYPE_OUTPUT, - mp_conf.verbose); - if(priv->handler == NULL) { + if(priv.vidix.is_error()) { MSG_FATAL("Couldn't find working VIDIX driver\n"); - mp_free(priv); + delete &priv; return NULL; } - if((err=vdlGetCapability(priv->handler,priv->cap)) != 0) { + if((err=priv.vidix.get_capabilities()) != 0) { MSG_FATAL("Couldn't get capability: %s\n",strerror(err)); - mp_free(priv); + delete &priv; return NULL; } - else MSG_V("Driver capability: %X\n",priv->cap->flags); - MSG_V("Using: %s by %s\n",priv->cap->name,priv->cap->author); + else MSG_V("Driver capability: %X\n",priv.vidix.cap.flags); + MSG_V("Using: %s by %s\n",priv.vidix.cap.name,priv.vidix.cap.author); if(!reent) { - priv->server_control = server->control; reent=1; } - priv->vo_server = reinterpret_cast<const vo_functions_t*>(server); - priv->inited=1; + priv.vo_server = reinterpret_cast<const vo_functions_t*>(server); + priv.inited=1; /* we are able to tune up this stuff depend on fourcc format */ vidix_server_t* rs = new vidix_server_t; rs->control=vidix_control; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-11-22 15:30:05
|
Revision: 432 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=432&view=rev Author: nickols_k Date: 2012-11-22 15:29:45 +0000 (Thu, 22 Nov 2012) Log Message: ----------- minor fixes + using namespace mpxp; Modified Paths: -------------- mplayerxp/configure mplayerxp/dump.cpp mplayerxp/input2/input.cpp mplayerxp/input2/joystick.cpp mplayerxp/input2/lirc.cpp mplayerxp/libao2/afmt.cpp mplayerxp/libao2/ao_alsa9.cpp mplayerxp/libao2/ao_arts.cpp mplayerxp/libao2/ao_esd.cpp mplayerxp/libao2/ao_jack.cpp mplayerxp/libao2/ao_nas.cpp mplayerxp/libao2/ao_null.cpp mplayerxp/libao2/ao_openal.cpp mplayerxp/libao2/ao_oss.cpp mplayerxp/libao2/ao_sdl.cpp mplayerxp/libao2/ao_wav.cpp mplayerxp/libao2/audio_out.cpp mplayerxp/libao2/mixer.cpp mplayerxp/libmpcodecs/ad.cpp mplayerxp/libmpcodecs/ad_a52.cpp mplayerxp/libmpcodecs/ad_acm.cpp mplayerxp/libmpcodecs/ad_dca.cpp mplayerxp/libmpcodecs/ad_dmo.cpp mplayerxp/libmpcodecs/ad_dshow.cpp mplayerxp/libmpcodecs/ad_dvdpcm.cpp mplayerxp/libmpcodecs/ad_faad.cpp mplayerxp/libmpcodecs/ad_ffmpeg.cpp mplayerxp/libmpcodecs/ad_hwac3.cpp mplayerxp/libmpcodecs/ad_libdv.cpp mplayerxp/libmpcodecs/ad_mp3.cpp mplayerxp/libmpcodecs/ad_null.cpp mplayerxp/libmpcodecs/ad_pcm.cpp mplayerxp/libmpcodecs/ad_qtaudio.cpp mplayerxp/libmpcodecs/ad_real.cpp mplayerxp/libmpcodecs/ad_twin.cpp mplayerxp/libmpcodecs/ad_vorbis.cpp mplayerxp/libmpcodecs/codecs_ld.cpp mplayerxp/libmpcodecs/dec_audio.cpp mplayerxp/libmpcodecs/dec_video.cpp mplayerxp/libmpcodecs/liba52/bit_allocate.cpp mplayerxp/libmpcodecs/liba52/bitstream.cpp mplayerxp/libmpcodecs/liba52/crc.cpp mplayerxp/libmpcodecs/liba52/downmix.cpp mplayerxp/libmpcodecs/liba52/imdct.cpp mplayerxp/libmpcodecs/liba52/parse.cpp mplayerxp/libmpcodecs/liba52/resample.cpp mplayerxp/libmpcodecs/libdca/bitstream.cpp mplayerxp/libmpcodecs/libdca/downmix.cpp mplayerxp/libmpcodecs/libdca/parse.cpp mplayerxp/libmpcodecs/libdca/resample.cpp mplayerxp/libmpcodecs/libnuppelvideo/RTjpegN.cpp mplayerxp/libmpcodecs/libnuppelvideo/minilzo.cpp mplayerxp/libmpcodecs/libnuppelvideo/nuppelvideo.cpp mplayerxp/libmpcodecs/vd.cpp mplayerxp/libmpcodecs/vd_divx4.cpp mplayerxp/libmpcodecs/vd_dmo.cpp mplayerxp/libmpcodecs/vd_dshow.cpp mplayerxp/libmpcodecs/vd_ffmpeg.cpp mplayerxp/libmpcodecs/vd_huffyuv.cpp mplayerxp/libmpcodecs/vd_libdv.cpp mplayerxp/libmpcodecs/vd_libmpeg2.cpp mplayerxp/libmpcodecs/vd_mpegpes.cpp mplayerxp/libmpcodecs/vd_null.cpp mplayerxp/libmpcodecs/vd_nuv.cpp mplayerxp/libmpcodecs/vd_qtvideo.cpp mplayerxp/libmpcodecs/vd_raw.cpp mplayerxp/libmpcodecs/vd_real.cpp mplayerxp/libmpcodecs/vd_theora.cpp mplayerxp/libmpcodecs/vd_vfw.cpp mplayerxp/libmpcodecs/vd_xanim.cpp mplayerxp/libmpcodecs/vd_xvid.cpp mplayerxp/libmpconf/cfgparser.cpp mplayerxp/libmpconf/codec-cfg.cpp mplayerxp/libmpconf/m_option.cpp mplayerxp/libmpconf/m_property.cpp mplayerxp/libmpconf/m_struct.cpp mplayerxp/libmpconf/subopt-helper.cpp mplayerxp/libmpdemux/aviprint.cpp mplayerxp/libmpdemux/demux_aiff.cpp mplayerxp/libmpdemux/demux_asf.cpp mplayerxp/libmpdemux/demux_audio.cpp mplayerxp/libmpdemux/demux_avi.cpp mplayerxp/libmpdemux/demux_bmp.cpp mplayerxp/libmpdemux/demux_demuxers.cpp mplayerxp/libmpdemux/demux_dv.cpp mplayerxp/libmpdemux/demux_film.cpp mplayerxp/libmpdemux/demux_fli.cpp mplayerxp/libmpdemux/demux_lavf.cpp mplayerxp/libmpdemux/demux_mkv.cpp mplayerxp/libmpdemux/demux_mov.cpp mplayerxp/libmpdemux/demux_mpg.cpp mplayerxp/libmpdemux/demux_mpxp64.cpp mplayerxp/libmpdemux/demux_nsv.cpp mplayerxp/libmpdemux/demux_null.cpp mplayerxp/libmpdemux/demux_nuv.cpp mplayerxp/libmpdemux/demux_ogg.cpp mplayerxp/libmpdemux/demux_pva.cpp mplayerxp/libmpdemux/demux_ra.cpp mplayerxp/libmpdemux/demux_rawaudio.cpp mplayerxp/libmpdemux/demux_rawvideo.cpp mplayerxp/libmpdemux/demux_real.cpp mplayerxp/libmpdemux/demux_roq.cpp mplayerxp/libmpdemux/demux_smjpeg.cpp mplayerxp/libmpdemux/demux_ts.cpp mplayerxp/libmpdemux/demux_ty.cpp mplayerxp/libmpdemux/demux_viv.cpp mplayerxp/libmpdemux/demux_vqf.cpp mplayerxp/libmpdemux/demux_y4m.cpp mplayerxp/libmpdemux/demuxer.cpp mplayerxp/libmpdemux/demuxer_r.cpp mplayerxp/libmpdemux/mp3_hdr.cpp mplayerxp/libmpdemux/mpdemux.cpp mplayerxp/libmpdemux/mpeg_hdr.cpp mplayerxp/libmpdemux/mux_lavf.cpp mplayerxp/libmpdemux/mux_mpxp64.cpp mplayerxp/libmpdemux/mux_raw.cpp mplayerxp/libmpdemux/muxer.cpp mplayerxp/libmpdemux/parse_es.cpp mplayerxp/libmpdemux/parse_mp4.cpp mplayerxp/libmpdemux/sub_cc.cpp mplayerxp/libmpdemux/sub_ty.cpp mplayerxp/libmpdemux/video.cpp mplayerxp/libmpdemux/yuv4mpeg.cpp mplayerxp/libmpdemux/yuv4mpeg_ratio.cpp mplayerxp/libmpstream/asf_mmst_streaming.cpp mplayerxp/libmpstream/asf_streaming.cpp mplayerxp/libmpstream/cache2.cpp mplayerxp/libmpstream/cdda.cpp mplayerxp/libmpstream/cddb.cpp mplayerxp/libmpstream/cookies.cpp mplayerxp/libmpstream/freesdp/common.cpp mplayerxp/libmpstream/freesdp/errorlist.cpp mplayerxp/libmpstream/freesdp/parser.cpp mplayerxp/libmpstream/http.cpp mplayerxp/libmpstream/librtsp/rtsp.cpp mplayerxp/libmpstream/librtsp/rtsp_rtp.cpp mplayerxp/libmpstream/librtsp/rtsp_session.cpp mplayerxp/libmpstream/mrl.cpp mplayerxp/libmpstream/network.cpp mplayerxp/libmpstream/pnm.cpp mplayerxp/libmpstream/realrtsp/asmrp.cpp mplayerxp/libmpstream/realrtsp/md5.cpp mplayerxp/libmpstream/realrtsp/real.cpp mplayerxp/libmpstream/realrtsp/rmff.cpp mplayerxp/libmpstream/realrtsp/sdpplin.cpp mplayerxp/libmpstream/realrtsp/xbuffer.cpp mplayerxp/libmpstream/rtp.cpp mplayerxp/libmpstream/s_cdd.cpp mplayerxp/libmpstream/s_dvdnav.cpp mplayerxp/libmpstream/s_dvdread.cpp mplayerxp/libmpstream/s_ffmpeg.cpp mplayerxp/libmpstream/s_file.cpp mplayerxp/libmpstream/s_ftp.cpp mplayerxp/libmpstream/s_network.cpp mplayerxp/libmpstream/s_null.cpp mplayerxp/libmpstream/s_oss.cpp mplayerxp/libmpstream/s_rtsp.cpp mplayerxp/libmpstream/s_tv.cpp mplayerxp/libmpstream/s_udp.cpp mplayerxp/libmpstream/s_vcdnav.cpp mplayerxp/libmpstream/stream.cpp mplayerxp/libmpstream/tcp.cpp mplayerxp/libmpstream/tvi/frequencies.cpp mplayerxp/libmpstream/tvi/tvi_bsdbt848.cpp mplayerxp/libmpstream/tvi/tvi_dummy.cpp mplayerxp/libmpstream/tvi/tvi_v4l.cpp mplayerxp/libmpstream/udp.cpp mplayerxp/libmpstream/url.cpp mplayerxp/libmpsub/find_sub.cpp mplayerxp/libmpsub/spudec.cpp mplayerxp/libmpsub/subreader.cpp mplayerxp/libmpsub/vobsub.cpp mplayerxp/libplaytree/asxparser.cpp mplayerxp/libplaytree/asxparser.h mplayerxp/libplaytree/playtree.cpp mplayerxp/libplaytree/playtreeparser.cpp mplayerxp/libvo/aspect.cpp mplayerxp/libvo/font_load.cpp mplayerxp/libvo/img_format.cpp mplayerxp/libvo/jpeg_enc.cpp mplayerxp/libvo/osd.cpp mplayerxp/libvo/screenshot.cpp mplayerxp/libvo/sub.cpp mplayerxp/libvo/video_out.cpp mplayerxp/libvo/vo_dga.cpp mplayerxp/libvo/vo_fbdev.cpp mplayerxp/libvo/vo_null.cpp mplayerxp/libvo/vo_opengl.cpp mplayerxp/libvo/vo_sdl.cpp mplayerxp/libvo/vo_vesa.cpp mplayerxp/libvo/vo_x11.cpp mplayerxp/libvo/vo_xv.cpp mplayerxp/libvo/vosub_vidix.cpp mplayerxp/libvo/x11_common.cpp mplayerxp/mp-opt-reg.cpp mplayerxp/mp_msg.cpp mplayerxp/mplayerxp.cpp mplayerxp/mplayerxp.h mplayerxp/nls/recode.cpp mplayerxp/osdep/aclib.cpp mplayerxp/osdep/cpudetect.cpp mplayerxp/osdep/get_path.cpp mplayerxp/osdep/getch2.cpp mplayerxp/osdep/lrmi.cpp mplayerxp/osdep/mp_malloc.cpp mplayerxp/osdep/mplib.cpp mplayerxp/osdep/mplib.h mplayerxp/osdep/shmem.cpp mplayerxp/osdep/timer-lx.cpp mplayerxp/osdep/timer.cpp mplayerxp/osdep/vbelib.cpp mplayerxp/postproc/af.cpp mplayerxp/postproc/af_ao2.cpp mplayerxp/postproc/af_channels.cpp mplayerxp/postproc/af_crystality.cpp mplayerxp/postproc/af_delay.cpp mplayerxp/postproc/af_dyn.cpp mplayerxp/postproc/af_echo3d.cpp mplayerxp/postproc/af_equalizer.cpp mplayerxp/postproc/af_export.cpp mplayerxp/postproc/af_extrastereo.cpp mplayerxp/postproc/af_ffenc.cpp mplayerxp/postproc/af_format.cpp mplayerxp/postproc/af_hrtf.cpp mplayerxp/postproc/af_karaoke.cpp mplayerxp/postproc/af_lp.cpp mplayerxp/postproc/af_null.cpp mplayerxp/postproc/af_pan.cpp mplayerxp/postproc/af_raw.cpp mplayerxp/postproc/af_resample.cpp mplayerxp/postproc/af_scaletempo.cpp mplayerxp/postproc/af_sinesuppress.cpp mplayerxp/postproc/af_sub.cpp mplayerxp/postproc/af_surround.cpp mplayerxp/postproc/af_tools.cpp mplayerxp/postproc/af_volnorm.cpp mplayerxp/postproc/af_volume.cpp mplayerxp/postproc/aflib.cpp mplayerxp/postproc/libmenu/menu.cpp mplayerxp/postproc/libmenu/menu_cmdlist.cpp mplayerxp/postproc/libmenu/menu_console.cpp mplayerxp/postproc/libmenu/menu_filesel.cpp mplayerxp/postproc/libmenu/menu_list.cpp mplayerxp/postproc/libmenu/menu_param.cpp mplayerxp/postproc/libmenu/menu_pt.cpp mplayerxp/postproc/libmenu/menu_txt.cpp mplayerxp/postproc/postprocess.cpp mplayerxp/postproc/swscale.cpp mplayerxp/postproc/vf.cpp mplayerxp/postproc/vf_1bpp.cpp mplayerxp/postproc/vf_2xsai.cpp mplayerxp/postproc/vf_aspect.cpp mplayerxp/postproc/vf_delogo.cpp mplayerxp/postproc/vf_denoise3d.cpp mplayerxp/postproc/vf_dint.cpp mplayerxp/postproc/vf_down3dright.cpp mplayerxp/postproc/vf_eq.cpp mplayerxp/postproc/vf_expand.cpp mplayerxp/postproc/vf_flip.cpp mplayerxp/postproc/vf_format.cpp mplayerxp/postproc/vf_framestep.cpp mplayerxp/postproc/vf_il.cpp mplayerxp/postproc/vf_menu.cpp mplayerxp/postproc/vf_mirror.cpp mplayerxp/postproc/vf_noise.cpp mplayerxp/postproc/vf_null.cpp mplayerxp/postproc/vf_ow.cpp mplayerxp/postproc/vf_palette.cpp mplayerxp/postproc/vf_panscan.cpp mplayerxp/postproc/vf_perspective.cpp mplayerxp/postproc/vf_pp.cpp mplayerxp/postproc/vf_raw.cpp mplayerxp/postproc/vf_rectangle.cpp mplayerxp/postproc/vf_rgb2bgr.cpp mplayerxp/postproc/vf_rotate.cpp mplayerxp/postproc/vf_scale.cpp mplayerxp/postproc/vf_smartblur.cpp mplayerxp/postproc/vf_softpulldown.cpp mplayerxp/postproc/vf_swapuv.cpp mplayerxp/postproc/vf_test.cpp mplayerxp/postproc/vf_unsharp.cpp mplayerxp/postproc/vf_vo.cpp mplayerxp/postproc/vf_yuvcsp.cpp mplayerxp/postproc/vf_yuy2.cpp mplayerxp/postproc/vf_yvu9.cpp mplayerxp/xmpcore/mp_aframe.cpp mplayerxp/xmpcore/mp_image.cpp mplayerxp/xmpcore/sig_hand.cpp mplayerxp/xmpcore/xmp_adecoder.cpp mplayerxp/xmpcore/xmp_aplayer.cpp mplayerxp/xmpcore/xmp_core.cpp mplayerxp/xmpcore/xmp_vdecoder.cpp mplayerxp/xmpcore/xmp_vplayer.cpp Modified: mplayerxp/configure =================================================================== --- mplayerxp/configure 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/configure 2012-11-22 15:29:45 UTC (rev 432) @@ -577,7 +577,6 @@ enabled gpl_only && disable win32loader -enable win32loader if win32 || ! x86_32 ; then disable win32loader fi Modified: mplayerxp/dump.cpp =================================================================== --- mplayerxp/dump.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/dump.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -18,9 +18,10 @@ #include "osdep/mplib.h" #define MSGT_CLASS MSGT_GLOBAL #include "mp_msg.h" - #include "dump.h" +using namespace mpxp; + static char *media=NULL,*port=NULL; /* example: -dump @avi:my_file.avi#rate=50 */ Modified: mplayerxp/input2/input.cpp =================================================================== --- mplayerxp/input2/input.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/input2/input.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -33,6 +33,8 @@ #include "joystick.h" #include "osdep/getch2.h" +using namespace mpxp; + #ifndef MP_MAX_KEY_FD #define MP_MAX_KEY_FD 10 #endif Modified: mplayerxp/input2/joystick.cpp =================================================================== --- mplayerxp/input2/joystick.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/input2/joystick.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -14,6 +14,8 @@ #include <fcntl.h> #include <errno.h> +using namespace mpxp; + #ifndef JOY_AXIS_DELTA #define JOY_AXIS_DELTA 500 #endif Modified: mplayerxp/input2/lirc.cpp =================================================================== --- mplayerxp/input2/lirc.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/input2/lirc.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -15,6 +15,8 @@ #include "input.h" #include "in_msg.h" +using namespace mpxp; + static struct lirc_config *lirc_config; char *lirc_configfile; Modified: mplayerxp/libao2/afmt.cpp =================================================================== --- mplayerxp/libao2/afmt.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libao2/afmt.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -1,5 +1,8 @@ #include "afmt.h" +#include "osdep/mplib.h" +using namespace mpxp; + const char* afmt2str(unsigned fmt) { const char* rs = "AFMT_Unknown"; switch (fmt) { Modified: mplayerxp/libao2/ao_alsa9.cpp =================================================================== --- mplayerxp/libao2/ao_alsa9.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libao2/ao_alsa9.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -30,6 +30,8 @@ #include "libmpstream/mrl.h" #include "osdep/mplib.h" +using namespace mpxp; + static ao_info_t info = { "ALSA-1.x audio output", Modified: mplayerxp/libao2/ao_arts.cpp =================================================================== --- mplayerxp/libao2/ao_arts.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libao2/ao_arts.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -30,6 +30,8 @@ #include "afmt.h" #include "ao_msg.h" +using namespace mpxp; + /* Feel mp_free to experiment with the following values: */ #define ARTS_PACKETS 10 /* Number of audio packets */ #define ARTS_PACKET_SIZE_LOG2 11 /* Log2 of audio packet size */ Modified: mplayerxp/libao2/ao_esd.cpp =================================================================== --- mplayerxp/libao2/ao_esd.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libao2/ao_esd.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -55,6 +55,7 @@ #include "ao_msg.h" #include "osdep/mplib.h" +using namespace mpxp; #define ESD_RESAMPLES 0 #define ESD_DEBUG 0 Modified: mplayerxp/libao2/ao_jack.cpp =================================================================== --- mplayerxp/libao2/ao_jack.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libao2/ao_jack.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -39,6 +39,8 @@ #include "mp_conf_lavc.h" #include <jack/jack.h> +using namespace mpxp; + static const ao_info_t info = { "JACK audio output", Modified: mplayerxp/libao2/ao_nas.cpp =================================================================== --- mplayerxp/libao2/ao_nas.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libao2/ao_nas.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -62,6 +62,8 @@ #include "afmt.h" #include "ao_msg.h" +using namespace mpxp; + /* NAS_FRAG_SIZE must be a power-of-two value */ #define NAS_FRAG_SIZE 4096 Modified: mplayerxp/libao2/ao_null.cpp =================================================================== --- mplayerxp/libao2/ao_null.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libao2/ao_null.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -15,6 +15,8 @@ #include "audio_out_internal.h" #include "ao_msg.h" +using namespace mpxp; + static ao_info_t info = { "Null audio output", "null", Modified: mplayerxp/libao2/ao_openal.cpp =================================================================== --- mplayerxp/libao2/ao_openal.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libao2/ao_openal.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -37,6 +37,8 @@ #include "osdep/mplib.h" #include "ao_msg.h" +using namespace mpxp; + static const ao_info_t info = { "OpenAL audio output", Modified: mplayerxp/libao2/ao_oss.cpp =================================================================== --- mplayerxp/libao2/ao_oss.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libao2/ao_oss.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -19,6 +19,8 @@ #include "audio_out_internal.h" #include "ao_msg.h" +using namespace mpxp; + static ao_info_t info = { "OSS/ioctl audio output", Modified: mplayerxp/libao2/ao_sdl.cpp =================================================================== --- mplayerxp/libao2/ao_sdl.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libao2/ao_sdl.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -21,6 +21,8 @@ #include "osdep/mplib.h" #include "ao_msg.h" +using namespace mpxp; + static ao_info_t info = { "SDLlib audio output", "sdl", Modified: mplayerxp/libao2/ao_wav.cpp =================================================================== --- mplayerxp/libao2/ao_wav.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libao2/ao_wav.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -40,6 +40,8 @@ #include <windows.h> #endif +using namespace mpxp; + static const ao_info_t info = { "RAW WAVE file writer audio output", Modified: mplayerxp/libao2/audio_out.cpp =================================================================== --- mplayerxp/libao2/audio_out.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libao2/audio_out.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -8,6 +8,8 @@ #include "afmt.h" #include "ao_msg.h" +using namespace mpxp; + extern const ao_functions_t audio_out_wav; extern const ao_functions_t audio_out_null; #ifdef USE_OSS_AUDIO Modified: mplayerxp/libao2/mixer.cpp =================================================================== --- mplayerxp/libao2/mixer.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libao2/mixer.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -7,7 +7,10 @@ #include "mp_config.h" #include "mixer.h" #include "libao2/audio_out.h" +#include "osdep/mplib.h" +using namespace mpxp; + void mixer_getvolume(const ao_data_t* ao, float *l,float *r ) { ao_control_vol_t vol; Modified: mplayerxp/libmpcodecs/ad.cpp =================================================================== --- mplayerxp/libmpcodecs/ad.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -13,7 +13,10 @@ #include "libmpdemux/stheader.h" #include "ad.h" #include "ad_msg.h" +#include "osdep/mplib.h" +using namespace mpxp; + /* Missed vorbis, mad, dshow */ extern const ad_functions_t mpcodecs_ad_null; Modified: mplayerxp/libmpcodecs/ad_a52.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_a52.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_a52.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -11,6 +11,8 @@ #include "mplayerxp.h" #include "help_mp.h" #include "osdep/cpudetect.h" +#include "osdep/bswap.h" +#include "osdep/mplib.h" #include "osdep/mm_accel.h" #include "mplayerxp.h" @@ -19,6 +21,8 @@ #include "libao2/audio_out.h" #include "postproc/af.h" +using namespace mpxp; + typedef struct priv_s { float last_pts; }priv_t; @@ -29,9 +33,6 @@ uint32_t mpxp_a52_accel=0; uint32_t mpxp_a52_flags=0; -#include "osdep/bswap.h" -#include "osdep/mplib.h" - static const ad_info_t info = { "liba52 AC3 driver", Modified: mplayerxp/libmpcodecs/ad_acm.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_acm.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_acm.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -12,6 +12,8 @@ #include "libao2/afmt.h" #include "help_mp.h" +using namespace mpxp; + static const ad_info_t info = { "Win32/ACM decoders", "acm", Modified: mplayerxp/libmpcodecs/ad_dca.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dca.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_dca.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -21,6 +21,8 @@ #include "postproc/af.h" #include "osdep/mplib.h" +using namespace mpxp; + #define MAX_AC5_FRAME 4096 dca_state_t* mpxp_dca_state; Modified: mplayerxp/libmpcodecs/ad_dmo.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dmo.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_dmo.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -12,6 +12,8 @@ #include "ad_internal.h" #include "ad_msg.h" +using namespace mpxp; + static const ad_info_t info = { "Win32/DMO decoders", "dmo", Modified: mplayerxp/libmpcodecs/ad_dshow.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dshow.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_dshow.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -9,6 +9,8 @@ #include "loader/dshow/DS_AudioDecoder.h" #include "codecs_ld.h" +using namespace mpxp; + static const ad_info_t info = { "Win32/DirectShow decoders", "dshow", Modified: mplayerxp/libmpcodecs/ad_dvdpcm.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dvdpcm.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_dvdpcm.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -3,8 +3,11 @@ #include <unistd.h> #include "ad_internal.h" #include "osdep/bswap.h" +#include "osdep/mplib.h" #include "libao2/afmt.h" +using namespace mpxp; + static const ad_info_t info = { "Uncompressed DVD/VOB LPCM audio decoder", "dvdpcm", Modified: mplayerxp/libmpcodecs/ad_faad.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_faad.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_faad.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -23,6 +23,8 @@ #include "libao2/audio_out.h" #include "postproc/af.h" +using namespace mpxp; + static const ad_info_t info = { "AAC (MPEG2/4 Advanced Audio Coding)", "faad", Modified: mplayerxp/libmpcodecs/ad_ffmpeg.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_ffmpeg.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_ffmpeg.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -17,6 +17,8 @@ #include "mp_conf_lavc.h"" #include "codecs_ld.h" +using namespace mpxp; + typedef struct priv_s { AVCodecContext *lavc_ctx; audio_probe_t* probe; Modified: mplayerxp/libmpcodecs/ad_hwac3.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_hwac3.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_hwac3.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -12,9 +12,12 @@ #include "codecs_ld.h" #include "osdep/cpudetect.h" #include "osdep/bswap.h" +#include "osdep/mplib.h" #include "libao2/afmt.h" +using namespace mpxp; + #define IEC61937_DATA_TYPE_AC3 1 typedef struct priv_s { Modified: mplayerxp/libmpcodecs/ad_libdv.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_libdv.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_libdv.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -17,9 +17,12 @@ #include "libmpdemux/stheader.h" #include "libao2/afmt.h" #include "osdep/bswap.h" +#include "osdep/mplib.h" #include "ad_internal.h" +using namespace mpxp; + static const ad_info_t info = { "Raw DV Audio Decoder", "libdv", Modified: mplayerxp/libmpcodecs/ad_mp3.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_mp3.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_mp3.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -15,6 +15,8 @@ #include "libao2/audio_out.h" #include "postproc/af.h" +using namespace mpxp; + static const ad_info_t info = { "MPEG layer-123", "mp3lib", Modified: mplayerxp/libmpcodecs/ad_null.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_null.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_null.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -2,7 +2,10 @@ #include <stdlib.h> #include <unistd.h> #include "ad_internal.h" +#include "osdep/mplib.h" +using namespace mpxp; + static const ad_info_t info = { "Null audio decoder", "null", Modified: mplayerxp/libmpcodecs/ad_pcm.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_pcm.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_pcm.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -4,7 +4,10 @@ #include "ad_internal.h" #include "libao2/afmt.h" #include "osdep/bswap.h" +#include "osdep/mplib.h" +using namespace mpxp; + static const ad_info_t info = { "Uncompressed PCM audio decoder", "pcm", Modified: mplayerxp/libmpcodecs/ad_qtaudio.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_qtaudio.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_qtaudio.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -10,6 +10,7 @@ #include "codecs_ld.h" #include "mplayerxp.h" #include "libao2/afmt.h" +#include "osdep/mplib.h" #ifdef WIN32_LOADER #include "loader/ldt_keeper.h" #endif @@ -18,6 +19,8 @@ #include <QuickTime/QuickTimeComponents.h> #endif +using namespace mpxp; + static const ad_info_t info = { "QuickTime Audio Decoder", "qtaudio", Modified: mplayerxp/libmpcodecs/ad_real.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_real.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_real.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -14,6 +14,9 @@ #include "osdep/mplib.h" #include "osdep/bswap.h" #include "libao2/afmt.h" + +using namespace mpxp; + static const ad_info_t info = { "RealAudio decoder", "realaudio", Modified: mplayerxp/libmpcodecs/ad_twin.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_twin.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_twin.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -13,6 +13,8 @@ #include "help_mp.h" +using namespace mpxp; + static const ad_info_t info = { "TWinVQ decoder", "vqf", Modified: mplayerxp/libmpcodecs/ad_vorbis.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_vorbis.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/ad_vorbis.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -10,6 +10,8 @@ #include "osdep/mplib.h" #include "osdep/bswap.h" +using namespace mpxp; + extern ao_data_t* ao_data; static const ad_info_t info = { Modified: mplayerxp/libmpcodecs/codecs_ld.cpp =================================================================== --- mplayerxp/libmpcodecs/codecs_ld.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/codecs_ld.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -9,9 +9,12 @@ #include "codecs_ld.h" #include "mp_config.h" #include "help_mp.h" +#include "osdep/mplib.h" #define MSGT_CLASS MSGT_GLOBAL #include "mp_msg.h" +using namespace mpxp; + any_t* ld_codec(const char *name,const char *url_hint) { any_t*dll_handle; Modified: mplayerxp/libmpcodecs/dec_audio.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_audio.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/dec_audio.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -25,6 +25,8 @@ #include "osdep/mplib.h" #include "ad_msg.h" +using namespace mpxp; + /* used for ac3surround decoder - set using -channels option */ af_cfg_t af_cfg; // Configuration for audio filters Modified: mplayerxp/libmpcodecs/dec_video.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_video.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/dec_video.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -36,6 +36,8 @@ #include "osdep/cpudetect.h" #include "vd_msg.h" +using namespace mpxp; + // =================================================================== vf_cfg_t vf_cfg; // Configuration for audio filters Modified: mplayerxp/libmpcodecs/liba52/bit_allocate.cpp =================================================================== --- mplayerxp/libmpcodecs/liba52/bit_allocate.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/liba52/bit_allocate.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -21,13 +21,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "../../mp_config.h" +#include "mp_config.h" #include <inttypes.h> #include "a52.h" #include "a52_internal.h" +#include "osdep/mplib.h" +using namespace mpxp; + static int hthtab[3][50] = { {0x730, 0x730, 0x7c0, 0x800, 0x820, 0x840, 0x850, 0x850, 0x860, 0x860, 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x890, 0x890, Modified: mplayerxp/libmpcodecs/liba52/bitstream.cpp =================================================================== --- mplayerxp/libmpcodecs/liba52/bitstream.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/liba52/bitstream.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -21,14 +21,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "../../mp_config.h" +#include "mp_config.h" #include <inttypes.h> #include "a52.h" #include "a52_internal.h" #include "bitstream.h" +#include "osdep/mplib.h" +using namespace mpxp; + #define BUFFER_SIZE 4096 void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf) Modified: mplayerxp/libmpcodecs/liba52/crc.cpp =================================================================== --- mplayerxp/libmpcodecs/liba52/crc.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/liba52/crc.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -25,6 +25,11 @@ #include <stdio.h> #include <inttypes.h> +#include "mp_config.h" +#include "osdep/mplib.h" + +using namespace mpxp; + static const uint16_t crc_lut[256] = { 0x0000,0x8005,0x800f,0x000a,0x801b,0x001e,0x0014,0x8011, Modified: mplayerxp/libmpcodecs/liba52/downmix.cpp =================================================================== --- mplayerxp/libmpcodecs/liba52/downmix.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/liba52/downmix.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -30,7 +30,10 @@ #include "a52_internal.h" #include "osdep/mm_accel.h" #include "osdep/cpudetect.h" +#include "osdep/mplib.h" +using namespace mpxp; + #define CONVERT(acmod,output) (((output) << 3) + (acmod)) extern uint32_t a52_accel; Modified: mplayerxp/libmpcodecs/liba52/imdct.cpp =================================================================== --- mplayerxp/libmpcodecs/liba52/imdct.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/liba52/imdct.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -36,7 +36,10 @@ #include "a52.h" #include "a52_internal.h" #include "osdep/mm_accel.h" +#include "osdep/mplib.h" +using namespace mpxp; + typedef struct complex_s { sample_t real; sample_t imag; Modified: mplayerxp/libmpcodecs/liba52/parse.cpp =================================================================== --- mplayerxp/libmpcodecs/liba52/parse.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/liba52/parse.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -35,6 +35,8 @@ #include "bitstream.h" #include "tables.h" +using namespace mpxp; + typedef struct { sample_t q1[2]; sample_t q2[2]; Modified: mplayerxp/libmpcodecs/liba52/resample.cpp =================================================================== --- mplayerxp/libmpcodecs/liba52/resample.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/liba52/resample.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -12,7 +12,10 @@ #include "osdep/mm_accel.h" #include "osdep/mangle.h" #include "osdep/cpudetect.h" +#include "osdep/mplib.h" +using namespace mpxp; + int (* a52_resample) (float * _f, int16_t * s16)=NULL; int (* a52_resample32) (float * _f, float * s16)=NULL; Modified: mplayerxp/libmpcodecs/libdca/bitstream.cpp =================================================================== --- mplayerxp/libmpcodecs/libdca/bitstream.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/libdca/bitstream.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -22,14 +22,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "../../mp_config.h" +#include "mp_config.h" #include <inttypes.h> #include "dca.h" #include "dca_internal.h" #include "bitstream.h" +#include "osdep/mplib.h" +using namespace mpxp; + #define BUFFER_SIZE 4096 void dca_bitstream_init (dca_state_t * state, uint8_t * buf, int word_mode, Modified: mplayerxp/libmpcodecs/libdca/downmix.cpp =================================================================== --- mplayerxp/libmpcodecs/libdca/downmix.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/libdca/downmix.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -28,9 +28,12 @@ #include <inttypes.h> #include "osdep/cpudetect.h" +#include "osdep/mplib.h" #include "dca.h" #include "dca_internal.h" +using namespace mpxp; + #define CONVERT(acmod,output) (((output) << DCA_CHANNEL_BITS) + (acmod)) int dca_downmix_init (int input, int flags, level_t * level, Modified: mplayerxp/libmpcodecs/libdca/parse.cpp =================================================================== --- mplayerxp/libmpcodecs/libdca/parse.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/libdca/parse.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -46,7 +46,7 @@ #include "tables_fir.h" #include "tables_vq.h" -/* #define LOG_DEBUG */ +using namespace mpxp; //#define LOG_DEBUG 1 Modified: mplayerxp/libmpcodecs/libdca/resample.cpp =================================================================== --- mplayerxp/libmpcodecs/libdca/resample.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/libdca/resample.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -12,7 +12,10 @@ #include "osdep/mm_accel.h" #include "osdep/mangle.h" #include "osdep/cpudetect.h" +#include "osdep/mplib.h" +using namespace mpxp; + int (* dca_resample) (float * _f, int16_t * s16)=NULL; int (* dca_resample32) (float * _f, float * s16)=NULL; Modified: mplayerxp/libmpcodecs/libnuppelvideo/RTjpegN.cpp =================================================================== --- mplayerxp/libmpcodecs/libnuppelvideo/RTjpegN.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/libnuppelvideo/RTjpegN.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -29,6 +29,8 @@ #include "mp_config.h" #include "osdep/mplib.h" +using namespace mpxp; + //#define SHOWBLOCK 1 #define BETTERCOMPRESSION 1 Modified: mplayerxp/libmpcodecs/libnuppelvideo/minilzo.cpp =================================================================== --- mplayerxp/libmpcodecs/libnuppelvideo/minilzo.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/libnuppelvideo/minilzo.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -57,7 +57,10 @@ #include <stdio.h> #include "osdep/cpudetect.h" +#include "osdep/mplib.h" +using namespace mpxp; + #ifndef __LZO_CONF_H #define __LZO_CONF_H Modified: mplayerxp/libmpcodecs/libnuppelvideo/nuppelvideo.cpp =================================================================== --- mplayerxp/libmpcodecs/libnuppelvideo/nuppelvideo.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/libnuppelvideo/nuppelvideo.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -14,7 +14,7 @@ #include "mp_config.h" #include "osdep/mplib.h" -//#include "fastmemcpy.h" +using namespace mpxp; #include "nuppelvideo.h" #include "RTjpegN.h" Modified: mplayerxp/libmpcodecs/vd.cpp =================================================================== --- mplayerxp/libmpcodecs/vd.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -18,6 +18,8 @@ #include "postproc/vf.h" #include "vd_msg.h" +using namespace mpxp; + extern const vd_functions_t mpcodecs_vd_null; extern const vd_functions_t mpcodecs_vd_ffmpeg; extern const vd_functions_t mpcodecs_vd_dshow; Modified: mplayerxp/libmpcodecs/vd_divx4.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_divx4.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_divx4.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -24,6 +24,8 @@ #include "osdep/mplib.h" #include "osdep/bswap.h" +using namespace mpxp; + static const vd_info_t info = { "DivX4Linux lib (divx4/5 mode)", "divx4", Modified: mplayerxp/libmpcodecs/vd_dmo.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_dmo.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_dmo.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -10,10 +10,13 @@ #include "vd_internal.h" #include "codecs_ld.h" +#include "osdep/mplib.h" #include "loader/dmo/DMO_VideoDecoder.h" #include "vd_msg.h" +using namespace mpxp; + static const vd_info_t info = { "Win32/DMO video codecs", "dmo", Modified: mplayerxp/libmpcodecs/vd_dshow.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_dshow.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_dshow.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -13,7 +13,10 @@ #include "loader/dshow/DS_VideoDecoder.h" #include "codecs_ld.h" #include "osdep/bswap.h" +#include "osdep/mplib.h" +using namespace mpxp; + static const vd_info_t info = { "Win32/DirectShow video codecs", "dshow", Modified: mplayerxp/libmpcodecs/vd_ffmpeg.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_ffmpeg.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_ffmpeg.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -25,6 +25,8 @@ #include "libvo/video_out.h" #include "osdep/bswap.h" +using namespace mpxp; + static const vd_info_t info = { "FFmpeg's libavcodec codec family", "ffmpeg", Modified: mplayerxp/libmpcodecs/vd_huffyuv.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_huffyuv.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_huffyuv.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -27,6 +27,8 @@ #include "osdep/mplib.h" #include "osdep/bswap.h" +using namespace mpxp; + static const vd_info_t info = { "HuffYUV Video decoder", "huffyuv", Modified: mplayerxp/libmpcodecs/vd_libdv.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_libdv.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_libdv.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -9,6 +9,7 @@ #include "libvo/img_format.h" #include "osdep/bswap.h" +#include "osdep/mplib.h" #include <libdv/dv.h> #include <libdv/dv_types.h> @@ -19,6 +20,8 @@ #include "vd_internal.h" +using namespace mpxp; + static const vd_info_t info = { "Raw DV Video Decoder", "libdv", Modified: mplayerxp/libmpcodecs/vd_libmpeg2.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_libmpeg2.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_libmpeg2.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -20,6 +20,8 @@ #include "osdep/mplib.h" #include "osdep/bswap.h" +using namespace mpxp; + static const vd_info_t info = { "libmpeg2 MPEG 1/2 Video decoder", "libmpeg2", Modified: mplayerxp/libmpcodecs/vd_mpegpes.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_mpegpes.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_mpegpes.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -4,7 +4,10 @@ #include "mp_config.h" #include "vd_internal.h" #include "osdep/bswap.h" +#include "osdep/mplib.h" +using namespace mpxp; + static const vd_info_t info = { "MPEG 1/2 Video passthrough", "mpegpes", Modified: mplayerxp/libmpcodecs/vd_null.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_null.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_null.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -2,9 +2,11 @@ #include <stdlib.h> #include "mp_config.h" - +#include "osdep/mplib.h" #include "vd_internal.h" +using namespace mpxp; + static const vd_info_t info = { "Null video decoder", "null", Modified: mplayerxp/libmpcodecs/vd_nuv.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_nuv.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_nuv.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -5,7 +5,10 @@ #include "vd_internal.h" #include "codecs_ld.h" #include "osdep/bswap.h" +#include "osdep/mplib.h" +using namespace mpxp; + static const vd_info_t info = { "NuppelVideo decoder", "nuv", Modified: mplayerxp/libmpcodecs/vd_qtvideo.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_qtvideo.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_qtvideo.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -14,8 +14,11 @@ #include "loader/ldt_keeper.h" #endif #include "codecs_ld.h" +#include "osdep/mplib.h" #include "vd_msg.h" +using namespace mpxp; + static const vd_info_t info = { "Quicktime Video decoder", "qtvideo", Modified: mplayerxp/libmpcodecs/vd_raw.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_raw.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_raw.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -4,7 +4,10 @@ #include "mp_config.h" #include "vd_internal.h" #include "osdep/bswap.h" +#include "osdep/mplib.h" +using namespace mpxp; + static const vd_info_t info = { "RAW Uncompressed Video", "raw", Modified: mplayerxp/libmpcodecs/vd_real.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_real.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_real.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -12,6 +12,8 @@ #include "osdep/mplib.h" #include "osdep/bswap.h" +using namespace mpxp; + static const vd_info_t info = { "RealPlayer video codecs", "realvid", Modified: mplayerxp/libmpcodecs/vd_theora.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_theora.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_theora.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -15,6 +15,8 @@ #include "osdep/mplib.h" #include "osdep/bswap.h" +using namespace mpxp; + static const vd_info_t info = { "Theora/VP3 video decoder", "theora", Modified: mplayerxp/libmpcodecs/vd_vfw.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_vfw.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_vfw.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -14,6 +14,8 @@ #include "loader/wine/driver.h" #include "libmpdemux/aviprint.h" +using namespace mpxp; + static const vd_info_t info_vfw = { "Win32/VfW video codecs", "vfw", Modified: mplayerxp/libmpcodecs/vd_xanim.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_xanim.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_xanim.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -26,6 +26,8 @@ #include "vd_internal.h" #include "codecs_ld.h" +using namespace mpxp; + static const vd_info_t info = { "XAnim codecs", "xanim", Modified: mplayerxp/libmpcodecs/vd_xvid.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_xvid.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpcodecs/vd_xvid.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -18,6 +18,8 @@ #include "osdep/mplib.h" #include "osdep/bswap.h" +using namespace mpxp; + static const vd_info_t info = { "XviD MPEG4 codec ", "xvid", Modified: mplayerxp/libmpconf/cfgparser.cpp =================================================================== --- mplayerxp/libmpconf/cfgparser.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpconf/cfgparser.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -18,6 +18,8 @@ #include "mp_config.h" #include "osdep/mplib.h" +using namespace mpxp; + #define COMMAND_LINE 0 #define CONFIG_FILE 1 Modified: mplayerxp/libmpconf/codec-cfg.cpp =================================================================== --- mplayerxp/libmpconf/codec-cfg.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpconf/codec-cfg.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -26,6 +26,8 @@ #define MSGT_CLASS MSGT_CODECCFG #include "mp_msg.h" +using namespace mpxp; + #define MAX_NR_TOKEN 16 #define MAX_LINE_LEN 1000 Modified: mplayerxp/libmpconf/m_option.cpp =================================================================== --- mplayerxp/libmpconf/m_option.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpconf/m_option.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -19,6 +19,8 @@ #define MSGT_CLASS MSGT_CPLAYER #include "mp_msg.h" +using namespace mpxp; + // Don't mp_free for 'production' atm #ifndef MP_DEBUG //#define NO_FREE Modified: mplayerxp/libmpconf/m_property.cpp =================================================================== --- mplayerxp/libmpconf/m_property.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpconf/m_property.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -17,6 +17,8 @@ #define MSGT_CLASS MSGT_CPLAYER #include "mp_msg.h" +using namespace mpxp; + #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5)) static int do_action(m_option_t* prop_list, const char* name, Modified: mplayerxp/libmpconf/m_struct.cpp =================================================================== --- mplayerxp/libmpconf/m_struct.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpconf/m_struct.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -13,6 +13,8 @@ #define MSGT_CLASS MSGT_CPLAYER #include "mp_msg.h" +using namespace mpxp; + const m_option_t* m_struct_get_field(const m_struct_t* st,const char* f) { int i; Modified: mplayerxp/libmpconf/subopt-helper.cpp =================================================================== --- mplayerxp/libmpconf/subopt-helper.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpconf/subopt-helper.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -26,6 +26,7 @@ #define MSGT_CLASS MSGT_GLOBAL #include "mp_msg.h" +using namespace mpxp; #ifndef MP_DEBUG #define NDEBUG Modified: mplayerxp/libmpdemux/aviprint.cpp =================================================================== --- mplayerxp/libmpdemux/aviprint.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/aviprint.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -3,13 +3,16 @@ #include <stdlib.h> #include <unistd.h> -#include "../mp_config.h" +#include "mp_config.h" #include "libmpstream/stream.h" #include "demuxer.h" #include "aviprint.h" #include "demux_msg.h" +#include "osdep/mplib.h" +using namespace mpxp; + extern int avi_stream_id(unsigned int id); void print_avih_flags(MainAVIHeader *h){ Modified: mplayerxp/libmpdemux/demux_aiff.cpp =================================================================== --- mplayerxp/libmpdemux/demux_aiff.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_aiff.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -13,6 +13,8 @@ #include "osdep/mplib.h" #include "demux_msg.h" +using namespace mpxp; + static unsigned long cvt_extended(const char * buf) { unsigned long mantissa,last=0; Modified: mplayerxp/libmpdemux/demux_asf.cpp =================================================================== --- mplayerxp/libmpdemux/demux_asf.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_asf.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -16,6 +16,9 @@ #include "aviprint.h" #include "demux_msg.h" #include "osdep/mplib.h" + +using namespace mpxp; + /* * Load 16/32-bit values in little endian byte order * from an unaligned address Modified: mplayerxp/libmpdemux/demux_audio.cpp =================================================================== --- mplayerxp/libmpdemux/demux_audio.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_audio.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -21,6 +21,8 @@ #include "demux_msg.h" #include "osdep/mplib.h" +using namespace mpxp; + #define RAW_MP1 1 #define RAW_MP2 2 #define RAW_MP3 3 Modified: mplayerxp/libmpdemux/demux_avi.cpp =================================================================== --- mplayerxp/libmpdemux/demux_avi.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_avi.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -19,6 +19,8 @@ #include "aviprint.h" #include "demux_msg.h" +using namespace mpxp; + typedef int (*alt_demuxer_t)(demuxer_t *demux,demux_stream_t *__ds); typedef struct { // index stuff: Modified: mplayerxp/libmpdemux/demux_bmp.cpp =================================================================== --- mplayerxp/libmpdemux/demux_bmp.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_bmp.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -22,6 +22,8 @@ #ifdef HAVE_SDL_IMAGE #include <SDL/SDL_image.h> +using namespace mpxp; + static int demux_rw_seek(struct SDL_RWops *context, int offset, int whence) { unsigned long newpos=-1; Modified: mplayerxp/libmpdemux/demux_demuxers.cpp =================================================================== --- mplayerxp/libmpdemux/demux_demuxers.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_demuxers.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -7,6 +7,9 @@ #include "stheader.h" #include "demux_msg.h" #include "osdep/mplib.h" + +using namespace mpxp; + typedef struct dd_priv { demuxer_t* vd; demuxer_t* ad; Modified: mplayerxp/libmpdemux/demux_dv.cpp =================================================================== --- mplayerxp/libmpdemux/demux_dv.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_dv.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -36,6 +36,8 @@ #include <libdv/dv.h> #include <libdv/dv_types.h> +using namespace mpxp; + #define DV_PAL_FRAME_SIZE 144000 #define DV_NTSC_FRAME_SIZE 122000 Modified: mplayerxp/libmpdemux/demux_film.cpp =================================================================== --- mplayerxp/libmpdemux/demux_film.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_film.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -26,6 +26,8 @@ #include "stheader.h" #include "demux_msg.h" +using namespace mpxp; + // chunk types found in a FILM file #define CHUNK_FILM mmioFOURCC('F', 'I', 'L', 'M') #define CHUNK_FDSC mmioFOURCC('F', 'D', 'S', 'C') Modified: mplayerxp/libmpdemux/demux_fli.cpp =================================================================== --- mplayerxp/libmpdemux/demux_fli.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_fli.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -19,6 +19,8 @@ #include "demux_msg.h" #include "osdep/mplib.h" +using namespace mpxp; + typedef struct _fli_frames_t { int num_frames; int current_frame; Modified: mplayerxp/libmpdemux/demux_lavf.cpp =================================================================== --- mplayerxp/libmpdemux/demux_lavf.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_lavf.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -33,6 +33,8 @@ #include "demux_msg.h" #include "osdep/mplib.h" +using namespace mpxp; + #define PROBE_BUF_SIZE 2048 #define BIO_BUFFER_SIZE 32768 Modified: mplayerxp/libmpdemux/demux_mkv.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mkv.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_mkv.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -43,6 +43,8 @@ #include "loader/qtx/qtxsdk/components.h" #include "demux_msg.h" +using namespace mpxp; + enum { LZO_INPUT_DEPLETED=1, LZO_OUTPUT_FULL=2, Modified: mplayerxp/libmpdemux/demux_mov.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mov.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_mov.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -50,6 +50,8 @@ #include <fcntl.h> #endif +using namespace mpxp; + #define BE_16(x) be2me_16(x) #define BE_32(x) be2me_32(x) Modified: mplayerxp/libmpdemux/demux_mpg.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mpg.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_mpg.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -24,6 +24,9 @@ #include "libmpcodecs/dec_audio.h" #include "demux_msg.h" #include "osdep/mplib.h" + +using namespace mpxp; + //#define MAX_PS_PACKETSIZE 2048 #define MAX_PS_PACKETSIZE (224*1024) Modified: mplayerxp/libmpdemux/demux_mpxp64.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mpxp64.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_mpxp64.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -27,6 +27,8 @@ #include "demux_msg.h" #include "osdep/mplib.h" +using namespace mpxp; + #define MAX_AV_STREAMS MAX_V_STREAMS+MAX_A_STREAMS+MAX_S_STREAMS typedef struct { Modified: mplayerxp/libmpdemux/demux_nsv.cpp =================================================================== --- mplayerxp/libmpdemux/demux_nsv.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_nsv.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -23,6 +23,8 @@ #include "demux_msg.h" #include "osdep/mplib.h" +using namespace mpxp; + typedef struct { float v_pts; int video_pack_no; Modified: mplayerxp/libmpdemux/demux_null.cpp =================================================================== --- mplayerxp/libmpdemux/demux_null.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_null.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -7,7 +7,10 @@ #include "demuxer.h" #include "stheader.h" #include "libmpconf/cfgparser.h" +#include "osdep/mplib.h" +using namespace mpxp; + static const config_t demux_null_opts[] = { {NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpdemux/demux_nuv.cpp =================================================================== --- mplayerxp/libmpdemux/demux_nuv.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_nuv.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -23,6 +23,7 @@ #include "demux_msg.h" #include "osdep/mplib.h" +using namespace mpxp; struct nuv_signature { Modified: mplayerxp/libmpdemux/demux_ogg.cpp =================================================================== --- mplayerxp/libmpdemux/demux_ogg.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_ogg.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -28,6 +28,8 @@ #include "demux_msg.h" #include "osdep/mplib.h" +using namespace mpxp; + #define BLOCK_SIZE 4096 #define FOURCC_VORBIS mmioFOURCC('v', 'r', 'b', 's') #define FOURCC_THEORA mmioFOURCC('t', 'h', 'e', 'o') Modified: mplayerxp/libmpdemux/demux_pva.cpp =================================================================== --- mplayerxp/libmpdemux/demux_pva.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_pva.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -37,6 +37,8 @@ #include "demux_msg.h" #include "osdep/mplib.h" +using namespace mpxp; + /* * #defines below taken from PVA spec (see URL above) */ Modified: mplayerxp/libmpdemux/demux_ra.cpp =================================================================== --- mplayerxp/libmpdemux/demux_ra.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_ra.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -20,6 +20,8 @@ #include "aviprint.h" #include "demux_msg.h" +using namespace mpxp; + #define FOURCC_DOTRA mmioFOURCC('.','r','a', 0xfd) #define FOURCC_144 mmioFOURCC('1','4','_','4') #define FOURCC_288 mmioFOURCC('2','8','_','8') Modified: mplayerxp/libmpdemux/demux_rawaudio.cpp =================================================================== --- mplayerxp/libmpdemux/demux_rawaudio.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_rawaudio.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -13,6 +13,8 @@ #include "osdep/mplib.h" #include "aviprint.h" +using namespace mpxp; + int use_rawaudio = 0; static int channels = 2; static int samplerate = 44100; Modified: mplayerxp/libmpdemux/demux_rawvideo.cpp =================================================================== --- mplayerxp/libmpdemux/demux_rawvideo.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_rawvideo.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -5,7 +5,6 @@ #include <unistd.h> #include <string.h> - #include "libmpstream/stream.h" #include "demuxer.h" #include "stheader.h" @@ -14,6 +13,8 @@ #include "libvo/img_format.h" #include "demux_msg.h" +using namespace mpxp; + typedef struct priv_s { int use_rawvideo; int format; Modified: mplayerxp/libmpdemux/demux_real.cpp =================================================================== --- mplayerxp/libmpdemux/demux_real.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_real.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -36,6 +36,8 @@ #include "libao2/afmt.h" #include "demux_msg.h" +using namespace mpxp; + #define MKTAG(a, b, c, d) (a | (b << 8) | (c << 16) | (d << 24)) #define MAX_STREAMS 32 Modified: mplayerxp/libmpdemux/demux_roq.cpp =================================================================== --- mplayerxp/libmpdemux/demux_roq.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_roq.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -21,6 +21,8 @@ #include "demux_msg.h" #include "osdep/mplib.h" +using namespace mpxp; + #define RoQ_INFO 0x1001 #define RoQ_QUAD_CODEBOOK 0x1002 #define RoQ_QUAD_VQ 0x1011 Modified: mplayerxp/libmpdemux/demux_smjpeg.cpp =================================================================== --- mplayerxp/libmpdemux/demux_smjpeg.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_smjpeg.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -26,6 +26,8 @@ #include "demux_msg.h" #include "osdep/mplib.h" +using namespace mpxp; + static MPXP_Rc smjpeg_probe(demuxer_t* demuxer){ int orig_pos = stream_tell(demuxer->stream); char buf[8]; Modified: mplayerxp/libmpdemux/demux_ts.cpp =================================================================== --- mplayerxp/libmpdemux/demux_ts.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_ts.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -41,6 +41,8 @@ #include "mpeg_hdr.h" #include "demux_msg.h" +using namespace mpxp; + #define TS_PH_PACKET_SIZE 192 #define TS_FEC_PACKET_SIZE 204 #define TS_PACKET_SIZE 188 Modified: mplayerxp/libmpdemux/demux_ty.cpp =================================================================== --- mplayerxp/libmpdemux/demux_ty.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_ty.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -49,6 +49,7 @@ #include "osdep/mplib.h" #include "libmpcodecs/dec_audio.h" +using namespace mpxp; #define AV_RB24(x) ((((uint8_t*)(x))[0] << 16) | \ (((uint8_t*)(x))[1] << 8) | \ Modified: mplayerxp/libmpdemux/demux_viv.cpp =================================================================== --- mplayerxp/libmpdemux/demux_viv.cpp 2012-11-22 12:56:08 UTC (rev 431) +++ mplayerxp/libmpdemux/demux_viv.cpp 2012-11-22 15:29:45 UTC (rev 432) @@ -21,6 +21,8 @@ #include "libmpconf/cfgparser.h" #include "osdep/mplib.h" +using namespace mpxp; + /* parameters ! */ static int vivo_... [truncated message content] |
From: <nic...@us...> - 2012-11-22 16:44:51
|
Revision: 433 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=433&view=rev Author: nickols_k Date: 2012-11-22 16:44:42 +0000 (Thu, 22 Nov 2012) Log Message: ----------- use direct MSG_X system without #define. Executable binary of MPlayerXP lost >60KB of size Modified Paths: -------------- mplayerxp/mp_msg.cpp mplayerxp/mp_msg.h Modified: mplayerxp/mp_msg.cpp =================================================================== --- mplayerxp/mp_msg.cpp 2012-11-22 15:29:45 UTC (rev 432) +++ mplayerxp/mp_msg.cpp 2012-11-22 16:44:42 UTC (rev 433) @@ -13,6 +13,7 @@ using namespace mpxp; +namespace mpxp { #define _bg(x) ((x) >> 4) #define _fg(x) ((x) & 0x0f) typedef struct priv_s { @@ -129,3 +130,4 @@ } void mpxp_print_flush(void) { fflush(stderr); } +} //namespace mpxp Modified: mplayerxp/mp_msg.h =================================================================== --- mplayerxp/mp_msg.h 2012-11-22 15:29:45 UTC (rev 432) +++ mplayerxp/mp_msg.h 2012-11-22 16:44:42 UTC (rev 433) @@ -3,11 +3,13 @@ #include "mplayerxp.h" -// verbosity elevel: +/* TODO: more highlighted levels */ +#ifndef MSGT_CLASS +#define MSGT_CLASS MSGT_CPLAYER +#endif -// stuff from level MSGL_FATAL-MSGL_HINT should be translated. +namespace mpxp { -/* TODO: more highlighted levels */ enum { MSGL_FATAL =0U, /* will exit/abort LightRed */ MSGL_ERR =1U, /* continues Red */ @@ -51,33 +53,40 @@ MSGT_MASK =0x0FFFFFFF }; + void mpxp_print_init(int verbose); + void mpxp_print_uninit(void); + void mpxp_print_flush(void); + int mpxp_printf( unsigned x, const char *format, ... ); -void mpxp_print_init(int verbose); -void mpxp_print_uninit(void); -void mpxp_print_flush(void); -int mpxp_printf( unsigned x, const char *format, ... ); + static inline int mpxp_print_dummy(const char* args,...) { + UNUSED(args); return 0; + } -#ifdef __GNUC__ -static inline int mpxp_print_dummy(const char* args,...) { UNUSED(args); return 0;} -#define mpxp_print(mod,lev, args... ) ((lev<(mp_conf.verbose+MSGL_V))?(mpxp_printf(((lev&0xF)<<28)|(mod&0x0FFFFFFF),## args)):(mpxp_print_dummy(args))) -#else -#define mpxp_print(mod,lev, ... ) mpxp_printf(((lev&0xF)<<28)|(mod&0x0FFFFFFF),__VA_ARGS__) -#endif - -#ifndef MSGT_CLASS -#define MSGT_CLASS MSGT_CPLAYER -#endif - #ifdef __va_arg_pack /* requires gcc-4.3.x */ -static __always_inline int MSG_INFO(const char* args,...) { return mpxp_print(MSGT_CLASS,MSGL_INFO,args,__va_arg_pack ()); } -static __always_inline int MSG_FATAL(const char* args,...) { return mpxp_print(MSGT_CLASS,MSGL_FATAL,args,__va_arg_pack ()); } -static __always_inline int MSG_WARN(const char* args,...) { return mpxp_print(MSGT_CLASS,MSGL_WARN,args,__va_arg_pack ()); } -static __always_inline int MSG_ERR(const char* args,...) { return mpxp_print(MSGT_CLASS,MSGL_ERR,args,__va_arg_pack ()); } -static __always_inline int MSG_V(const char* args,...) { return mpxp_print(MSGT_CLASS,MSGL_V,args,__va_arg_pack ()); } -static __always_inline int MSG_OK(const char* args,...) { return mpxp_print(MSGT_CLASS,MSGL_OK,args,__va_arg_pack ()); } -static __always_inline int MSG_HINT(const char* args,...) { return mpxp_print(MSGT_CLASS,MSGL_HINT,args,__va_arg_pack ()); } -static __always_inline int MSG_STATUS(const char* args,...) { return mpxp_print(MSGT_CLASS,MSGL_STATUS,args,__va_arg_pack ()); } - +static __always_inline int MSG_INFO(const char* args,...) { + return mpxp_printf((MSGL_INFO<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()); +} +static __always_inline int MSG_FATAL(const char* args,...) { + return mpxp_printf((MSGL_FATAL<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()); +} +static __always_inline int MSG_WARN(const char* args,...) { + return mpxp_printf((MSGL_WARN<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()); +} +static __always_inline int MSG_ERR(const char* args,...) { + return mpxp_printf((MSGL_ERR<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()); +} +static __always_inline int MSG_OK(const char* args,...) { + return mpxp_printf((MSGL_OK<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()); +} +static __always_inline int MSG_HINT(const char* args,...) { + return mpxp_printf((MSGL_HINT<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()); +} +static __always_inline int MSG_STATUS(const char* args,...) { + return mpxp_printf((MSGL_STATUS<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()); +} +static __always_inline int MSG_V(const char* args,...) { + return mpxp_printf((MSGL_V<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()); +} #ifdef MP_DEBUG static __always_inline int MSG_DBG2(const char* args,...) { return mpxp_print(MSGT_CLASS,MSGL_DBG3,args,__va_arg_pack ()); } static __always_inline int MSG_DBG3(const char* args,...) { return mpxp_print(MSGT_CLASS,MSGL_DBG4,args,__va_arg_pack ()); } @@ -85,8 +94,13 @@ static __always_inline int MSG_DBG2(const char* args,...) { return mpxp_print_dummy(args); } static __always_inline int MSG_DBG3(const char* args,...) { return mpxp_print_dummy(args); } #endif - #else // __va_arg_pack +#ifdef __GNUC__ +#define mpxp_print(mod,lev, args... ) ((lev<(mp_conf.verbose+MSGL_V))?(mpxp_printf(((lev&0xF)<<28)|(mod&0x0FFFFFFF),## args)):(mpxp_print_dummy(args))) +#else +#undef mpxp_print +#define mpxp_print(mod,lev, ... ) mpxp_printf(((lev&0xF)<<28)|(mod&0x0FFFFFFF),__VA_ARGS__) +#endif #undef MSG_INFO #undef MSG_FATAL #undef MSG_WARN @@ -113,5 +127,6 @@ #define MSG_DBG3(args...) mpxp_print_dummy(); #endif #endif // __va_arg_pack +} // namespace mpxp #endif // __MP_MSG_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-11-23 09:18:37
|
Revision: 438 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=438&view=rev Author: nickols_k Date: 2012-11-23 09:18:26 +0000 (Fri, 23 Nov 2012) Log Message: ----------- Change number of backtraces. Note: i suspect that my development environment has been virused to add illegal patch into MPlayerXP. When i perform transition on to C++ then i found out the strange behaviour of ld: - [424] commit didn't break linkage of the project althrough this patch replaces some short C-names of functions with C++-long names. Therefore, short C-names like rtsp_session_start() were linked by g++ regardless the fact that official source-tree of project lost them. - [437] commit emulates fixing of problem. I had movie which couldn't be played before this commit. But additional MSG_V() cannot fix anything in player. Furthermore, player after this commit doesn't print some symbols which it must print with this patch. - list of suspect calls with -core.malloc-debug=3 option points me that some internal contexts of player were substituted by illegal patch. Additional proof of that is [434] commit. This commit did illegal patch thinner, but not removed it. Furthemore, each replace of #define with inline function or enum decreases size of project regardless on long C++-names of functions and data objects. Well, one of goal transition project on C++ was using of C++ long-names which are dynamically changed together with changing number or types of arguments. But, it seems that there is big aliance against of me and my project. And i suspect some objects from mplayerhq team who revenge me for fork using dirty technology. Considering the fact that they hate C++ i'm suspecting that they coerce somebody to attack my project and modify illegal patch parallel with my improvements. Additional observations: - My local copy of g++ still prints: "warning: 'packed' attribute ignored" that makes win32loader non working at least. That warning became appears right after adding so-called small secury holes into structures of project. - My local copy of /lib32/libgcc_s.so was damaged because demuxer returns -nan in pts field for each packet. Moreover, upgrade of gcc didn't help to solve this problem. Thus, i have no working 32-bit development environment. - My 32-bit development environment (aka: gcc-4.5.4) printed: --- 8< ---- In file included from ../osdep/cpudetect.h:4:0, from win32.c:942: ../mplayerxp.h:130:20: error: invalid storage class for function 'escape_player' ../mplayerxp.h:130:20: warning: no previous prototype for 'escape_player' ../mplayerxp.h:135:23: error: invalid storage class for function 'check_pin' ../mplayerxp.h:135:23: warning: no previous prototype for 'check_pin' --- 8< --- mplayerxp.h:130: static inline void escape_player(const char* why,unsigned num_calls) { mplayerxp.h:135: static inline MPXP_Rc check_pin(const char* module,unsigned pin1,unsigned pin2) { --- 8< --- - Last few days, 32-bit binary of mplayerxp is able to print help only and ignores command-line arguments. But who is that (***insert any colorful phrases here***) analog of virus which attacks my development environment and who is his host(s)? Thus, i need find out the way to restore the quality of my development enviroment! Modified Paths: -------------- mplayerxp/configure mplayerxp/libao2/ao_sdl.cpp mplayerxp/osdep/mp_malloc.cpp Modified: mplayerxp/configure =================================================================== --- mplayerxp/configure 2012-11-22 18:37:26 UTC (rev 437) +++ mplayerxp/configure 2012-11-23 09:18:26 UTC (rev 438) @@ -795,6 +795,7 @@ bsd && add_ldflags "-rdynamic" enabled dbg23 def_debug='#define MP_DEBUG 1' || def_debug='#undef MP_DEBUG' +enabled dbg23 && check_cflags "-fbounds-check" # Checking for VIDIX enabled vidix && xxrequire2 vidix "vidix/vidix.h vidix/vidixlibxx.h" Vidix -lvidixxx Modified: mplayerxp/libao2/ao_sdl.cpp =================================================================== --- mplayerxp/libao2/ao_sdl.cpp 2012-11-22 18:37:26 UTC (rev 437) +++ mplayerxp/libao2/ao_sdl.cpp 2012-11-23 09:18:26 UTC (rev 438) @@ -9,6 +9,7 @@ * Thanks to Arpi for nice ringbuffer-code! * */ +#include <algorithm> #include <stdio.h> #include <stdlib.h> @@ -56,8 +57,7 @@ int x; while(len>0){ if(priv->full_buffers==NUM_BUFS) break; - x=BUFFSIZE-priv->buf_write_pos; - if(x>len) x=len; + x=std::min(unsigned(len),BUFFSIZE-priv->buf_write_pos); memcpy(priv->buffer[priv->buf_write]+priv->buf_write_pos,data+len2,x); len2+=x; len-=x; priv->buffered_bytes+=x; priv->buf_write_pos+=x; @@ -77,8 +77,7 @@ int x; while(len>0){ if(priv->full_buffers==0) break; // no more data buffered! - x=BUFFSIZE-priv->buf_read_pos; - if(x>len) x=len; + x=std::min(unsigned(len),BUFFSIZE-priv->buf_read_pos); memcpy(data+len2,priv->buffer[priv->buf_read]+priv->buf_read_pos,x); SDL_MixAudio(data+len2, data+len2, x, priv->volume); len2+=x; len-=x; Modified: mplayerxp/osdep/mp_malloc.cpp =================================================================== --- mplayerxp/osdep/mp_malloc.cpp 2012-11-22 18:37:26 UTC (rev 437) +++ mplayerxp/osdep/mp_malloc.cpp 2012-11-23 09:18:26 UTC (rev 438) @@ -17,11 +17,13 @@ namespace mpxp { +enum { Max_BackTraces=13 }; + typedef struct mp_slot_s { any_t* page_ptr; size_t size; size_t ncalls; - any_t* calls[10]; + any_t* calls[Max_BackTraces]; }mp_slot_t; typedef struct mp_slot_container_s { @@ -218,7 +220,7 @@ if(!slot) { printf("[__prot_free_append] suspect call found! Can't find slot for address: %p [aligned: %p]\n",ptr,page_ptr); __prot_print_slots(&priv->mallocs); - __print_backtrace(10); + __print_backtrace(Max_BackTraces); kill(getpid(), SIGILL); } size_t fullsize=app_fullsize(slot->size); @@ -234,7 +236,7 @@ if(!slot) { printf("[__prot_realloc_append] suspect call found! Can't find slot for address: %p [aligned: %p]\n",ptr,prot_page_align(ptr)); __prot_print_slots(&priv->mallocs); - __print_backtrace(10); + __print_backtrace(Max_BackTraces); kill(getpid(), SIGILL); } memcpy(rp,ptr,std::min(slot->size,size)); @@ -268,7 +270,7 @@ if(!slot) { printf("[__prot_free_prepend] suspect call found! Can't find slot for address: %p [aligned: %p]\n",ptr,page_ptr); __prot_print_slots(&priv->mallocs); - __print_backtrace(10); + __print_backtrace(Max_BackTraces); kill(getpid(), SIGILL); } mprotect(page_ptr,__VM_PAGE_SIZE__,MP_PROT_READ|MP_PROT_WRITE); @@ -283,7 +285,7 @@ if(!slot) { printf("[__prot_realloc_prepend] suspect call found! Can't find slot for address: %p [aligned: %p]\n",ptr,pre_page_align(ptr)); __prot_print_slots(&priv->mallocs); - __print_backtrace(10); + __print_backtrace(Max_BackTraces); kill(getpid(), SIGILL); } memcpy(rp,ptr,std::min(slot->size,size)); @@ -324,7 +326,7 @@ rp=malloc(size); if(rp) { slot=prot_append_slot(&priv->mallocs,rp,size); - slot->ncalls=backtrace(slot->calls,10); + slot->ncalls=backtrace(slot->calls,Max_BackTraces); } return rp; } @@ -335,7 +337,7 @@ if(rp) { mp_slot_t* slot; slot=prot_append_slot(&priv->mallocs,rp,size); - slot->ncalls=backtrace(slot->calls,10); + slot->ncalls=backtrace(slot->calls,Max_BackTraces); } return rp; } @@ -351,7 +353,7 @@ MSG_WARN("[bt_realloc] suspect call found! Can't find slot for address: %p\n",ptr); mp_slot_t* _slot; _slot=prot_append_slot(&priv->reallocs,ptr,size); - _slot->ncalls=backtrace(_slot->calls,10); + _slot->ncalls=backtrace(_slot->calls,Max_BackTraces); } else { slot->page_ptr=rp; // update address after realloc slot->size=size; @@ -366,7 +368,7 @@ MSG_WARN("[bt_free] suspect call found! Can't find slot for address: %p\n",ptr); mp_slot_t* _slot; _slot=prot_append_slot(&priv->frees,ptr,0); - _slot->ncalls=backtrace(_slot->calls,10); + _slot->ncalls=backtrace(_slot->calls,Max_BackTraces); return; } prot_free_slot(&priv->mallocs,ptr); @@ -389,7 +391,7 @@ } } if(printable) MSG_INFO("%20s",s); - else for(j=0;j<std::min(c->slots[i].size,size_t(10));j++) { + else for(j=0;j<std::min(c->slots[i].size,size_t(Max_BackTraces));j++) { MSG_INFO("%02X ",(unsigned char)s[j]); } MSG_INFO("\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-11-23 10:26:27
|
Revision: 439 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=439&view=rev Author: nickols_k Date: 2012-11-23 10:26:17 +0000 (Fri, 23 Nov 2012) Log Message: ----------- disable streaming by default + fix problem: libmpconf/libmpconf.a(m_option.o): In function `parse_custom_url(m_option const*, char const*, char*, void*, int)': m_option.cpp:(.text+0x23e8): undefined reference to `mpxp::url2string(char*, char const*)' collect2: ld returned 1 exit status P.S.: In addition to [438] comments i need to say that illegal patch violates GPL because doesn't exists in form of source code available for receiving and modifications. Preamble ( GPLv2 ): When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. TERMS AND CONDITIONS (GPLv3) : 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. Modified Paths: -------------- mplayerxp/configure mplayerxp/libmpconf/m_option.cpp mplayerxp/libmpconf/m_option.h mplayerxp/libmpstream/Makefile mplayerxp/libmpstream/asf_mmst_streaming.cpp mplayerxp/libmpstream/s_cdd.cpp mplayerxp/libmpstream/url.cpp mplayerxp/libmpstream/url.h mplayerxp/xmpcore/xmp_adecoder.cpp mplayerxp/xmpcore/xmp_aplayer.cpp Modified: mplayerxp/configure =================================================================== --- mplayerxp/configure 2012-11-23 09:18:26 UTC (rev 438) +++ mplayerxp/configure 2012-11-23 10:26:17 UTC (rev 439) @@ -92,7 +92,8 @@ "static|build static libraries", "dbg23|allow additional level of debug messages", "win32loader|build support for Win32 codecs", - "random_name|generates pseudo random suffix of target" + "random_name|generates pseudo random suffix of target", + "im_sure_that_must_have_streaming| the key to unlock streaming" ) AUTOCONF_LIST=( @@ -407,6 +408,7 @@ check_func2 execinfo.h backtrace print_config HAVE_ mp_config.h mp_config.mak backtrace +disabled im_sure_that_must_have_streaming && disable streaming disable inet_pton if enabled streaming ; then disable socklib @@ -431,6 +433,7 @@ disabled inet_pton && disable streaming print_config HAVE_ mp_config.h mp_config.mak streaming +enabled streaming && inputmodules="streaming $inputmodules" || noinputmodules="streaming $noinputmodules" disabled streaming && disable af_inet6 Modified: mplayerxp/libmpconf/m_option.cpp =================================================================== --- mplayerxp/libmpconf/m_option.cpp 2012-11-23 09:18:26 UTC (rev 438) +++ mplayerxp/libmpconf/m_option.cpp 2012-11-23 10:26:17 UTC (rev 439) @@ -1785,6 +1785,7 @@ NULL }; +#ifdef HAVE_STREAMING static int parse_custom_url(const m_option_t* opt,const char *name, char *url, any_t* dst, int src) { int pos1, pos2, r, v6addr = 0; @@ -1965,7 +1966,7 @@ char* fname = ptr2+1; if(l > 1) { fname = new char [l]; - url_unescape_string(fname,ptr2+1); + url2string(fname,ptr2+1); } r = m_struct_set(desc,dst,"filename",fname); if(fname != ptr2+1) @@ -1994,3 +1995,4 @@ NULL, NULL }; +#endif Modified: mplayerxp/libmpconf/m_option.h =================================================================== --- mplayerxp/libmpconf/m_option.h 2012-11-23 09:18:26 UTC (rev 438) +++ mplayerxp/libmpconf/m_option.h 2012-11-23 10:26:17 UTC (rev 439) @@ -89,12 +89,13 @@ */ extern const m_option_type_t m_option_type_obj_presets; +#ifdef HAVE_STREAMING /// Parse an URL into a struct. /** The option priv field (\ref m_option::priv) must point to a * \ref m_struct_st describing which fields of the URL must be used. */ extern const m_option_type_t m_option_type_custom_url; - +#endif /// Extra definition needed for \ref m_option_type_obj_params options. typedef struct { const struct m_struct_st* desc; /// Field descriptions. @@ -130,7 +131,9 @@ #define MCONF_TYPE_SPAN (&m_option_type_span) #define MCONF_TYPE_OBJ_SETTINGS_LIST (&m_option_type_obj_settings_list) #define MCONF_TYPE_OBJ_PRESETS (&m_option_type_obj_presets) +#ifdef HAVE_STREAMING #define MCONF_TYPE_CUSTOM_URL (&m_option_type_custom_url) +#endif #define MCONF_TYPE_OBJ_PARAMS (&m_option_type_obj_params) #define MCONF_TYPE_TIME (&m_option_type_time) #define MCONF_TYPE_TIME_SIZE (&m_option_type_time_size) Modified: mplayerxp/libmpstream/Makefile =================================================================== --- mplayerxp/libmpstream/Makefile 2012-11-23 09:18:26 UTC (rev 438) +++ mplayerxp/libmpstream/Makefile 2012-11-23 10:26:17 UTC (rev 439) @@ -6,8 +6,8 @@ DO_MAKE = @ for i in $(SUBDIRS); do $(MAKE) -C $$i $@ || exit; done DO_ALL = @ for i in $(SUBDIRS); do $(MAKE) -C $$i all || exit; done -CXXSRCS=s_tv.cpp -CXXSRCS+= s_file.cpp s_ffmpeg.cpp s_null.cpp +CXXSRCS= s_ffmpeg.cpp s_file.cpp s_null.cpp s_tv.cpp +CXXSRCS+= cache2.cpp mrl.cpp stream.cpp url.cpp ifeq ($(HAVE_LIBCDIO_CDDA),yes) CXXSRCS += s_cdd.cpp CXXSRCS += cdda.cpp @@ -21,24 +21,31 @@ ifeq ($(USE_DVDREAD),yes) CXXSRCS += s_dvdread.cpp endif -CXXSRCS += url.cpp ifeq ($(USE_OSS_AUDIO),yes) CXXSRCS += s_oss.cpp endif ifeq ($(USE_LIBVCD),yes) CXXSRCS += s_vcdnav.cpp endif -CXXSRCS += mrl.cpp SUBDIRS = tvi ifeq ($(HAVE_STREAMING),yes) SUBDIRS += freesdp librtsp realrtsp -CXXSRCS += asf_streaming.cpp asf_mmst_streaming.cpp s_ftp.cpp s_udp.cpp s_network.cpp -CXXSRCS+=s_rtsp.cpp network.cpp http.cpp cookies.cpp rtp.cpp pnm.cpp tcp.cpp udp.cpp +CXXSRCS += asf_streaming.cpp \ + asf_mmst_streaming.cpp \ + cookies.cpp \ + http.cpp \ + network.cpp \ + pnm.cpp \ + rtp.cpp \ + tcp.cpp \ + udp.cpp +CXXSRCS += s_ftp.cpp \ + s_network.cpp \ + s_rtsp.cpp \ + s_udp.cpp endif -CXXSRCS+= stream.cpp cache2.cpp - OBJS = $(SRCS:.c=.o) CXXOBJS = $(CXXSRCS:.cpp=.o) INCLUDE = -I../ @@ -61,9 +68,10 @@ $(LIBNAME): $(SUBDIRS) $(OBJS) $(CXXOBJS) $(AR) r $(LIBNAME) $(OBJS) $(CXXOBJS) + $(AR) r $(LIBNAME) \ + $(wildcard tvi/*.o) ifeq ($(HAVE_STREAMING),yes) $(AR) r $(LIBNAME) \ - $(wildcard tvi/*.o) \ $(wildcard freesdp/*.o) \ $(wildcard librtsp/*.o) \ $(wildcard realrtsp/*.o) Modified: mplayerxp/libmpstream/asf_mmst_streaming.cpp =================================================================== --- mplayerxp/libmpstream/asf_mmst_streaming.cpp 2012-11-23 09:18:26 UTC (rev 438) +++ mplayerxp/libmpstream/asf_mmst_streaming.cpp 2012-11-23 10:26:17 UTC (rev 439) @@ -520,7 +520,7 @@ MSG_FATAL("Memory allocation failed!\n"); return -1; } - url_unescape_string(unescpath,path); + url2string(unescpath,path); path=unescpath; if( url1->port==0 ) { Modified: mplayerxp/libmpstream/s_cdd.cpp =================================================================== --- mplayerxp/libmpstream/s_cdd.cpp 2012-11-23 09:18:26 UTC (rev 438) +++ mplayerxp/libmpstream/s_cdd.cpp 2012-11-23 10:26:17 UTC (rev 439) @@ -40,6 +40,7 @@ static MPXP_Rc __FASTCALL__ _cddb_open(any_t*libinput,stream_t *stream,const char *filename,unsigned flags) { +#ifdef HAVE_STREAMING const char *param; char *device; MPXP_Rc retval; @@ -55,6 +56,9 @@ if(device) delete device; check_pin("stream",stream->pin,STREAM_PIN); return retval; +#else + return MPXP_False; +#endif } static int __FASTCALL__ cdd_read(stream_t*stream,stream_packet_t*sp) Modified: mplayerxp/libmpstream/url.cpp =================================================================== --- mplayerxp/libmpstream/url.cpp 2012-11-23 09:18:26 UTC (rev 438) +++ mplayerxp/libmpstream/url.cpp 2012-11-23 10:26:17 UTC (rev 439) @@ -4,6 +4,7 @@ * (C) 2001, MPlayer team. * */ +#include <limits> #include <string.h> #include <stdlib.h> @@ -19,10 +20,7 @@ using namespace mpxp; -#ifndef SIZE_MAX -#define SIZE_MAX ((size_t)-1) -#endif - +namespace mpxp { URL_t *url_redirect(URL_t **url, const char *redir) { URL_t *u = *url; URL_t *res; @@ -57,7 +55,7 @@ if( url==NULL ) return NULL; - if (strlen(url) > (SIZE_MAX / 3 - 1)) { + if (strlen(url) > (std::numeric_limits<size_t>::max() / 3 - 1)) { MSG_FATAL("MemAllocFailed\n"); goto err_out; } @@ -77,7 +75,7 @@ // Initialisation of the URL container members memset( Curl, 0, sizeof(URL_t) ); - url_escape_string(escfilename,url); + string2url(escfilename,url); // Copy the url in the URL container Curl->url = mp_strdup(escfilename); @@ -243,7 +241,7 @@ /* Replace escape sequences in an URL (or a part of an URL) */ /* works like strcpy(), but without return argument */ void -url_unescape_string(char *outbuf, const char *inbuf) +url2string(char *outbuf, const char *inbuf) { unsigned char c,c1,c2; int i,len=strlen(inbuf); @@ -313,7 +311,7 @@ /* Replace specific characters in the URL string by an escape sequence */ /* works like strcpy(), but without return argument */ void -url_escape_string(char *outbuf, const char *_inbuf) { +string2url(char *outbuf, const char *_inbuf) { char* inbuf=mp_strdup(_inbuf); int i = 0,j,len = strlen(inbuf); char* tmp,*in; @@ -361,7 +359,7 @@ if(!unesc) unesc = new char [len+1]; // unescape first to avoid escaping escape - url_unescape_string(unesc,in); + url2string(unesc,in); // then escape, including mark and other reserved chars // that can come from escape sequences url_escape_string_part(outbuf,unesc); @@ -402,3 +400,4 @@ } } #endif //__URL_DEBUG +} // namespace mpxp Modified: mplayerxp/libmpstream/url.h =================================================================== --- mplayerxp/libmpstream/url.h 2012-11-23 09:18:26 UTC (rev 438) +++ mplayerxp/libmpstream/url.h 2012-11-23 10:26:17 UTC (rev 439) @@ -9,7 +9,8 @@ //#define __URL_DEBUG -typedef struct { +namespace mpxp { + typedef struct { char *url; char *protocol; char *hostname; @@ -17,17 +18,17 @@ unsigned int port; char *username; char *password; -} URL_t; + } URL_t; -URL_t* url_new(const char* url); -void url_free(URL_t* url); + URL_t* url_new(const char* url); + void url_free(URL_t* url); -URL_t *url_redirect(URL_t **url, const char *redir); -void url_unescape_string(char *outbuf, const char *inbuf); -void url_escape_string(char *outbuf, const char *inbuf); + URL_t *url_redirect(URL_t **url, const char *redir); + void url2string(char *outbuf, const char *inbuf); + void string2url(char *outbuf, const char *inbuf); #ifdef __URL_DEBUG -void url_debug(URL_t* url); + void url_debug(URL_t* url); #endif // __URL_DEBUG - +} // namespace #endif // __URL_H Modified: mplayerxp/xmpcore/xmp_adecoder.cpp =================================================================== --- mplayerxp/xmpcore/xmp_adecoder.cpp 2012-11-23 09:18:26 UTC (rev 438) +++ mplayerxp/xmpcore/xmp_adecoder.cpp 2012-11-23 10:26:17 UTC (rev 439) @@ -4,6 +4,7 @@ #include <stdio.h> #include <unistd.h> // for usleep() #include <math.h> +#include <sys/time.h> #include "mplayerxp.h" #include "mp_msg.h" Modified: mplayerxp/xmpcore/xmp_aplayer.cpp =================================================================== --- mplayerxp/xmpcore/xmp_aplayer.cpp 2012-11-23 09:18:26 UTC (rev 438) +++ mplayerxp/xmpcore/xmp_aplayer.cpp 2012-11-23 10:26:17 UTC (rev 439) @@ -4,6 +4,7 @@ #include <unistd.h> // for usleep() #include <pthread.h> #include <math.h> +#include <sys/time.h> #include "mplayerxp.h" #include "mp_msg.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-11-23 16:09:19
|
Revision: 443 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=443&view=rev Author: nickols_k Date: 2012-11-23 16:09:06 +0000 (Fri, 23 Nov 2012) Log Message: ----------- include rootdir xmpcore osdep into namespace mpxp; Modified Paths: -------------- mplayerxp/dump.cpp mplayerxp/dump.h mplayerxp/input2/input.cpp mplayerxp/input2/joystick.cpp mplayerxp/input2/lirc.cpp mplayerxp/libao2/afmt.cpp mplayerxp/libao2/ao_alsa9.cpp mplayerxp/libao2/ao_arts.cpp mplayerxp/libao2/ao_esd.cpp mplayerxp/libao2/ao_jack.cpp mplayerxp/libao2/ao_nas.cpp mplayerxp/libao2/ao_null.cpp mplayerxp/libao2/ao_openal.cpp mplayerxp/libao2/ao_oss.cpp mplayerxp/libao2/ao_sdl.cpp mplayerxp/libao2/ao_wav.cpp mplayerxp/libao2/audio_out.cpp mplayerxp/libao2/mixer.cpp mplayerxp/libmpcodecs/ad.cpp mplayerxp/libmpcodecs/ad_a52.cpp mplayerxp/libmpcodecs/ad_acm.cpp mplayerxp/libmpcodecs/ad_dca.cpp mplayerxp/libmpcodecs/ad_dmo.cpp mplayerxp/libmpcodecs/ad_dshow.cpp mplayerxp/libmpcodecs/ad_dvdpcm.cpp mplayerxp/libmpcodecs/ad_faad.cpp mplayerxp/libmpcodecs/ad_hwac3.cpp mplayerxp/libmpcodecs/ad_lavc.cpp mplayerxp/libmpcodecs/ad_libdv.cpp mplayerxp/libmpcodecs/ad_mp3.cpp mplayerxp/libmpcodecs/ad_null.cpp mplayerxp/libmpcodecs/ad_pcm.cpp mplayerxp/libmpcodecs/ad_qtaudio.cpp mplayerxp/libmpcodecs/ad_real.cpp mplayerxp/libmpcodecs/ad_twin.cpp mplayerxp/libmpcodecs/ad_vorbis.cpp mplayerxp/libmpcodecs/codecs_ld.cpp mplayerxp/libmpcodecs/dec_audio.cpp mplayerxp/libmpcodecs/dec_video.cpp mplayerxp/libmpcodecs/liba52/bit_allocate.cpp mplayerxp/libmpcodecs/liba52/bitstream.cpp mplayerxp/libmpcodecs/liba52/crc.cpp mplayerxp/libmpcodecs/liba52/downmix.cpp mplayerxp/libmpcodecs/liba52/imdct.cpp mplayerxp/libmpcodecs/liba52/parse.cpp mplayerxp/libmpcodecs/liba52/resample.cpp mplayerxp/libmpcodecs/libdca/bitstream.cpp mplayerxp/libmpcodecs/libdca/downmix.cpp mplayerxp/libmpcodecs/libdca/parse.cpp mplayerxp/libmpcodecs/libdca/resample.cpp mplayerxp/libmpcodecs/libnuppelvideo/RTjpegN.cpp mplayerxp/libmpcodecs/libnuppelvideo/minilzo.cpp mplayerxp/libmpcodecs/libnuppelvideo/nuppelvideo.cpp mplayerxp/libmpcodecs/vd.cpp mplayerxp/libmpcodecs/vd_divx4.cpp mplayerxp/libmpcodecs/vd_dmo.cpp mplayerxp/libmpcodecs/vd_dshow.cpp mplayerxp/libmpcodecs/vd_huffyuv.cpp mplayerxp/libmpcodecs/vd_lavc.cpp mplayerxp/libmpcodecs/vd_libdv.cpp mplayerxp/libmpcodecs/vd_libmpeg2.cpp mplayerxp/libmpcodecs/vd_mpegpes.cpp mplayerxp/libmpcodecs/vd_null.cpp mplayerxp/libmpcodecs/vd_nuv.cpp mplayerxp/libmpcodecs/vd_qtvideo.cpp mplayerxp/libmpcodecs/vd_raw.cpp mplayerxp/libmpcodecs/vd_real.cpp mplayerxp/libmpcodecs/vd_theora.cpp mplayerxp/libmpcodecs/vd_vfw.cpp mplayerxp/libmpcodecs/vd_xanim.cpp mplayerxp/libmpcodecs/vd_xvid.cpp mplayerxp/libmpconf/cfgparser.cpp mplayerxp/libmpconf/codec-cfg.cpp mplayerxp/libmpconf/m_option.cpp mplayerxp/libmpconf/m_property.cpp mplayerxp/libmpconf/m_struct.cpp mplayerxp/libmpconf/subopt-helper.cpp mplayerxp/libmpdemux/aviprint.cpp mplayerxp/libmpdemux/demux_aiff.cpp mplayerxp/libmpdemux/demux_asf.cpp mplayerxp/libmpdemux/demux_audio.cpp mplayerxp/libmpdemux/demux_avi.cpp mplayerxp/libmpdemux/demux_bmp.cpp mplayerxp/libmpdemux/demux_demuxers.cpp mplayerxp/libmpdemux/demux_dv.cpp mplayerxp/libmpdemux/demux_film.cpp mplayerxp/libmpdemux/demux_fli.cpp mplayerxp/libmpdemux/demux_lavf.cpp mplayerxp/libmpdemux/demux_mkv.cpp mplayerxp/libmpdemux/demux_mov.cpp mplayerxp/libmpdemux/demux_mpg.cpp mplayerxp/libmpdemux/demux_mpxp64.cpp mplayerxp/libmpdemux/demux_nsv.cpp mplayerxp/libmpdemux/demux_null.cpp mplayerxp/libmpdemux/demux_nuv.cpp mplayerxp/libmpdemux/demux_ogg.cpp mplayerxp/libmpdemux/demux_pva.cpp mplayerxp/libmpdemux/demux_ra.cpp mplayerxp/libmpdemux/demux_rawaudio.cpp mplayerxp/libmpdemux/demux_rawvideo.cpp mplayerxp/libmpdemux/demux_real.cpp mplayerxp/libmpdemux/demux_roq.cpp mplayerxp/libmpdemux/demux_smjpeg.cpp mplayerxp/libmpdemux/demux_ts.cpp mplayerxp/libmpdemux/demux_ty.cpp mplayerxp/libmpdemux/demux_viv.cpp mplayerxp/libmpdemux/demux_vqf.cpp mplayerxp/libmpdemux/demux_y4m.cpp mplayerxp/libmpdemux/demuxer.cpp mplayerxp/libmpdemux/demuxer_r.cpp mplayerxp/libmpdemux/mp3_hdr.cpp mplayerxp/libmpdemux/mpdemux.cpp mplayerxp/libmpdemux/mpeg_hdr.cpp mplayerxp/libmpdemux/mux_lavf.cpp mplayerxp/libmpdemux/mux_mpxp64.cpp mplayerxp/libmpdemux/mux_raw.cpp mplayerxp/libmpdemux/muxer.cpp mplayerxp/libmpdemux/parse_es.cpp mplayerxp/libmpdemux/parse_mp4.cpp mplayerxp/libmpdemux/sub_cc.cpp mplayerxp/libmpdemux/sub_ty.cpp mplayerxp/libmpdemux/video.cpp mplayerxp/libmpdemux/yuv4mpeg.cpp mplayerxp/libmpdemux/yuv4mpeg_ratio.cpp mplayerxp/libmpstream/asf_mmst_streaming.cpp mplayerxp/libmpstream/asf_streaming.cpp mplayerxp/libmpstream/cache2.cpp mplayerxp/libmpstream/cdda.cpp mplayerxp/libmpstream/cddb.cpp mplayerxp/libmpstream/cookies.cpp mplayerxp/libmpstream/freesdp/common.cpp mplayerxp/libmpstream/freesdp/errorlist.cpp mplayerxp/libmpstream/freesdp/parser.cpp mplayerxp/libmpstream/http.cpp mplayerxp/libmpstream/librtsp/rtsp.cpp mplayerxp/libmpstream/librtsp/rtsp_rtp.cpp mplayerxp/libmpstream/librtsp/rtsp_session.cpp mplayerxp/libmpstream/mrl.cpp mplayerxp/libmpstream/network.cpp mplayerxp/libmpstream/pnm.cpp mplayerxp/libmpstream/realrtsp/asmrp.cpp mplayerxp/libmpstream/realrtsp/md5.cpp mplayerxp/libmpstream/realrtsp/real.cpp mplayerxp/libmpstream/realrtsp/rmff.cpp mplayerxp/libmpstream/realrtsp/sdpplin.cpp mplayerxp/libmpstream/realrtsp/xbuffer.cpp mplayerxp/libmpstream/rtp.cpp mplayerxp/libmpstream/s_cdd.cpp mplayerxp/libmpstream/s_dvdnav.cpp mplayerxp/libmpstream/s_dvdread.cpp mplayerxp/libmpstream/s_file.cpp mplayerxp/libmpstream/s_ftp.cpp mplayerxp/libmpstream/s_lavc.cpp mplayerxp/libmpstream/s_network.cpp mplayerxp/libmpstream/s_null.cpp mplayerxp/libmpstream/s_oss.cpp mplayerxp/libmpstream/s_rtsp.cpp mplayerxp/libmpstream/s_tv.cpp mplayerxp/libmpstream/s_udp.cpp mplayerxp/libmpstream/s_vcdnav.cpp mplayerxp/libmpstream/stream.cpp mplayerxp/libmpstream/tcp.cpp mplayerxp/libmpstream/tvi/frequencies.cpp mplayerxp/libmpstream/tvi/tvi_bsdbt848.cpp mplayerxp/libmpstream/tvi/tvi_dummy.cpp mplayerxp/libmpstream/tvi/tvi_v4l.cpp mplayerxp/libmpstream/udp.cpp mplayerxp/libmpstream/url.cpp mplayerxp/libmpsub/find_sub.cpp mplayerxp/libmpsub/spudec.cpp mplayerxp/libmpsub/subreader.cpp mplayerxp/libmpsub/vobsub.cpp mplayerxp/libplaytree/asxparser.cpp mplayerxp/libplaytree/playtree.cpp mplayerxp/libplaytree/playtreeparser.cpp mplayerxp/libvo/aspect.cpp mplayerxp/libvo/font_load.cpp mplayerxp/libvo/img_format.cpp mplayerxp/libvo/jpeg_enc.cpp mplayerxp/libvo/osd.cpp mplayerxp/libvo/screenshot.cpp mplayerxp/libvo/sub.cpp mplayerxp/libvo/video_out.cpp mplayerxp/libvo/vo_dga.cpp mplayerxp/libvo/vo_fbdev.cpp mplayerxp/libvo/vo_null.cpp mplayerxp/libvo/vo_opengl.cpp mplayerxp/libvo/vo_sdl.cpp mplayerxp/libvo/vo_vesa.cpp mplayerxp/libvo/vo_x11.cpp mplayerxp/libvo/vo_xv.cpp mplayerxp/libvo/vosub_vidix.cpp mplayerxp/libvo/x11_common.cpp mplayerxp/mp-opt-reg.cpp mplayerxp/mp_msg.cpp mplayerxp/mplayerxp.cpp mplayerxp/mplayerxp.h mplayerxp/nls/recode.cpp mplayerxp/osdep/aclib.cpp mplayerxp/osdep/bswap.h mplayerxp/osdep/cpudetect.cpp mplayerxp/osdep/cpudetect.h mplayerxp/osdep/get_path.cpp mplayerxp/osdep/get_path.h mplayerxp/osdep/getch2.cpp mplayerxp/osdep/getch2.h mplayerxp/osdep/keycodes.h mplayerxp/osdep/lrmi.cpp mplayerxp/osdep/lrmi.h mplayerxp/osdep/mm_accel.h mplayerxp/osdep/mp_malloc.cpp mplayerxp/osdep/mplib.cpp mplayerxp/osdep/shmem.cpp mplayerxp/osdep/shmem.h mplayerxp/osdep/timer-lx.cpp mplayerxp/osdep/timer.cpp mplayerxp/osdep/timer.h mplayerxp/osdep/vbelib.cpp mplayerxp/osdep/vbelib.h mplayerxp/postproc/af.cpp mplayerxp/postproc/af_ao2.cpp mplayerxp/postproc/af_channels.cpp mplayerxp/postproc/af_crystality.cpp mplayerxp/postproc/af_delay.cpp mplayerxp/postproc/af_dyn.cpp mplayerxp/postproc/af_echo3d.cpp mplayerxp/postproc/af_equalizer.cpp mplayerxp/postproc/af_export.cpp mplayerxp/postproc/af_extrastereo.cpp mplayerxp/postproc/af_ffenc.cpp mplayerxp/postproc/af_format.cpp mplayerxp/postproc/af_hrtf.cpp mplayerxp/postproc/af_karaoke.cpp mplayerxp/postproc/af_lp.cpp mplayerxp/postproc/af_null.cpp mplayerxp/postproc/af_pan.cpp mplayerxp/postproc/af_raw.cpp mplayerxp/postproc/af_resample.cpp mplayerxp/postproc/af_scaletempo.cpp mplayerxp/postproc/af_sinesuppress.cpp mplayerxp/postproc/af_sub.cpp mplayerxp/postproc/af_surround.cpp mplayerxp/postproc/af_tools.cpp mplayerxp/postproc/af_volnorm.cpp mplayerxp/postproc/af_volume.cpp mplayerxp/postproc/aflib.cpp mplayerxp/postproc/libmenu/menu.cpp mplayerxp/postproc/libmenu/menu_cmdlist.cpp mplayerxp/postproc/libmenu/menu_console.cpp mplayerxp/postproc/libmenu/menu_filesel.cpp mplayerxp/postproc/libmenu/menu_list.cpp mplayerxp/postproc/libmenu/menu_param.cpp mplayerxp/postproc/libmenu/menu_pt.cpp mplayerxp/postproc/libmenu/menu_txt.cpp mplayerxp/postproc/postprocess.cpp mplayerxp/postproc/swscale.cpp mplayerxp/postproc/vf.cpp mplayerxp/postproc/vf_1bpp.cpp mplayerxp/postproc/vf_2xsai.cpp mplayerxp/postproc/vf_aspect.cpp mplayerxp/postproc/vf_delogo.cpp mplayerxp/postproc/vf_denoise3d.cpp mplayerxp/postproc/vf_dint.cpp mplayerxp/postproc/vf_down3dright.cpp mplayerxp/postproc/vf_eq.cpp mplayerxp/postproc/vf_expand.cpp mplayerxp/postproc/vf_flip.cpp mplayerxp/postproc/vf_format.cpp mplayerxp/postproc/vf_framestep.cpp mplayerxp/postproc/vf_il.cpp mplayerxp/postproc/vf_menu.cpp mplayerxp/postproc/vf_mirror.cpp mplayerxp/postproc/vf_noise.cpp mplayerxp/postproc/vf_null.cpp mplayerxp/postproc/vf_ow.cpp mplayerxp/postproc/vf_palette.cpp mplayerxp/postproc/vf_panscan.cpp mplayerxp/postproc/vf_perspective.cpp mplayerxp/postproc/vf_pp.cpp mplayerxp/postproc/vf_raw.cpp mplayerxp/postproc/vf_rectangle.cpp mplayerxp/postproc/vf_rgb2bgr.cpp mplayerxp/postproc/vf_rotate.cpp mplayerxp/postproc/vf_scale.cpp mplayerxp/postproc/vf_smartblur.cpp mplayerxp/postproc/vf_softpulldown.cpp mplayerxp/postproc/vf_swapuv.cpp mplayerxp/postproc/vf_test.cpp mplayerxp/postproc/vf_unsharp.cpp mplayerxp/postproc/vf_vo.cpp mplayerxp/postproc/vf_yuvcsp.cpp mplayerxp/postproc/vf_yuy2.cpp mplayerxp/postproc/vf_yvu9.cpp mplayerxp/xmpcore/PointerProtector.h mplayerxp/xmpcore/mp_aframe.cpp mplayerxp/xmpcore/mp_aframe.h mplayerxp/xmpcore/mp_image.cpp mplayerxp/xmpcore/mp_image.h mplayerxp/xmpcore/sig_hand.cpp mplayerxp/xmpcore/sig_hand.h mplayerxp/xmpcore/xmp_adecoder.cpp mplayerxp/xmpcore/xmp_adecoder.h mplayerxp/xmpcore/xmp_aplayer.cpp mplayerxp/xmpcore/xmp_aplayer.h mplayerxp/xmpcore/xmp_core.cpp mplayerxp/xmpcore/xmp_core.h mplayerxp/xmpcore/xmp_enums.h mplayerxp/xmpcore/xmp_vdecoder.cpp mplayerxp/xmpcore/xmp_vdecoder.h mplayerxp/xmpcore/xmp_vplayer.cpp mplayerxp/xmpcore/xmp_vplayer.h Modified: mplayerxp/dump.cpp =================================================================== --- mplayerxp/dump.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/dump.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* dump.c - stream dumper */ @@ -7,20 +10,17 @@ #define __USE_ISOC99 1 /* for lrint */ #include <math.h> -#include "mp_config.h" - #include "xmpcore/sig_hand.h" #include "help_mp.h" #include "input2/input.h" #include "mplayerxp.h" #include "libmpdemux/muxer.h" #include "libmpstream/mrl.h" -#include "osdep/mplib.h" #define MSGT_CLASS MSGT_GLOBAL #include "mp_msg.h" #include "dump.h" -using namespace mpxp; +namespace mpxp { static char *media=NULL,*port=NULL; @@ -462,3 +462,5 @@ ,priv->m_audio?priv->m_audio->wf->nChannels:-1 ,priv->asize); } + +} // namespace mpxp Modified: mplayerxp/dump.h =================================================================== --- mplayerxp/dump.h 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/dump.h 2012-11-23 16:09:06 UTC (rev 443) @@ -4,12 +4,12 @@ #ifndef DUMP_H_INCLUDED #define DUMP_H_INCLUDED 1 #include "libmpdemux/demuxer_r.h" - -extern int dump_parse(const char *param); -extern void dump_stream(stream_t *stream); -extern void dump_mux_init(demuxer_t *demuxer,any_t*libinput); -extern void dump_mux(demuxer_t *demuxer,int use_pts,const char *seek_to_sec,unsigned play_n_frames); -extern void dump_mux_close(demuxer_t *demuxer); -extern void __FASTCALL__ dump_stream_event_handler(struct stream_s *s,const stream_packet_t*sp); - +namespace mpxp { + int dump_parse(const char *param); + void dump_stream(stream_t *stream); + void dump_mux_init(demuxer_t *demuxer,any_t*libinput); + void dump_mux(demuxer_t *demuxer,int use_pts,const char *seek_to_sec,unsigned play_n_frames); + void dump_mux_close(demuxer_t *demuxer); + void __FASTCALL__ dump_stream_event_handler(struct stream_s *s,const stream_packet_t*sp); +} //namespace #endif Modified: mplayerxp/input2/input.cpp =================================================================== --- mplayerxp/input2/input.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/input2/input.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdlib.h> #include <string.h> #include <stdio.h> @@ -18,7 +21,6 @@ #include "osdep/keycodes.h" #include "osdep/get_path.h" #include "osdep/timer.h" -#include "osdep/mplib.h" #include "libmpconf/cfgparser.h" #include "in_msg.h" @@ -33,8 +35,6 @@ #include "joystick.h" #include "osdep/getch2.h" -using namespace mpxp; - #ifndef MP_MAX_KEY_FD #define MP_MAX_KEY_FD 10 #endif Modified: mplayerxp/input2/joystick.cpp =================================================================== --- mplayerxp/input2/joystick.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/input2/joystick.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,9 +1,10 @@ #include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #ifdef HAVE_JOYSTICK #include "joystick.h" #include "input.h" -#include "osdep/mplib.h" #include <stdlib.h> #include <stdio.h> @@ -14,8 +15,6 @@ #include <fcntl.h> #include <errno.h> -using namespace mpxp; - #ifndef JOY_AXIS_DELTA #define JOY_AXIS_DELTA 500 #endif Modified: mplayerxp/input2/lirc.cpp =================================================================== --- mplayerxp/input2/lirc.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/input2/lirc.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,4 +1,6 @@ #include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #ifdef HAVE_LIRC @@ -15,8 +17,6 @@ #include "input.h" #include "in_msg.h" -using namespace mpxp; - static struct lirc_config *lirc_config; char *lirc_configfile; Modified: mplayerxp/libao2/afmt.cpp =================================================================== --- mplayerxp/libao2/afmt.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libao2/afmt.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,7 +1,7 @@ -#include "afmt.h" +#include "mp_config.h" #include "osdep/mplib.h" - using namespace mpxp; +#include "afmt.h" const char* afmt2str(unsigned fmt) { const char* rs = "AFMT_Unknown"; Modified: mplayerxp/libao2/ao_alsa9.cpp =================================================================== --- mplayerxp/libao2/ao_alsa9.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libao2/ao_alsa9.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* ao_alsa9 - ALSA-0.9.x output plugin for MPlayer @@ -17,7 +20,6 @@ #include <string.h> #include <sys/poll.h> -#include "mp_config.h" #include "mplayerxp.h" #define ALSA_PCM_NEW_HW_PARAMS_API #define ALSA_PCM_NEW_SW_PARAMS_API @@ -28,10 +30,7 @@ #include "afmt.h" #include "ao_msg.h" #include "libmpstream/mrl.h" -#include "osdep/mplib.h" -using namespace mpxp; - static ao_info_t info = { "ALSA-1.x audio output", Modified: mplayerxp/libao2/ao_arts.cpp =================================================================== --- mplayerxp/libao2/ao_arts.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libao2/ao_arts.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * aRts (KDE analogue Real-Time synthesizer) audio output driver for MPlayerXP * @@ -23,15 +26,12 @@ #include <artsc.h> #include <stdio.h> -#include "mp_config.h" #include "audio_out.h" #include "audio_out_internal.h" #include "postproc/af.h" #include "afmt.h" #include "ao_msg.h" -using namespace mpxp; - /* Feel mp_free to experiment with the following values: */ #define ARTS_PACKETS 10 /* Number of audio packets */ #define ARTS_PACKET_SIZE_LOG2 11 /* Log2 of audio packet size */ Modified: mplayerxp/libao2/ao_esd.cpp =================================================================== --- mplayerxp/libao2/ao_esd.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libao2/ao_esd.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * EsounD (Enlightened Sound Daemon) audio output driver for MPlayerXP * @@ -47,16 +50,12 @@ #endif #include <esd.h> -#include "mp_config.h" #include "audio_out.h" #include "audio_out_internal.h" #include "postproc/af.h" #include "afmt.h" #include "ao_msg.h" -#include "osdep/mplib.h" -using namespace mpxp; - #define ESD_RESAMPLES 0 #define ESD_DEBUG 0 Modified: mplayerxp/libao2/ao_jack.cpp =================================================================== --- mplayerxp/libao2/ao_jack.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libao2/ao_jack.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * JACK audio output driver for MPlayer * @@ -26,21 +29,16 @@ #include <string.h> #include <unistd.h> -#include "mp_config.h" - #include "audio_out.h" #include "audio_out_internal.h" #include "postproc/af.h" #include "afmt.h" #include "osdep/timer.h" -#include "osdep/mplib.h" #include "ao_msg.h" #include "mp_conf_lavc.h" #include <jack/jack.h> -using namespace mpxp; - static const ao_info_t info = { "JACK audio output", Modified: mplayerxp/libao2/ao_nas.cpp =================================================================== --- mplayerxp/libao2/ao_nas.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libao2/ao_nas.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * NAS audio output driver * @@ -53,17 +56,12 @@ #include <limits.h> #include <audio/audiolib.h> -#include "mp_config.h" - #include "audio_out.h" #include "audio_out_internal.h" #include "postproc/af.h" -#include "osdep/mplib.h" #include "afmt.h" #include "ao_msg.h" -using namespace mpxp; - /* NAS_FRAG_SIZE must be a power-of-two value */ #define NAS_FRAG_SIZE 4096 Modified: mplayerxp/libao2/ao_null.cpp =================================================================== --- mplayerxp/libao2/ao_null.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libao2/ao_null.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdint.h> #include <stdio.h> #include <stdlib.h> @@ -5,9 +8,7 @@ #include <limits.h> #include <sys/time.h> -#include "mp_config.h" #include "osdep/bswap.h" -#include "osdep/mplib.h" #include "libmpstream/mrl.h" #include "afmt.h" @@ -15,8 +16,6 @@ #include "audio_out_internal.h" #include "ao_msg.h" -using namespace mpxp; - static ao_info_t info = { "Null audio output", "null", Modified: mplayerxp/libao2/ao_openal.cpp =================================================================== --- mplayerxp/libao2/ao_openal.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libao2/ao_openal.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * OpenAL audio output driver for MPlayerXP * @@ -19,9 +22,6 @@ * along with MPlayer; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "mp_config.h" - #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -34,11 +34,8 @@ #include "postproc/af.h" #include "afmt.h" #include "osdep/timer.h" -#include "osdep/mplib.h" #include "ao_msg.h" -using namespace mpxp; - static const ao_info_t info = { "OpenAL audio output", Modified: mplayerxp/libao2/ao_oss.cpp =================================================================== --- mplayerxp/libao2/ao_oss.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libao2/ao_oss.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> @@ -10,17 +13,13 @@ #include <errno.h> #include <string.h> -#include "mp_config.h" #include "mixer.h" -#include "osdep/mplib.h" #include "afmt.h" #include "audio_out.h" #include "audio_out_internal.h" #include "ao_msg.h" -using namespace mpxp; - static ao_info_t info = { "OSS/ioctl audio output", Modified: mplayerxp/libao2/ao_sdl.cpp =================================================================== --- mplayerxp/libao2/ao_sdl.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libao2/ao_sdl.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * ao_sdl.c - libao2 SDLlib Audio Output Driver for MPlayer * @@ -13,17 +16,14 @@ #include <stdio.h> #include <stdlib.h> +#include <SDL/SDL.h> #include "audio_out.h" #include "audio_out_internal.h" #include "afmt.h" -#include <SDL/SDL.h> #include "osdep/fastmemcpy.h" -#include "osdep/mplib.h" #include "ao_msg.h" -using namespace mpxp; - static ao_info_t info = { "SDLlib audio output", "sdl", Modified: mplayerxp/libao2/ao_wav.cpp =================================================================== --- mplayerxp/libao2/ao_wav.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libao2/ao_wav.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * PCM audio output driver * @@ -17,9 +20,6 @@ * with MPlayer; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - -#include "mp_config.h" - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -31,7 +31,6 @@ #include "audio_out.h" #include "audio_out_internal.h" #include "libvo/video_out.h" -#include "osdep/mplib.h" #include "help_mp.h" #include "ao_msg.h" @@ -40,8 +39,6 @@ #include <windows.h> #endif -using namespace mpxp; - static const ao_info_t info = { "RAW WAVE file writer audio output", Modified: mplayerxp/libao2/audio_out.cpp =================================================================== --- mplayerxp/libao2/audio_out.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libao2/audio_out.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -2,10 +5,6 @@ -#include "mp_config.h" -#include "osdep/mplib.h" #include "audio_out.h" #include "afmt.h" #include "ao_msg.h" -using namespace mpxp; - extern const ao_functions_t audio_out_wav; Modified: mplayerxp/libao2/mixer.cpp =================================================================== --- mplayerxp/libao2/mixer.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libao2/mixer.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <string.h> #include <sys/ioctl.h> #include <fcntl.h> @@ -4,13 +7,9 @@ #include <stdio.h> #include <unistd.h> -#include "mp_config.h" #include "mixer.h" #include "libao2/audio_out.h" -#include "osdep/mplib.h" -using namespace mpxp; - void mixer_getvolume(const ao_data_t* ao, float *l,float *r ) { ao_control_vol_t vol; Modified: mplayerxp/libmpcodecs/ad.cpp =================================================================== --- mplayerxp/libmpcodecs/ad.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* ad.c - audio decoder interface */ @@ -6,17 +9,12 @@ #include <stdlib.h> #include <string.h> -#include "mp_config.h" - #include "libmpstream/stream.h" #include "libmpdemux/demuxer.h" #include "libmpdemux/stheader.h" #include "ad.h" #include "ad_msg.h" -#include "osdep/mplib.h" -using namespace mpxp; - /* Missed vorbis, mad, dshow */ extern const ad_functions_t mpcodecs_ad_null; Modified: mplayerxp/libmpcodecs/ad_a52.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_a52.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_a52.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #define __USE_XOPEN 1 @@ -7,12 +10,10 @@ #include "ad_internal.h" #include "codecs_ld.h" -#include "mp_config.h" #include "mplayerxp.h" #include "help_mp.h" #include "osdep/cpudetect.h" #include "osdep/bswap.h" -#include "osdep/mplib.h" #include "osdep/mm_accel.h" #include "mplayerxp.h" @@ -21,8 +22,6 @@ #include "libao2/audio_out.h" #include "postproc/af.h" -using namespace mpxp; - typedef struct priv_s { float last_pts; }priv_t; Modified: mplayerxp/libmpcodecs/ad_acm.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_acm.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_acm.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,4 +1,6 @@ #include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -8,12 +10,9 @@ #include "codecs_ld.h" #include "loader/wineacm.h" #include "libmpdemux/aviprint.h" -#include "osdep/mplib.h" #include "libao2/afmt.h" #include "help_mp.h" -using namespace mpxp; - static const ad_info_t info = { "Win32/ACM decoders", "acm", Modified: mplayerxp/libmpcodecs/ad_dca.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dca.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_dca.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #define __USE_XOPEN 1 @@ -7,7 +10,6 @@ #include "ad_internal.h" #include "codecs_ld.h" -#include "mp_config.h" #include "mplayerxp.h" #include "help_mp.h" #include "osdep/cpudetect.h" @@ -19,10 +21,7 @@ #include "libao2/afmt.h" #include "libao2/audio_out.h" #include "postproc/af.h" -#include "osdep/mplib.h" -using namespace mpxp; - #define MAX_AC5_FRAME 4096 dca_state_t* mpxp_dca_state; Modified: mplayerxp/libmpcodecs/ad_dmo.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dmo.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_dmo.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -5,15 +8,11 @@ #include "codecs_ld.h" -#include "mp_config.h" #include "mplayerxp.h" #include "help_mp.h" -#include "osdep/mplib.h" #include "ad_internal.h" #include "ad_msg.h" -using namespace mpxp; - static const ad_info_t info = { "Win32/DMO decoders", "dmo", Modified: mplayerxp/libmpcodecs/ad_dshow.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dshow.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_dshow.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -3,12 +6,8 @@ #include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ #include "ad_internal.h" -#include "mp_config.h" #include "help_mp.h" -#include "osdep/mplib.h" #include "loader/dshow/DS_AudioDecoder.h" #include "codecs_ld.h" -using namespace mpxp; - static const ad_info_t info = { "Win32/DirectShow decoders", Modified: mplayerxp/libmpcodecs/ad_dvdpcm.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dvdpcm.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_dvdpcm.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -3,9 +6,6 @@ #include "ad_internal.h" #include "osdep/bswap.h" -#include "osdep/mplib.h" #include "libao2/afmt.h" -using namespace mpxp; - static const ad_info_t info = { "Uncompressed DVD/VOB LPCM audio decoder", Modified: mplayerxp/libmpcodecs/ad_faad.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_faad.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_faad.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* ad_faad.c - MPlayer AAC decoder using libfaad2 * This file is part of MPlayer, see http://mplayerhq.hu/ for info. * (c)2002 by Felix Buenemann <atmosfear at users.sourceforge.net> @@ -3,6 +6,4 @@ * File licensed under the GPL, see http://www.fsf.org/ for more info. */ -#include "mp_config.h" - #include <stdio.h> #include <stdlib.h> @@ -13,18 +14,14 @@ #include "help_mp.h" #include "osdep/bswap.h" #include "codecs_ld.h" -#include "mp_config.h" #include "ad_internal.h" #include "mplayerxp.h" #include "osdep/cpudetect.h" #include "osdep/mm_accel.h" -#include "osdep/mplib.h" #include "libao2/afmt.h" #include "libao2/audio_out.h" #include "postproc/af.h" -using namespace mpxp; - static const ad_info_t info = { "AAC (MPEG2/4 Advanced Audio Coding)", "faad", Modified: mplayerxp/libmpcodecs/ad_hwac3.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_hwac3.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_hwac3.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #define __USE_XOPEN 1 @@ -7,17 +10,12 @@ #include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ #include "ad_internal.h" -#include "mp_config.h" #include "help_mp.h" #include "codecs_ld.h" #include "osdep/cpudetect.h" #include "osdep/bswap.h" -#include "osdep/mplib.h" - #include "libao2/afmt.h" -using namespace mpxp; - #define IEC61937_DATA_TYPE_AC3 1 typedef struct priv_s { Modified: mplayerxp/libmpcodecs/ad_lavc.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_lavc.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_lavc.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #define __USE_GNU 1 @@ -8,17 +11,13 @@ #include "libao2/afmt.h" #include "ad_internal.h" -#include "mp_config.h" #include "help_mp.h" #include "osdep/bswap.h" -#include "osdep/mplib.h" #include "libmpconf/codec-cfg.h" #include "mp_conf_lavc.h"" #include "codecs_ld.h" -using namespace mpxp; - typedef struct priv_s { AVCodecContext *lavc_ctx; audio_probe_t* probe; Modified: mplayerxp/libmpcodecs/ad_libdv.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_libdv.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_libdv.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -5,9 +8,7 @@ #include <unistd.h> #include <math.h> -#include "mp_config.h" #include "help_mp.h" -#include "osdep/mplib.h" #include <libdv/dv.h> #include <libdv/dv_types.h> @@ -17,12 +18,8 @@ #include "libmpdemux/stheader.h" #include "libao2/afmt.h" #include "osdep/bswap.h" -#include "osdep/mplib.h" - #include "ad_internal.h" -using namespace mpxp; - static const ad_info_t info = { "Raw DV Audio Decoder", "libdv", Modified: mplayerxp/libmpcodecs/ad_mp3.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_mp3.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_mp3.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -3,10 +6,8 @@ #include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ #include "ad_internal.h" -#include "mp_config.h" #include "mplayerxp.h" #include "osdep/cpudetect.h" #include "osdep/mm_accel.h" #include "osdep/fastmemcpy.h" -#include "osdep/mplib.h" #include "osdep/bswap.h" #include "codecs_ld.h" @@ -15,8 +16,6 @@ #include "libao2/audio_out.h" #include "postproc/af.h" -using namespace mpxp; - static const ad_info_t info = { "MPEG layer-123", "mp3lib", Modified: mplayerxp/libmpcodecs/ad_null.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_null.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_null.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -2,6 +5,3 @@ #include "ad_internal.h" -#include "osdep/mplib.h" -using namespace mpxp; - static const ad_info_t info = { Modified: mplayerxp/libmpcodecs/ad_pcm.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_pcm.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_pcm.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -4,10 +7,7 @@ #include "ad_internal.h" #include "libao2/afmt.h" #include "osdep/bswap.h" -#include "osdep/mplib.h" -using namespace mpxp; - static const ad_info_t info = { "Uncompressed PCM audio decoder", "pcm", Modified: mplayerxp/libmpcodecs/ad_qtaudio.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_qtaudio.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_qtaudio.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -3,5 +6,4 @@ #include <inttypes.h> #include <dlfcn.h> -#include "mp_config.h" #include "ad_internal.h" @@ -10,7 +12,6 @@ #include "codecs_ld.h" #include "mplayerxp.h" #include "libao2/afmt.h" -#include "osdep/mplib.h" #ifdef WIN32_LOADER #include "loader/ldt_keeper.h" #endif @@ -19,8 +20,6 @@ #include <QuickTime/QuickTimeComponents.h> #endif -using namespace mpxp; - static const ad_info_t info = { "QuickTime Audio Decoder", "qtaudio", Modified: mplayerxp/libmpcodecs/ad_real.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_real.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_real.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> @@ -3,6 +6,4 @@ #include <unistd.h> -#include "mp_config.h" - #include <stddef.h> #include <dlfcn.h> @@ -11,12 +12,9 @@ #include "ad_internal.h" #include "codecs_ld.h" #include "ad_msg.h" -#include "osdep/mplib.h" #include "osdep/bswap.h" #include "libao2/afmt.h" -using namespace mpxp; - static const ad_info_t info = { "RealAudio decoder", "realaudio", Modified: mplayerxp/libmpcodecs/ad_twin.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_twin.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_twin.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,4 +1,6 @@ #include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -9,12 +11,8 @@ #include "loader/wine/windef.h" #include "libao2/afmt.h" #include "libmpdemux/aviprint.h" -#include "osdep/mplib.h" - #include "help_mp.h" -using namespace mpxp; - static const ad_info_t info = { "TWinVQ decoder", "vqf", Modified: mplayerxp/libmpcodecs/ad_vorbis.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_vorbis.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/ad_vorbis.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -2,14 +5,8 @@ #include <dlfcn.h> -#include "mp_config.h" #include "codecs_ld.h" #include "ad_internal.h" #include "libao2/afmt.h" #include "libao2/audio_out.h" -#include "osdep/mplib.h" #include "osdep/bswap.h" -using namespace mpxp; - -extern ao_data_t* ao_data; - static const ad_info_t info = { Modified: mplayerxp/libmpcodecs/codecs_ld.cpp =================================================================== --- mplayerxp/libmpcodecs/codecs_ld.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/codecs_ld.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* codecs_ld - light interface to codec loader */ @@ -7,14 +10,10 @@ #include <string.h> #include <stdarg.h> #include "codecs_ld.h" -#include "mp_config.h" #include "help_mp.h" -#include "osdep/mplib.h" #define MSGT_CLASS MSGT_GLOBAL #include "mp_msg.h" -using namespace mpxp; - any_t* ld_codec(const char *name,const char *url_hint) { any_t*dll_handle; Modified: mplayerxp/libmpcodecs/dec_audio.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_audio.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/dec_audio.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <algorithm> #include <stdio.h> @@ -4,7 +7,6 @@ #include <stdlib.h> #include <unistd.h> -#include "mp_config.h" #include "help_mp.h" #include "mplayerxp.h" @@ -22,11 +24,8 @@ #include "libmpdemux/demuxer_r.h" #include "postproc/af.h" #include "osdep/fastmemcpy.h" -#include "osdep/mplib.h" #include "ad_msg.h" -using namespace mpxp; - /* used for ac3surround decoder - set using -channels option */ af_cfg_t af_cfg; // Configuration for audio filters Modified: mplayerxp/libmpcodecs/dec_video.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_video.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/dec_video.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,4 +1,6 @@ #include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #ifdef _OPENMP #include <omp.h> @@ -13,7 +15,6 @@ #include "osdep/timer.h" #include "osdep/shmem.h" -#include "osdep/mplib.h" #include "libmpstream/stream.h" #include "libmpdemux/demuxer.h" @@ -36,8 +37,6 @@ #include "osdep/cpudetect.h" #include "vd_msg.h" -using namespace mpxp; - // =================================================================== vf_cfg_t vf_cfg; // Configuration for audio filters @@ -95,7 +94,6 @@ } #include "libvo/video_out.h" -extern vo_data_t*vo_data; #define MPDEC_THREAD_COND (VF_FLAGS_THREADS|VF_FLAGS_SLICES) static unsigned smp_num_cpus=1; static unsigned use_vf_threads=0; @@ -280,7 +278,6 @@ } } -extern vo_data_t* vo_data; static void update_subtitle(sh_video_t *sh_video,float v_pts,unsigned idx); int mpcv_decode(any_t *opaque,const enc_frame_t* frame){ priv_t* priv=(priv_t*)opaque; @@ -404,9 +401,6 @@ #include "libvo/video_out.h" -extern vo_data_t* vo_data; -extern const vd_functions_t* mpvdec; // FIXME! - MPXP_Rc mpcodecs_config_vo(sh_video_t *sh, int w, int h, any_t* libinput){ priv_t* priv=(priv_t*)sh->decoder; int i,j; @@ -443,7 +437,7 @@ // check (query) if codec really support this outfmt... sh->outfmtidx=j; // pass index to the control() function this way if(priv->mpvdec->control(sh,VDCTRL_QUERY_FORMAT,&out_fmt)==MPXP_False) { - MSG_DBG2("vo_debug: codec[%s] query_format(%s) returned FALSE\n",mpvdec->info->driver_name,vo_format_name(out_fmt)); + MSG_DBG2("vo_debug: codec[%s] query_format(%s) returned FALSE\n",priv->mpvdec->info->driver_name,vo_format_name(out_fmt)); continue; } j=i; Modified: mplayerxp/libmpcodecs/liba52/bit_allocate.cpp =================================================================== --- mplayerxp/libmpcodecs/liba52/bit_allocate.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/liba52/bit_allocate.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * bit_allocate.c * Copyright (C) 2000-2002 Michel Lespinasse <wa...@zo...> @@ -20,17 +23,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include "mp_config.h" - #include <inttypes.h> #include "a52.h" #include "a52_internal.h" -#include "osdep/mplib.h" -using namespace mpxp; - static int hthtab[3][50] = { {0x730, 0x730, 0x7c0, 0x800, 0x820, 0x840, 0x850, 0x850, 0x860, 0x860, 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x890, 0x890, Modified: mplayerxp/libmpcodecs/liba52/bitstream.cpp =================================================================== --- mplayerxp/libmpcodecs/liba52/bitstream.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/liba52/bitstream.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * bitstream.c * Copyright (C) 2000-2002 Michel Lespinasse <wa...@zo...> @@ -20,18 +23,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include "mp_config.h" - #include <inttypes.h> #include "a52.h" #include "a52_internal.h" #include "bitstream.h" -#include "osdep/mplib.h" -using namespace mpxp; - #define BUFFER_SIZE 4096 void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf) Modified: mplayerxp/libmpcodecs/liba52/crc.cpp =================================================================== --- mplayerxp/libmpcodecs/liba52/crc.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/liba52/crc.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * crc.c * @@ -25,11 +28,6 @@ #include <stdio.h> #include <inttypes.h> -#include "mp_config.h" -#include "osdep/mplib.h" - -using namespace mpxp; - static const uint16_t crc_lut[256] = { 0x0000,0x8005,0x800f,0x000a,0x801b,0x001e,0x0014,0x8011, Modified: mplayerxp/libmpcodecs/liba52/downmix.cpp =================================================================== --- mplayerxp/libmpcodecs/liba52/downmix.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/liba52/downmix.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * downmix.c * Copyright (C) 2000-2002 Michel Lespinasse <wa...@zo...> @@ -20,9 +23,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include "mp_config.h" - #include <string.h> #include <inttypes.h> @@ -30,10 +30,7 @@ #include "a52_internal.h" #include "osdep/mm_accel.h" #include "osdep/cpudetect.h" -#include "osdep/mplib.h" -using namespace mpxp; - #define CONVERT(acmod,output) (((output) << 3) + (acmod)) extern uint32_t a52_accel; Modified: mplayerxp/libmpcodecs/liba52/imdct.cpp =================================================================== --- mplayerxp/libmpcodecs/liba52/imdct.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/liba52/imdct.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * imdct.c * Copyright (C) 2000-2002 Michel Lespinasse <wa...@zo...> @@ -23,9 +26,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include "mp_config.h" - #include <math.h> #include <stdio.h> #ifndef M_PI @@ -36,10 +36,7 @@ #include "a52.h" #include "a52_internal.h" #include "osdep/mm_accel.h" -#include "osdep/mplib.h" -using namespace mpxp; - typedef struct complex_s { sample_t real; sample_t imag; Modified: mplayerxp/libmpcodecs/liba52/parse.cpp =================================================================== --- mplayerxp/libmpcodecs/liba52/parse.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/liba52/parse.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * parse.c * Copyright (C) 2000-2002 Michel Lespinasse <wa...@zo...> @@ -21,22 +24,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mp_config.h" - #include <stdlib.h> #include <stdio.h> #include <string.h> #include <inttypes.h> -#include "osdep/mplib.h" - #include "a52.h" #include "a52_internal.h" #include "bitstream.h" #include "tables.h" -using namespace mpxp; - typedef struct { sample_t q1[2]; sample_t q2[2]; Modified: mplayerxp/libmpcodecs/liba52/resample.cpp =================================================================== --- mplayerxp/libmpcodecs/liba52/resample.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/liba52/resample.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; // a52_resample_init should find the requested converter (from type flags -> // given number of channels) and set up some function pointers... @@ -4,7 +7,6 @@ // a52_resample() should do the conversion. -#include "mp_config.h" #include <inttypes.h> #include <stdio.h> #include "a52.h" @@ -12,10 +14,7 @@ #include "osdep/mm_accel.h" #include "osdep/mangle.h" #include "osdep/cpudetect.h" -#include "osdep/mplib.h" -using namespace mpxp; - int (* a52_resample) (float * _f, int16_t * s16)=NULL; int (* a52_resample32) (float * _f, float * s16)=NULL; Modified: mplayerxp/libmpcodecs/libdca/bitstream.cpp =================================================================== --- mplayerxp/libmpcodecs/libdca/bitstream.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/libdca/bitstream.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * bitstream.c * Copyright (C) 2004 Gildas Bazin <gb...@vi...> @@ -21,18 +24,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include "mp_config.h" - #include <inttypes.h> #include "dca.h" #include "dca_internal.h" #include "bitstream.h" -#include "osdep/mplib.h" -using namespace mpxp; - #define BUFFER_SIZE 4096 void dca_bitstream_init (dca_state_t * state, uint8_t * buf, int word_mode, Modified: mplayerxp/libmpcodecs/libdca/downmix.cpp =================================================================== --- mplayerxp/libmpcodecs/libdca/downmix.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/libdca/downmix.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * downmix.c * Copyright (C) 2004 Gildas Bazin <gb...@vi...> @@ -21,19 +24,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include "mp_config.h" - #include <string.h> #include <inttypes.h> #include "osdep/cpudetect.h" -#include "osdep/mplib.h" #include "dca.h" #include "dca_internal.h" -using namespace mpxp; - #define CONVERT(acmod,output) (((output) << DCA_CHANNEL_BITS) + (acmod)) int dca_downmix_init (int input, int flags, level_t * level, Modified: mplayerxp/libmpcodecs/libdca/parse.cpp =================================================================== --- mplayerxp/libmpcodecs/libdca/parse.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/libdca/parse.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * parse.c * Copyright (C) 2004 Gildas Bazin <gb...@vi...> @@ -19,9 +22,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include "mp_config.h" - #include <stdio.h> #include <stdlib.h> @@ -29,8 +29,6 @@ #include <inttypes.h> #include <math.h> -#include "osdep/mplib.h" - #ifndef M_PI #define M_PI 3.1415926535897932384626433832795029 #endif @@ -46,8 +44,6 @@ #include "tables_fir.h" #include "tables_vq.h" -using namespace mpxp; - //#define LOG_DEBUG 1 static int decode_blockcode (int code, int levels, int *values); Modified: mplayerxp/libmpcodecs/libdca/resample.cpp =================================================================== --- mplayerxp/libmpcodecs/libdca/resample.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/libdca/resample.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; // dca_resample_init should find the requested converter (from type flags -> // given number of channels) and set up some function pointers... @@ -8,14 +11,10 @@ #include <stdio.h> #include "dca.h" #include "dca_internal.h" -#include "mp_config.h" #include "osdep/mm_accel.h" #include "osdep/mangle.h" #include "osdep/cpudetect.h" -#include "osdep/mplib.h" -using namespace mpxp; - int (* dca_resample) (float * _f, int16_t * s16)=NULL; int (* dca_resample32) (float * _f, float * s16)=NULL; Modified: mplayerxp/libmpcodecs/libnuppelvideo/RTjpegN.cpp =================================================================== --- mplayerxp/libmpcodecs/libnuppelvideo/RTjpegN.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/libnuppelvideo/RTjpegN.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* RTjpeg (C) Justin Schoeman 1998 (ju...@su...) @@ -26,11 +29,7 @@ #include <string.h> #include "RTjpegN.h" -#include "mp_config.h" -#include "osdep/mplib.h" -using namespace mpxp; - //#define SHOWBLOCK 1 #define BETTERCOMPRESSION 1 Modified: mplayerxp/libmpcodecs/libnuppelvideo/minilzo.cpp =================================================================== --- mplayerxp/libmpcodecs/libnuppelvideo/minilzo.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/libnuppelvideo/minilzo.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* minilzo.c -- mini subset of the LZO real-time data compression library This file is part of the LZO real-time data compression library. @@ -57,10 +60,7 @@ #include <stdio.h> #include "osdep/cpudetect.h" -#include "osdep/mplib.h" -using namespace mpxp; - #ifndef __LZO_CONF_H #define __LZO_CONF_H Modified: mplayerxp/libmpcodecs/libnuppelvideo/nuppelvideo.cpp =================================================================== --- mplayerxp/libmpcodecs/libnuppelvideo/nuppelvideo.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/libnuppelvideo/nuppelvideo.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * NuppelVideo 0.05 file parser * for MPlayer @@ -11,11 +14,6 @@ #include <string.h> #include <unistd.h> -#include "mp_config.h" -#include "osdep/mplib.h" - -using namespace mpxp; - #include "nuppelvideo.h" #include "RTjpegN.h" #include "minilzo.h" Modified: mplayerxp/libmpcodecs/vd.cpp =================================================================== --- mplayerxp/libmpcodecs/vd.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/vd.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -2,3 +5,2 @@ -#include "mp_config.h" #include "help_mp.h" @@ -13,13 +15,10 @@ #include "libmpstream/stream.h" #include "libmpdemux/demuxer.h" #include "libmpdemux/stheader.h" -#include "osdep/mplib.h" #include "vd.h" #include "postproc/vf.h" #include "vd_msg.h" -using namespace mpxp; - extern const vd_functions_t mpcodecs_vd_null; extern const vd_functions_t mpcodecs_vd_lavc; extern const vd_functions_t mpcodecs_vd_dshow; Modified: mplayerxp/libmpcodecs/vd_divx4.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_divx4.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/vd_divx4.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* HACKING notes: first time it was OpenDivx project by Mayo (unsupported by mplayerxp) @@ -12,7 +15,6 @@ #include <stdarg.h> #include <assert.h> -#include "mp_config.h" #include "help_mp.h" #include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ @@ -21,11 +23,8 @@ #include "vd.h" #include "codecs_ld.h" #include "libvo/video_out.h" -#include "osdep/mplib.h" #include "osdep/bswap.h" -using namespace mpxp; - static const vd_info_t info = { "DivX4Linux lib (divx4/5 mode)", "divx4", Modified: mplayerxp/libmpcodecs/vd_dmo.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_dmo.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/vd_dmo.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #include <stdarg.h> @@ -2,4 +5,2 @@ -#include "mp_config.h" - #include "help_mp.h" @@ -10,13 +11,9 @@ #include "vd_internal.h" #include "codecs_ld.h" -#include "osdep/mplib.h" - #include "loader/dmo/DMO_VideoDecoder.h" #include "vd_msg.h" -using namespace mpxp; - static const vd_info_t info = { "Win32/DMO video codecs", "dmo", Modified: mplayerxp/libmpcodecs/vd_dshow.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_dshow.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/vd_dshow.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #include <stdarg.h> @@ -2,3 +5,2 @@ -#include "mp_config.h" #include "mplayerxp.h" @@ -13,10 +15,7 @@ #include "loader/dshow/DS_VideoDecoder.h" #include "codecs_ld.h" #include "osdep/bswap.h" -#include "osdep/mplib.h" -using namespace mpxp; - static const vd_info_t info = { "Win32/DirectShow video codecs", "dshow", Modified: mplayerxp/libmpcodecs/vd_huffyuv.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_huffyuv.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/vd_huffyuv.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * * HuffYUV Decoder for Mplayer @@ -20,15 +23,10 @@ #include <stdio.h> #include <stdlib.h> -#include "mp_config.h" - #include "vd_internal.h" #include "help_mp.h" -#include "osdep/mplib.h" #include "osdep/bswap.h" -using namespace mpxp; - static const vd_info_t info = { "HuffYUV Video decoder", "huffyuv", Modified: mplayerxp/libmpcodecs/vd_lavc.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_lavc.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/vd_lavc.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <algorithm> #include <ctype.h> @@ -6,7 +9,6 @@ #include <assert.h> #include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ -#include "mp_config.h" #include "mplayerxp.h" #include "xmpcore/xmp_core.h" #ifdef HAVE_GOMP @@ -16,7 +18,6 @@ #include "help_mp.h" #include "osdep/bswap.h" -#include "osdep/mplib.h" #include "vd_internal.h" #include "codecs_ld.h" @@ -25,8 +26,6 @@ #include "libvo/video_out.h" #include "osdep/bswap.h" -using namespace mpxp; - static const vd_info_t info = { "lavc codec family", "lavc", @@ -244,7 +243,6 @@ return MPXP_False; } -extern unsigned xp_num_cpu; static MPXP_Rc init(sh_video_t *sh,any_t* libinput){ unsigned avc_version=0; priv_t *priv = reinterpret_cast<priv_t*>(sh->context); @@ -390,7 +388,7 @@ if(priv->lavc_codec->capabilities&CODEC_CAP_DR1) priv->cap_dr1=1; priv->ctx->flags|= CODEC_FLAG_EMU_EDGE; - if(lavc_param_threads < 0) lavc_param_threads = xp_num_cpu; + if(lavc_param_threads < 0) lavc_param_threads = get_number_cpu(); if(lavc_param_threads > 1) { priv->ctx->thread_count = lavc_param_threads; MSG_STATUS("Using %i threads in lavc\n",lavc_param_threads); Modified: mplayerxp/libmpcodecs/vd_libdv.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_libdv.cpp 2012-11-23 12:04:19 UTC (rev 442) +++ mplayerxp/libmpcodecs/vd_libdv.cpp 2012-11-23 16:09:06 UTC (rev 443) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -5,11 +8,8 @@ #include <unistd.h> #include <math.h> -#include "mp_config.h" - #include "libvo/img_format.h" #include "osdep/bswap.h" -#include "osdep/mplib.h" #include <libdv/dv.h> #include <libdv/dv_types.h> @@ -20,8 +20,6 @@ #include "vd_internal.h" -using namespace mpxp; - static const vd_info_t info = { "Raw DV Video D... [truncated message content] |
From: <nic...@us...> - 2012-11-23 17:08:26
|
Revision: 444 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=444&view=rev Author: nickols_k Date: 2012-11-23 17:08:19 +0000 (Fri, 23 Nov 2012) Log Message: ----------- use more clear name for thread sleeping Modified Paths: -------------- mplayerxp/libao2/ao_nas.cpp mplayerxp/libmpcodecs/dec_video.cpp mplayerxp/libmpstream/cache2.cpp mplayerxp/libmpstream/s_dvdnav.cpp mplayerxp/libvo/vosub_vidix.cpp mplayerxp/mplayerxp.cpp mplayerxp/mplayerxp.h mplayerxp/xmpcore/xmp_adecoder.cpp mplayerxp/xmpcore/xmp_aplayer.cpp mplayerxp/xmpcore/xmp_core.cpp mplayerxp/xmpcore/xmp_vdecoder.cpp mplayerxp/xmpcore/xmp_vplayer.cpp Modified: mplayerxp/libao2/ao_nas.cpp =================================================================== --- mplayerxp/libao2/ao_nas.cpp 2012-11-23 16:09:06 UTC (rev 443) +++ mplayerxp/libao2/ao_nas.cpp 2012-11-23 17:08:19 UTC (rev 444) @@ -246,7 +246,7 @@ "ao_nas: event thread heartbeat (state=%s)\n", nas_state(priv->state)); nas_empty_event_queue(priv); - usleep(1000); + yield_timeslice(); } while (!priv->stop_thread); return NULL; @@ -523,7 +523,7 @@ MSG_DBG3("ao_nas: uninit()\n"); priv->expect_underrun = 1; - while (priv->state != AuStateStop) usleep(1000); + while (priv->state != AuStateStop) yield_timeslice(); priv->stop_thread = 1; pthread_join(priv->event_thread, NULL); AuCloseServer(priv->aud); @@ -547,7 +547,7 @@ AuStopFlow(priv->aud, priv->flow, &as); if (as != AuSuccess) nas_print_error(priv->aud, "reset(): AuStopFlow", as); - usleep(1000); + yield_timeslice(); } } Modified: mplayerxp/libmpcodecs/dec_video.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_video.cpp 2012-11-23 16:09:06 UTC (rev 443) +++ mplayerxp/libmpcodecs/dec_video.cpp 2012-11-23 17:08:19 UTC (rev 444) @@ -296,7 +296,7 @@ sh_video->active_slices=0; mpi=priv->mpvdec->decode(sh_video, frame); MSG_DBG2("decvideo: decoding video %u bytes\n",frame->len); - while(sh_video->active_slices!=0) usleep(0); + while(sh_video->active_slices!=0) yield_timeslice(); /* ------------------------ frame decoded. -------------------- */ if(!mpi) return 0; // error / skipped frame Modified: mplayerxp/libmpstream/cache2.cpp =================================================================== --- mplayerxp/libmpstream/cache2.cpp 2012-11-23 16:09:06 UTC (rev 443) +++ mplayerxp/libmpstream/cache2.cpp 2012-11-23 17:08:19 UTC (rev 444) @@ -360,7 +360,7 @@ MSG_DBG2("CACHE2_SEEK: %lli,%lli,%lli <> %lli\n",START_FILEPOS(c),c->read_filepos,END_FILEPOS(c),pos); if(pos<0/* || pos>END_FILEPOS(c)*/) { c->eof=1; return 0; } - while(c->in_fill) usleep(0); + while(c->in_fill) yield_timeslice(); CACHE2_LOCK(c); if(c->eof) c2_stream_reset(c); C2_ASSERT(pos < c->stream->start_pos); Modified: mplayerxp/libmpstream/s_dvdnav.cpp =================================================================== --- mplayerxp/libmpstream/s_dvdnav.cpp 2012-11-23 16:09:06 UTC (rev 443) +++ mplayerxp/libmpstream/s_dvdnav.cpp 2012-11-23 17:08:19 UTC (rev 444) @@ -275,13 +275,13 @@ if(event == DVDNAV_STILL_FRAME) { dvdnav_still_skip(dvdnav_priv->dvdnav); /* don't let dvdnav stall on this image */ - while (dvdnav_stream_sleeping(stream)) usleep(1000); /* 1ms */ + while (dvdnav_stream_sleeping(stream)) yield_timeslice(); /* 10ms */ } #ifdef DVDNAV_WAIT else if(event == DVDNAV_WAIT) { - usleep(1000); + yield_timeslice(); dvdnav_wait_skip(dvdnav_priv->dvdnav); /* don't let dvdnav stall on this image */ } #endif @@ -382,15 +382,14 @@ uint32_t length=1; uint32_t sector; - if (pos==0) - { + if (pos==0) { dvdnav_priv->started=0; dvdnav_priv->cpos=0; return 0; } sector=pos/DVD_BLOCK_SIZE; dvdnav_sector_search(dvdnav_priv->dvdnav,sector,SEEK_SET); - usleep(0); /* wait for HOP_CHANNEL event */ + yield_timeslice(); /* wait for HOP_CHANNEL event */ dvdnav_get_position(dvdnav_priv->dvdnav, &newpos, &length); if(newpos > sector) newpos=sector; dvdnav_priv->cpos = (newpos)*2048; @@ -486,7 +485,7 @@ const dvdnav_still_event_t *still_event = (const dvdnav_still_event_t*)(sp->buf); MSG_DBG2( "######## DVDNAV Event: Still Frame: %d sec(s)\n", still_event->length ); while (dvdnav_stream_sleeping(s)) { - usleep(1000); /* 1ms */ + yield_timeslice(); } dvdnav_stream_sleep(s,still_event->length); break; Modified: mplayerxp/libvo/vosub_vidix.cpp =================================================================== --- mplayerxp/libvo/vosub_vidix.cpp 2012-11-23 16:09:06 UTC (rev 443) +++ mplayerxp/libvo/vosub_vidix.cpp 2012-11-23 17:08:19 UTC (rev 444) @@ -156,7 +156,7 @@ i=5; if(!sync_mode) while(dma_busy && i) { - usleep(0); + yield_timeslice(); dma_busy = priv.vidix.dma_status(); i--; } Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-11-23 16:09:06 UTC (rev 443) +++ mplayerxp/mplayerxp.cpp 2012-11-23 17:08:19 UTC (rev 444) @@ -1379,14 +1379,14 @@ if (MPXPSys->ao_inited==MPXP_Ok && sh_audio) { if(xmp_test_model(XMP_Run_AudioPlayer)) { xp_core->in_pause=1; - while( !dec_ahead_can_aseek ) usleep(0); + while( !dec_ahead_can_aseek ) yield_timeslice(); } ao_pause(ao_data); // pause audio, keep data if possible } while( (cmd = mp_input_get_cmd(MPXPSys->libinput(),20,1,1)) == NULL) { if(sh_video && MPXPSys->vo_inited) vo_check_events(vo_data); - usleep(20000); + yield_timeslice(); } if (cmd && cmd->id == MP_CMD_PAUSE) { Modified: mplayerxp/mplayerxp.h =================================================================== --- mplayerxp/mplayerxp.h 2012-11-23 16:09:06 UTC (rev 443) +++ mplayerxp/mplayerxp.h 2012-11-23 17:08:19 UTC (rev 444) @@ -4,6 +4,7 @@ #include <pthread.h> #include <stdint.h> #include <string.h> +#include <unistd.h> #include "mp_config.h" #include "osdep/mplib.h" #include "xmpcore/xmp_enums.h" @@ -146,13 +147,15 @@ void exit_player(const char* why); + /* 10 ms or 10'000 microsecs is optimal time for thread sleeping */ + inline int yield_timeslice() { return usleep(10000); } - static inline void escape_player(const char* why,unsigned num_calls) { + inline void escape_player(const char* why,unsigned num_calls) { show_backtrace(why,num_calls); exit_player(why); } - static inline MPXP_Rc check_pin(const char* module,unsigned pin1,unsigned pin2) { + inline MPXP_Rc check_pin(const char* module,unsigned pin1,unsigned pin2) { if(pin1!=pin2) { char msg[4096]; strcpy(msg,"Found incorrect PIN in module: "); Modified: mplayerxp/xmpcore/xmp_adecoder.cpp =================================================================== --- mplayerxp/xmpcore/xmp_adecoder.cpp 2012-11-23 16:09:06 UTC (rev 443) +++ mplayerxp/xmpcore/xmp_adecoder.cpp 2012-11-23 17:08:19 UTC (rev 444) @@ -5,7 +5,6 @@ #include <errno.h> #include <stdio.h> -#include <unistd.h> // for usleep() #include <math.h> #include <sys/time.h> @@ -101,7 +100,7 @@ int loops = 10; pthread_cond_broadcast( &audio_buffer.wait_buffer_cond ); while( audio_buffer.blocked_readers > 0 && loops > 0 ) { - usleep(1); + yield_timeslice(); loops--; } if( audio_buffer.blocked_readers > 0 ) @@ -446,7 +445,7 @@ while(priv->state!=Pth_Canceling) { if(priv->state==Pth_Sleep) { priv->state=Pth_ASleep; - while(priv->state==Pth_ASleep) usleep(0); + while(priv->state==Pth_ASleep) yield_timeslice(); continue; } __MP_UNIT(priv->p_idx,"decode audio"); @@ -486,7 +485,7 @@ } pthread_cond_timedwait( &audio_decode_cond, &audio_decode_mutex, &timeout ); } else - usleep(1); + yield_timeslice(); } UNLOCK_AUDIO_DECODE(); Modified: mplayerxp/xmpcore/xmp_aplayer.cpp =================================================================== --- mplayerxp/xmpcore/xmp_aplayer.cpp 2012-11-23 16:09:06 UTC (rev 443) +++ mplayerxp/xmpcore/xmp_aplayer.cpp 2012-11-23 17:08:19 UTC (rev 444) @@ -4,7 +4,6 @@ #include <algorithm> #include <stdio.h> -#include <unistd.h> // for usleep() #include <pthread.h> #include <math.h> #include <sys/time.h> @@ -171,7 +170,7 @@ while(priv->state!=Pth_Canceling) { if(priv->state==Pth_Sleep) { priv->state=Pth_ASleep; - while(priv->state==Pth_ASleep) usleep(0); + while(priv->state==Pth_ASleep) yield_timeslice(); continue; } __MP_UNIT(priv->p_idx,"audio decore_audio"); Modified: mplayerxp/xmpcore/xmp_core.cpp =================================================================== --- mplayerxp/xmpcore/xmp_core.cpp 2012-11-23 16:09:06 UTC (rev 443) +++ mplayerxp/xmpcore/xmp_core.cpp 2012-11-23 17:08:19 UTC (rev 444) @@ -167,7 +167,7 @@ void dae_wait_decoder_outrun(const dec_ahead_engine_t* it) { if(it) { do { - usleep(0); + yield_timeslice(); }while(dae_get_decoder_outrun(it) < xp_core->num_v_buffs/2); } } @@ -321,11 +321,11 @@ unsigned rc; if(xp_core->audio && xmp_test_model(XMP_Run_AudioDecoder)) { if((rc=xmp_register_thread(xp_core->audio,sig_audio_decode,a_dec_ahead_routine,"audio decoder"))==UINT_MAX) return rc; - while(xp_core->mpxp_threads[rc]->state!=Pth_Run) usleep(0); + while(xp_core->mpxp_threads[rc]->state!=Pth_Run) yield_timeslice(); } if(xp_core->video && xmp_test_model(XMP_Run_VideoDecoder|XMP_Run_VA_Decoder)) { if((rc=xmp_register_thread(xp_core->video,sig_video_decode,xmp_video_decoder,"video+audio decoders"))==UINT_MAX) return rc; - while(xp_core->mpxp_threads[rc]->state!=Pth_Run) usleep(0); + while(xp_core->mpxp_threads[rc]->state!=Pth_Run) yield_timeslice(); } return 0; } @@ -335,11 +335,11 @@ unsigned rc; if(xp_core->audio && xmp_test_model(XMP_Run_AudioPlayer|XMP_Run_AudioPlayback)) { if((rc=xmp_register_thread(xp_core->audio,sig_audio_play,audio_play_routine,"audio player"))==UINT_MAX) return rc; - while(xp_core->mpxp_threads[rc]->state!=Pth_Run) usleep(0); + while(xp_core->mpxp_threads[rc]->state!=Pth_Run) yield_timeslice(); } if(xp_core->video && xmp_test_model(XMP_Run_VideoPlayer)) { if((rc=xmp_register_thread(xp_core->video,sig_video_play,xmp_video_player,"video player"))==UINT_MAX) return rc; - while(xp_core->mpxp_threads[rc]->state!=Pth_Run) usleep(0); + while(xp_core->mpxp_threads[rc]->state!=Pth_Run) yield_timeslice(); } return 0; } @@ -352,7 +352,7 @@ if(force) pthread_kill(xp_core->mpxp_threads[i]->pth_id,SIGKILL); else { xp_core->mpxp_threads[i]->state=Pth_Canceling; - while(xp_core->mpxp_threads[i]->state==Pth_Canceling) usleep(0); + while(xp_core->mpxp_threads[i]->state==Pth_Canceling) yield_timeslice(); } print_stopped_thread(i); delete xp_core->mpxp_threads[i]; @@ -366,7 +366,7 @@ unsigned i; for(i=1;i<xp_core->num_threads;i++) { xp_core->mpxp_threads[i]->state=Pth_Sleep; - while(xp_core->mpxp_threads[i]->state==Pth_Sleep) usleep(0); + while(xp_core->mpxp_threads[i]->state==Pth_Sleep) yield_timeslice(); } } @@ -384,7 +384,7 @@ unsigned i; for(i=1;i<xp_core->num_threads;i++) { xp_core->mpxp_threads[i]->state=Pth_Run; - while(xp_core->mpxp_threads[i]->state==Pth_ASleep) usleep(0); + while(xp_core->mpxp_threads[i]->state==Pth_ASleep) yield_timeslice(); } } Modified: mplayerxp/xmpcore/xmp_vdecoder.cpp =================================================================== --- mplayerxp/xmpcore/xmp_vdecoder.cpp 2012-11-23 16:09:06 UTC (rev 443) +++ mplayerxp/xmpcore/xmp_vdecoder.cpp 2012-11-23 17:08:19 UTC (rev 444) @@ -2,7 +2,6 @@ #include "osdep/mplib.h" using namespace mpxp; #include <stdio.h> -#include <unistd.h> // for usleep() #include <math.h> #include "libmpcodecs/dec_video.h" @@ -152,7 +151,7 @@ if(priv->state==Pth_Sleep) { pt_sleep: priv->state=Pth_ASleep; - while(priv->state==Pth_ASleep) usleep(0); + while(priv->state==Pth_ASleep) yield_timeslice(); if(xp_core->bad_pts) mpeg_timer=HUGE; continue; } @@ -204,7 +203,7 @@ { int i,delay; /* sleeping 200 ms is far enough for 25 fps */ delay=xp_n_frame_to_drop?0:20; - for(i=0;i<delay;i++) usleep(0); + for(i=0;i<delay;i++) yield_timeslice(); } #endif if(xp_n_frame_to_drop) drop_param=mp_conf.frame_dropping; @@ -254,7 +253,7 @@ xp_thread_decode_audio(d_audio); __MP_UNIT(priv->p_idx,"dec_ahead 5"); } - usleep(1); + yield_timeslice(); } free_enc_frame(frame); /*------------------------ frame decoded. --------------------*/ @@ -263,7 +262,7 @@ if(xp_core->audio && xmp_test_model(XMP_Run_VA_Decoder)) { while(!xp_core->audio->eof && priv->state!=Pth_Canceling && priv->state!=Pth_Sleep) { __MP_UNIT(priv->p_idx,"decode audio"); - if(!xp_thread_decode_audio(d_audio)) usleep(1); + if(!xp_thread_decode_audio(d_audio)) yield_timeslice(); __MP_UNIT(priv->p_idx,NULL); } } Modified: mplayerxp/xmpcore/xmp_vplayer.cpp =================================================================== --- mplayerxp/xmpcore/xmp_vplayer.cpp 2012-11-23 16:09:06 UTC (rev 443) +++ mplayerxp/xmpcore/xmp_vplayer.cpp 2012-11-23 17:08:19 UTC (rev 444) @@ -2,7 +2,6 @@ #include "osdep/mplib.h" using namespace mpxp; #include <stdio.h> -#include <unistd.h> // for usleep() #include <math.h> #include "help_mp.h" @@ -72,7 +71,7 @@ if(MPXPCtx->use_pts_fix2 && sh_audio) { if(sh_video->chapter_change == -1) { /* First frame after seek */ while(v_pts < 1.0 && sh_audio->timer==0.0 && ao_get_delay(ao_data)==0.0) - usleep(0); /* Wait for audio to start play */ + yield_timeslice(); /* Wait for audio to start play */ if(sh_audio->timer > 2.0 && v_pts < 1.0) { MSG_V("Video chapter change detected\n"); sh_video->chapter_change=1; @@ -138,8 +137,7 @@ } while(sleep_time>XP_MIN_TIMESLICE) { - /* mp_free cpu for threads */ - usleep(1); + yield_timeslice(); sleep_time-=GetRelativeTime(); } MP_UNIT("sleep_usleep"); @@ -201,7 +199,7 @@ /* Don't burn CPU here! With using of v_pts for A-V sync we will enter xp_decore_video without any delay (like while(1);) Sleeping for 10 ms doesn't matter with frame dropping */ - usleep(0); + yield_timeslice(); } else { unsigned int t2=GetTimer(); double tt; @@ -291,7 +289,7 @@ if(priv->state==Pth_Canceling) break; if(priv->state==Pth_Sleep) { priv->state=Pth_ASleep; - while(priv->state==Pth_ASleep) usleep(0); + while(priv->state==Pth_ASleep) yield_timeslice(); continue; } __MP_UNIT(priv->p_idx,"play video"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-11-24 07:35:50
|
Revision: 445 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=445&view=rev Author: nickols_k Date: 2012-11-24 07:35:40 +0000 (Sat, 24 Nov 2012) Log Message: ----------- minor fixes Modified Paths: -------------- TODO mplayerxp/configure mplayerxp/libmpcodecs/ad_vorbis.cpp mplayerxp/libmpcodecs/dec_video.cpp mplayerxp/libmpcodecs/vd.h mplayerxp/libmpcodecs/vd_divx4.cpp mplayerxp/libmpcodecs/vd_dmo.cpp mplayerxp/libmpcodecs/vd_dshow.cpp mplayerxp/libmpcodecs/vd_huffyuv.cpp mplayerxp/libmpcodecs/vd_lavc.cpp mplayerxp/libmpcodecs/vd_libdv.cpp mplayerxp/libmpcodecs/vd_libmpeg2.cpp mplayerxp/libmpcodecs/vd_mpegpes.cpp mplayerxp/libmpcodecs/vd_nuv.cpp mplayerxp/libmpcodecs/vd_qtvideo.cpp mplayerxp/libmpcodecs/vd_raw.cpp mplayerxp/libmpcodecs/vd_real.cpp mplayerxp/libmpcodecs/vd_theora.cpp mplayerxp/libmpcodecs/vd_vfw.cpp mplayerxp/libmpcodecs/vd_xanim.cpp mplayerxp/libmpcodecs/vd_xvid.cpp Modified: TODO =================================================================== --- TODO 2012-11-23 17:08:19 UTC (rev 444) +++ TODO 2012-11-24 07:35:40 UTC (rev 445) @@ -1,5 +1,7 @@ TODO for mplayerxp: +- Move vo_data and ao_data into private of vf_vo and af_ao2 or into + MPXPCtx at least. - Problem: it seems that demuxer doesn't differ bitmap-based subtitles from Closed Caption (plain ascii-text) ones. Because of this some demuxer's parser call video-driver directly to render subtitle on screen that breaks Modified: mplayerxp/configure =================================================================== --- mplayerxp/configure 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/configure 2012-11-24 07:35:40 UTC (rev 445) @@ -684,6 +684,7 @@ enabled sdl && check_pkg sdl sdl enabled sdl && require2 sdl SDL/SDL.h SDL_CreateYUVOverlay print_config HAVE_ mp_config.h mp_config.mak sdl +disabled sdl && disable sdl_image if enabled sdl; then enabled sdl_image && require2 sdl_image SDL/SDL_image.h IMG_Load_RW -lSDL_image print_config HAVE_ mp_config.h mp_config.mak sdl_image @@ -803,7 +804,7 @@ # Checking for VIDIX enabled vidix && xxrequire2 vidix "vidix/vidix.h vidix/vidixlibxx.h" Vidix -lvidixxx print_config CONFIG_ mp_config.h mp_config.mak vidix -enabled x11 && enabled vidix && vomodules="vidix $vomodules" || novomodules="vidix $novomodules" +enabled x11 && enabled vidix && vomodules=":vidix $vomodules" || novomodules=":vidix $novomodules" enabled joystick && test linux || disable joystick Modified: mplayerxp/libmpcodecs/ad_vorbis.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_vorbis.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/ad_vorbis.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -5,11 +5,12 @@ #include <stdlib.h> #include <unistd.h> #include <dlfcn.h> +#include "osdep/bswap.h" #include "codecs_ld.h" #include "ad_internal.h" #include "libao2/afmt.h" #include "libao2/audio_out.h" -#include "osdep/bswap.h" +#include "postproc/af.h" static const ad_info_t info = { "Ogg/Vorbis audio decoder", @@ -113,7 +114,9 @@ #define OGG_FMT16 AFMT_S16_LE #endif sh->afmt=OGG_FMT16; - if(ao_control(ao_data,AOCONTROL_QUERY_FORMAT,OGG_FMT32) == MPXP_Ok) { + if(af_query_fmt(sh->afilter,mpaf_format_e(AFMT_FLOAT32)) == MPXP_Ok|| + af_query_fmt(sh->afilter,mpaf_format_e(OGG_FMT32)) == MPXP_Ok || + af_query_fmt(sh->afilter,mpaf_format_e(OGG_FMT24)) == MPXP_Ok) { sh->afmt=OGG_FMT32; } // assume 128kbit if bitrate not specified in the header Modified: mplayerxp/libmpcodecs/dec_video.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_video.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/dec_video.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -401,7 +401,7 @@ #include "libvo/video_out.h" -MPXP_Rc mpcodecs_config_vo(sh_video_t *sh, int w, int h, any_t* libinput){ +MPXP_Rc mpcodecs_config_vf(sh_video_t *sh, int w, int h, any_t* libinput){ priv_t* priv=(priv_t*)sh->decoder; int i,j; unsigned int out_fmt=0; @@ -573,7 +573,7 @@ // mp_imgtype: buffering type, see mp_image.h // mp_imgflag: buffer requirements (read/write, preserve, stride limits), see mp_image.h // returns NULL or allocated mp_image_t* -// Note: buffer allocation may be moved to mpcodecs_config_vo() later... +// Note: buffer allocation may be moved to mpcodecs_config_vf() later... mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag,int w, int h){ MSG_DBG2("mpcodecs_get_image(vf_%s,%i,%i,%i,%i) was called\n",((vf_instance_t *)(sh->vfilter))->info->name,mp_imgtype,mp_imgflag,w,h); mp_image_t* mpi=vf_get_new_image(sh->vfilter,sh->codec->outfmt[sh->outfmtidx],mp_imgtype,mp_imgflag,w,h,dae_curr_vdecoded(xp_core)); Modified: mplayerxp/libmpcodecs/vd.h =================================================================== --- mplayerxp/libmpcodecs/vd.h 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd.h 2012-11-24 07:35:40 UTC (rev 445) @@ -70,7 +70,7 @@ VDCTRL_RESYNC_STREAM =7 /* resync video stream if needed */ }; // callbacks: -MPXP_Rc __FASTCALL__ mpcodecs_config_vo(sh_video_t *sh, int w, int h, any_t* libinput); +MPXP_Rc __FASTCALL__ mpcodecs_config_vf(sh_video_t *sh, int w, int h, any_t* libinput); mp_image_t* __FASTCALL__ mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag,int w, int h); void __FASTCALL__ mpcodecs_draw_slice(sh_video_t* sh, mp_image_t*); void __FASTCALL__ mpcodecs_draw_image(sh_video_t* sh, mp_image_t *mpi); Modified: mplayerxp/libmpcodecs/vd_divx4.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_divx4.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd_divx4.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -214,7 +214,7 @@ priv_t*p; int bits=12; if(!load_lib("libdivx"SLIBSUFFIX)) return MPXP_False; - if(!(mpcodecs_config_vo(sh,sh->src_w,sh->src_h,libinput))) return MPXP_False; + if(!(mpcodecs_config_vf(sh,sh->src_w,sh->src_h,libinput))) return MPXP_False; switch(sh->codec->outfmt[sh->outfmtidx]){ case IMGFMT_YV12: case IMGFMT_I420: Modified: mplayerxp/libmpcodecs/vd_dmo.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_dmo.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd_dmo.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -55,7 +55,7 @@ "package from: ftp://mplayerhq.hu/MPlayer/releases/w32codec.tar.bz2!\n"); return MPXP_False; } - if(!mpcodecs_config_vo(sh,sh->src_w,sh->src_h,libinput)) return MPXP_False; + if(!mpcodecs_config_vf(sh,sh->src_w,sh->src_h,libinput)) return MPXP_False; out_fmt=sh->codec->outfmt[sh->outfmtidx]; switch(out_fmt){ case IMGFMT_YUY2: Modified: mplayerxp/libmpcodecs/vd_dshow.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_dshow.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd_dshow.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -74,7 +74,7 @@ MSG_HINT("package from: ftp://mplayerhq.hu/MPlayer/releases/w32codec.zip !\n"); return MPXP_False; } - if(!mpcodecs_config_vo(sh,sh->src_w,sh->src_h,libinput)) return MPXP_False; + if(!mpcodecs_config_vf(sh,sh->src_w,sh->src_h,libinput)) return MPXP_False; out_fmt=sh->codec->outfmt[sh->outfmtidx]; switch(out_fmt){ case IMGFMT_YUY2: Modified: mplayerxp/libmpcodecs/vd_huffyuv.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_huffyuv.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd_huffyuv.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -328,7 +328,7 @@ switch (priv->bitmaptype) { case BMPTYPE_RGB: case BMPTYPE_YUV: - vo_ret = mpcodecs_config_vo(sh,sh->src_w,sh->src_h,libinput); + vo_ret = mpcodecs_config_vf(sh,sh->src_w,sh->src_h,libinput); break; case BMPTYPE_RGBA: MSG_ERR( "[HuffYUV] RGBA not supported yet.\n"); Modified: mplayerxp/libmpcodecs/vd_lavc.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_lavc.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd_lavc.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -425,7 +425,7 @@ } if(pp_flags) ppContext=pp2_get_context(sh->src_w,sh->src_h,pp_flags); } - return mpcodecs_config_vo(sh,sh->src_w,sh->src_h,libinput); + return mpcodecs_config_vf(sh,sh->src_w,sh->src_h,libinput); } // uninit driver Modified: mplayerxp/libmpcodecs/vd_libdv.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_libdv.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd_libdv.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -81,7 +81,7 @@ static MPXP_Rc init(sh_video_t *sh,any_t* libinput) { sh->context = (any_t*)init_global_rawdv_decoder(); - return mpcodecs_config_vo(sh,sh->src_w,sh->src_h,libinput); + return mpcodecs_config_vf(sh,sh->src_w,sh->src_h,libinput); } // uninit driver Modified: mplayerxp/libmpcodecs/vd_libmpeg2.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_libmpeg2.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd_libmpeg2.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -262,7 +262,7 @@ if(!load_lib("libmpeg2"SLIBSUFFIX)) return MPXP_False; sh->context=priv=new(zeromem) priv_t; if(!(priv->mpeg2dec=mpeg2_init(MPXPCtx->mplayer_accel))) return MPXP_False; - return mpcodecs_config_vo(sh,sh->src_w,sh->src_h,libinput); + return mpcodecs_config_vf(sh,sh->src_w,sh->src_h,libinput); } // uninit driver Modified: mplayerxp/libmpcodecs/vd_mpegpes.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_mpegpes.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd_mpegpes.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -102,7 +102,7 @@ // init driver static MPXP_Rc init(sh_video_t *sh,any_t* libinput){ - return mpcodecs_config_vo(sh,sh->src_w,sh->src_h,libinput); + return mpcodecs_config_vf(sh,sh->src_w,sh->src_h,libinput); } // uninit driver Modified: mplayerxp/libmpcodecs/vd_nuv.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_nuv.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd_nuv.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -50,7 +50,7 @@ // init driver static MPXP_Rc init(sh_video_t *sh,any_t* libinput){ - return mpcodecs_config_vo(sh,sh->src_w,sh->src_h,libinput); + return mpcodecs_config_vf(sh,sh->src_w,sh->src_h,libinput); } // uninit driver Modified: mplayerxp/libmpcodecs/vd_qtvideo.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_qtvideo.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd_qtvideo.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -293,9 +293,9 @@ } MSG_V("imgfmt: %s qt_imgfmt: %.4s\n", vo_format_name(imgfmt), &qt_imgfmt); sh->context = (any_t*)qt_imgfmt; - if(!mpcodecs_config_vo(sh,sh->src_w,sh->src_h,libinput)) return MPXP_False; + if(!mpcodecs_config_vf(sh,sh->src_w,sh->src_h,libinput)) return MPXP_False; #else - if(!mpcodecs_config_vo(sh,sh->src_w,sh->src_h,libinput)) return MPXP_False; + if(!mpcodecs_config_vf(sh,sh->src_w,sh->src_h,libinput)) return MPXP_False; #endif return MPXP_Ok; } Modified: mplayerxp/libmpcodecs/vd_raw.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_raw.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd_raw.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -101,7 +101,7 @@ MSG_WARN("RAW: depth %d not supported\n",sh->bih->biBitCount); } } - return mpcodecs_config_vo(sh,sh->src_w,sh->src_h,libinput); + return mpcodecs_config_vf(sh,sh->src_w,sh->src_h,libinput); } // uninit driver Modified: mplayerxp/libmpcodecs/vd_real.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_real.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd_real.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -180,7 +180,7 @@ if(!load_syms(sh->codec->dll_name)) return MPXP_False; // only I420 supported - if(!mpcodecs_config_vo(sh,sh->src_w,sh->src_h,libinput)) return MPXP_False; + if(!mpcodecs_config_vf(sh,sh->src_w,sh->src_h,libinput)) return MPXP_False; // init codec: sh->context=NULL; result=(*rvyuv_init)(&init_data, &sh->context); Modified: mplayerxp/libmpcodecs/vd_theora.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_theora.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd_theora.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -127,7 +127,7 @@ MSG_V("INFO: Theora video init ok!\n"); - return mpcodecs_config_vo (sh,sh->src_w,sh->src_h,libinput); + return mpcodecs_config_vf(sh,sh->src_w,sh->src_h,libinput); } /* Modified: mplayerxp/libmpcodecs/vd_vfw.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_vfw.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd_vfw.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -259,7 +259,7 @@ priv->ex = vfw_ex; if(init_vfw_video_codec(sh)!=MPXP_Ok) return MPXP_False; MSG_V("INFO: Win32/VFW init OK!\n"); - return mpcodecs_config_vo(sh,sh->src_w,sh->src_h,libinput); + return mpcodecs_config_vf(sh,sh->src_w,sh->src_h,libinput); } // uninit driver Modified: mplayerxp/libmpcodecs/vd_xanim.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_xanim.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd_xanim.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -897,7 +897,7 @@ // init driver static MPXP_Rc init(sh_video_t *sh,any_t* libinput){ if(xacodec_init_video(sh,sh->codec->outfmt[sh->outfmtidx])) - return mpcodecs_config_vo(sh,sh->src_w,sh->src_h,libinput); + return mpcodecs_config_vf(sh,sh->src_w,sh->src_h,libinput); return MPXP_False; } Modified: mplayerxp/libmpcodecs/vd_xvid.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_xvid.cpp 2012-11-23 17:08:19 UTC (rev 444) +++ mplayerxp/libmpcodecs/vd_xvid.cpp 2012-11-24 07:35:40 UTC (rev 445) @@ -434,7 +434,7 @@ priv->img_type = MP_IMGTYPE_TEMP; break; } - return mpcodecs_config_vo(sh, sh->src_w, sh->src_h,libinput); + return mpcodecs_config_vf(sh, sh->src_w, sh->src_h,libinput); } // uninit driver This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |