Folks, 

Attahced is a new version of the AC3 bigdvb patch. 

1. It contains a fully functioning transport.c that requires no mpeg.c hack, 
finally! It is a combintation of Marcus' changes and mine.

2. I have also started implementing/fixing audio track selection through the 
+/- keys. I think it might actually work for TS recording, but haven't tested 
it. This should also allow toggling of languages where avialable, however I 
have no streams to test it against here in oz. 

3. Included is an attempt to fix the audio change problems in the TS recoding, 
again it is not tested but has a good chance of working. Tim can you test it?

4. There is still some code in transport.c that I have ifdef'd out. Everything 
I have tested works without it and if it is left in then there is audio 
stuttering.

Cheers,
Mark Anderson

On Thu, 13 Jan 2005 09:17 am, Mark Anderson wrote:
> On Wed, 12 Jan 2005 09:15 am, Mark Anderson wrote:
>
> I fixed the audio in trandsport.c, unfortunatley I screwed up the video.
> Attached is the diff as it stands, anyone see anything obvious causing the
> video screw up?
>
> The diff is applied againts the original transport.c and no mpeg.c hack is
> needed.
>
> Cheers,
> Mark.
>
> > Folks,
> >
> > After a number of hours starting at hex dumps and trying. to learn a bit
> > about mpeg/dvb protocols I have finally found the problem with
> > transport.c, unfortunately I haven't been able to craft some code that
> > actually fixes it.
> >
> > The problem: The 9th byte of the mpeg2 data is the header length, in
> > australia for AC3 payload this is always set to 7 bytes. The code in
> > transport.c only ever puts 4 of the 7 bytes into the transformed stream.
> > mpeg.c looks at the header length and makes sure it pulls out that many
> > bytes:
> >
> > The code in mpegps_read_pes_header is:
> >
> >     len -= header_len;
> >         while (header_len > 0) {
> >             get_byte(&s->pb);
> >             header_len--;
> >         }
> >
> >
> > Because transform has not put the last three bytes of the header in,
> > mpeg.c pulls out the wrong bytes and everything goes downhill from there.
> > I have confirmed that if transport puts the full 7 bytes in the it all
> > works fine.
> >
> > I added the following code to write_ipack in transport.c to try to fix
> > this:
> >
> >  /*write in the rest of the header as specified by p->hlength*/
> >         if ((p->cid == PRIVATE_STREAM1) && (p->count == 13))
> >         {
> >                 while (p->count < (p->hlength + 9))
> >                 {
> >                         p->buf[p->count++] = data[p->count - 13];
> >                 }
> >         }
> >
> > This almost does it except there are 3 additonal bytes after the four
> > byte streamid/ac3_off header. If I hack mpeg.c to pull the extras out it
> > produces perfect audio. The reason the extra three bytes are added due to
> > the above code is that it adds the reast of the header, but since
> > write_ipack has no way of telling the caller that it has used up some
> > bytes out of its source buffer, the bytes are re-added in the next call
> > to write_ipack.
> >
> > Marcus, since you are much more familiar with this code, maybe you could
> > work out how to get the proper header bytes added?
> >
> > Cheers,
> > Mark Anderson
Binary files ../mythtv-bdvb-35.orig/libs/libavformat/libmythavformat-0.16.so and ./libs/libavformat/libmythavformat-0.16.so differ
Binary files ../mythtv-bdvb-35.orig/libs/libavformat/libmythavformat-0.16.so.0 and ./libs/libavformat/libmythavformat-0.16.so.0 differ
Binary files ../mythtv-bdvb-35.orig/libs/libavformat/libmythavformat-0.16.so.0.16 and ./libs/libavformat/libmythavformat-0.16.so.0.16 differ
Binary files ../mythtv-bdvb-35.orig/libs/libavformat/libmythavformat-0.16.so.0.16.0 and ./libs/libavformat/libmythavformat-0.16.so.0.16.0 differ
diff -Bbupr -xconfig.log -xconfig.mak -xMakefile ../mythtv-bdvb-35.orig/libs/libavformat/mpeg.c ./libs/libavformat/mpeg.c
--- ../mythtv-bdvb-35.orig/libs/libavformat/mpeg.c	2005-01-08 17:32:42.000000000 +1100
+++ ./libs/libavformat/mpeg.c	2005-01-12 16:23:58.000000000 +1100
@@ -1531,6 +1532,11 @@ static int mpegps_read_packet(AVFormatCo
         goto skip;
     st->codec.codec_type = type;
     st->codec.codec_id = codec_id;
+    /*notify the callback of the change in streams*/
+    if (s->streams_changed) {
+        s->streams_changed(s->stream_change_data);
+    }
+
     if (codec_id != CODEC_ID_PCM_S16BE)
         st->need_parsing = 1;
  found:
Only in ./libs/libavformat: mpeg.c.orig
Binary files ../mythtv-bdvb-35.orig/libs/libavformat/mpeg.o and ./libs/libavformat/mpeg.o differ
diff -Bbupr -xconfig.log -xconfig.mak -xMakefile ../mythtv-bdvb-35.orig/libs/libmythtv/avformatdecoder.cpp ./libs/libmythtv/avformatdecoder.cpp
--- ../mythtv-bdvb-35.orig/libs/libmythtv/avformatdecoder.cpp	2005-01-09 03:48:12.000000000 +1100
+++ ./libs/libmythtv/avformatdecoder.cpp	2005-01-13 20:39:55.000000000 +1100
@@ -39,6 +39,7 @@ AvFormatDecoder::AvFormatDecoder(NuppelV
     audio_channels = -1;
     audio_sample_size = -1;
     audio_sampling_rate = -1;
+    audio_codec = -1;
 
     exitafterdecoded = false;
     ateof = false;
@@ -522,11 +523,8 @@ int AvFormatDecoder::ScanStreams(bool no
         {
             VERBOSE(VB_IMPORTANT, 
                     QString("AvFormatDecoder: Could not find decoder for "
-                            "codec (%1) aborting.")
+                            "codec,  ignoring (%1).")
                            .arg(enc->codec_id));
-            av_close_input_file(ic);
-            ic = NULL;
-            scanerror = -1;
             continue;
         }
 
@@ -597,8 +595,27 @@ bool AvFormatDecoder::CheckVideoParams(i
     return true;
 }
 
-void AvFormatDecoder::CheckAudioParams(int freq, int channels, bool safe)
+QString AvFormatDecoder::getCurrentAudioTrackDescription()
+{
+	switch (audio_codec)
+	{
+		case CODEC_ID_AC3:
+
+		   	return QString("Dolby Digital ");
+		case CODEC_ID_MP2:
+			return QString("%1 kHz, %2 channel MPEG audio").
+				arg(audio_sampling_rate/1000).
+				arg(audio_channels);
+		default:
+			return QString("%1 kHz, %2 channel audio").
+				arg(audio_sampling_rate/1000).
+		    	arg(audio_channels);	
+	}		
+}
+
+void AvFormatDecoder::CheckAudioParams(int freq, int channels, int codec_id, bool safe)
 {
+
     if (freq <= 0 || channels <= 0)
         return;
 
@@ -604,18 +621,20 @@ void AvFormatDecoder::CheckAudioParams(i
 
     if (safe || audio_check_1st == 2)
     {
-        if (freq == audio_sampling_rate && channels == audio_channels)
+        if (freq == audio_sampling_rate && channels == audio_channels && audio_codec == codec_id) 
             return;
         audio_check_1st = 1;
         audio_sampling_rate_2nd = freq;
         audio_channels_2nd = channels;
+        audio_codec_2nd = codec_id; 
         if (safe == false)
             return;
     }
     else
     {
         if (freq != audio_sampling_rate_2nd || channels != audio_channels_2nd ||
-            (freq == audio_sampling_rate && channels == audio_channels))
+            codec_id != audio_codec_2nd ||
+            (freq == audio_sampling_rate && channels == audio_channels && codec_id == audio_codec))
         {
             audio_sampling_rate_2nd = -1;
             audio_channels_2nd = -1;
@@ -631,11 +650,14 @@ void AvFormatDecoder::CheckAudioParams(i
     }
 
     audio_check_1st = 2;
-
     if (audio_channels != -1)
-        VERBOSE(VB_AUDIO, QString("Audio format changed from %1 channels,"
-                " %2hz to %3 channels %4hz").arg(audio_channels)
-                .arg(audio_sampling_rate).arg(channels).arg(freq));
+	{
+        VERBOSE(VB_ALL, QString("Audio format changed from %1 channels,"
+                " %2hz codec %3 to %4 channels %5hz codec %6").arg(audio_channels)
+                .arg(audio_sampling_rate).arg(audio_codec).arg(channels)
+                .arg(freq).arg(codec_id));
+	}
+	
 
     AVCodecContext *enc = &ic->streams[wantedAudioStream]->codec;
     AVCodec *codec = enc->codec;
@@ -1019,7 +1041,7 @@ void AvFormatDecoder::incCurrentAudioTra
         wantedAudioStream = audioStreams[currentAudioTrack];
 
         AVCodecContext *e = &ic->streams[wantedAudioStream]->codec;
-        CheckAudioParams(e->sample_rate, e->channels, true);
+        CheckAudioParams(e->sample_rate, e->channels, e->codec_id, true);
     }
 }
 
@@ -1036,7 +1058,7 @@ void AvFormatDecoder::decCurrentAudioTra
         wantedAudioStream = audioStreams[currentAudioTrack];
 
         AVCodecContext *e = &ic->streams[wantedAudioStream]->codec;
-        CheckAudioParams(e->sample_rate, e->channels, true);
+        CheckAudioParams(e->sample_rate, e->channels, e->codec_id, true);
     }
 }
 
@@ -1054,22 +1076,26 @@ bool AvFormatDecoder::setCurrentAudioTra
     wantedAudioStream = audioStreams[currentAudioTrack];
 
     AVCodecContext *e = &ic->streams[wantedAudioStream]->codec;
-    CheckAudioParams(e->sample_rate, e->channels, true);
+    CheckAudioParams(e->sample_rate, e->channels, e->codec_id, true);
     return true;
 }
 
