[MPlayer-cvslog] r19169 - in trunk: libao2/ao_dxr2.c libvo/vo_dxr2.c

ben subversion at mplayerhq.hu
Sun Jul 23 12:10:07 CEST 2006


Author: ben
Date: Sun Jul 23 12:10:06 2006
New Revision: 19169

Modified:
   trunk/libao2/ao_dxr2.c
   trunk/libvo/vo_dxr2.c

Log:
use mpeg packetizer helpers for sending lpcm packets

Modified: trunk/libao2/ao_dxr2.c
==============================================================================
--- trunk/libao2/ao_dxr2.c	(original)
+++ trunk/libao2/ao_dxr2.c	Sun Jul 23 12:10:06 2006
@@ -26,6 +26,7 @@
 LIBAO_EXTERN(dxr2)
 
 static int volume=19;
+static int last_freq_id = -1;
 extern int dxr2_fd;
 
 // to set/get/query special features/parameters
@@ -72,6 +73,8 @@
 	if(dxr2_fd <= 0)
 	  return 0;
 
+        last_freq_id = -1;
+        
 	ao_data.outburst=2048;
 	ao_data.samplerate=rate;
 	ao_data.channels=channels;
@@ -151,12 +154,28 @@
     return y;
 }
 
+static void dxr2_send_lpcm_packet(unsigned char* data,int len,int id,unsigned int timestamp,int freq_id)
+{
+  extern int write_dxr2(unsigned char *data, int len);
+  
+  if(dxr2_fd < 0) {
+    mp_msg(MSGT_AO,MSGL_ERR,"DXR2 fd is not valid\n");
+    return;
+  }    
+
+  if(last_freq_id != freq_id) {
+    ioctl(dxr2_fd, DXR2_IOC_SET_AUDIO_SAMPLE_FREQUENCY, &freq_id);
+    last_freq_id = freq_id;
+  }
+
+  send_mpeg_lpcm_packet (data, len, id, timestamp, freq_id, write_dxr2);
+}
+
 // plays 'len' bytes of 'data'
 // it should round it down to outburst*n
 // return: number of bytes played
 static int play(void* data,int len,int flags){
   extern int write_dxr2(unsigned char *data, int len);
-  extern void dxr2_send_lpcm_packet(unsigned char* data,int len,int id,int timestamp,int freq_id);
 
   // MPEG and AC3 don't work :-(
     if(ao_data.format==AF_FORMAT_MPEG2)

Modified: trunk/libvo/vo_dxr2.c
==============================================================================
--- trunk/libvo/vo_dxr2.c	(original)
+++ trunk/libvo/vo_dxr2.c	Sun Jul 23 12:10:06 2006
@@ -36,7 +36,6 @@
 
 static int movie_w,movie_h;
 static int playing = 0;
-static int last_freq_id = -1;
 
 // vo device used to blank the screen for the overlay init
 static  vo_functions_t* sub_vo = NULL;
@@ -218,99 +217,6 @@
   write_dxr2(mpg_eof, sizeof(mpg_eof));
 }
 
-void dxr2_send_lpcm_packet(unsigned char* data,int len,int id,unsigned int timestamp,int freq_id)
-{
-  int arg;
-  int ptslen=5;
-
-  if(dxr2_fd < 0) {
-    mp_msg(MSGT_VO,MSGL_ERR,"DXR2 fd is not valid\n");
-    return;
-  }    
-
-  if(last_freq_id != freq_id) {
-    ioctl(dxr2_fd, DXR2_IOC_SET_AUDIO_SAMPLE_FREQUENCY, &freq_id);
-    last_freq_id = freq_id;
-  }
-
-  if (((int) timestamp)<0)
-    timestamp=0;
-
-  mp_msg(MSGT_VO,MSGL_DBG2,"dxr2_send_lpcm_packet(timestamp=%d)\n", timestamp);
-  // startcode:
-  pack[0]=pack[1]=0;pack[2]=0x01;
-
-  // stream id
-  pack[3]=0xBD;
-
-  while(len>=4){
-    int payload_size;
-
-    payload_size=PACK_MAX_SIZE-6-3-ptslen-7; // max possible data len
-    if(payload_size>len) payload_size=len;
-    payload_size&=(~3); // align!
-
-    // packetsize:
-    pack[4]=(payload_size+3+ptslen+7)>>8;
-    pack[5]=(payload_size+3+ptslen+7)&255;
-
-    // stuffing:
-    pack[6]=0x81;
-    //		pack[7]=0x00; //0x80
-
-    // hdrlen:
-    pack[8]=ptslen;
-
-    if(ptslen){
-      int x;
-      pack[7]=0x80;
-      // presentation time stamp:
-      x=(0x02 << 4) | (((timestamp >> 30) & 0x07) << 1) | 1;
-      pack[9]=x;
-      x=((((timestamp >> 15) & 0x7fff) << 1) | 1);
-      pack[10]=x>>8; pack[11]=x&255;
-      x=((((timestamp) & 0x7fff) << 1) | 1);
-      pack[12]=x>>8; pack[13]=x&255;
-    } else {
-      pack[7]=0x00;
-    }
-
-    // ============ LPCM header: (7 bytes) =================
-    // Info by mocm at convergence.de
-
-    //	   ID:
-    pack[ptslen+9]=id;
-
-    //	   number of frames:
-    pack[ptslen+10]=0x07;
-
-    //	   first acces unit pointer, i.e. start of audio frame:
-    pack[ptslen+11]=0x00;
-    pack[ptslen+12]=0x04;
-
-    //	   audio emphasis on-off                                  1 bit
-    //	   audio mute on-off                                      1 bit
-    //	   reserved                                               1 bit
-    //	   audio frame number                                     5 bit
-    pack[ptslen+13]=0x0C;
-
-    //	   quantization word length                               2 bit
-    //	   audio sampling frequency (48khz = 0, 96khz = 1)        2 bit
-    //	   reserved                                               1 bit
-    //	   number of audio channels - 1 (e.g. stereo = 1)         3 bit
-    pack[ptslen+14]=1;
-
-    //	   dynamic range control (0x80 if off)
-    pack[ptslen+15]=0x80;
-
-    write_dxr2(pack, 6+3+ptslen+7);
-    write_dxr2(data, payload_size);
-
-    len-=payload_size; data+=payload_size;
-    timestamp+=90000/4*payload_size/48000;
-  }
-}
-
 void dxr2_send_sub_packet(unsigned char* data,int len,int id,unsigned int timestamp) {
   int ptslen=5;
 
@@ -613,8 +519,6 @@
     playing = 0;
   }
 
-  last_freq_id = -1;
-
   // Video stream setup
   arg3.arg1 = DXR2_STREAM_VIDEO;
   arg3.arg2 = 0;



More information about the MPlayer-cvslog mailing list