diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-01-29 16:10:55 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-01-29 16:34:07 +0100 |
commit | 181663291357bfad4d1e630f3c5932847a2a0520 (patch) | |
tree | ef47e9b364e163341216a0c837069b8be8e27db5 /src/video_decode.c | |
parent | 87e95e6868580df0ba9e1ba97b3f1d4dd66f7b9c (diff) | |
download | advtime-181663291357bfad4d1e630f3c5932847a2a0520.tar.gz advtime-181663291357bfad4d1e630f3c5932847a2a0520.tar.bz2 advtime-181663291357bfad4d1e630f3c5932847a2a0520.zip |
video-decode: Allow reusing an old frame
Diffstat (limited to 'src/video_decode.c')
-rw-r--r-- | src/video_decode.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/video_decode.c b/src/video_decode.c index 993fd14..e6748e0 100644 --- a/src/video_decode.c +++ b/src/video_decode.c @@ -97,9 +97,14 @@ video_decode_get_frame(struct video_decode *vd, struct video_frame **frame) int decoded, got_picture; int ret; - f = calloc(1, sizeof *f); - if (f == NULL) - return -1; + if (*frame != NULL) { + f = *frame; + } else { + f = calloc(1, sizeof *f); + if (f == NULL) + return -1; + f->frame = avcodec_alloc_frame(); + } packet.data = NULL; do { @@ -122,8 +127,6 @@ video_decode_get_frame(struct video_decode *vd, struct video_frame **frame) } } while (packet.stream_index != vd->stream); - f->frame = avcodec_alloc_frame(); - do { #if DEBUG printf("packet.data: %p, packet.siz: %d, packet.strm_idx: %d\n", @@ -150,7 +153,8 @@ video_decode_get_frame(struct video_decode *vd, struct video_frame **frame) f->base.height = vd->codec_ctx->height; f->base.stride = f->frame->linesize[0]; - *frame = &f->base; + if (*frame == NULL) + *frame = &f->base; return 1; } |