-bool AvFormatDecoder::autoSelectAudioTrack()
+bool AvFormatDecoder::autoSelectAudioTrack(bool prefer_ac3)
 {
     if (!audioStreams.size())
         return false;
 
+    if (prefer_ac3)
+    {
+        prefer_ac3 = gContext->GetNumSetting("WantAC3", false);
+    }
+
     bool foundAudio = false;
     int minChannels = 1;
     int maxTracks = (audioStreams.size() - 1);
     int track;
-    if (do_ac3_passthru)
+    if (prefer_ac3)
         minChannels = 2;
-
     while (!foundAudio)
     {
         for (track = maxTracks; track >= 0; track--)
@@ -1076,7 +1102,11 @@ bool AvFormatDecoder::autoSelectAudioTra
         {
             int tempStream = audioStreams[track];
             AVCodecContext *e = &ic->streams[tempStream]->codec;
-
+                    if (((prefer_ac3) && (e->codec_id != CODEC_ID_AC3)) || 
+                        ((!prefer_ac3) && (e->codec_id == CODEC_ID_AC3))) 
+                    {
+                        continue;
+                    }
             if (e->channels > minChannels)
             {
                 currentAudioTrack = track;
@@ -1087,16 +1117,26 @@ bool AvFormatDecoder::autoSelectAudioTra
                 VERBOSE(VB_AUDIO, 
                         QString("It has %1 channels and we needed at least %2")
                                .arg(e->channels).arg(minChannels + 1));
+                            if (prefer_ac3)
+                            {
+                                VERBOSE(VB_ALL, QString("AC3 stream has been selected"));
+                            }
 
                 AVCodecContext *e = &ic->streams[wantedAudioStream]->codec;
-                CheckAudioParams(e->sample_rate, e->channels, true);
+			    CheckAudioParams(e->sample_rate, e->channels, e->codec_id, true);
                 return true;
             }
         }
         minChannels--;
         if (minChannels < 0)
+	    {
+                    if (prefer_ac3)
+                    {
+                        return autoSelectAudioTrack(false);
+                    }
             return false;
     }
+    }
 
     return false;
 }
