annotate libmpdemux/demux_lmlm4.c @ 34077:deff81b57903

Cosmetic: Order STREAMTYPE related code. Always choose order FILE, STREAM, VCD, DVD for reasons of clarity.
author ib
date Fri, 30 Sep 2011 15:28:01 +0000
parents 8f81a826c86e
children 598ef7d90b78
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
1 /*
29238
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
2 * LMLM4 MPEG4 Compression Card stream & file parser
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
3 * Copyright (C) 2003 Maxim Yevtyushkin <max@linuxmedialabs.com>
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
4 * based on SMJPEG file parser by Alex Beregszaszi
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
5 *
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
6 * This file is part of MPlayer.
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
7 *
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
8 * MPlayer is free software; you can redistribute it and/or modify
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
9 * 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: 25707
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
11 * (at your option) any later version.
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
12 *
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
13 * MPlayer is distributed in the hope that it will be useful,
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
16 * GNU General Public License for more details.
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
17 *
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
18 * 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: 25707
diff changeset
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 25707
diff changeset
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
21 */
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
22
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
23 #include <stdio.h>
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
24 #include <stdlib.h>
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
25 #include <unistd.h>
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
26 #include <string.h> /* strtok */
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
27
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
28 #include "config.h"
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
29 #include "mp_msg.h"
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
30 #include "help_mp.h"
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
31
22605
4d81dbdf46b9 Add explicit location for headers from the stream/ directory.
diego
parents: 21421
diff changeset
32 #include "stream/stream.h"
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
33 #include "demuxer.h"
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
34 #include "stheader.h"
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
35
25607
9d0b189ce1b2 Fix illegal identifiers: Names starting with __ or _ and uppercase are reserved
diego
parents: 24357
diff changeset
36 typedef struct FrameInfo
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
37 {
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
38 ssize_t frameSize;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
39 ssize_t paddingSize;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
40 int frameType;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
41 int channelNo;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
42 } FrameInfo;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
43
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
44 #define FRAMETYPE_I 0
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
45 #define FRAMETYPE_P 1
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
46 #define FRAMETYPE_B 2
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
47 #define FRAMETYPE_AUDIO_MPEG1L2 4
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
48 #define FRAMETYPE_AUDIO_ULAW 5
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
49 #define FRAMETYPE_AUDIO_ADPCM 6
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
50
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
51 #define PACKET_BLOCK_SIZE 0x00000200
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
52 #define PACKET_BLOCK_LAST 0x000001FF
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
53 #define PACKET_BLOCK_MASK 0xFFFFFE00
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
54
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
55 #define MAX_PACKET_SIZE 1048576 // 1 Mb
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
56
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
57 #define STREAM_START_CODE_SIZE 4
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
58
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
59 /*
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
60 // codes in MSB first
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
61 static unsigned int start_code [] =
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
62 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
63 0xB0010000, // VISUAL_OBJECT_SEQUENCE_START_CODE
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
64 0xB6010000, // VOP_START_CODE
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
65 0x04C4FDFF, // MPEG1LAYERII_START_CODE
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
66 0x00000000 // end of start codes list
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
67 };
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
68 */
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
69
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
70 static int imeHeaderValid(FrameInfo *frame)
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
71 {
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
72 if ( frame->channelNo > 7 ||
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
73 frame->frameSize > MAX_PACKET_SIZE || frame->frameSize <= 0)
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
74 {
31858
bf37d5ac4516 Add 'z' length modifier to %d printf format specifiers for size_t arguments.
diego
parents: 31609
diff changeset
75 mp_msg(MSGT_DEMUX, MSGL_V,
33841
25667edae85c cleanup: adjust printf format strings to match parameter types
diego
parents: 32123
diff changeset
76 "Invalid packet in LMLM4 stream: ch=%d size=%zu\n",
31858
bf37d5ac4516 Add 'z' length modifier to %d printf format specifiers for size_t arguments.
diego
parents: 31609
diff changeset
77 frame->channelNo, frame->frameSize);
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
78 return 0;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
79 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
80 switch (frame->frameType) {
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
81 case FRAMETYPE_I:
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
82 case FRAMETYPE_P:
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
83 case FRAMETYPE_B:
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
84 case FRAMETYPE_AUDIO_MPEG1L2:
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
85 case FRAMETYPE_AUDIO_ULAW:
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
86 case FRAMETYPE_AUDIO_ADPCM:
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
87 break;
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
88 default:
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
89 mp_msg(MSGT_DEMUX, MSGL_V, "Invalid packet in LMLM4 stream (wrong packet type %d)\n", frame->frameType);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
90 return 0;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
91 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
92 return 1;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
93 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
94
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
95 /*
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
96 int searchMPEG4Stream(demuxer_t* demuxer, IME6400Header *imeHeader)
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
97 {
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
98 void *data;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
99 ssize_t imeHeaderSize = sizeof(IME6400Header);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
100 ssize_t dataSize = sizeof(IME6400Header) * 3;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
101 ssize_t ptr = imeHeaderSize * 2;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
102 int errNo, startCodeNo;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
103 off_t pos;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
104
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
105 data = malloc(dataSize);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
106
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
107 imeHeaderSwap(imeHeader);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
108 memcpy(data + imeHeaderSize, imeHeader, imeHeaderSize);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
109
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
110 // printHex(data + imeHeaderSize, imeHeaderSize);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
111
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
112 while ((errNo = stream_read(demuxer->stream, data + imeHeaderSize * 2 , imeHeaderSize)) == imeHeaderSize)
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
113 {
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
114 // printHex(data + imeHeaderSize * 2, imeHeaderSize);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
115
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
116 pos = stream_tell(demuxer->stream);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
117 while (dataSize - ptr >= STREAM_START_CODE_SIZE) {
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
118 startCodeNo = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
119 while (start_code[startCodeNo])
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
120 {
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
121 if (memcmp(&start_code[startCodeNo], data + ptr, STREAM_START_CODE_SIZE) == 0) // start code match
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
122 {
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
123 memcpy(imeHeader, data + ptr - imeHeaderSize, imeHeaderSize);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
124 imeHeaderSwap(imeHeader);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
125 if (imeHeaderValid(imeHeader))
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
126 {
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
127 stream_seek(demuxer->stream, pos - (dataSize - ptr));
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
128 free(data);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
129 return 0;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
130 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
131 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
132 startCodeNo++;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
133 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
134 ptr++;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
135 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
136 memcpy(data,data + imeHeaderSize, imeHeaderSize * 2);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
137 ptr -= imeHeaderSize;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
138 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
139
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
140 free(data);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
141 return errNo;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
142 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
143 */
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
144
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
145 static int getFrame(demuxer_t *demuxer, FrameInfo *frameInfo)
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
146 {
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
147 unsigned int packetSize;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
148
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
149 frameInfo->channelNo = stream_read_word(demuxer->stream);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
150 frameInfo->frameType = stream_read_word(demuxer->stream);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
151 packetSize=stream_read_dword(demuxer->stream);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
152
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
153 if(stream_eof(demuxer->stream)){
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
154 frameInfo->frameSize = 0;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
155 return 0;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
156 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
157
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
158 frameInfo->frameSize = packetSize - 8; //sizeof(IME6400Header);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
159 frameInfo->paddingSize = (packetSize & PACKET_BLOCK_LAST) ? PACKET_BLOCK_SIZE - (packetSize & PACKET_BLOCK_LAST) : 0;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
160
33841
25667edae85c cleanup: adjust printf format strings to match parameter types
diego
parents: 32123
diff changeset
161 mp_msg(MSGT_DEMUX, MSGL_DBG2, "typ: %d chan: %d size: %zu pad: %zu\n",
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
162 frameInfo->frameType,
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
163 frameInfo->channelNo,
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
164 frameInfo->frameSize,
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
165 frameInfo->paddingSize);
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
166
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
167 if(!imeHeaderValid(frameInfo)){
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
168 // skip this packet
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
169 stream_skip(demuxer->stream,PACKET_BLOCK_SIZE-8);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
170 frameInfo->frameSize = 0;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
171 return -1;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
172 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
173
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
174 return 1;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
175 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
176
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
177 static int lmlm4_check_file(demuxer_t* demuxer)
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
178 {
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
179 FrameInfo frameInfo;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
180 unsigned int first;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
181
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
182 mp_msg(MSGT_DEMUX, MSGL_V, "Checking for LMLM4 Stream Format\n");
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
183
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
184 if(getFrame(demuxer, &frameInfo)!=1){
11790
rfelker
parents: 11590
diff changeset
185 mp_msg(MSGT_DEMUX, MSGL_V, "LMLM4 Stream Format not found\n");
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
186 return 0;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
187 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
188 first=stream_read_dword(demuxer->stream);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
189 stream_skip(demuxer->stream,-12);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
190
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
191 mp_msg(MSGT_DEMUXER,MSGL_V,"LMLM4: first=0x%08X\n",first);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
192
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
193 switch(frameInfo.frameType){
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
194 case FRAMETYPE_AUDIO_MPEG1L2:
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
195 if( (first & 0xffe00000) != 0xffe00000 ){
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
196 mp_msg(MSGT_DEMUXER,MSGL_V,"LMLM4: not mpeg audio\n");
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
197 return 0;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
198 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
199 if((4-((first>>17)&3))!=2){
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
200 mp_msg(MSGT_DEMUXER,MSGL_V,"LMLM4: not layer-2\n");
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
201 return 0;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
202 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
203 if(((first>>10)&0x3)==3){
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
204 mp_msg(MSGT_DEMUXER,MSGL_V,"LMLM4: invalid audio sampelrate\n");
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
205 return 0;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
206 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
207 mp_msg(MSGT_DEMUXER,MSGL_V,"LMLM4: first packet is audio, header checks OK!\n");
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
208 break;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
209 // TODO: add checks for video header too, for case of disabled audio
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
210 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
211
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
212
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
213 // stream_reset(demuxer->stream);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
214 mp_msg(MSGT_DEMUX, MSGL_V, "LMLM4 Stream Format found\n");
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
215
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
216 return DEMUXER_TYPE_LMLM4;
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
217 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
218
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
219 static int video = 0;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
220 static int frames= 0;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
221
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
222 // return value:
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
223 // 0 = EOF or no stream found
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
224 // 1 = successfully read a packet
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
225 static int demux_lmlm4_fill_buffer(demuxer_t *demux, demux_stream_t *ds)
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
226 {
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
227 FrameInfo frameInfo;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
228 double pts;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
229 int id=1;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
230 int ret;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
231
24357
ca0c0e094f1c warning fix:
diego
parents: 22605
diff changeset
232 //hdr:
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
233 demux->filepos = stream_tell(demux->stream);
17366
934380353fd6 massive attack: mp_msg printf format fixes
rathann
parents: 16175
diff changeset
234 mp_msg(MSGT_DEMUX, MSGL_DBG2, "fpos = %"PRId64"\n", (int64_t)demux->filepos);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
235
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
236 ret=getFrame(demux, &frameInfo);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
237 if(ret<=0) return ret; // EOF/error
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
238
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
239 pts=demux->video->sh ? frames*((sh_video_t*)(demux->video->sh))->frametime : 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
240
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
241 switch(frameInfo.frameType){
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
242 case FRAMETYPE_AUDIO_MPEG1L2:
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
243 mp_dbg(MSGT_DEMUX, MSGL_DBG2, "Audio Packet\n");
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
244 if (!video)
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
245 {
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
246 stream_skip(demux->stream, frameInfo.frameSize + frameInfo.paddingSize);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
247 mp_msg(MSGT_DEMUX, MSGL_V, "Skip Audio Packet\n");
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
248 return -1; //goto hdr;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
249 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
250 if(demux->audio->id==-1){
31609
cd81fce1f010 Make the stream language an argument to the stream creation function
reimar
parents: 29263
diff changeset
251 if(!demux->a_streams[id]) new_sh_audio(demux,id, NULL);
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
252 demux->audio->id=id;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
253 demux->audio->sh=demux->a_streams[id];
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
254 ((sh_audio_t*)(demux->audio->sh))->format=0x50; // mpeg audio layer 1/2
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
255 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
256 if(demux->audio->id==id)
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
257 ds_read_packet(demux->audio, demux->stream, frameInfo.frameSize,
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
258 pts, demux->filepos, 0);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
259 else
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
260 stream_skip(demux->stream,frameInfo.frameSize);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
261 break;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
262 case FRAMETYPE_I:
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
263 if (!video) {
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
264 video = 1;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
265 mp_dbg(MSGT_DEMUX, MSGL_DBG2, "First Video Packet\n");
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
266 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
267 case FRAMETYPE_P:
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
268 frames=(frames+1)&(1024*1024-1); // wrap around at 4 hrs to avoid inaccurate float calculations
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
269 if (!video)
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
270 {
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
271 stream_skip(demux->stream, frameInfo.frameSize + frameInfo.paddingSize);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
272 mp_msg(MSGT_DEMUX, MSGL_V, "Skip Video P Packet\n");
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
273 return -1; //goto hdr;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
274 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
275 mp_dbg(MSGT_DEMUX, MSGL_DBG2, "Video Packet\n");
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
276 if(demux->video->id==-1){
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
277 if(!demux->v_streams[id]) new_sh_video(demux,id);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
278 demux->video->id=id;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
279 demux->video->sh=demux->v_streams[id];
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
280 ((sh_video_t*)(demux->video->sh))->format=0x10000004; // mpeg4-ES
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
281 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
282 if(demux->video->id==id)
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
283 ds_read_packet(demux->video, demux->stream, frameInfo.frameSize,
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
284 pts, demux->filepos, 0);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
285 break;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
286 default:
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
287 stream_skip(demux->stream,frameInfo.frameSize);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
288 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
289
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
290 stream_skip(demux->stream, frameInfo.paddingSize);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
291
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
292 return 1;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
293 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
294
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
295 static demuxer_t* demux_open_lmlm4(demuxer_t* demuxer){
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
296 sh_audio_t *sh_audio=NULL;
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
297 sh_video_t *sh_video=NULL;
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
298
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
299 #if 0
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
300 sh_video_t* sh_video;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
301 sh_audio_t* sh_audio;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
302 unsigned int htype = 0, hleng;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
303 int i = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
304
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
305 sh_video = new_sh_video(demuxer, 0);
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
306 demuxer->video->sh = sh_video;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
307 sh_video->ds = demuxer->video;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
308 sh_video->disp_w = 640;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
309 sh_video->disp_h = 480;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
310 sh_video->format = mmioFOURCC('D','I','V','X');
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
311
32123
a86413775fbe Replace sizeof(BITMAPINFOHEADER)
reimar
parents: 32121
diff changeset
312 sh_video->bih = calloc(1, sizeof(*sh_video->bih));
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
313
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
314 /* these are false values */
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
315 sh_video->bih->biSize = 40;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
316 sh_video->bih->biWidth = sh_video->disp_w;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
317 sh_video->bih->biHeight = sh_video->disp_h;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
318 sh_video->bih->biPlanes = 3;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
319 sh_video->bih->biBitCount = 16;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
320 sh_video->bih->biCompression = sh_video->format;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
321 sh_video->bih->biSizeImage = sh_video->disp_w*sh_video->disp_h;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
322
31609
cd81fce1f010 Make the stream language an argument to the stream creation function
reimar
parents: 29263
diff changeset
323 sh_audio = new_sh_audio(demuxer, 0, NULL);
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
324 demuxer->audio->sh = sh_audio;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
325 sh_audio->ds = demuxer->audio;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
326
32121
d332ea379205 Replace sizeof(WAVEFORMATEX) occurrences.
reimar
parents: 32119
diff changeset
327 sh_audio->wf = calloc(1, sizeof(*sh_audio->wf));
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
328
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
329 sh_audio->samplerate = 48000;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
330 sh_audio->wf->wBitsPerSample = 16;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
331 sh_audio->channels = 2;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
332 sh_audio->format = 0x50;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
333 sh_audio->wf->wFormatTag = sh_audio->format;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
334 sh_audio->wf->nChannels = sh_audio->channels;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
335 sh_audio->wf->nSamplesPerSec = sh_audio->samplerate;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
336 sh_audio->wf->nAvgBytesPerSec = sh_audio->wf->nChannels*
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
337 sh_audio->wf->wBitsPerSample*sh_audio->wf->nSamplesPerSec/8;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
338 sh_audio->wf->nBlockAlign = sh_audio->channels *2;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
339 sh_audio->wf->cbSize = 0;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
340
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
341 #endif
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
342
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
343 demuxer->seekable = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
344
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
345 if(!ds_fill_buffer(demuxer->video)){
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
346 mp_msg(MSGT_DEMUXER,MSGL_INFO,"LMLM4: " MSGTR_MissingVideoStream);
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
347 demuxer->video->sh=NULL;
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
348 } else {
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
349 sh_video=demuxer->video->sh;sh_video->ds=demuxer->video;
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
350 }
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
351 if(demuxer->audio->id!=-2) {
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
352 if(!ds_fill_buffer(demuxer->audio)){
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
353 mp_msg(MSGT_DEMUXER,MSGL_INFO,"LMLM4: " MSGTR_MissingAudioStream);
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
354 demuxer->audio->sh=NULL;
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
355 } else {
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
356 sh_audio=demuxer->audio->sh;sh_audio->ds=demuxer->audio;
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
357 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
358 }
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29238
diff changeset
359
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
360 return demuxer;
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
361 }
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
362
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
363 static void demux_close_lmlm4(demuxer_t *demuxer)
11590
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
364 {
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
365 // printf("Close LMLM4 Stream\n");
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
366 return;
0908285ada31 LML-M4 mpeg4 capture card raw stream format support
arpi
parents:
diff changeset
367 }
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
368
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
369
25707
d4fe6e23283e Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents: 25607
diff changeset
370 const demuxer_desc_t demuxer_desc_lmlm4 = {
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
371 "LMLM4 MPEG4 Compression Card stream demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
372 "lmlm4",
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
373 "RAW LMLM4",
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
374 "Maxim Yevtyushkin",
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
375 "",
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
376 DEMUXER_TYPE_LMLM4,
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
377 0, // unsafe autodetect
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
378 lmlm4_check_file,
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
379 demux_lmlm4_fill_buffer,
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
380 demux_open_lmlm4,
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
381 demux_close_lmlm4,
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
382 NULL,
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
383 NULL
6b86089c2edd Demuxer modularization
rtognimp
parents: 11790
diff changeset
384 };