diff --git a/ext-codec/VP8.h b/ext-codec/VP8.h index 10009456..9273c618 100644 --- a/ext-codec/VP8.h +++ b/ext-codec/VP8.h @@ -20,7 +20,11 @@ public: bool keyFrame() const override { auto ptr = (uint8_t *) this->data() + this->prefixSize(); - return !(*ptr & 0x01); + int size = this->size() - this->prefixSize(); + if (size < 10) { + return false; + } + return !(*ptr & 0x01) && ptr[3] == 0x9D && ptr[4] == 0x01 && ptr[5] == 0x2A; } bool configFrame() const override { return false; } bool dropAble() const override { return false; } diff --git a/ext-codec/VP9.h b/ext-codec/VP9.h index c99cd70f..c9d06a89 100644 --- a/ext-codec/VP9.h +++ b/ext-codec/VP9.h @@ -20,7 +20,11 @@ public: bool keyFrame() const override { auto ptr = (uint8_t *) this->data() + this->prefixSize(); - return (*ptr & 0x80); + int size = this->size() - this->prefixSize(); + if (size < 4) { + return false; + } + return (*ptr & 0xCC) == 0x80 && ptr[1] == 0x49 && ptr[2] == 0x83 && ptr[3] == 0x42; } bool configFrame() const override { return false; } bool dropAble() const override { return false; }