annotate tiertexseq.c @ 2745:0d82417b7a88 libavformat

Typo
author takis
date Wed, 14 Nov 2007 12:42:45 +0000
parents b21c2af60bc9
children d52c718e83f9
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
1618
7376514d9d60 missdetected a broken mp3
michael
parents: 1406
diff changeset
65 if (p->buf_size < 258)
1381
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
1618
7376514d9d60 missdetected a broken mp3
michael
parents: 1406
diff changeset
74 if(p->buf[256]==0 && p->buf[257]==0)
7376514d9d60 missdetected a broken mp3
michael
parents: 1406
diff changeset
75 return 0;
7376514d9d60 missdetected a broken mp3
michael
parents: 1406
diff changeset
76
1381
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
77 /* 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
78 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
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
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
81 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
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 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
84 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
85
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
86 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
87
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
88 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
89 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
90 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
91 break;
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
92 else {
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 = &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
94 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
95 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
96 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
97 if (!seq_buffer->data)
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2006
diff changeset
98 return AVERROR(ENOMEM);
1381
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
99 }
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 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
102 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
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
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
105 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
106 {
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
107 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
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 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
110 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
111
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
112 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
113 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
114 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
115
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
116 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
117 if (get_buffer(pb, seq_buffer->data + seq_buffer->fill_size, data_size) != data_size)
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
118 return AVERROR(EIO);
1381
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 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
121 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
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
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
124 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
125 {
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
126 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
127 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
128 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
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 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
131 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
132
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
133 /* 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
134 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
135 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
136 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
137 } else {
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
138 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
139 }
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
140
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
141 /* 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
142 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
143 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
144 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
145 } else {
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
146 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
147 }
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
148
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
149 /* 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
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 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
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 < 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
154 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
155
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163 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
164 }
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
165 }
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
166
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
167 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
168 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
169 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
170
1381
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 = &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
172 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
173 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
174 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
175 } else {
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
176 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
177 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
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 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
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
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
183 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
184 {
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
185 int i, rc;
2006
2f0154760e5f Get rid of unnecessary pointer casts.
diego
parents: 1618
diff changeset
186 SeqDemuxContext *seq = s->priv_data;
1381
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
187 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
188 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
189
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
190 /* 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
191 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
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 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
196
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
197 /* 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
198 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
199 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
200 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
201 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
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
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
204 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
205
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->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
207
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
208 /* 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
209 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
210 if (!st)
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2006
diff changeset
211 return AVERROR(ENOMEM);
1381
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 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
214 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
215 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
216 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
217 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
218 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
219 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
220
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
221 /* 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
222 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
223 if (!st)
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2006
diff changeset
224 return AVERROR(ENOMEM);
1381
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
225
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
226 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
227 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
228 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
229 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
230 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
231 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
232 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
233 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
234 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
235 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
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 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
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
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
240 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
241 {
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
242 int rc;
2006
2f0154760e5f Get rid of unnecessary pointer casts.
diego
parents: 1618
diff changeset
243 SeqDemuxContext *seq = s->priv_data;
1381
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
244 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
245
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
246 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
247 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
248 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
249 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
250
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
251 /* 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
252 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
253 if (av_new_packet(pkt, 1 + seq->current_pal_data_size + seq->current_video_data_size))
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2006
diff changeset
254 return AVERROR(ENOMEM);
1381
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
255
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] = 0;
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 (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
258 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
259 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
260 if (get_buffer(pb, &pkt->data[1], seq->current_pal_data_size) != seq->current_pal_data_size)
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
261 return AVERROR(EIO);
1381
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
262 }
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
263 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
264 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
265 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
266 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
267 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
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 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
270 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
271
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
272 /* 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
273 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
274 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
275 }
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
276 }
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
277
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
278 /* 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
279 if (seq->current_audio_data_offs == 0) /* end of data reached */
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
280 return AVERROR(EIO);
1381
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 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
283 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
284 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
285 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
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 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
288 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
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 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
291 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
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
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
294 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
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 int i;
2006
2f0154760e5f Get rid of unnecessary pointer casts.
diego
parents: 1618
diff changeset
297 SeqDemuxContext *seq = s->priv_data;
1381
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 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
300 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
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 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
303 }
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
304
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
305 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
306 "tiertexseq",
d0a6c143b246 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
307 "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
308 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
309 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
310 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
311 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
312 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
313 };