Mercurial > mplayer.hg
annotate libmpdemux/demux_rawdv.c @ 36580:0462f5c5aa00
demux_mkv: use a default mime-type if none was specified.
author | reimar |
---|---|
date | Mon, 20 Jan 2014 22:08:46 +0000 |
parents | 12ed11a8df90 |
children | 1b0d31ceb2ec |
rev | line source |
---|---|
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
1 /* |
29236
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
2 * raw DV file parser |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
3 * copyright (c) 2002 Alexander Neundorf <neundorf@kde.org> |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
4 * based on the fli demuxer |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
5 * |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
6 * This file is part of MPlayer. |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
7 * |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
8 * MPlayer is free software; you can redistribute it and/or |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
10 * License as published by the Free Software Foundation; either |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
11 * version 2.1 of the License, or (at your option) any later version. |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
12 * |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
13 * MPlayer is distributed in the hope that it will be useful, |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
16 * Lesser General Public License for more details. |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
17 * |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
19 * License along with MPlayer; if not, write to the Free Software |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
db6cd163b7fb
Replace informal LGPL header by standard LGPL license header.
diego
parents:
26299
diff
changeset
|
21 */ |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
22 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
23 #include <stdio.h> |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
24 #include <stdlib.h> |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
25 #include <unistd.h> |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
26 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
27 #include "config.h" |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
28 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
29 #include "mp_msg.h" |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
30 #include "help_mp.h" |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
31 |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
20432
diff
changeset
|
32 #include "stream/stream.h" |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
33 #include "demuxer.h" |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
34 #include "stheader.h" |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
35 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
36 #include <libdv/dv.h> |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
37 #include <libdv/dv_types.h> |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
38 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
39 #define DV_PAL_FRAME_SIZE 144000 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
40 #define DV_NTSC_FRAME_SIZE 122000 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
41 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
42 typedef struct |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
43 { |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
44 int current_frame; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
45 int frame_size; |
9630
72870542a127
largefile support by Matthias Schwarzott <zzam@gmx.de>
alex
parents:
9032
diff
changeset
|
46 off_t current_filepos; |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
47 int frame_number; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
48 dv_decoder_t *decoder; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
49 } rawdv_frames_t; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
50 |
17636 | 51 static void demux_seek_rawdv(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags) |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
52 { |
36529 | 53 rawdv_frames_t *frames = demuxer->priv; |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
54 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
|
55 off_t newpos=(flags&SEEK_ABSOLUTE)?0:frames->current_frame; |
baf32110d3fc
Use defines to give names to the different seek flags.
reimar
parents:
25707
diff
changeset
|
56 if(flags&SEEK_FACTOR) |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
57 { |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
58 // float 0..1 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
59 newpos+=rel_seek_secs*frames->frame_number; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
60 } |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
61 else |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
62 { |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
63 // secs |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
64 newpos+=rel_seek_secs*sh_video->fps; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
65 } |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
66 if(newpos<0) |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
67 newpos=0; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
68 else if(newpos>frames->frame_number) |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
69 newpos=frames->frame_number; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
70 frames->current_frame=newpos; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
71 frames->current_filepos=newpos*frames->frame_size; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
72 } |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
73 |
16175 | 74 static int rawdv_check_file(demuxer_t *demuxer) |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
75 { |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
76 unsigned char tmp_buffer[DV_PAL_FRAME_SIZE]; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
77 int bytes_read=0; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
78 int result=0; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
79 dv_decoder_t *td; |
7594
a715a0960762
This just corrects a function name to match the other demuxer's
arpi
parents:
6925
diff
changeset
|
80 |
a715a0960762
This just corrects a function name to match the other demuxer's
arpi
parents:
6925
diff
changeset
|
81 mp_msg(MSGT_DEMUX,MSGL_V,"Checking for DV\n"); |
a715a0960762
This just corrects a function name to match the other demuxer's
arpi
parents:
6925
diff
changeset
|
82 |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
83 bytes_read=stream_read(demuxer->stream,tmp_buffer,DV_PAL_FRAME_SIZE); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
84 if ((bytes_read!=DV_PAL_FRAME_SIZE) && (bytes_read!=DV_NTSC_FRAME_SIZE)) |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
85 return 0; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
86 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
87 td=dv_decoder_new(TRUE,TRUE,FALSE); |
8822 | 88 if (!td) |
89 return 0; | |
90 | |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
91 td->quality=DV_QUALITY_BEST; |
8822 | 92 result=dv_parse_header(td, tmp_buffer); |
9032 | 93 if (result<0) |
8822 | 94 return 0; |
95 | |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
96 if ((( td->num_dif_seqs==10) || (td->num_dif_seqs==12)) |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
97 && (td->width==720) |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
98 && ((td->height==576) || (td->height==480))) |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
99 result=1; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
100 dv_decoder_free(td); |
36530 | 101 return result ? DEMUXER_TYPE_RAWDV : 0; |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
102 } |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
103 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
104 // return value: |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
105 // 0 = EOF or no stream found |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
106 // 1 = successfully read a packet |
16175 | 107 static int demux_rawdv_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds) |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
108 { |
36529 | 109 rawdv_frames_t *frames = demuxer->priv; |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
110 demux_packet_t* dp_video=NULL; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
111 sh_video_t *sh_video = demuxer->video->sh; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
112 int bytes_read=0; |
34136 | 113 // fprintf(stderr,"demux_rawdv_fill_buffer() seek to %llu, size: %d\n",frames->current_filepos,frames->frame_size); |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
114 // fetch the frame from the file |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
115 // first, position the file properly since ds_read_packet() doesn't |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
116 // seem to do it, even though it takes a file offset as a parameter |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
117 stream_seek(demuxer->stream, frames->current_filepos); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
118 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
119 dp_video=new_demux_packet(frames->frame_size); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
120 bytes_read=stream_read(demuxer->stream,dp_video->buffer,frames->frame_size); |
36528 | 121 if (bytes_read<frames->frame_size) { |
122 free_demux_packet(dp_video); | |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
123 return 0; |
36528 | 124 } |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
125 dp_video->pts=frames->current_frame/sh_video->fps; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
126 dp_video->pos=frames->current_filepos; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
127 dp_video->flags=0; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
128 |
7673 | 129 if (demuxer->audio && demuxer->audio->id>=-1) |
130 { | |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
131 demux_packet_t* dp_audio=clone_demux_packet(dp_video); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
132 ds_add_packet(demuxer->audio,dp_audio); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
133 } |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
134 ds_add_packet(demuxer->video,dp_video); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
135 // get the next frame ready |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
136 frames->current_filepos+=frames->frame_size; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
137 frames->current_frame++; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
138 // fprintf(stderr," audio->packs: %d , video->packs: %d \n",demuxer->audio->packs, demuxer->video->packs); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
139 return 1; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
140 } |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
141 |
16175 | 142 static demuxer_t* demux_open_rawdv(demuxer_t* demuxer) |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
143 { |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
144 unsigned char dv_frame[DV_PAL_FRAME_SIZE]; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
145 sh_video_t *sh_video = NULL; |
36530 | 146 rawdv_frames_t *frames = calloc(1, sizeof(*frames)); |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
147 dv_decoder_t *dv_decoder=NULL; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
148 |
17366 | 149 mp_msg(MSGT_DEMUXER,MSGL_V,"demux_open_rawdv() end_pos %"PRId64"\n",(int64_t)demuxer->stream->end_pos); |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
150 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
151 // go back to the beginning |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
152 stream_reset(demuxer->stream); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
153 stream_seek(demuxer->stream, 0); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
154 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
155 //get the first frame |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
156 stream_read(demuxer->stream, dv_frame, DV_PAL_FRAME_SIZE); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
157 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
158 //read params from this frame |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
159 dv_decoder=dv_decoder_new(TRUE,TRUE,FALSE); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
160 dv_decoder->quality=DV_QUALITY_BEST; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
161 |
20432
972c93990379
add two missing checks - PATCH by Karolina Lindqvist AT kramnet-se
reynaldo
parents:
19062
diff
changeset
|
162 if (dv_parse_header(dv_decoder, dv_frame) == -1) |
36572 | 163 goto err_out; |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
164 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
165 // create a new video stream header |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
166 sh_video = new_sh_video(demuxer, 0); |
20432
972c93990379
add two missing checks - PATCH by Karolina Lindqvist AT kramnet-se
reynaldo
parents:
19062
diff
changeset
|
167 if (!sh_video) |
36572 | 168 goto err_out; |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
169 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
170 // make sure the demuxer knows about the new video stream header |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
171 // (even though new_sh_video() ought to take care of it) |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
172 demuxer->seekable = 1; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
173 demuxer->video->sh = sh_video; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
174 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
175 // make sure that the video demuxer stream header knows about its |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
176 // parent video demuxer stream (this is getting wacky), or else |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
177 // video_read_properties() will choke |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
178 sh_video->ds = demuxer->video; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
179 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
180 // custom fourcc for internal MPlayer use |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
181 // sh_video->format = mmioFOURCC('R', 'A', 'D', 'V'); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
182 sh_video->format = mmioFOURCC('D', 'V', 'S', 'D'); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
183 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
184 sh_video->disp_w = dv_decoder->width; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
185 sh_video->disp_h = dv_decoder->height; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
186 mp_msg(MSGT_DEMUXER,MSGL_V,"demux_open_rawdv() frame_size: %d w: %d h: %d dif_seq: %d system: %d\n",dv_decoder->frame_size,dv_decoder->width, dv_decoder->height,dv_decoder->num_dif_seqs,dv_decoder->system); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
187 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
188 sh_video->fps= (dv_decoder->system==e_dv_system_525_60?29.97:25); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
189 sh_video->frametime = 1.0/sh_video->fps; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
190 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
191 // emulate BITMAPINFOHEADER for win32 decoders: |
32123 | 192 sh_video->bih=calloc(1, sizeof(*sh_video->bih)); |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
193 sh_video->bih->biSize=40; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
194 sh_video->bih->biWidth = dv_decoder->width; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
195 sh_video->bih->biHeight = dv_decoder->height; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
196 sh_video->bih->biPlanes=1; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
197 sh_video->bih->biBitCount=24; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
198 sh_video->bih->biCompression=sh_video->format; // "DVSD" |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
199 sh_video->bih->biSizeImage=sh_video->bih->biWidth*sh_video->bih->biHeight*3; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
200 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
201 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
202 frames->current_filepos=0; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
203 frames->current_frame=0; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
204 frames->frame_size=dv_decoder->frame_size; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
205 frames->frame_number=demuxer->stream->end_pos/frames->frame_size; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
206 |
34136 | 207 mp_msg(MSGT_DEMUXER,MSGL_V,"demux_open_rawdv() seek to %llu, size: %d, dv_dec->frame_size: %d\n",frames->current_filepos,frames->frame_size, dv_decoder->frame_size); |
7673 | 208 if (dv_decoder->audio != NULL && demuxer->audio->id>=-1){ |
31609
cd81fce1f010
Make the stream language an argument to the stream creation function
reimar
parents:
29897
diff
changeset
|
209 sh_audio_t *sh_audio = new_sh_audio(demuxer, 0, NULL); |
26299
4d56038ec730
Fix lots and lots of other demuxers broken by r26301
reimar
parents:
25883
diff
changeset
|
210 demuxer->audio->id = 0; |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
211 demuxer->audio->sh = sh_audio; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
212 sh_audio->ds = demuxer->audio; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
213 mp_msg(MSGT_DEMUXER,MSGL_V,"demux_open_rawdv() chan: %d samplerate: %d\n",dv_decoder->audio->num_channels,dv_decoder->audio->frequency ); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
214 // custom fourcc for internal MPlayer use |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
215 sh_audio->format = mmioFOURCC('R', 'A', 'D', 'V'); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
216 |
32121 | 217 sh_audio->wf = calloc(1, sizeof(*sh_audio->wf)); |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
218 sh_audio->wf->wFormatTag = sh_audio->format; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
219 sh_audio->wf->nChannels = dv_decoder->audio->num_channels; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
220 sh_audio->wf->wBitsPerSample = 16; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
221 sh_audio->wf->nSamplesPerSec = dv_decoder->audio->frequency; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
222 // info about the input stream: |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
223 sh_audio->wf->nAvgBytesPerSec = sh_video->fps*dv_decoder->frame_size; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
224 sh_audio->wf->nBlockAlign = dv_decoder->frame_size; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
225 |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
226 // sh_audio->context=(void*)dv_decoder; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
227 } |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
228 stream_reset(demuxer->stream); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
229 stream_seek(demuxer->stream, 0); |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
230 dv_decoder_free(dv_decoder); //we keep this in the context of both stream headers |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
231 demuxer->priv=frames; |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
232 return demuxer; |
36572 | 233 |
234 err_out: | |
235 if (dv_decoder) dv_decoder_free(dv_decoder); | |
236 free(frames); | |
237 return NULL; | |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
238 } |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
239 |
16175 | 240 static void demux_close_rawdv(demuxer_t* demuxer) |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
241 { |
36530 | 242 free(demuxer->priv); |
243 demuxer->priv = NULL; | |
6925
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
244 } |
cc46462d0015
raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff
changeset
|
245 |
16175 | 246 static int demux_rawdv_control(demuxer_t *demuxer,int cmd, void *arg) { |
36529 | 247 rawdv_frames_t *frames = demuxer->priv; |
14934
89031188b7b2
Rather simple patch for RAWDV demuxer which lets it say whats the total
rtognimp
parents:
10539
diff
changeset
|
248 sh_video_t *sh_video=demuxer->video->sh; |
89031188b7b2
Rather simple patch for RAWDV demuxer which lets it say whats the total
rtognimp
parents:
10539
diff
changeset
|
249 |
89031188b7b2
Rather simple patch for RAWDV demuxer which lets it say whats the total
rtognimp
parents:
10539
diff
changeset
|
250 switch(cmd) { |
89031188b7b2
Rather simple patch for RAWDV demuxer which lets it say whats the total
rtognimp
parents:
10539
diff
changeset
|
251 case DEMUXER_CTRL_GET_TIME_LENGTH: |
36530 | 252 *(double *)arg=(double)frames->frame_number / sh_video->fps; |
14934
89031188b7b2
Rather simple patch for RAWDV demuxer which lets it say whats the total
rtognimp
parents:
10539
diff
changeset
|
253 return DEMUXER_CTRL_OK; |
89031188b7b2
Rather simple patch for RAWDV demuxer which lets it say whats the total
rtognimp
parents:
10539
diff
changeset
|
254 |
89031188b7b2
Rather simple patch for RAWDV demuxer which lets it say whats the total
rtognimp
parents:
10539
diff
changeset
|
255 case DEMUXER_CTRL_GET_PERCENT_POS: |
36530 | 256 *(int *)arg=(int)(frames->current_frame * 100. / frames->frame_number); |
14934
89031188b7b2
Rather simple patch for RAWDV demuxer which lets it say whats the total
rtognimp
parents:
10539
diff
changeset
|
257 return DEMUXER_CTRL_OK; |
89031188b7b2
Rather simple patch for RAWDV demuxer which lets it say whats the total
rtognimp
parents:
10539
diff
changeset
|
258 |
89031188b7b2
Rather simple patch for RAWDV demuxer which lets it say whats the total
rtognimp
parents:
10539
diff
changeset
|
259 default: |
89031188b7b2
Rather simple patch for RAWDV demuxer which lets it say whats the total
rtognimp
parents:
10539
diff
changeset
|
260 return DEMUXER_CTRL_NOTIMPL; |
89031188b7b2
Rather simple patch for RAWDV demuxer which lets it say whats the total
rtognimp
parents:
10539
diff
changeset
|
261 } |
89031188b7b2
Rather simple patch for RAWDV demuxer which lets it say whats the total
rtognimp
parents:
10539
diff
changeset
|
262 } |
89031188b7b2
Rather simple patch for RAWDV demuxer which lets it say whats the total
rtognimp
parents:
10539
diff
changeset
|
263 |
16175 | 264 |
25707
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
22605
diff
changeset
|
265 const demuxer_desc_t demuxer_desc_rawdv = { |
16175 | 266 "Raw DV demuxer", |
267 "rawdv", | |
268 "RAWDV", | |
269 "Alexander Neundorf", | |
270 "", | |
271 DEMUXER_TYPE_RAWDV, | |
272 0, // unsafe autodetect | |
273 rawdv_check_file, | |
274 demux_rawdv_fill_buffer, | |
275 demux_open_rawdv, | |
276 demux_close_rawdv, | |
277 demux_seek_rawdv, | |
278 demux_rawdv_control | |
279 }; |