Commit 131698af authored by Michael Niedermayer's avatar Michael Niedermayer

flashsv2enc: switch to encode2()

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent e2cc39b6
......@@ -823,17 +823,22 @@ static int reconfigure_at_keyframe(FlashSV2Context * s, const uint8_t * image,
return 0;
}
static int flashsv2_encode_frame(AVCodecContext * avctx, uint8_t * buf,
int buf_size, void *data)
static int flashsv2_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
FlashSV2Context *const s = avctx->priv_data;
AVFrame *pict = data;
AVFrame *const p = &s->frame;
int res;
int keyframe = 0;
*p = *pict;
if (!pkt->data &&
(res = av_new_packet(pkt, s->frame_size + FF_MIN_BUFFER_SIZE)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
return res;
}
/* First frame needs to be a keyframe */
if (avctx->frame_number == 0)
keyframe = 1;
......@@ -844,12 +849,6 @@ static int flashsv2_encode_frame(AVCodecContext * avctx, uint8_t * buf,
keyframe = 1;
}
if (buf_size < s->frame_size) {
//Conservative upper bound check for compressed data
av_log(avctx, AV_LOG_ERROR, "buf_size %d < %d\n", buf_size, s->frame_size);
return -1;
}
if (!keyframe
&& avctx->frame_number > s->last_key_frame + avctx->keyint_min) {
recommend_keyframe(s, &keyframe);
......@@ -866,13 +865,14 @@ static int flashsv2_encode_frame(AVCodecContext * avctx, uint8_t * buf,
if (s->use15_7)
s->dist = optimum_dist(s);
res = write_bitstream(s, p->data[0], p->linesize[0], buf, buf_size, keyframe);
res = write_bitstream(s, p->data[0], p->linesize[0], pkt->data, pkt->size, keyframe);
if (keyframe) {
new_key_frame(s);
p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1;
s->last_key_frame = avctx->frame_number;
pkt->flags |= AV_PKT_FLAG_KEY;
av_log(avctx, AV_LOG_DEBUG, "Inserting key frame at frame %d\n", avctx->frame_number);
} else {
p->pict_type = AV_PICTURE_TYPE_P;
......@@ -881,7 +881,10 @@ static int flashsv2_encode_frame(AVCodecContext * avctx, uint8_t * buf,
avctx->coded_frame = p;
return res;
pkt->size = res;
*got_packet = 1;
return 0;
}
static av_cold int flashsv2_encode_end(AVCodecContext * avctx)
......@@ -899,7 +902,7 @@ AVCodec ff_flashsv2_encoder = {
.id = CODEC_ID_FLASHSV2,
.priv_data_size = sizeof(FlashSV2Context),
.init = flashsv2_encode_init,
.encode = flashsv2_encode_frame,
.encode2 = flashsv2_encode_frame,
.close = flashsv2_encode_end,
.pix_fmts = (enum PixelFormat[]) {PIX_FMT_BGR24, PIX_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("Flash Screen Video Version 2"),
......
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