[FFmpeg-devel] [PATCH]Support DVD-A files containing LPCM

Carl Eugen Hoyos cehoyos at ag.or.at
Mon Jul 29 13:18:57 CEST 2013


Hi!

Attached patch fixes the sample from ticket #2758 for me, 
I cannot implement >16bit or multichannel without samples.

Please review, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 5d5b09f..544c0df 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -581,6 +581,37 @@ static int mpegps_read_packet(AVFormatContext *s,
                 goto skip;
             avio_skip(s->pb, 6);
             len -=6;
+      } else if (lpcm_header_len > 8 && startcode == 0xa0) {
+          // DVD-A LPCM audio
+          int sample_rates[] = { 48000, 96000, 192000,
+                                 0, 0, 0, 0, 0,
+                                 44100, 88200, 176400 };
+          unsigned sample_rate, channels;
+          avio_skip(s->pb, 2); // Pointer to start of audio frame
+          avio_skip(s->pb, 1); // Unknown
+          len -= 3;
+          if (avio_r8(s->pb) & 0xF0) {
+              avpriv_request_sample(s, "DVD-A LPCM audio != 16bit");
+              return AVERROR_PATCHWELCOME;
+          }
+          st->codec->codec_id = AV_CODEC_ID_PCM_S16BE;
+          sample_rate = avio_r8(s->pb) >> 4;
+          len -= 2;
+          if (sample_rate > 10)
+              goto skip;
+          st->codec->sample_rate = sample_rates[sample_rate];
+          if (!st->codec->sample_rate)
+              goto skip;
+          avio_skip(s->pb, 1); // Unknown
+          channels = avio_r8(s->pb);
+          len -= 2;
+          if (channels > 1) {
+              avpriv_request_sample(s, "Multichannel DVD-A LPCM audio");
+              return AVERROR_PATCHWELCOME;
+          }
+          st->codec->channels = channels + 1;
+          avio_skip(s->pb, lpcm_header_len - 7);
+          len -= lpcm_header_len - 7;
       } else {
         int b1, freq;
 


More information about the ffmpeg-devel mailing list