annotate lcldec.c @ 9642:d706b300b89f libavcodec

Document av_set_string3() returned error codes.
author stefano
date Thu, 14 May 2009 19:03:22 +0000
parents 0dce4fe6e6f3
children d6a35d7be925
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
1 /*
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
2 * LCL (LossLess Codec Library) Codec
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
3 * Copyright (c) 2002-2004 Roberto Togni
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
4 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3777
diff changeset
5 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3777
diff changeset
6 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3777
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
fa06a4a448f7 Fix for older version of zlib
rtognimp
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: 3777
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3777
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
15 * Lesser General Public License for more details.
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
16 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
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: 3777
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
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
20 */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
21
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
22 /**
8718
e9d9d946f213 Use full internal pathname in doxygen @file directives.
diego
parents: 8673
diff changeset
23 * @file libavcodec/lcldec.c
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
24 * LCL (LossLess Codec Library) Video Codec
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
25 * Decoder for MSZH and ZLIB codecs
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
26 * Experimental encoder for ZLIB RGB24
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
27 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
28 * Fourcc: MSZH, ZLIB
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
29 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
30 * Original Win32 dll:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
31 * Ver2.23 By Kenji Oshima 2000.09.20
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
32 * avimszh.dll, avizlib.dll
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
33 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
34 * A description of the decoding algorithm can be found here:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
35 * http://www.pcisys.net/~melanson/codecs
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
36 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
37 * Supports: BGR24 (RGB 24bpp)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
38 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
39 */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
40
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
41 #include <stdio.h>
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
42 #include <stdlib.h>
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
43
4962
f99e40a7155b Remove redundant #inclusion of common.h, avcodec.h already #includes it.
diego
parents: 4827
diff changeset
44 #include "avcodec.h"
9428
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents: 9355
diff changeset
45 #include "get_bits.h"
5294
e21873a1c00b split lcl.c into lcldec.c, lclenc.c, lcl.h
mru
parents: 5215
diff changeset
46 #include "lcl.h"
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
47
8590
7a463923ecd1 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 7040
diff changeset
48 #if CONFIG_ZLIB
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
49 #include <zlib.h>
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
50 #endif
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
51
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
52 /*
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
53 * Decoder context
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
54 */
5294
e21873a1c00b split lcl.c into lcldec.c, lclenc.c, lcl.h
mru
parents: 5215
diff changeset
55 typedef struct LclDecContext {
5297
mru
parents: 5296
diff changeset
56 AVFrame pic;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
57
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
58 // Image type
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
59 int imgtype;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
60 // Compression type
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
61 int compression;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
62 // Flags
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
63 int flags;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
64 // Decompressed data size
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
65 unsigned int decomp_size;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
66 // Decompression buffer
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
67 unsigned char* decomp_buf;
8590
7a463923ecd1 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 7040
diff changeset
68 #if CONFIG_ZLIB
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
69 z_stream zstream;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
70 #endif
5294
e21873a1c00b split lcl.c into lcldec.c, lclenc.c, lcl.h
mru
parents: 5215
diff changeset
71 } LclDecContext;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
72
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
73
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
74 /*
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
75 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
76 * Helper functions
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
77 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
78 */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
79 static inline unsigned char fix (int pix14)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
80 {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
81 int tmp;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
82
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
83 tmp = (pix14 + 0x80000) >> 20;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
84 if (tmp < 0)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
85 return 0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
86 if (tmp > 255)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
87 return 255;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
88 return tmp;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
89 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
90
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
91
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
92
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
93 static inline unsigned char get_b (unsigned char yq, signed char bq)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
94 {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
95 return fix((yq << 20) + bq * 1858076);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
96 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
97
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
98
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
99
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
100 static inline unsigned char get_g (unsigned char yq, signed char bq, signed char rq)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
101 {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
102 return fix((yq << 20) - bq * 360857 - rq * 748830);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
103 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
104
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
105
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
106
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
107 static inline unsigned char get_r (unsigned char yq, signed char rq)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
108 {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
109 return fix((yq << 20) + rq * 1470103);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
110 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
111
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
112
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
113
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
114 static unsigned int mszh_decomp(unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize)
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
115 {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
116 unsigned char *destptr_bak = destptr;
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
117 unsigned char *destptr_end = destptr + destsize;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
118 unsigned char mask = 0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
119 unsigned char maskbit = 0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
120 unsigned int ofs, cnt;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
121
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
122 while ((srclen > 0) && (destptr < destptr_end)) {
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
123 if (maskbit == 0) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
124 mask = *(srcptr++);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
125 maskbit = 8;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
126 srclen--;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
127 continue;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
128 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
129 if ((mask & (1 << (--maskbit))) == 0) {
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
130 if (destptr + 4 > destptr_end)
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
131 break;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
132 *(int*)destptr = *(int*)srcptr;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
133 srclen -= 4;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
134 destptr += 4;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
135 srcptr += 4;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
136 } else {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
137 ofs = *(srcptr++);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
138 cnt = *(srcptr++);
6375
551232d0fa74 Remove duplicate ;
reimar
parents: 6218
diff changeset
139 ofs += cnt * 256;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
140 cnt = ((cnt >> 3) & 0x1f) + 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
141 ofs &= 0x7ff;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
142 srclen -= 2;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
143 cnt *= 4;
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
144 if (destptr + cnt > destptr_end) {
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
145 cnt = destptr_end - destptr;
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
146 }
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
147 for (; cnt > 0; cnt--) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
148 *(destptr) = *(destptr - ofs);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
149 destptr++;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
150 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
151 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
152 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
153
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
154 return (destptr - destptr_bak);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
155 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
156
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
157
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
158
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
159 /*
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
160 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
161 * Decode a frame
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
162 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
163 */
9355
54bc8a2727b0 Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents: 8718
diff changeset
164 static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
165 {
9355
54bc8a2727b0 Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents: 8718
diff changeset
166 const uint8_t *buf = avpkt->data;
54bc8a2727b0 Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents: 8718
diff changeset
167 int buf_size = avpkt->size;
5297
mru
parents: 5296
diff changeset
168 LclDecContext * const c = avctx->priv_data;
mru
parents: 5296
diff changeset
169 unsigned char *encoded = (unsigned char *)buf;
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
170 unsigned int pixel_ptr;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
171 int row, col;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
172 unsigned char *outptr;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
173 unsigned int width = avctx->width; // Real image width
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
174 unsigned int height = avctx->height; // Real image height
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
175 unsigned int mszh_dlen;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
176 unsigned char yq, y1q, uq, vq;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
177 int uqvq;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
178 unsigned int mthread_inlen, mthread_outlen;
8590
7a463923ecd1 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 7040
diff changeset
179 #if CONFIG_ZLIB
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
180 int zret; // Zlib return code
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
181 #endif
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
182 unsigned int len = buf_size;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
183
5297
mru
parents: 5296
diff changeset
184 if(c->pic.data[0])
mru
parents: 5296
diff changeset
185 avctx->release_buffer(avctx, &c->pic);
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
186
5297
mru
parents: 5296
diff changeset
187 c->pic.reference = 0;
mru
parents: 5296
diff changeset
188 c->pic.buffer_hints = FF_BUFFER_HINTS_VALID;
mru
parents: 5296
diff changeset
189 if(avctx->get_buffer(avctx, &c->pic) < 0){
mru
parents: 5296
diff changeset
190 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
mru
parents: 5296
diff changeset
191 return -1;
mru
parents: 5296
diff changeset
192 }
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
193
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
194 outptr = c->pic.data[0]; // Output image pointer
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
195
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
196 /* Decompress frame */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
197 switch (avctx->codec_id) {
5297
mru
parents: 5296
diff changeset
198 case CODEC_ID_MSZH:
mru
parents: 5296
diff changeset
199 switch (c->compression) {
mru
parents: 5296
diff changeset
200 case COMP_MSZH:
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
201 if (c->flags & FLAG_MULTITHREAD) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
202 mthread_inlen = *((unsigned int*)encoded);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
203 mthread_outlen = *((unsigned int*)(encoded+4));
5297
mru
parents: 5296
diff changeset
204 if (mthread_outlen > c->decomp_size) // this should not happen
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
205 mthread_outlen = c->decomp_size;
5297
mru
parents: 5296
diff changeset
206 mszh_dlen = mszh_decomp(encoded + 8, mthread_inlen, c->decomp_buf, c->decomp_size);
mru
parents: 5296
diff changeset
207 if (mthread_outlen != mszh_dlen) {
mru
parents: 5296
diff changeset
208 av_log(avctx, AV_LOG_ERROR, "Mthread1 decoded size differs (%d != %d)\n",
mru
parents: 5296
diff changeset
209 mthread_outlen, mszh_dlen);
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
210 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
211 }
5297
mru
parents: 5296
diff changeset
212 mszh_dlen = mszh_decomp(encoded + 8 + mthread_inlen, len - mthread_inlen,
mru
parents: 5296
diff changeset
213 c->decomp_buf + mthread_outlen, c->decomp_size - mthread_outlen);
mru
parents: 5296
diff changeset
214 if (mthread_outlen != mszh_dlen) {
mru
parents: 5296
diff changeset
215 av_log(avctx, AV_LOG_ERROR, "Mthread2 decoded size differs (%d != %d)\n",
mru
parents: 5296
diff changeset
216 mthread_outlen, mszh_dlen);
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
217 return -1;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
218 }
5297
mru
parents: 5296
diff changeset
219 encoded = c->decomp_buf;
mru
parents: 5296
diff changeset
220 len = c->decomp_size;
mru
parents: 5296
diff changeset
221 } else {
mru
parents: 5296
diff changeset
222 mszh_dlen = mszh_decomp(encoded, len, c->decomp_buf, c->decomp_size);
mru
parents: 5296
diff changeset
223 if (c->decomp_size != mszh_dlen) {
mru
parents: 5296
diff changeset
224 av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %d)\n",
mru
parents: 5296
diff changeset
225 c->decomp_size, mszh_dlen);
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
226 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
227 }
5297
mru
parents: 5296
diff changeset
228 encoded = c->decomp_buf;
mru
parents: 5296
diff changeset
229 len = mszh_dlen;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
230 }
5297
mru
parents: 5296
diff changeset
231 break;
mru
parents: 5296
diff changeset
232 case COMP_MSZH_NOCOMP:
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
233 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
234 default:
5297
mru
parents: 5296
diff changeset
235 av_log(avctx, AV_LOG_ERROR, "BUG! Unknown MSZH compression in frame decoder.\n");
mru
parents: 5296
diff changeset
236 return -1;
mru
parents: 5296
diff changeset
237 }
mru
parents: 5296
diff changeset
238 break;
mru
parents: 5296
diff changeset
239 case CODEC_ID_ZLIB:
8590
7a463923ecd1 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 7040
diff changeset
240 #if CONFIG_ZLIB
5297
mru
parents: 5296
diff changeset
241 /* Using the original dll with normal compression (-1) and RGB format
mru
parents: 5296
diff changeset
242 * gives a file with ZLIB fourcc, but frame is really uncompressed.
mru
parents: 5296
diff changeset
243 * To be sure that's true check also frame size */
mru
parents: 5296
diff changeset
244 if ((c->compression == COMP_ZLIB_NORMAL) && (c->imgtype == IMGTYPE_RGB24) &&
mru
parents: 5296
diff changeset
245 (len == width * height * 3))
mru
parents: 5296
diff changeset
246 break;
mru
parents: 5296
diff changeset
247 zret = inflateReset(&(c->zstream));
mru
parents: 5296
diff changeset
248 if (zret != Z_OK) {
mru
parents: 5296
diff changeset
249 av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
250 return -1;
5297
mru
parents: 5296
diff changeset
251 }
mru
parents: 5296
diff changeset
252 if (c->flags & FLAG_MULTITHREAD) {
mru
parents: 5296
diff changeset
253 mthread_inlen = *((unsigned int*)encoded);
mru
parents: 5296
diff changeset
254 mthread_outlen = *((unsigned int*)(encoded+4));
mru
parents: 5296
diff changeset
255 if (mthread_outlen > c->decomp_size)
mru
parents: 5296
diff changeset
256 mthread_outlen = c->decomp_size;
mru
parents: 5296
diff changeset
257 c->zstream.next_in = encoded + 8;
mru
parents: 5296
diff changeset
258 c->zstream.avail_in = mthread_inlen;
mru
parents: 5296
diff changeset
259 c->zstream.next_out = c->decomp_buf;
mru
parents: 5296
diff changeset
260 c->zstream.avail_out = c->decomp_size;
mru
parents: 5296
diff changeset
261 zret = inflate(&(c->zstream), Z_FINISH);
mru
parents: 5296
diff changeset
262 if ((zret != Z_OK) && (zret != Z_STREAM_END)) {
mru
parents: 5296
diff changeset
263 av_log(avctx, AV_LOG_ERROR, "Mthread1 inflate error: %d\n", zret);
mru
parents: 5296
diff changeset
264 return -1;
mru
parents: 5296
diff changeset
265 }
mru
parents: 5296
diff changeset
266 if (mthread_outlen != (unsigned int)(c->zstream.total_out)) {
mru
parents: 5296
diff changeset
267 av_log(avctx, AV_LOG_ERROR, "Mthread1 decoded size differs (%u != %lu)\n",
mru
parents: 5296
diff changeset
268 mthread_outlen, c->zstream.total_out);
mru
parents: 5296
diff changeset
269 return -1;
mru
parents: 5296
diff changeset
270 }
mru
parents: 5296
diff changeset
271 zret = inflateReset(&(c->zstream));
mru
parents: 5296
diff changeset
272 if (zret != Z_OK) {
mru
parents: 5296
diff changeset
273 av_log(avctx, AV_LOG_ERROR, "Mthread2 inflate reset error: %d\n", zret);
mru
parents: 5296
diff changeset
274 return -1;
mru
parents: 5296
diff changeset
275 }
mru
parents: 5296
diff changeset
276 c->zstream.next_in = encoded + 8 + mthread_inlen;
mru
parents: 5296
diff changeset
277 c->zstream.avail_in = len - mthread_inlen;
mru
parents: 5296
diff changeset
278 c->zstream.next_out = c->decomp_buf + mthread_outlen;
mru
parents: 5296
diff changeset
279 c->zstream.avail_out = c->decomp_size - mthread_outlen;
mru
parents: 5296
diff changeset
280 zret = inflate(&(c->zstream), Z_FINISH);
mru
parents: 5296
diff changeset
281 if ((zret != Z_OK) && (zret != Z_STREAM_END)) {
mru
parents: 5296
diff changeset
282 av_log(avctx, AV_LOG_ERROR, "Mthread2 inflate error: %d\n", zret);
mru
parents: 5296
diff changeset
283 return -1;
mru
parents: 5296
diff changeset
284 }
mru
parents: 5296
diff changeset
285 if (mthread_outlen != (unsigned int)(c->zstream.total_out)) {
mru
parents: 5296
diff changeset
286 av_log(avctx, AV_LOG_ERROR, "Mthread2 decoded size differs (%d != %lu)\n",
mru
parents: 5296
diff changeset
287 mthread_outlen, c->zstream.total_out);
mru
parents: 5296
diff changeset
288 return -1;
mru
parents: 5296
diff changeset
289 }
mru
parents: 5296
diff changeset
290 } else {
mru
parents: 5296
diff changeset
291 c->zstream.next_in = encoded;
mru
parents: 5296
diff changeset
292 c->zstream.avail_in = len;
mru
parents: 5296
diff changeset
293 c->zstream.next_out = c->decomp_buf;
mru
parents: 5296
diff changeset
294 c->zstream.avail_out = c->decomp_size;
mru
parents: 5296
diff changeset
295 zret = inflate(&(c->zstream), Z_FINISH);
mru
parents: 5296
diff changeset
296 if ((zret != Z_OK) && (zret != Z_STREAM_END)) {
mru
parents: 5296
diff changeset
297 av_log(avctx, AV_LOG_ERROR, "Inflate error: %d\n", zret);
mru
parents: 5296
diff changeset
298 return -1;
mru
parents: 5296
diff changeset
299 }
mru
parents: 5296
diff changeset
300 if (c->decomp_size != (unsigned int)(c->zstream.total_out)) {
mru
parents: 5296
diff changeset
301 av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %lu)\n",
mru
parents: 5296
diff changeset
302 c->decomp_size, c->zstream.total_out);
mru
parents: 5296
diff changeset
303 return -1;
mru
parents: 5296
diff changeset
304 }
mru
parents: 5296
diff changeset
305 }
mru
parents: 5296
diff changeset
306 encoded = c->decomp_buf;
6375
551232d0fa74 Remove duplicate ;
reimar
parents: 6218
diff changeset
307 len = c->decomp_size;
5297
mru
parents: 5296
diff changeset
308 #else
mru
parents: 5296
diff changeset
309 av_log(avctx, AV_LOG_ERROR, "BUG! Zlib support not compiled in frame decoder.\n");
mru
parents: 5296
diff changeset
310 return -1;
mru
parents: 5296
diff changeset
311 #endif
mru
parents: 5296
diff changeset
312 break;
mru
parents: 5296
diff changeset
313 default:
mru
parents: 5296
diff changeset
314 av_log(avctx, AV_LOG_ERROR, "BUG! Unknown codec in frame decoder compression switch.\n");
mru
parents: 5296
diff changeset
315 return -1;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
316 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
317
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
318
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
319 /* Apply PNG filter */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
320 if ((avctx->codec_id == CODEC_ID_ZLIB) && (c->flags & FLAG_PNGFILTER)) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
321 switch (c->imgtype) {
5297
mru
parents: 5296
diff changeset
322 case IMGTYPE_YUV111:
mru
parents: 5296
diff changeset
323 case IMGTYPE_RGB24:
mru
parents: 5296
diff changeset
324 for (row = 0; row < height; row++) {
mru
parents: 5296
diff changeset
325 pixel_ptr = row * width * 3;
mru
parents: 5296
diff changeset
326 yq = encoded[pixel_ptr++];
mru
parents: 5296
diff changeset
327 uqvq = AV_RL16(encoded+pixel_ptr);
mru
parents: 5296
diff changeset
328 pixel_ptr += 2;
mru
parents: 5296
diff changeset
329 for (col = 1; col < width; col++) {
mru
parents: 5296
diff changeset
330 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
mru
parents: 5296
diff changeset
331 uqvq -= AV_RL16(encoded+pixel_ptr+1);
mru
parents: 5296
diff changeset
332 AV_WL16(encoded+pixel_ptr+1, uqvq);
mru
parents: 5296
diff changeset
333 pixel_ptr += 3;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
334 }
5297
mru
parents: 5296
diff changeset
335 }
mru
parents: 5296
diff changeset
336 break;
mru
parents: 5296
diff changeset
337 case IMGTYPE_YUV422:
mru
parents: 5296
diff changeset
338 for (row = 0; row < height; row++) {
mru
parents: 5296
diff changeset
339 pixel_ptr = row * width * 2;
mru
parents: 5296
diff changeset
340 yq = uq = vq =0;
mru
parents: 5296
diff changeset
341 for (col = 0; col < width/4; col++) {
mru
parents: 5296
diff changeset
342 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
mru
parents: 5296
diff changeset
343 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
mru
parents: 5296
diff changeset
344 encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2];
mru
parents: 5296
diff changeset
345 encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3];
mru
parents: 5296
diff changeset
346 encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
mru
parents: 5296
diff changeset
347 encoded[pixel_ptr+5] = uq -= encoded[pixel_ptr+5];
mru
parents: 5296
diff changeset
348 encoded[pixel_ptr+6] = vq -= encoded[pixel_ptr+6];
mru
parents: 5296
diff changeset
349 encoded[pixel_ptr+7] = vq -= encoded[pixel_ptr+7];
mru
parents: 5296
diff changeset
350 pixel_ptr += 8;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
351 }
5297
mru
parents: 5296
diff changeset
352 }
mru
parents: 5296
diff changeset
353 break;
mru
parents: 5296
diff changeset
354 case IMGTYPE_YUV411:
mru
parents: 5296
diff changeset
355 for (row = 0; row < height; row++) {
mru
parents: 5296
diff changeset
356 pixel_ptr = row * width / 2 * 3;
mru
parents: 5296
diff changeset
357 yq = uq = vq =0;
mru
parents: 5296
diff changeset
358 for (col = 0; col < width/4; col++) {
mru
parents: 5296
diff changeset
359 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
mru
parents: 5296
diff changeset
360 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
mru
parents: 5296
diff changeset
361 encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2];
mru
parents: 5296
diff changeset
362 encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3];
mru
parents: 5296
diff changeset
363 encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
mru
parents: 5296
diff changeset
364 encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5];
mru
parents: 5296
diff changeset
365 pixel_ptr += 6;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
366 }
5297
mru
parents: 5296
diff changeset
367 }
mru
parents: 5296
diff changeset
368 break;
mru
parents: 5296
diff changeset
369 case IMGTYPE_YUV211:
mru
parents: 5296
diff changeset
370 for (row = 0; row < height; row++) {
mru
parents: 5296
diff changeset
371 pixel_ptr = row * width * 2;
mru
parents: 5296
diff changeset
372 yq = uq = vq =0;
mru
parents: 5296
diff changeset
373 for (col = 0; col < width/2; col++) {
mru
parents: 5296
diff changeset
374 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
mru
parents: 5296
diff changeset
375 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
mru
parents: 5296
diff changeset
376 encoded[pixel_ptr+2] = uq -= encoded[pixel_ptr+2];
mru
parents: 5296
diff changeset
377 encoded[pixel_ptr+3] = vq -= encoded[pixel_ptr+3];
mru
parents: 5296
diff changeset
378 pixel_ptr += 4;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
379 }
5297
mru
parents: 5296
diff changeset
380 }
mru
parents: 5296
diff changeset
381 break;
mru
parents: 5296
diff changeset
382 case IMGTYPE_YUV420:
mru
parents: 5296
diff changeset
383 for (row = 0; row < height/2; row++) {
mru
parents: 5296
diff changeset
384 pixel_ptr = row * width * 3;
mru
parents: 5296
diff changeset
385 yq = y1q = uq = vq =0;
mru
parents: 5296
diff changeset
386 for (col = 0; col < width/2; col++) {
mru
parents: 5296
diff changeset
387 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
mru
parents: 5296
diff changeset
388 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
mru
parents: 5296
diff changeset
389 encoded[pixel_ptr+2] = y1q -= encoded[pixel_ptr+2];
mru
parents: 5296
diff changeset
390 encoded[pixel_ptr+3] = y1q -= encoded[pixel_ptr+3];
mru
parents: 5296
diff changeset
391 encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
mru
parents: 5296
diff changeset
392 encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5];
mru
parents: 5296
diff changeset
393 pixel_ptr += 6;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
394 }
5297
mru
parents: 5296
diff changeset
395 }
mru
parents: 5296
diff changeset
396 break;
mru
parents: 5296
diff changeset
397 default:
mru
parents: 5296
diff changeset
398 av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in pngfilter switch.\n");
mru
parents: 5296
diff changeset
399 return -1;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
400 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
401 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
402
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
403 /* Convert colorspace */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
404 switch (c->imgtype) {
5297
mru
parents: 5296
diff changeset
405 case IMGTYPE_YUV111:
mru
parents: 5296
diff changeset
406 for (row = height - 1; row >= 0; row--) {
mru
parents: 5296
diff changeset
407 pixel_ptr = row * c->pic.linesize[0];
mru
parents: 5296
diff changeset
408 for (col = 0; col < width; col++) {
mru
parents: 5296
diff changeset
409 outptr[pixel_ptr++] = get_b(encoded[0], encoded[1]);
mru
parents: 5296
diff changeset
410 outptr[pixel_ptr++] = get_g(encoded[0], encoded[1], encoded[2]);
mru
parents: 5296
diff changeset
411 outptr[pixel_ptr++] = get_r(encoded[0], encoded[2]);
mru
parents: 5296
diff changeset
412 encoded += 3;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
413 }
5297
mru
parents: 5296
diff changeset
414 }
mru
parents: 5296
diff changeset
415 break;
mru
parents: 5296
diff changeset
416 case IMGTYPE_YUV422:
mru
parents: 5296
diff changeset
417 for (row = height - 1; row >= 0; row--) {
mru
parents: 5296
diff changeset
418 pixel_ptr = row * c->pic.linesize[0];
mru
parents: 5296
diff changeset
419 for (col = 0; col < width/4; col++) {
mru
parents: 5296
diff changeset
420 outptr[pixel_ptr++] = get_b(encoded[0], encoded[4]);
mru
parents: 5296
diff changeset
421 outptr[pixel_ptr++] = get_g(encoded[0], encoded[4], encoded[6]);
mru
parents: 5296
diff changeset
422 outptr[pixel_ptr++] = get_r(encoded[0], encoded[6]);
mru
parents: 5296
diff changeset
423 outptr[pixel_ptr++] = get_b(encoded[1], encoded[4]);
mru
parents: 5296
diff changeset
424 outptr[pixel_ptr++] = get_g(encoded[1], encoded[4], encoded[6]);
mru
parents: 5296
diff changeset
425 outptr[pixel_ptr++] = get_r(encoded[1], encoded[6]);
mru
parents: 5296
diff changeset
426 outptr[pixel_ptr++] = get_b(encoded[2], encoded[5]);
mru
parents: 5296
diff changeset
427 outptr[pixel_ptr++] = get_g(encoded[2], encoded[5], encoded[7]);
mru
parents: 5296
diff changeset
428 outptr[pixel_ptr++] = get_r(encoded[2], encoded[7]);
mru
parents: 5296
diff changeset
429 outptr[pixel_ptr++] = get_b(encoded[3], encoded[5]);
mru
parents: 5296
diff changeset
430 outptr[pixel_ptr++] = get_g(encoded[3], encoded[5], encoded[7]);
mru
parents: 5296
diff changeset
431 outptr[pixel_ptr++] = get_r(encoded[3], encoded[7]);
mru
parents: 5296
diff changeset
432 encoded += 8;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
433 }
5297
mru
parents: 5296
diff changeset
434 }
mru
parents: 5296
diff changeset
435 break;
mru
parents: 5296
diff changeset
436 case IMGTYPE_RGB24:
mru
parents: 5296
diff changeset
437 for (row = height - 1; row >= 0; row--) {
mru
parents: 5296
diff changeset
438 pixel_ptr = row * c->pic.linesize[0];
mru
parents: 5296
diff changeset
439 for (col = 0; col < width; col++) {
mru
parents: 5296
diff changeset
440 outptr[pixel_ptr++] = encoded[0];
mru
parents: 5296
diff changeset
441 outptr[pixel_ptr++] = encoded[1];
mru
parents: 5296
diff changeset
442 outptr[pixel_ptr++] = encoded[2];
mru
parents: 5296
diff changeset
443 encoded += 3;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
444 }
5297
mru
parents: 5296
diff changeset
445 }
mru
parents: 5296
diff changeset
446 break;
mru
parents: 5296
diff changeset
447 case IMGTYPE_YUV411:
mru
parents: 5296
diff changeset
448 for (row = height - 1; row >= 0; row--) {
mru
parents: 5296
diff changeset
449 pixel_ptr = row * c->pic.linesize[0];
mru
parents: 5296
diff changeset
450 for (col = 0; col < width/4; col++) {
mru
parents: 5296
diff changeset
451 outptr[pixel_ptr++] = get_b(encoded[0], encoded[4]);
mru
parents: 5296
diff changeset
452 outptr[pixel_ptr++] = get_g(encoded[0], encoded[4], encoded[5]);
mru
parents: 5296
diff changeset
453 outptr[pixel_ptr++] = get_r(encoded[0], encoded[5]);
mru
parents: 5296
diff changeset
454 outptr[pixel_ptr++] = get_b(encoded[1], encoded[4]);
mru
parents: 5296
diff changeset
455 outptr[pixel_ptr++] = get_g(encoded[1], encoded[4], encoded[5]);
mru
parents: 5296
diff changeset
456 outptr[pixel_ptr++] = get_r(encoded[1], encoded[5]);
mru
parents: 5296
diff changeset
457 outptr[pixel_ptr++] = get_b(encoded[2], encoded[4]);
mru
parents: 5296
diff changeset
458 outptr[pixel_ptr++] = get_g(encoded[2], encoded[4], encoded[5]);
mru
parents: 5296
diff changeset
459 outptr[pixel_ptr++] = get_r(encoded[2], encoded[5]);
mru
parents: 5296
diff changeset
460 outptr[pixel_ptr++] = get_b(encoded[3], encoded[4]);
mru
parents: 5296
diff changeset
461 outptr[pixel_ptr++] = get_g(encoded[3], encoded[4], encoded[5]);
mru
parents: 5296
diff changeset
462 outptr[pixel_ptr++] = get_r(encoded[3], encoded[5]);
mru
parents: 5296
diff changeset
463 encoded += 6;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
464 }
5297
mru
parents: 5296
diff changeset
465 }
mru
parents: 5296
diff changeset
466 break;
mru
parents: 5296
diff changeset
467 case IMGTYPE_YUV211:
mru
parents: 5296
diff changeset
468 for (row = height - 1; row >= 0; row--) {
mru
parents: 5296
diff changeset
469 pixel_ptr = row * c->pic.linesize[0];
mru
parents: 5296
diff changeset
470 for (col = 0; col < width/2; col++) {
mru
parents: 5296
diff changeset
471 outptr[pixel_ptr++] = get_b(encoded[0], encoded[2]);
mru
parents: 5296
diff changeset
472 outptr[pixel_ptr++] = get_g(encoded[0], encoded[2], encoded[3]);
mru
parents: 5296
diff changeset
473 outptr[pixel_ptr++] = get_r(encoded[0], encoded[3]);
mru
parents: 5296
diff changeset
474 outptr[pixel_ptr++] = get_b(encoded[1], encoded[2]);
mru
parents: 5296
diff changeset
475 outptr[pixel_ptr++] = get_g(encoded[1], encoded[2], encoded[3]);
mru
parents: 5296
diff changeset
476 outptr[pixel_ptr++] = get_r(encoded[1], encoded[3]);
mru
parents: 5296
diff changeset
477 encoded += 4;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
478 }
5297
mru
parents: 5296
diff changeset
479 }
mru
parents: 5296
diff changeset
480 break;
mru
parents: 5296
diff changeset
481 case IMGTYPE_YUV420:
mru
parents: 5296
diff changeset
482 for (row = height / 2 - 1; row >= 0; row--) {
mru
parents: 5296
diff changeset
483 pixel_ptr = 2 * row * c->pic.linesize[0];
mru
parents: 5296
diff changeset
484 for (col = 0; col < width/2; col++) {
mru
parents: 5296
diff changeset
485 outptr[pixel_ptr] = get_b(encoded[0], encoded[4]);
mru
parents: 5296
diff changeset
486 outptr[pixel_ptr+1] = get_g(encoded[0], encoded[4], encoded[5]);
mru
parents: 5296
diff changeset
487 outptr[pixel_ptr+2] = get_r(encoded[0], encoded[5]);
mru
parents: 5296
diff changeset
488 outptr[pixel_ptr+3] = get_b(encoded[1], encoded[4]);
mru
parents: 5296
diff changeset
489 outptr[pixel_ptr+4] = get_g(encoded[1], encoded[4], encoded[5]);
mru
parents: 5296
diff changeset
490 outptr[pixel_ptr+5] = get_r(encoded[1], encoded[5]);
mru
parents: 5296
diff changeset
491 outptr[pixel_ptr-c->pic.linesize[0]] = get_b(encoded[2], encoded[4]);
mru
parents: 5296
diff changeset
492 outptr[pixel_ptr-c->pic.linesize[0]+1] = get_g(encoded[2], encoded[4], encoded[5]);
mru
parents: 5296
diff changeset
493 outptr[pixel_ptr-c->pic.linesize[0]+2] = get_r(encoded[2], encoded[5]);
mru
parents: 5296
diff changeset
494 outptr[pixel_ptr-c->pic.linesize[0]+3] = get_b(encoded[3], encoded[4]);
mru
parents: 5296
diff changeset
495 outptr[pixel_ptr-c->pic.linesize[0]+4] = get_g(encoded[3], encoded[4], encoded[5]);
mru
parents: 5296
diff changeset
496 outptr[pixel_ptr-c->pic.linesize[0]+5] = get_r(encoded[3], encoded[5]);
mru
parents: 5296
diff changeset
497 pixel_ptr += 6;
mru
parents: 5296
diff changeset
498 encoded += 6;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
499 }
5297
mru
parents: 5296
diff changeset
500 }
mru
parents: 5296
diff changeset
501 break;
mru
parents: 5296
diff changeset
502 default:
mru
parents: 5296
diff changeset
503 av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in image decoder.\n");
mru
parents: 5296
diff changeset
504 return -1;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
505 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
506
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
507 *data_size = sizeof(AVFrame);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
508 *(AVFrame*)data = c->pic;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
509
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
510 /* always report that the buffer was completely consumed */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
511 return buf_size;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
512 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
513
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
514 /*
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
515 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
516 * Init lcl decoder
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
517 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
518 */
6517
48759bfbd073 Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents: 6375
diff changeset
519 static av_cold int decode_init(AVCodecContext *avctx)
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
520 {
5294
e21873a1c00b split lcl.c into lcldec.c, lclenc.c, lcl.h
mru
parents: 5215
diff changeset
521 LclDecContext * const c = avctx->priv_data;
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
522 unsigned int basesize = avctx->width * avctx->height;
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
523 unsigned int max_basesize = ((avctx->width + 3) & ~3) * ((avctx->height + 3) & ~3);
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
524 unsigned int max_decomp_size;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
525 int zret; // Zlib return code
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
526
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
527 c->pic.data[0] = NULL;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
528
8590
7a463923ecd1 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 7040
diff changeset
529 #if CONFIG_ZLIB
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
530 // Needed if zlib unused or init aborted before inflateInit
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
531 memset(&(c->zstream), 0, sizeof(z_stream));
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
532 #endif
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
533
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
534 if (avctx->extradata_size < 8) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
535 av_log(avctx, AV_LOG_ERROR, "Extradata size too small.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
536 return 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
537 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
538
2429
4b350cc506a7 Use avcodec_check_dimensions instead of custom hack
rtognimp
parents: 2418
diff changeset
539 if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
540 return 1;
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
541 }
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
542
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
543 /* Check codec type */
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
544 if (((avctx->codec_id == CODEC_ID_MSZH) && (*((char *)avctx->extradata + 7) != CODEC_MSZH)) ||
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
545 ((avctx->codec_id == CODEC_ID_ZLIB) && (*((char *)avctx->extradata + 7) != CODEC_ZLIB))) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
546 av_log(avctx, AV_LOG_ERROR, "Codec id and codec type mismatch. This should not happen.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
547 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
548
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
549 /* Detect image type */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
550 switch (c->imgtype = *((char *)avctx->extradata + 4)) {
5297
mru
parents: 5296
diff changeset
551 case IMGTYPE_YUV111:
mru
parents: 5296
diff changeset
552 c->decomp_size = basesize * 3;
mru
parents: 5296
diff changeset
553 max_decomp_size = max_basesize * 3;
mru
parents: 5296
diff changeset
554 av_log(avctx, AV_LOG_INFO, "Image type is YUV 1:1:1.\n");
mru
parents: 5296
diff changeset
555 break;
mru
parents: 5296
diff changeset
556 case IMGTYPE_YUV422:
mru
parents: 5296
diff changeset
557 c->decomp_size = basesize * 2;
mru
parents: 5296
diff changeset
558 max_decomp_size = max_basesize * 2;
mru
parents: 5296
diff changeset
559 av_log(avctx, AV_LOG_INFO, "Image type is YUV 4:2:2.\n");
mru
parents: 5296
diff changeset
560 break;
mru
parents: 5296
diff changeset
561 case IMGTYPE_RGB24:
mru
parents: 5296
diff changeset
562 c->decomp_size = basesize * 3;
mru
parents: 5296
diff changeset
563 max_decomp_size = max_basesize * 3;
mru
parents: 5296
diff changeset
564 av_log(avctx, AV_LOG_INFO, "Image type is RGB 24.\n");
mru
parents: 5296
diff changeset
565 break;
mru
parents: 5296
diff changeset
566 case IMGTYPE_YUV411:
mru
parents: 5296
diff changeset
567 c->decomp_size = basesize / 2 * 3;
mru
parents: 5296
diff changeset
568 max_decomp_size = max_basesize / 2 * 3;
mru
parents: 5296
diff changeset
569 av_log(avctx, AV_LOG_INFO, "Image type is YUV 4:1:1.\n");
mru
parents: 5296
diff changeset
570 break;
mru
parents: 5296
diff changeset
571 case IMGTYPE_YUV211:
mru
parents: 5296
diff changeset
572 c->decomp_size = basesize * 2;
mru
parents: 5296
diff changeset
573 max_decomp_size = max_basesize * 2;
mru
parents: 5296
diff changeset
574 av_log(avctx, AV_LOG_INFO, "Image type is YUV 2:1:1.\n");
mru
parents: 5296
diff changeset
575 break;
mru
parents: 5296
diff changeset
576 case IMGTYPE_YUV420:
mru
parents: 5296
diff changeset
577 c->decomp_size = basesize / 2 * 3;
mru
parents: 5296
diff changeset
578 max_decomp_size = max_basesize / 2 * 3;
mru
parents: 5296
diff changeset
579 av_log(avctx, AV_LOG_INFO, "Image type is YUV 4:2:0.\n");
mru
parents: 5296
diff changeset
580 break;
mru
parents: 5296
diff changeset
581 default:
mru
parents: 5296
diff changeset
582 av_log(avctx, AV_LOG_ERROR, "Unsupported image format %d.\n", c->imgtype);
mru
parents: 5296
diff changeset
583 return 1;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
584 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
585
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
586 /* Detect compression method */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
587 c->compression = *((char *)avctx->extradata + 5);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
588 switch (avctx->codec_id) {
5297
mru
parents: 5296
diff changeset
589 case CODEC_ID_MSZH:
mru
parents: 5296
diff changeset
590 switch (c->compression) {
mru
parents: 5296
diff changeset
591 case COMP_MSZH:
mru
parents: 5296
diff changeset
592 av_log(avctx, AV_LOG_INFO, "Compression enabled.\n");
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
593 break;
5297
mru
parents: 5296
diff changeset
594 case COMP_MSZH_NOCOMP:
mru
parents: 5296
diff changeset
595 c->decomp_size = 0;
mru
parents: 5296
diff changeset
596 av_log(avctx, AV_LOG_INFO, "No compression.\n");
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
597 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
598 default:
5297
mru
parents: 5296
diff changeset
599 av_log(avctx, AV_LOG_ERROR, "Unsupported compression format for MSZH (%d).\n", c->compression);
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
600 return 1;
5297
mru
parents: 5296
diff changeset
601 }
mru
parents: 5296
diff changeset
602 break;
mru
parents: 5296
diff changeset
603 case CODEC_ID_ZLIB:
8590
7a463923ecd1 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 7040
diff changeset
604 #if CONFIG_ZLIB
5297
mru
parents: 5296
diff changeset
605 switch (c->compression) {
mru
parents: 5296
diff changeset
606 case COMP_ZLIB_HISPEED:
mru
parents: 5296
diff changeset
607 av_log(avctx, AV_LOG_INFO, "High speed compression.\n");
mru
parents: 5296
diff changeset
608 break;
mru
parents: 5296
diff changeset
609 case COMP_ZLIB_HICOMP:
mru
parents: 5296
diff changeset
610 av_log(avctx, AV_LOG_INFO, "High compression.\n");
mru
parents: 5296
diff changeset
611 break;
mru
parents: 5296
diff changeset
612 case COMP_ZLIB_NORMAL:
mru
parents: 5296
diff changeset
613 av_log(avctx, AV_LOG_INFO, "Normal compression.\n");
mru
parents: 5296
diff changeset
614 break;
mru
parents: 5296
diff changeset
615 default:
mru
parents: 5296
diff changeset
616 if ((c->compression < Z_NO_COMPRESSION) || (c->compression > Z_BEST_COMPRESSION)) {
mru
parents: 5296
diff changeset
617 av_log(avctx, AV_LOG_ERROR, "Unsupported compression level for ZLIB: (%d).\n", c->compression);
mru
parents: 5296
diff changeset
618 return 1;
mru
parents: 5296
diff changeset
619 }
mru
parents: 5296
diff changeset
620 av_log(avctx, AV_LOG_INFO, "Compression level for ZLIB: (%d).\n", c->compression);
mru
parents: 5296
diff changeset
621 }
mru
parents: 5296
diff changeset
622 #else
mru
parents: 5296
diff changeset
623 av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled.\n");
mru
parents: 5296
diff changeset
624 return 1;
mru
parents: 5296
diff changeset
625 #endif
mru
parents: 5296
diff changeset
626 break;
mru
parents: 5296
diff changeset
627 default:
mru
parents: 5296
diff changeset
628 av_log(avctx, AV_LOG_ERROR, "BUG! Unknown codec in compression switch.\n");
mru
parents: 5296
diff changeset
629 return 1;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
630 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
631
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
632 /* Allocate decompression buffer */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
633 if (c->decomp_size) {
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
634 if ((c->decomp_buf = av_malloc(max_decomp_size)) == NULL) {
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
635 av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
636 return 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
637 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
638 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
639
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
640 /* Detect flags */
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
641 c->flags = *((char *)avctx->extradata + 6);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
642 if (c->flags & FLAG_MULTITHREAD)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
643 av_log(avctx, AV_LOG_INFO, "Multithread encoder flag set.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
644 if (c->flags & FLAG_NULLFRAME)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
645 av_log(avctx, AV_LOG_INFO, "Nullframe insertion flag set.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
646 if ((avctx->codec_id == CODEC_ID_ZLIB) && (c->flags & FLAG_PNGFILTER))
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
647 av_log(avctx, AV_LOG_INFO, "PNG filter flag set.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
648 if (c->flags & FLAGMASK_UNUSED)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
649 av_log(avctx, AV_LOG_ERROR, "Unknown flag set (%d).\n", c->flags);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
650
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
651 /* If needed init zlib */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
652 if (avctx->codec_id == CODEC_ID_ZLIB) {
8590
7a463923ecd1 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 7040
diff changeset
653 #if CONFIG_ZLIB
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
654 c->zstream.zalloc = Z_NULL;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
655 c->zstream.zfree = Z_NULL;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
656 c->zstream.opaque = Z_NULL;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
657 zret = inflateInit(&(c->zstream));
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
658 if (zret != Z_OK) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
659 av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
660 return 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
661 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
662 #else
5297
mru
parents: 5296
diff changeset
663 av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled.\n");
mru
parents: 5296
diff changeset
664 return 1;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
665 #endif
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
666 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
667
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
668 avctx->pix_fmt = PIX_FMT_BGR24;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
669
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
670 return 0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
671 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
672
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
673 /*
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
674 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
675 * Uninit lcl decoder
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
676 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
677 */
6517
48759bfbd073 Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents: 6375
diff changeset
678 static av_cold int decode_end(AVCodecContext *avctx)
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
679 {
5297
mru
parents: 5296
diff changeset
680 LclDecContext * const c = avctx->priv_data;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
681
5297
mru
parents: 5296
diff changeset
682 if (c->pic.data[0])
mru
parents: 5296
diff changeset
683 avctx->release_buffer(avctx, &c->pic);
8590
7a463923ecd1 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 7040
diff changeset
684 #if CONFIG_ZLIB
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
685 inflateEnd(&(c->zstream));
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
686 #endif
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
687
5297
mru
parents: 5296
diff changeset
688 return 0;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
689 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
690
8590
7a463923ecd1 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 7040
diff changeset
691 #if CONFIG_MSZH_DECODER
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
692 AVCodec mszh_decoder = {
5297
mru
parents: 5296
diff changeset
693 "mszh",
mru
parents: 5296
diff changeset
694 CODEC_TYPE_VIDEO,
mru
parents: 5296
diff changeset
695 CODEC_ID_MSZH,
mru
parents: 5296
diff changeset
696 sizeof(LclDecContext),
mru
parents: 5296
diff changeset
697 decode_init,
mru
parents: 5296
diff changeset
698 NULL,
mru
parents: 5296
diff changeset
699 decode_end,
mru
parents: 5296
diff changeset
700 decode_frame,
mru
parents: 5296
diff changeset
701 CODEC_CAP_DR1,
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6712
diff changeset
702 .long_name = NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) MSZH"),
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
703 };
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
704 #endif
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
705
8590
7a463923ecd1 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 7040
diff changeset
706 #if CONFIG_ZLIB_DECODER
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
707 AVCodec zlib_decoder = {
5297
mru
parents: 5296
diff changeset
708 "zlib",
mru
parents: 5296
diff changeset
709 CODEC_TYPE_VIDEO,
mru
parents: 5296
diff changeset
710 CODEC_ID_ZLIB,
mru
parents: 5296
diff changeset
711 sizeof(LclDecContext),
mru
parents: 5296
diff changeset
712 decode_init,
mru
parents: 5296
diff changeset
713 NULL,
mru
parents: 5296
diff changeset
714 decode_end,
mru
parents: 5296
diff changeset
715 decode_frame,
mru
parents: 5296
diff changeset
716 CODEC_CAP_DR1,
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6712
diff changeset
717 .long_name = NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) ZLIB"),
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
718 };
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
719 #endif