annotate tiertexseqv.c @ 11840:6258952f47df libavcodec

bgr/rgb444 for nut
author michael
date Sun, 06 Jun 2010 11:43:53 +0000
parents 7dd2a45249a9
children
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 /**
11644
7dd2a45249a9 Remove explicit filename from Doxygen @file commands.
diego
parents: 11560
diff changeset
23 * @file
4006
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
9428
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents: 9355
diff changeset
29 #include "get_bits.h"
4006
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 } SeqVideoContext;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
36
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
37
6283
michael
parents: 5089
diff changeset
38 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
39 {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
40 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
41 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
42 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
43
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
44 /* 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
45 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
46 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
47 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
48 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
49 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
50 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
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 /* 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
53 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
54 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
55 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
56 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
57 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
58 } else {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
59 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
60 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
61 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
62 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
63 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
64 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
65 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
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
6283
michael
parents: 5089
diff changeset
68 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
69 {
6283
michael
parents: 5089
diff changeset
70 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
71 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
72 GetBitContext gb;
7207
655f242bb525 Remove context fields which can be used as simple local variables.
diego
parents: 7206
diff changeset
73 unsigned char block[8 * 8];
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
74
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
75 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
76 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
77 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
78 case 1:
7207
655f242bb525 Remove context fields which can be used as simple local variables.
diego
parents: 7206
diff changeset
79 src = seq_unpack_rle_block(src, block, sizeof(block));
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
80 for (b = 0; b < 8; b++) {
7207
655f242bb525 Remove context fields which can be used as simple local variables.
diego
parents: 7206
diff changeset
81 memcpy(dst, &block[b * 8], 8);
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
82 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
83 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
84 break;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
85 case 2:
7207
655f242bb525 Remove context fields which can be used as simple local variables.
diego
parents: 7206
diff changeset
86 src = seq_unpack_rle_block(src, block, sizeof(block));
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
87 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
88 for (b = 0; b < 8; b++)
7207
655f242bb525 Remove context fields which can be used as simple local variables.
diego
parents: 7206
diff changeset
89 dst[b * seq->frame.linesize[0]] = block[i * 8 + b];
4006
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;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
91 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
92 break;
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
93 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
94 } else {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
95 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
96 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
97 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
98 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
99 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
100 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
101 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
102 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
103 }
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 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
107 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
108
6283
michael
parents: 5089
diff changeset
109 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
110 {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
111 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
112
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
113 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
114 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
115 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 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
117 }
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 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
120 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
121
6283
michael
parents: 5089
diff changeset
122 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
123 {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
124 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
125
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
126 do {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
127 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
128 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
129 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
130 } 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
131
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
132 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
133 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
134
6283
michael
parents: 5089
diff changeset
135 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
136 {
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
137 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
138 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
139 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
140 unsigned char *dst;
7207
655f242bb525 Remove context fields which can be used as simple local variables.
diego
parents: 7206
diff changeset
141 uint32_t *palette;
4006
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) {
7207
655f242bb525 Remove context fields which can be used as simple local variables.
diego
parents: 7206
diff changeset
146 palette = (uint32_t *)seq->frame.data[1];
4006
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 (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
148 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
149 c[j] = (*data << 2) | (*data >> 4);
7207
655f242bb525 Remove context fields which can be used as simple local variables.
diego
parents: 7206
diff changeset
150 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
151 }
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
6517
48759bfbd073 Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents: 6283
diff changeset
176 static av_cold int seqvideo_decode_init(AVCodecContext *avctx)
4006
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
7206
3092ae791531 Remove av_cold attribute on decode_frame and add it to decode_end
diego
parents: 7040
diff changeset
188 static int seqvideo_decode_frame(AVCodecContext *avctx,
4006
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,
9355
54bc8a2727b0 Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents: 8718
diff changeset
190 AVPacket *avpkt)
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 {
9355
54bc8a2727b0 Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents: 8718
diff changeset
192 const uint8_t *buf = avpkt->data;
54bc8a2727b0 Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents: 8718
diff changeset
193 int buf_size = avpkt->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
194
4827
b3ee9a1526b0 Get rid of unnecessary pointer casts.
diego
parents: 4801
diff changeset
195 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
196
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
197 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
198 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
199 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
200 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
201 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
202 }
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 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
205
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
206 *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
207 *(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
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 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
210 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
211
7206
3092ae791531 Remove av_cold attribute on decode_frame and add it to decode_end
diego
parents: 7040
diff changeset
212 static av_cold int seqvideo_decode_end(AVCodecContext *avctx)
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 {
4827
b3ee9a1526b0 Get rid of unnecessary pointer casts.
diego
parents: 4801
diff changeset
214 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
215
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
216 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
217 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
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 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
220 }
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
221
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
222 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
223 "tiertexseqvideo",
11560
8a4984c5cacc Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents: 9428
diff changeset
224 AVMEDIA_TYPE_VIDEO,
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
225 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
226 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
227 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
228 NULL,
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
229 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
230 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
231 CODEC_CAP_DR1,
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6722
diff changeset
232 .long_name = NULL_IF_CONFIG_SMALL("Tiertex Limited SEQ video"),
4006
986d6651a452 support for Tiertex .seq files demuxing/video decoding, by Gregory Montoir %cyx A users P sourceforge P net%
bcoudurier
parents:
diff changeset
233 };