Commit d615e3bb authored by Stephane Glondu's avatar Stephane Glondu

Updated version 0.3.0 from 'upstream/0.3.0'

with Debian dir 8e052e08c6fa14eb064e87c8780aacf464541181
parents 8234e45a 01882a62
0.3.0 (03-08-2015)
=====
* Add support for S16BE, S24LE and S32LE
* Fix deprecated APIs
0.2.1 (2013-02-18)
=====
* Add pulseaudio backend.
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
AC_INIT([ocaml-mm],[0.2.1],[savonet-users@lists.sourceforge.net])
AC_INIT([ocaml-mm],[0.3.0],[savonet-users@lists.sourceforge.net])
VERSION=$PACKAGE_VERSION
AC_MSG_RESULT(configuring $PACKAGE_STRING)
......@@ -78,6 +78,10 @@ if test "x$enable_v4l" != "xno" ; then
AC_CHECK_HEADERS([linux/videodev.h],[W_V4L="yes"],[W_V4L="no"])
fi
# Bytes
AC_CHECK_OCAML_BINDING([bytes],[],[],[1])
INCDIRS="$INCDIRS `$OCAMLFIND query bytes`"
AC_SUBST(W_V4L)
AC_SUBST(VERSION)
AC_SUBST(INCDIRS)
......
......@@ -3,7 +3,7 @@ module Img = Image.RGBA32
let read_PPM ?alpha fname =
let ic = open_in_bin fname in
let len = in_channel_length ic in
let data = String.create len in
let data = Bytes.create len in
really_input ic data 0 len;
close_in ic;
Img.of_PPM ?alpha data
......
......@@ -3,7 +3,7 @@ module Img = Image.RGBA32
let read_PPM ?alpha fname =
let ic = open_in_bin fname in
let len = in_channel_length ic in
let data = String.create len in
let data = Bytes.create len in
really_input ic data 0 len;
close_in ic;
Img.of_PPM ?alpha data
......
#LIBS = $(shell find . -maxdepth 1 -type d | sed "s/^\.\///" | grep -v "\.")
ifeq "yes" "yes"
ifeq "no" "yes"
LIBS += alsa
endif
ifeq "yes" "yes"
ifeq "no" "yes"
LIBS += ao
endif
ifeq "yes" "yes"
ifeq "no" "yes"
LIBS += ffmpeg
endif
ifeq "yes" "yes"
ifeq "no" "yes"
LIBS += gstreamer
endif
ifeq "yes" "yes"
ifeq "no" "yes"
LIBS += mad
endif
ifeq "yes" "yes"
LIBS += oss
endif
ifeq "yes" "yes"
ifeq "no" "yes"
LIBS += sdl
endif
ifeq "yes" "yes"
ifeq "no" "yes"
# LIBS += theora
endif
ifeq "no" "yes"
......
OCAMLFLAGS = -g -w +A@5-7@8@11@12@20-35-44-45
OCAMLNCFLAGS =
OCAMLLDFLAGS = -linkall
CFLAGS = -g -O2 -I.. -g -Wall -O3
INCDIRS = .. /home/toots/.opam/system/lib/ogg /home/toots/.opam/system/lib/bytes
NO_CUSTOM = yes
OCAMLDOCFLAGS = -sort -stars
ANNOTATE = yes
OCAMLMAKEFILE = OCamlMakefile
OCAMLFIND = ocamlfind
OCAMLFIND_LDCONF =
OCAMLC = ocamlc
OCAMLOPT = ocamlopt
OCAMLMKTOP = ocamlmktop
OCAMLMKLIB = ocamlmklib
OCAMLCP = @OCAMLCP@
OCAMLDEP = ocamldep
OCAMLLEX = ocamllex
OCAMLYACC = ocamlyacc
OCAMLDOC = ocamldoc
CC = gcc
AR = ar
LATEX = @LATEX@
DVIPS = @DVIPS@
PS2PDF = @PS2PDF@
OCAMLLIBPATH = /usr/lib/ocaml
OCAMLBEST = byte opt
INCDIRS+= .. /home/toots/.opam/system/lib/ogg /home/toots/.opam/system/lib/bytes
......@@ -56,7 +56,7 @@ object (self)
let f =
Mad.openstream
(fun n ->
let s = String.create n in
let s = Bytes.create n in
let n = self#stream_read s 0 n in
s, n)
in
......
......@@ -80,7 +80,7 @@ object (self)
method read buf ofs len =
let slen = Audio.S16LE.length channels len in
let s = String.create slen in
let s = Bytes.create slen in
let r = self#stream_read s 0 slen in
let len = Audio.S16LE.duration channels r in
Audio.S16LE.to_audio s 0 buf ofs len;
......
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2011-01-19.21; # UTC
scriptversion=2011-11-20.07; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
......@@ -35,7 +35,7 @@ scriptversion=2011-01-19.21; # UTC
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
......@@ -156,7 +156,7 @@ while test $# -ne 0; do
-s) stripcmd=$stripprog;;
-t) dst_arg=$2
# Protect names problematic for `test' and other utilities.
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
......@@ -190,7 +190,7 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
fi
shift # arg
dst_arg=$arg
# Protect names problematic for `test' and other utilities.
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
......@@ -202,7 +202,7 @@ if test $# -eq 0; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
......@@ -240,7 +240,7 @@ fi
for src
do
# Protect names problematic for `test' and other utilities.
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
......@@ -354,7 +354,7 @@ do
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writeable bit of parent directory when it shouldn't.
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
......
......@@ -97,6 +97,11 @@ AC_DEFUN([AC_PROG_OCAML],
AC_CHECK_TOOL_STRICT([OCAMLDEP],[ocamldep],[no])
if test "$OCAMLDEP" = "no"; then
AC_MSG_ERROR(Cannot find ocamlmklib.)
else
AC_CHECK_TOOL_STRICT([OCAMLDEPOPT],[ocamldep.opt],[no])
if test "$OCAMLDEPOPT" != "no"; then
OCAMLDEP=$OCAMLDEPOPT
fi
fi
AC_SUBST([OCAMLDEP])
......@@ -116,6 +121,12 @@ AC_DEFUN([AC_PROG_OCAML],
# checking for ocamldoc
AC_CHECK_TOOL([OCAMLDOC],[ocamldoc],[no])
if test "$OCAMLDOC" != "no"; then
AC_CHECK_TOOL([OCAMLDOCOPT],[ocamldoc.opt],[no])
if test "$OCAMLDOCOPT" != "no"; then
OCAMLDOC=$OCAMLDOCOPT
fi
fi
AC_SUBST([OCAMLDOC])
......@@ -198,6 +209,11 @@ AC_DEFUN([AC_PROG_CAMLP4],
AC_SUBST([CAMLP4RF])
])
AC_DEFUN([AC_PROG_CAMLIDL],
[dnl
AC_CHECK_TOOL(CAMLIDL,camlidl,no)
AC_SUBST(CAMLIDL)
])
AC_DEFUN([AC_PROG_FINDLIB],
[dnl
......@@ -208,6 +224,15 @@ AC_DEFUN([AC_PROG_FINDLIB],
AC_SUBST([OCAMLFIND])
])
AC_DEFUN([AC_CHECK_OCAML_STDLIB],
[dnl
AC_REQUIRE([AC_PROG_FINDLIB])dnl
AC_MSG_CHECKING([for ocaml standard library path])
OCAML_STDLIB=`$OCAMLFIND printconf stdlib`
AC_SUBST(OCAML_STDLIB)
AC_MSG_RESULT([$OCAML_STDLIB])
])
dnl Thanks to Jim Meyering for working this next bit out for us.
dnl XXX We should define AS_TR_SH if it's not defined already
......
......@@ -11,8 +11,7 @@ AC_SUBST(OCAMLFIND_LDCONF)
AC_PROG_OCAML()
AC_CHECK_TOOL(CAMLIDL,camlidl,no)
AC_SUBST(CAMLIDL)
AC_PROG_CAMLIDL()
AC_PROG_OCAMLLEX()
......@@ -22,6 +21,8 @@ AC_PROG_CAMLP4()
AC_PROG_FINDLIB()
AC_CHECK_OCAML_STDLIB()
# Check if caml/threads.h is present
AC_CHECK_HEADER([caml/threads.h],[CAML_THREADS=yes],[],[#include <caml/misc.h>])
......@@ -30,10 +31,21 @@ AC_ARG_ENABLE([debugging],
[--disable-debugging],
[disable debugging information (backtrace printing in particular)]))
if test "x$enable_debugging" = "xyes" ; then
if test "$enable_debugging" \!= "no" ; then
OCAMLFLAGS="$OCAMLFLAGS -g"
fi
AC_ARG_WITH([ocaml-warnings],
AC_HELP_STRING(
[--with-ocaml-warnings=WARNINGS],
[Enable specific list of ocaml compiler warnings.]))
if test -n "${with_ocaml_warnings}" ; then
OCAMLFLAGS="$OCAMLFLAGS -w +${with_ocaml_warnings}"
else
OCAMLFLAGS="$OCAMLFLAGS -w +A@5-7@8@11@12@20-35-44-45"
fi
AC_ARG_ENABLE([profiling],
AC_HELP_STRING(
[--enable-profiling],
......
......@@ -44,6 +44,8 @@ if test -n "$PKG_CONFIG"; then
fi[]dnl
])dnl PKG_PROG_PKG_CONFIG
AC_ARG_VAR([PKG_CONFIG_OPTIONS], [Additional options passed when invoking pkg-config])
dnl PKG_CONFIG_CHECK_MODULE([name],[min-version])
dnl min-version is optional
AC_DEFUN([PKG_CONFIG_CHECK_MODULE],
......@@ -53,12 +55,12 @@ else
PKGCONFIG_CHECK_VERSION=""
fi
AC_MSG_CHECKING([whether pkg-config knows about $1${PKGCONFIG_CHECK_VERSION}])
if ! $PKG_CONFIG --exists $1; then
if ! $PKG_CONFIG $PKG_CONFIG_OPTIONS --exists $1; then
AC_MSG_ERROR([$1.pc not found.. Do you need to set PKG_CONFIG_PATH?])
else
if test -n "$2"; then
if ! $PKG_CONFIG --atleast-version=$2 $1; then
$1_VERSION="`pkg-config --modversion $1`"
if ! $PKG_CONFIG $PKG_CONFIG_OPTIONS --atleast-version=$2 $1; then
$1_VERSION="`$PKG_CONFIG $PKG_CONFIG_OPTIONS --modversion $1`"
AC_MSG_ERROR([requires version >= $2, found ${$1_VERSION}])
else
AC_MSG_RESULT([ok])
......@@ -67,8 +69,8 @@ else
AC_MSG_RESULT([ok])
fi
fi
CFLAGS="$CFLAGS `$PKG_CONFIG --cflags $1`"
CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags $1`"
LIBS="$LIBS `$PKG_CONFIG --libs-only-l $1`"
LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs-only-L $1`"
CFLAGS="$CFLAGS `$PKG_CONFIG $PKG_CONFIG_OPTIONS --cflags $1`"
CPPFLAGS="$CPPFLAGS `$PKG_CONFIG $PKG_CONFIG_OPTIONS --cflags $1`"
LIBS="$LIBS `$PKG_CONFIG $PKG_CONFIG_OPTIONS --libs-only-l $1`"
LDFLAGS="$LDFLAGS `$PKG_CONFIG $PKG_CONFIG_OPTIONS --libs-only-L $1`"
])
......@@ -68,7 +68,7 @@ object (self)
method virtual private stream_read : string -> int -> int -> int
method private input_once n =
let buf = String.create n in
let buf = Bytes.create n in
let n = self#stream_read buf 0 n in
if n = String.length buf then
buf
......@@ -126,7 +126,7 @@ object (self)
assert (self#stream_write s 0 len = len)
method private output_num b n =
let s = String.create b in
let s = Bytes.create b in
for i = 0 to b - 1 do
s.[i] <- char_of_int ((n lsr (8 * i)) land 0xff)
done;
......@@ -139,7 +139,7 @@ object (self)
method private output_int n = self#output_num 4 n
method private output_num_be b n =
let s = String.create b in
let s = Bytes.create b in
for i = 0 to b - 1 do
s.[i] <- char_of_int ((n lsr (8 * (b - i - 1))) land 0xff)
done;
......
......@@ -98,7 +98,7 @@ let byte_of_float x =
char_of_int (clip (int_of_float (x *. 127.)))
let encode_event chan e =
let s = String.create 3 in
let s = Bytes.create 3 in
let coi = char_of_int in
let bof = byte_of_float in
(
......@@ -150,7 +150,7 @@ let clear buf ofs len =
(* complement of clear *)
let extract buf ofs len =
if not (ofs = 0 && len = duration buf) then
buf.data <- List.filter (fun (t,_) -> ofs <= t & t < ofs + len) buf.data
buf.data <- List.filter (fun (t,_) -> ofs <= t && t < ofs + len) buf.data
let cmp te1 te2 = fst te1 - fst te2
......@@ -286,7 +286,7 @@ module IO = struct
data.(!pos - 1)
in
let get_text len =
let ans = String.create len in
let ans = Bytes.create len in
if !pos + len >= Array.length data then raise Invalid_data;
for i = 0 to len - 1 do
ans.[i] <- char_of_int data.(!pos + i)
......
......@@ -953,13 +953,47 @@ module S16LE = struct
let make buf ofs len =
let slen = length (channels buf) len in
let sbuf = String.create slen in
let sbuf = Bytes.create slen in
of_audio buf ofs sbuf 0 len;
sbuf
external to_audio : string -> int -> float array array -> int -> int -> unit = "caml_float_pcm_convert_s16le_byte" "caml_float_pcm_convert_s16le_native"
end
module S16BE = struct
let length channels samples = channels * samples * 2
let duration channels len = len / (2 * channels)
external of_audio :
float array array -> int -> string -> int -> int -> unit
= "caml_float_pcm_to_s16be"
let make buf ofs len =
let slen = length (channels buf) len in
let sbuf = Bytes.create slen in
of_audio buf ofs sbuf 0 len;
sbuf
external to_audio : string -> int -> float array array -> int -> int -> unit = "caml_float_pcm_convert_s16be_byte" "caml_float_pcm_convert_s16be_native"
end
module S24LE = struct
external of_audio :
float array array -> int -> string -> int -> int -> unit
= "caml_float_pcm_to_s24le"
external to_audio : string -> int -> float array array -> int -> int -> unit = "caml_float_pcm_convert_s24le_byte" "caml_float_pcm_convert_s24le_native"
end
module S32LE = struct
external of_audio :
float array array -> int -> string -> int -> int -> unit
= "caml_float_pcm_to_s32le"
external to_audio : string -> int -> float array array -> int -> int -> unit = "caml_float_pcm_convert_s32le_byte" "caml_float_pcm_convert_s32le_native"
end
let add b1 o1 b2 o2 len = iter2 (fun b1 b2 -> Mono.add b1 o1 b2 o2 len) b1 b2
let add_coeff b1 o1 k b2 o2 len = iter2 (fun b1 b2 -> Mono.add_coeff b1 o1 k b2 o2 len) b1 b2
......
......@@ -33,8 +33,10 @@
(** Operations on audio data. *)
(** At given sample rate, number of samples in given amount of time. *)
val samples_of_seconds : int -> float -> int
(** At given sample rate, duration of given number of samples. *)
val seconds_of_samples : int -> int -> float
(** Convert decibels to linear coefficient. *)
......@@ -96,6 +98,8 @@ module Mono : sig
(** Clear a portion of a buffer (fill it with zeroes). *)
val clear : buffer -> int -> int -> unit
val amplify : float -> buffer -> int -> int -> unit
val resample : ?mode:[`Nearest | `Linear] -> float -> buffer -> int -> int -> buffer
val clip : buffer -> int -> int -> unit
......@@ -317,6 +321,30 @@ module S16LE : sig
val to_audio : string -> int -> buffer -> int -> int -> unit
end
module S16BE : sig
val length : int -> int -> int
val duration : int -> int -> int
val of_audio : buffer -> int -> string -> int -> int -> unit
val make : buffer -> int -> int -> string
val to_audio : string -> int -> buffer -> int -> int -> unit
end
module S24LE : sig
val of_audio : buffer -> int -> string -> int -> int -> unit
val to_audio : string -> int -> buffer -> int -> int -> unit
end
module S32LE : sig
val of_audio : buffer -> int -> string -> int -> int -> unit
val to_audio : string -> int -> buffer -> int -> int -> unit
end
val resample : ?mode:[`Nearest | `Linear] -> float -> buffer -> int -> int -> buffer
(** Same as [Array.blit] for audio data. *)
......
This diff is collapsed.
......@@ -796,42 +796,48 @@ CAMLprim value caml_rgb_to_bmp(value _rgb)
frame rgb;
frame_of_value(_rgb,&rgb);
int len = Rgb_num_pix(&rgb);
char *bmp = malloc(54 + 3 * len);
char *bmp = malloc(122 + 4 * len);
if (bmp == NULL) caml_raise_out_of_memory();
int i, j;
unsigned char a;
caml_enter_blocking_section();
bmp[0]='B'; /* Magic number */
bmp[1]='M';
bmp_pint32(bmp+2 , 54 + 3 * len); /* File size */
bmp_pint32(bmp+2 , 122 + 4 * len);/* File size */
bmp_pint16(bmp+6 , 0); /* Reserved */
bmp_pint16(bmp+8 , 0); /* Reserved */
bmp_pint32(bmp+10, 54); /* Data offset */
bmp_pint32(bmp+14, 40); /* Second header size */
bmp_pint32(bmp+18, rgb.width); /* Width */
bmp_pint32(bmp+22, rgb.height); /* Height */
bmp_pint32(bmp+10, 122); /* Data offset */
bmp_pint32(bmp+14, 108); /* Second header size */
bmp_pint32(bmp+18, rgb.width); /* Width */
bmp_pint32(bmp+22, rgb.height); /* Height */
bmp_pint16(bmp+26, 1); /* Nb of color planes */
bmp_pint16(bmp+28, 24); /* BPP */
bmp_pint32(bmp+30, 0); /* Compression */
bmp_pint32(bmp+34, 3 * len); /* Image size */
bmp_pint32(bmp+38, 2834); /* Horizontal resolution */
bmp_pint32(bmp+42, 2834); /* Vertical resolution */
bmp_pint16(bmp+28, 32); /* BPP */
bmp_pint32(bmp+30, 3); /* Compression: bitfields */
bmp_pint32(bmp+34, 4 * len); /* Image size */
bmp_pint32(bmp+38, 2835); /* Horizontal resolution */
bmp_pint32(bmp+42, 2835); /* Vertical resolution */
bmp_pint32(bmp+46, 0); /* Number of colors */
bmp_pint32(bmp+50, 0); /* Number of important colors */
bmp_pint32(bmp+54, 0x00ff0000); /* Red mask */
bmp_pint32(bmp+58, 0x0000ff00); /* Green mask */
bmp_pint32(bmp+62, 0x000000ff); /* Blue mask */
bmp_pint32(bmp+66, 0xff000000); /* Alpha mask */
bmp_pint32(bmp+70, 0x57696e20); /* Type of color space */
for(i = 0; i < 12; i++)
bmp_pint32(bmp+74+4*i, 0); /* Unused */
for(j = 0; j < rgb.height; j++)
for(i = 0; i < rgb.width; i++)
{
a = Alpha(&rgb, i, j);
bmp[3 * ((rgb.height - j - 1) * rgb.width + i) + 0 + 54] = Blue(&rgb, i, j) * a / 0xff;
bmp[3 * ((rgb.height - j - 1) * rgb.width + i) + 1 + 54] = Green(&rgb, i, j) * a / 0xff;
bmp[3 * ((rgb.height - j - 1) * rgb.width + i) + 2 + 54] = Red(&rgb, i, j) * a / 0xff;
bmp[4 * ((rgb.height - j - 1) * rgb.width + i) + 0 + 122] = Blue(&rgb, i, j);
bmp[4 * ((rgb.height - j - 1) * rgb.width + i) + 1 + 122] = Green(&rgb, i, j);
bmp[4 * ((rgb.height - j - 1) * rgb.width + i) + 2 + 122] = Red(&rgb, i, j);
bmp[4 * ((rgb.height - j - 1) * rgb.width + i) + 3 + 122] = Alpha(&rgb, i, j);
}
caml_leave_blocking_section();
ans = caml_alloc_string(54 + 3 * len);
memcpy(String_val(ans), bmp, 54 + 3 * len);
ans = caml_alloc_string(122 + 4 * len);
memcpy(String_val(ans), bmp, 122 + 4 * len);
free(bmp);
CAMLreturn(ans);
......
#include <caml/bigarray.h>
#include <stdint.h>
typedef struct
{
int width; /* Width in pixels */
......@@ -23,7 +25,7 @@ typedef struct
#define Is_outside(rgb,i,j) (i<0||j<0||i>=(rgb)->width||j>=(rgb)->height)
#define Space_clip_color(rgb,c,i,j) (Is_outside(rgb,i,j))?0:Color(rgb,c,i,j)
//For copying pixel by pixel
#define Int_pixel(rgb,i,j) (((uint32*)(rgb)->data)[i + j * ((rgb)->stride/4)])
#define Int_pixel(rgb,i,j) (((uint32_t*)(rgb)->data)[i + j * ((rgb)->stride/4)])
#ifndef BIGENDIAN
#define rshift 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment