For those interested, attached is an updated patch to get AC3 audio working 
with bigdvb3.5 in australia. No functional changes, will just apply cleanly 
against big dvb 3.5

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 -buprB -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-10 17:29:25.000000000 +1100
@@ -1457,6 +1457,8 @@ static int mpegps_read_pes_header(AVForm
         goto redo;
 
     if (startcode == 0x1bd) {
+        startcode = 0x80;
+#if 0
         if (len < 1)
             goto redo;
         startcode = get_byte(&s->pb);
@@ -1470,7 +1472,9 @@ static int mpegps_read_pes_header(AVForm
             get_byte(&s->pb);
             len -= 3;
         }
+#endif
     }
+
     if(dts != AV_NOPTS_VALUE && ppos && s->build_index){
         int i;
         for(i=0; i<s->nb_streams; i++){
@@ -1531,6 +1535,10 @@ static int mpegps_read_packet(AVFormatCo
         goto skip;
     st->codec.codec_type = type;
     st->codec.codec_id = codec_id;
+   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 -buprB -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-10 17:42:49.314108911 +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,11 @@ int AvFormatDecoder::ScanStreams(bool no
         {
             VERBOSE(VB_IMPORTANT, 
                     QString("AvFormatDecoder: Could not find decoder for "
-                            "codec (%1) aborting.")
+                            "codec (%1) ignoring.")
                            .arg(enc->codec_id));
-            av_close_input_file(ic);
-            ic = NULL;
-            scanerror = -1;
+            //av_close_input_file(ic);
+            //ic = NULL;
+            //scanerror = -1;
             continue;
         }
 
@@ -597,8 +598,9 @@ bool AvFormatDecoder::CheckVideoParams(i
     return true;
 }
 
-void AvFormatDecoder::CheckAudioParams(int freq, int channels, bool safe)
+void AvFormatDecoder::CheckAudioParams(int freq, int channels, int codec_id, bool safe)
 {
+
     if (freq <= 0 || channels <= 0)
         return;
 
@@ -604,18 +606,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 +635,11 @@ 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 +1023,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 +1040,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 +1058,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 wantac3)
 {
     if (!audioStreams.size())
         return false;
 
+    if (wantac3)
+    {
+	wantac3 = gContext->GetNumSetting("WantAC3", false);
+    }
+
     bool foundAudio = false;
     int minChannels = 1;
     int maxTracks = (audioStreams.size() - 1);
     int track;
-    if (do_ac3_passthru)
+    if (wantac3)
         minChannels = 2;
-
     while (!foundAudio)
     {
         for (track = maxTracks; track >= 0; track--)
@@ -1076,7 +1084,11 @@ bool AvFormatDecoder::autoSelectAudioTra
         {
             int tempStream = audioStreams[track];
             AVCodecContext *e = &ic->streams[tempStream]->codec;
-
+	    if (((wantac3) && (e->codec_id != CODEC_ID_AC3)) || 
+	       ((!wantac3) && (e->codec_id == CODEC_ID_AC3))) 
+	    {
+                 continue;
+            }
             if (e->channels > minChannels)
             {
                 currentAudioTrack = track;
@@ -1087,16 +1099,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 (wantac3)
+                {
+                    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 (wantac3)
+            {
+                  return autoSelectAudioTrack(false);
+            }
             return false;
     }
+    }
 
     return false;
 }
@@ -1113,6 +1135,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 +1144,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 +1186,7 @@ bool AvFormatDecoder::GetFrame(int onlyv
 
     while (!allowedquit)
     {
+	
         if (gotvideo)
         {
             if (lowbuffers && onlyvideo == 0 && lastapts < lastvpts + 100 &&
@@ -1272,9 +1298,14 @@ bool AvFormatDecoder::GetFrame(int onlyv
             {
                 case CODEC_TYPE_AUDIO:
                 {
+                    //hmm the codec has changed from what we were initialised with
+                    //move to the next stream to see if it is correct
+		    if (curstream->codec.codec_id != audio_codec)
+                    {
+                        incCurrentAudioTrack();
+                    }
                     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 +1335,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
Only in ./libs/libmythtv: .avformatdecoder.cpp.swp
diff -buprB -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-10 17:29:25.000000000 +1100
@@ -78,7 +78,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 +112,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 +134,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 -buprB -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-10 17:29:25.000000000 +1100
@@ -394,6 +394,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 +409,7 @@ void send_ipack(ipack *p)
 				
 				ac3_off +=  nframes * ai.framesize - p->count;
 			}
+#endif
 			break;
 
 		case 0x20:
@@ -434,17 +436,20 @@ 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;
 				break;
-				
+#endif				
 			case 0x20:
+#if 0
 				p->count += 2;
 				p->buf[9] = 0x20;
 				p->buf[10] = 0;				
+#endif
 				break;
 			}
 		}		
Only in ./libs/libmythtv/dvbdev: transform.c.orig
diff -buprB -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-10 17:50:40.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();
 
Only in ./libs/libmythtv: dvbrecorder.cpp.orig
Only in ./libs/libmythtv: dvbrecorder.cpp.rej
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/dvbrecorder.o and ./libs/libmythtv/dvbrecorder.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/NuppelVideoPlayer.o and ./libs/libmythtv/NuppelVideoPlayer.o differ
diff -buprB -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-10 17:46:26.000000000 +1100
@@ -509,13 +509,12 @@ class PMTObject 
 
         // Try to auto detect which audio stream to use
         // (Can go away when we can record them all)
-        ElementaryPIDObject *PreferredAudioStream()
+	ElementaryPIDObject *PreferredAudioStream(bool wantAC3 = 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)
+		if (wantAC3)
             {
                 for (pit = Components.begin(); pit != Components.end(); ++pit)
                     if ((*pit).Record && ((*pit).Type == ES_TYPE_AUDIO_AC3))
Only in ./libs/libmythtv: sitypes.h.orig
Only in ./libs/libmythtv: sitypes.h.rej
Binary files ../mythtv-bdvb-35.orig/libs/libmythtv/transform.o and ./libs/libmythtv/transform.o differ
Only in ./: oz-ac3-bigdvb3.5.diff
diff -buprB -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
_______________________________________________
mythtv-dev mailing list
[email protected]
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev

Reply via email to