[MPlayer-dev-eng] DXR3 patch
David Holm
dholm at telia.com
Wed Nov 28 15:42:41 CET 2001
WHY aren't you applying the patch (or if you have, why haven't you told
me). I'm almost done with the next patch, and I DON'T want more e-mails
from users asking why it doesn't work (since you didn't apply my last
patch either)...
David Holm wrote:
>Hi,
>first of all, you forgot to apply my previous patch resulting in the current
>CVS being broken when compiling with dxr3. Second of all, I have managed to
>partially fix the audio bug (read the docs), it now works pretty good.
>
>I have also added preliminary support for RTE in main/configure and
>main/Makefile. RTE 0.4 includes only mp1e and NOT ffmpeg, rte can be
>downloaded from zapping.sf.net.
>
>I'll do a test implementation in vo_dxr3.c (probably) and then implement it
>in the libvo2 core for hardware cards.
>
>//David Holm
>
>
>------------------------------------------------------------------------
>
>diff -Naur -x CVS -x .* -x *.mak -x *html main/libao2/ao_dxr3.c main-dxr3/libao2/ao_dxr3.c
>--- main/libao2/ao_dxr3.c Sun Nov 18 14:10:21 2001
>+++ main-dxr3/libao2/ao_dxr3.c Tue Nov 27 19:14:40 2001
>@@ -16,6 +16,9 @@
> #include "audio_out.h"
> #include "audio_out_internal.h"
>
>+void perror( const char *s );
>+#include <errno.h>
>+int sys_nerr;
> extern int verbose;
>
> static ao_info_t info =
>@@ -28,15 +31,6 @@
>
> LIBAO_EXTERN(dxr3)
>
>-// there are some globals:
>-// ao_samplerate
>-// ao_channels
>-// ao_format
>-// ao_bps
>-// ao_outburst
>-// ao_buffersize
>-
>-//static char *em8300_ma="/dev/em8300_ma";
> static audio_buf_info dxr3_buf_info;
> static int fd_control = 0, fd_audio = 0;
>
>@@ -73,30 +67,33 @@
> printf("AO: [dxr3] Can't open em8300 control /dev/em8300\n");
> return 0;
> }
>-
>- ao_format = format;
>- if( ioctl (fd_audio, SNDCTL_DSP_SETFMT, &ao_format) < 0 )
>+
>+ ioctl(fd_audio, SNDCTL_DSP_RESET, NULL);
>+ ao_data.format = format;
>+ if( ioctl (fd_audio, SNDCTL_DSP_SETFMT, &ao_data.format) < 0 )
> printf( "AO: [dxr3] Unable to set audio format\n" );
>- if(format == AFMT_AC3 && ao_format != AFMT_AC3)
>+ if(format == AFMT_AC3 && ao_data.format != AFMT_AC3)
> {
> printf("AO: [dxr3] Can't set audio device /dev/em8300_ma to AC3 output\n");
> return 0;
> }
> printf("AO: [dxr3] Sample format: %s (requested: %s)\n",
>- audio_out_format_name(ao_format), audio_out_format_name(format));
>+ audio_out_format_name(ao_data.format), audio_out_format_name(format));
>
> if(format != AFMT_AC3)
> {
>- ao_channels=channels-1;
>- if( ioctl (fd_audio, SNDCTL_DSP_STEREO, &ao_channels) < 0 )
>+ ao_data.channels=channels-1;
>+ if( ioctl (fd_audio, SNDCTL_DSP_STEREO, &ao_data.channels) < 0 )
> printf( "AO: [dxr3] Unable to set number of channels\n" );
>
> // set rate
>- ao_samplerate=rate;
>- if( ioctl (fd_audio, SNDCTL_DSP_SPEED, &ao_samplerate) < 0 )
>+ ao_data.bps = (channels+1)*rate;
>+ ao_data.samplerate=rate;
>+ if( ioctl (fd_audio, SNDCTL_DSP_SPEED, &ao_data.samplerate) < 0 )
> printf( "AO: [dxr3] Unable to set samplerate\n" );
>- printf("AO: [dxr3] Using %d Hz samplerate (requested: %d)\n",ao_samplerate,rate);
>+ printf("AO: [dxr3] Using %d Hz samplerate (requested: %d)\n",ao_data.samplerate,rate);
> }
>+ else ao_data.bps *= 2;
>
> if( ioctl(fd_audio, SNDCTL_DSP_GETOSPACE, &dxr3_buf_info)==-1 )
> {
>@@ -104,44 +101,20 @@
> printf("AO: [dxr3] Driver doesn't support SNDCTL_DSP_GETOSPACE :-(\n");
> if( ioctl( fd_audio, SNDCTL_DSP_GETBLKSIZE, &r) ==-1 )
> {
>- printf( "AO: [dxr3] %d bytes/frag (config.h)\n", ao_outburst );
>+ printf( "AO: [dxr3] %d bytes/frag (config.h)\n", ao_data.outburst );
> }
> else
> {
>- ao_outburst=r;
>- printf( "AO: [dxr3] %d bytes/frag (GETBLKSIZE)\n",ao_outburst);
>+ ao_data.outburst=r;
>+ printf( "AO: [dxr3] %d bytes/frag (GETBLKSIZE)\n",ao_data.outburst);
> }
> }
> else
> {
> printf("AO: [dxr3] frags: %3d/%d (%d bytes/frag) free: %6d\n",
> dxr3_buf_info.fragments+1, dxr3_buf_info.fragstotal, dxr3_buf_info.fragsize, dxr3_buf_info.bytes);
>- if(ao_buffersize==-1) ao_buffersize=dxr3_buf_info.bytes;
>- ao_outburst=dxr3_buf_info.fragsize;
>- }
>-
>- if(ao_buffersize==-1){
>- // Measuring buffer size:
>- void* data;
>- ao_buffersize=0;
>-#ifdef HAVE_AUDIO_SELECT
>- data=malloc(ao_outburst); memset(data,0,ao_outburst);
>- while(ao_buffersize<0x40000){
>- fd_set rfds;
>- struct timeval tv;
>- FD_ZERO(&rfds); FD_SET(fd_audio,&rfds);
>- tv.tv_sec=0; tv.tv_usec = 0;
>- if(!select(fd_audio+1, NULL, &rfds, NULL, &tv)) break;
>- write(fd_audio,data,ao_outburst);
>- ao_buffersize+=ao_outburst;
>- }
>- free(data);
>- if(ao_buffersize==0){
>- printf("\nAO: [dxr3] *** Your audio driver DOES NOT support select() ***\n");
>- printf("Recompile mplayer with #undef HAVE_AUDIO_SELECT in config.h !\n\n");
>- return 0;
>- }
>-#endif
>+ ao_data.buffersize=(dxr3_buf_info.bytes/2)-1;
>+ ao_data.outburst=dxr3_buf_info.fragsize;
> }
>
> ioval = EM8300_PLAYMODE_PLAY;
>@@ -159,6 +132,7 @@
> if( ioctl(fd_audio, SNDCTL_DSP_RESET, NULL) < 0 )
> printf( "AO: [dxr3] Unable to reset device\n" );
> close( fd_audio );
>+ close( fd_control ); /* Just in case */
> }
>
> // stop playing and empty buffers (for seeking/pause)
>@@ -171,8 +145,6 @@
> // stop playing, keep buffers (for pause)
> static void audio_pause()
> {
>- // for now, just call reset();
>-// reset();
> int ioval;
> fd_control = open( "/dev/em8300", O_WRONLY );
> if( fd_control < 0 )
>@@ -202,35 +174,35 @@
> }
> }
>
>-
> // return: how many bytes can be played without blocking
> static int get_space()
> {
> int space = 0;
>- if( ioctl(fd_audio, SNDCTL_DSP_GETOSPACE, &dxr3_buf_info) < 0 )
>+ if( ioctl(fd_audio, SNDCTL_DSP_GETODELAY, &space) < 0 )
> {
>- printf( "AO: [dxr3] Unable to get free space in buffer\n" );
>- return 0;
>+ printf( "AO: [dxr3] Unable to get unplayed bytes in buffer\n" );
>+ return ao_data.outburst;
> }
>-
>- space = dxr3_buf_info.fragments*dxr3_buf_info.fragsize;
>+ space = ao_data.buffersize - space;
> return space;
> }
>
> static int play(void* data,int len,int flags)
> {
>- int pts = ao_pts;
>- if( ioctl( fd_audio, EM8300_IOCTL_AUDIO_SETPTS, &pts ) < 0 )
>+ if( ioctl( fd_audio, EM8300_IOCTL_AUDIO_SETPTS, &ao_data.pts ) < 0 )
> printf( "AO: [dxr3] Unable to set pts\n" );
> return write(fd_audio,data,len);
> }
>
> // return: how many unplayed bytes are in the buffer
>-static int get_delay()
>+static float get_delay()
> {
>- int r=0;
>- if( ioctl(fd_audio, SNDCTL_DSP_GETODELAY, &r) < 0 )
>+ int r=0;
>+ if( ioctl(fd_audio, SNDCTL_DSP_GETODELAY, &r) < 0 )
>+ {
> printf( "AO: [dxr3] Unable to get unplayed bytes in buffer\n" );
>- return r;
>+ return ((float)ao_data.buffersize)/(float)ao_data.bps;
>+ }
>+ return (((float)r)/(float)ao_data.bps);
> }
>
>diff -Naur -x CVS -x .* -x *.mak -x *html main/libvo/vo_dxr3.c main-dxr3/libvo/vo_dxr3.c
>--- main/libvo/vo_dxr3.c Sun Nov 18 14:10:22 2001
>+++ main-dxr3/libvo/vo_dxr3.c Tue Nov 27 19:33:54 2001
>@@ -381,7 +381,7 @@
> /* open it */
> if (avcodec_open(&codec_context, codec) < 0)
> {
>- printf(stderr, "VO: [dxr3] Could not open codec\n");
>+ printf( "VO: [dxr3] Could not open codec\n" );
> return -1;
> }
>
>@@ -424,7 +424,6 @@
>
> static uint32_t draw_frame(uint8_t * src[])
> {
>- int pts = 0;
> if( img_format == IMGFMT_MPEGPES )
> {
> int data_left;
>@@ -432,8 +431,7 @@
> unsigned char *data = p->data;
>
> data_left = p->size;
>- pts = p->timestamp;
>- if( ioctl( fd_video, EM8300_IOCTL_VIDEO_SETPTS, &pts ) < 0 )
>+ if( ioctl( fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vo_pts ) < 0 )
> printf( "VO: [dxr3] Unable to set PTS in draw_frame\n" );
> while( data_left )
> data_left -= write( fd_video, &((unsigned char*)p->data)[p->size-data_left], data_left );
>@@ -516,8 +514,7 @@
> #undef ONE_HALF
> #undef FIX(x)
> //End of ffmpeg code, see ffmpeg.sourceforge.net for terms of license
>- pts = vo_pts;
>- if( ioctl( fd_video, EM8300_IOCTL_VIDEO_SETPTS, &pts ) < 0 )
>+ if( ioctl( fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vo_pts ) < 0 )
> printf( "VO: [dxr3] Unable to set PTS in draw_frame\n" );
> tmp_size = out_size = avcodec_encode_video(&codec_context, outbuf, outbuf_size, &picture);
> while( out_size )
>@@ -535,8 +532,8 @@
> {
> }
> }
>- pts = vo_pts;
>- if( ioctl( fd_video, EM8300_IOCTL_VIDEO_SETPTS, &pts ) < 0 )
>+
>+ if( ioctl( fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vo_pts ) < 0 )
> printf( "VO: [dxr3] Unable to set PTS in draw_frame\n" );
> tmp_size = out_size = avcodec_encode_video(&codec_context, outbuf, outbuf_size, &picture);
> while( out_size )
>--- main/configure Tue Nov 27 18:58:29 2001
>+++ main-dxr3/configure Tue Nov 27 21:08:31 2001
>@@ -651,6 +651,7 @@
> _rtc=auto
> _ossaudio=auto
> _mad=auto
>+_mp1e=auto
> _vorbis=auto
> _css=auto
> _dvdread=auto
>@@ -1962,6 +1963,26 @@
> echores "$_mad"
>
>
>+echocheck "mp1e rte support"
>+if test "$_mp1e" = auto ; then
>+ _mp1e=no
>+ cat > $TMPC << EOF
>+#include <sys/types.h>
>+#include <unistd.h>
>+#include <rte.h>
>+int main(void) { return 0; }
>+EOF
>+ cc_check -lrte && _mp1e=yes
>+fi
>+if test "$_mp1e" = yes ; then
>+ _def_mp1e='#define USE_MP1E 1'
>+ _ld_mp1e='-lrte'
>+else
>+ _def_mp1e='#undef USE_MP1E'
>+fi
>+echores "$_mp1e"
>+
>+
> echocheck "OggVorbis support"
> if test "$_vorbis" = auto ; then
> _vorbis=no
>@@ -2482,6 +2503,8 @@
> DS_LIB = $_ld_dshow
> AV_DEP = $_dep_libavcodec
> AV_LIB = $_ld_libavcodec
>+MP1E_DEP = $_dep_mp1e
>+MP1E_LIB = $_ld_mp1e
> ARCH_LIB = $_ld_arch $_ld_iconv
> DIVX4LINUX = $_divx4linux
> DECORE_LIB = $_ld_decore
>@@ -2636,6 +2659,9 @@
> /* use only decoders from libavcodec: */
> #define CONFIG_DECODERS 1
>
>+/* mp1e rte encoder */
>+$_def_mp1e
>+
> /* XAnim DLL support */
> $_def_xanim
> $_def_xanim_path
>@@ -2706,6 +2732,9 @@
>
> /* libmad support */
> $_def_mad
>+
>+/* mp1e support */
>+$_def_mp1e
>
> /* enable OggVorbis support */
> $_def_vorbis
>--- main/DOCS/DXR3 Thu Nov 8 22:51:20 2001
>+++ main-dxr3/DOCS/DXR3 Tue Nov 27 21:19:40 2001
>@@ -1,6 +1,11 @@
> DXR3/H+ video/audio output plugins manual by David Holm
> =======================================================
>
>+2001-11-27: -ao dxr3 now works, still a few bugs though
>+ you might have to reload the em8300 modules
>+ after a playback or you might get static the
>+ next time you use the dxr3 audio interface.
>+
> 1. Introduction
>
> The DXR3 and Hollywood+ are two not too different mpeg-(1/2) and ac3
>@@ -64,8 +69,7 @@
>
> After installation you will have two new outdevices in mplayer:
> -vo dxr3 For video output
>- -ao dxr3 For audio output (due to an unresolved bug
>- this is not recommended/useful!)
>+ -ao dxr3 For audio output
>
> MPEG-1, MPEG-2, VCD and DVD Notes
> There are some notes to take into account here for optimum playback.
>@@ -83,22 +87,17 @@
> to run faster tell me which one because I'll be interested in how it
> could possibly be any faster than OpenDivX4Linux...
>
>-Unsupported Codecs:
>-If you ever get a codec unsupported message, lookup the codec in the
>-codecs.conf file (search for "videocodec <codecname>"), copy the entire
>-codec section and send it to me and I'll make sure it works with the
>-next patch (or the next after that if I have a thousand things to take
>-care of first ;) my e-mail is at the bottom of this page.
>-
>-4. Todo
>-
>- * Scale video played using windows codecs (High)
>- * Make the osd use the subpic feature of the dxr3 (almost done)(High)
>- * Driver options (probably not until libvo2) (Medium)
>+Other codecs:
>+Currently they don't work. I'm working on implementing libvo2 which
>+will be a much more convenient and faster way of working with
>+vo<->codec interaction. If libvo2 takes longer to develop than I
>+have estimated perhaps I'll add more codec support to libvo. Otherwise
>+you'll just have to wait for libvo2. (there is an implementation
>+for other codecs, but I think it's pretty broken currently ;)
>
>
>
>-5. Contacting me
>+4. Contacting me
>
> You can contact me either by e-mailing me, <dholm at iname.com> or by using
> icq: 798427
>
More information about the MPlayer-dev-eng
mailing list