On Sunday 06 February 2005 15:30, Isaac Richards wrote:
> On Monday 31 January 2005 04:28 am, Mark Anderson wrote:
> > On Monday 31 January 2005 16:53, Isaac Richards wrote:
> > > On Saturday 29 January 2005 05:26 pm, Mark Anderson wrote:
> > > > For those following the AC3 audio saga, here is a patch against the
> > > > CVS from yesterday to get AC3 audio up and running with DVB. This
> > > > patch is different to previous patches in a number of ways, mostly I
> > > > have changed things after advice from Isaac.
> > >
> > > Before I apply this - could you test moving the av_remove_stream to the
> > > Reset() function instead of SeekReset()? That will only get called
> > > when channel/inputs change, instead of on every seek..
> >
> > Made the changes and everything seems to function correctly.
> >
> > I have included a new version diffed against CVS, this removes the change
> > in sitypes.cpp as indicated by Jesper. I also added a couple of comments
> > above the av_remove_stream code block.
>
> I've just reverted the av_remove_stream part of this patch. It's causing
> normal XvMC to die on a channel change, and I haven't had time to track
> down why. Can you come up with a better way to handle this?
>
> Isaac
Attached is a new version of the patch that does not clear out the video
stream on a channel change, it only removes audio streams. Could someone who
can reproduce this problem apply the patch (to the reverted CVS) and see if
the channel change problem comes back. Also could someone confirm if the
problem is exhibited when using TS rather than PS recording?
I just tested this patch with my system running nvidia XvMC and am able to
change channels fine. I have an EPIA but haven't got around to setting up
XvMC so am not in a position to test the unichrome XvMC at the moment.
Cheers,
Mark Anderson
Index: libs/libmythtv/avformatdecoder.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/avformatdecoder.cpp,v
retrieving revision 1.131
diff -b -u -p -r1.131 avformatdecoder.cpp
--- libs/libmythtv/avformatdecoder.cpp 29 Jan 2005 00:06:57 -0000 1.131
+++ libs/libmythtv/avformatdecoder.cpp 6 Feb 2005 21:12:28 -0000
@@ -255,6 +255,17 @@ void AvFormatDecoder::Reset(void)
{
SeekReset();
+ //
+ // Clear out the existing audio streams
+ // so we can get a clean set from the
+ // new seek position.
+ for (int i = ic->nb_streams - 1; i >= 0; i--)
+ {
+ if (ic->streams[i]->codec.codec_type == CODEC_TYPE_AUDIO)
+ {
+ av_remove_stream(ic, ic->streams[i]->id);
+ }
+ }
m_positionMap.clear();
framesPlayed = 0;
framesRead = 0;
@@ -1140,6 +1151,7 @@ void AvFormatDecoder::incCurrentAudioTra
wantedAudioStream = audioStreams[currentAudioTrack];
AVCodecContext *e = &ic->streams[wantedAudioStream]->codec;
+ SetupAudioStream();
CheckAudioParams(e->sample_rate, e->channels, true);
}
}
@@ -1157,6 +1169,7 @@ void AvFormatDecoder::decCurrentAudioTra
wantedAudioStream = audioStreams[currentAudioTrack];
AVCodecContext *e = &ic->streams[wantedAudioStream]->codec;
+ SetupAudioStream();
CheckAudioParams(e->sample_rate, e->channels, true);
}
}
@@ -1175,10 +1188,23 @@ bool AvFormatDecoder::setCurrentAudioTra
wantedAudioStream = audioStreams[currentAudioTrack];
AVCodecContext *e = &ic->streams[wantedAudioStream]->codec;
+ SetupAudioStream();
CheckAudioParams(e->sample_rate, e->channels, true);
return true;
}
+//
+// This function will select the best audio track
+// available usgin the following rules:
+//
+// 1. The fist AC3 track found will be select,
+// 2. If no AC3 is found then the audio track with
+// the most number of channels is selected.
+//
+// This code has no awareness to language preferences
+// although I don't think it would be too hard to
+// add.
+//
bool AvFormatDecoder::autoSelectAudioTrack()
{
if (!audioStreams.size())
@@ -1191,7 +1217,10 @@ bool AvFormatDecoder::autoSelectAudioTra
if (do_ac3_passthru)
minChannels = 2;
- while (!foundAudio)
+ int selectedTrack = -1;
+ int selectedChannels = -1;
+
+ while ((!foundAudio) && (minChannels >= 0))
{
for (track = maxTracks; track >= 0; track--)
{
@@ -1200,26 +1229,58 @@ bool AvFormatDecoder::autoSelectAudioTra
if (e->channels > minChannels)
{
- currentAudioTrack = track;
- wantedAudioStream = tempStream;
- VERBOSE(VB_AUDIO,
- QString("Auto-selecting audio track #%1 (stream #%2).")
- .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 we find an AC3 codec then we select it
+ //as the preferred codec.
+ if (e->codec_id == CODEC_ID_AC3)
+ {
+ selectedTrack = track;
+ foundAudio = true;
+ break;
+ }
- AVCodecContext *e = &ic->streams[wantedAudioStream]->codec;
- CheckAudioParams(e->sample_rate, e->channels, true);
- return true;
+ if (e->channels > selectedChannels)
+ {
+ //this is a candidate with more channels
+ //than the previous, or there was no previous
+ //so select it.
+ selectedTrack = track;
}
}
+ }
+ if (!foundAudio)
+ {
minChannels--;
- if (minChannels < 0)
- return false;
+ }
}
+ if (selectedTrack == -1)
+ {
+ //no suitable track was found
return false;
+ }
+
+ currentAudioTrack = selectedTrack;
+ wantedAudioStream = audioStreams[currentAudioTrack];
+
+ AVCodecContext *e = &ic->streams[wantedAudioStream]->codec;
+ if (e->codec_id == CODEC_ID_AC3)
+ {
+ VERBOSE(VB_AUDIO,
+ QString("Auto-selecting AC3 audio track (stream #%2).")
+ .arg(wantedAudioStream));
+ }
+ else
+ {
+ VERBOSE(VB_AUDIO,
+ QString("Auto-selecting audio track #%1 (stream #%2).")
+ .arg(selectedTrack + 1).arg(wantedAudioStream));
+ VERBOSE(VB_AUDIO,
+ QString("It has %1 channels and we needed at least %2")
+ .arg(selectedChannels).arg(minChannels + 1));
+ }
+ SetupAudioStream();
+ CheckAudioParams(e->sample_rate, e->channels, true);
+ return true;
}
void AvFormatDecoder::SetupAudioStream(void)
_______________________________________________
mythtv-dev mailing list
[email protected]
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev