Commit fc6664de authored by banan's avatar banan

Respect the gop size (-g) for marking I frames. Use -g 0 gives the old behaviour.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@8326 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent fce982be
...@@ -74,6 +74,7 @@ typedef struct FlashSVContext { ...@@ -74,6 +74,7 @@ typedef struct FlashSVContext {
uint8_t* encbuffer; uint8_t* encbuffer;
int block_size; int block_size;
z_stream zstream; z_stream zstream;
int last_key_frame;
} FlashSVContext; } FlashSVContext;
static int copy_region_enc(uint8_t *sptr, uint8_t *dptr, static int copy_region_enc(uint8_t *sptr, uint8_t *dptr,
...@@ -125,6 +126,8 @@ static int flashsv_encode_init(AVCodecContext *avctx) ...@@ -125,6 +126,8 @@ static int flashsv_encode_init(AVCodecContext *avctx)
} }
*/ */
s->last_key_frame=0;
s->image_width = avctx->width; s->image_width = avctx->width;
s->image_height = avctx->height; s->image_height = avctx->height;
...@@ -238,6 +241,7 @@ static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_siz ...@@ -238,6 +241,7 @@ static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_siz
*p = *pict; *p = *pict;
/* First frame needs to be a keyframe */
if (avctx->frame_number == 0) { if (avctx->frame_number == 0) {
s->previous_frame = av_mallocz(p->linesize[0]*s->image_height); s->previous_frame = av_mallocz(p->linesize[0]*s->image_height);
if (!s->previous_frame) { if (!s->previous_frame) {
...@@ -247,6 +251,13 @@ static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_siz ...@@ -247,6 +251,13 @@ static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_siz
I_frame = 1; I_frame = 1;
} }
/* Check the placement of keyframes */
if (avctx->gop_size > 0) {
if (avctx->frame_number >= s->last_key_frame + avctx->gop_size) {
I_frame = 1;
}
}
#if 0 #if 0
int w, h; int w, h;
int optim_sizes[16][16]; int optim_sizes[16][16];
...@@ -297,6 +308,8 @@ static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_siz ...@@ -297,6 +308,8 @@ static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_siz
if (I_frame) { if (I_frame) {
p->pict_type = FF_I_TYPE; p->pict_type = FF_I_TYPE;
p->key_frame = 1; p->key_frame = 1;
s->last_key_frame = avctx->frame_number;
av_log(avctx, AV_LOG_DEBUG, "Inserting key frame at frame %d\n",avctx->frame_number);
} else { } else {
p->pict_type = FF_P_TYPE; p->pict_type = FF_P_TYPE;
p->key_frame = 0; p->key_frame = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment