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

Side by Side Diff: media/base/audio_discard_helper.h

Issue 2543633006: To M56: Use ffmpeg for opus decoding, no need to maintain our decoder. (Closed)
Patch Set: 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/BUILD.gn ('k') | media/base/audio_discard_helper.cc » ('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 #ifndef MEDIA_BASE_AUDIO_DISCARD_HELPER_H_ 5 #ifndef MEDIA_BASE_AUDIO_DISCARD_HELPER_H_
6 #define MEDIA_BASE_AUDIO_DISCARD_HELPER_H_ 6 #define MEDIA_BASE_AUDIO_DISCARD_HELPER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 12 matching lines...) Expand all
23 class MEDIA_EXPORT AudioDiscardHelper { 23 class MEDIA_EXPORT AudioDiscardHelper {
24 public: 24 public:
25 // |sample_rate| is the sample rate of decoded data which will be handed into 25 // |sample_rate| is the sample rate of decoded data which will be handed into
26 // the ProcessBuffers() call. 26 // the ProcessBuffers() call.
27 // 27 //
28 // |decoder_delay| is the number of frames a decoder will output before data 28 // |decoder_delay| is the number of frames a decoder will output before data
29 // corresponding to the first encoded buffer is output. Callers only need to 29 // corresponding to the first encoded buffer is output. Callers only need to
30 // specify this if the decoder inserts frames which have no corresponding 30 // specify this if the decoder inserts frames which have no corresponding
31 // encoded buffer. 31 // encoded buffer.
32 // 32 //
33 // |delayed_discard| indicates that the codec requires two encoded buffers
34 // before the first decoded output buffer. Used only for vorbis currently.
35 //
33 // For example, most MP3 decoders will output 529 junk frames before the data 36 // For example, most MP3 decoders will output 529 junk frames before the data
34 // corresponding to the first encoded buffer is output. These frames are not 37 // corresponding to the first encoded buffer is output. These frames are not
35 // represented in the encoded data stream and instead are an artifact of how 38 // represented in the encoded data stream and instead are an artifact of how
36 // most MP3 decoders work. See http://lame.sourceforge.net/tech-FAQ.txt 39 // most MP3 decoders work. See http://lame.sourceforge.net/tech-FAQ.txt
37 AudioDiscardHelper(int sample_rate, size_t decoder_delay); 40 AudioDiscardHelper(int sample_rate,
41 size_t decoder_delay,
42 bool delayed_discard);
38 ~AudioDiscardHelper(); 43 ~AudioDiscardHelper();
39 44
40 // Converts a TimeDelta to a frame count based on the constructed sample rate. 45 // Converts a TimeDelta to a frame count based on the constructed sample rate.
41 // |duration| must be positive. 46 // |duration| must be positive.
42 size_t TimeDeltaToFrames(base::TimeDelta duration) const; 47 size_t TimeDeltaToFrames(base::TimeDelta duration) const;
43 48
44 // Resets internal state and indicates that |initial_discard| of upcoming 49 // Resets internal state and indicates that |initial_discard| of upcoming
45 // frames should be discarded. 50 // frames should be discarded.
46 void Reset(size_t initial_discard); 51 void Reset(size_t initial_discard);
47 52
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // associated buffer. 88 // associated buffer.
84 size_t discard_frames_; 89 size_t discard_frames_;
85 90
86 // The last encoded buffer timestamp seen by ProcessBuffers() or kNoTimestamp 91 // The last encoded buffer timestamp seen by ProcessBuffers() or kNoTimestamp
87 // if no buffers have been seen thus far. Used to issue warnings for buffer 92 // if no buffers have been seen thus far. Used to issue warnings for buffer
88 // sequences with non-monotonic timestamps. 93 // sequences with non-monotonic timestamps.
89 base::TimeDelta last_input_timestamp_; 94 base::TimeDelta last_input_timestamp_;
90 95
91 // Certain codecs require two encoded buffers before they'll output the first 96 // Certain codecs require two encoded buffers before they'll output the first
92 // decoded buffer. In this case DiscardPadding must be carried over from the 97 // decoded buffer. In this case DiscardPadding must be carried over from the
93 // previous encoded buffer. Enabled automatically if an encoded buffer is 98 // previous encoded buffer. Set during construction.
94 // given to ProcessBuffers() with a NULL decoded buffer. 99 const bool delayed_discard_;
95 bool delayed_discard_;
96 DecoderBuffer::DiscardPadding delayed_discard_padding_; 100 DecoderBuffer::DiscardPadding delayed_discard_padding_;
97 101
98 // When |decoder_delay_| > 0, the number of frames which should be discarded 102 // When |decoder_delay_| > 0, the number of frames which should be discarded
99 // from the next buffer. The index at which to start discarding is calculated 103 // from the next buffer. The index at which to start discarding is calculated
100 // by subtracting |delayed_end_discard_| from |decoder_delay_|. 104 // by subtracting |delayed_end_discard_| from |decoder_delay_|.
101 size_t delayed_end_discard_; 105 size_t delayed_end_discard_;
102 106
103 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDiscardHelper); 107 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDiscardHelper);
104 }; 108 };
105 109
106 } // namespace media 110 } // namespace media
107 111
108 #endif // MEDIA_BASE_AUDIO_DISCARD_HELPER_H_ 112 #endif // MEDIA_BASE_AUDIO_DISCARD_HELPER_H_
OLDNEW
« no previous file with comments | « media/BUILD.gn ('k') | media/base/audio_discard_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698