annotate tiertexseqv.c @ 6498:d9c48a85fd23 libavcodec

improve precision in mdct.c using double for some temporaries
author mru
date Sun, 16 Mar 2008 13:15:42 +0000
parents 2134a0fc46f3
children 48759bfbd073
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
1 /*
986d6651a452 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 Video Decoder
986d6651a452 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)
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
4 *
986d6651a452 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.
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
6 *
986d6651a452 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
986d6651a452 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
986d6651a452 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
986d6651a452 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.
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
11 *
986d6651a452 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,
986d6651a452 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
986d6651a452 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
986d6651a452 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.
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
16 *
986d6651a452 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
986d6651a452 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
986d6651a452 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
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
20 */
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
21
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
22 /**
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
23 * @file tiertexseqv.c
986d6651a452 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 video decoder
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
25 */
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
26
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
27 #include "avcodec.h"
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
28 #define ALT_BITSTREAM_READER_LE
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
29 #include "bitstream.h"
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
30
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
31
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
32 typedef struct SeqVideoContext {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
33 AVCodecContext *avctx;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
34 AVFrame frame;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
35 unsigned int palette[256];
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
36 unsigned char block[8 * 8];
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
37 } SeqVideoContext;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
38
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
39
6283
michael
parents: 5089
diff changeset
40 static const unsigned char *seq_unpack_rle_block(const unsigned char *src, unsigned char *dst, int dst_size)
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
41 {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
42 int i, len, sz;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
43 GetBitContext gb;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
44 int code_table[64];
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
45
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
46 /* get the rle codes (at most 64 bytes) */
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
47 init_get_bits(&gb, src, 64 * 8);
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
48 for (i = 0, sz = 0; i < 64 && sz < dst_size; i++) {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
49 code_table[i] = get_sbits(&gb, 4);
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
50 sz += FFABS(code_table[i]);
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
51 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
52 src += (get_bits_count(&gb) + 7) / 8;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
53
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
54 /* do the rle unpacking */
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
55 for (i = 0; i < 64 && dst_size > 0; i++) {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
56 len = code_table[i];
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
57 if (len < 0) {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
58 len = -len;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
59 memset(dst, *src++, FFMIN(len, dst_size));
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
60 } else {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
61 memcpy(dst, src, FFMIN(len, dst_size));
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
62 src += len;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
63 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
64 dst += len;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
65 dst_size -= len;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
66 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
67 return src;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
68 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
69
6283
michael
parents: 5089
diff changeset
70 static const unsigned char *seq_decode_op1(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst)
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
71 {
6283
michael
parents: 5089
diff changeset
72 const unsigned char *color_table;
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
73 int b, i, len, bits;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
74 GetBitContext gb;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
75
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
76 len = *src++;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
77 if (len & 0x80) {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
78 switch (len & 3) {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
79 case 1:
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
80 src = seq_unpack_rle_block(src, seq->block, sizeof(seq->block));
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
81 for (b = 0; b < 8; b++) {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
82 memcpy(dst, &seq->block[b * 8], 8);
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
83 dst += seq->frame.linesize[0];
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
84 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
85 break;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
86 case 2:
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
87 src = seq_unpack_rle_block(src, seq->block, sizeof(seq->block));
986d6651a452 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 < 8; i++) {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
89 for (b = 0; b < 8; b++)
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
90 dst[b * seq->frame.linesize[0]] = seq->block[i * 8 + b];
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
91 ++dst;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
92 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
93 break;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
94 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
95 } else {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
96 color_table = src;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
97 src += len;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
98 bits = ff_log2_tab[len - 1] + 1;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
99 init_get_bits(&gb, src, bits * 8 * 8); src += bits * 8;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
100 for (b = 0; b < 8; b++) {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
101 for (i = 0; i < 8; i++)
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
102 dst[i] = color_table[get_bits(&gb, bits)];
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
103 dst += seq->frame.linesize[0];
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
104 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
105 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
106
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
107 return src;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
108 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
109
6283
michael
parents: 5089
diff changeset
110 static const unsigned char *seq_decode_op2(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst)
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
111 {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
112 int i;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
113
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
114 for (i = 0; i < 8; i++) {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
115 memcpy(dst, src, 8);
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
116 src += 8;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
117 dst += seq->frame.linesize[0];
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
118 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
119
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
120 return src;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
121 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
122
6283
michael
parents: 5089
diff changeset
123 static const unsigned char *seq_decode_op3(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst)
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
124 {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
125 int pos, offset;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
126
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
127 do {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
128 pos = *src++;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
129 offset = ((pos >> 3) & 7) * seq->frame.linesize[0] + (pos & 7);
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
130 dst[offset] = *src++;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
131 } while (!(pos & 0x80));
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
132
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
133 return src;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
134 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
135
6283
michael
parents: 5089
diff changeset
136 static void seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int data_size)
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
137 {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
138 GetBitContext gb;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
139 int flags, i, j, x, y, op;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
140 unsigned char c[3];
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
141 unsigned char *dst;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
142
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
143 flags = *data++;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
144
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
145 if (flags & 1) {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
146 for (i = 0; i < 256; i++) {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
147 for (j = 0; j < 3; j++, data++)
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
148 c[j] = (*data << 2) | (*data >> 4);
5089
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 4962
diff changeset
149 seq->palette[i] = AV_RB24(c);
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
150 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
151 memcpy(seq->frame.data[1], seq->palette, sizeof(seq->palette));
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
152 seq->frame.palette_has_changed = 1;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
153 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
154
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
155 if (flags & 2) {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
156 init_get_bits(&gb, data, 128 * 8); data += 128;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
157 for (y = 0; y < 128; y += 8)
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
158 for (x = 0; x < 256; x += 8) {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
159 dst = &seq->frame.data[0][y * seq->frame.linesize[0] + x];
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
160 op = get_bits(&gb, 2);
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
161 switch (op) {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
162 case 1:
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
163 data = seq_decode_op1(seq, data, dst);
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
164 break;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
165 case 2:
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
166 data = seq_decode_op2(seq, data, dst);
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
167 break;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
168 case 3:
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
169 data = seq_decode_op3(seq, data, dst);
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
170 break;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
171 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
172 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
173 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
174 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
175
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
176 static int seqvideo_decode_init(AVCodecContext *avctx)
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
177 {
4827
b3ee9a1526b0 Get rid of unnecessary pointer casts.
diego
parents: 4801
diff changeset
178 SeqVideoContext *seq = avctx->priv_data;
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
179
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
180 seq->avctx = avctx;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
181 avctx->pix_fmt = PIX_FMT_PAL8;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
182
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
183 seq->frame.data[0] = NULL;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
184
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
185 return 0;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
186 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
187
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
188 static int seqvideo_decode_frame(AVCodecContext *avctx,
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
189 void *data, int *data_size,
6283
michael
parents: 5089
diff changeset
190 const uint8_t *buf, int buf_size)
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
191 {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
192
4827
b3ee9a1526b0 Get rid of unnecessary pointer casts.
diego
parents: 4801
diff changeset
193 SeqVideoContext *seq = avctx->priv_data;
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
194
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
195 seq->frame.reference = 1;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
196 seq->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
197 if (avctx->reget_buffer(avctx, &seq->frame)) {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
198 av_log(seq->avctx, AV_LOG_ERROR, "tiertexseqvideo: reget_buffer() failed\n");
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
199 return -1;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
200 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
201
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
202 seqvideo_decode(seq, buf, buf_size);
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
203
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
204 *data_size = sizeof(AVFrame);
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
205 *(AVFrame *)data = seq->frame;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
206
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
207 return buf_size;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
208 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
209
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
210 static int seqvideo_decode_end(AVCodecContext *avctx)
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
211 {
4827
b3ee9a1526b0 Get rid of unnecessary pointer casts.
diego
parents: 4801
diff changeset
212 SeqVideoContext *seq = avctx->priv_data;
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
213
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
214 if (seq->frame.data[0])
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
215 avctx->release_buffer(avctx, &seq->frame);
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
216
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
217 return 0;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
218 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
219
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
220 AVCodec tiertexseqvideo_decoder = {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
221 "tiertexseqvideo",
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
222 CODEC_TYPE_VIDEO,
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
223 CODEC_ID_TIERTEXSEQVIDEO,
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
224 sizeof(SeqVideoContext),
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
225 seqvideo_decode_init,
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
226 NULL,
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
227 seqvideo_decode_end,
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
228 seqvideo_decode_frame,
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
229 CODEC_CAP_DR1,
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
230 };