diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-02-24 03:30:42 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-02-24 03:30:42 +0100 |
commit | 131698af55bef251f07e8f7499213001515458ef (patch) | |
tree | 64a65c26d3c9cfbc752a552af22c11dc1686a2f5 | |
parent | e2cc39b6096ed4353293252e3955417b7766f161 (diff) | |
download | ffmpeg-131698af55bef251f07e8f7499213001515458ef.tar.gz |
flashsv2enc: switch to encode2()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/flashsv2enc.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c index 6466be7858..8efdb46921 100644 --- a/libavcodec/flashsv2enc.c +++ b/libavcodec/flashsv2enc.c @@ -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"), |