comparison lcldec.c @ 9757:8e4d442554b3 libavcodec

Use FFMIN
author reimar
date Sun, 31 May 2009 09:57:42 +0000
parents ed55b61c8e45
children 8ebcc162db3d
comparison
equal deleted inserted replaced
9756:ed55b61c8e45 9757:8e4d442554b3
189 switch (c->compression) { 189 switch (c->compression) {
190 case COMP_MSZH: 190 case COMP_MSZH:
191 if (c->flags & FLAG_MULTITHREAD) { 191 if (c->flags & FLAG_MULTITHREAD) {
192 mthread_inlen = *(unsigned int*)encoded; 192 mthread_inlen = *(unsigned int*)encoded;
193 mthread_outlen = *(unsigned int*)(encoded+4); 193 mthread_outlen = *(unsigned int*)(encoded+4);
194 if (mthread_outlen > c->decomp_size) // this should not happen 194 mthread_outlen = FFMIN(mthread_outlen, c->decomp_size);
195 mthread_outlen = c->decomp_size;
196 mszh_dlen = mszh_decomp(encoded + 8, mthread_inlen, c->decomp_buf, c->decomp_size); 195 mszh_dlen = mszh_decomp(encoded + 8, mthread_inlen, c->decomp_buf, c->decomp_size);
197 if (mthread_outlen != mszh_dlen) { 196 if (mthread_outlen != mszh_dlen) {
198 av_log(avctx, AV_LOG_ERROR, "Mthread1 decoded size differs (%d != %d)\n", 197 av_log(avctx, AV_LOG_ERROR, "Mthread1 decoded size differs (%d != %d)\n",
199 mthread_outlen, mszh_dlen); 198 mthread_outlen, mszh_dlen);
200 return -1; 199 return -1;
236 break; 235 break;
237 if (c->flags & FLAG_MULTITHREAD) { 236 if (c->flags & FLAG_MULTITHREAD) {
238 int ret; 237 int ret;
239 mthread_inlen = *(unsigned int*)encoded; 238 mthread_inlen = *(unsigned int*)encoded;
240 mthread_outlen = *(unsigned int*)(encoded+4); 239 mthread_outlen = *(unsigned int*)(encoded+4);
241 if (mthread_outlen > c->decomp_size) 240 mthread_outlen = FFMIN(mthread_outlen, c->decomp_size);
242 mthread_outlen = c->decomp_size;
243 ret = zlib_decomp(avctx, encoded + 8, mthread_inlen, 0, mthread_outlen); 241 ret = zlib_decomp(avctx, encoded + 8, mthread_inlen, 0, mthread_outlen);
244 if (ret < 0) return ret; 242 if (ret < 0) return ret;
245 ret = zlib_decomp(avctx, encoded + 8 + mthread_inlen, len - mthread_inlen, 243 ret = zlib_decomp(avctx, encoded + 8 + mthread_inlen, len - mthread_inlen,
246 mthread_outlen, mthread_outlen); 244 mthread_outlen, mthread_outlen);
247 if (ret < 0) return ret; 245 if (ret < 0) return ret;