comparison flashsvenc.c @ 4651:ff9749708137 libavcodec

Respect the gop size (-g) for marking I frames. Use -g 0 gives the old behaviour.
author banan
date Sun, 11 Mar 2007 21:01:33 +0000
parents 414d484f6483
children b3ee9a1526b0
comparison
equal deleted inserted replaced
4650:31bf54d9353d 4651:ff9749708137
72 int block_width, block_height; 72 int block_width, block_height;
73 uint8_t* tmpblock; 73 uint8_t* tmpblock;
74 uint8_t* encbuffer; 74 uint8_t* encbuffer;
75 int block_size; 75 int block_size;
76 z_stream zstream; 76 z_stream zstream;
77 int last_key_frame;
77 } FlashSVContext; 78 } FlashSVContext;
78 79
79 static int copy_region_enc(uint8_t *sptr, uint8_t *dptr, 80 static int copy_region_enc(uint8_t *sptr, uint8_t *dptr,
80 int dx, int dy, int h, int w, int stride, uint8_t *pfptr) { 81 int dx, int dy, int h, int w, int stride, uint8_t *pfptr) {
81 int i,j; 82 int i,j;
122 if (zret != Z_OK) { 123 if (zret != Z_OK) {
123 av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret); 124 av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
124 return -1; 125 return -1;
125 } 126 }
126 */ 127 */
128
129 s->last_key_frame=0;
127 130
128 s->image_width = avctx->width; 131 s->image_width = avctx->width;
129 s->image_height = avctx->height; 132 s->image_height = avctx->height;
130 133
131 s->tmpblock = av_mallocz(3*256*256); 134 s->tmpblock = av_mallocz(3*256*256);
236 int I_frame = 0; 239 int I_frame = 0;
237 int opt_w, opt_h; 240 int opt_w, opt_h;
238 241
239 *p = *pict; 242 *p = *pict;
240 243
244 /* First frame needs to be a keyframe */
241 if (avctx->frame_number == 0) { 245 if (avctx->frame_number == 0) {
242 s->previous_frame = av_mallocz(p->linesize[0]*s->image_height); 246 s->previous_frame = av_mallocz(p->linesize[0]*s->image_height);
243 if (!s->previous_frame) { 247 if (!s->previous_frame) {
244 av_log(avctx, AV_LOG_ERROR, "Memory allocation failed.\n"); 248 av_log(avctx, AV_LOG_ERROR, "Memory allocation failed.\n");
245 return -1; 249 return -1;
246 } 250 }
247 I_frame = 1; 251 I_frame = 1;
252 }
253
254 /* Check the placement of keyframes */
255 if (avctx->gop_size > 0) {
256 if (avctx->frame_number >= s->last_key_frame + avctx->gop_size) {
257 I_frame = 1;
258 }
248 } 259 }
249 260
250 #if 0 261 #if 0
251 int w, h; 262 int w, h;
252 int optim_sizes[16][16]; 263 int optim_sizes[16][16];
295 306
296 //mark the frame type so the muxer can mux it correctly 307 //mark the frame type so the muxer can mux it correctly
297 if (I_frame) { 308 if (I_frame) {
298 p->pict_type = FF_I_TYPE; 309 p->pict_type = FF_I_TYPE;
299 p->key_frame = 1; 310 p->key_frame = 1;
311 s->last_key_frame = avctx->frame_number;
312 av_log(avctx, AV_LOG_DEBUG, "Inserting key frame at frame %d\n",avctx->frame_number);
300 } else { 313 } else {
301 p->pict_type = FF_P_TYPE; 314 p->pict_type = FF_P_TYPE;
302 p->key_frame = 0; 315 p->key_frame = 0;
303 } 316 }
304 317