annotate tiertexseq.c @ 1481:08322a7e3804 libavformat

make some symbols static
author mru
date Sat, 11 Nov 2006 20:56:36 +0000
parents c7d4c4279fb7
children 7376514d9d60
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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++)
1405
f88bcfcc2f50 fix probe, patch by Andreas Oman, andreas at olebyn dot nu
bcoudurier
parents: 1381
diff changeset
71 if (p->buf[i] != 0)
1381
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;
1406
c7d4c4279fb7 avoid crashing when trying to parse invalid files, patch by Andreas Oman, andreas at olebyn dot nu
bcoudurier
parents: 1405
diff changeset
125 int i, e, err;
1381
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++);
1406
c7d4c4279fb7 avoid crashing when trying to parse invalid files, patch by Andreas Oman, andreas at olebyn dot nu
bcoudurier
parents: 1405
diff changeset
156 err = seq_fill_buffer(seq, pb, buffer_num[1 + i],
1381
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]);
1406
c7d4c4279fb7 avoid crashing when trying to parse invalid files, patch by Andreas Oman, andreas at olebyn dot nu
bcoudurier
parents: 1405
diff changeset
159 if (err != 0)
c7d4c4279fb7 avoid crashing when trying to parse invalid files, patch by Andreas Oman, andreas at olebyn dot nu
bcoudurier
parents: 1405
diff changeset
160 return err;
1381
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 }
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
163
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
164 if (buffer_num[0] != 255) {
1406
c7d4c4279fb7 avoid crashing when trying to parse invalid files, patch by Andreas Oman, andreas at olebyn dot nu
bcoudurier
parents: 1405
diff changeset
165 if (buffer_num[0] >= SEQ_NUM_FRAME_BUFFERS)
c7d4c4279fb7 avoid crashing when trying to parse invalid files, patch by Andreas Oman, andreas at olebyn dot nu
bcoudurier
parents: 1405
diff changeset
166 return AVERROR_INVALIDDATA;
c7d4c4279fb7 avoid crashing when trying to parse invalid files, patch by Andreas Oman, andreas at olebyn dot nu
bcoudurier
parents: 1405
diff changeset
167
1381
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_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
169 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
170 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
171 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
172 } else {
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
173 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
174 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
175 }
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 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
178 }
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
179
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
180 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
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 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
183 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
184 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
185 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
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 /* 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
188 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
189 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
190 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
191
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
192 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
193
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
194 /* 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
195 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
196 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
197 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
198 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
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
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
201 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
202
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
203 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
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 /* 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
206 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
207 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
208 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
209
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
210 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
211 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
212 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
213 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
214 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
215 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
216 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
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 /* 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
219 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
220 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
221 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
222
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
223 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
224 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
225 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
226 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
227 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
228 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
229 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
230 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
231 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
232 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
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 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
235 }
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
236
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
237 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
238 {
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
239 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
240 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
241 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
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 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
244 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
245 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
246 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
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 /* 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
249 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
250 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
251 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
252
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
253 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
254 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
255 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
256 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
257 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
258 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
259 }
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
260 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
261 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
262 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
263 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
264 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
265 }
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
266 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
267 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
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 /* 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
270 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
271 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
272 }
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
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
275 /* 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
276 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
277 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
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 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
280 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
281 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
282 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
283
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
284 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
285 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
286
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
287 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
288 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
289 }
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 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
292 {
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
293 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
294 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
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 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
297 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
298
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
299 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
300 }
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
301
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
302 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
303 "tiertexseq",
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
304 "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
305 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
306 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
307 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
308 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
309 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
310 };