зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1322234 - P3. Add method to read a VP9 profile from a VP9 bitstream r=TD-Linux
Depends on D7616 Differential Revision: https://phabricator.services.mozilla.com/D7647 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
6c63270a37
Коммит
c0ac48ee0c
|
@ -5,6 +5,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "VPXDecoder.h"
|
||||
#include "BitReader.h"
|
||||
#include "TimeUnits.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "mozilla/PodOperations.h"
|
||||
|
@ -337,5 +338,33 @@ VPXDecoder::GetFrameSize(Span<const uint8_t> aBuffer, Codec aCodec)
|
|||
|
||||
return gfx::IntSize(si.w, si.h);
|
||||
}
|
||||
|
||||
/* static */
|
||||
int
|
||||
VPXDecoder::GetVP9Profile(Span<const uint8_t> aBuffer)
|
||||
{
|
||||
if (aBuffer.Length() < 2) {
|
||||
// Can't be good.
|
||||
return -1;
|
||||
}
|
||||
BitReader br(aBuffer.Elements(), aBuffer.Length() * 8);
|
||||
|
||||
uint32_t frameMarker = br.ReadBits(2); // frame_marker
|
||||
if (frameMarker != 2) {
|
||||
// That's not a valid vp9 header.
|
||||
return -1;
|
||||
}
|
||||
uint32_t profile = br.ReadBits(1); // profile_low_bit
|
||||
profile |= br.ReadBits(1) << 1; // profile_high_bit
|
||||
if (profile == 3) {
|
||||
profile += br.ReadBits(1); // reserved_zero
|
||||
if (profile > 3) {
|
||||
// reserved_zero wasn't zero.
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
#undef LOG
|
||||
|
|
|
@ -56,6 +56,10 @@ public:
|
|||
// Return the frame dimensions for a sample for the specified codec.
|
||||
static gfx::IntSize GetFrameSize(Span<const uint8_t> aBuffer, Codec aCodec);
|
||||
|
||||
// Return the VP9 profile as per https://www.webmproject.org/vp9/profiles/
|
||||
// Return negative value if error.
|
||||
static int GetVP9Profile(Span<const uint8_t> aBuffer);
|
||||
|
||||
private:
|
||||
~VPXDecoder();
|
||||
RefPtr<DecodePromise> ProcessDecode(MediaRawData* aSample);
|
||||
|
|
Загрузка…
Ссылка в новой задаче