Revision 54353abe libavcodec/flashsvenc.c

View differences:

libavcodec/flashsvenc.c
114 114

  
115 115
    // Needed if zlib unused or init aborted before deflateInit
116 116
    memset(&(s->zstream), 0, sizeof(z_stream));
117
/*
118
    s->zstream.zalloc = NULL; //av_malloc;
119
    s->zstream.zfree = NULL; //av_free;
120
    s->zstream.opaque = NULL;
121
    zret = deflateInit(&(s->zstream), 9);
122
    if (zret != Z_OK) {
123
        av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
124
        return -1;
125
    }
126
*/
127 117

  
128 118
    s->last_key_frame=0;
129 119

  
......
193 183
                //ret = deflateReset(&(s->zstream));
194 184
                if (ret != Z_OK)
195 185
                    av_log(s->avctx, AV_LOG_ERROR, "error while compressing block %dx%d\n", i, j);
196
                /*
197
                s->zstream.next_in = s->tmpblock;
198
                s->zstream.avail_in = 3*ws*hs;
199
                s->zstream.total_in = 0;
200

  
201
                s->zstream.next_out = ptr+2;
202
                s->zstream.avail_out = buf_size-buf_pos-2;
203
                s->zstream.total_out = 0;
204

  
205
                ret = deflate(&(s->zstream), Z_FINISH);
206
                if ((ret != Z_OK) && (ret != Z_STREAM_END))
207
                    av_log(s->avctx, AV_LOG_ERROR, "error while compressing block %dx%d\n", i, j);
208 186

  
209
                size = s->zstream.total_out;
210
                //av_log(avctx, AV_LOG_INFO, "compressed blocks: %d\n", size);
211
                */
212 187
                bytestream_put_be16(&ptr,(unsigned int)zsize);
213 188
                buf_pos += zsize+2;
214 189
                //av_log(avctx, AV_LOG_ERROR, "buf_pos = %d\n", buf_pos);
......
263 238
        }
264 239
    }
265 240

  
266
#if 0
267
    int w, h;
268
    int optim_sizes[16][16];
269
    int smallest_size;
270
    //Try all possible combinations and store the encoded frame sizes
271
    for (w=1 ; w<17 ; w++) {
272
        for (h=1 ; h<17 ; h++) {
273
            optim_sizes[w-1][h-1] = encode_bitstream(s, p, s->encbuffer, s->image_width*s->image_height*4, w*16, h*16, s->previous_frame);
274
            //av_log(avctx, AV_LOG_ERROR, "[%d][%d]size = %d\n",w,h,optim_sizes[w-1][h-1]);
275
        }
276
    }
277

  
278
    //Search for the smallest framesize and encode the frame with those parameters
279
    smallest_size=optim_sizes[0][0];
280
    opt_w = 0;
281
    opt_h = 0;
282
    for (w=0 ; w<16 ; w++) {
283
        for (h=0 ; h<16 ; h++) {
284
            if (optim_sizes[w][h] < smallest_size) {
285
                smallest_size = optim_sizes[w][h];
286
                opt_w = w;
287
                opt_h = h;
288
            }
289
        }
290
    }
291
    res = encode_bitstream(s, p, buf, buf_size, (opt_w+1)*16, (opt_h+1)*16, s->previous_frame);
292
    av_log(avctx, AV_LOG_ERROR, "[%d][%d]optimal size = %d, res = %d|\n", opt_w, opt_h, smallest_size, res);
293

  
294
    if (buf_size < res)
295
        av_log(avctx, AV_LOG_ERROR, "buf_size %d < res %d\n", buf_size, res);
296

  
297
#else
298 241
    opt_w=4;
299 242
    opt_h=4;
300 243

  
......
305 248
    }
306 249

  
307 250
    res = encode_bitstream(s, p, buf, buf_size, opt_w*16, opt_h*16, pfptr, &I_frame);
308
#endif
251

  
309 252
    //save the current frame
310 253
    if(p->linesize[0] > 0)
311 254
        memcpy(s->previous_frame, p->data[0], s->image_height*p->linesize[0]);

Also available in: Unified diff