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

Issue 10533004: Use aligned buffer in the audio mixer. (Closed)

Created:
8 years, 6 months ago by enal
Modified:
8 years, 6 months ago
CC:
chromium-reviews, feature-media-reviews_chromium.org
Visibility:
Public.

Description

Use aligned buffer in the audio mixer. Allows us in the future to use faster SSE/AVX intrinsics. TEST=None, should work as expected.

Patch Set 1 #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+4 lines, -4 lines) Patch
M media/audio/audio_output_mixer.h View 2 chunks +2 lines, -1 line 0 comments Download
M media/audio/audio_output_mixer.cc View 2 chunks +2 lines, -3 lines 1 comment Download

Messages

Total messages: 12 (0 generated)
enal1
Dale, can you please take a look?
8 years, 6 months ago (2012-06-05 14:05:38 UTC) #1
scherkus (not reviewing)
https://chromiumcodereview.appspot.com/10533004/diff/1/media/audio/audio_output_mixer.cc File media/audio/audio_output_mixer.cc (right): https://chromiumcodereview.appspot.com/10533004/diff/1/media/audio/audio_output_mixer.cc#newcode23 media/audio/audio_output_mixer.cc:23: mixer_data_(new DecoderBuffer(params_.GetBytesPerBuffer())), I'm not convinced we should be using ...
8 years, 6 months ago (2012-06-05 16:37:43 UTC) #2
enal1
On 2012/06/05 16:37:43, scherkus wrote: > https://chromiumcodereview.appspot.com/10533004/diff/1/media/audio/audio_output_mixer.cc > File media/audio/audio_output_mixer.cc (right): > > https://chromiumcodereview.appspot.com/10533004/diff/1/media/audio/audio_output_mixer.cc#newcode23 > ...
8 years, 6 months ago (2012-06-05 16:44:49 UTC) #3
enal1
On 2012/06/05 16:44:49, enal1 wrote: > On 2012/06/05 16:37:43, scherkus wrote: > > > https://chromiumcodereview.appspot.com/10533004/diff/1/media/audio/audio_output_mixer.cc ...
8 years, 6 months ago (2012-06-05 16:54:35 UTC) #4
scherkus (not reviewing)
On 2012/06/05 16:54:35, enal1 wrote: > On 2012/06/05 16:44:49, enal1 wrote: > > On 2012/06/05 ...
8 years, 6 months ago (2012-06-05 17:20:04 UTC) #5
DaleCurtis
On 2012/06/05 16:54:35, enal1 wrote: > On 2012/06/05 16:44:49, enal1 wrote: > > On 2012/06/05 ...
8 years, 6 months ago (2012-06-05 17:20:29 UTC) #6
enal1
We have 2 allocations with same requirement -- one in ffmpeg, another in chrome. It ...
8 years, 6 months ago (2012-06-05 17:24:48 UTC) #7
scherkus (not reviewing)
On 2012/06/05 17:20:29, DaleCurtis wrote: > On 2012/06/05 16:54:35, enal1 wrote: > > On 2012/06/05 ...
8 years, 6 months ago (2012-06-05 17:50:32 UTC) #8
enal1
On 2012/06/05 17:50:32, scherkus wrote: > On 2012/06/05 17:20:29, DaleCurtis wrote: > > On 2012/06/05 ...
8 years, 6 months ago (2012-06-05 17:59:35 UTC) #9
DaleCurtis
On 2012/06/05 17:50:32, scherkus wrote: > On 2012/06/05 17:20:29, DaleCurtis wrote: > > On 2012/06/05 ...
8 years, 6 months ago (2012-06-05 18:02:28 UTC) #10
DaleCurtis
On 2012/06/05 18:02:28, DaleCurtis wrote: > On 2012/06/05 17:50:32, scherkus wrote: > > On 2012/06/05 ...
8 years, 6 months ago (2012-06-05 18:04:43 UTC) #11
enal1
8 years, 6 months ago (2012-06-05 19:18:05 UTC) #12
On 2012/06/05 18:04:43, DaleCurtis wrote:
> On 2012/06/05 18:02:28, DaleCurtis wrote:
> > On 2012/06/05 17:50:32, scherkus wrote:
> > > On 2012/06/05 17:20:29, DaleCurtis wrote:
> > > > On 2012/06/05 16:54:35, enal1 wrote:
> > > > > On 2012/06/05 16:44:49, enal1 wrote:
> > > > > > On 2012/06/05 16:37:43, scherkus wrote:
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
https://chromiumcodereview.appspot.com/10533004/diff/1/media/audio/audio_outp...
> > > > > > > File media/audio/audio_output_mixer.cc (right):
> > > > > > > 
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
https://chromiumcodereview.appspot.com/10533004/diff/1/media/audio/audio_outp...
> > > > > > > media/audio/audio_output_mixer.cc:23: mixer_data_(new
> > > > > > > DecoderBuffer(params_.GetBytesPerBuffer())),
> > > > > > > I'm not convinced we should be using DecoderBuffer as a general
> > purpose
> > > > > > aligned
> > > > > > > memory allocator.
> > > > > > > 
> > > > > > > Would src/base/memory/aligned_memory.h work here instead?
> > > > > > 
> > > > > > I thought about it. DecoderBuffer is too specialized, I'd prefer
> > something
> > > > > more
> > > > > > lightweight. We don't need reference counter.
> > > > > > 
> > > > > > What finally bought me is the fact that it hides exact alignment
> amount.
> > > Of
> > > > > > course I could directly use FF_INPUT_BUFFER_PADDING_SIZE, but
> resulting
> > > code
> > > > > is
> > > > > > less elegant. And overhead is small enough.
> > > > > 
> > > > > BTW, FF_INPUT_BUFFER_PADDING_SIZE is probably wrong -- it is 16 bytes,
> > while
> > > > AVX
> > > > > needs more. With DecoderBuffer I can be sure data is properly aligned.
> > > > 
> > > > We're not aligning based on FF_INPUT_BUFFER_PADDING_SIZE, the av_malloc
> call
> > > > runs posix_memalign on Linux and a hacked memalign on Windows/Mac. The
> > buffer
> > > > padding is another requirement.
> > > > 
> > > > aligned_memory.h is only for static (compile time) alignments, you can't
> use
> > > it
> > > > for dynamic allocations :(
> > > > 
> > > > We could refactor the memory allocation bits of DecoderBuffer into say
> > > > AlignedData and have DecoderBuffer inherit Buffer and AlignedData.
> > > > 
> > > > Using DecoderBuffer here is definitely not ideal, but the alternative is
> > > > implementing your own hacked memalign
> > > 
> > > Would it help to have a simple scoped aligned memory allocator that uses
> > > av_malloc/free if available and something else on platforms that don't use
> > > FFmpeg (i.e., Android)?
> > > 
> > > namespace media {
> > > class Aligned {
> > >  public:
> > >   Aligned(size) : size_(size), data_(av_malloc(size + PADDING)) {}
> > >   ~Aligned() { av_free(data_); }
> > > 
> > >   void* data() { return data_; }
> > >   int size() { return size_; }
> > > };
> > > }  // namespace
> > 
> > That's roughly what I was suggesting, but with the further requirement that
we
> > refactor DecoderBuffer on top it so we don't have to duplicate the testing
in
> > place there.
> > 
> > Short term, what's enal has now is probably fine. We just need to mark it
with
> a
> > TODO(dalecurtis): Refactor DecoderBuffer into AlignedData.
> 
> Another solution would be to build something similar to what av_malloc does
into
> base/ so all of Chrome can have a general purpose dynamic aligned allocator.

Ok, abandoning it for now. We do not require alignment yet...

Powered by Google App Engine
This is Rietveld 408576698