summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2013-01-31 15:25:59 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2013-01-31 17:11:33 +0100
commit80924a0068db59c7e114992869766b1a4c543cac (patch)
tree4b48c28f5ce963ecbbd08cd9e09043d94bfe358b
parent8bdae5adf908b361447d337cf632f66a3818711c (diff)
downloadadvtime-80924a0068db59c7e114992869766b1a4c543cac.tar.gz
advtime-80924a0068db59c7e114992869766b1a4c543cac.tar.bz2
advtime-80924a0068db59c7e114992869766b1a4c543cac.zip
video-decode: Add duration to struct video_decode
-rw-r--r--src/video_decode.c14
-rw-r--r--src/video_decode.h4
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 <stdint.h>
-struct video_decode;
+struct video_decode {
+ int64_t duration;
+};
struct video_frame {
uint8_t *data;
int width, height, stride;