changeset 22037:489b443a8ecf

added code to scan the video stream to search the actual video codec used; triggered only if requested by the user with option -psprobe. Evo files require this option because H264 is stored like MPEG2 without using the PSM
author nicodvb
date Sun, 28 Jan 2007 21:42:22 +0000
parents 2c6cccdeaf65
children 2f2dab18d868
files cfg-common.h libmpdemux/demux_mpg.c
diffstat 2 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-common.h	Sun Jan 28 21:27:15 2007 +0000
+++ b/cfg-common.h	Sun Jan 28 21:42:22 2007 +0000
@@ -235,6 +235,7 @@
 	{"tsprog", &ts_prog, CONF_TYPE_INT, CONF_RANGE, 0, 65534, NULL},
 #define TS_MAX_PROBE_SIZE 2000000 /* don't forget to change this in libmpdemux/demux_ts.c too */
 	{"tsprobe", &ts_probe, CONF_TYPE_POSITION, 0, 0, TS_MAX_PROBE_SIZE, NULL},
+	{"psprobe", &ps_probe, CONF_TYPE_POSITION, 0, 0, TS_MAX_PROBE_SIZE, NULL},
 	{"tskeepbroken", &ts_keep_broken, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 
 	// draw by slices or whole frame (useful with libmpeg2/libavcodec)
@@ -384,6 +385,7 @@
 extern int ts_prog;
 extern int ts_keep_broken;
 extern off_t ts_probe;
+extern off_t ps_probe;
 
 #include "stream/tv.h"
 #include "stream/stream_radio.h"
--- a/libmpdemux/demux_mpg.c	Sun Jan 28 21:27:15 2007 +0000
+++ b/libmpdemux/demux_mpg.c	Sun Jan 28 21:42:22 2007 +0000
@@ -41,6 +41,7 @@
 
 extern char* dvdsub_lang;
 static int mpeg_pts_error=0;
+off_t ps_probe = 0;
 
 static int parse_psm(demuxer_t *demux, int len) {
   unsigned char c, id, type;
@@ -1051,6 +1052,35 @@
         }
     }
 
+    if(!sh_video->format && ps_probe > 0) {
+        int mpeg2, h264, mpeg4, head;
+        off_t pos = stream_tell(demuxer->stream);
+
+        clear_stats();
+        do {
+            head=sync_video_packet(demuxer->video);
+            update_stats(head);
+            skip_video_packet(demuxer->video);
+        } while(stream_tell(demuxer->stream) < pos + ps_probe);
+
+        ds_free_packs(demuxer->video);
+        stream_seek(demuxer->stream, pos);
+        mp_msg(MSGT_DEMUX,MSGL_INFO,"MPEG packet stats: p100: %d  p101: %d p1B6: %d p12x: %d sli: %d a: %d b: %d c: %d idr: %d sps: %d pps: %d\n",
+            num_elementary_packets100, num_elementary_packets101,
+            num_elementary_packets1B6, num_elementary_packets12x,
+            num_h264_slice, num_h264_dpa, num_h264_dpb, num_h264_dpc,
+            num_h264_idr, num_h264_sps, num_h264_pps);
+
+        if(num_elementary_packets1B6>3 && num_elementary_packets12x>=1 &&
+            num_elementary_packets100<=num_elementary_packets12x)
+            sh_video->format = 0x10000004;
+        else if((num_h264_slice>3 || (num_h264_dpa>3 && num_h264_dpb>3 && num_h264_dpc>3)) &&
+            num_h264_sps>=1 && num_h264_pps>=1 && num_h264_idr>=1 &&
+            num_elementary_packets1B6==0)
+                sh_video->format = 0x10000005;
+        else sh_video->format = 0x10000002;
+    }
+
     return demuxer;
 }