annotate libmpdemux/demux_rawdv.c @ 7164:6175f7d18f8c

added needed errno.h
author alex
date Fri, 30 Aug 2002 13:34:08 +0000
parents cc46462d0015
children a715a0960762
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6925
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
1 /*
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
2 raw dv file parser for MPlayer
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
3 by Alexander Neundorf <neundorf@kde.org>
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
4 based on the fli demuxer
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
5
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
6 LGPL
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
7 */
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
8
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
9 #include <stdio.h>
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
10 #include <stdlib.h>
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
11 #include <unistd.h>
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
12
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
13 #include "config.h"
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
14
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
15 #ifdef HAVE_LIBDV095
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
16
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
17 #include "mp_msg.h"
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
18 #include "help_mp.h"
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
19
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
20 #include "stream.h"
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
21 #include "demuxer.h"
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
22 #include "stheader.h"
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
23
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
24 #include <libdv/dv.h>
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
25 #include <libdv/dv_types.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 #define DV_PAL_FRAME_SIZE 144000
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
28 #define DV_NTSC_FRAME_SIZE 122000
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
29
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
30 typedef struct
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
31 {
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
32 int current_frame;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
33 int frame_size;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
34 int current_filepos;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
35 int frame_number;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
36 dv_decoder_t *decoder;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
37 } rawdv_frames_t;
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 void demux_seek_rawdv(demuxer_t *demuxer,float rel_seek_secs,int flags)
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
40 {
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
41 rawdv_frames_t *frames = (rawdv_frames_t *)demuxer->priv;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
42 sh_video_t *sh_video = demuxer->video->sh;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
43 int newpos=(flags&1)?0:frames->current_frame;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
44 if(flags&2)
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
45 {
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
46 // float 0..1
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
47 newpos+=rel_seek_secs*frames->frame_number;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
48 }
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
49 else
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
50 {
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
51 // secs
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
52 newpos+=rel_seek_secs*sh_video->fps;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
53 }
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
54 if(newpos<0)
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
55 newpos=0;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
56 else if(newpos>frames->frame_number)
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
57 newpos=frames->frame_number;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
58 frames->current_frame=newpos;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
59 frames->current_filepos=newpos*frames->frame_size;
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
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
62 int check_file_rawdv(demuxer_t *demuxer)
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
63 {
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
64 unsigned char tmp_buffer[DV_PAL_FRAME_SIZE];
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
65 int bytes_read=0;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
66 int result=0;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
67 dv_decoder_t *td;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
68 stream_reset(demuxer->stream);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
69 stream_seek(demuxer->stream, 0);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
70 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
71 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
72 return 0;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
73
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
74 td=dv_decoder_new(TRUE,TRUE,FALSE);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
75 td->quality=DV_QUALITY_BEST;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
76 dv_parse_header(td, tmp_buffer);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
77 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
78 && (td->width==720)
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
79 && ((td->height==576) || (td->height==480)))
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
80 result=1;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
81 dv_decoder_free(td);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
82 return result;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
83 }
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
84
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
85 // return value:
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
86 // 0 = EOF or no stream found
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
87 // 1 = successfully read a packet
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
88 int demux_rawdv_fill_buffer(demuxer_t *demuxer)
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
89 {
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
90 rawdv_frames_t *frames = (rawdv_frames_t *)demuxer->priv;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
91 demux_packet_t* dp_video=NULL;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
92 sh_video_t *sh_video = demuxer->video->sh;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
93 int bytes_read=0;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
94 // fprintf(stderr,"demux_rawdv_fill_buffer() seek to %d, size: %d\n",frames->current_filepos,frames->frame_size);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
95 // fetch the frame from the file
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
96 // 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
97 // 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
98 stream_seek(demuxer->stream, frames->current_filepos);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
99
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
100 dp_video=new_demux_packet(frames->frame_size);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
101 bytes_read=stream_read(demuxer->stream,dp_video->buffer,frames->frame_size);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
102 if (bytes_read<frames->frame_size)
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
103 return 0;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
104 dp_video->pts=frames->current_frame/sh_video->fps;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
105 dp_video->pos=frames->current_filepos;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
106 dp_video->flags=0;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
107
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
108 if (demuxer->audio)
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
109 {
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
110 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
111 ds_add_packet(demuxer->audio,dp_audio);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
112 }
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
113 ds_add_packet(demuxer->video,dp_video);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
114 // get the next frame ready
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
115 frames->current_filepos+=frames->frame_size;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
116 frames->current_frame++;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
117 // 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
118 return 1;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
119 }
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
120
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
121 demuxer_t* demux_open_rawdv(demuxer_t* demuxer)
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
122 {
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
123 unsigned char dv_frame[DV_PAL_FRAME_SIZE];
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
124 sh_video_t *sh_video = NULL;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
125 rawdv_frames_t *frames = (rawdv_frames_t *)malloc(sizeof(rawdv_frames_t));
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
126 dv_decoder_t *dv_decoder=NULL;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
127
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
128 mp_msg(MSGT_DEMUXER,MSGL_V,"demux_open_rawdv() end_pos %d\n",demuxer->stream->end_pos);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
129
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
130 // go back to the beginning
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
131 stream_reset(demuxer->stream);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
132 stream_seek(demuxer->stream, 0);
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 //get the first frame
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
135 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
136
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
137 //read params from this frame
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
138 dv_decoder=dv_decoder_new(TRUE,TRUE,FALSE);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
139 dv_decoder->quality=DV_QUALITY_BEST;
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 dv_parse_header(dv_decoder, dv_frame);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
142
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
143 // create a new video stream header
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
144 sh_video = new_sh_video(demuxer, 0);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
145
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
146 // 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
147 // (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
148 demuxer->seekable = 1;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
149 demuxer->video->sh = sh_video;
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 // 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
152 // 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
153 // video_read_properties() will choke
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
154 sh_video->ds = demuxer->video;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
155
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
156 // custom fourcc for internal MPlayer use
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
157 // sh_video->format = mmioFOURCC('R', 'A', 'D', 'V');
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
158 sh_video->format = mmioFOURCC('D', 'V', 'S', 'D');
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
159
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
160 sh_video->disp_w = dv_decoder->width;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
161 sh_video->disp_h = dv_decoder->height;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
162 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
163
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
164 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
165 sh_video->frametime = 1.0/sh_video->fps;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
166
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
167 // emulate BITMAPINFOHEADER for win32 decoders:
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
168 sh_video->bih=malloc(sizeof(BITMAPINFOHEADER));
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
169 memset(sh_video->bih,0,sizeof(BITMAPINFOHEADER));
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
170 sh_video->bih->biSize=40;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
171 sh_video->bih->biWidth = dv_decoder->width;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
172 sh_video->bih->biHeight = dv_decoder->height;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
173 sh_video->bih->biPlanes=1;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
174 sh_video->bih->biBitCount=24;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
175 sh_video->bih->biCompression=sh_video->format; // "DVSD"
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
176 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
177
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
178
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
179 frames->current_filepos=0;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
180 frames->current_frame=0;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
181 frames->frame_size=dv_decoder->frame_size;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
182 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
183
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
184 mp_msg(MSGT_DEMUXER,MSGL_V,"demux_open_rawdv() seek to %d, size: %d, dv_dec->frame_size: %d\n",frames->current_filepos,frames->frame_size, dv_decoder->frame_size);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
185 if (dv_decoder->audio != NULL){
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
186 sh_audio_t *sh_audio = new_sh_audio(demuxer, 0);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
187 demuxer->audio->sh = sh_audio;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
188 sh_audio->ds = demuxer->audio;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
189 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
190 // custom fourcc for internal MPlayer use
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
191 sh_audio->format = mmioFOURCC('R', 'A', 'D', 'V');
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
192
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
193 sh_audio->wf = malloc(sizeof(WAVEFORMATEX));
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
194 memset(sh_audio->wf, 0, sizeof(WAVEFORMATEX));
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
195 sh_audio->wf->wFormatTag = sh_audio->format;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
196 sh_audio->wf->nChannels = dv_decoder->audio->num_channels;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
197 sh_audio->wf->wBitsPerSample = 16;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
198 sh_audio->wf->nSamplesPerSec = dv_decoder->audio->frequency;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
199 // info about the input stream:
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
200 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
201 sh_audio->wf->nBlockAlign = dv_decoder->frame_size;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
202
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
203 // sh_audio->context=(void*)dv_decoder;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
204 }
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
205 stream_reset(demuxer->stream);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
206 stream_seek(demuxer->stream, 0);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
207 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
208 demuxer->priv=frames;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
209 return demuxer;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
210 }
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
211
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
212 void demux_close_rawdv(demuxer_t* demuxer)
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
213 {
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
214 rawdv_frames_t *frames = (rawdv_frames_t *)demuxer->priv;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
215
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
216 if(frames==0)
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
217 return;
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
218 free(frames);
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
219 }
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
220
cc46462d0015 raw .dv stream demuxer by Alexander Neundorf <neundorf@kde.org>
arpi
parents:
diff changeset
221 #endif