diff options
author | Alfred E. Heggestad <aeh@db.org> | 2016-08-17 17:58:53 +0200 |
---|---|---|
committer | Alfred E. Heggestad <aeh@db.org> | 2016-08-17 17:58:53 +0200 |
commit | 51bcb910977c7de70eb59add3c8f7bc3cfce8aa2 (patch) | |
tree | 9d710f86d5c631accf80ab2f5e84ea0c72305e9b /modules/vp8 | |
parent | a8352d927271b380cb9f9e486b25a504fd61cf0a (diff) |
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
Diffstat (limited to 'modules/vp8')
-rw-r--r-- | modules/vp8/decode.c | 21 | ||||
-rw-r--r-- | modules/vp8/vp8.h | 2 |
2 files changed, 20 insertions, 3 deletions
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 */ |