From 51bcb910977c7de70eb59add3c8f7bc3cfce8aa2 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 17 Aug 2016 17:58:53 +0200 Subject: vidcodec: add 'intra' parameter to decoder api - the intra flag must be set to true, if the decoded video frame is a full intra frame (Key frame) - the video decoder can use this flag to cancel sending of FIR packets --- modules/vp8/decode.c | 21 +++++++++++++++++++-- modules/vp8/vp8.h | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'modules/vp8') diff --git a/modules/vp8/decode.c b/modules/vp8/decode.c index 1722eb6..4399c0b 100644 --- a/modules/vp8/decode.c +++ b/modules/vp8/decode.c @@ -173,6 +173,18 @@ static inline int hdr_decode(struct hdr *hdr, struct mbuf *mb) } +static inline bool is_keyframe(struct mbuf *mb) +{ + if (mbuf_get_left(mb) < 1) + return false; + + if (mb->buf[mb->pos] & 0x01) + return false; + + return true; +} + + static inline int16_t seq_diff(uint16_t x, uint16_t y) { return (int16_t)(y - x); @@ -180,7 +192,7 @@ static inline int16_t seq_diff(uint16_t x, uint16_t y) int vp8_decode(struct viddec_state *vds, struct vidframe *frame, - bool marker, uint16_t seq, struct mbuf *mb) + bool *intra, bool marker, uint16_t seq, struct mbuf *mb) { vpx_codec_iter_t iter = NULL; vpx_codec_err_t res; @@ -188,9 +200,11 @@ int vp8_decode(struct viddec_state *vds, struct vidframe *frame, struct hdr hdr; int err, i; - if (!vds || !frame || !mb) + if (!vds || !frame || !intra || !mb) return EINVAL; + *intra = false; + err = hdr_decode(&hdr, mb); if (err) return err; @@ -206,6 +220,9 @@ int vp8_decode(struct viddec_state *vds, struct vidframe *frame, if (hdr.start && hdr.partid == 0) { + if (is_keyframe(mb)) + *intra = true; + mbuf_rewind(vds->mb); vds->started = true; } diff --git a/modules/vp8/vp8.h b/modules/vp8/vp8.h index 934e3ee..c0e262a 100644 --- a/modules/vp8/vp8.h +++ b/modules/vp8/vp8.h @@ -21,7 +21,7 @@ int vp8_encode(struct videnc_state *ves, bool update, int vp8_decode_update(struct viddec_state **vdsp, const struct vidcodec *vc, const char *fmtp); int vp8_decode(struct viddec_state *vds, struct vidframe *frame, - bool marker, uint16_t seq, struct mbuf *mb); + bool *intra, bool marker, uint16_t seq, struct mbuf *mb); /* SDP */ -- cgit v1.2.3