4550
|
1
|
|
2 #include <stdio.h>
|
|
3 #include <stdlib.h>
|
|
4 #include <unistd.h>
|
|
5 #include <sys/types.h>
|
|
6 #include <sys/stat.h>
|
|
7 #include <unistd.h>
|
|
8
|
|
9 #include "config.h"
|
|
10 #include "mp_msg.h"
|
|
11 #include "help_mp.h"
|
|
12
|
|
13 #include "stream.h"
|
|
14 #include "demuxer.h"
|
|
15 #include "stheader.h"
|
|
16 #include "mf.h"
|
|
17
|
|
18 typedef struct
|
|
19 {
|
|
20 int nr_of_frames;
|
|
21 int curr_frame;
|
|
22 } demuxer_mf_t;
|
|
23
|
|
24 void demux_seek_mf(demuxer_t *demuxer,float rel_seek_secs,int flags){
|
|
25 }
|
|
26
|
|
27 // return value:
|
|
28 // 0 = EOF or no stream found
|
|
29 // 1 = successfully read a packet
|
|
30 int demux_mf_fill_buffer(demuxer_t *demuxer){
|
|
31 mf_t * mf;
|
|
32 demuxer_mf_t * dmf;
|
|
33 struct stat fs;
|
|
34 FILE * f;
|
|
35
|
|
36 dmf=(demuxer_mf_t*)demuxer->priv;
|
|
37 if ( dmf->curr_frame >= dmf->nr_of_frames ) return 0;
|
|
38 mf=(mf_t*)demuxer->stream->priv;
|
|
39
|
|
40 stat( mf->names[dmf->curr_frame],&fs );
|
4556
|
41 printf( "[demux_mf] frame: %d (%s,%d)\n",dmf->curr_frame,mf->names[dmf->curr_frame],fs.st_size );
|
4550
|
42
|
|
43 if ( !( f=fopen( mf->names[dmf->curr_frame],"r" ) ) ) return 0;
|
|
44 {
|
|
45 sh_video_t * sh_video = demuxer->video->sh;
|
|
46 demux_packet_t * dp = new_demux_packet( fs.st_size );
|
|
47 // stream_read(stream,dp->buffer,len);
|
|
48 if ( !fread( dp->buffer,1,fs.st_size,f ) ) return 0;
|
|
49 dp->pts=dmf->curr_frame / sh_video->fps;
|
|
50 dp->pos=dmf->curr_frame;
|
|
51 dp->flags=0;
|
|
52 // append packet to DS stream:
|
|
53 ds_add_packet( demuxer->video,dp );
|
|
54 }
|
|
55 fclose( f );
|
|
56
|
|
57 dmf->curr_frame++;
|
|
58 return 1;
|
|
59 }
|
|
60
|
|
61 demuxer_t* demux_open_mf(demuxer_t* demuxer){
|
|
62 sh_video_t *sh_video = NULL;
|
|
63 mf_t *mf = NULL;
|
|
64 demuxer_mf_t *dmf = NULL;
|
|
65
|
|
66 mp_msg( MSGT_DEMUX,MSGL_V,"[demux_mf] mf demuxer opened.\n" );
|
|
67 mf=(mf_t*)demuxer->stream->priv;
|
|
68 dmf=calloc( 1,sizeof( demuxer_mf_t ) );
|
|
69
|
|
70 // go back to the beginning
|
|
71 stream_reset(demuxer->stream);
|
|
72 stream_seek(demuxer->stream, 0);
|
|
73 demuxer->movi_start = 0;
|
|
74 demuxer->movi_end = mf->nr_of_files - 1;
|
|
75 dmf->nr_of_frames= mf->nr_of_files;
|
|
76 dmf->curr_frame=0;
|
|
77
|
|
78 // create a new video stream header
|
|
79 sh_video = new_sh_video(demuxer, 0);
|
|
80 // make sure the demuxer knows about the new video stream header
|
|
81 // (even though new_sh_video() ought to take care of it)
|
|
82 demuxer->video->sh = sh_video;
|
|
83
|
|
84 // make sure that the video demuxer stream header knows about its
|
|
85 // parent video demuxer stream (this is getting wacky), or else
|
|
86 // video_read_properties() will choke
|
|
87 sh_video->ds = demuxer->video;
|
|
88
|
|
89 if ( !strcmp( mf_type,"jpg" ) ) sh_video->format = mmioFOURCC('M', 'J', 'P', 'G');
|
|
90 else { mp_msg(MSGT_DEMUX, MSGL_INFO, "[demux_mf] unknow input file type.\n" ); free( dmf ); return NULL; }
|
|
91
|
|
92 sh_video->disp_w = mf_w;
|
|
93 sh_video->disp_h = mf_h;
|
|
94 sh_video->fps = mf_fps;
|
|
95 sh_video->frametime = 1 / sh_video->fps;
|
|
96
|
4556
|
97 // emulate BITMAPINFOHEADER:
|
|
98 sh_video->bih=malloc(sizeof(BITMAPINFOHEADER));
|
|
99 memset(sh_video->bih,0,sizeof(BITMAPINFOHEADER));
|
|
100 sh_video->bih->biSize=40;
|
|
101 sh_video->bih->biWidth = mf_w;
|
|
102 sh_video->bih->biHeight = mf_h;
|
|
103 sh_video->bih->biPlanes=1;
|
|
104 sh_video->bih->biBitCount=24;
|
|
105 sh_video->bih->biCompression=sh_video->format;
|
|
106 sh_video->bih->biSizeImage=sh_video->bih->biWidth*sh_video->bih->biHeight*3;
|
|
107
|
4550
|
108 /* disable seeking */
|
|
109 demuxer->seekable = 0;
|
|
110
|
|
111 demuxer->priv=(void*)dmf;
|
|
112
|
|
113 return demuxer;
|
|
114 }
|