Mercurial > libavcodec.hg
comparison flashsvenc.c @ 5016:3674582fb4e7 libavcodec
Remove lots of unused commented code. (Cleanup)
author | banan |
---|---|
date | Thu, 17 May 2007 07:50:08 +0000 |
parents | c9b17d87df0a |
children | 1eebbc25db1f |
comparison
equal
deleted
inserted
replaced
5015:c9b17d87df0a | 5016:3674582fb4e7 |
---|---|
112 return -1; | 112 return -1; |
113 } | 113 } |
114 | 114 |
115 // Needed if zlib unused or init aborted before deflateInit | 115 // Needed if zlib unused or init aborted before deflateInit |
116 memset(&(s->zstream), 0, sizeof(z_stream)); | 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 s->last_key_frame=0; | 118 s->last_key_frame=0; |
129 | 119 |
130 s->image_width = avctx->width; | 120 s->image_width = avctx->width; |
131 s->image_height = avctx->height; | 121 s->image_height = avctx->height; |
191 | 181 |
192 | 182 |
193 //ret = deflateReset(&(s->zstream)); | 183 //ret = deflateReset(&(s->zstream)); |
194 if (ret != Z_OK) | 184 if (ret != Z_OK) |
195 av_log(s->avctx, AV_LOG_ERROR, "error while compressing block %dx%d\n", i, j); | 185 av_log(s->avctx, AV_LOG_ERROR, "error while compressing block %dx%d\n", i, j); |
196 /* | 186 |
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 | |
209 size = s->zstream.total_out; | |
210 //av_log(avctx, AV_LOG_INFO, "compressed blocks: %d\n", size); | |
211 */ | |
212 bytestream_put_be16(&ptr,(unsigned int)zsize); | 187 bytestream_put_be16(&ptr,(unsigned int)zsize); |
213 buf_pos += zsize+2; | 188 buf_pos += zsize+2; |
214 //av_log(avctx, AV_LOG_ERROR, "buf_pos = %d\n", buf_pos); | 189 //av_log(avctx, AV_LOG_ERROR, "buf_pos = %d\n", buf_pos); |
215 } else { | 190 } else { |
216 pred_blocks++; | 191 pred_blocks++; |
261 if (avctx->frame_number >= s->last_key_frame + avctx->gop_size) { | 236 if (avctx->frame_number >= s->last_key_frame + avctx->gop_size) { |
262 I_frame = 1; | 237 I_frame = 1; |
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 opt_w=4; | 241 opt_w=4; |
299 opt_h=4; | 242 opt_h=4; |
300 | 243 |
301 if (buf_size < s->image_width*s->image_height*3) { | 244 if (buf_size < s->image_width*s->image_height*3) { |
302 //Conservative upper bound check for compressed data | 245 //Conservative upper bound check for compressed data |
303 av_log(avctx, AV_LOG_ERROR, "buf_size %d < %d\n", buf_size, s->image_width*s->image_height*3); | 246 av_log(avctx, AV_LOG_ERROR, "buf_size %d < %d\n", buf_size, s->image_width*s->image_height*3); |
304 return -1; | 247 return -1; |
305 } | 248 } |
306 | 249 |
307 res = encode_bitstream(s, p, buf, buf_size, opt_w*16, opt_h*16, pfptr, &I_frame); | 250 res = encode_bitstream(s, p, buf, buf_size, opt_w*16, opt_h*16, pfptr, &I_frame); |
308 #endif | 251 |
309 //save the current frame | 252 //save the current frame |
310 if(p->linesize[0] > 0) | 253 if(p->linesize[0] > 0) |
311 memcpy(s->previous_frame, p->data[0], s->image_height*p->linesize[0]); | 254 memcpy(s->previous_frame, p->data[0], s->image_height*p->linesize[0]); |
312 else | 255 else |
313 memcpy(s->previous_frame, p->data[0] + p->linesize[0] * (s->image_height-1), s->image_height*abs(p->linesize[0])); | 256 memcpy(s->previous_frame, p->data[0] + p->linesize[0] * (s->image_height-1), s->image_height*abs(p->linesize[0])); |