--- ./libavcodec/Makefile.ORG Mon Sep 29 00:26:39 2003 +++ ./libavcodec/Makefile Sat Sep 25 02:37:00 2004 @@ -7,7 +7,7 @@ VPATH=$(SRC_PATH)/libavcodec # NOTE: -I.. is needed to include config.h -CFLAGS= $(OPTFLAGS) -Wall -DHAVE_AV_CONFIG_H -I.. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE +CFLAGS= $(OPTFLAGS) $(PIC) -Wall -DHAVE_AV_CONFIG_H -I.. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE OBJS= common.o utils.o mem.o allcodecs.o \ mpegvideo.o jrevdct.o jfdctfst.o jfdctint.o\ @@ -229,8 +229,8 @@ ifeq ($(CONFIG_WIN32),yes) install -s -m 755 $(SLIB) "$(prefix)" else - install -d $(prefix)/lib - install -s -m 755 $(SLIB) $(prefix)/lib/libavcodec-$(VERSION).so + $(INSTALL) -d $(prefix)/lib + $(INSTALL) -s -m 755 $(SLIB) $(prefix)/lib/libavcodec-$(VERSION).so ln -sf libavcodec-$(VERSION).so $(prefix)/lib/libavcodec.so ldconfig || true endif @@ -239,11 +239,11 @@ endif installlib: all install-headers - install -m 644 $(LIB) $(prefix)/lib + $(INSTALL) -m 644 $(LIB) $(prefix)/lib install-headers: mkdir -p "$(prefix)/include/ffmpeg" - install -m 644 $(SRC_PATH)/libavcodec/avcodec.h $(SRC_PATH)/libavcodec/common.h \ + $(INSTALL) -m 644 $(SRC_PATH)/libavcodec/avcodec.h $(SRC_PATH)/libavcodec/common.h \ "$(prefix)/include/ffmpeg" # --- ./libavcodec/resample.c.ORG Mon Sep 29 00:26:39 2003 +++ ./libavcodec/resample.c Sat Sep 25 02:47:57 2004 @@ -23,6 +23,7 @@ */ #include "avcodec.h" +#include "dsputil.h" typedef struct { /* fractional resampling */ --- ./libavformat/Makefile.ORG Mon Sep 29 00:26:40 2003 +++ ./libavformat/Makefile Sat Sep 25 04:02:47 2004 @@ -43,6 +43,10 @@ OBJS+= audio.o endif +ifeq ($(CONFIG_AUDIO_SUN),yes) +OBJS+= sunaudio.o +endif + ifeq ($(CONFIG_AUDIO_BEOS),yes) PPOBJS+= beosaudio.o EXTRALIBS+=-lbe -lmedia @@ -92,8 +96,8 @@ ifeq ($(CONFIG_WIN32),yes) install -s -m 755 $(SLIB) "$(prefix)" else - install -d $(prefix)/lib - install -s -m 755 $(SLIB) $(prefix)/lib/libavformat-$(VERSION).so + $(INSTALL) -d $(prefix)/lib + $(INSTALL) -s -m 755 $(SLIB) $(prefix)/lib/libavformat-$(VERSION).so ln -sf libavformat-$(VERSION).so $(prefix)/lib/libavformat.so ldconfig || true endif @@ -102,11 +106,11 @@ endif installlib: all install-headers - install -m 644 $(LIB) $(prefix)/lib + $(INSTALL) -m 644 $(LIB) $(prefix)/lib install-headers: mkdir -p "$(prefix)/include/ffmpeg" - install -m 644 $(SRC_PATH)/libavformat/avformat.h $(SRC_PATH)/libavformat/avio.h \ + $(INSTALL) -m 644 $(SRC_PATH)/libavformat/avformat.h $(SRC_PATH)/libavformat/avio.h \ $(SRC_PATH)/libavformat/rtp.h $(SRC_PATH)/libavformat/rtsp.h \ $(SRC_PATH)/libavformat/rtspcodes.h \ "$(prefix)/include/ffmpeg" --- ./libavformat/allformats.c.ORG Mon Sep 29 00:26:40 2003 +++ ./libavformat/allformats.c Sat Sep 25 02:33:27 2004 @@ -72,7 +72,7 @@ #ifdef CONFIG_VIDEO4LINUX video_grab_init(); #endif -#if defined(CONFIG_AUDIO_OSS) || defined(CONFIG_AUDIO_BEOS) +#if defined(CONFIG_AUDIO_OSS) || defined(CONFIG_AUDIO_SUN) || defined(CONFIG_AUDIO_BEOS) audio_init(); #endif --- ./libavformat/sunaudio.c.ORG Fri Sep 24 22:06:20 2004 +++ ./libavformat/sunaudio.c Fri Sep 24 23:32:16 2004 @@ -1,0 +1,292 @@ +/* + * Solaris audio play and grab interface + * Copyright (c) 2000, 2001 Fabrice Bellard. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "avformat.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef AUDIO_SWFEATURE_MIXER /* solaris 8 or newer? */ +# define HAVE_SYS_MIXER_H 1 +#endif +#if HAVE_SYS_MIXER_H +# include +#endif + + +const char *audio_device = "/dev/audio"; + +#define AUDIO_BLOCK_SIZE 4096 + +typedef struct { + int fd; + int sample_rate; + int channels; + int frame_size; /* in bytes ! */ + int codec_id; + int flip_left : 1; + uint8_t buffer[AUDIO_BLOCK_SIZE]; + int buffer_ptr; +} AudioData; + +static int audio_open(AudioData *s, int is_output) +{ + int audio_fd; + int err; + audio_info_t info; + char *flip = getenv("AUDIO_FLIP_LEFT"); + + /* open linux audio device */ + if (is_output) + audio_fd = open(audio_device, O_WRONLY); + else + audio_fd = open(audio_device, O_RDONLY); + if (audio_fd < 0) { + perror(audio_device); + return -EIO; + } + + if (flip && *flip == '1') { + s->flip_left = 1; + } + + /* non blocking mode */ + if (!is_output) + fcntl(audio_fd, F_SETFL, O_NONBLOCK); + + s->frame_size = AUDIO_BLOCK_SIZE; + AUDIO_INITINFO(&info); + if (s->channels > 2) + s->channels = 2; + info.record.channels = s->channels; + info.record.sample_rate = s->sample_rate; + info.record.precision = AUDIO_PRECISION_16; + info.record.encoding = AUDIO_ENCODING_LINEAR; + info.record.gain = AUDIO_MID_GAIN; + info.record.port = AUDIO_LINE_IN; + info.record.pause = 0; + s->codec_id = CODEC_ID_PCM_S16BE; + s->fd = audio_fd; + err = ioctl(audio_fd, AUDIO_SETINFO, &info); + if (err < 0) { + perror("AUDIO_SETINFO"); + goto fail; + } + return 0; + fail: + close(audio_fd); + return -EIO; +} + +static int audio_close(AudioData *s) +{ + close(s->fd); + return 0; +} + +/* sound output support */ +static int audio_write_header(AVFormatContext *s1) +{ + AudioData *s = s1->priv_data; + AVStream *st; + int ret; + + st = s1->streams[0]; + s->sample_rate = st->codec.sample_rate; + s->channels = st->codec.channels; + ret = audio_open(s, 1); + if (ret < 0) { + return -EIO; + } else { + return 0; + } +} + +static int audio_write_packet(AVFormatContext *s1, int stream_index, + uint8_t *buf, int size, int force_pts) +{ + AudioData *s = s1->priv_data; + int len, ret; + + while (size > 0) { + len = AUDIO_BLOCK_SIZE - s->buffer_ptr; + if (len > size) + len = size; + memcpy(s->buffer + s->buffer_ptr, buf, len); + s->buffer_ptr += len; + if (s->buffer_ptr >= AUDIO_BLOCK_SIZE) { + for(;;) { + ret = write(s->fd, s->buffer, AUDIO_BLOCK_SIZE); + if (ret > 0) + break; + if (ret < 0 && (errno != EAGAIN && errno != EINTR)) + return -EIO; + } + s->buffer_ptr = 0; + } + buf += len; + size -= len; + } + return 0; +} + +static int audio_write_trailer(AVFormatContext *s1) +{ + AudioData *s = s1->priv_data; + + audio_close(s); + return 0; +} + +/* grab support */ + +static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap) +{ + AudioData *s = s1->priv_data; + AVStream *st; + int ret; + + if (!ap || ap->sample_rate <= 0 || ap->channels <= 0) + return -1; + + st = av_new_stream(s1, 0); + if (!st) { + return -ENOMEM; + } + s->sample_rate = ap->sample_rate; + s->channels = ap->channels; + + ret = audio_open(s, 0); + if (ret < 0) { + av_free(st); + return -EIO; + } + + /* take real parameters */ + st->codec.codec_type = CODEC_TYPE_AUDIO; + st->codec.codec_id = s->codec_id; + st->codec.sample_rate = s->sample_rate; + st->codec.channels = s->channels; + + av_set_pts_info(s1, 48, 1, 1000000); /* 48 bits pts in us */ + return 0; +} + +static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) +{ + AudioData *s = s1->priv_data; + int ret, bdelay; + int64_t cur_time; +/* struct audio_buf_info abufi; */ + + if (av_new_packet(pkt, s->frame_size) < 0) + return -EIO; + for(;;) { + ret = read(s->fd, pkt->data, pkt->size); + if (ret > 0) + break; + if (ret == -1 && (errno == EAGAIN || errno == EINTR)) { + av_free_packet(pkt); + pkt->size = 0; + return 0; + } + if (!(ret == 0 || (ret == -1 && (errno == EAGAIN || errno == EINTR)))) { + av_free_packet(pkt); + return -EIO; + } + } + pkt->size = ret; + + /* compute pts of the start of the packet */ + cur_time = av_gettime(); + bdelay = ret; +#if 0 + if (ioctl(s->fd, SNDCTL_DSP_GETISPACE, &abufi) == 0) { + bdelay += abufi.bytes; + } +#endif + /* substract time represented by the number of bytes in the audio fifo */ + cur_time -= (bdelay * 1000000LL) / (s->sample_rate * s->channels); + + /* convert to wanted units */ + pkt->pts = cur_time & ((1LL << 48) - 1); + + if (s->flip_left && s->channels == 2) { + int i; + short *p = (short *) pkt->data; + + for (i = 0; i < ret; i += 4) { + *p = ~*p; + p += 2; + } + } + return 0; +} + +static int audio_read_close(AVFormatContext *s1) +{ + AudioData *s = s1->priv_data; + + audio_close(s); + return 0; +} + +static AVInputFormat audio_in_format = { + "audio_device", + "audio grab and output", + sizeof(AudioData), + NULL, + audio_read_header, + audio_read_packet, + audio_read_close, + .flags = AVFMT_NOFILE, +}; + +static AVOutputFormat audio_out_format = { + "audio_device", + "audio grab and output", + "", + "", + sizeof(AudioData), + /* XXX: we make the assumption that the soundcard accepts this format */ + /* XXX: find better solution with "preinit" method, needed also in + other formats */ +#ifdef WORDS_BIGENDIAN + CODEC_ID_PCM_S16BE, +#else + CODEC_ID_PCM_S16LE, +#endif + CODEC_ID_NONE, + audio_write_header, + audio_write_packet, + audio_write_trailer, + .flags = AVFMT_NOFILE, +}; + +int audio_init(void) +{ + av_register_input_format(&audio_in_format); + av_register_output_format(&audio_out_format); + return 0; +} --- ./tests/Makefile.ORG Mon Sep 29 00:26:41 2003 +++ ./tests/Makefile Sat Sep 25 02:33:27 2004 @@ -5,7 +5,7 @@ include ../config.mak VPATH=$(SRC_PATH)/tests -CFLAGS=-O2 -Wall -g +CFLAGS=-O2 $(PIC) -Wall -g REFFILE1=$(SRC_PATH)/tests/ffmpeg.regression.ref REFFILE2=$(SRC_PATH)/tests/rotozoom.regression.ref --- ./Makefile.ORG Mon Sep 29 00:26:39 2003 +++ ./Makefile Sat Sep 25 02:34:35 2004 @@ -6,7 +6,7 @@ VPATH=$(SRC_PATH) -CFLAGS= $(OPTFLAGS) -Wall -g -I. -I$(SRC_PATH) -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavformat -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE +CFLAGS= $(OPTFLAGS) $(PIC) -Wall -g -I. -I$(SRC_PATH) -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavformat -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE LDFLAGS+= -g ifeq ($(TARGET_GPROF),yes) @@ -75,11 +75,11 @@ ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs $(CC) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(FFLIBS) $(EXTRALIBS) -ffmpeg$(EXESUF): ffmpeg_g$(EXESUF) +ffmpeg$(exesuf): ffmpeg_g$(exesuf) cp -p $< $@ $(STRIP) $@ -ffserver$(EXESUF): ffserver.o .libs +ffserver$(exesuf): ffserver.o .libs $(CC) $(LDFLAGS) $(FFSLDFLAGS) -o $@ ffserver.o $(FFLIBS) $(EXTRALIBS) ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs @@ -106,9 +106,10 @@ install: all install-man $(INSTALLVHOOK) $(MAKE) -C libavcodec install $(MAKE) -C libavformat install - install -d "$(bindir)" - install -c -s -m 755 $(PROG) "$(bindir)" + $(INSTALL) -d "$(bindir)" + $(INSTALL) -c -s -m 755 $(PROG) "$(bindir)" + # create the window installer wininstaller: all install makensis ffinstall.nsi @@ -117,8 +118,8 @@ install-man: ifneq ($(CONFIG_WIN32),yes) if [ -f $(SRC_PATH)/doc/ffmpeg.1 ] ; then \ - install -d $(mandir)/man1 ; \ - install -m 644 $(SRC_PATH)/doc/ffmpeg.1 $(SRC_PATH)/doc/ffplay.1 \ + $(INSTALL) -d $(mandir)/man1 ; \ + $(INSTALL) -m 644 $(SRC_PATH)/doc/ffmpeg.1 $(SRC_PATH)/doc/ffplay.1 \ $(SRC_PATH)/doc/ffserver.1 $(mandir)/man1 ; \ fi endif --- ./configure.ORG Mon Sep 29 00:26:39 2003 +++ ./configure Sat Sep 25 03:42:39 2004 @@ -27,6 +27,7 @@ ranlib="ranlib" make="make" strip="strip" +install="install" cpu=`uname -m` tune="generic" powerpc_perf="no" @@ -56,13 +57,16 @@ sh4) cpu="sh4" ;; + sun4u) + cpu="sparc64" + ;; *) cpu="unknown" ;; esac gprof="no" -v4l="yes" -audio_oss="yes" +v4l="no" +audio_oss="no" audio_beos="no" dv1394="yes" network="yes" @@ -105,6 +109,19 @@ amr_nb_fixed="no" sunmlib="no" +typep() +{ + cmd=$1 ; TMP=$IFS ; IFS=: ; set $PATH + for dir + do + if [ -x "$dir/$cmd" ]; then + echo "$dir/$cmd"; IFS=$TMP; return 0 + fi + done + IFS=$TMP; return 1 +} + + # OS specific targetos=`uname -s` case $targetos in @@ -139,14 +156,20 @@ extralibs="-lnet" fi ;; SunOS) -v4l="no" -audio_oss="no" +if [ -f /opt/KSWbt8x8/include/videodev.h ]; then + v4l="yes"; CFLAGS="$CFLAGS -I/opt/KSWbt8x8/include" +elif [ -f /opt/KSWv4lcmn/include/videodev.h ]; then + v4l="yes"; CFLAGS="$CFLAGS -I/opt/KSWv4lcmn/include" +fi +#pkginfo -q SUNWmlib && pkginfo -q SUNWmlibh && sunmlib="yes" +audio_sun="yes" dv1394="no" make="gmake" +install=`typep ginstall` || install="/usr/ucb/install" LDFLAGS="" FFSLDFLAGS="" need_inet_aton="yes" -extralibs="$extralibs -lsocket -lnsl" +extralibs="$extralibs -lsocket -lnsl -lrt" ;; FreeBSD) v4l="no" @@ -298,6 +321,8 @@ ;; --disable-audio-oss) audio_oss="no" ;; + --disable-audio-sun) audio_sun="no" + ;; --disable-audio-beos) audio_beos="no" ;; --disable-dv1394) dv1394="no" @@ -696,8 +721,8 @@ freetype2=no if test "x$targetos" != "xBeOS" && test "$os2" != "yes"; then - if test "`which freetype-config`" != ""; then - if $cc -o $TMPE $TMPC `freetype-config --cflags` `freetype-config --libs` 2> /dev/null ; then + if freetype-config --version >/dev/null 2>&1 ; then + if $cc -o $TMPE $TMPC `freetype-config --cflags` `freetype-config --libs` > /dev/null 2>&1 ; then freetype2=yes fi fi @@ -864,6 +889,7 @@ echo "AR=$ar" >> config.mak echo "RANLIB=$ranlib" >> config.mak echo "STRIP=$strip" >> config.mak +echo "INSTALL=$install" >> config.mak echo "OPTFLAGS=$CFLAGS" >> config.mak echo "LDFLAGS=$LDFLAGS" >> config.mak echo "FFSLDFLAGS=$FFSLDFLAGS" >> config.mak @@ -1025,6 +1051,11 @@ echo "CONFIG_AUDIO_OSS=yes" >> config.mak fi +if test "$audio_sun" = "yes" ; then + echo "#define CONFIG_AUDIO_SUN 1" >> $TMPH + echo "CONFIG_AUDIO_SUN=yes" >> config.mak +fi + if test "$audio_beos" = "yes" ; then echo "#define CONFIG_AUDIO_BEOS 1" >> $TMPH echo "CONFIG_AUDIO_BEOS=yes" >> config.mak