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

Side by Side Diff: media/mojo/common/media_type_converters.cc

Issue 2572573007: Use passthrough decoder for (E)AC3 formats (Closed)
Patch Set: Sanity checks Created 3 years, 7 months 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/formats/ac3/ac3_util_unittest.cc ('k') | no next file » | 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/mojo/common/media_type_converters.h" 5 #include "media/mojo/common/media_type_converters.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 return buffer; 304 return buffer;
305 } 305 }
306 306
307 // static 307 // static
308 scoped_refptr<media::AudioBuffer> 308 scoped_refptr<media::AudioBuffer>
309 TypeConverter<scoped_refptr<media::AudioBuffer>, media::mojom::AudioBufferPtr>:: 309 TypeConverter<scoped_refptr<media::AudioBuffer>, media::mojom::AudioBufferPtr>::
310 Convert(const media::mojom::AudioBufferPtr& input) { 310 Convert(const media::mojom::AudioBufferPtr& input) {
311 if (input->end_of_stream) 311 if (input->end_of_stream)
312 return media::AudioBuffer::CreateEOSBuffer(); 312 return media::AudioBuffer::CreateEOSBuffer();
313 313
314 if (input->frame_count <= 0 ||
315 static_cast<size_t>(input->sample_format) > media::kSampleFormatMax ||
316 static_cast<size_t>(input->channel_layout) > media::CHANNEL_LAYOUT_MAX ||
317 ChannelLayoutToChannelCount(input->channel_layout) !=
318 input->channel_count) {
319 LOG(ERROR) << "Receive an invalid audio buffer, replace it with EOS.";
320 return media::AudioBuffer::CreateEOSBuffer();
321 }
322
323 if (IsBitstream(input->sample_format)) {
324 uint8_t* data = input->data.data();
325 return media::AudioBuffer::CopyBitstreamFrom(
326 input->sample_format, input->channel_layout, input->channel_count,
327 input->sample_rate, input->frame_count, &data, input->data.size(),
328 input->timestamp);
329 }
330
314 // Setup channel pointers. AudioBuffer::CopyFrom() will only use the first 331 // Setup channel pointers. AudioBuffer::CopyFrom() will only use the first
315 // one in the case of interleaved data. 332 // one in the case of interleaved data.
316 std::vector<const uint8_t*> channel_ptrs(input->channel_count, nullptr); 333 std::vector<const uint8_t*> channel_ptrs(input->channel_count, nullptr);
317 const size_t size_per_channel = input->data.size() / input->channel_count; 334 const size_t size_per_channel = input->data.size() / input->channel_count;
318 DCHECK_EQ(0u, input->data.size() % input->channel_count); 335 DCHECK_EQ(0u, input->data.size() % input->channel_count);
319 for (int i = 0; i < input->channel_count; ++i) 336 for (int i = 0; i < input->channel_count; ++i)
320 channel_ptrs[i] = input->data.data() + i * size_per_channel; 337 channel_ptrs[i] = input->data.data() + i * size_per_channel;
321 338
322 return media::AudioBuffer::CopyFrom( 339 return media::AudioBuffer::CopyFrom(
323 input->sample_format, input->channel_layout, input->channel_count, 340 input->sample_format, input->channel_layout, input->channel_count,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 input->format, input->coded_size, input->visible_rect, 401 input->format, input->coded_size, input->visible_rect,
385 input->natural_size, std::move(data->frame_data), 402 input->natural_size, std::move(data->frame_data),
386 base::saturated_cast<size_t>(data->frame_data_size), 403 base::saturated_cast<size_t>(data->frame_data_size),
387 base::saturated_cast<size_t>(data->y_offset), 404 base::saturated_cast<size_t>(data->y_offset),
388 base::saturated_cast<size_t>(data->u_offset), 405 base::saturated_cast<size_t>(data->u_offset),
389 base::saturated_cast<size_t>(data->v_offset), data->y_stride, 406 base::saturated_cast<size_t>(data->v_offset), data->y_stride,
390 data->u_stride, data->v_stride, input->timestamp); 407 data->u_stride, data->v_stride, input->timestamp);
391 } 408 }
392 409
393 } // namespace mojo 410 } // namespace mojo
OLDNEW
« no previous file with comments | « media/formats/ac3/ac3_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698