Files
palemoon27/dom/media/VideoSegment.cpp
T
roytam1 967126c55b import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1162211 Use sqlite private cache mode in Cache API. r=ehsan (7d91c65569)
- Bug 1220308 Cache API should teardown DOM objects when Worker hits Terminating status. r=baku (a50fd37df1)
- Bug 1144214 - Fix DeleteOrphanedBodyAction so that it doesn't orphan cache files if the action is canceled; r=bkelly (df310a4915)
- Bug 1243849 - Restore support for accessing the Cache API from app://URLs and also for storing requests/responses with app:// URLs within it; r=bkelly (07144da733)
- Bug 1199434 - Fire an event when the print engine encounters an error. r=smaug (e714d1f979)
- Bug 1230092. Make nsIDOMCustomEvent no longer inherit from nsIDOMEvent, so that CustomEvent doesn't end up with multiple inheritance from nsIDOMEvent. r=smaug (cd8e1b5ff5)
- Bug 1177927: Use nsFrameList::GetLength() instead of manual iteration to count pages in nsPrintEngine. r=tn (ddcdde1201)
- Bug 1177927: Use nsFrameList::GetLength() instead of manual iteration to count pages in nsPrintEngine. r=tn (6b8944ab43)
- Bug 1196896 - add CSSLexer.performEOFFixup. r=heycam, r=bz (c5159fc644)
- Bug 1153378 - Move local variable in behind #ifndef MOZILLA_XPCOMRT_API. r=jesup (8e5a9c1c48)
- Bug 1227396: P1. Remove TimestampedMediaByteRange object. r=cpearce (1fae1c62c5)
- Bug 1201404 - Implement minimal gtests to exercise the MPEG4 parser - r=rillian (2a47ebc9e4)
- Bug 1187067 - Added gtests using the bug's test file, running simple checks and many parsing runs to catch parser crashes. r=rillian (71027a9572)
- Bug 1138992: P2. Add gtest. r=kentuckyfriedtakahe (672e0975a1)
- Bug 1200326 - P 1 - Moved test case contents from test source into separate file - r=rillian (e3cdcdd121)
- Bug 1200326 - part 2 - Parse subsets of the input stream - r=rillian (c72577319e)
- Bug 1200326 - p3 - Test case filenames are now in a list, to allow adding more tests - r=rillian (e8a21b4842)
- Bug 1200326 - p4 - Added test case from bug 1200326, with more checks - r=rillian (8befb8260f)
- Bug 1204580 - p1: Added test case files. r=rillian (6573cf686d)
- Bug 1181213 - Added Added mp4 test case to libstagefright gtest - r=rillian (1278f9dc75)
- Bug 1181719 - p1: Added mp4 test case to libstagefright gtest - r=rillian (7ea78da4d9)
- Bug 1181223 - p1: Added mp4 test case to libstagefright gtest - r=rillian (14f0b6c719)
- Bug 1156505 - p1: Added test case file from bug. r=rillian (9d188b3c6a)
- Bug 1181220 - p1: Added mp4 test case to libstagefright gtest - r=rillian (b98029cb8e)
- Bug 1181215 - p1: Added mp4 test case to libstagefright gtest - r=rillian (2c20d374b7)
- Bug 1185230 - p1: Added mp4 test case to libstagefright gtest - r=rillian (e848ebec16)
- Bug 1216748 - p1. Added test case with different 'covr' sizes - r=rillian (1c0097dc85)
- Bug 1224019 - Disable Stagefright subset gtests - r=jya, rs=botond (5ee3e6319c)
- Bug 1227396: P2. Rename some MediaByteRange methods. r=cpearce (3d14aeb56b)
- Bug 1227396: P3. Add IntervalSet::LastInterval method. r=gerald (96b8503a26)
- Bug 1227396: P4. Add IntervalSet::Clear method. r=gerald (460ff0cd8f)
- Bug 1227396: P5. Make Interval::Span ignore empty interval. r=gerald (ba16de0a91)
- Bug 1227396: P6. Replace MediaByteBuffer with Interval<int64_t>. r=cpearce (eed5d5ca5c)
- Bug 1227396: P7. Replace nsTArray<MediaByteRange> with dedicated MediaByteRangeSet object. r=cpearce (ea59b05aea)
- Bug 1188150 - ADTSContainerParser gtest. r=jya (6a4a061647)
- Bug 1227396: P8. Replace MediaByteRange with Interval<int64_t> typedef. r=cpearce (4d3e657b3b)
- Bug 1219047 - Call rust mp4parser with logging. r=kinetik (70abf59813)
- Bug 1220882 - Use LazyLogModule in MP4Metadata. r=kinetik (3443b56be3)
- Bug 1220885 - Add telemetry probe for rust mp4parse success. r=kinetik p=ally (c012bd11bf)
- Bug 1174356 - Add missing MediaData include. r=jya (bfe6182cfe)
- Bug 1227396: P9. Remove unnecessary monitor. r=cpearce (4f156658c4)
- Bug 1227396: P10: Remove stray function definition. r=cpearce (4c1641560c)
- Bug 1227396: P11. Add IntervalSet::operator- operand. r=gerald (b56ceb52f4)
- Bug 1227396: P12. Use MediaByteRangeSet capabilities to filter already processed data. r=cpearce (098d8852d9)
- Bug 1227396: P13. Refactor how MP4 buffered range is calculated. r=cpearce (66711bd76f)
- Bug 1227396: P14. Reduce memory usage of sample index for audio tracks. r=cpearce (e1c36bd791)
- Bug 1197007: Turn off optimization for GMPLoaderImpl::Load. r=cpearce (5df0a365c7)
- Bug 1208892 - Replace the uses of memset to clean up data in GMPLoader::Load with an inline memset; r=cpearce (ce4f3a3a64)
- Bug 1187031: Move back to using USER_LOCKDOWN for the GMP sandbox policy on Windows. r=aklotz (53c39be48d)
- Bug 1214018 - p1: Using vector to pass machine id - r=cpearce (19782ec5b3)
- Bug 1214018 - p2: Import machine_id_mac.cc from Chromium repo - r=cpearce (000d4734ab)
- Bug 1214018 - p3: Modify machine_id_mac for FF build - r=cpearce (41818ddc72)
- Bug 1214018 - p4: Use machine_id_mac in GMPLoader - r=cpearce (4af56e5a6e)
- Bug 1220326 - Wipe stack after Mac node id generation. r=jrmuizel (8c94ddab25)
- Bug 1181718 - Fallible allocation of blank audio data - r=jya (7867407417)
- Bug 1229963 - use UniquePtr<T[]> instead of nsAutoArrayPtr<T> in dom/media/; r=cpearce (796241f002)
- Bug 1229965 - Use MakeUniqueFallible in blank decoder - r=jya (bac70f5c80)
- Bug 1139256 - remove the assertion in AudioStream::GetPositionInFramesUnlocked(). See bug 1139256 comment 4 for the detail. r=kinetik. (6e386c7b00)
- missing bits (1dc7b00da3)
- Bug 1185115: P2. replace all stagefright::Vector with nsTArray. r=kentuckyfriedtakahe (de4e57b4cd)
- Bug 1181223 - p2: Handle wrong saio/saiz size instead of assuming it is correct - r=rillian (59f5afa21f)
- Bug 1138992: P1. Ignore ctts version if we have 0 samples in the table. r=kentuckyfriedtakahe (efb86ce02d)
- Bug 1216845 - Check fallible allocations - r=rillian (fac4210e2a)
- Bug 1229615 - Compare track counts between rust and stagefright. r=rillian (1b7ee2e4a8)
- Bug 1219475 - Fix a comparison warning. r=gerald (2efe7f952d)
- Bug 1181719 - p2: Check numBitsLeft before each getBits - r=rillian (f7bd7039ed)
- Bug 1187067 - Null-check mLastTrack before dereferencing it - r=rillian (e2d99073ff)
- Bug 1181220 - p2: Check if MIME types are valid - r=rillian (c1d1254f6d)
- Bug 1185230 - p2: Store MPEG4Source::mTimescale as uint32_t - r=rillian (21d124ab25)
- Bug 1207909 - p1: Fixed ALOGV statement - r=jya (0aef385b41)
- Bug 1207909 - p2: Fixed a warning (uninitialized 'err') and typo - r=jya (a9c157feda)
- partial remove of hack (59ca36fbd4)
- Bug 1156505 - p2: Null-check sampleTable before use. r=rillian (ab18d1d939)
- Bug 1181215 - p2: Better track verification - r=rillian (d61d5914aa)
- Bug 1210319 - p1. Removed unused code - r=rillian (4c0b33fc59)
- Bug 1210319 - p2. Minor intf clean-up, RIP trex - r=rillian (27aaf6ae80)
- Bug 1229134: Check that memory allocation actually succeeded. r=gerald (b6587bc900)
- Bug 1209388: [mp3] Remove AppleMP3Reader. r=kentuckyfriedtakahe (e81f265901)
- Bug 1198576 - Remove MediaCodecReader. r=bwu (e867950ff4)
- Bug 1191833: P1. Properly check webm mimetype against codec type. r=cpearce (9b27b8064a)
- Bug 1229605: [MSE] Allow webm/audio independently of video. r=kentuckyfriedtakahe (7b79dfaf4c)
- Bug 1229339: Partial revert of commit c15c9f37f. r=cpearce (90fa115b64)
2023-05-04 10:41:24 +08:00

