[FFmpeg-devel] [PATCH 3/3] mpegdemux: support MLP/AOB

Michael Niedermayer michaelni at gmx.at
Tue Jul 31 21:08:15 CEST 2012


Fixes issue1731

Based-on-patch-by: carl
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavformat/mpeg.c |   19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index ba80913..2158c0a 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -374,6 +374,7 @@ static int mpegps_read_packet(AVFormatContext *s,
     MpegDemuxContext *m = s->priv_data;
     AVStream *st;
     int len, startcode, i, es_type, ret;
+    int lpcm_header_len;
     int request_probe= 0;
     enum CodecID codec_id = CODEC_ID_NONE;
     enum AVMediaType type;
@@ -390,8 +391,7 @@ static int mpegps_read_packet(AVFormatContext *s,
 
         /* audio: skip header */
         avio_r8(s->pb);
-        avio_r8(s->pb);
-        avio_r8(s->pb);
+        lpcm_header_len = avio_rb16(s->pb);
         len -= 3;
         if (startcode >= 0xb0 && startcode <= 0xbf) {
             /* MLP/TrueHD audio has a 4-byte header */
@@ -457,8 +457,12 @@ static int mpegps_read_packet(AVFormatContext *s,
         codec_id = CODEC_ID_DTS;
     } else if (startcode >= 0xa0 && startcode <= 0xaf) {
         type = AVMEDIA_TYPE_AUDIO;
-        /* 16 bit form will be handled as CODEC_ID_PCM_S16BE */
-        codec_id = CODEC_ID_PCM_DVD;
+        if(lpcm_header_len == 6) {
+            codec_id = CODEC_ID_MLP;
+        } else {
+            /* 16 bit form will be handled as CODEC_ID_PCM_S16BE */
+            codec_id = CODEC_ID_PCM_DVD;
+        }
     } else if (startcode >= 0xb0 && startcode <= 0xbf) {
         type = AVMEDIA_TYPE_AUDIO;
         codec_id = CODEC_ID_TRUEHD;
@@ -492,6 +496,12 @@ static int mpegps_read_packet(AVFormatContext *s,
     if(st->discard >= AVDISCARD_ALL)
         goto skip;
     if (startcode >= 0xa0 && startcode <= 0xaf) {
+      if (lpcm_header_len == 6) {
+            if (len < 6)
+                goto skip;
+            avio_skip(s->pb, 6);
+            len -=6;
+      } else {
         int b1, freq;
 
         /* for LPCM, we just skip the header and consider it is raw
@@ -513,6 +523,7 @@ static int mpegps_read_packet(AVFormatContext *s,
             st->codec->codec_id = CODEC_ID_PCM_S16BE;
         else if (st->codec->bits_per_coded_sample == 28)
             return AVERROR(EINVAL);
+      }
     }
     ret = av_get_packet(s->pb, pkt, len);
     pkt->pts = pts;
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list