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/vp9/decode.c | |
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/vp9/decode.c')
-rw-r--r-- | modules/vp9/decode.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/modules/vp9/decode.c b/modules/vp9/decode.c index 84f0d49..f69b240 100644 --- a/modules/vp9/decode.c +++ b/modules/vp9/decode.c @@ -164,6 +164,24 @@ static inline int hdr_decode(struct hdr *hdr, struct mbuf *mb) } +static inline bool is_keyframe(const struct mbuf *mb) +{ + vpx_codec_stream_info_t si; + vpx_codec_err_t ret; + + memset(&si, 0, sizeof(si)); + si.sz = sizeof(si); + + ret = vpx_codec_peek_stream_info(&vpx_codec_vp9_dx_algo, + mbuf_buf(mb), + (unsigned int)mbuf_get_left(mb), &si); + if (ret != VPX_CODEC_OK) + return false; + + return si.is_kf; +} + + static inline int16_t seq_diff(uint16_t x, uint16_t y) { return (int16_t)(y - x); @@ -171,7 +189,7 @@ static inline int16_t seq_diff(uint16_t x, uint16_t y) int vp9_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; @@ -179,9 +197,11 @@ int vp9_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; + vds->n_bytes += mbuf_get_left(mb); err = hdr_decode(&hdr, mb); @@ -195,6 +215,9 @@ int vp9_decode(struct viddec_state *vds, struct vidframe *frame, if (hdr.b) { + if (is_keyframe(mb)) + *intra = true; + mbuf_rewind(vds->mb); vds->started = true; } |