summaryrefslogtreecommitdiff
path: root/libavcodec/flashsvenc.c
diff options
context:
space:
mode:
authorBenjamin Larsson <banan@ludd.ltu.se>2007-03-11 21:01:33 +0000
committerBenjamin Larsson <banan@ludd.ltu.se>2007-03-11 21:01:33 +0000
commit8736d68a80f2ba1bb034b0ad67575d3a7e477cb7 (patch)
treeb26e6f2d2425f32b1c9874985da4bcfb358a7ce1 /libavcodec/flashsvenc.c
parente7485bf378cb2589b72202aae6a96c8ab715dc41 (diff)
Respect the gop size (-g) for marking I frames. Use -g 0 gives the old behaviour.
Originally committed as revision 8326 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/flashsvenc.c')
-rw-r--r--libavcodec/flashsvenc.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c
index be07c65b48..cbf4883288 100644
--- a/libavcodec/flashsvenc.c
+++ b/libavcodec/flashsvenc.c
@@ -74,6 +74,7 @@ typedef struct FlashSVContext {
uint8_t* encbuffer;
int block_size;
z_stream zstream;
+ int last_key_frame;
} FlashSVContext;
static int copy_region_enc(uint8_t *sptr, uint8_t *dptr,
@@ -125,6 +126,8 @@ static int flashsv_encode_init(AVCodecContext *avctx)
}
*/
+ s->last_key_frame=0;
+
s->image_width = avctx->width;
s->image_height = avctx->height;
@@ -238,6 +241,7 @@ static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_siz
*p = *pict;
+ /* First frame needs to be a keyframe */
if (avctx->frame_number == 0) {
s->previous_frame = av_mallocz(p->linesize[0]*s->image_height);
if (!s->previous_frame) {
@@ -247,6 +251,13 @@ static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_siz
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
int w, h;
int optim_sizes[16][16];
@@ -297,6 +308,8 @@ static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_siz
if (I_frame) {
p->pict_type = FF_I_TYPE;
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 {
p->pict_type = FF_P_TYPE;
p->key_frame = 0;