]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/mpeg.c
Merge commit 'c869fcdeac3b7cd71a852b928902daadeca55685'
[ffmpeg] / libavformat / mpeg.c
index 1ea58d5ed525457fd0239f8b0ea911040d1e6a68..1777283939cacfe12382cccef31a02a9e9cf6f11 100644 (file)
@@ -193,6 +193,8 @@ static long mpegps_psm_parse(MpegDemuxContext *m, AVIOContext *pb)
     /* skip program_stream_info */
     avio_skip(pb, ps_info_length);
     es_map_length = avio_rb16(pb);
+    /* Ignore es_map_length, trust psm_length */
+    es_map_length = psm_length - ps_info_length - 10;
 
     /* at least one es available? */
     while (es_map_length >= 4){
@@ -521,7 +523,13 @@ static int mpegps_read_packet(AVFormatContext *s,
         codec_id = AV_CODEC_ID_DVD_NAV;
     } else if (startcode >= 0x1c0 && startcode <= 0x1df) {
         type = AVMEDIA_TYPE_AUDIO;
-        codec_id = m->sofdec > 0 ? AV_CODEC_ID_ADPCM_ADX : AV_CODEC_ID_MP2;
+        if (m->sofdec > 0) {
+            codec_id = AV_CODEC_ID_ADPCM_ADX;
+            // Auto-detect AC-3
+            request_probe = 50;
+        } else {
+            codec_id = AV_CODEC_ID_MP2;
+        }
     } else if (startcode >= 0x80 && startcode <= 0x87) {
         type = AVMEDIA_TYPE_AUDIO;
         codec_id = AV_CODEC_ID_AC3;