Update to libXv 1.0.10

This commit is contained in:
matthieu 2013-09-28 17:51:20 +00:00
parent 4624618994
commit f0a97458d0
10 changed files with 1869 additions and 1387 deletions

View File

@ -1,3 +1,195 @@
commit 736d7ac5a94c7aa6761d50ab58339a3d9a116c51
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Sep 7 22:19:48 2013 -0700
libXv 1.0.10
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 4a7d2ca2438649e61b7dcb9491391ff6fbd482ac
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Fri Jul 5 21:19:29 2013 -0700
Remove fallback for _XEatDataWords, require libX11 1.6 for it
_XEatDataWords was orignally introduced with the May 2013 security
patches, and in order to ease the process of delivering those,
fallback versions of _XEatDataWords were included in the X extension
library patches so they could be applied to older versions that didn't
have libX11 1.6 yet. Now that we're past that hurdle, we can drop
the fallbacks and just require libX11 1.6 for building new versions
of the extension libraries.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 06d275959b5dd78c319d5200ca6d986934b18920
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Jun 22 23:43:58 2013 -0700
Refactor error handling
Reduce code duplication, make error checking & cleanup more consistent
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 29b23d387e32d09e1b34682f01cee899a08a1176
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Jun 22 21:47:34 2013 -0700
Add missing calls to _XEatDataWords when we are skipping _XRead
If we failed to allocate the buffer to _XRead into, discard the
rest of the reply, instead of leaving it to confuse the reading
of the next reply.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 5a09a55b5b13280990465d83205e796bb8cd68ac
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Jun 22 21:04:06 2013 -0700
Replace custom copy of GetReq macro with call to Xlib 1.5's _XGetRequest
xvproto.h names don't match those required by the Xlibint.h GetReq* macros,
but at least we can rely on the _XGetRequest function for the bulk of the
work now, instead of duplicating it.
Also clears clang warnings repeated for every request function:
Xv.c:137:5: warning: cast from 'char *' to 'xvQueryExtensionReq *' increases re
quired alignment from 1 to 2 [-Wcast-align]
XvGetReq(QueryExtension, req);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Xvlibint.h:52:8: note: expanded from macro 'XvGetReq'
req = (xv##name##Req *)(dpy->last_req = dpy->bufptr);\
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Xv.c:137:5: warning: implicit conversion loses integer precision: 'int' to 'CAR
D8' (aka 'unsigned char') [-Wconversion]
XvGetReq(QueryExtension, req);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Xvlibint.h:53:30: note: expanded from macro 'XvGetReq'
req->reqType = info->codes->major_opcode;\
~ ~~~~~~~~~~~~~^~~~~~~~~~~~
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit ef2722e10b275d13d754d2b92e67f72b0716d070
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Jun 22 20:33:13 2013 -0700
Require ANSI C89 pre-processor, drop pre-C89 token pasting support
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
commit e73a2199f039e9ae772efb6be8d1db68eb346fa4
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Jun 22 13:35:12 2013 -0700
Use pad_to_int32 macro instead of repeated (x + 3) & ~3 pattern
Makes code clearer, and using ~3U instead of ~3 clears some signed int
warnings.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 4ced44196d6636006c9724a373c0d2ca0c12dc1e
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Jun 22 11:20:13 2013 -0700
Fix sign conversion & comparison warnings from clang
Clears up:
Xv.c:196:21: warning: implicit conversion changes signedness: 'CARD32' (aka 'unsigned int') to 'int' [-Wsign-conversion]
size = rep.length << 2;
~ ~~~~~~~~~~~^~~~
Xv.c:212:41: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
if ((pas=(XvAdaptorInfo *)Xmalloc(size))==NULL) {
~~~~~~~~^~~~~
Xv.c:236:43: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
pa->num_adaptors = rep.num_adaptors - ii;
~ ~~~~~~~~~~~~~~~~~^~~~
Xv.c:243:40: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
if ( (name = (char *)Xmalloc(size+1)) == NULL)
~~~~~~~~~~~~^~~
Xv.c:251:37: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
(void)strncpy(name, u.string, size);
~~~~~~~ ^~~~
Xv.c:260:36: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
if ((pfs=(XvFormat *)Xmalloc(size))==NULL) {
~~~~~~~~^~~~~
Xv.c:269:20: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
for (jj=0; jj<pa->num_formats; jj++) {
~~^~~~~~~~~~~~~~~~
Xv.c:259:29: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
size = pa->num_formats*sizeof(XvFormat);
~ ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
Xv.c:305:16: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
for (ii=0; ii<pAdaptors->num_adaptors; ii++, pa++)
~~^~~~~~~~~~~~~~~~~~~~~~~~
Xv.c:356:21: warning: implicit conversion changes signedness: 'CARD32' (aka 'unsigned int') to 'int' [-Wsign-conversion]
size = rep.length << 2;
~ ~~~~~~~~~~~^~~~
Xv.c:369:41: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
if ( (pes = (XvEncodingInfo *)Xmalloc(size)) == NULL) {
~~~~~~~~^~~~~
Xv.c:392:45: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
pe->num_encodings = rep.num_encodings - jj;
~ ~~~~~~~~~~~~~~~~~~^~~~
Xv.c:397:40: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
if ( (name = (char *)Xmalloc(size+1)) == NULL) {
~~~~~~~~~~~~^~~
Xv.c:404:31: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
strncpy(name, u.string, size);
~~~~~~~ ^~~~
Xv.c:433:16: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
for (ii=0; ii<pEncodings->num_encodings; ii++, pe++) {
~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Xv.c:886:27: warning: comparison of integers of different signs: 'int' and 'CAR
D32' (aka 'unsigned int') [-Wsign-compare]
for (i = 0; i < rep.num_attributes; i++) {
~ ^ ~~~~~~~~~~~~~~~~~~
Xv.c:946:27: warning: comparison of integers of different signs: 'int' and 'CAR
D32' (aka 'unsigned int') [-Wsign-compare]
for (i = 0; i < rep.num_formats; i++) {
~ ^ ~~~~~~~~~~~~~~~
Xv.c:1100:5: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare]
SetReqLen(req, len, len);
^~~~~~~~~~~~~~~~~~~~~~~~
X11/Xlibint.h:530:27: note: expanded from macro 'SetReqLen'
if ((req->length + n) > (unsigned)65535) { \
^ ~~~~~~~~~~~~~~~
Xv.c:1100:20: warning: implicit conversion changes signedness: 'int' to 'unsigned int' [-Wsign-conversion]
SetReqLen(req, len, len);
~~~~~~~~~~~~~~~^~~~~~~~~
X11/Xlibint.h:532:21: note: expanded from macro 'SetReqLen'
MakeBigReq(req,n) \
^
X11/Xlibint.h:505:35: note: expanded from macro 'MakeBigReq'
((CARD32 *)req)[1] = _BRlen + n + 2; \
~ ^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 89dc3ff457644271b1c633efa9682ae45e55d9d8
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Jun 22 11:07:13 2013 -0700
Remove unnecessary casts from Xmalloc calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
commit 54851e0e72e2017c14c504459078c97d6112696b
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Jun 22 19:58:20 2013 -0700
Adopt X.Org standard code style, with consistent indentation
Having differing indent levels of 2, 3, & 4 spaces hurts my eyes.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit d58f74ebfd0c56ffeb8e288c65592228af197a2e
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Jun 22 19:06:09 2013 -0700

View File

@ -75,7 +75,8 @@ subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in $(srcdir)/xv.pc.in \
$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
config.guess config.sub depcomp install-sh ltmain.sh missing
compile config.guess config.sub depcomp install-sh ltmain.sh \
missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View File

@ -9828,7 +9828,7 @@ dnl DEALINGS IN THE SOFTWARE.
# See the "minimum version" comment for each macro you use to see what
# version you require.
m4_defun([XORG_MACROS_VERSION],[
m4_define([vers_have], [1.16.2])
m4_define([vers_have], [1.17.1])
m4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
m4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
m4_if(m4_cmp(maj_have, maj_needed), 0,,
@ -11334,18 +11334,18 @@ fi
found="no"
m4_foreach([flag], m4_cdr($@), [
if test $found = "no" ; then
if test "x$xorg_testset_unknown_warning_option" = "xyes" ; then
if test "x$xorg_testset_]CACHE_PREFIX[_unknown_warning_option" = "xyes" ; then
PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
fi
if test "x$xorg_testset_unused_command_line_argument" = "xyes" ; then
if test "x$xorg_testset_]CACHE_PREFIX[_unused_command_line_argument" = "xyes" ; then
PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
fi
PREFIX[FLAGS]="$PREFIX[FLAGS] ]flag["
dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname
AC_MSG_CHECKING([if ]COMPILER[ supports]flag[])
AC_MSG_CHECKING([if ]COMPILER[ supports ]flag[])
cacheid=AS_TR_SH([xorg_cv_]CACHE_PREFIX[_flag_]flag[])
AC_CACHE_VAL($cacheid,
[AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;])],

347
lib/libXv/compile Normal file
View File

@ -0,0 +1,347 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2012-10-14.11; # UTC
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

View File

@ -30,9 +30,6 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the `_XEatDataWords' function. */
#undef HAVE__XEATDATAWORDS
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR

454
lib/libXv/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@
# Initialize Autoconf
AC_PREREQ([2.60])
AC_INIT([libXv], [1.0.9],
AC_INIT([libXv], [1.0.10],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXv])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])
@ -41,13 +41,7 @@ XORG_DEFAULT_OPTIONS
XORG_CHECK_MALLOC_ZERO
# Obtain compiler/linker options for depedencies
PKG_CHECK_MODULES(XV, x11 xext xextproto videoproto)
# Check for _XEatDataWords function that may be patched into older Xlib release
SAVE_LIBS="$LIBS"
LIBS="$XV_LIBS"
AC_CHECK_FUNCS([_XEatDataWords])
LIBS="$SAVE_LIBS"
PKG_CHECK_MODULES(XV, [x11 >= 1.6 xext xextproto videoproto])
# Allow checking code with lint, sparse, etc.
XORG_WITH_LINT

View File

@ -164,30 +164,30 @@ typedef struct {
_XFUNCPROTOBEGIN
extern int XvQueryExtension(
Display* /* display */,
unsigned int* /* p_version */,
unsigned int* /* p_revision */,
unsigned int* /* p_requestBase */,
unsigned int* /* p_eventBase */,
unsigned int* /* p_errorBase */
Display * /* display */,
unsigned int * /* p_version */,
unsigned int * /* p_revision */,
unsigned int * /* p_requestBase */,
unsigned int * /* p_eventBase */,
unsigned int * /* p_errorBase */
);
extern int XvQueryAdaptors(
Display* /* display */,
Display * /* display */,
Window /* window */,
unsigned int* /* p_nAdaptors */,
XvAdaptorInfo** /* p_pAdaptors */
unsigned int * /* p_nAdaptors */,
XvAdaptorInfo ** /* p_pAdaptors */
);
extern int XvQueryEncodings(
Display* /* display */,
Display * /* display */,
XvPortID /* port */,
unsigned int* /* p_nEncoding */,
XvEncodingInfo** /* p_pEncoding */
unsigned int * /* p_nEncoding */,
XvEncodingInfo ** /* p_pEncoding */
);
extern int XvPutVideo(
Display* /* display */,
Display * /* display */,
XvPortID /* port */,
Drawable /* d */,
GC /* gc */,
@ -202,7 +202,7 @@ extern int XvPutVideo(
);
extern int XvPutStill(
Display* /* display */,
Display * /* display */,
XvPortID /* port */,
Drawable /* d */,
GC /* gc */,
@ -217,7 +217,7 @@ extern int XvPutStill(
);
extern int XvGetVideo(
Display* /* display */,
Display * /* display */,
XvPortID /* port */,
Drawable /* d */,
GC /* gc */,
@ -232,7 +232,7 @@ extern int XvGetVideo(
);
extern int XvGetStill(
Display* /* display */,
Display * /* display */,
XvPortID /* port */,
Drawable /* d */,
GC /* gc */,
@ -247,84 +247,84 @@ extern int XvGetStill(
);
extern int XvStopVideo(
Display* /* display */,
Display * /* display */,
XvPortID /* port */,
Drawable /* drawable */
);
extern int XvGrabPort(
Display* /* display */,
Display * /* display */,
XvPortID /* port */,
Time /* time */
);
extern int XvUngrabPort(
Display* /* display */,
Display * /* display */,
XvPortID /* port */,
Time /* time */
);
extern int XvSelectVideoNotify(
Display* /* display */,
Display * /* display */,
Drawable /* drawable */,
Bool /* onoff */
);
extern int XvSelectPortNotify(
Display* /* display */,
Display * /* display */,
XvPortID /* port */,
Bool /* onoff */
);
extern int XvSetPortAttribute(
Display* /* display */,
Display * /* display */,
XvPortID /* port */,
Atom /* attribute */,
int /* value */
);
extern int XvGetPortAttribute(
Display* /* display */,
Display * /* display */,
XvPortID /* port */,
Atom /* attribute */,
int* /* p_value */
int * /* p_value */
);
extern int XvQueryBestSize(
Display* /* display */,
Display * /* display */,
XvPortID /* port */,
Bool /* motion */,
unsigned int /* vid_w */,
unsigned int /* vid_h */,
unsigned int /* drw_w */,
unsigned int /* drw_h */,
unsigned int* /* p_actual_width */,
unsigned int* /* p_actual_width */
unsigned int * /* p_actual_width */,
unsigned int * /* p_actual_width */
);
extern XvAttribute* XvQueryPortAttributes(
Display* /* display */,
extern XvAttribute *XvQueryPortAttributes(
Display * /* display */,
XvPortID /* port */,
int* /* number */
int * /* number */
);
extern void XvFreeAdaptorInfo(
XvAdaptorInfo* /* adaptors */
XvAdaptorInfo * /* adaptors */
);
extern void XvFreeEncodingInfo(
XvEncodingInfo* /* encodings */
XvEncodingInfo * /* encodings */
);
extern XvImageFormatValues * XvListImageFormats (
extern XvImageFormatValues *XvListImageFormats (
Display *display,
XvPortID port_id,
int *count_return
);
extern XvImage * XvCreateImage (
extern XvImage *XvCreateImage (
Display *display,
XvPortID port,
int id,
@ -366,11 +366,11 @@ extern int XvShmPutImage (
Bool send_event
);
extern XvImage * XvShmCreateImage (
extern XvImage *XvShmCreateImage (
Display *display,
XvPortID port,
int id,
char* data,
char *data,
int width,
int height,
XShmSegmentInfo *shminfo

View File

@ -60,17 +60,6 @@ SOFTWARE.
#include <X11/extensions/XShm.h>
#include <limits.h>
#ifndef HAVE__XEATDATAWORDS
static inline void _XEatDataWords(Display *dpy, unsigned long n)
{
# ifndef LONG64
if (n >= (ULONG_MAX >> 2))
_XIOError(dpy);
# endif
_XEatData (dpy, n << 2);
}
#endif
static XExtensionInfo _xv_info_data;
static XExtensionInfo *xv_info = &_xv_info_data;
static const char *xv_extension_name = XvName;
@ -78,8 +67,10 @@ static const char *xv_extension_name = XvName;
#define XvCheckExtension(dpy, i, val) \
XextCheckExtension(dpy, i, xv_extension_name, val)
#define pad_to_int32(bytes) (((bytes) + 3) & ~3U)
static char *xv_error_string(Display *dpy, int code, XExtCodes *codes,
char * buf, int n);
char *buf, int n);
static int xv_close_display(Display *dpy, XExtCodes *codes);
static Bool xv_wire_to_event(Display *dpy, XEvent *host, xEvent *wire);
@ -98,23 +89,19 @@ static XExtensionHooks xv_extension_hooks = {
};
static const char *xv_error_list[] =
{
static const char *xv_error_list[] = {
"BadPort", /* XvBadPort */
"BadEncoding", /* XvBadEncoding */
"BadControl" /* XvBadControl */
};
static XEXT_GENERATE_CLOSE_DISPLAY (xv_close_display, xv_info)
static XEXT_GENERATE_CLOSE_DISPLAY(xv_close_display, xv_info)
static XEXT_GENERATE_FIND_DISPLAY (xv_find_display, xv_info,
xv_extension_name,
&xv_extension_hooks,
static XEXT_GENERATE_FIND_DISPLAY(xv_find_display, xv_info,
xv_extension_name, &xv_extension_hooks,
XvNumEvents, NULL)
static XEXT_GENERATE_ERROR_STRING (xv_error_string, xv_extension_name,
static XEXT_GENERATE_ERROR_STRING(xv_error_string, xv_extension_name,
XvNumErrors, xv_error_list)
@ -125,11 +112,12 @@ XvQueryExtension(
unsigned int *p_revision,
unsigned int *p_requestBase,
unsigned int *p_eventBase,
unsigned int *p_errorBase
){
unsigned int *p_errorBase)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvQueryExtensionReq *req;
xvQueryExtensionReply rep;
int status;
XvCheckExtension(dpy, info, XvBadExtension);
@ -137,10 +125,9 @@ XvQueryExtension(
XvGetReq(QueryExtension, req);
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return XvBadExtension;
if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
status = XvBadExtension;
goto out;
}
*p_version = rep.version;
@ -149,10 +136,13 @@ XvQueryExtension(
*p_eventBase = info->codes->first_event;
*p_errorBase = info->codes->first_error;
status = Success;
out:
UnlockDisplay(dpy);
SyncHandle();
return Success;
return status;
}
int
@ -160,23 +150,24 @@ XvQueryAdaptors(
Display *dpy,
Window window,
unsigned int *p_nAdaptors,
XvAdaptorInfo **p_pAdaptors
){
XvAdaptorInfo **p_pAdaptors)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvQueryAdaptorsReq *req;
xvQueryAdaptorsReply rep;
int size,ii,jj;
size_t size;
unsigned int ii, jj;
char *name;
XvAdaptorInfo *pas, *pa;
XvAdaptorInfo *pas = NULL, *pa;
XvFormat *pfs, *pf;
char *buffer;
union
{
char *buffer = NULL;
union {
char *buffer;
char *string;
xvAdaptorInfo *pa;
xvFormat *pf;
} u;
int status;
XvCheckExtension(dpy, info, XvBadExtension);
@ -187,48 +178,56 @@ XvQueryAdaptors(
/* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy);
SyncHandle();
return(XvBadReply);
if (_XReply(dpy, (xReply *) &rep, 0, xFalse) == 0) {
rep.num_adaptors = 0;
status = XvBadReply;
goto out;
}
size = rep.length << 2;
if ( (buffer = (char *)Xmalloc ((unsigned) size)) == NULL) {
UnlockDisplay(dpy);
SyncHandle();
return(XvBadAlloc);
if (size > 0) {
if ((buffer = Xmalloc(size)) == NULL) {
_XEatDataWords(dpy, rep.length);
status = XvBadAlloc;
goto out;
}
_XRead(dpy, buffer, (long) size);
}
_XRead (dpy, buffer, size);
u.buffer = buffer;
/* GET INPUT ADAPTORS */
if (rep.num_adaptors == 0) {
pas = NULL;
} else {
size = rep.num_adaptors*sizeof(XvAdaptorInfo);
if ((pas=(XvAdaptorInfo *)Xmalloc(size))==NULL) {
Xfree(buffer);
UnlockDisplay(dpy);
SyncHandle();
return(XvBadAlloc);
/* If there's no adaptors, there's nothing more to do. */
status = Success;
goto out;
}
if (size < (rep.num_adaptors * sz_xvAdaptorInfo)) {
/* If there's not enough data for the number of adaptors,
then we have a problem. */
status = XvBadReply;
goto out;
}
size = rep.num_adaptors * sizeof(XvAdaptorInfo);
if ((pas = Xmalloc(size)) == NULL) {
status = XvBadAlloc;
goto out;
}
/* INIT ADAPTOR FIELDS */
pa = pas;
for (ii=0; ii<rep.num_adaptors; ii++) {
for (ii = 0; ii < rep.num_adaptors; ii++) {
pa->num_adaptors = 0;
pa->name = (char *)NULL;
pa->formats = (XvFormat *)NULL;
pa->name = (char *) NULL;
pa->formats = (XvFormat *) NULL;
pa++;
}
u.buffer = buffer;
pa = pas;
for (ii=0; ii<rep.num_adaptors; ii++) {
for (ii = 0; ii < rep.num_adaptors; ii++) {
pa->type = u.pa->type;
pa->base_id = u.pa->base_id;
pa->num_ports = u.pa->num_ports;
@ -238,40 +237,33 @@ XvQueryAdaptors(
/* GET ADAPTOR NAME */
size = u.pa->name_size;
u.buffer += (sz_xvAdaptorInfo + 3) & ~3;
u.buffer += pad_to_int32(sz_xvAdaptorInfo);
if ( (name = (char *)Xmalloc(size+1)) == NULL)
{
XvFreeAdaptorInfo(pas);
Xfree(buffer);
UnlockDisplay(dpy);
SyncHandle();
return(XvBadAlloc);
if ((name = Xmalloc(size + 1)) == NULL) {
status = XvBadAlloc;
goto out;
}
(void)strncpy(name, u.string, size);
(void) strncpy(name, u.string, size);
name[size] = '\0';
pa->name = name;
u.buffer += (size + 3) & ~3;
u.buffer += pad_to_int32(size);
/* GET FORMATS */
size = pa->num_formats*sizeof(XvFormat);
if ((pfs=(XvFormat *)Xmalloc(size))==NULL) {
XvFreeAdaptorInfo(pas);
Xfree(buffer);
UnlockDisplay(dpy);
SyncHandle();
return(XvBadAlloc);
size = pa->num_formats * sizeof(XvFormat);
if ((pfs = Xmalloc(size)) == NULL) {
status = XvBadAlloc;
goto out;
}
pf = pfs;
for (jj=0; jj<pa->num_formats; jj++) {
for (jj = 0; jj < pa->num_formats; jj++) {
pf->depth = u.pf->depth;
pf->visual_id = u.pf->visual;
pf++;
u.buffer += (sz_xvFormat + 3) & ~3;
u.buffer += pad_to_int32(sz_xvFormat);
}
pa->formats = pfs;
@ -280,6 +272,14 @@ XvQueryAdaptors(
}
status = Success;
out:
if (status != Success) {
XvFreeAdaptorInfo(pas);
pas = NULL;
}
*p_nAdaptors = rep.num_adaptors;
*p_pAdaptors = pas;
@ -287,29 +287,26 @@ XvQueryAdaptors(
UnlockDisplay(dpy);
SyncHandle();
return (Success);
return status;
}
void
XvFreeAdaptorInfo(XvAdaptorInfo *pAdaptors)
{
XvAdaptorInfo *pa;
int ii;
unsigned int ii;
if (!pAdaptors) return;
if (!pAdaptors)
return;
pa = pAdaptors;
for (ii=0; ii<pAdaptors->num_adaptors; ii++, pa++)
{
if (pa->name)
{
for (ii = 0; ii < pAdaptors->num_adaptors; ii++, pa++) {
if (pa->name) {
Xfree(pa->name);
}
if (pa->formats)
{
if (pa->formats) {
Xfree(pa->formats);
}
}
@ -322,21 +319,22 @@ XvQueryEncodings(
Display *dpy,
XvPortID port,
unsigned int *p_nEncodings,
XvEncodingInfo **p_pEncodings
){
XvEncodingInfo ** p_pEncodings)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvQueryEncodingsReq *req;
xvQueryEncodingsReply rep;
int size, jj;
size_t size;
unsigned int jj;
char *name;
XvEncodingInfo *pes, *pe;
char *buffer;
union
{
XvEncodingInfo *pes = NULL, *pe;
char *buffer = NULL;
union {
char *buffer;
char *string;
xvEncodingInfo *pe;
} u;
int status;
XvCheckExtension(dpy, info, XvBadExtension);
@ -347,43 +345,56 @@ XvQueryEncodings(
/* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy);
SyncHandle();
return(XvBadReply);
if (_XReply(dpy, (xReply *) &rep, 0, xFalse) == 0) {
rep.num_encodings = 0;
status = XvBadReply;
goto out;
}
size = rep.length << 2;
if ( (buffer = (char *)Xmalloc ((unsigned) size)) == NULL) {
UnlockDisplay(dpy);
SyncHandle();
return(XvBadAlloc);
if (size > 0) {
if ((buffer = Xmalloc(size)) == NULL) {
_XEatDataWords(dpy, rep.length);
status = XvBadAlloc;
goto out;
}
_XRead(dpy, buffer, (long) size);
}
_XRead (dpy, buffer, size);
u.buffer = buffer;
/* GET ENCODINGS */
size = rep.num_encodings*sizeof(XvEncodingInfo);
if ( (pes = (XvEncodingInfo *)Xmalloc(size)) == NULL) {
Xfree(buffer);
UnlockDisplay(dpy);
SyncHandle();
return(XvBadAlloc);
if (rep.num_encodings == 0) {
/* If there's no encodings, there's nothing more to do. */
status = Success;
goto out;
}
if (size < (rep.num_encodings * sz_xvEncodingInfo)) {
/* If there's not enough data for the number of adaptors,
then we have a problem. */
status = XvBadReply;
goto out;
}
size = rep.num_encodings * sizeof(XvEncodingInfo);
if ((pes = Xmalloc(size)) == NULL) {
status = XvBadAlloc;
goto out;
}
/* INITIALIZE THE ENCODING POINTER */
pe = pes;
for (jj=0; jj<rep.num_encodings; jj++) {
pe->name = (char *)NULL;
for (jj = 0; jj < rep.num_encodings; jj++) {
pe->name = (char *) NULL;
pe->num_encodings = 0;
pe++;
}
u.buffer = buffer;
pe = pes;
for (jj=0; jj<rep.num_encodings; jj++) {
for (jj = 0; jj < rep.num_encodings; jj++) {
pe->encoding_id = u.pe->encoding;
pe->width = u.pe->width;
pe->height = u.pe->height;
@ -392,21 +403,26 @@ XvQueryEncodings(
pe->num_encodings = rep.num_encodings - jj;
size = u.pe->name_size;
u.buffer += (sz_xvEncodingInfo + 3) & ~3;
u.buffer += pad_to_int32(sz_xvEncodingInfo);
if ( (name = (char *)Xmalloc(size+1)) == NULL) {
XvFreeEncodingInfo(pes);
Xfree(buffer);
UnlockDisplay(dpy);
SyncHandle();
return(XvBadAlloc);
if ((name = Xmalloc(size + 1)) == NULL) {
status = XvBadAlloc;
goto out;
}
strncpy(name, u.string, size);
name[size] = '\0';
pe->name = name;
pe++;
u.buffer += (size + 3) & ~3;
u.buffer += pad_to_int32(size);
}
status = Success;
out:
if (status != Success) {
XvFreeEncodingInfo(pes);
pes = NULL;
}
*p_nEncodings = rep.num_encodings;
@ -422,16 +438,17 @@ XvQueryEncodings(
void
XvFreeEncodingInfo(XvEncodingInfo *pEncodings)
{
XvEncodingInfo *pe;
int ii;
unsigned long ii;
if (!pEncodings) return;
if (!pEncodings)
return;
pe = pEncodings;
for (ii=0; ii<pEncodings->num_encodings; ii++, pe++) {
if (pe->name) Xfree(pe->name);
for (ii = 0; ii < pEncodings->num_encodings; ii++, pe++) {
if (pe->name)
Xfree(pe->name);
}
Xfree(pEncodings);
@ -446,8 +463,8 @@ XvPutVideo(
int vx, int vy,
unsigned int vw, unsigned int vh,
int dx, int dy,
unsigned int dw, unsigned int dh
){
unsigned int dw, unsigned int dh)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvPutVideoReq *req;
@ -486,8 +503,8 @@ XvPutStill(
int vx, int vy,
unsigned int vw, unsigned int vh,
int dx, int dy,
unsigned int dw, unsigned int dh
){
unsigned int dw, unsigned int dh)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvPutStillReq *req;
@ -525,8 +542,8 @@ XvGetVideo(
int vx, int vy,
unsigned int vw, unsigned int vh,
int dx, int dy,
unsigned int dw, unsigned int dh
){
unsigned int dw, unsigned int dh)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvGetVideoReq *req;
@ -564,8 +581,8 @@ XvGetStill(
int vx, int vy,
unsigned int vw, unsigned int vh,
int dx, int dy,
unsigned int dw, unsigned int dh
){
unsigned int dw, unsigned int dh)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvGetStillReq *req;
@ -595,11 +612,8 @@ XvGetStill(
}
int
XvStopVideo(
Display *dpy,
XvPortID port,
Drawable draw
){
XvStopVideo(Display *dpy, XvPortID port, Drawable draw)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvStopVideoReq *req;
@ -618,11 +632,8 @@ XvStopVideo(
}
int
XvGrabPort(
Display *dpy,
XvPortID port,
Time time
){
XvGrabPort(Display *dpy, XvPortID port, Time time)
{
XExtDisplayInfo *info = xv_find_display(dpy);
int result;
xvGrabPortReply rep;
@ -636,7 +647,7 @@ XvGrabPort(
req->port = port;
req->time = time;
if (_XReply (dpy, (xReply *) &rep, 0, xTrue) == 0)
if (_XReply(dpy, (xReply *) &rep, 0, xTrue) == 0)
rep.result = GrabSuccess;
result = rep.result;
@ -648,11 +659,8 @@ XvGrabPort(
}
int
XvUngrabPort(
Display *dpy,
XvPortID port,
Time time
){
XvUngrabPort(Display *dpy, XvPortID port, Time time)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvUngrabPortReq *req;
@ -671,11 +679,8 @@ XvUngrabPort(
}
int
XvSelectVideoNotify(
Display *dpy,
Drawable drawable,
Bool onoff
){
XvSelectVideoNotify(Display *dpy, Drawable drawable, Bool onoff)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvSelectVideoNotifyReq *req;
@ -694,11 +699,8 @@ XvSelectVideoNotify(
}
int
XvSelectPortNotify(
Display *dpy,
XvPortID port,
Bool onoff
){
XvSelectPortNotify(Display *dpy, XvPortID port, Bool onoff)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvSelectPortNotifyReq *req;
@ -717,12 +719,7 @@ XvSelectPortNotify(
}
int
XvSetPortAttribute (
Display *dpy,
XvPortID port,
Atom attribute,
int value
)
XvSetPortAttribute(Display *dpy, XvPortID port, Atom attribute, int value)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvSetPortAttributeReq *req;
@ -743,16 +740,12 @@ XvSetPortAttribute (
}
int
XvGetPortAttribute (
Display *dpy,
XvPortID port,
Atom attribute,
int *p_value
)
XvGetPortAttribute(Display *dpy, XvPortID port, Atom attribute, int *p_value)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvGetPortAttributeReq *req;
xvGetPortAttributeReply rep;
int status;
XvCheckExtension(dpy, info, XvBadExtension);
@ -764,18 +757,18 @@ XvGetPortAttribute (
/* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy);
SyncHandle();
return(XvBadReply);
if (_XReply(dpy, (xReply *) &rep, 0, xFalse) == 0) {
status = XvBadReply;
}
else {
*p_value = rep.value;
status = Success;
}
*p_value = rep.value;
UnlockDisplay(dpy);
SyncHandle();
return (Success);
return status;
}
int
@ -788,12 +781,12 @@ XvQueryBestSize(
unsigned int drw_w,
unsigned int drw_h,
unsigned int *p_actual_width,
unsigned int *p_actual_height
)
unsigned int *p_actual_height)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvQueryBestSizeReq *req;
xvQueryBestSizeReply rep;
int status;
XvCheckExtension(dpy, info, XvBadExtension);
@ -809,23 +802,23 @@ XvQueryBestSize(
/* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy);
SyncHandle();
return(XvBadReply);
if (_XReply(dpy, (xReply *) &rep, 0, xFalse) == 0) {
status = XvBadReply;
}
else {
*p_actual_width = rep.actual_width;
*p_actual_height = rep.actual_height;
status = Success;
}
UnlockDisplay(dpy);
SyncHandle();
return (Success);
return status;
}
XvAttribute*
XvAttribute *
XvQueryPortAttributes(Display *dpy, XvPortID port, int *num)
{
XExtDisplayInfo *info = xv_find_display(dpy);
@ -844,10 +837,8 @@ XvQueryPortAttributes(Display *dpy, XvPortID port, int *num)
/* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy);
SyncHandle();
return ret;
if (_XReply(dpy, (xReply *) &rep, 0, xFalse) == 0) {
goto out;
}
/*
@ -861,26 +852,28 @@ XvQueryPortAttributes(Display *dpy, XvPortID port, int *num)
* and free it as a single/simple buffer.
*/
if(rep.num_attributes) {
if (rep.num_attributes) {
unsigned long size;
/* limit each part to no more than one half the max size */
if ((rep.num_attributes < ((INT_MAX / 2) / sizeof(XvAttribute))) &&
(rep.text_size < (INT_MAX / 2)-1)) {
size = (rep.num_attributes * sizeof(XvAttribute)) + rep.text_size + 1;
(rep.text_size < (INT_MAX / 2) - 1)) {
size = (rep.num_attributes * sizeof(XvAttribute)) +
rep.text_size + 1;
ret = Xmalloc(size);
}
if (ret != NULL) {
char* marker = (char*)(&ret[rep.num_attributes]);
char *marker = (char *) (&ret[rep.num_attributes]);
xvAttributeInfo Info;
int i;
unsigned int i;
/* keep track of remaining room for text strings */
size = rep.text_size;
for(i = 0; i < rep.num_attributes; i++) {
_XRead(dpy, (char*)(&Info), sz_xvAttributeInfo);
ret[i].flags = (int)Info.flags;
for (i = 0; i < rep.num_attributes; i++) {
_XRead(dpy, (char *) (&Info), sz_xvAttributeInfo);
ret[i].flags = (int) Info.flags;
ret[i].min_value = Info.min;
ret[i].max_value = Info.max;
ret[i].name = marker;
@ -895,21 +888,21 @@ XvQueryPortAttributes(Display *dpy, XvPortID port, int *num)
/* ensure final string is nil-terminated to avoid exposure of
uninitialized memory */
*marker = '\0';
} else
}
else
_XEatDataWords(dpy, rep.length);
}
out:
UnlockDisplay(dpy);
SyncHandle();
return ret;
}
XvImageFormatValues * XvListImageFormats (
Display *dpy,
XvPortID port,
int *num
){
XvImageFormatValues *
XvListImageFormats(Display *dpy, XvPortID port, int *num)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvListImageFormatsReq *req;
xvListImageFormatsReply rep;
@ -926,22 +919,20 @@ XvImageFormatValues * XvListImageFormats (
/* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy);
SyncHandle();
return NULL;
if (_XReply(dpy, (xReply *) &rep, 0, xFalse) == 0) {
goto out;
}
if(rep.num_formats) {
if (rep.num_formats) {
if (rep.num_formats < (INT_MAX / sizeof(XvImageFormatValues)))
ret = Xmalloc(rep.num_formats * sizeof(XvImageFormatValues));
if (ret != NULL) {
xvImageFormatInfo Info;
int i;
unsigned int i;
for(i = 0; i < rep.num_formats; i++) {
_XRead(dpy, (char*)(&Info), sz_xvImageFormatInfo);
for (i = 0; i < rep.num_formats; i++) {
_XRead(dpy, (char *) (&Info), sz_xvImageFormatInfo);
ret[i].id = Info.id;
ret[i].type = Info.type;
ret[i].byte_order = Info.byte_order;
@ -966,24 +957,27 @@ XvImageFormatValues * XvListImageFormats (
ret[i].scanline_order = Info.scanline_order;
(*num)++;
}
} else
}
else
_XEatDataWords(dpy, rep.length);
}
out:
UnlockDisplay(dpy);
SyncHandle();
return ret;
}
XvImage * XvCreateImage (
XvImage *
XvCreateImage(
Display *dpy,
XvPortID port,
int id,
char *data,
int width,
int height
) {
int height)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvQueryImageAttributesReq *req;
xvQueryImageAttributesReply rep;
@ -1001,10 +995,8 @@ XvImage * XvCreateImage (
/* READ THE REPLY */
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return NULL;
if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
goto out;
}
if (rep.num_planes < ((INT_MAX >> 3) - sizeof(XvImage)))
@ -1016,57 +1008,58 @@ XvImage * XvCreateImage (
ret->height = rep.height;
ret->data_size = rep.data_size;
ret->num_planes = rep.num_planes;
ret->pitches = (int*)(&ret[1]);
ret->pitches = (int *) (&ret[1]);
ret->offsets = ret->pitches + rep.num_planes;
ret->data = data;
ret->obdata = NULL;
_XRead(dpy, (char*)(ret->pitches), rep.num_planes << 2);
_XRead(dpy, (char*)(ret->offsets), rep.num_planes << 2);
} else
_XRead(dpy, (char *) (ret->pitches), rep.num_planes << 2);
_XRead(dpy, (char *) (ret->offsets), rep.num_planes << 2);
}
else
_XEatDataWords(dpy, rep.length);
out:
UnlockDisplay(dpy);
SyncHandle();
return ret;
}
XvImage * XvShmCreateImage (
XvImage *
XvShmCreateImage(
Display *dpy,
XvPortID port,
int id,
char *data,
int width,
int height,
XShmSegmentInfo *shminfo
){
XShmSegmentInfo *shminfo)
{
XvImage *ret;
ret = XvCreateImage(dpy, port, id, data, width, height);
if(ret) ret->obdata = (XPointer)shminfo;
if (ret)
ret->obdata = (XPointer) shminfo;
return ret;
}
int XvPutImage (
int
XvPutImage(
Display *dpy,
XvPortID port,
Drawable d,
GC gc,
XvImage *image,
int src_x,
int src_y,
unsigned int src_w,
unsigned int src_h,
int dest_x,
int dest_y,
unsigned int dest_w,
unsigned int dest_h
){
int src_x, int src_y,
unsigned int src_w, unsigned int src_h,
int dest_x, int dest_y,
unsigned int dest_w, unsigned int dest_h)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvPutImageReq *req;
int len;
unsigned int len;
XvCheckExtension(dpy, info, XvBadExtension);
@ -1091,14 +1084,14 @@ int XvPutImage (
req->width = image->width;
req->height = image->height;
len = (image->data_size + 3) >> 2;
len = ((unsigned int) image->data_size + 3) >> 2;
SetReqLen(req, len, len);
/* Yes it's kindof lame that we are sending the whole thing,
but for video all of it may be needed even if displaying
only a subsection, and I don't want to go through the
trouble of creating subregions to send */
Data(dpy, (char *)image->data, image->data_size);
Data(dpy, (char *) image->data, image->data_size);
UnlockDisplay(dpy);
SyncHandle();
@ -1106,24 +1099,21 @@ int XvPutImage (
return Success;
}
int XvShmPutImage (
int
XvShmPutImage(
Display *dpy,
XvPortID port,
Drawable d,
GC gc,
XvImage *image,
int src_x,
int src_y,
unsigned int src_w,
unsigned int src_h,
int dest_x,
int dest_y,
unsigned int dest_w,
unsigned int dest_h,
Bool send_event
){
int src_x, int src_y,
unsigned int src_w, unsigned int src_h,
int dest_x, int dest_y,
unsigned int dest_w, unsigned int dest_h,
Bool send_event)
{
XExtDisplayInfo *info = xv_find_display(dpy);
XShmSegmentInfo *shminfo = (XShmSegmentInfo *)image->obdata;
XShmSegmentInfo *shminfo = (XShmSegmentInfo *) image->obdata;
xvShmPutImageReq *req;
XvCheckExtension(dpy, info, XvBadExtension);
@ -1163,17 +1153,15 @@ static Bool
xv_wire_to_event(Display *dpy, XEvent *host, xEvent *wire)
{
XExtDisplayInfo *info = xv_find_display(dpy);
XvEvent *re = (XvEvent *)host;
xvEvent *event = (xvEvent *)wire;
XvEvent *re = (XvEvent *) host;
xvEvent *event = (xvEvent *) wire;
XvCheckExtension(dpy, info, False);
switch((event->u.u.type & 0x7F) - info->codes->first_event)
{
switch ((event->u.u.type & 0x7F) - info->codes->first_event) {
case XvVideoNotify:
re->xvvideo.type = event->u.u.type & 0x7f;
re->xvvideo.serial =
_XSetLastRequestRead(dpy, (xGenericReply *)event);
re->xvvideo.serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
re->xvvideo.send_event = ((event->u.u.type & 0x80) != 0);
re->xvvideo.display = dpy;
re->xvvideo.time = event->u.videoNotify.time;
@ -1183,8 +1171,7 @@ xv_wire_to_event(Display *dpy, XEvent *host, xEvent *wire)
break;
case XvPortNotify:
re->xvport.type = event->u.u.type & 0x7f;
re->xvport.serial =
_XSetLastRequestRead(dpy, (xGenericReply *)event);
re->xvport.serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
re->xvport.send_event = ((event->u.u.type & 0x80) != 0);
re->xvport.display = dpy;
re->xvport.time = event->u.portNotify.time;
@ -1198,5 +1185,3 @@ xv_wire_to_event(Display *dpy, XEvent *host, xEvent *wire)
return (True);
}

View File

@ -44,30 +44,12 @@ SOFTWARE.
#include <X11/extensions/Xvproto.h>
#include <X11/extensions/Xvlib.h>
#if !defined(UNIXCPP)
#define XvGetReq(name, req) \
WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(xv##name##Req)) > dpy->bufmax)\
_XFlush(dpy);\
req = (xv##name##Req *)(dpy->last_req = dpy->bufptr);\
req->reqType = info->codes->major_opcode;\
req->xvReqType = xv_##name; \
req->length = (SIZEOF(xv##name##Req))>>2;\
dpy->bufptr += SIZEOF(xv##name##Req);\
dpy->request++
/* names in Xvproto.h don't match the expectation of Xlib's GetReq* macros,
so we have to provide our own implementation */
#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
#define XvGetReq(name, req) \
WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(xv/**/name/**/Req)) > dpy->bufmax)\
_XFlush(dpy);\
req = (xv/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
req->reqType = info->codes->major_opcode;\
req->xvReqType = xv_/**/name;\
req->length = (SIZEOF(xv/**/name/**/Req))>>2;\
dpy->bufptr += SIZEOF(xv/**/name/**/Req);\
dpy->request++
#endif
req = (xv##name##Req *) _XGetRequest( \
dpy, (CARD8) info->codes->major_opcode, SIZEOF(xv##name##Req)); \
req->xvReqType = xv_##name;
#endif /* XVLIBINT_H */