Mercurial > libavformat.hg
annotate tiertexseq.c @ 1383:97bd1648eb9a libavformat
Add a note about illegal codec IDs.
author | diego |
---|---|
date | Fri, 13 Oct 2006 00:02:33 +0000 |
parents | d0a6c143b246 |
children | f88bcfcc2f50 |
rev | line source |
---|---|
1381
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
1 /* |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
2 * Tiertex Limited SEQ File Demuxer |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
3 * Copyright (c) 2006 Gregory Montoir (cyx@users.sourceforge.net) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
4 * |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
5 * This file is part of FFmpeg. |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
6 * |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
11 * |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
16 * |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
20 */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
21 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
22 /** |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
23 * @file tiertexseq.c |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
24 * Tiertex Limited SEQ file demuxer |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
25 */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
26 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
27 #include "avformat.h" |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
28 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
29 #define SEQ_FRAME_SIZE 6144 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
30 #define SEQ_FRAME_W 256 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
31 #define SEQ_FRAME_H 128 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
32 #define SEQ_NUM_FRAME_BUFFERS 30 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
33 #define SEQ_AUDIO_BUFFER_SIZE 882 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
34 #define SEQ_SAMPLE_RATE 22050 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
35 #define SEQ_FRAME_RATE 25 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
36 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
37 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
38 typedef struct TiertexSeqFrameBuffer { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
39 int fill_size; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
40 int data_size; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
41 unsigned char *data; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
42 } TiertexSeqFrameBuffer; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
43 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
44 typedef struct SeqDemuxContext { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
45 int audio_stream_index; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
46 int video_stream_index; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
47 int current_frame_pts; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
48 int current_frame_offs; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
49 TiertexSeqFrameBuffer frame_buffers[SEQ_NUM_FRAME_BUFFERS]; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
50 int frame_buffers_count; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
51 unsigned int current_audio_data_size; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
52 unsigned int current_audio_data_offs; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
53 unsigned int current_pal_data_size; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
54 unsigned int current_pal_data_offs; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
55 unsigned int current_video_data_size; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
56 unsigned char *current_video_data_ptr; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
57 int audio_buffer_full; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
58 } SeqDemuxContext; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
59 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
60 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
61 static int seq_probe(AVProbeData *p) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
62 { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
63 int i; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
64 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
65 if (p->buf_size < 256) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
66 return 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
67 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
68 /* there's no real header in a .seq file, the only thing they have in common */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
69 /* is the first 256 bytes of the file which are always filled with 0 */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
70 for (i = 0; i < 256; i++) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
71 if (p->buf[0] != 0) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
72 return 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
73 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
74 /* only one fourth of the score since the previous check is too naive */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
75 return AVPROBE_SCORE_MAX / 4; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
76 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
77 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
78 static int seq_init_frame_buffers(SeqDemuxContext *seq, ByteIOContext *pb) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
79 { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
80 int i, sz; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
81 TiertexSeqFrameBuffer *seq_buffer; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
82 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
83 url_fseek(pb, 256, SEEK_SET); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
84 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
85 for (i = 0; i < SEQ_NUM_FRAME_BUFFERS; i++) { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
86 sz = get_le16(pb); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
87 if (sz == 0) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
88 break; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
89 else { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
90 seq_buffer = &seq->frame_buffers[i]; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
91 seq_buffer->fill_size = 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
92 seq_buffer->data_size = sz; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
93 seq_buffer->data = av_malloc(sz); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
94 if (!seq_buffer->data) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
95 return AVERROR_NOMEM; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
96 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
97 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
98 seq->frame_buffers_count = i; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
99 return 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
100 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
101 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
102 static int seq_fill_buffer(SeqDemuxContext *seq, ByteIOContext *pb, int buffer_num, unsigned int data_offs, int data_size) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
103 { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
104 TiertexSeqFrameBuffer *seq_buffer; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
105 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
106 if (buffer_num >= SEQ_NUM_FRAME_BUFFERS) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
107 return AVERROR_INVALIDDATA; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
108 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
109 seq_buffer = &seq->frame_buffers[buffer_num]; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
110 if (seq_buffer->fill_size + data_size > seq_buffer->data_size) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
111 return AVERROR_INVALIDDATA; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
112 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
113 url_fseek(pb, seq->current_frame_offs + data_offs, SEEK_SET); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
114 if (get_buffer(pb, seq_buffer->data + seq_buffer->fill_size, data_size) != data_size) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
115 return AVERROR_IO; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
116 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
117 seq_buffer->fill_size += data_size; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
118 return 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
119 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
120 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
121 static int seq_parse_frame_data(SeqDemuxContext *seq, ByteIOContext *pb) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
122 { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
123 unsigned int offset_table[4], buffer_num[4]; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
124 TiertexSeqFrameBuffer *seq_buffer; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
125 int i, e; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
126 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
127 seq->current_frame_offs += SEQ_FRAME_SIZE; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
128 url_fseek(pb, seq->current_frame_offs, SEEK_SET); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
129 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
130 /* sound data */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
131 seq->current_audio_data_offs = get_le16(pb); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
132 if (seq->current_audio_data_offs != 0) { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
133 seq->current_audio_data_size = SEQ_AUDIO_BUFFER_SIZE * 2; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
134 } else { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
135 seq->current_audio_data_size = 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
136 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
137 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
138 /* palette data */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
139 seq->current_pal_data_offs = get_le16(pb); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
140 if (seq->current_pal_data_offs != 0) { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
141 seq->current_pal_data_size = 768; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
142 } else { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
143 seq->current_pal_data_size = 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
144 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
145 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
146 /* video data */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
147 for (i = 0; i < 4; i++) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
148 buffer_num[i] = get_byte(pb); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
149 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
150 for (i = 0; i < 4; i++) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
151 offset_table[i] = get_le16(pb); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
152 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
153 for (i = 0; i < 3; i++) { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
154 if (offset_table[i] != 0) { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
155 for (e = i + 1; e < 4 && offset_table[e] == 0; e++); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
156 seq_fill_buffer(seq, pb, buffer_num[1 + i], |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
157 offset_table[i], |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
158 offset_table[e] - offset_table[i]); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
159 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
160 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
161 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
162 if (buffer_num[0] != 255) { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
163 seq_buffer = &seq->frame_buffers[buffer_num[0]]; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
164 seq->current_video_data_size = seq_buffer->fill_size; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
165 seq->current_video_data_ptr = seq_buffer->data; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
166 seq_buffer->fill_size = 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
167 } else { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
168 seq->current_video_data_size = 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
169 seq->current_video_data_ptr = 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
170 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
171 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
172 return 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
173 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
174 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
175 static int seq_read_header(AVFormatContext *s, AVFormatParameters *ap) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
176 { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
177 int i, rc; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
178 SeqDemuxContext *seq = (SeqDemuxContext *)s->priv_data; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
179 ByteIOContext *pb = &s->pb; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
180 AVStream *st; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
181 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
182 /* init internal buffers */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
183 rc = seq_init_frame_buffers(seq, pb); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
184 if (rc) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
185 return rc; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
186 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
187 seq->current_frame_offs = 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
188 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
189 /* preload (no audio data, just buffer operations related data) */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
190 for (i = 1; i <= 100; i++) { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
191 rc = seq_parse_frame_data(seq, pb); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
192 if (rc) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
193 return rc; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
194 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
195 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
196 seq->current_frame_pts = 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
197 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
198 seq->audio_buffer_full = 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
199 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
200 /* initialize the video decoder stream */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
201 st = av_new_stream(s, 0); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
202 if (!st) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
203 return AVERROR_NOMEM; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
204 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
205 av_set_pts_info(st, 32, 1, SEQ_FRAME_RATE); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
206 seq->video_stream_index = st->index; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
207 st->codec->codec_type = CODEC_TYPE_VIDEO; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
208 st->codec->codec_id = CODEC_ID_TIERTEXSEQVIDEO; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
209 st->codec->codec_tag = 0; /* no fourcc */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
210 st->codec->width = SEQ_FRAME_W; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
211 st->codec->height = SEQ_FRAME_H; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
212 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
213 /* initialize the audio decoder stream */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
214 st = av_new_stream(s, 0); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
215 if (!st) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
216 return AVERROR_NOMEM; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
217 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
218 av_set_pts_info(st, 32, 1, SEQ_SAMPLE_RATE); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
219 seq->audio_stream_index = st->index; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
220 st->codec->codec_type = CODEC_TYPE_AUDIO; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
221 st->codec->codec_id = CODEC_ID_PCM_S16BE; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
222 st->codec->codec_tag = 0; /* no tag */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
223 st->codec->channels = 1; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
224 st->codec->sample_rate = SEQ_SAMPLE_RATE; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
225 st->codec->bits_per_sample = 16; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
226 st->codec->bit_rate = st->codec->sample_rate * st->codec->bits_per_sample * st->codec->channels; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
227 st->codec->block_align = st->codec->channels * st->codec->bits_per_sample; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
228 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
229 return 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
230 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
231 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
232 static int seq_read_packet(AVFormatContext *s, AVPacket *pkt) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
233 { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
234 int rc; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
235 SeqDemuxContext *seq = (SeqDemuxContext *)s->priv_data; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
236 ByteIOContext *pb = &s->pb; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
237 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
238 if (!seq->audio_buffer_full) { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
239 rc = seq_parse_frame_data(seq, pb); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
240 if (rc) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
241 return rc; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
242 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
243 /* video packet */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
244 if (seq->current_pal_data_size + seq->current_video_data_size != 0) { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
245 if (av_new_packet(pkt, 1 + seq->current_pal_data_size + seq->current_video_data_size)) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
246 return AVERROR_NOMEM; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
247 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
248 pkt->data[0] = 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
249 if (seq->current_pal_data_size != 0) { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
250 pkt->data[0] |= 1; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
251 url_fseek(pb, seq->current_frame_offs + seq->current_pal_data_offs, SEEK_SET); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
252 if (get_buffer(pb, &pkt->data[1], seq->current_pal_data_size) != seq->current_pal_data_size) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
253 return AVERROR_IO; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
254 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
255 if (seq->current_video_data_size != 0) { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
256 pkt->data[0] |= 2; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
257 memcpy(&pkt->data[1 + seq->current_pal_data_size], |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
258 seq->current_video_data_ptr, |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
259 seq->current_video_data_size); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
260 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
261 pkt->stream_index = seq->video_stream_index; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
262 pkt->pts = seq->current_frame_pts; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
263 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
264 /* sound buffer will be processed on next read_packet() call */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
265 seq->audio_buffer_full = 1; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
266 return 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
267 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
268 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
269 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
270 /* audio packet */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
271 if (seq->current_audio_data_offs == 0) /* end of data reached */ |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
272 return AVERROR_IO; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
273 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
274 url_fseek(pb, seq->current_frame_offs + seq->current_audio_data_offs, SEEK_SET); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
275 rc = av_get_packet(pb, pkt, seq->current_audio_data_size); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
276 if (rc < 0) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
277 return rc; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
278 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
279 pkt->stream_index = seq->audio_stream_index; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
280 pkt->pts = seq->current_frame_pts++; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
281 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
282 seq->audio_buffer_full = 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
283 return 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
284 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
285 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
286 static int seq_read_close(AVFormatContext *s) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
287 { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
288 int i; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
289 SeqDemuxContext *seq = (SeqDemuxContext *)s->priv_data; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
290 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
291 for (i = 0; i < SEQ_NUM_FRAME_BUFFERS; i++) |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
292 av_free(seq->frame_buffers[i].data); |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
293 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
294 return 0; |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
295 } |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
296 |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
297 AVInputFormat tiertexseq_demuxer = { |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
298 "tiertexseq", |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
299 "Tiertex Limited SEQ format", |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
300 sizeof(SeqDemuxContext), |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
301 seq_probe, |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
302 seq_read_header, |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
303 seq_read_packet, |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
304 seq_read_close, |
d0a6c143b246
support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff
changeset
|
305 }; |