Bug 1228601 - [Part1] Store only supported video rotation informatin into VideoInfo.; r=mattwoodrow

MozReview-Commit-ID: GF1PpJGkGyA

--HG--
extra : transplant_source : %C5%FF%EB%29j%E2T_h%AC%22%8Ey%E0%91%C6%7Dh%1C%09
This commit is contained in:
Kilik Kuo 2016-05-13 02:17:39 +08:00
Родитель 668477329c
Коммит b0d32a9fb5
2 изменённых файлов: 28 добавлений и 0 удалений

Просмотреть файл

@ -177,6 +177,12 @@ private:
// Stores info relevant to presenting media frames.
class VideoInfo : public TrackInfo {
public:
enum Rotation {
kDegree_0 = 0,
kDegree_90 = 90,
kDegree_180 = 180,
kDegree_270 = 270,
};
VideoInfo()
: VideoInfo(-1, -1)
{
@ -190,6 +196,7 @@ public:
, mImage(nsIntSize(aWidth, aHeight))
, mCodecSpecificConfig(new MediaByteBuffer)
, mExtraData(new MediaByteBuffer)
, mRotation(kDegree_0)
, mImageRect(nsIntRect(0, 0, aWidth, aHeight))
{
}
@ -201,6 +208,7 @@ public:
, mImage(aOther.mImage)
, mCodecSpecificConfig(aOther.mCodecSpecificConfig)
, mExtraData(aOther.mExtraData)
, mRotation(aOther.mRotation)
, mImageRect(aOther.mImageRect)
{
}
@ -259,6 +267,21 @@ public:
return imageRect;
}
Rotation ToSupportedRotation(int32_t aDegree)
{
switch (aDegree) {
case 90:
return kDegree_90;
case 180:
return kDegree_180;
case 270:
return kDegree_270;
default:
NS_WARN_IF_FALSE(aDegree == 0, "Invalid rotation degree, ignored");
return kDegree_0;
}
}
// Size in pixels at which the video is rendered. This is after it has
// been scaled by its aspect ratio.
nsIntSize mDisplay;
@ -272,6 +295,10 @@ public:
RefPtr<MediaByteBuffer> mCodecSpecificConfig;
RefPtr<MediaByteBuffer> mExtraData;
// Describing how many degrees video frames should be rotated in clock-wise to
// get correct view.
Rotation mRotation;
private:
// mImage may be cropped; currently only used with the WebM container.
// A negative width or height indicate that no cropping is to occur.

Просмотреть файл

@ -164,6 +164,7 @@ MP4VideoInfo::Update(const MetaData* aMetaData, const char* aMimeType)
mDisplay.height = FindInt32(aMetaData, kKeyDisplayHeight);
mImage.width = FindInt32(aMetaData, kKeyWidth);
mImage.height = FindInt32(aMetaData, kKeyHeight);
mRotation = VideoInfo::ToSupportedRotation(FindInt32(aMetaData, kKeyRotation));
FindData(aMetaData, kKeyAVCC, mExtraData);
if (!mExtraData->Length()) {