Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Side by Side Diff: media/filters/decoder_stream_traits.cc

Issue 2545523005: [Video] Collect average keyframe distance for video (Closed)
Patch Set: Record only the distance between frames Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/filters/decoder_stream_traits.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/decoder_stream_traits.h" 5 #include "media/filters/decoder_stream_traits.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram_macros.h"
8 #include "media/base/audio_buffer.h" 9 #include "media/base/audio_buffer.h"
9 #include "media/base/audio_decoder.h" 10 #include "media/base/audio_decoder.h"
10 #include "media/base/audio_decoder_config.h" 11 #include "media/base/audio_decoder_config.h"
11 #include "media/base/video_decoder.h" 12 #include "media/base/video_decoder.h"
12 #include "media/base/video_frame.h" 13 #include "media/base/video_frame.h"
13 14
14 namespace media { 15 namespace media {
15 16
16 // Audio decoder stream traits implementation. 17 // Audio decoder stream traits implementation.
17 18
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 DemuxerStream* stream, 109 DemuxerStream* stream,
109 CdmContext* cdm_context, 110 CdmContext* cdm_context,
110 const InitCB& init_cb, 111 const InitCB& init_cb,
111 const OutputCB& output_cb) { 112 const OutputCB& output_cb) {
112 DCHECK(stream->video_decoder_config().IsValidConfig()); 113 DCHECK(stream->video_decoder_config().IsValidConfig());
113 decoder->Initialize(stream->video_decoder_config(), 114 decoder->Initialize(stream->video_decoder_config(),
114 stream->liveness() == DemuxerStream::LIVENESS_LIVE, 115 stream->liveness() == DemuxerStream::LIVENESS_LIVE,
115 cdm_context, init_cb, output_cb); 116 cdm_context, init_cb, output_cb);
116 } 117 }
117 118
119 void DecoderStreamTraits<DemuxerStream::VIDEO>::OnStreamReset(
120 DemuxerStream* stream) {
121 DCHECK(stream);
122 last_keyframe_timestamp_ = base::TimeDelta();
123 }
124
125 void DecoderStreamTraits<DemuxerStream::VIDEO>::OnDecode(
126 const scoped_refptr<DecoderBuffer>& buffer) {
127 if (buffer->end_of_stream()) {
128 if (!buffer)
DaleCurtis 2016/12/07 23:02:43 This can't ever be true or you've already deref'd
whywhat 2016/12/08 00:23:30 Oops, weird auto formatting obscuring a missing re
129 return;
130
131 last_keyframe_timestamp_ = base::TimeDelta();
132 return;
133 }
134
135 if (!buffer->is_key_frame())
136 return;
137
138 base::TimeDelta current_frame_timestamp = buffer->timestamp();
139 if (last_keyframe_timestamp_.is_zero()) {
140 last_keyframe_timestamp_ = current_frame_timestamp;
141 return;
142 }
143
144 UMA_HISTOGRAM_MEDIUM_TIMES(
145 "Media.Video.KeyFrameDistance",
146 current_frame_timestamp - last_keyframe_timestamp_);
147 }
148
118 } // namespace media 149 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/decoder_stream_traits.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698