From 80924a0068db59c7e114992869766b1a4c543cac Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Thu, 31 Jan 2013 15:25:59 +0100 Subject: video-decode: Add duration to struct video_decode --- src/video_decode.c | 14 +++++++++----- src/video_decode.h | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/video_decode.c b/src/video_decode.c index 955cd5d..ea23aea 100644 --- a/src/video_decode.c +++ b/src/video_decode.c @@ -15,7 +15,8 @@ struct video_frame_priv { AVFrame *frame; }; -struct video_decode { +struct video_decode_priv { + struct video_decode base; AVFormatContext *fmt_ctx; AVCodecContext *codec_ctx; AVCodec *codec; @@ -25,7 +26,7 @@ struct video_decode { int video_decode_init(struct video_decode **vd_out, char *file, int64_t ts) { - struct video_decode *vd; + struct video_decode_priv *vd; vd = calloc(1, sizeof *vd); if (vd == NULL) @@ -77,14 +78,16 @@ video_decode_init(struct video_decode **vd_out, char *file, int64_t ts) return -5; } - *vd_out = vd; + vd->base.duration = vd->fmt_ctx->streams[vd->stream]->duration; + + *vd_out = &vd->base; return 0; } void video_decode_uninit(struct video_decode **_vd) { - struct video_decode *vd = *_vd; + struct video_decode_priv *vd = (struct video_decode_priv *) *_vd; *_vd = NULL; avcodec_close(vd->codec_ctx); @@ -97,8 +100,9 @@ video_decode_uninit(struct video_decode **_vd) } int -video_decode_get_frame(struct video_decode *vd, struct video_frame **frame) +video_decode_get_frame(struct video_decode *_vd, struct video_frame **frame) { + struct video_decode_priv *vd = (struct video_decode_priv *) _vd; struct video_frame_priv *f; AVPacket packet; int decoded, got_picture; diff --git a/src/video_decode.h b/src/video_decode.h index 40d2587..3261b76 100644 --- a/src/video_decode.h +++ b/src/video_decode.h @@ -3,7 +3,9 @@ #include -struct video_decode; +struct video_decode { + int64_t duration; +}; struct video_frame { uint8_t *data; int width, height, stride; -- cgit