annotate libmpdemux/demux_mf.c @ 35419:d86249ebbcca

Don't unconditionally reset Track, Chapter and Angle after playback. Only do so if they had been used (i.e. the current StreamType makes use of them).
author ib
date Thu, 29 Nov 2012 14:23:26 +0000
parents 920b8d28379b
children 389d43c448b3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29238
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
1 /*
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
2 * This file is part of MPlayer.
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
3 *
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
5 * it under the terms of the GNU General Public License as published by
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
7 * (at your option) any later version.
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
8 *
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
12 * GNU General Public License for more details.
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
13 *
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
14 * You should have received a copy of the GNU General Public License along
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 28990
diff changeset
17 */
4550
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
18
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
19 #include <stdio.h>
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
20 #include <stdlib.h>
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
21 #include <unistd.h>
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
22 #include <sys/types.h>
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
23 #include <sys/stat.h>
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
24 #include <unistd.h>
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
25
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
26 #include "config.h"
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
27 #include "mp_msg.h"
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
28 #include "help_mp.h"
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
29
22605
4d81dbdf46b9 Add explicit location for headers from the stream/ directory.
diego
parents: 22083
diff changeset
30 #include "stream/stream.h"
4550
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
31 #include "demuxer.h"
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
32 #include "stheader.h"
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
33 #include "mf.h"
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
34
17636
b849a99cdc3c Second-try commit of this patch.
corey
parents: 17624
diff changeset
35 static void demux_seek_mf(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){
35284
b46668aabd5c Simplify, remove pointless casts.
reimar
parents: 34947
diff changeset
36 mf_t * mf = demuxer->priv;
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4556
diff changeset
37 sh_video_t * sh_video = demuxer->video->sh;
25883
baf32110d3fc Use defines to give names to the different seek flags.
reimar
parents: 25707
diff changeset
38 int newpos = (flags & SEEK_ABSOLUTE)?0:mf->curr_frame - 1;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
39
25883
baf32110d3fc Use defines to give names to the different seek flags.
reimar
parents: 25707
diff changeset
40 if ( flags & SEEK_FACTOR ) newpos+=rel_seek_secs*(mf->nr_of_files - 1);
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4556
diff changeset
41 else newpos+=rel_seek_secs * sh_video->fps;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4556
diff changeset
42 if ( newpos < 0 ) newpos=0;
19180
c5ee8c9808ef fix 3 bugs in libmpdemux/demux_mf.c
gpoirier
parents: 17636
diff changeset
43 if( newpos >= mf->nr_of_files) newpos=mf->nr_of_files - 1;
29488
6f7e97c44353 Set demuxer->filepos in mf demuxer, since the stream_tell fallback is not
reimar
parents: 29447
diff changeset
44 demuxer->filepos=mf->curr_frame=newpos;
4550
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
45 }
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
46
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
47 // return value:
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
48 // 0 = EOF or no stream found
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
49 // 1 = successfully read a packet
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
50 static int demux_mf_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds){
35284
b46668aabd5c Simplify, remove pointless casts.
reimar
parents: 34947
diff changeset
51 mf_t * mf = demuxer->priv;
4550
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
52 struct stat fs;
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
53 FILE * f;
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
54
7407
8780415baa87 stream layer cleanup - part 1
arpi
parents: 7362
diff changeset
55 if ( mf->curr_frame >= mf->nr_of_files ) return 0;
4550
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
56
7407
8780415baa87 stream layer cleanup - part 1
arpi
parents: 7362
diff changeset
57 stat( mf->names[mf->curr_frame],&fs );
8780415baa87 stream layer cleanup - part 1
arpi
parents: 7362
diff changeset
58 // printf( "[demux_mf] frame: %d (%s,%d)\n",mf->curr_frame,mf->names[mf->curr_frame],fs.st_size );
4550
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
59
9992
e33317c4d9af fopen requires binary flag on windows, too
faust3
parents: 9945
diff changeset
60 if ( !( f=fopen( mf->names[mf->curr_frame],"rb" ) ) ) return 0;
4550
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
61 {
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
62 sh_video_t * sh_video = demuxer->video->sh;
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
63 demux_packet_t * dp = new_demux_packet( fs.st_size );
35285
920b8d28379b Fix memleak when reading a file fails.
reimar
parents: 35284
diff changeset
64 if ( !fread( dp->buffer,fs.st_size,1,f ) ) {
920b8d28379b Fix memleak when reading a file fails.
reimar
parents: 35284
diff changeset
65 fclose(f);
920b8d28379b Fix memleak when reading a file fails.
reimar
parents: 35284
diff changeset
66 free_demux_packet(dp);
920b8d28379b Fix memleak when reading a file fails.
reimar
parents: 35284
diff changeset
67 return 0;
920b8d28379b Fix memleak when reading a file fails.
reimar
parents: 35284
diff changeset
68 }
7407
8780415baa87 stream layer cleanup - part 1
arpi
parents: 7362
diff changeset
69 dp->pts=mf->curr_frame / sh_video->fps;
8780415baa87 stream layer cleanup - part 1
arpi
parents: 7362
diff changeset
70 dp->pos=mf->curr_frame;
34947
1e843d908eae For mf:// all frames are keyframes, mark them as such.
reimar
parents: 34554
diff changeset
71 dp->flags=1;
4550
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
72 // append packet to DS stream:
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
73 ds_add_packet( demuxer->video,dp );
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
74 }
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
75 fclose( f );
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
76
29488
6f7e97c44353 Set demuxer->filepos in mf demuxer, since the stream_tell fallback is not
reimar
parents: 29447
diff changeset
77 demuxer->filepos=mf->curr_frame++;
4550
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
78 return 1;
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
79 }
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
80
28990
e2552a27678c map jls (jpeg-ls), thm and db (thumbnails) files to jpg
compn
parents: 26711
diff changeset
81 // force extension/type to have a fourcc
e2552a27678c map jls (jpeg-ls), thm and db (thumbnails) files to jpg
compn
parents: 26711
diff changeset
82
25033
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
83 static const struct {
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
84 const char *type;
25062
25ee4d06a2df 100l, fix uint32_t* instead of uint32_t typo in demux_mf type->fourcc table
reimar
parents: 25034
diff changeset
85 uint32_t format;
25033
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
86 } type2format[] = {
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
87 { "bmp", mmioFOURCC('b', 'm', 'p', ' ') },
29447
db248c87f4cf Allow dpx image files as input.
cehoyos
parents: 29263
diff changeset
88 { "dpx", mmioFOURCC('d', 'p', 'x', ' ') },
34499
7247b323cfc3 demux_mf: add j2c and jpc as jpeg2k, add tiff extension as tif image.
compn
parents: 32537
diff changeset
89 { "j2c", mmioFOURCC('M', 'J', '2', 'C') },
30132
e6373560edd1 Add support for JPEG2000 via FFmpeg/OpenJPEG
reimar
parents: 29488
diff changeset
90 { "j2k", mmioFOURCC('M', 'J', '2', 'C') },
e6373560edd1 Add support for JPEG2000 via FFmpeg/OpenJPEG
reimar
parents: 29488
diff changeset
91 { "jp2", mmioFOURCC('M', 'J', '2', 'C') },
34499
7247b323cfc3 demux_mf: add j2c and jpc as jpeg2k, add tiff extension as tif image.
compn
parents: 32537
diff changeset
92 { "jpc", mmioFOURCC('M', 'J', '2', 'C') },
25033
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
93 { "jpeg", mmioFOURCC('I', 'J', 'P', 'G') },
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
94 { "jpg", mmioFOURCC('I', 'J', 'P', 'G') },
34554
8f2e2ea80a3d add jps / pns image formats, sync'd from ffmpeg
compn
parents: 34499
diff changeset
95 { "jps", mmioFOURCC('I', 'J', 'P', 'G') },
28990
e2552a27678c map jls (jpeg-ls), thm and db (thumbnails) files to jpg
compn
parents: 26711
diff changeset
96 { "jls", mmioFOURCC('I', 'J', 'P', 'G') },
e2552a27678c map jls (jpeg-ls), thm and db (thumbnails) files to jpg
compn
parents: 26711
diff changeset
97 { "thm", mmioFOURCC('I', 'J', 'P', 'G') },
e2552a27678c map jls (jpeg-ls), thm and db (thumbnails) files to jpg
compn
parents: 26711
diff changeset
98 { "db", mmioFOURCC('I', 'J', 'P', 'G') },
25961
354ad909efcf add ffpcx decoder, works on my samples.
compn
parents: 25883
diff changeset
99 { "pcx", mmioFOURCC('p', 'c', 'x', ' ') },
25033
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
100 { "png", mmioFOURCC('M', 'P', 'N', 'G') },
34554
8f2e2ea80a3d add jps / pns image formats, sync'd from ffmpeg
compn
parents: 34499
diff changeset
101 { "pns", mmioFOURCC('M', 'P', 'N', 'G') },
26711
4be576db89df add ffptx , works on ptx samples
compn
parents: 26070
diff changeset
102 { "ptx", mmioFOURCC('p', 't', 'x', ' ') },
25033
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
103 { "tga", mmioFOURCC('M', 'T', 'G', 'A') },
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
104 { "tif", mmioFOURCC('t', 'i', 'f', 'f') },
34499
7247b323cfc3 demux_mf: add j2c and jpc as jpeg2k, add tiff extension as tif image.
compn
parents: 32537
diff changeset
105 { "tiff", mmioFOURCC('t', 'i', 'f', 'f') },
25033
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
106 { "sgi", mmioFOURCC('S', 'G', 'I', '1') },
26070
77aa6f108f20 sun rasterfile decoder
compn
parents: 25961
diff changeset
107 { "sun", mmioFOURCC('s', 'u', 'n', ' ') },
77aa6f108f20 sun rasterfile decoder
compn
parents: 25961
diff changeset
108 { "ras", mmioFOURCC('s', 'u', 'n', ' ') },
77aa6f108f20 sun rasterfile decoder
compn
parents: 25961
diff changeset
109 { "ra", mmioFOURCC('s', 'u', 'n', ' ') },
77aa6f108f20 sun rasterfile decoder
compn
parents: 25961
diff changeset
110 { "im1", mmioFOURCC('s', 'u', 'n', ' ') },
77aa6f108f20 sun rasterfile decoder
compn
parents: 25961
diff changeset
111 { "im8", mmioFOURCC('s', 'u', 'n', ' ') },
77aa6f108f20 sun rasterfile decoder
compn
parents: 25961
diff changeset
112 { "im24", mmioFOURCC('s', 'u', 'n', ' ') },
77aa6f108f20 sun rasterfile decoder
compn
parents: 25961
diff changeset
113 { "sunras", mmioFOURCC('s', 'u', 'n', ' ') },
25033
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
114 { NULL, 0 }
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
115 };
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
116
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
117 static demuxer_t* demux_open_mf(demuxer_t* demuxer){
4550
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
118 sh_video_t *sh_video = NULL;
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
119 mf_t *mf = NULL;
25033
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
120 int i;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
121
7407
8780415baa87 stream layer cleanup - part 1
arpi
parents: 7362
diff changeset
122 if(!demuxer->stream->url) return NULL;
22083
59982606e602 mf demuxer only works with mf:// urls, so check for that.
reimar
parents: 19794
diff changeset
123 if(strncmp(demuxer->stream->url, "mf://", 5)) return NULL;
9148
946b14a9e743 type autodetection (from filemask/filelist extension)
arpi
parents: 7407
diff changeset
124
17624
7b30bef00830 allow autodetection of pictures type when using mf://@file.list syntax
iive
parents: 17569
diff changeset
125
7b30bef00830 allow autodetection of pictures type when using mf://@file.list syntax
iive
parents: 17569
diff changeset
126 mf=open_mf(demuxer->stream->url + 5);
7b30bef00830 allow autodetection of pictures type when using mf://@file.list syntax
iive
parents: 17569
diff changeset
127 if(!mf) return NULL;
7b30bef00830 allow autodetection of pictures type when using mf://@file.list syntax
iive
parents: 17569
diff changeset
128
9148
946b14a9e743 type autodetection (from filemask/filelist extension)
arpi
parents: 7407
diff changeset
129 if(!mf_type){
17624
7b30bef00830 allow autodetection of pictures type when using mf://@file.list syntax
iive
parents: 17569
diff changeset
130 char* p=strrchr(mf->names[0],'.');
9148
946b14a9e743 type autodetection (from filemask/filelist extension)
arpi
parents: 7407
diff changeset
131 if(!p){
946b14a9e743 type autodetection (from filemask/filelist extension)
arpi
parents: 7407
diff changeset
132 mp_msg(MSGT_DEMUX, MSGL_INFO, "[demux_mf] file type was not set! (try -mf type=xxx)\n" );
946b14a9e743 type autodetection (from filemask/filelist extension)
arpi
parents: 7407
diff changeset
133 free( mf ); return NULL;
946b14a9e743 type autodetection (from filemask/filelist extension)
arpi
parents: 7407
diff changeset
134 }
946b14a9e743 type autodetection (from filemask/filelist extension)
arpi
parents: 7407
diff changeset
135 mf_type=strdup(p+1);
946b14a9e743 type autodetection (from filemask/filelist extension)
arpi
parents: 7407
diff changeset
136 mp_msg(MSGT_DEMUX, MSGL_INFO, "[demux_mf] file type was not set! trying 'type=%s'...\n", mf_type);
946b14a9e743 type autodetection (from filemask/filelist extension)
arpi
parents: 7407
diff changeset
137 }
946b14a9e743 type autodetection (from filemask/filelist extension)
arpi
parents: 7407
diff changeset
138
29488
6f7e97c44353 Set demuxer->filepos in mf demuxer, since the stream_tell fallback is not
reimar
parents: 29447
diff changeset
139 demuxer->filepos=mf->curr_frame=0;
4550
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
140
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
141 demuxer->movi_start = 0;
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
142 demuxer->movi_end = mf->nr_of_files - 1;
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
143
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
144 // create a new video stream header
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
145 sh_video = new_sh_video(demuxer, 0);
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
146 // make sure the demuxer knows about the new video stream header
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
147 // (even though new_sh_video() ought to take care of it)
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
148 demuxer->video->sh = sh_video;
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
149
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
150 // make sure that the video demuxer stream header knows about its
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
151 // parent video demuxer stream (this is getting wacky), or else
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
152 // video_read_properties() will choke
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
153 sh_video->ds = demuxer->video;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
154
25033
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
155 for (i = 0; type2format[i].type; i++)
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
156 if (strcasecmp(mf_type, type2format[i].type) == 0)
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
157 break;
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
158 if (!type2format[i].type) {
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
159 mp_msg(MSGT_DEMUX, MSGL_INFO, "[demux_mf] unknown input file type.\n" );
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
160 free(mf);
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
161 return NULL;
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
162 }
3dceb6c96307 Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
reimar
parents: 25020
diff changeset
163 sh_video->format = type2format[i].format;
4550
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
164
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
165 sh_video->disp_w = mf_w;
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
166 sh_video->disp_h = mf_h;
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
167 sh_video->fps = mf_fps;
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
168 sh_video->frametime = 1 / sh_video->fps;
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
169
4556
90a535d87e7b emulating BITMAPINFOHDR (for win32 codecs)
arpi
parents: 4550
diff changeset
170 // emulate BITMAPINFOHEADER:
32105
c08363dc5320 Replace sizoef(type) by sizeof(*ptrvar).
reimar
parents: 32097
diff changeset
171 sh_video->bih=calloc(1, sizeof(*sh_video->bih));
4556
90a535d87e7b emulating BITMAPINFOHDR (for win32 codecs)
arpi
parents: 4550
diff changeset
172 sh_video->bih->biSize=40;
90a535d87e7b emulating BITMAPINFOHDR (for win32 codecs)
arpi
parents: 4550
diff changeset
173 sh_video->bih->biWidth = mf_w;
90a535d87e7b emulating BITMAPINFOHDR (for win32 codecs)
arpi
parents: 4550
diff changeset
174 sh_video->bih->biHeight = mf_h;
90a535d87e7b emulating BITMAPINFOHDR (for win32 codecs)
arpi
parents: 4550
diff changeset
175 sh_video->bih->biPlanes=1;
90a535d87e7b emulating BITMAPINFOHDR (for win32 codecs)
arpi
parents: 4550
diff changeset
176 sh_video->bih->biBitCount=24;
90a535d87e7b emulating BITMAPINFOHDR (for win32 codecs)
arpi
parents: 4550
diff changeset
177 sh_video->bih->biCompression=sh_video->format;
90a535d87e7b emulating BITMAPINFOHDR (for win32 codecs)
arpi
parents: 4550
diff changeset
178 sh_video->bih->biSizeImage=sh_video->bih->biWidth*sh_video->bih->biHeight*3;
90a535d87e7b emulating BITMAPINFOHDR (for win32 codecs)
arpi
parents: 4550
diff changeset
179
4550
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
180 /* disable seeking */
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4556
diff changeset
181 // demuxer->seekable = 0;
4550
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
182
7407
8780415baa87 stream layer cleanup - part 1
arpi
parents: 7362
diff changeset
183 demuxer->priv=(void*)mf;
4550
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
184
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
185 return demuxer;
ff9f62e4bdd8 add mfi demuxer
pontscho
parents:
diff changeset
186 }
5810
8a357300d0ec Added demuxer uninit
albeu
parents: 5029
diff changeset
187
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
188 static void demux_close_mf(demuxer_t* demuxer) {
7407
8780415baa87 stream layer cleanup - part 1
arpi
parents: 7362
diff changeset
189 mf_t *mf = demuxer->priv;
5810
8a357300d0ec Added demuxer uninit
albeu
parents: 5029
diff changeset
190
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
191 free(mf);
5810
8a357300d0ec Added demuxer uninit
albeu
parents: 5029
diff changeset
192 }
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
193
19220
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
194 static int demux_control_mf(demuxer_t *demuxer, int cmd, void *arg) {
35284
b46668aabd5c Simplify, remove pointless casts.
reimar
parents: 34947
diff changeset
195 mf_t *mf = demuxer->priv;
19220
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
196 sh_video_t *sh_video = demuxer->video->sh;
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
197
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
198 switch(cmd) {
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
199 case DEMUXER_CTRL_GET_TIME_LENGTH:
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
200 *((double *)arg) = (double)mf->nr_of_files / sh_video->fps;
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
201 return DEMUXER_CTRL_OK;
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
202
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
203 case DEMUXER_CTRL_GET_PERCENT_POS:
19794
0951c3e8864b Avoid division by zero DEMUXER_CTRL_GET_PERCENT_POS with only one frame by just
reimar
parents: 19220
diff changeset
204 if (mf->nr_of_files <= 1)
0951c3e8864b Avoid division by zero DEMUXER_CTRL_GET_PERCENT_POS with only one frame by just
reimar
parents: 19220
diff changeset
205 return DEMUXER_CTRL_DONTKNOW;
19220
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
206 *((int *)arg) = 100 * mf->curr_frame / (mf->nr_of_files - 1);
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
207 return DEMUXER_CTRL_OK;
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
208
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
209 default:
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
210 return DEMUXER_CTRL_NOTIMPL;
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
211 }
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
212 }
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
213
25707
d4fe6e23283e Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents: 25062
diff changeset
214 const demuxer_desc_t demuxer_desc_mf = {
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
215 "mf demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
216 "mf",
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
217 "MF",
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
218 "?",
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
219 "multiframe?, pictures demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
220 DEMUXER_TYPE_MF,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
221 0, // no autodetect
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
222 NULL,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
223 demux_mf_fill_buffer,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
224 demux_open_mf,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
225 demux_close_mf,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
226 demux_seek_mf,
19220
fbd2391fcbb8 Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS,
reimar
parents: 19180
diff changeset
227 demux_control_mf
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9992
diff changeset
228 };