You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-06-14 22:15:12 +02:00
zmbvenc: move header writing to the end of encode_frame().
This makes switching to encode2() simpler, because it allows us to know exactly how large should the output buffer be before we start writing into it.
This commit is contained in:
@ -138,17 +138,6 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size, void
|
|||||||
p->key_frame= keyframe;
|
p->key_frame= keyframe;
|
||||||
chpal = !keyframe && memcmp(p->data[1], c->pal2, 1024);
|
chpal = !keyframe && memcmp(p->data[1], c->pal2, 1024);
|
||||||
|
|
||||||
fl = (keyframe ? ZMBV_KEYFRAME : 0) | (chpal ? ZMBV_DELTAPAL : 0);
|
|
||||||
*buf++ = fl; len++;
|
|
||||||
if(keyframe){
|
|
||||||
deflateReset(&c->zstream);
|
|
||||||
*buf++ = 0; len++; // hi ver
|
|
||||||
*buf++ = 1; len++; // lo ver
|
|
||||||
*buf++ = 1; len++; // comp
|
|
||||||
*buf++ = 4; len++; // format - 8bpp
|
|
||||||
*buf++ = ZMBV_BLOCK; len++; // block width
|
|
||||||
*buf++ = ZMBV_BLOCK; len++; // block height
|
|
||||||
}
|
|
||||||
palptr = (uint32_t*)p->data[1];
|
palptr = (uint32_t*)p->data[1];
|
||||||
src = p->data[0];
|
src = p->data[0];
|
||||||
prev = c->prev;
|
prev = c->prev;
|
||||||
@ -223,6 +212,9 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size, void
|
|||||||
src += p->linesize[0];
|
src += p->linesize[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (keyframe)
|
||||||
|
deflateReset(&c->zstream);
|
||||||
|
|
||||||
c->zstream.next_in = c->work_buf;
|
c->zstream.next_in = c->work_buf;
|
||||||
c->zstream.avail_in = work_size;
|
c->zstream.avail_in = work_size;
|
||||||
c->zstream.total_in = 0;
|
c->zstream.total_in = 0;
|
||||||
@ -235,6 +227,16 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size, void
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fl = (keyframe ? ZMBV_KEYFRAME : 0) | (chpal ? ZMBV_DELTAPAL : 0);
|
||||||
|
*buf++ = fl; len++;
|
||||||
|
if (keyframe) {
|
||||||
|
*buf++ = 0; len++; // hi ver
|
||||||
|
*buf++ = 1; len++; // lo ver
|
||||||
|
*buf++ = 1; len++; // comp
|
||||||
|
*buf++ = 4; len++; // format - 8bpp
|
||||||
|
*buf++ = ZMBV_BLOCK; len++; // block width
|
||||||
|
*buf++ = ZMBV_BLOCK; len++; // block height
|
||||||
|
}
|
||||||
memcpy(buf, c->comp_buf, c->zstream.total_out);
|
memcpy(buf, c->comp_buf, c->zstream.total_out);
|
||||||
return len + c->zstream.total_out;
|
return len + c->zstream.total_out;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user