annotate lcl.c @ 4191:c9867abab7e6 libavcodec

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