Detect audio stream type only after stream switch.

This commit is contained in:
Johns 2012-02-11 18:22:48 +01:00
parent baa4500a2c
commit a91533f6d1
6 changed files with 92 additions and 87 deletions

View File

@ -1,6 +1,7 @@
User johns User johns
Date: Date:
Detect audio stream type only after stream switch.
Detect more h264 streams with leading zeros. Detect more h264 streams with leading zeros.
VDPAU: support for studio levels added. VDPAU: support for studio levels added.
Add support for skip chroma deinterlace to software deinterlacer. Add support for skip chroma deinterlace to software deinterlacer.

View File

@ -156,6 +156,11 @@ Setup: /etc/vdr/setup.conf
softhddevice.Suspend.X11 = 0 softhddevice.Suspend.X11 = 0
1 suspend stops X11 server (not working yet) 1 suspend stops X11 server (not working yet)
VideoDisplayFormat = ?
0 pan and scan
1 letter box
2 center cut-out
Setup: /etc/vdr/remote.conf Setup: /etc/vdr/remote.conf
------ ------

4
Todo
View File

@ -40,6 +40,7 @@ video:
OSD can only be shown after some stream could be shown OSD can only be shown after some stream could be shown
yaepghd changed position is lost on channel switch yaepghd changed position is lost on channel switch
use x11 screen size without geometry configuration use x11 screen size without geometry configuration
pause (live tv) has sometime problems with SAT1 HD Pro7 HD
vdpau: vdpau:
software decoder path not working software decoder path not working
@ -83,10 +84,9 @@ audio:
selectable. selectable.
software volume support software volume support
add pause support for replay pause add pause support for replay pause
some plugin send a private LPCM stream (CODEC_ID_PCM_DVD), which
isn't supported by ffmpeg, write own parser.
Mute should do a real mute and not only set volume to zero. Mute should do a real mute and not only set volume to zero.
Starting suspended and muted, didn't register the mute. Starting suspended and muted, didn't register the mute.
switching stero/dolby produces klick sound
audio/alsa: audio/alsa:
better downmix of >2 channels on 2 channel hardware better downmix of >2 channels on 2 channel hardware

View File

