annotate lcl.c @ 5243:dd11d0b32cc9 libavcodec

move dequantization into its own inline function
author stefang
date Sat, 07 Jul 2007 07:14:58 +0000
parents 2b72f9bc4f06
children
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 /**
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
23 * @file lcl.c
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"
2398
582e635cfa08 common.c -> bitstream.c (and the single non bitstream func -> utils.c)
michael
parents: 2250
diff changeset
45 #include "bitstream.h"
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
46
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
47 #ifdef CONFIG_ZLIB
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
48 #include <zlib.h>
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
49 #endif
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
50
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
51
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
52 #define BMPTYPE_YUV 1
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
53 #define BMPTYPE_RGB 2
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
54
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
55 #define IMGTYPE_YUV111 0
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
56 #define IMGTYPE_YUV422 1
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
57 #define IMGTYPE_RGB24 2
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
58 #define IMGTYPE_YUV411 3
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
59 #define IMGTYPE_YUV211 4
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
60 #define IMGTYPE_YUV420 5
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
61
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
62 #define COMP_MSZH 0
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
63 #define COMP_MSZH_NOCOMP 1
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
64 #define COMP_ZLIB_HISPEED 1
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
65 #define COMP_ZLIB_HICOMP 9
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
66 #define COMP_ZLIB_NORMAL -1
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
67
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
68 #define FLAG_MULTITHREAD 1
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
69 #define FLAG_NULLFRAME 2
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
70 #define FLAG_PNGFILTER 4
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
71 #define FLAGMASK_UNUSED 0xf8
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
72
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
73 #define CODEC_MSZH 1
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
74 #define CODEC_ZLIB 3
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
75
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
76 #define FOURCC_MSZH mmioFOURCC('M','S','Z','H')
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
77 #define FOURCC_ZLIB mmioFOURCC('Z','L','I','B')
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
78
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
79 /*
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
80 * Decoder context
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
81 */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
82 typedef struct LclContext {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
83
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
84 AVCodecContext *avctx;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
85 AVFrame pic;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
86 PutBitContext pb;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
87
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
88 // Image type
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
89 int imgtype;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
90 // Compression type
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
91 int compression;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
92 // Flags
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
93 int flags;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
94 // Decompressed data size
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
95 unsigned int decomp_size;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
96 // Decompression buffer
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
97 unsigned char* decomp_buf;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
98 // Maximum compressed data size
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
99 unsigned int max_comp_size;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
100 // Compression buffer
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
101 unsigned char* comp_buf;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
102 #ifdef CONFIG_ZLIB
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
103 z_stream zstream;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
104 #endif
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
105 } LclContext;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
106
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
107
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
108 /*
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
109 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
110 * Helper functions
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 static inline unsigned char fix (int pix14)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
114 {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
115 int tmp;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
116
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
117 tmp = (pix14 + 0x80000) >> 20;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
118 if (tmp < 0)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
119 return 0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
120 if (tmp > 255)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
121 return 255;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
122 return tmp;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
123 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
124
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
125
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
126
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
127 static inline unsigned char get_b (unsigned char yq, signed char bq)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
128 {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
129 return fix((yq << 20) + bq * 1858076);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
130 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
131
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
132
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
133
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
134 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
135 {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
136 return fix((yq << 20) - bq * 360857 - rq * 748830);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
137 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
138
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
139
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
140
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
141 static inline unsigned char get_r (unsigned char yq, signed char rq)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
142 {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
143 return fix((yq << 20) + rq * 1470103);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
144 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
145
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
146
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
147
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
148 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
149 {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
150 unsigned char *destptr_bak = destptr;
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
151 unsigned char *destptr_end = destptr + destsize;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
152 unsigned char mask = 0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
153 unsigned char maskbit = 0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
154 unsigned int ofs, cnt;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
155
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
156 while ((srclen > 0) && (destptr < destptr_end)) {
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
157 if (maskbit == 0) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
158 mask = *(srcptr++);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
159 maskbit = 8;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
160 srclen--;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
161 continue;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
162 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
163 if ((mask & (1 << (--maskbit))) == 0) {
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
164 if (destptr + 4 > destptr_end)
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
165 break;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
166 *(int*)destptr = *(int*)srcptr;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
167 srclen -= 4;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
168 destptr += 4;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
169 srcptr += 4;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
170 } else {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
171 ofs = *(srcptr++);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
172 cnt = *(srcptr++);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
173 ofs += cnt * 256;;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
174 cnt = ((cnt >> 3) & 0x1f) + 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
175 ofs &= 0x7ff;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
176 srclen -= 2;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
177 cnt *= 4;
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
178 if (destptr + cnt > destptr_end) {
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
179 cnt = destptr_end - destptr;
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
180 }
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
181 for (; cnt > 0; cnt--) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
182 *(destptr) = *(destptr - ofs);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
183 destptr++;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
184 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
185 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
186 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
187
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
188 return (destptr - destptr_bak);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
189 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
190
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
191
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
192
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
193 #ifdef CONFIG_DECODERS
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
194 /*
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
195 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
196 * Decode a frame
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
197 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
198 */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
199 static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
200 {
4827
b3ee9a1526b0 Get rid of unnecessary pointer casts.
diego
parents: 4801
diff changeset
201 LclContext * const c = avctx->priv_data;
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
202 unsigned char *encoded = (unsigned char *)buf;
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
203 unsigned int pixel_ptr;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
204 int row, col;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
205 unsigned char *outptr;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
206 unsigned int width = avctx->width; // Real image width
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
207 unsigned int height = avctx->height; // Real image height
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
208 unsigned int mszh_dlen;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
209 unsigned char yq, y1q, uq, vq;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
210 int uqvq;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
211 unsigned int mthread_inlen, mthread_outlen;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
212 #ifdef CONFIG_ZLIB
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
213 int zret; // Zlib return code
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
214 #endif
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
215 unsigned int len = buf_size;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
216
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
217 if(c->pic.data[0])
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
218 avctx->release_buffer(avctx, &c->pic);
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
219
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
220 c->pic.reference = 0;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
221 c->pic.buffer_hints = FF_BUFFER_HINTS_VALID;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
222 if(avctx->get_buffer(avctx, &c->pic) < 0){
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
223 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
224 return -1;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
225 }
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
226
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
227 outptr = c->pic.data[0]; // Output image pointer
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
228
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
229 /* Decompress frame */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
230 switch (avctx->codec_id) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
231 case CODEC_ID_MSZH:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
232 switch (c->compression) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
233 case COMP_MSZH:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
234 if (c->flags & FLAG_MULTITHREAD) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
235 mthread_inlen = *((unsigned int*)encoded);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
236 mthread_outlen = *((unsigned int*)(encoded+4));
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
237 if (mthread_outlen > c->decomp_size) // this should not happen
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
238 mthread_outlen = c->decomp_size;
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
239 mszh_dlen = mszh_decomp(encoded + 8, mthread_inlen, c->decomp_buf, c->decomp_size);
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
240 if (mthread_outlen != mszh_dlen) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
241 av_log(avctx, AV_LOG_ERROR, "Mthread1 decoded size differs (%d != %d)\n",
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
242 mthread_outlen, mszh_dlen);
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
243 return -1;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
244 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
245 mszh_dlen = mszh_decomp(encoded + 8 + mthread_inlen, len - mthread_inlen,
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
246 c->decomp_buf + mthread_outlen, c->decomp_size - mthread_outlen);
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
247 if (mthread_outlen != mszh_dlen) {
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
248 av_log(avctx, AV_LOG_ERROR, "Mthread2 decoded size differs (%d != %d)\n",
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
249 mthread_outlen, mszh_dlen);
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
250 return -1;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
251 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
252 encoded = c->decomp_buf;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
253 len = c->decomp_size;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
254 } else {
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
255 mszh_dlen = mszh_decomp(encoded, len, c->decomp_buf, c->decomp_size);
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
256 if (c->decomp_size != mszh_dlen) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
257 av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %d)\n",
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
258 c->decomp_size, mszh_dlen);
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
259 return -1;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
260 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
261 encoded = c->decomp_buf;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
262 len = mszh_dlen;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
263 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
264 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
265 case COMP_MSZH_NOCOMP:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
266 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
267 default:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
268 av_log(avctx, AV_LOG_ERROR, "BUG! Unknown MSZH compression in frame decoder.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
269 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
270 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
271 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
272 case CODEC_ID_ZLIB:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
273 #ifdef CONFIG_ZLIB
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
274 /* Using the original dll with normal compression (-1) and RGB format
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
275 * gives a file with ZLIB fourcc, but frame is really uncompressed.
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
276 * To be sure that's true check also frame size */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
277 if ((c->compression == COMP_ZLIB_NORMAL) && (c->imgtype == IMGTYPE_RGB24) &&
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
278 (len == width * height * 3))
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
279 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
280 zret = inflateReset(&(c->zstream));
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
281 if (zret != Z_OK) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
282 av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
283 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
284 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
285 if (c->flags & FLAG_MULTITHREAD) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
286 mthread_inlen = *((unsigned int*)encoded);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
287 mthread_outlen = *((unsigned int*)(encoded+4));
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
288 if (mthread_outlen > c->decomp_size)
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
289 mthread_outlen = c->decomp_size;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
290 c->zstream.next_in = encoded + 8;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
291 c->zstream.avail_in = mthread_inlen;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
292 c->zstream.next_out = c->decomp_buf;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
293 c->zstream.avail_out = c->decomp_size;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
294 zret = inflate(&(c->zstream), Z_FINISH);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
295 if ((zret != Z_OK) && (zret != Z_STREAM_END)) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
296 av_log(avctx, AV_LOG_ERROR, "Mthread1 inflate error: %d\n", zret);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
297 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
298 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
299 if (mthread_outlen != (unsigned int)(c->zstream.total_out)) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
300 av_log(avctx, AV_LOG_ERROR, "Mthread1 decoded size differs (%u != %lu)\n",
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
301 mthread_outlen, c->zstream.total_out);
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
302 return -1;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
303 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
304 zret = inflateReset(&(c->zstream));
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
305 if (zret != Z_OK) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
306 av_log(avctx, AV_LOG_ERROR, "Mthread2 inflate reset error: %d\n", zret);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
307 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
308 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
309 c->zstream.next_in = encoded + 8 + mthread_inlen;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
310 c->zstream.avail_in = len - mthread_inlen;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
311 c->zstream.next_out = c->decomp_buf + mthread_outlen;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
312 c->zstream.avail_out = c->decomp_size - mthread_outlen;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
313 zret = inflate(&(c->zstream), Z_FINISH);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
314 if ((zret != Z_OK) && (zret != Z_STREAM_END)) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
315 av_log(avctx, AV_LOG_ERROR, "Mthread2 inflate error: %d\n", zret);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
316 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
317 }
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
318 if (mthread_outlen != (unsigned int)(c->zstream.total_out)) {
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
319 av_log(avctx, AV_LOG_ERROR, "Mthread2 decoded size differs (%d != %lu)\n",
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
320 mthread_outlen, c->zstream.total_out);
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
321 return -1;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
322 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
323 } else {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
324 c->zstream.next_in = encoded;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
325 c->zstream.avail_in = len;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
326 c->zstream.next_out = c->decomp_buf;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
327 c->zstream.avail_out = c->decomp_size;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
328 zret = inflate(&(c->zstream), Z_FINISH);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
329 if ((zret != Z_OK) && (zret != Z_STREAM_END)) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
330 av_log(avctx, AV_LOG_ERROR, "Inflate error: %d\n", zret);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
331 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
332 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
333 if (c->decomp_size != (unsigned int)(c->zstream.total_out)) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
334 av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %lu)\n",
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
335 c->decomp_size, c->zstream.total_out);
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
336 return -1;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
337 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
338 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
339 encoded = c->decomp_buf;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
340 len = c->decomp_size;;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
341 #else
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
342 av_log(avctx, AV_LOG_ERROR, "BUG! Zlib support not compiled in frame decoder.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
343 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
344 #endif
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
345 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
346 default:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
347 av_log(avctx, AV_LOG_ERROR, "BUG! Unknown codec in frame decoder compression switch.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
348 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
349 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
350
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
351
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
352 /* Apply PNG filter */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
353 if ((avctx->codec_id == CODEC_ID_ZLIB) && (c->flags & FLAG_PNGFILTER)) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
354 switch (c->imgtype) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
355 case IMGTYPE_YUV111:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
356 case IMGTYPE_RGB24:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
357 for (row = 0; row < height; row++) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
358 pixel_ptr = row * width * 3;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
359 yq = encoded[pixel_ptr++];
5089
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 4962
diff changeset
360 uqvq = AV_RL16(encoded+pixel_ptr);
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 4962
diff changeset
361 pixel_ptr += 2;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
362 for (col = 1; col < width; col++) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
363 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
5089
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 4962
diff changeset
364 uqvq -= AV_RL16(encoded+pixel_ptr+1);
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 4962
diff changeset
365 AV_WL16(encoded+pixel_ptr+1, uqvq);
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
366 pixel_ptr += 3;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
367 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
368 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
369 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
370 case IMGTYPE_YUV422:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
371 for (row = 0; row < height; row++) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
372 pixel_ptr = row * width * 2;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
373 yq = uq = vq =0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
374 for (col = 0; col < width/4; col++) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
375 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
376 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
377 encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
378 encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
379 encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
380 encoded[pixel_ptr+5] = uq -= encoded[pixel_ptr+5];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
381 encoded[pixel_ptr+6] = vq -= encoded[pixel_ptr+6];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
382 encoded[pixel_ptr+7] = vq -= encoded[pixel_ptr+7];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
383 pixel_ptr += 8;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
384 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
385 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
386 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
387 case IMGTYPE_YUV411:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
388 for (row = 0; row < height; row++) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
389 pixel_ptr = row * width / 2 * 3;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
390 yq = uq = vq =0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
391 for (col = 0; col < width/4; col++) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
392 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
393 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
394 encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
395 encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
396 encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
397 encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
398 pixel_ptr += 6;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
399 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
400 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
401 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
402 case IMGTYPE_YUV211:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
403 for (row = 0; row < height; row++) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
404 pixel_ptr = row * width * 2;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
405 yq = uq = vq =0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
406 for (col = 0; col < width/2; col++) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
407 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
408 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
409 encoded[pixel_ptr+2] = uq -= encoded[pixel_ptr+2];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
410 encoded[pixel_ptr+3] = vq -= encoded[pixel_ptr+3];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
411 pixel_ptr += 4;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
412 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
413 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
414 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
415 case IMGTYPE_YUV420:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
416 for (row = 0; row < height/2; row++) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
417 pixel_ptr = row * width * 3;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
418 yq = y1q = uq = vq =0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
419 for (col = 0; col < width/2; col++) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
420 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
421 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
422 encoded[pixel_ptr+2] = y1q -= encoded[pixel_ptr+2];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
423 encoded[pixel_ptr+3] = y1q -= encoded[pixel_ptr+3];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
424 encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
425 encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
426 pixel_ptr += 6;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
427 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
428 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
429 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
430 default:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
431 av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in pngfilter switch.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
432 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
433 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
434 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
435
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
436 /* Convert colorspace */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
437 switch (c->imgtype) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
438 case IMGTYPE_YUV111:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
439 for (row = height - 1; row >= 0; row--) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
440 pixel_ptr = row * c->pic.linesize[0];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
441 for (col = 0; col < width; col++) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
442 outptr[pixel_ptr++] = get_b(encoded[0], encoded[1]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
443 outptr[pixel_ptr++] = get_g(encoded[0], encoded[1], encoded[2]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
444 outptr[pixel_ptr++] = get_r(encoded[0], encoded[2]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
445 encoded += 3;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
446 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
447 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
448 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
449 case IMGTYPE_YUV422:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
450 for (row = height - 1; row >= 0; row--) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
451 pixel_ptr = row * c->pic.linesize[0];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
452 for (col = 0; col < width/4; col++) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
453 outptr[pixel_ptr++] = get_b(encoded[0], encoded[4]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
454 outptr[pixel_ptr++] = get_g(encoded[0], encoded[4], encoded[6]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
455 outptr[pixel_ptr++] = get_r(encoded[0], encoded[6]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
456 outptr[pixel_ptr++] = get_b(encoded[1], encoded[4]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
457 outptr[pixel_ptr++] = get_g(encoded[1], encoded[4], encoded[6]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
458 outptr[pixel_ptr++] = get_r(encoded[1], encoded[6]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
459 outptr[pixel_ptr++] = get_b(encoded[2], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
460 outptr[pixel_ptr++] = get_g(encoded[2], encoded[5], encoded[7]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
461 outptr[pixel_ptr++] = get_r(encoded[2], encoded[7]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
462 outptr[pixel_ptr++] = get_b(encoded[3], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
463 outptr[pixel_ptr++] = get_g(encoded[3], encoded[5], encoded[7]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
464 outptr[pixel_ptr++] = get_r(encoded[3], encoded[7]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
465 encoded += 8;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
466 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
467 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
468 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
469 case IMGTYPE_RGB24:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
470 for (row = height - 1; row >= 0; row--) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
471 pixel_ptr = row * c->pic.linesize[0];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
472 for (col = 0; col < width; col++) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
473 outptr[pixel_ptr++] = encoded[0];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
474 outptr[pixel_ptr++] = encoded[1];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
475 outptr[pixel_ptr++] = encoded[2];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
476 encoded += 3;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
477 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
478 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
479 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
480 case IMGTYPE_YUV411:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
481 for (row = height - 1; row >= 0; row--) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
482 pixel_ptr = row * c->pic.linesize[0];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
483 for (col = 0; col < width/4; col++) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
484 outptr[pixel_ptr++] = get_b(encoded[0], encoded[4]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
485 outptr[pixel_ptr++] = get_g(encoded[0], encoded[4], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
486 outptr[pixel_ptr++] = get_r(encoded[0], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
487 outptr[pixel_ptr++] = get_b(encoded[1], encoded[4]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
488 outptr[pixel_ptr++] = get_g(encoded[1], encoded[4], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
489 outptr[pixel_ptr++] = get_r(encoded[1], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
490 outptr[pixel_ptr++] = get_b(encoded[2], encoded[4]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
491 outptr[pixel_ptr++] = get_g(encoded[2], encoded[4], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
492 outptr[pixel_ptr++] = get_r(encoded[2], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
493 outptr[pixel_ptr++] = get_b(encoded[3], encoded[4]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
494 outptr[pixel_ptr++] = get_g(encoded[3], encoded[4], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
495 outptr[pixel_ptr++] = get_r(encoded[3], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
496 encoded += 6;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
497 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
498 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
499 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
500 case IMGTYPE_YUV211:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
501 for (row = height - 1; row >= 0; row--) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
502 pixel_ptr = row * c->pic.linesize[0];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
503 for (col = 0; col < width/2; col++) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
504 outptr[pixel_ptr++] = get_b(encoded[0], encoded[2]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
505 outptr[pixel_ptr++] = get_g(encoded[0], encoded[2], encoded[3]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
506 outptr[pixel_ptr++] = get_r(encoded[0], encoded[3]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
507 outptr[pixel_ptr++] = get_b(encoded[1], encoded[2]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
508 outptr[pixel_ptr++] = get_g(encoded[1], encoded[2], encoded[3]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
509 outptr[pixel_ptr++] = get_r(encoded[1], encoded[3]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
510 encoded += 4;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
511 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
512 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
513 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
514 case IMGTYPE_YUV420:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
515 for (row = height / 2 - 1; row >= 0; row--) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
516 pixel_ptr = 2 * row * c->pic.linesize[0];
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
517 for (col = 0; col < width/2; col++) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
518 outptr[pixel_ptr] = get_b(encoded[0], encoded[4]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
519 outptr[pixel_ptr+1] = get_g(encoded[0], encoded[4], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
520 outptr[pixel_ptr+2] = get_r(encoded[0], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
521 outptr[pixel_ptr+3] = get_b(encoded[1], encoded[4]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
522 outptr[pixel_ptr+4] = get_g(encoded[1], encoded[4], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
523 outptr[pixel_ptr+5] = get_r(encoded[1], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
524 outptr[pixel_ptr-c->pic.linesize[0]] = get_b(encoded[2], encoded[4]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
525 outptr[pixel_ptr-c->pic.linesize[0]+1] = get_g(encoded[2], encoded[4], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
526 outptr[pixel_ptr-c->pic.linesize[0]+2] = get_r(encoded[2], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
527 outptr[pixel_ptr-c->pic.linesize[0]+3] = get_b(encoded[3], encoded[4]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
528 outptr[pixel_ptr-c->pic.linesize[0]+4] = get_g(encoded[3], encoded[4], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
529 outptr[pixel_ptr-c->pic.linesize[0]+5] = get_r(encoded[3], encoded[5]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
530 pixel_ptr += 6;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
531 encoded += 6;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
532 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
533 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
534 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
535 default:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
536 av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in image decoder.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
537 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
538 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
539
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
540 *data_size = sizeof(AVFrame);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
541 *(AVFrame*)data = c->pic;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
542
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
543 /* always report that the buffer was completely consumed */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
544 return buf_size;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
545 }
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
546 #endif
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
547
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
548 #ifdef CONFIG_ENCODERS
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
549 /*
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
550 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
551 * Encode a frame
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
552 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
553 */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
554 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
555 LclContext *c = avctx->priv_data;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
556 AVFrame *pict = data;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
557 AVFrame * const p = &c->pic;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
558 int i;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
559 int zret; // Zlib return code
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
560
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
561 #ifndef CONFIG_ZLIB
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
562 av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled in.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
563 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
564 #else
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
565
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
566 init_put_bits(&c->pb, buf, buf_size);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
567
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
568 *p = *pict;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
569 p->pict_type= FF_I_TYPE;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
570 p->key_frame= 1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
571
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
572 if(avctx->pix_fmt != PIX_FMT_BGR24){
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
573 av_log(avctx, AV_LOG_ERROR, "Format not supported!\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
574 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
575 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
576
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
577 zret = deflateReset(&(c->zstream));
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
578 if (zret != Z_OK) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
579 av_log(avctx, AV_LOG_ERROR, "Deflate reset error: %d\n", zret);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
580 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
581 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
582 c->zstream.next_out = c->comp_buf;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
583 c->zstream.avail_out = c->max_comp_size;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
584
2250
902caf560c43 Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents: 2248
diff changeset
585 for(i = avctx->height - 1; i >= 0; i--) {
902caf560c43 Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents: 2248
diff changeset
586 c->zstream.next_in = p->data[0]+p->linesize[0]*i;
902caf560c43 Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents: 2248
diff changeset
587 c->zstream.avail_in = avctx->width*3;
902caf560c43 Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents: 2248
diff changeset
588 zret = deflate(&(c->zstream), Z_NO_FLUSH);
902caf560c43 Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents: 2248
diff changeset
589 if (zret != Z_OK) {
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
590 av_log(avctx, AV_LOG_ERROR, "Deflate error: %d\n", zret);
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
591 return -1;
2250
902caf560c43 Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents: 2248
diff changeset
592 }
902caf560c43 Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents: 2248
diff changeset
593 }
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
594 zret = deflate(&(c->zstream), Z_FINISH);
2250
902caf560c43 Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents: 2248
diff changeset
595 if (zret != Z_STREAM_END) {
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
596 av_log(avctx, AV_LOG_ERROR, "Deflate error: %d\n", zret);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
597 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
598 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
599
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
600 for (i = 0; i < c->zstream.total_out; i++)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
601 put_bits(&c->pb, 8, c->comp_buf[i]);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
602 flush_put_bits(&c->pb);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
603
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
604 return c->zstream.total_out;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
605 #endif
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
606 }
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
607 #endif /* CONFIG_ENCODERS */
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
608
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
609 #ifdef CONFIG_DECODERS
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
610 /*
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
611 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
612 * Init lcl decoder
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
613 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
614 */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
615 static int decode_init(AVCodecContext *avctx)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
616 {
4827
b3ee9a1526b0 Get rid of unnecessary pointer casts.
diego
parents: 4801
diff changeset
617 LclContext * const c = avctx->priv_data;
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
618 unsigned int basesize = avctx->width * avctx->height;
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
619 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
620 unsigned int max_decomp_size;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
621 int zret; // Zlib return code
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
622
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
623 c->avctx = avctx;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
624
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
625 c->pic.data[0] = NULL;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
626
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
627 #ifdef CONFIG_ZLIB
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
628 // Needed if zlib unused or init aborted before inflateInit
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
629 memset(&(c->zstream), 0, sizeof(z_stream));
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
630 #endif
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
631
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
632 if (avctx->extradata_size < 8) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
633 av_log(avctx, AV_LOG_ERROR, "Extradata size too small.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
634 return 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
635 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
636
2429
4b350cc506a7 Use avcodec_check_dimensions instead of custom hack
rtognimp
parents: 2418
diff changeset
637 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
638 return 1;
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
639 }
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
640
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
641 /* Check codec type */
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
642 if (((avctx->codec_id == CODEC_ID_MSZH) && (*((char *)avctx->extradata + 7) != CODEC_MSZH)) ||
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
643 ((avctx->codec_id == CODEC_ID_ZLIB) && (*((char *)avctx->extradata + 7) != CODEC_ZLIB))) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
644 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
645 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
646
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
647 /* Detect image type */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
648 switch (c->imgtype = *((char *)avctx->extradata + 4)) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
649 case IMGTYPE_YUV111:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
650 c->decomp_size = basesize * 3;
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
651 max_decomp_size = max_basesize * 3;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
652 av_log(avctx, AV_LOG_INFO, "Image type is YUV 1:1:1.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
653 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
654 case IMGTYPE_YUV422:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
655 c->decomp_size = basesize * 2;
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
656 max_decomp_size = max_basesize * 2;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
657 av_log(avctx, AV_LOG_INFO, "Image type is YUV 4:2:2.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
658 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
659 case IMGTYPE_RGB24:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
660 c->decomp_size = basesize * 3;
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
661 max_decomp_size = max_basesize * 3;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
662 av_log(avctx, AV_LOG_INFO, "Image type is RGB 24.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
663 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
664 case IMGTYPE_YUV411:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
665 c->decomp_size = basesize / 2 * 3;
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
666 max_decomp_size = max_basesize / 2 * 3;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
667 av_log(avctx, AV_LOG_INFO, "Image type is YUV 4:1:1.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
668 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
669 case IMGTYPE_YUV211:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
670 c->decomp_size = basesize * 2;
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
671 max_decomp_size = max_basesize * 2;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
672 av_log(avctx, AV_LOG_INFO, "Image type is YUV 2:1:1.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
673 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
674 case IMGTYPE_YUV420:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
675 c->decomp_size = basesize / 2 * 3;
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
676 max_decomp_size = max_basesize / 2 * 3;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
677 av_log(avctx, AV_LOG_INFO, "Image type is YUV 4:2:0.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
678 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
679 default:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
680 av_log(avctx, AV_LOG_ERROR, "Unsupported image format %d.\n", c->imgtype);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
681 return 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
682 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
683
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
684 /* Detect compression method */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
685 c->compression = *((char *)avctx->extradata + 5);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
686 switch (avctx->codec_id) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
687 case CODEC_ID_MSZH:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
688 switch (c->compression) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
689 case COMP_MSZH:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
690 av_log(avctx, AV_LOG_INFO, "Compression enabled.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
691 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
692 case COMP_MSZH_NOCOMP:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
693 c->decomp_size = 0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
694 av_log(avctx, AV_LOG_INFO, "No compression.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
695 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
696 default:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
697 av_log(avctx, AV_LOG_ERROR, "Unsupported compression format for MSZH (%d).\n", c->compression);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
698 return 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
699 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
700 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
701 case CODEC_ID_ZLIB:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
702 #ifdef CONFIG_ZLIB
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
703 switch (c->compression) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
704 case COMP_ZLIB_HISPEED:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
705 av_log(avctx, AV_LOG_INFO, "High speed compression.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
706 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
707 case COMP_ZLIB_HICOMP:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
708 av_log(avctx, AV_LOG_INFO, "High compression.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
709 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
710 case COMP_ZLIB_NORMAL:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
711 av_log(avctx, AV_LOG_INFO, "Normal compression.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
712 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
713 default:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
714 if ((c->compression < Z_NO_COMPRESSION) || (c->compression > Z_BEST_COMPRESSION)) {
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
715 av_log(avctx, AV_LOG_ERROR, "Unsupported compression level for ZLIB: (%d).\n", c->compression);
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
716 return 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
717 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
718 av_log(avctx, AV_LOG_INFO, "Compression level for ZLIB: (%d).\n", c->compression);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
719 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
720 #else
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
721 av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
722 return 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
723 #endif
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
724 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
725 default:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
726 av_log(avctx, AV_LOG_ERROR, "BUG! Unknown codec in compression switch.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
727 return 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
728 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
729
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
730 /* Allocate decompression buffer */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
731 if (c->decomp_size) {
2418
82af834636c2 Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents: 2398
diff changeset
732 if ((c->decomp_buf = av_malloc(max_decomp_size)) == NULL) {
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
733 av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
734 return 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
735 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
736 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
737
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
738 /* Detect flags */
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
739 c->flags = *((char *)avctx->extradata + 6);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
740 if (c->flags & FLAG_MULTITHREAD)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
741 av_log(avctx, AV_LOG_INFO, "Multithread encoder flag set.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
742 if (c->flags & FLAG_NULLFRAME)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
743 av_log(avctx, AV_LOG_INFO, "Nullframe insertion flag set.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
744 if ((avctx->codec_id == CODEC_ID_ZLIB) && (c->flags & FLAG_PNGFILTER))
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
745 av_log(avctx, AV_LOG_INFO, "PNG filter flag set.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
746 if (c->flags & FLAGMASK_UNUSED)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
747 av_log(avctx, AV_LOG_ERROR, "Unknown flag set (%d).\n", c->flags);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
748
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
749 /* If needed init zlib */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
750 if (avctx->codec_id == CODEC_ID_ZLIB) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
751 #ifdef CONFIG_ZLIB
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
752 c->zstream.zalloc = Z_NULL;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
753 c->zstream.zfree = Z_NULL;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
754 c->zstream.opaque = Z_NULL;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
755 zret = inflateInit(&(c->zstream));
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
756 if (zret != Z_OK) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
757 av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
758 return 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
759 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
760 #else
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
761 av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
762 return 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
763 #endif
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
764 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
765
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
766 avctx->pix_fmt = PIX_FMT_BGR24;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
767
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
768 return 0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
769 }
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
770 #endif /* CONFIG_DECODERS */
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
771
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
772 #ifdef CONFIG_ENCODERS
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
773 /*
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
774 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
775 * Init lcl encoder
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
776 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
777 */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
778 static int encode_init(AVCodecContext *avctx)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
779 {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
780 LclContext *c = avctx->priv_data;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
781 int zret; // Zlib return code
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
782
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
783 #ifndef CONFIG_ZLIB
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
784 av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
785 return 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
786 #else
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
787
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
788 c->avctx= avctx;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
789
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
790 assert(avctx->width && avctx->height);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
791
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
792 avctx->extradata= av_mallocz(8);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
793 avctx->coded_frame= &c->pic;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
794
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
795 // Will be user settable someday
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
796 c->compression = 6;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
797 c->flags = 0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
798
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
799 switch(avctx->pix_fmt){
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
800 case PIX_FMT_BGR24:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
801 c->imgtype = IMGTYPE_RGB24;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
802 c->decomp_size = avctx->width * avctx->height * 3;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
803 avctx->bits_per_sample= 24;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
804 break;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
805 default:
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
806 av_log(avctx, AV_LOG_ERROR, "Format %d not supported\n", avctx->pix_fmt);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
807 return -1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
808 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
809
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
810 ((uint8_t*)avctx->extradata)[0]= 4;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
811 ((uint8_t*)avctx->extradata)[1]= 0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
812 ((uint8_t*)avctx->extradata)[2]= 0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
813 ((uint8_t*)avctx->extradata)[3]= 0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
814 ((uint8_t*)avctx->extradata)[4]= c->imgtype;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
815 ((uint8_t*)avctx->extradata)[5]= c->compression;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
816 ((uint8_t*)avctx->extradata)[6]= c->flags;
2250
902caf560c43 Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents: 2248
diff changeset
817 ((uint8_t*)avctx->extradata)[7]= CODEC_ZLIB;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
818 c->avctx->extradata_size= 8;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
819
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
820 c->zstream.zalloc = Z_NULL;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
821 c->zstream.zfree = Z_NULL;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
822 c->zstream.opaque = Z_NULL;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
823 zret = deflateInit(&(c->zstream), c->compression);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
824 if (zret != Z_OK) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
825 av_log(avctx, AV_LOG_ERROR, "Deflate init error: %d\n", zret);
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
826 return 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
827 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
828
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
829 /* Conservative upper bound taken from zlib v1.2.1 source */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
830 c->max_comp_size = c->decomp_size + ((c->decomp_size + 7) >> 3) +
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
831 ((c->decomp_size + 63) >> 6) + 11;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
832 if ((c->comp_buf = av_malloc(c->max_comp_size)) == NULL) {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
833 av_log(avctx, AV_LOG_ERROR, "Can't allocate compression buffer.\n");
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
834 return 1;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
835 }
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
836
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
837 return 0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
838 #endif
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
839 }
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
840 #endif /* CONFIG_ENCODERS */
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
841
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
842
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
843
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
844 #ifdef CONFIG_DECODERS
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
845 /*
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
846 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
847 * Uninit lcl decoder
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
848 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
849 */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
850 static int decode_end(AVCodecContext *avctx)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
851 {
4827
b3ee9a1526b0 Get rid of unnecessary pointer casts.
diego
parents: 4801
diff changeset
852 LclContext * const c = avctx->priv_data;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
853
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
854 if (c->pic.data[0])
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
855 avctx->release_buffer(avctx, &c->pic);
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
856 #ifdef CONFIG_ZLIB
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
857 inflateEnd(&(c->zstream));
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
858 #endif
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
859
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
860 return 0;
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
861 }
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
862 #endif
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
863
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
864 #ifdef CONFIG_ENCODERS
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
865 /*
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
866 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
867 * Uninit lcl encoder
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
868 *
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
869 */
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
870 static int encode_end(AVCodecContext *avctx)
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
871 {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
872 LclContext *c = avctx->priv_data;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
873
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
874 av_freep(&avctx->extradata);
2248
e4e1b4f31db6 segfault fix by (Kostya <cannonball at bw-team dot com>)
michael
parents: 1744
diff changeset
875 av_freep(&c->comp_buf);
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
876 #ifdef CONFIG_ZLIB
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
877 deflateEnd(&(c->zstream));
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
878 #endif
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
879
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
880 return 0;
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
881 }
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
882 #endif
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
883
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
884 #ifdef CONFIG_MSZH_DECODER
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
885 AVCodec mszh_decoder = {
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
886 "mszh",
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
887 CODEC_TYPE_VIDEO,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
888 CODEC_ID_MSZH,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
889 sizeof(LclContext),
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
890 decode_init,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
891 NULL,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
892 decode_end,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
893 decode_frame,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
894 CODEC_CAP_DR1,
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
895 };
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
896 #endif
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
897
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
898 #ifdef CONFIG_ZLIB_DECODER
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
899 AVCodec zlib_decoder = {
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
900 "zlib",
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
901 CODEC_TYPE_VIDEO,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
902 CODEC_ID_ZLIB,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
903 sizeof(LclContext),
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
904 decode_init,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
905 NULL,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
906 decode_end,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
907 decode_frame,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
908 CODEC_CAP_DR1,
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
909 };
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3036
diff changeset
910 #endif
1743
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
911
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
912 #ifdef CONFIG_ENCODERS
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
913
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
914 AVCodec zlib_encoder = {
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
915 "zlib",
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
916 CODEC_TYPE_VIDEO,
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
917 CODEC_ID_ZLIB,
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
918 sizeof(LclContext),
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
919 encode_init,
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
920 encode_frame,
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
921 encode_end,
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
922 };
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
923
fa06a4a448f7 Fix for older version of zlib
rtognimp
parents:
diff changeset
924 #endif //CONFIG_ENCODERS