annotate tscc.c @ 3947:c8c591fe26f8 libavcodec

Change license headers to say 'FFmpeg' instead of 'this program/this library' and fix GPL/LGPL version mismatches.
author diego
date Sat, 07 Oct 2006 15:30:46 +0000
parents 9b75ab171fa9
children 05e932ddaaa9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
1 /*
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
2 * TechSmith Camtasia decoder
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
3 * Copyright (c) 2004 Konstantin Shishkov
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
4 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3800
diff changeset
5 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3800
diff changeset
6 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3800
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3800
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3800
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
15 * Lesser General Public License for more details.
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
16 *
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3800
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 2979
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
20 *
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
21 */
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
22
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
23 /**
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
24 * @file tscc.c
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
25 * TechSmith Camtasia decoder
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
26 *
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
27 * Fourcc: TSCC
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
28 *
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
29 * Codec is very simple:
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
30 * it codes picture (picture difference, really)
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
31 * with algorithm almost identical to Windows RLE8,
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
32 * only without padding and with greater pixel sizes,
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
33 * then this coded picture is packed with ZLib
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
34 *
2196
3eae46c131a3 8-bit mode corrections
melanson
parents: 2170
diff changeset
35 * Supports: BGR8,BGR555,BGR24 - only BGR8 and BGR555 tested
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
36 *
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
37 */
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
38
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
39 #include <stdio.h>
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
40 #include <stdlib.h>
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
41
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
42 #include "common.h"
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
43 #include "avcodec.h"
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
44
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
45 #ifdef CONFIG_ZLIB
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
46 #include <zlib.h>
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
47 #endif
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
48
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
49
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
50 /*
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
51 * Decoder context
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
52 */
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
53 typedef struct TsccContext {
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
54
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
55 AVCodecContext *avctx;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
56 AVFrame pic;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
57
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
58 // Bits per pixel
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
59 int bpp;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
60 // Decompressed data size
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
61 unsigned int decomp_size;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
62 // Decompression buffer
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
63 unsigned char* decomp_buf;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
64 int height;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
65 #ifdef CONFIG_ZLIB
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
66 z_stream zstream;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
67 #endif
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
68 } CamtasiaContext;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
69
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
70 /*
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
71 *
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
72 * Decode RLE - almost identical to Windows BMP RLE8
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
73 * and enhanced to bigger color depths
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
74 *
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
75 */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2510
diff changeset
76
2455
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
77 static int decode_rle(CamtasiaContext *c, unsigned int srcsize)
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
78 {
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
79 unsigned char *src = c->decomp_buf;
2455
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
80 unsigned char *output, *output_end;
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
81 int p1, p2, line=c->height, pos=0, i;
3121
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
82 uint16_t pix16;
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
83 uint32_t pix32;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2510
diff changeset
84
2196
3eae46c131a3 8-bit mode corrections
melanson
parents: 2170
diff changeset
85 output = c->pic.data[0] + (c->height - 1) * c->pic.linesize[0];
2455
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
86 output_end = c->pic.data[0] + (c->height) * c->pic.linesize[0];
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
87 while(src < c->decomp_buf + srcsize) {
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
88 p1 = *src++;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
89 if(p1 == 0) { //Escape code
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
90 p2 = *src++;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
91 if(p2 == 0) { //End-of-line
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
92 output = c->pic.data[0] + (--line) * c->pic.linesize[0];
2455
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
93 if (line < 0)
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
94 return -1;
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
95 pos = 0;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
96 continue;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
97 } else if(p2 == 1) { //End-of-picture
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
98 return 0;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
99 } else if(p2 == 2) { //Skip
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
100 p1 = *src++;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
101 p2 = *src++;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
102 line -= p2;
2455
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
103 if (line < 0)
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
104 return -1;
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
105 pos += p1;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
106 output = c->pic.data[0] + line * c->pic.linesize[0] + pos * (c->bpp / 8);
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
107 continue;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
108 }
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
109 // Copy data
2455
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
110 if (output + p2 * (c->bpp / 8) > output_end) {
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
111 src += p2 * (c->bpp / 8);
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
112 continue;
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
113 }
3121
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
114 if ((c->bpp == 8) || (c->bpp == 24)) {
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
115 for(i = 0; i < p2 * (c->bpp / 8); i++) {
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
116 *output++ = *src++;
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
117 }
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
118 // RLE8 copy is actually padded - and runs are not!
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
119 if(c->bpp == 8 && (p2 & 1)) {
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
120 src++;
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
121 }
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
122 } else if (c->bpp == 16) {
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
123 for(i = 0; i < p2; i++) {
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
124 pix16 = LE_16(src);
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
125 src += 2;
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
126 *(uint16_t*)output = pix16;
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
127 output += 2;
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
128 }
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
129 } else if (c->bpp == 32) {
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
130 for(i = 0; i < p2; i++) {
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
131 pix32 = LE_32(src);
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
132 src += 4;
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
133 *(uint32_t*)output = pix32;
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
134 output += 4;
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
135 }
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
136 }
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
137 pos += p2;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
138 } else { //Run of pixels
2481
0803adcb3ec3 Add 32bit RGB support
rtognimp
parents: 2455
diff changeset
139 int pix[4]; //original pixel
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
140 switch(c->bpp){
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
141 case 8: pix[0] = *src++;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
142 break;
3121
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
143 case 16: pix16 = LE_16(src);
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
144 src += 2;
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
145 *(uint16_t*)pix = pix16;
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
146 break;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
147 case 24: pix[0] = *src++;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
148 pix[1] = *src++;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
149 pix[2] = *src++;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
150 break;
3121
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
151 case 32: pix32 = LE_32(src);
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
152 src += 4;
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
153 *(uint32_t*)pix = pix32;
2481
0803adcb3ec3 Add 32bit RGB support
rtognimp
parents: 2455
diff changeset
154 break;
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
155 }
2455
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
156 if (output + p1 * (c->bpp / 8) > output_end)
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
157 continue;
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
158 for(i = 0; i < p1; i++) {
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
159 switch(c->bpp){
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
160 case 8: *output++ = pix[0];
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
161 break;
3121
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
162 case 16: *(uint16_t*)output = pix16;
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
163 output += 2;
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
164 break;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
165 case 24: *output++ = pix[0];
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
166 *output++ = pix[1];
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
167 *output++ = pix[2];
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
168 break;
3121
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
169 case 32: *(uint32_t*)output = pix32;
99cbff5f8038 make TSCC endian-safe, PPC testing courtesy of Diego B.
melanson
parents: 3036
diff changeset
170 output += 4;
2481
0803adcb3ec3 Add 32bit RGB support
rtognimp
parents: 2455
diff changeset
171 break;
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
172 }
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
173 }
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
174 pos += p1;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
175 }
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
176 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2510
diff changeset
177
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2510
diff changeset
178 av_log(c->avctx, AV_LOG_ERROR, "Camtasia warning: no End-of-picture code\n");
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
179 return 1;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
180 }
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
181
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
182 /*
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
183 *
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
184 * Decode a frame
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
185 *
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
186 */
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
187 static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size)
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
188 {
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
189 CamtasiaContext * const c = (CamtasiaContext *)avctx->priv_data;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
190 unsigned char *encoded = (unsigned char *)buf;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
191 unsigned char *outptr;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
192 #ifdef CONFIG_ZLIB
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
193 int zret; // Zlib return code
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
194 #endif
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
195 int len = buf_size;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
196
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
197 if(c->pic.data[0])
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
198 avctx->release_buffer(avctx, &c->pic);
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
199
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
200 c->pic.reference = 1;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
201 c->pic.buffer_hints = FF_BUFFER_HINTS_VALID;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
202 if(avctx->get_buffer(avctx, &c->pic) < 0){
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
203 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
204 return -1;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
205 }
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
206
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
207 outptr = c->pic.data[0]; // Output image pointer
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
208
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
209 #ifdef CONFIG_ZLIB
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
210 zret = inflateReset(&(c->zstream));
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
211 if (zret != Z_OK) {
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
212 av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
213 return -1;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
214 }
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
215 c->zstream.next_in = encoded;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
216 c->zstream.avail_in = len;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
217 c->zstream.next_out = c->decomp_buf;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
218 c->zstream.avail_out = c->decomp_size;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
219 zret = inflate(&(c->zstream), Z_FINISH);
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
220 // Z_DATA_ERROR means empty picture
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
221 if ((zret != Z_OK) && (zret != Z_STREAM_END) && (zret != Z_DATA_ERROR)) {
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
222 av_log(avctx, AV_LOG_ERROR, "Inflate error: %d\n", zret);
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
223 return -1;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
224 }
2455
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
225
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
226
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
227 if(zret != Z_DATA_ERROR)
2455
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
228 decode_rle(c, c->zstream.avail_out);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2510
diff changeset
229
2196
3eae46c131a3 8-bit mode corrections
melanson
parents: 2170
diff changeset
230 /* make the palette available on the way out */
3eae46c131a3 8-bit mode corrections
melanson
parents: 2170
diff changeset
231 if (c->avctx->pix_fmt == PIX_FMT_PAL8) {
3eae46c131a3 8-bit mode corrections
melanson
parents: 2170
diff changeset
232 memcpy(c->pic.data[1], c->avctx->palctrl->palette, AVPALETTE_SIZE);
3eae46c131a3 8-bit mode corrections
melanson
parents: 2170
diff changeset
233 if (c->avctx->palctrl->palette_changed) {
3eae46c131a3 8-bit mode corrections
melanson
parents: 2170
diff changeset
234 c->pic.palette_has_changed = 1;
3eae46c131a3 8-bit mode corrections
melanson
parents: 2170
diff changeset
235 c->avctx->palctrl->palette_changed = 0;
3eae46c131a3 8-bit mode corrections
melanson
parents: 2170
diff changeset
236 }
3eae46c131a3 8-bit mode corrections
melanson
parents: 2170
diff changeset
237 }
3eae46c131a3 8-bit mode corrections
melanson
parents: 2170
diff changeset
238
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
239 #else
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
240 av_log(avctx, AV_LOG_ERROR, "BUG! Zlib support not compiled in frame decoder.\n");
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
241 return -1;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
242 #endif
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
243
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
244 *data_size = sizeof(AVFrame);
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
245 *(AVFrame*)data = c->pic;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
246
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
247 /* always report that the buffer was completely consumed */
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
248 return buf_size;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
249 }
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
250
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
251
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
252
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
253 /*
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
254 *
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
255 * Init tscc decoder
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
256 *
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
257 */
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
258 static int decode_init(AVCodecContext *avctx)
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
259 {
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
260 CamtasiaContext * const c = (CamtasiaContext *)avctx->priv_data;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
261 int zret; // Zlib return code
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
262
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
263 c->avctx = avctx;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
264 avctx->has_b_frames = 0;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
265
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
266 c->pic.data[0] = NULL;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
267 c->height = avctx->height;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
268
3800
9b75ab171fa9 1l: correct argument order in avcodec_check_dimensions
kostya
parents: 3121
diff changeset
269 if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
2455
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
270 return 1;
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
271 }
d74d342cabb9 Check pointers before writing to memory
rtognimp
parents: 2453
diff changeset
272
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
273 #ifdef CONFIG_ZLIB
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
274 // Needed if zlib unused or init aborted before inflateInit
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2510
diff changeset
275 memset(&(c->zstream), 0, sizeof(z_stream));
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
276 #else
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
277 av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled.\n");
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
278 return 1;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
279 #endif
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
280 switch(avctx->bits_per_sample){
2196
3eae46c131a3 8-bit mode corrections
melanson
parents: 2170
diff changeset
281 case 8: avctx->pix_fmt = PIX_FMT_PAL8; break;
3eae46c131a3 8-bit mode corrections
melanson
parents: 2170
diff changeset
282 case 16: avctx->pix_fmt = PIX_FMT_RGB555; break;
2481
0803adcb3ec3 Add 32bit RGB support
rtognimp
parents: 2455
diff changeset
283 case 24:
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
284 avctx->pix_fmt = PIX_FMT_BGR24;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
285 break;
2481
0803adcb3ec3 Add 32bit RGB support
rtognimp
parents: 2455
diff changeset
286 case 32: avctx->pix_fmt = PIX_FMT_RGBA32; break;
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
287 default: av_log(avctx, AV_LOG_ERROR, "Camtasia error: unknown depth %i bpp\n", avctx->bits_per_sample);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2510
diff changeset
288 return -1;
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
289 }
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
290 c->bpp = avctx->bits_per_sample;
2196
3eae46c131a3 8-bit mode corrections
melanson
parents: 2170
diff changeset
291 c->decomp_size = (avctx->width * c->bpp + (avctx->width + 254) / 255 + 2) * avctx->height + 2;//RLE in the 'best' case
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
292
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
293 /* Allocate decompression buffer */
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
294 if (c->decomp_size) {
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
295 if ((c->decomp_buf = av_malloc(c->decomp_size)) == NULL) {
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
296 av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
297 return 1;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
298 }
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
299 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2510
diff changeset
300
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
301 #ifdef CONFIG_ZLIB
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
302 c->zstream.zalloc = Z_NULL;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
303 c->zstream.zfree = Z_NULL;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
304 c->zstream.opaque = Z_NULL;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
305 zret = inflateInit(&(c->zstream));
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
306 if (zret != Z_OK) {
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
307 av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
308 return 1;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
309 }
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
310 #endif
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
311
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
312 return 0;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
313 }
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
314
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
315
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
316
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
317 /*
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
318 *
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
319 * Uninit tscc decoder
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
320 *
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
321 */
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
322 static int decode_end(AVCodecContext *avctx)
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
323 {
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
324 CamtasiaContext * const c = (CamtasiaContext *)avctx->priv_data;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
325
2510
5e9f8eef19b9 memleak fix
michael
parents: 2481
diff changeset
326 av_freep(&c->decomp_buf);
5e9f8eef19b9 memleak fix
michael
parents: 2481
diff changeset
327
2170
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
328 if (c->pic.data[0])
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
329 avctx->release_buffer(avctx, &c->pic);
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
330 #ifdef CONFIG_ZLIB
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
331 inflateEnd(&(c->zstream));
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
332 #endif
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
333
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
334 return 0;
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
335 }
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
336
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
337 AVCodec tscc_decoder = {
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
338 "camtasia",
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
339 CODEC_TYPE_VIDEO,
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
340 CODEC_ID_TSCC,
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
341 sizeof(CamtasiaContext),
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
342 decode_init,
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
343 NULL,
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
344 decode_end,
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
345 decode_frame,
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
346 CODEC_CAP_DR1,
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
347 };
51da590b31a3 TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
348