Mercurial > libavcodec.hg
annotate tscc.c @ 8228:416ffc3907bf libavcodec
Remove ineffectual hack that attempts to build ppc/check_altivec.o without
AltiVec flags. The flags are set by configure and used to compile all files
anyway. Setting extra AltiVec options here just duplicates them for the files
for which they are set.
author | diego |
---|---|
date | Sun, 30 Nov 2008 16:57:28 +0000 |
parents | bbac1857dd86 |
children | e9d9d946f213 |
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 * @file tscc.c |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
24 * TechSmith Camtasia decoder |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
25 * |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
26 * Fourcc: TSCC |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
27 * |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
28 * Codec is very simple: |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
29 * it codes picture (picture difference, really) |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
30 * with algorithm almost identical to Windows RLE8, |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
31 * only without padding and with greater pixel sizes, |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
32 * then this coded picture is packed with ZLib |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
33 * |
2196 | 34 * Supports: BGR8,BGR555,BGR24 - only BGR8 and BGR555 tested |
2170
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
35 * |
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 #include <stdio.h> |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
39 #include <stdlib.h> |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
40 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
41 #include "avcodec.h" |
7885
f874e1d5cf07
Factorize out code used for MS RLE format decoding in different decoders.
kostya
parents:
7823
diff
changeset
|
42 #include "msrledec.h" |
2170
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
43 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
44 #include <zlib.h> |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
45 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
46 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
47 /* |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
48 * Decoder context |
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 typedef struct TsccContext { |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
51 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
52 AVCodecContext *avctx; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
53 AVFrame pic; |
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 // Bits per pixel |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
56 int bpp; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
57 // Decompressed data size |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
58 unsigned int decomp_size; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
59 // Decompression buffer |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
60 unsigned char* decomp_buf; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
61 int height; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
62 z_stream zstream; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
63 } CamtasiaContext; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
64 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
65 /* |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
66 * |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
67 * Decode a frame |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
68 * |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
69 */ |
6286 | 70 static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) |
2170
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
71 { |
4827 | 72 CamtasiaContext * const c = avctx->priv_data; |
6286 | 73 const unsigned char *encoded = buf; |
2170
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
74 unsigned char *outptr; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
75 int zret; // Zlib return code |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
76 int len = buf_size; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
77 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
78 if(c->pic.data[0]) |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
79 avctx->release_buffer(avctx, &c->pic); |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
80 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
81 c->pic.reference = 1; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
82 c->pic.buffer_hints = FF_BUFFER_HINTS_VALID; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
83 if(avctx->get_buffer(avctx, &c->pic) < 0){ |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
84 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
85 return -1; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
86 } |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
87 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
88 outptr = c->pic.data[0]; // Output image pointer |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
89 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
90 zret = inflateReset(&(c->zstream)); |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
91 if (zret != Z_OK) { |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
92 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
|
93 return -1; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
94 } |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
95 c->zstream.next_in = encoded; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
96 c->zstream.avail_in = len; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
97 c->zstream.next_out = c->decomp_buf; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
98 c->zstream.avail_out = c->decomp_size; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
99 zret = inflate(&(c->zstream), Z_FINISH); |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
100 // Z_DATA_ERROR means empty picture |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
101 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
|
102 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
|
103 return -1; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
104 } |
2455 | 105 |
106 | |
2170
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
107 if(zret != Z_DATA_ERROR) |
7885
f874e1d5cf07
Factorize out code used for MS RLE format decoding in different decoders.
kostya
parents:
7823
diff
changeset
|
108 ff_msrle_decode(avctx, &c->pic, c->bpp, c->decomp_buf, c->zstream.avail_out); |
2967 | 109 |
2196 | 110 /* make the palette available on the way out */ |
111 if (c->avctx->pix_fmt == PIX_FMT_PAL8) { | |
112 memcpy(c->pic.data[1], c->avctx->palctrl->palette, AVPALETTE_SIZE); | |
113 if (c->avctx->palctrl->palette_changed) { | |
114 c->pic.palette_has_changed = 1; | |
115 c->avctx->palctrl->palette_changed = 0; | |
116 } | |
117 } | |
118 | |
2170
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
119 *data_size = sizeof(AVFrame); |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
120 *(AVFrame*)data = c->pic; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
121 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
122 /* always report that the buffer was completely consumed */ |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
123 return buf_size; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
124 } |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
125 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
126 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
127 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
128 /* |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
129 * |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
130 * Init tscc decoder |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
131 * |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
132 */ |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6286
diff
changeset
|
133 static av_cold int decode_init(AVCodecContext *avctx) |
2170
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
134 { |
4827 | 135 CamtasiaContext * const c = avctx->priv_data; |
2170
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
136 int zret; // Zlib return code |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
137 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
138 c->avctx = avctx; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
139 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
140 c->pic.data[0] = NULL; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
141 c->height = avctx->height; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
142 |
3800
9b75ab171fa9
1l: correct argument order in avcodec_check_dimensions
kostya
parents:
3121
diff
changeset
|
143 if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) { |
2455 | 144 return 1; |
145 } | |
146 | |
2170
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
147 // Needed if zlib unused or init aborted before inflateInit |
2967 | 148 memset(&(c->zstream), 0, sizeof(z_stream)); |
7823
4525dcd81357
Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents:
7040
diff
changeset
|
149 switch(avctx->bits_per_coded_sample){ |
2196 | 150 case 8: avctx->pix_fmt = PIX_FMT_PAL8; break; |
151 case 16: avctx->pix_fmt = PIX_FMT_RGB555; break; | |
2481 | 152 case 24: |
2170
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
153 avctx->pix_fmt = PIX_FMT_BGR24; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
154 break; |
4494
ce643a22f049
Replace deprecated PIX_FMT names by the newer variants.
diego
parents:
4364
diff
changeset
|
155 case 32: avctx->pix_fmt = PIX_FMT_RGB32; break; |
7823
4525dcd81357
Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents:
7040
diff
changeset
|
156 default: av_log(avctx, AV_LOG_ERROR, "Camtasia error: unknown depth %i bpp\n", avctx->bits_per_coded_sample); |
2967 | 157 return -1; |
2170
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
158 } |
7823
4525dcd81357
Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents:
7040
diff
changeset
|
159 c->bpp = avctx->bits_per_coded_sample; |
2196 | 160 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
|
161 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
162 /* Allocate decompression buffer */ |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
163 if (c->decomp_size) { |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
164 if ((c->decomp_buf = av_malloc(c->decomp_size)) == NULL) { |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
165 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
|
166 return 1; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
167 } |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
168 } |
2967 | 169 |
2170
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
170 c->zstream.zalloc = Z_NULL; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
171 c->zstream.zfree = Z_NULL; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
172 c->zstream.opaque = Z_NULL; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
173 zret = inflateInit(&(c->zstream)); |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
174 if (zret != Z_OK) { |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
175 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
|
176 return 1; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
177 } |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
178 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
179 return 0; |
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 /* |
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 * Uninit tscc decoder |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
187 * |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
188 */ |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6286
diff
changeset
|
189 static av_cold int decode_end(AVCodecContext *avctx) |
2170
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
190 { |
4827 | 191 CamtasiaContext * const c = avctx->priv_data; |
2170
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
192 |
2510 | 193 av_freep(&c->decomp_buf); |
194 | |
2170
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
195 if (c->pic.data[0]) |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
196 avctx->release_buffer(avctx, &c->pic); |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
197 inflateEnd(&(c->zstream)); |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
198 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
199 return 0; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
200 } |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
201 |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
202 AVCodec tscc_decoder = { |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
203 "camtasia", |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
204 CODEC_TYPE_VIDEO, |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
205 CODEC_ID_TSCC, |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
206 sizeof(CamtasiaContext), |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
207 decode_init, |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
208 NULL, |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
209 decode_end, |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
210 decode_frame, |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
211 CODEC_CAP_DR1, |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6710
diff
changeset
|
212 .long_name = NULL_IF_CONFIG_SMALL("TechSmith Screen Capture Codec"), |
2170
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
213 }; |
51da590b31a3
TechSmith Camtasia (TSCC) video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
214 |