[mythtv] [Experimental PATCH] BIG DVB PATCH V3.2 Released

Mark Anderson markjanderson at mail.com
Tue Dec 21 02:33:32 UTC 2004


>
> Just found out that in ScanStreams, the line:
>
> AVCodec *codec = avcodec_find_decoder(enc->codec_id);
>
> evals to nothing as enc->codec_id = 86021 which is 0x15005 which is
> CODEC_ID_DTS. (incidently I couldn't register the DTS codec). I am
> tempted to just swap the order of CODEC_ID_DTS and CODEC_ID_AC3 in
> avcodec.h and see if it works. At the moment trying to find out where
> 0x15005 comes from.
>
> My apologies for the misconceptions in the A52/AC3 specs... :(
>
>
I am also in Australia and actively trying to get AC3 passthrough working with 
this patch. I have been monitoring this thread for help. 

I found the problem in the avcodec_find_decoder function last night. The 
problem is actually in the ScanStreams function which doesn'y correctly 
handler invalid codecs. I hacked the following changes in to fix the problem

--- avformatdecoder.cpp.orig    2004-12-21 13:13:33.411319906 +1100
+++ avformatdecoder.cpp 2004-12-20 16:44:21.000000000 +1100
@@ -518,9 +518,9 @@ int AvFormatDecoder::ScanStreams(bool no
         {
             VERBOSE(VB_IMPORTANT, QString("AvFormatDecoder: Could not find 
decoder for 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;
         }

After making this change the DTS codec is correclty ignored and the frontend 
no longer crashes. However, once you get past this you will then run into a 
problem with the autoSelectAudioTrack not correctly selecting the AC3 track. 
It seems it selects the first track that has 2 or more channels, which seems 
to change between seperate "Watch TV" calls, not sure why it is not 
consistent but I changed the function to choose ac3 tracks before other 
tracks. Note that the do_ac3passthrough variable is always false when this 
function is called (it hasn't been setup at that stage). 

After doing this I can choose a tv channel that has no AC3 sound (e.g the Ten 
TV Guide) and it plays the pcm fine, then I change to a station that has AC3 
(e.g. channel Ten) and I get the occasional noise from the amp but that is 
all,  but all of the AC3 configuration seems to happen correctly. I think 
this will be related to the problems that have already been disccussed in 
this thread but I haven't had a chance to patch the changes in to try it out.  

Hope all this is usefull and we can get some digital sound working soon!

Cheers 
Mark.

The diffs are as follows:
--- avformatdecoder.h.orig      2004-12-21 13:23:33.513058773 +1100
+++ avformatdecoder.h   2004-12-20 13:03:31.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; }

--- avformatdecoder.cpp.orig    2004-12-21 13:20:47.503176958 +1100
+++ avformatdecoder.cpp 2004-12-21 13:21:38.926157285 +1100
@@ -518,9 +518,9 @@ int AvFormatDecoder::ScanStreams(bool no
         {
             VERBOSE(VB_IMPORTANT, QString("AvFormatDecoder: Could not find 
decoder for 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;
         }

@@ -1038,7 +1038,7 @@ bool AvFormatDecoder::setCurrentAudioTra
     return true;
 }

-bool AvFormatDecoder::autoSelectAudioTrack()
+bool AvFormatDecoder::autoSelectAudioTrack(bool wantac3)
 {
     if (!audioStreams.size())
         return false;
@@ -1047,15 +1047,19 @@ bool AvFormatDecoder::autoSelectAudioTra
     int maxTracks = (audioStreams.size() - 1);
     int track;

-    if (do_ac3passthrough)
+    if (wantac3)
         minChannels = 2;
-
     while (!foundAudio)
     {
         for (track = maxTracks; track >= 0; track--)
         {
             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;
@@ -1064,6 +1068,10 @@ bool AvFormatDecoder::autoSelectAudioTra
                                   .arg(track + 1).arg(tempStream));
                 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);
                 return true;
@@ -1072,6 +1080,10 @@ bool AvFormatDecoder::autoSelectAudioTra
         minChannels--;
         if (minChannels < 0)
         {
+           if (wantac3)
+           {
+                return autoSelectAudioTrack(false);
+            }
             return false;
         }
     }



More information about the mythtv-dev mailing list