Bug 1136877 - Collect telemetry on constraint_set flags from decoded SPS. r=jya, a=lsblakk
authorMike Taylor <miket@mozilla.com>
Fri, 06 Mar 2015 08:17:00 -0500
changeset 250384 027a0ac06377
parent 250383 3aa618647813
child 250385 99fe61cb246f
push id4570
push userryanvm@gmail.com
push date2015-03-16 16:03 +0000
treeherdermozilla-beta@ad1f181d8593 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya, lsblakk
bugs1136877
milestone37.0
Bug 1136877 - Collect telemetry on constraint_set flags from decoded SPS. r=jya, a=lsblakk
dom/media/fmp4/MP4Reader.cpp
toolkit/components/telemetry/Histograms.json
--- a/dom/media/fmp4/MP4Reader.cpp
+++ b/dom/media/fmp4/MP4Reader.cpp
@@ -66,18 +66,26 @@ TrackTypeToStr(TrackType aTrack)
   }
 }
 #endif
 
 bool
 AccumulateSPSTelemetry(const ByteBuffer* aExtradata)
 {
   SPSData spsdata;
-  if (H264::DecodeSPSFromExtraData(aExtradata, spsdata) &&
-      spsdata.profile_idc && spsdata.level_idc) {
+  if (H264::DecodeSPSFromExtraData(aExtradata, spsdata)) {
+   uint8_t constraints = (spsdata.constraint_set0_flag ? (1 << 0) : 0) |
+                         (spsdata.constraint_set1_flag ? (1 << 1) : 0) |
+                         (spsdata.constraint_set2_flag ? (1 << 2) : 0) |
+                         (spsdata.constraint_set3_flag ? (1 << 3) : 0) |
+                         (spsdata.constraint_set4_flag ? (1 << 4) : 0) |
+                         (spsdata.constraint_set5_flag ? (1 << 5) : 0);
+    Telemetry::Accumulate(Telemetry::VIDEO_DECODED_H264_SPS_CONSTRAINT_SET_FLAG,
+                          constraints);
+
     // Collect profile_idc values up to 244, otherwise 0 for unknown.
     Telemetry::Accumulate(Telemetry::VIDEO_DECODED_H264_SPS_PROFILE,
                           spsdata.profile_idc <= 244 ? spsdata.profile_idc : 0);
 
     // Make sure level_idc represents a value between levels 1 and 5.2,
     // otherwise collect 0 for unknown level.
     Telemetry::Accumulate(Telemetry::VIDEO_DECODED_H264_SPS_LEVEL,
                           (spsdata.level_idc >= 10 && spsdata.level_idc <= 52) ?
@@ -708,17 +716,17 @@ MP4Reader::Update(TrackType aTrack)
        needOutput,
        decoder.mInputExhausted,
        decoder.mIsFlushing);
 
   if (needInput) {
     MP4Sample* sample = PopSample(aTrack);
 
     // Collect telemetry from h264 Annex B SPS.
-    if (sample && !mFoundSPSForTelemetry && AnnexB::HasSPS(sample)) {
+    if (!mFoundSPSForTelemetry && sample && AnnexB::HasSPS(sample)) {
       nsRefPtr<ByteBuffer> extradata = AnnexB::ExtractExtraData(sample);
       mFoundSPSForTelemetry = AccumulateSPSTelemetry(extradata);
     }
 
     if (sample) {
       decoder.mDecoder->Input(sample);
       if (aTrack == kVideo) {
         a.mParsed++;
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -5435,16 +5435,22 @@
     "description": "The H.264 level (level_idc) as extracted from the codecs parameter passed to HTMLMediaElement.canPlayType, from levels 1 (10) to 5.2 (51), with the addition of 0 for unknown values."
   },
   "VIDEO_CANPLAYTYPE_H264_PROFILE": {
     "expires_in_version": "40",
     "kind": "enumerated",
     "n_values": 244,
     "description": "The H.264 profile number (profile_idc) as extracted from the codecs parameter passed to HTMLMediaElement.canPlayType."
   },
+  "VIDEO_DECODED_H264_SPS_CONSTRAINT_SET_FLAG": {
+    "expires_in_version": "40",
+    "kind": "enumerated",
+    "n_values": 128,
+    "description": "A bit pattern to collect H.264 constraint set flag from the decoded SPS. Bits 0 through 5 represent constraint_set0_flag through constraint_set5_flag, respectively."
+  },
   "VIDEO_DECODED_H264_SPS_LEVEL": {
     "expires_in_version": "40",
     "kind": "enumerated",
     "n_values": 51,
     "description": "The H.264 level (level_idc) as extracted from the decoded SPS, from levels 1 (10) to 5.2 (51), with the addition of 0 for unknown values."
   },
   "VIDEO_DECODED_H264_SPS_PROFILE": {
     "expires_in_version": "40",