@@ -1113,6 +1153,8 @@ void AvFormatDecoder::SetupAudioStream(v
     VERBOSE(VB_ALL, QString("Initializing audio parms from stream #%1.")
             .arg(currentAudioTrack));
 
+    audio_codec = curstream->codec.codec_id;
+
     m_parent->SetEffDsp(curstream->codec.sample_rate * 100);
 
     do_ac3_passthru = curstream->codec.codec_id == CODEC_ID_AC3 &&
@@ -1120,6 +1162,7 @@ void AvFormatDecoder::SetupAudioStream(v
 
     if (do_ac3_passthru)
     {
+	VERBOSE(VB_ALL, QString("AC3 passthrough is enabled"));
         // An AC3 stream looks like a 48KHz 2ch audio stream to
         // the sound card
         audio_sample_size = 4;
@@ -1161,6 +1204,7 @@ bool AvFormatDecoder::GetFrame(int onlyv
 
     while (!allowedquit)
     {
+	
         if (gotvideo)
         {
             if (lowbuffers && onlyvideo == 0 && lastapts < lastvpts + 100 &&
@@ -1272,9 +1316,23 @@ bool AvFormatDecoder::GetFrame(int onlyv
             {
                 case CODEC_TYPE_AUDIO:
                 {
+					static int packetsWithNewCodec = 0;
+					
+                    //hmm the codec has changed from what we were initialised with
+                    //move to the next stream to see if it is correct, but only
+					//if we have received x packets with the new codec
+					if ((curstream->codec.codec_id != audio_codec))
+                    {
+						packetsWithNewCodec++;
+						if (packetsWithNewCodec > 5)
+						{
+							incCurrentAudioTrack();
+							packetsWithNewCodec = 0;
+						}
+                    }
+					
                     if (firstloop && pkt->pts != (int64_t)AV_NOPTS_VALUE)
                         lastapts = pkt->pts / (AV_TIME_BASE / 1000);
-
                     if (onlyvideo != 0 ||
                         (pkt->stream_index != wantedAudioStream))
                     {
@@ -1304,7 +1362,9 @@ bool AvFormatDecoder::GetFrame(int onlyv
 
                     if (!do_ac3_passthru)
                         CheckAudioParams(curstream->codec.sample_rate,
-                                         curstream->codec.channels, false);
+                                         curstream->codec.channels, 
+                                         curstream->codec.codec_id,
+                                         false);
 
                     long long temppts = lastapts;
 
Only in ./libs/libmythtv: avformatdecoder.cpp.orig
Only in ./libs/libmythtv: avformatdecoder.cpp.rej
diff -Bbupr -xconfig.log -xconfig.mak -xMakefile ../mythtv-bdvb-35.orig/libs/libmythtv/avformatdecoder.h ./libs/libmythtv/avformatdecoder.h
--- ../mythtv-bdvb-35.orig/libs/libmythtv/avformatdecoder.h	2005-01-09 03:48:12.000000000 +1100
+++ ./libs/libmythtv/avformatdecoder.h	2005-01-13 20:08:37.000000000 +1100
@@ -68,6 +68,7 @@ class AvFormatDecoder : public DecoderBa
 
     void SetPixelFormat(const int);
 
+	virtual QString getCurrentAudioTrackDescription();
     virtual void incCurrentAudioTrack();
     virtual void decCurrentAudioTrack();
     virtual bool setCurrentAudioTrack(int trackNo);
@@ -78,7 +79,7 @@ class AvFormatDecoder : public DecoderBa
     /// Attempt to find the optimal audio stream to use based on the number of channels,
     /// and if we're doing AC3 passthrough.  This will select the highest stream number
     /// that matches our criteria.
-    bool autoSelectAudioTrack();
+    bool autoSelectAudioTrack(bool wantac3 = true);
 
     RingBuffer *getRingBuf(void) { return ringBuffer; }
 
@@ -112,7 +113,7 @@ class AvFormatDecoder : public DecoderBa
     bool CheckVideoParams(int width, int height);
 
     /// See if the audio parameters have changed, return true if so.
-    void CheckAudioParams(int freq, int channels, bool safe);
+    void CheckAudioParams(int freq, int channels, int codec, bool safe);
     void SetupAudioStream(void);
 
     int EncodeAC3Frame(unsigned char* data, int len, short *samples,
@@ -134,10 +135,13 @@ class AvFormatDecoder : public DecoderBa
     int audio_sample_size;
     int audio_sampling_rate;
     int audio_channels;
+    int audio_codec;
 
     int audio_check_1st;         ///< Used by CheckAudioParams
     int audio_sampling_rate_2nd; ///< Used by CheckAudioParams
     int audio_channels_2nd;      ///< Used by CheckAudioParams
+    int audio_codec_2nd; ///< Used by CheckAudioParams
+
 
     int bitrate;
 
Only in ./libs/libmythtv: avformatdecoder.h.orig
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/avformatdecoder.o and ./libs/libmythtv/avformatdecoder.o differ
diff -Bbupr -xconfig.log -xconfig.mak -xMakefile ../mythtv-bdvb-35.orig/libs/libmythtv/decoderbase.h ./libs/libmythtv/decoderbase.h
--- ../mythtv-bdvb-35.orig/libs/libmythtv/decoderbase.h	2005-01-08 11:28:14.000000000 +1100
+++ ./libs/libmythtv/decoderbase.h	2005-01-13 20:46:31.271799630 +1100
@@ -64,6 +64,7 @@ class DecoderBase
 
     const int getCurrentAudioTrack() const { return currentAudioTrack;}
     virtual void incCurrentAudioTrack(){}
+    virtual QString getCurrentAudioTrackDescription(){ return QString("Unknown"); }
     virtual void decCurrentAudioTrack(){}
     virtual bool setCurrentAudioTrack(int){ return false;}
                                                           
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/decoderbase.o and ./libs/libmythtv/decoderbase.o differ
diff -Bbupr -xconfig.log -xconfig.mak -xMakefile ../mythtv-bdvb-35.orig/libs/libmythtv/dtvrecorder.h ./libs/libmythtv/dtvrecorder.h
--- ../mythtv-bdvb-35.orig/libs/libmythtv/dtvrecorder.h	2005-01-08 11:31:40.000000000 +1100
+++ ./libs/libmythtv/dtvrecorder.h	2005-01-13 21:30:58.000000000 +1100
@@ -54,6 +54,9 @@ class DTVRecorder: public RecorderBase
 
     void GetBlankFrameMap(QMap<long long, int> &blank_frame_map);
     virtual void Reset();
+	virtual void incCurrentAudioTrack(){}
+	virtual void decCurrentAudioTrack(){}
+		
   protected:
     void FinishRecording(void);
     void FindKeyframes(const TSPacket* tspacket);
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/dtvrecorder.o and ./libs/libmythtv/dtvrecorder.o differ
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/dvbcam.o and ./libs/libmythtv/dvbcam.o differ
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/dvbchannel.o and ./libs/libmythtv/dvbchannel.o differ
diff -Bbupr -xconfig.log -xconfig.mak -xMakefile ../mythtv-bdvb-35.orig/libs/libmythtv/dvbdev/transform.c ./libs/libmythtv/dvbdev/transform.c
--- ../mythtv-bdvb-35.orig/libs/libmythtv/dvbdev/transform.c	2005-01-10 08:59:18.000000000 +1100
+++ ./libs/libmythtv/dvbdev/transform.c	2005-01-13 21:51:10.425367288 +1100
@@ -140,7 +139,9 @@ int get_vinfo(uint8_t *mbuf, int count, 
 		}
 	}
 
-	if (! found) return -1;
+	if (! found)
+	   	return -1;
+	
 	c += 4;
 	if (c+12 >= count) return -1;
 	headr = mbuf+c;
@@ -394,6 +395,7 @@ void send_ipack(ipack *p)
 		switch (streamid & 0xF8){
 
 		case 0x80:
+#if 0			
 			ai.off = 0;
 			ac3_off = ((p->buf[off+2] << 8)| p->buf[off+3]);
 			if (ac3_off < p->count)
@@ -408,6 +410,7 @@ void send_ipack(ipack *p)
 				
 				ac3_off +=  nframes * ai.framesize - p->count;
 			}
+#endif			
 			break;
 
 		case 0x20:
@@ -426,7 +429,7 @@ void send_ipack(ipack *p)
 		
 		p->buf[6] = 0x80;
 		p->buf[7] = 0x00;
-		p->buf[8] = 0x00;
+		p->buf[8] = 0x00;//p->hlength;
 		p->count = 9;
 
 		if (p->cid == PRIVATE_STREAM1){
@@ -434,17 +437,21 @@ void send_ipack(ipack *p)
 			switch (streamid & 0xF8){
 
 			case 0x80: 
+#if 0				
 				p->count += 4;
 				p->buf[9] = streamid;
 				p->buf[10] = 0;
 				p->buf[11] = (ac3_off >> 8)& 0xFF;
 				p->buf[12] = (ac3_off)& 0xFF;
+#endif				
 				break;
 				
 			case 0x20:
+#if 0				
 				p->count += 2;
 				p->buf[9] = 0x20;
 				p->buf[10] = 0;				
+#endif				
 				break;
 			}
 		}		
@@ -466,19 +473,10 @@ static void write_ipack(ipack *p, uint8_
 	int diff =0;
 
 	if (p->count < 6){
-		if (trans_pts_dts(p->pts) > trans_pts_dts(p->last_pts))
-			memcpy(p->last_pts, p->pts, 5);
 		p->count = 0;
 		memcpy(p->buf+p->count, headr, 3);
 		p->count += 6;
 	}
-	if ( p->size == p->size_orig && p->plength &&
-	     (diff = 6+p->plength - p->found + p->count +count) > p->size &&
-	     diff < 3*p->size/2){
-		
-			p->size = diff/2;
-//			fprintf(stderr,"size: %d \n",p->size);
-	}
 
 	if (p->cid == PRIVATE_STREAM1 && p->count == p->hlength+9){
 		switch (p->priv_type){
@@ -490,20 +488,20 @@ static void write_ipack(ipack *p, uint8_
 		case PRIV_TS_AC3: /* keep this as default */
 		default:
 		{
-			int ac3_off;
-			ac3_off = get_ac3info(data, count, &ai,0);
-			if (ac3_off>=0 && ai.framesize){
+				/*
+				 * add in a dummy 4 byte audio header
+				 * to match mpeg dvd standard. The values
+				 * will be filled in later (in send_ipack)
+				 * when it has a full packet to search
+				 */
 				p->buf[p->count] = 0x80;
-				p->buf[p->count+1] = (p->size - p->count
-						      - 4 - ac3_off)/ 
-					ai.framesize + 1;
-				p->buf[p->count+2] = (ac3_off >> 8)& 0xFF;
-				p->buf[p->count+3] = (ac3_off)& 0xFF;
+				p->buf[p->count+1] = 0;
+				p->buf[p->count+2] = 0;
+				p->buf[p->count+3] = 0;
 				p->count+=4;
-				
-			}
 		}
 		break;
+
 		}
 	}
 
@@ -518,8 +516,10 @@ static void write_ipack(ipack *p, uint8_
 //		fprintf(stderr,"count: %d \n",p->count);
 		send_ipack(p);
 		if (rest > 0 && count - rest > 0)
+		{
 			write_ipack(p, data+rest, count-rest);
 	}
+	}
 }
 
 void instant_repack (uint8_t *buf, int count, ipack *p)
@@ -640,8 +640,7 @@ void instant_repack (uint8_t *buf, int c
 	if (!p->plength) p->plength = MMAX_PLENGTH-6;
 
 
-	if ( p->done || ((p->mpeg == 2 && p->found >= 9)  || 
-	     (p->mpeg == 1 && p->found >= 7)) ){
+	if ( p->done || ((p->mpeg == 2 && p->found >= 9) )){
 		switch (p->cid){
 			
 		case AUDIO_STREAM_S ... AUDIO_STREAM_E:			
@@ -653,12 +652,19 @@ void instant_repack (uint8_t *buf, int c
 				write_ipack(p, &p->flag2, 1);
 				write_ipack(p, &p->hlength, 1);
 			}
-
-			if (p->mpeg == 1 && p->found == 7){
-				write_ipack(p, &p->flag1, 1);
+			if (p->cid == PRIVATE_STREAM1)
+			{
+				if (p->mpeg == 2 && p->found < 9+p->hlength){
+					while (c < count && p->found < 9+p->hlength){
+						write_ipack(p, buf+c, 1);
+						c++;
+						p->found++;
 			}
-
-
+					if (c == count) return;
+				}
+			}
+			else
+			{	
 			if (p->mpeg == 2 && (p->flag2 & PTS_ONLY) &&  
 			    p->found < 14){
 				while (c < count && p->found < 14){
@@ -669,8 +675,7 @@ void instant_repack (uint8_t *buf, int c
 				}
 				if (c == count) return;
 			}
-			
-
+			}
 			while (c < count && p->found < p->plength+6){
 				l = count -c;
 				if (l+p->found > p->plength+6)
Only in ./libs/libmythtv/dvbdev: transform.c.orig
Only in ./libs/libmythtv/dvbdev: transform.c.working
diff -Bbupr -xconfig.log -xconfig.mak -xMakefile ../mythtv-bdvb-35.orig/libs/libmythtv/dvbrecorder.cpp ./libs/libmythtv/dvbrecorder.cpp
--- ../mythtv-bdvb-35.orig/libs/libmythtv/dvbrecorder.cpp	2005-01-10 08:59:18.000000000 +1100
+++ ./libs/libmythtv/dvbrecorder.cpp	2005-01-13 21:40:33.000000000 +1100
@@ -51,6 +51,7 @@ using namespace std;
 
 #include "RingBuffer.h"
 #include "programinfo.h"
+#include "mythcontext.h"
 
 #include "transform.h"
 #include "dvbtypes.h"
@@ -351,7 +352,7 @@ void DVBRecorder::SetDemuxFilters()
     else
     {
         // PES recording currently only supports one video and one audio PID (I think???)
-        ElementaryPIDObject *as = m_pmt.PreferredAudioStream();
+        ElementaryPIDObject *as = m_pmt.PreferredAudioStream(gContext->GetNumSetting("WantAC3", false));
         ElementaryPIDObject *vs = m_pmt.PreferredVideoStream();
         ElementaryPIDObject *sub = m_pmt.PreferredSubtitleStream();
 
@@ -911,3 +912,17 @@ void DVBRecorder::DebugTSHeader(unsigned
 
 //TODO
 }
+
+void DVBRecorder::incCurrentAudioTrack()
+{
+     ElementaryPIDObject *as = m_pmt.IncAudioStream();
+     if (as)
+        OpenFilters(as->PID, as->Type);
+}
+
+void DVBRecorder::decCurrentAudioTrack()
+{
+     ElementaryPIDObject *as = m_pmt.DecAudioStream();
+     if (as)
+        OpenFilters(as->PID, as->Type);
+}
Only in ./libs/libmythtv: dvbrecorder.cpp.orig
Only in ./libs/libmythtv: dvbrecorder.cpp.rej
diff -Bbupr -xconfig.log -xconfig.mak -xMakefile ../mythtv-bdvb-35.orig/libs/libmythtv/dvbrecorder.h ./libs/libmythtv/dvbrecorder.h
--- ../mythtv-bdvb-35.orig/libs/libmythtv/dvbrecorder.h	2005-01-10 08:59:18.000000000 +1100
+++ ./libs/libmythtv/dvbrecorder.h	2005-01-13 21:30:26.000000000 +1100
@@ -33,6 +33,8 @@ public:
 
     void StartRecording(void);
     void Reset(void);
+	void incCurrentAudioTrack();
+	void decCurrentAudioTrack();
 
 public slots:
     void ChannelChanged(dvb_channel_t& chan);
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/dvbrecorder.o and ./libs/libmythtv/dvbrecorder.o differ
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/hdtvrecorder.o and ./libs/libmythtv/hdtvrecorder.o differ
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/ivtvdecoder.o and ./libs/libmythtv/ivtvdecoder.o differ
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/libmythtv-0.16.so and ./libs/libmythtv/libmythtv-0.16.so differ
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/libmythtv-0.16.so.0 and ./libs/libmythtv/libmythtv-0.16.so.0 differ
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/libmythtv-0.16.so.0.16 and ./libs/libmythtv/libmythtv-0.16.so.0.16 differ
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/libmythtv-0.16.so.0.16.0 and ./libs/libmythtv/libmythtv-0.16.so.0.16.0 differ
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/moc_dvbchannel.o and ./libs/libmythtv/moc_dvbchannel.o differ
diff -Bbupr -xconfig.log -xconfig.mak -xMakefile ../mythtv-bdvb-35.orig/libs/libmythtv/moc_dvbrecorder.cpp ./libs/libmythtv/moc_dvbrecorder.cpp
--- ../mythtv-bdvb-35.orig/libs/libmythtv/moc_dvbrecorder.cpp	2005-01-10 09:20:28.000000000 +1100
+++ ./libs/libmythtv/moc_dvbrecorder.cpp	2005-01-13 21:43:44.256289940 +1100
@@ -1,7 +1,7 @@
 /****************************************************************************
 ** DVBRecorder meta object code from reading C++ file 'dvbrecorder.h'
 **
-** Created: Mon Jan 10 09:20:28 2005
+** Created: Thu Jan 13 21:43:44 2005
 **      by: The Qt MOC ()
 **
 ** WARNING! All changes made in this file will be lost!
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/moc_dvbrecorder.o and ./libs/libmythtv/moc_dvbrecorder.o differ
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/moc_scanwizard.o and ./libs/libmythtv/moc_scanwizard.o differ
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/moc_siparser.o and ./libs/libmythtv/moc_siparser.o differ
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/nuppeldecoder.o and ./libs/libmythtv/nuppeldecoder.o differ
diff -Bbupr -xconfig.log -xconfig.mak -xMakefile ../mythtv-bdvb-35.orig/libs/libmythtv/NuppelVideoPlayer.cpp ./libs/libmythtv/NuppelVideoPlayer.cpp
--- ../mythtv-bdvb-35.orig/libs/libmythtv/NuppelVideoPlayer.cpp	2005-01-10 04:25:24.000000000 +1100
+++ ./libs/libmythtv/NuppelVideoPlayer.cpp	2005-01-13 20:49:56.000000000 +1100
@@ -4171,7 +4171,13 @@ bool NuppelVideoPlayer::setCurrentAudioT
     else
         return false;
 }
-
+QString NuppelVideoPlayer::getCurrentAudioTrackDescription()
+{
+    if (decoder)
+        return decoder->getCurrentAudioTrackDescription();
+    else
+        return QString("Unknown audio");
+}
 
 int NuppelVideoPlayer::getCurrentAudioTrack()
 {
diff -Bbupr -xconfig.log -xconfig.mak -xMakefile ../mythtv-bdvb-35.orig/libs/libmythtv/NuppelVideoPlayer.h ./libs/libmythtv/NuppelVideoPlayer.h
--- ../mythtv-bdvb-35.orig/libs/libmythtv/NuppelVideoPlayer.h	2004-12-08 15:23:16.000000000 +1100
+++ ./libs/libmythtv/NuppelVideoPlayer.h	2005-01-13 20:51:52.339094456 +1100
@@ -203,6 +203,7 @@ class NuppelVideoPlayer
     void decCurrentAudioTrack();
     bool setCurrentAudioTrack(int trackNo);
     int getCurrentAudioTrack();
+    QString getCurrentAudioTrackDescription();
 
     long long CalcMaxFFTime(long long ff);
 
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/NuppelVideoPlayer.o and ./libs/libmythtv/NuppelVideoPlayer.o differ
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/scanwizard.o and ./libs/libmythtv/scanwizard.o differ
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/siparser.o and ./libs/libmythtv/siparser.o differ
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/siscan.o and ./libs/libmythtv/siscan.o differ
diff -Bbupr -xconfig.log -xconfig.mak -xMakefile ../mythtv-bdvb-35.orig/libs/libmythtv/sitypes.h ./libs/libmythtv/sitypes.h
--- ../mythtv-bdvb-35.orig/libs/libmythtv/sitypes.h	2005-01-04 18:11:33.000000000 +1100
+++ ./libs/libmythtv/sitypes.h	2005-01-13 22:01:30.871236943 +1100
@@ -507,32 +507,86 @@ class PMTObject 
             return !hasCA;
         }
 
-        // Try to auto detect which audio stream to use
-        // (Can go away when we can record them all)
-        ElementaryPIDObject *PreferredAudioStream()
+		ElementaryPIDObject *DecAudioStream()
         {
+			bool found = false;
             QValueList<ElementaryPIDObject>::Iterator pit;
-            
-            // Change this if you prefer AC3 over PCM, and are not using TS recording
-            bool prefer_ac3 = false;            
-            if (prefer_ac3)
+			for (pit = Components.end(); pit != Components.begin(); --pit)
             {
-                for (pit = Components.begin(); pit != Components.end(); ++pit)
-                    if ((*pit).Record && ((*pit).Type == ES_TYPE_AUDIO_AC3))
+				if (found)
+				{
+					switch ((*pit).Record && ((*pit).Type))
+					{
+					case ES_TYPE_AUDIO_AC3:
+					case ES_TYPE_AUDIO_PCM:
                         return &(*pit);
+						break;
+					}
+				}
+		  		if ((&(*pit) == currentAudioPID) || (currentAudioPID == NULL))
+				{
+					found = true;
+				}	
+			}
+			//didn't find a track after current, search again from
+			//the beginning
+			currentAudioPID = NULL;
+			return DecAudioStream();			
             }
 
-            // Use first PCM stream
+		ElementaryPIDObject *IncAudioStream()
+		{
+			bool found = false;
+			QValueList<ElementaryPIDObject>::Iterator pit;
             for (pit = Components.begin(); pit != Components.end(); ++pit)
-                if ((*pit).Record && ((*pit).Type == ES_TYPE_AUDIO_PCM))
+			{
+				if (found)
+				{
+					switch ((*pit).Record && ((*pit).Type))
+					{
+					case ES_TYPE_AUDIO_AC3:
+					case ES_TYPE_AUDIO_PCM:
                     return &(*pit);
+						break;
+					}
+				}
+	 			if ((&(*pit) == currentAudioPID) || (currentAudioPID == NULL))
+				{
+					found = true;
+				}		
+			}
+			//didn't find a track after current, search again from
+			//the beginning
+			currentAudioPID = NULL;
+			return IncAudioStream();
+		}
 
-            // No PCM found - look for AC3
-            for (pit = Components.begin(); pit != Components.end(); ++pit)
-                if ((*pit).Record && ((*pit).Type == ES_TYPE_AUDIO_AC3))
-                    return &(*pit);
+		// Try to auto detect which audio stream to use
+		// (Can go away when we can record them all)
+		ElementaryPIDObject *PreferredAudioStream(bool prefer_ac3 = false)
+		{
+			QValueList<ElementaryPIDObject>::Iterator pit;
+			int desiredCodec = ES_TYPE_AUDIO_PCM;
+			currentAudioPID = NULL;
 
-            return NULL;
+			// Change this if you prefer AC3 over PCM, 
+			// and are not using TS recording.
+			if (prefer_ac3)
+			{
+				desiredCodec = ES_TYPE_AUDIO_AC3;	
+			}
+			for (pit = Components.begin(); pit != Components.end(); ++pit)
+			{
+				if ((*pit).Record && ((*pit).Type == desiredCodec))
+				{
+					currentAudioPID = &(*pit);
+				}
+			}
+			if ((prefer_ac3) && (currentAudioPID == NULL))
+			{
+				return PreferredAudioStream(false);
+			}
+		    return currentAudioPID;
         }
 
         // Try to auto detect which video stream to use
@@ -567,6 +621,7 @@ class PMTObject 
         bool hasCA;
         bool hasAudio;
         bool hasVideo;  
+		ElementaryPIDObject *currentAudioPID;
 };
 
 class PATObject 
Only in ./libs/libmythtv: sitypes.h.orig
Only in ./libs/libmythtv: sitypes.h.rej
Only in ./libs/libmythtv: transform.c
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/transform.o and ./libs/libmythtv/transform.o differ
diff -Bbupr -xconfig.log -xconfig.mak -xMakefile ../mythtv-bdvb-35.orig/libs/libmythtv/tv_play.cpp ./libs/libmythtv/tv_play.cpp
--- ../mythtv-bdvb-35.orig/libs/libmythtv/tv_play.cpp	2004-12-25 10:24:07.000000000 +1100
+++ ./libs/libmythtv/tv_play.cpp	2005-01-13 20:47:06.833517695 +1100
@@ -1592,11 +1592,8 @@ void TV::ProcessKeypress(QKeyEvent *e)
                 activenvp->incCurrentAudioTrack();
                 if ( activenvp->getCurrentAudioTrack() )
                 {
-                    QString msg = QString("%1 %2")
-                                  .arg(tr("Audio track"))
-                                  .arg(activenvp->getCurrentAudioTrack());
-
-                    osd->SetSettingsText(msg, 3);
+                    osd->SetSettingsText(
+						activenvp->getCurrentAudioTrackDescription(), 3);
                 }
             }
         }
@@ -1607,11 +1604,8 @@ void TV::ProcessKeypress(QKeyEvent *e)
                 activenvp->decCurrentAudioTrack();
                 if ( activenvp->getCurrentAudioTrack() )
                 {
-                    QString msg = QString("%1 %2")
-                                  .arg(tr("Audio track"))
-                                  .arg(activenvp->getCurrentAudioTrack());
-
-                    osd->SetSettingsText(msg, 3);
+                    osd->SetSettingsText(
+						activenvp->getCurrentAudioTrackDescription(), 3);
                 }
 
             }
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/tv_play.o and ./libs/libmythtv/tv_play.o differ
diff -Bbupr -xconfig.log -xconfig.mak -xMakefile ../mythtv-bdvb-35.orig/libs/libmythtv/tv_rec.cpp ./libs/libmythtv/tv_rec.cpp
--- ../mythtv-bdvb-35.orig/libs/libmythtv/tv_rec.cpp	2005-01-10 08:59:18.000000000 +1100
+++ ./libs/libmythtv/tv_rec.cpp	2005-01-13 21:09:39.000000000 +1100
@@ -2299,3 +2299,13 @@ void TVRec::StoreInputChannels(map<int, 
     pthread_mutex_unlock(&db_lock);
 }
 
+void TVRec::incCurrentAudioTrack()
+{
+#ifdef USING_DVB
+#endif
+}
+void TVRec::decCurrentAudioTrack()
+{
+#ifdef USING_DVB
+#endif
+}
diff -Bbupr -xconfig.log -xconfig.mak -xMakefile ../mythtv-bdvb-35.orig/libs/libmythtv/tv_rec.h ./libs/libmythtv/tv_rec.h
--- ../mythtv-bdvb-35.orig/libs/libmythtv/tv_rec.h	2004-08-16 08:38:31.000000000 +1000
+++ ./libs/libmythtv/tv_rec.h	2005-01-13 21:06:42.704761542 +1100
@@ -139,6 +139,8 @@ class TVRec
 
     int GetCaptureCardNum(void) { return m_capturecardnum; }
 
+	void incCurrentAudioTrack();
+	void decCurrentAudioTrack();
  protected:
     void RunTV(void);
     static void *EventThread(void *param);
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/tv_rec.o and ./libs/libmythtv/tv_rec.o differ
Only in .: oz-ac3-bigdvb3.5.diff
Only in .: oz-ac3-bigdvb3.5v2.diff
Only in .: oz-ac3-bigdvb3.5v3.diff
diff -Bbupr -xconfig.log -xconfig.mak -xMakefile ../mythtv-bdvb-35.orig/programs/mythfrontend/globalsettings.cpp ./programs/mythfrontend/globalsettings.cpp
--- ../mythtv-bdvb-35.orig/programs/mythfrontend/globalsettings.cpp	2004-12-20 05:26:28.000000000 +1100
+++ ./programs/mythfrontend/globalsettings.cpp	2005-01-10 17:29:25.000000000 +1100
@@ -184,6 +184,17 @@ static GenericCheckBox *IndividualMuteCo
     return gc;
 }
 
+static GenericCheckBox *WantAC3()
+{
+    GenericCheckBox *gc = new GenericCheckBox("WantAC3");
+    gc->setLabel(QObject::tr("Use Dolby digital audio where available"));
+    gc->setValue(false);
+    gc->setHelpText(QObject::tr("Where a Dolby digital sound track is "
+			"available (usually digital TV) use it. If this is not"
+			" set then Dolby audio will be disabled"));
+    return gc;
+}
+
 static GenericCheckBox *AC3PassThrough()
 {
     GenericCheckBox *gc = new GenericCheckBox("AC3PassThru");
@@ -1880,6 +1891,7 @@ public:
          setUseLabel(false);
 
          addChild(AudioOutputDevice());
+         addChild(WantAC3());
          addChild(AC3PassThrough());
          addChild(AggressiveBuffer());
 
Binary files ../mythtv-bdvb-35.orig/programs/mythfrontend/globalsettings.o and ./programs/mythfrontend/globalsettings.o differ
Binary files ../mythtv-bdvb-35.orig/programs/mythfrontend/mythfrontend and ./programs/mythfrontend/mythfrontend differ
Only in .: transform.diff
_______________________________________________
mythtv-dev mailing list
[email protected]
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev

Reply via email to