@ -2070,13 +2070,7 @@ int64_t AudioGetClock(void)
*/ */
void AudioSetVolume(int volume) void AudioSetVolume(int volume)
{ {
#ifdef USE_ALSA return AudioUsedModule->SetVolume(volume);
AlsaSetVolume(volume);
#endif
#ifdef USE_OSS
OssSetVolume(volume);
#endif
(void)volume;
} }
/** /**

View File

@ -877,7 +877,7 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
int err; int err;
int isAC3; int isAC3;
// FIXME: use swr_convert from swresample // FIXME: use swr_convert from swresample (only in ffmpeg!)
// FIXME: tell ac3 decoder to use downmix // FIXME: tell ac3 decoder to use downmix
if (audio_decoder->ReSample) { if (audio_decoder->ReSample) {
audio_resample_close(audio_decoder->ReSample); audio_resample_close(audio_decoder->ReSample);

View File

@ -76,6 +76,7 @@ static volatile char NewAudioStream; ///< new audio stream
static volatile char SkipAudio; ///< skip audio stream static volatile char SkipAudio; ///< skip audio stream
static AudioDecoder *MyAudioDecoder; ///< audio decoder static AudioDecoder *MyAudioDecoder; ///< audio decoder
static enum CodecID AudioCodecID; ///< current codec id static enum CodecID AudioCodecID; ///< current codec id
static int AudioChannelID; ///< current audio channel id
/** /**
** mpeg bitrate table. ** mpeg bitrate table.
@ -202,8 +203,7 @@ static int FindAudioSync(const AVPacket * avpkt)
** @param size size of PES packet ** @param size size of PES packet
** @param id PES packet type ** @param id PES packet type
*/ */
int PlayAudio(const uint8_t * data, int size, int PlayAudio(const uint8_t * data, int size, uint8_t id)
__attribute__ ((unused)) uint8_t id)
{ {
int n; int n;
int osize; int osize;
@ -263,87 +263,92 @@ int PlayAudio(const uint8_t * data, int size,
// Detect audio code // Detect audio code
// MPEG-PS mp2 MPEG1, MPEG2, AC3, LPCM, AAC LATM // MPEG-PS mp2 MPEG1, MPEG2, AC3, LPCM, AAC LATM
// Syncword - 0x0B77 // only if unknown or new channel id
if (data[0] == 0x0B && data[1] == 0x77) { if (AudioCodecID == CODEC_ID_NONE || AudioChannelID != id) {
if (AudioCodecID != CODEC_ID_AC3) { AudioChannelID = id;
Debug(3, "[softhddev]%s: AC-3 %d\n", __FUNCTION__, id); // Syncword - 0x0B77
CodecAudioClose(MyAudioDecoder); if (data[0] == 0x0B && data[1] == 0x77) {
CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_AC3); if (AudioCodecID != CODEC_ID_AC3) {
AudioCodecID = CODEC_ID_AC3; Debug(3, "[softhddev]%s: AC-3 %d\n", __FUNCTION__, id);
} CodecAudioClose(MyAudioDecoder);
// Syncword - 0xFFFC - 0xFFFF CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_AC3);
} else if (data[0] == 0xFF && (data[1] & 0xFC) == 0xFC) { AudioCodecID = CODEC_ID_AC3;
if (AudioCodecID != CODEC_ID_MP2) {
Debug(3, "[softhddev]%s: MP2 %d\n", __FUNCTION__, id);
CodecAudioClose(MyAudioDecoder);
CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_MP2);
AudioCodecID = CODEC_ID_MP2;
}
// latm header 0x56E0 11bits: 0x2B7
} else if (data[0] == 0x56 && (data[1] & 0xE0) == 0xE0) {
if (AudioCodecID != CODEC_ID_AAC_LATM) {
Debug(3, "[softhddev]%s: AAC LATM %d\n", __FUNCTION__, id);
CodecAudioClose(MyAudioDecoder);
CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_AAC_LATM);
AudioCodecID = CODEC_ID_AAC_LATM;
}
// Private stream + LPCM ID
} else if (data[-n - 9 + 3] == 0xBD && data[0] == 0xA0) {
if (AudioCodecID != CODEC_ID_PCM_DVD) {
static int samplerates[] = { 48000, 96000, 44100, 32000 };
int samplerate;
int channels;
int bits_per_sample;
Debug(3, "[softhddev]%s: LPCM %d sr:%d bits:%d chan:%d\n",
__FUNCTION__, id, data[5] >> 4,
(((data[5] >> 6) & 0x3) + 4) * 4, (data[5] & 0x7) + 1);
CodecAudioClose(MyAudioDecoder);
bits_per_sample = (((data[5] >> 6) & 0x3) + 4) * 4;
if (bits_per_sample != 16) {
Error(_
("softhddev: LPCM %d bits per sample aren't supported\n"),
bits_per_sample);
// FIXME: handle unsupported formats.
} }
samplerate = samplerates[data[5] >> 4]; // Syncword - 0xFFFC - 0xFFFF
channels = (data[5] & 0x7) + 1; } else if (data[0] == 0xFF && (data[1] & 0xFC) == 0xFC) {
AudioSetup(&samplerate, &channels, 0); if (AudioCodecID != CODEC_ID_MP2) {
if (samplerate != samplerates[data[5] >> 4]) { Debug(3, "[softhddev]%s: MP2 %d\n", __FUNCTION__, id);
Error(_("softhddev: LPCM %d sample-rate is unsupported\n"), CodecAudioClose(MyAudioDecoder);
samplerates[data[5] >> 4]); CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_MP2);
// FIXME: support resample AudioCodecID = CODEC_ID_MP2;
} }
if (channels != (data[5] & 0x7) + 1) { // latm header 0x56E0 11bits: 0x2B7
Error(_("softhddev: LPCM %d channels are unsupported\n"), } else if (data[0] == 0x56 && (data[1] & 0xE0) == 0xE0) {
(data[5] & 0x7) + 1); // && (((data[1] & 0x1F) << 8) + (data[2] & 0xFF)) < size
// FIXME: support resample if (AudioCodecID != CODEC_ID_AAC_LATM) {
Debug(3, "[softhddev]%s: AAC LATM %d\n", __FUNCTION__, id);
CodecAudioClose(MyAudioDecoder);
CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_AAC_LATM);
AudioCodecID = CODEC_ID_AAC_LATM;
} }
//CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_PCM_DVD); // Private stream + LPCM ID
AudioCodecID = CODEC_ID_PCM_DVD; } else if (data[-n - 9 + 3] == 0xBD && data[0] == 0xA0) {
} if (AudioCodecID != CODEC_ID_PCM_DVD) {
} else { static int samplerates[] = { 48000, 96000, 44100, 32000 };
// no start package int samplerate;
// FIXME: Nick/Viva sends this shit, need to find sync in packet int channels;
// FIXME: otherwise it takes too long until sound appears int bits_per_sample;
if (AudioCodecID == CODEC_ID_NONE) { Debug(3, "[softhddev]%s: LPCM %d sr:%d bits:%d chan:%d\n",
Debug(3, "[softhddev]%s: ??? %d\n", __FUNCTION__, id); __FUNCTION__, id, data[5] >> 4,
avpkt->data = (void *)data; (((data[5] >> 6) & 0x3) + 4) * 4, (data[5] & 0x7) + 1);
avpkt->size = size; CodecAudioClose(MyAudioDecoder);
n = FindAudioSync(avpkt);
if (n < 0) {
return osize;
}
avpkt->pts = AV_NOPTS_VALUE; bits_per_sample = (((data[5] >> 6) & 0x3) + 4) * 4;
CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_MP2); if (bits_per_sample != 16) {
AudioCodecID = CODEC_ID_MP2; Error(_
data += n; ("softhddev: LPCM %d bits per sample aren't supported\n"),
size -= n; bits_per_sample);
// FIXME: handle unsupported formats.
}
samplerate = samplerates[data[5] >> 4];
channels = (data[5] & 0x7) + 1;
AudioSetup(&samplerate, &channels, 0);
if (samplerate != samplerates[data[5] >> 4]) {
Error(_("softhddev: LPCM %d sample-rate is unsupported\n"),
samplerates[data[5] >> 4]);
// FIXME: support resample
}
if (channels != (data[5] & 0x7) + 1) {
Error(_("softhddev: LPCM %d channels are unsupported\n"),
(data[5] & 0x7) + 1);
// FIXME: support resample
}
//CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_PCM_DVD);
AudioCodecID = CODEC_ID_PCM_DVD;
}
} else {
// no start package
// FIXME: Nick/Viva sends this shit, need to find sync in packet
// FIXME: otherwise it takes too long until sound appears
if (AudioCodecID == CODEC_ID_NONE) {
Debug(3, "[softhddev]%s: ??? %d\n", __FUNCTION__, id);
avpkt->data = (void *)data;
avpkt->size = size;
n = FindAudioSync(avpkt);
if (1 && n < 0) {
return osize;
}
avpkt->pts = AV_NOPTS_VALUE;
CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_MP2);
AudioCodecID = CODEC_ID_MP2;
data += n;
size -= n;
}
} }
// no decoder or codec known // still no decoder or codec known
if (AudioCodecID == CODEC_ID_NONE) { if (AudioCodecID == CODEC_ID_NONE) {
return osize; return osize;
} }