mirror of
https://github.com/mpv-player/mpv
synced 2025-01-01 04:36:24 +01:00
raw mpeg4-es support (you need to set -fps manually!)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9070 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
1c07dc9f3f
commit
da08b8a076
@ -309,6 +309,7 @@ videocodec ffodivx
|
||||
format 0x4
|
||||
fourcc UMP4
|
||||
fourcc 3IV2,3iv2 ; 3ivx Delta 4
|
||||
format 0x10000004 ; mpeg 4 es
|
||||
driver ffmpeg
|
||||
dll mpeg4 ;opendivx
|
||||
out YV12,I420,IYUV
|
||||
|
@ -247,6 +247,7 @@ static int demux_mpg_read_packet(demuxer_t *demux,int id){
|
||||
|
||||
int num_elementary_packets100=0;
|
||||
int num_elementary_packets101=0;
|
||||
int num_elementary_packets12x=0;
|
||||
int num_elementary_packets1B6=0;
|
||||
int num_elementary_packetsPES=0;
|
||||
int num_mp3audio_packets=0;
|
||||
@ -314,7 +315,8 @@ do{
|
||||
} else {
|
||||
if(head>=0x100 && head<0x1B0){
|
||||
if(head==0x100) ++num_elementary_packets100; else
|
||||
if(head==0x101) ++num_elementary_packets101;
|
||||
if(head==0x101) ++num_elementary_packets101; else
|
||||
if(head>=0x120 && head<=0x12F) ++num_elementary_packets12x;
|
||||
mp_msg(MSGT_DEMUX,MSGL_DBG3,"Opps... elementary video packet found: %03X\n",head);
|
||||
} else
|
||||
if((head>=0x1C0 && head<0x1F0) || head==0x1BD){
|
||||
|
@ -292,6 +292,7 @@ int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds){
|
||||
case DEMUXER_TYPE_FILM: return demux_film_fill_buffer(demux);
|
||||
case DEMUXER_TYPE_BMP: return demux_bmp_fill_buffer(demux);
|
||||
case DEMUXER_TYPE_FLI: return demux_fli_fill_buffer(demux);
|
||||
case DEMUXER_TYPE_MPEG4_ES:
|
||||
case DEMUXER_TYPE_MPEG_ES: return demux_mpg_es_fill_buffer(demux);
|
||||
case DEMUXER_TYPE_MPEG_PS: return demux_mpg_fill_buffer(demux);
|
||||
case DEMUXER_TYPE_AVI: return demux_avi_fill_buffer(demux);
|
||||
@ -502,6 +503,7 @@ 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_mp3audio_packets;
|
||||
|
||||
// commandline options, flags:
|
||||
@ -813,6 +815,7 @@ if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPEG_PS){
|
||||
num_elementary_packets100=0;
|
||||
num_elementary_packets101=0;
|
||||
num_elementary_packets1B6=0;
|
||||
num_elementary_packets12x=0;
|
||||
num_elementary_packetsPES=0;
|
||||
num_mp3audio_packets=0;
|
||||
|
||||
@ -823,8 +826,10 @@ if(file_format==DEMUXER_TYPE_UNKNOWN || 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 PES: %d MP3: %d \n",
|
||||
num_elementary_packets100,num_elementary_packets101,num_elementary_packetsPES,num_mp3audio_packets);
|
||||
mp_msg(MSGT_DEMUX,MSGL_V,"MPEG packet stats: p100: %d p101: %d p1B6: %d p12x: %d PES: %d MP3: %d \n",
|
||||
num_elementary_packets100,num_elementary_packets101,
|
||||
num_elementary_packets1B6,num_elementary_packets12x,
|
||||
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)
|
||||
@ -836,7 +841,16 @@ if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPEG_PS){
|
||||
--pes;continue; // tricky...
|
||||
}
|
||||
file_format=DEMUXER_TYPE_MPEG_ES; // <-- hack is here :)
|
||||
} else {
|
||||
} else
|
||||
#if 0
|
||||
// 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(demuxer->synced==2)
|
||||
mp_msg(MSGT_DEMUXER,MSGL_ERR,"MPEG: " MSGTR_MissingVideoStreamBug);
|
||||
else
|
||||
@ -849,15 +863,15 @@ if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPEG_PS){
|
||||
}
|
||||
}
|
||||
//=============== Try to open as MPEG-ES file: =================
|
||||
if(file_format==DEMUXER_TYPE_MPEG_ES){ // little hack, see above!
|
||||
demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_ES,audio_id,video_id,dvdsub_id);
|
||||
if(file_format==DEMUXER_TYPE_MPEG_ES || file_format==DEMUXER_TYPE_MPEG4_ES){ // little hack, see above!
|
||||
demuxer=new_demuxer(stream,file_format,audio_id,video_id,dvdsub_id);
|
||||
if(!ds_fill_buffer(demuxer->video)){
|
||||
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_InvalidMPEGES);
|
||||
file_format=DEMUXER_TYPE_UNKNOWN;
|
||||
free_demuxer(demuxer);
|
||||
demuxer = NULL;
|
||||
} else {
|
||||
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"MPEG-ES");
|
||||
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,(file_format==DEMUXER_TYPE_MPEG_ES)?"MPEG-ES":"MPEG4-ES");
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_LIBDV095
|
||||
@ -1044,6 +1058,7 @@ switch(file_format){
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DEMUXER_TYPE_MPEG4_ES:
|
||||
case DEMUXER_TYPE_MPEG_ES: {
|
||||
sh_audio=NULL; // ES streams has no audio channel
|
||||
d_video->sh=new_sh_video(demuxer,0); // create dummy video stream header, id=0
|
||||
@ -1207,6 +1222,7 @@ switch(demuxer->file_format){
|
||||
case DEMUXER_TYPE_ASF:
|
||||
demux_seek_asf(demuxer,rel_seek_secs,flags); break;
|
||||
|
||||
case DEMUXER_TYPE_MPEG4_ES:
|
||||
case DEMUXER_TYPE_MPEG_ES:
|
||||
case DEMUXER_TYPE_MPEG_PS:
|
||||
demux_seek_mpg(demuxer,rel_seek_secs,flags); break;
|
||||
@ -1312,6 +1328,7 @@ extern int demux_xmms_control(demuxer_t *demuxer, int cmd, void *arg);
|
||||
|
||||
int demux_control(demuxer_t *demuxer, int cmd, void *arg) {
|
||||
switch(demuxer->type) {
|
||||
case DEMUXER_TYPE_MPEG4_ES:
|
||||
case DEMUXER_TYPE_MPEG_ES:
|
||||
case DEMUXER_TYPE_MPEG_PS:
|
||||
return demux_mpg_control(demuxer,cmd,arg);
|
||||
|
@ -35,11 +35,12 @@
|
||||
#define DEMUXER_TYPE_SMJPEG 24
|
||||
#define DEMUXER_TYPE_XMMS 25
|
||||
#define DEMUXER_TYPE_RAWVIDEO 26
|
||||
#define DEMUXER_TYPE_MPEG4_ES 27
|
||||
|
||||
// This should always match the higest demuxer type number.
|
||||
// Unless you want to disallow users to force the demuxer to some types
|
||||
#define DEMUXER_TYPE_MIN 0
|
||||
#define DEMUXER_TYPE_MAX 26
|
||||
#define DEMUXER_TYPE_MAX 27
|
||||
|
||||
#define DEMUXER_TYPE_DEMUXERS (1<<16)
|
||||
// A virtual demuxer type for the network code
|
||||
|
@ -89,6 +89,46 @@ switch(d_video->demuxer->file_format){
|
||||
if (!demux_is_mpeg_rtp_stream(d_video->demuxer)) break;
|
||||
// otherwise fall through to...
|
||||
#endif
|
||||
case DEMUXER_TYPE_MPEG4_ES: {
|
||||
videobuf_len=0; videobuf_code_len=0;
|
||||
mp_msg(MSGT_DECVIDEO,MSGL_V,"Searching for Video Object Start code... ");fflush(stdout);
|
||||
while(1){
|
||||
int i=sync_video_packet(d_video);
|
||||
if(i<=0x11F) break; // found it!
|
||||
if(!i || !skip_video_packet(d_video)){
|
||||
mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
|
||||
if(!videobuffer) videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE);
|
||||
if(!videobuffer){
|
||||
mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
|
||||
return 0;
|
||||
}
|
||||
mp_msg(MSGT_DECVIDEO,MSGL_V,"Searching for Video Object Layer Start code... ");fflush(stdout);
|
||||
while(1){
|
||||
int i=sync_video_packet(d_video);
|
||||
printf("0x%X\n",i);
|
||||
if(i>=0x120 && i<=0x12F) break; // found it!
|
||||
if(!i || !read_video_packet(d_video)){
|
||||
mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\nSearching for Video Object Plane Start code... ");fflush(stdout);
|
||||
while(1){
|
||||
int i=sync_video_packet(d_video);
|
||||
if(i==0x1B6) break; // found it!
|
||||
if(!i || !read_video_packet(d_video)){
|
||||
mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
|
||||
sh_video->format=0x10000004;
|
||||
break;
|
||||
}
|
||||
case DEMUXER_TYPE_PVA:
|
||||
case DEMUXER_TYPE_MPEG_ES:
|
||||
case DEMUXER_TYPE_MPEG_PS: {
|
||||
@ -316,6 +356,16 @@ int video_read_frame(sh_video_t* sh_video,float* frame_time_ptr,unsigned char**
|
||||
telecine=1;
|
||||
}
|
||||
|
||||
} else if(demuxer->file_format==DEMUXER_TYPE_MPEG4_ES){
|
||||
//
|
||||
while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){
|
||||
int i=sync_video_packet(d_video);
|
||||
if(!read_video_packet(d_video)) return -1; // EOF
|
||||
if(i==0x1B6) break;
|
||||
}
|
||||
*start=videobuffer; in_size=videobuf_len;
|
||||
videobuf_len=0;
|
||||
|
||||
} else {
|
||||
// frame-based file formats: (AVI,ASF,MOV)
|
||||
in_size=ds_get_packet(d_video,start);
|
||||
|
Loading…
Reference in New Issue
Block a user