115 lines
3.0 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "VideoSegment.h"
#include "gfx2DGlue.h"
#include "ImageContainer.h"
#include "Layers.h"
namespace mozilla {
using namespace layers;
VideoFrame::VideoFrame(already_AddRefed<Image>& aImage,
const gfx::IntSize& aIntrinsicSize)
: mImage(aImage), mIntrinsicSize(aIntrinsicSize), mForceBlack(false)
{}
VideoFrame::VideoFrame()
: mIntrinsicSize(0, 0), mForceBlack(false)
{}
VideoFrame::~VideoFrame()
{}
void
VideoFrame::SetNull() {
mImage = nullptr;
mIntrinsicSize = gfx::IntSize(0, 0);
}
void
VideoFrame::TakeFrom(VideoFrame* aFrame)
{
mImage = aFrame->mImage.forget();
mIntrinsicSize = aFrame->mIntrinsicSize;
mForceBlack = aFrame->GetForceBlack();
}
#if !defined(MOZILLA_XPCOMRT_API)
/* static */ already_AddRefed<Image>
VideoFrame::CreateBlackImage(const gfx::IntSize& aSize)
{
RefPtr<ImageContainer> container = LayerManager::CreateImageContainer();
RefPtr<PlanarYCbCrImage> image = container->CreatePlanarYCbCrImage();
if (!image) {
MOZ_ASSERT(false);
return nullptr;
}
int len = ((aSize.width * aSize.height) * 3 / 2);
// Generate a black image.
ScopedDeletePtr<uint8_t> frame(new uint8_t[len]);
int y = aSize.width * aSize.height;
// Fill Y plane.
memset(frame.rwget(), 0x10, y);
// Fill Cb/Cr planes.
memset(frame.rwget() + y, 0x80, (len - y));
const uint8_t lumaBpp = 8;
const uint8_t chromaBpp = 4;
layers::PlanarYCbCrData data;
data.mYChannel = frame.rwget();
data.mYSize = gfx::IntSize(aSize.width, aSize.height);
data.mYStride = (int32_t) (aSize.width * lumaBpp / 8.0);
data.mCbCrStride = (int32_t) (aSize.width * chromaBpp / 8.0);
data.mCbChannel = frame.get() + aSize.height * data.mYStride;
data.mCrChannel = data.mCbChannel + aSize.height * data.mCbCrStride / 2;
data.mCbCrSize = gfx::IntSize(aSize.width / 2, aSize.height / 2);
data.mPicX = 0;
data.mPicY = 0;
data.mPicSize = gfx::IntSize(aSize.width, aSize.height);
data.mStereoMode = StereoMode::MONO;
// SetData copies data, so we can free data.
if (!image->SetData(data)) {
MOZ_ASSERT(false);
return nullptr;
}
return image.forget();
}
#endif // !defined(MOZILLA_XPCOMRT_API)
VideoChunk::VideoChunk()
{}
VideoChunk::~VideoChunk()
{}
void
VideoSegment::AppendFrame(already_AddRefed<Image>&& aImage,
StreamTime aDuration,
const IntSize& aIntrinsicSize,
bool aForceBlack)
{
VideoChunk* chunk = AppendChunk(aDuration);
VideoFrame frame(aImage, aIntrinsicSize);
frame.SetForceBlack(aForceBlack);
chunk->mFrame.TakeFrom(&frame);
}
VideoSegment::VideoSegment()
: MediaSegmentBase<VideoSegment, VideoChunk>(VIDEO)
{}
VideoSegment::~VideoSegment()
{}
} // namespace mozilla