diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-11-21 21:34:46 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2013-03-08 07:38:30 +0100 |
commit | 759001c534287a96dc96d1e274665feb7059145d (patch) | |
tree | 6ace9560c20aa30db92067c5b45d7bd86e458d10 /libavcodec/roqvideoenc.c | |
parent | 6e7b50b4270116ded8b874d76cb7c5b1a0341827 (diff) | |
download | ffmpeg-759001c534287a96dc96d1e274665feb7059145d.tar.gz |
lavc decoders: work with refcounted frames.
Diffstat (limited to 'libavcodec/roqvideoenc.c')
-rw-r--r-- | libavcodec/roqvideoenc.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c index 192f1eb6a3..636418a5d9 100644 --- a/libavcodec/roqvideoenc.c +++ b/libavcodec/roqvideoenc.c @@ -936,6 +936,22 @@ static void roq_encode_video(RoqContext *enc) enc->framesSinceKeyframe++; } +static int roq_encode_end(AVCodecContext *avctx) +{ + RoqContext *enc = avctx->priv_data; + + av_frame_free(&enc->current_frame); + av_frame_free(&enc->last_frame); + + av_free(enc->tmpData); + av_free(enc->this_motion4); + av_free(enc->last_motion4); + av_free(enc->this_motion8); + av_free(enc->last_motion8); + + return 0; +} + static int roq_encode_init(AVCodecContext *avctx) { RoqContext *enc = avctx->priv_data; @@ -957,8 +973,12 @@ static int roq_encode_init(AVCodecContext *avctx) enc->framesSinceKeyframe = 0; enc->first_frame = 1; - enc->last_frame = &enc->frames[0]; - enc->current_frame = &enc->frames[1]; + enc->last_frame = av_frame_alloc(); + enc->current_frame = av_frame_alloc(); + if (!enc->last_frame || !enc->current_frame) { + roq_encode_end(avctx); + return AVERROR(ENOMEM); + } enc->tmpData = av_malloc(sizeof(RoqTempdata)); @@ -1033,8 +1053,8 @@ static int roq_encode_frame(AVCodecContext *avctx, AVPacket *pkt, if (enc->first_frame) { /* Alloc memory for the reconstruction data (we must know the stride for that) */ - if (ff_get_buffer(avctx, enc->current_frame) || - ff_get_buffer(avctx, enc->last_frame)) { + if (ff_get_buffer(avctx, enc->current_frame, 0) || + ff_get_buffer(avctx, enc->last_frame, 0)) { av_log(avctx, AV_LOG_ERROR, " RoQ: get_buffer() failed\n"); return -1; } @@ -1056,22 +1076,6 @@ static int roq_encode_frame(AVCodecContext *avctx, AVPacket *pkt, return 0; } -static int roq_encode_end(AVCodecContext *avctx) -{ - RoqContext *enc = avctx->priv_data; - - avctx->release_buffer(avctx, enc->last_frame); - avctx->release_buffer(avctx, enc->current_frame); - - av_free(enc->tmpData); - av_free(enc->this_motion4); - av_free(enc->last_motion4); - av_free(enc->this_motion8); - av_free(enc->last_motion8); - - return 0; -} - AVCodec ff_roq_encoder = { .name = "roqvideo", .type = AVMEDIA_TYPE_VIDEO, |