summaryrefslogtreecommitdiffstats
path: root/libmpdemux/demuxer.c
diff options
context:
space:
mode:
authornicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-06-06 21:30:53 +0000
committernicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-06-06 21:30:53 +0000
commit2b1fef3a9848356e2addb9345d6a42e632630110 (patch)
tree7af494e02946a228c1bb8bc150c8b4fbf205451b /libmpdemux/demuxer.c
parent8f224ba1bc91d948202b9ea12c17fdb4a355e68e (diff)
downloadmpv-2b1fef3a9848356e2addb9345d6a42e632630110.tar.bz2
mpv-2b1fef3a9848356e2addb9345d6a42e632630110.tar.xz
moved mpeg-ps/es probing code to demux_mpg.c
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15671 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux/demuxer.c')
-rw-r--r--libmpdemux/demuxer.c119
1 files changed, 17 insertions, 102 deletions
diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c
index 7927160dce..615dd47143 100644
--- a/libmpdemux/demuxer.c
+++ b/libmpdemux/demuxer.c
@@ -584,21 +584,6 @@ float ds_get_next_pts(demux_stream_t *ds) {
// ====================================================================
-// feed-back from demuxers:
-extern int num_elementary_packets100; // for MPEG-ES fileformat detection
-extern int num_elementary_packets101;
-extern int num_elementary_packetsPES;
-extern int num_elementary_packets1B6;
-extern int num_elementary_packets12x;
-extern int num_h264_slice; //combined slice
-extern int num_h264_dpa; //DPA Slice
-extern int num_h264_dpb; //DPB Slice
-extern int num_h264_dpc; //DPC Slice
-extern int num_h264_idr; //IDR Slice
-extern int num_h264_sps;
-extern int num_h264_pps;
-extern int num_mp3audio_packets;
-
// commandline options, flags:
extern int force_ni;
extern int pts_from_bps;
@@ -617,6 +602,7 @@ int demux_open_fli(demuxer_t* demuxer);
int demux_open_mf(demuxer_t* demuxer);
int demux_open_film(demuxer_t* demuxer);
int demux_open_roq(demuxer_t* demuxer);
+int demux_mpg_probe(demuxer_t *demuxer);
#ifdef HAVE_LIBDV095
int demux_open_rawdv(demuxer_t* demuxer);
extern int rawdv_check_file(demuxer_t *demuxer);
@@ -1000,96 +986,25 @@ if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_LMLM4){
demuxer = NULL;
}
}
-//=============== Try to open as MPEG-PS file: =================
+
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPEG_PS){
- int pes=1;
- int tmp;
- off_t tmppos;
- file_format=DEMUXER_TYPE_UNKNOWN;
- while(pes>=0){
- demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_PS,audio_id,video_id,dvdsub_id);
-
- // try to pre-detect PES:
- tmppos=stream_tell(demuxer->stream);
- tmp=stream_read_dword(demuxer->stream);
- if(tmp==0x1E0 || tmp==0x1C0){
- tmp=stream_read_word(demuxer->stream);
- if(tmp>1 && tmp<=2048) pes=0; // demuxer->synced=3; // PES...
- }
- stream_seek(demuxer->stream,tmppos);
-
- if(!pes) demuxer->synced=3; // hack!
-
- num_elementary_packets100=0;
- num_elementary_packets101=0;
- num_elementary_packets1B6=0;
- num_elementary_packets12x=0;
- num_elementary_packetsPES=0;
- num_h264_slice=0; //combined slice
- num_h264_dpa=0; //DPA Slice
- num_h264_dpb=0; //DPB Slice
- num_h264_dpc=0; //DPC Slice
- num_h264_idr=0; //IDR Slice
- num_h264_sps=0;
- num_h264_pps=0;
- num_mp3audio_packets=0;
-
- if(demux_mpg_open(demuxer)){
- if(!pes)
+ demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_PS,audio_id,video_id,dvdsub_id);
+ file_format = demux_mpg_probe(demuxer);
+ mp_msg(MSGT_DEMUXER,MSGL_V,"demux_mpg_probe returned file_format %d\n", file_format);
+ if(file_format==DEMUXER_TYPE_UNKNOWN) {
+ free_demuxer(demuxer);
+ demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_PS,audio_id,video_id,dvdsub_id);
+ demuxer->synced = 3;
+ file_format = demux_mpg_probe(demuxer);
+ mp_msg(MSGT_DEMUXER,MSGL_V,"demux_mpg_probe returned file_format %d\n", file_format);
+ if(file_format==DEMUXER_TYPE_MPEG_PS)
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"MPEG-PES");
- else
+ } else if(file_format==DEMUXER_TYPE_MPEG_PS)
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"MPEG-PS");
- file_format=DEMUXER_TYPE_MPEG_PS;
- } else {
- mp_msg(MSGT_DEMUX,MSGL_V,"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 PES: %d MP3: %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=0,
- num_h264_idr, num_h264_sps=0,
- num_h264_pps,
- num_elementary_packetsPES,num_mp3audio_packets);
-//MPEG packet stats: p100: 458 p101: 458 PES: 0 MP3: 1103 (.m2v)
- if(num_mp3audio_packets>50 && num_mp3audio_packets>2*num_elementary_packets100
- && abs(num_elementary_packets100-num_elementary_packets101)>2)
- break; // it's .MP3
- // some hack to get meaningfull error messages to our unhappy users:
- if(num_elementary_packets100>=2 && num_elementary_packets101>=2 &&
- abs(num_elementary_packets101+8-num_elementary_packets100)<16){
- if(num_elementary_packetsPES>=4 && num_elementary_packetsPES>=num_elementary_packets100-4){
- --pes;continue; // tricky...
- }
- file_format=DEMUXER_TYPE_MPEG_ES; // <-- hack is here :)
- } else
-#if 1
- // fuzzy mpeg4-es detection. do NOT enable without heavy testing of mpeg formats detection!
- if(num_elementary_packets1B6>3 && num_elementary_packets12x>=1 &&
- num_elementary_packetsPES==0 && num_elementary_packets100<=num_elementary_packets12x &&
- demuxer->synced<2){
- file_format=DEMUXER_TYPE_MPEG4_ES;
- } else
-#endif
-#if 1
- // fuzzy h264-es detection. do NOT enable without heavy testing of mpeg formats detection!
- if((num_h264_slice>3 || (num_h264_dpa>3 && num_h264_dpb>3 && num_h264_dpc>3)) &&
- /* FIXME num_h264_sps>=1 && */ num_h264_pps>=1 && num_h264_idr>=1 &&
- num_elementary_packets1B6==0 && num_elementary_packetsPES==0 &&
- demuxer->synced<2){
- file_format=DEMUXER_TYPE_H264_ES;
- } else
-#endif
- {
- if(demuxer->synced==2)
- mp_msg(MSGT_DEMUXER,MSGL_ERR,"MPEG: " MSGTR_MissingVideoStreamBug);
- else
- mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_NotSystemStream);
- }
- if (demuxer && file_format != DEMUXER_TYPE_MPEG_PS) {
- free_demuxer(demuxer);
- demuxer = NULL;
- }
- }
- break;
+
+ if(file_format != DEMUXER_TYPE_MPEG_PS) {
+ free_demuxer(demuxer);
+ demuxer = NULL;
}
}
//=============== Try to open as MPEG-ES file: =================