media/libmkv/bug970774.patch
author Lina Cambridge <lina@yakshaving.ninja>
Tue, 02 Apr 2019 18:49:21 +0000
changeset 467645 db20a3f4324ec9fc29bb21bda77672e7e7640529
parent 170664 838a38c416bd1817c71b39e28fbf561fbbeb5770
permissions -rw-r--r--
Bug 1539104 - Add a way to detect supported storage connection operations. r=mak In retrospect, overloading `Connection::connectionReady` to mean "is ready _and_ supports this operation" wasn't a good idea. This commit reverts that change (cfd44c936a9b), and adds two new methods: * `Connection::operationSupported`, to check if a connection supports sync or async operations. This method is public. * `Connection::ensureOperationSupported`, that asserts or returns an error if the connection doesn't support an operation. This is private. `operationSupported` is used by callers like `Service::minimizeMemory` to detect if the connection supports sync operations, since both sync and async connections implement `mozIStorageConnection` now. Finally, some callers used `!mDBConn` to check if the connection was ready, while others used `connectionReady()`. This commit changes them to use the latter. Differential Revision: https://phabricator.services.mozilla.com/D24974

diff --git a/media/libmkv/WebMElement.c b/media/libmkv/WebMElement.c
--- a/media/libmkv/WebMElement.c
+++ b/media/libmkv/WebMElement.c
@@ -52,32 +52,39 @@ static UInt64 generateTrackID(unsigned i
   r = r << 32;
   r +=  rand();
 //  UInt64 rval = t ^ r;
   return t ^ r;
 }
 
 void writeVideoTrack(EbmlGlobal *glob, unsigned int trackNumber, int flagLacing,
                      const char *codecId, unsigned int pixelWidth, unsigned int pixelHeight,
+                     unsigned int displayWidth, unsigned int displayHeight,
                      double frameRate) {
   EbmlLoc start;
   UInt64 trackID;
   Ebml_StartSubElement(glob, &start, TrackEntry);
   Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber);
   trackID = generateTrackID(trackNumber);
   Ebml_SerializeUnsigned(glob, TrackUID, trackID);
   Ebml_SerializeString(glob, CodecName, "VP8");  // TODO shouldn't be fixed
 
   Ebml_SerializeUnsigned(glob, TrackType, 1); // video is always 1
   Ebml_SerializeString(glob, CodecID, codecId);
   {
     EbmlLoc videoStart;
     Ebml_StartSubElement(glob, &videoStart, Video);
     Ebml_SerializeUnsigned(glob, PixelWidth, pixelWidth);
     Ebml_SerializeUnsigned(glob, PixelHeight, pixelHeight);
+    if (pixelWidth != displayWidth) {
+      Ebml_SerializeUnsigned(glob, DisplayWidth, displayWidth);
+    }
+    if (pixelHeight != displayHeight) {
+      Ebml_SerializeUnsigned(glob, DisplayHeight, displayHeight);
+    }
     Ebml_SerializeFloat(glob, FrameRate, frameRate);
     Ebml_EndSubElement(glob, &videoStart); // Video
   }
   Ebml_EndSubElement(glob, &start); // Track Entry
 }
 void writeAudioTrack(EbmlGlobal *glob, unsigned int trackNumber, int flagLacing,
                      const char *codecId, double samplingFrequency, unsigned int channels,
                      unsigned char *private, unsigned long privateSize) {
diff --git a/media/libmkv/WebMElement.h b/media/libmkv/WebMElement.h
--- a/media/libmkv/WebMElement.h
+++ b/media/libmkv/WebMElement.h
@@ -16,16 +16,17 @@ extern "C" {
 #include "EbmlWriter.h"
 
 // these are helper functions
 void writeHeader(EbmlGlobal *ebml);
 void writeSegmentInformation(EbmlGlobal *ebml, EbmlLoc *startInfo, unsigned long timeCodeScale, double duration);
 // this function is a helper only, it assumes a lot of defaults
 void writeVideoTrack(EbmlGlobal *ebml, unsigned int trackNumber, int flagLacing,
                      const char *codecId, unsigned int pixelWidth, unsigned int pixelHeight,
+                     unsigned int displayWidth, unsigned int displayHeight,
                      double frameRate);
 void writeAudioTrack(EbmlGlobal *glob, unsigned int trackNumber, int flagLacing,
                      const char *codecId, double samplingFrequency, unsigned int channels,
                      unsigned char *private_, unsigned long privateSize);
 
 void writeSimpleBlock(EbmlGlobal *ebml, unsigned char trackNumber, short timeCode,
                       int isKeyframe, unsigned char lacingFlag, int discardable,
                       unsigned char *data, unsigned long dataLength);