diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/video_decode.c | 14 | ||||
-rw-r--r-- | 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 <stdint.h> -struct video_decode; +struct video_decode { + int64_t duration; +}; struct video_frame { uint8_t *data; int width, height, stride; |