diff options
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; } |