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

Side by Side Diff: media/formats/webm/webm_audio_client.cc

Issue 2752323002: Support Opus Ambisonics playback (Closed)
Patch Set: another fix for unreliable ffmpeg channels vs layout Created 3 years, 6 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/filters/ffmpeg_audio_decoder.cc ('k') | media/renderers/audio_renderer_impl.h » ('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/formats/webm/webm_audio_client.h" 5 #include "media/formats/webm/webm_audio_client.h"
6 6
7 #include "media/base/audio_decoder_config.h" 7 #include "media/base/audio_decoder_config.h"
8 #include "media/base/channel_layout.h" 8 #include "media/base/channel_layout.h"
9 #include "media/formats/webm/webm_constants.h" 9 #include "media/formats/webm/webm_constants.h"
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 return false; 43 return false;
44 } 44 }
45 45
46 if (samples_per_second_ <= 0) 46 if (samples_per_second_ <= 0)
47 return false; 47 return false;
48 48
49 // Set channel layout default if a Channels element was not present. 49 // Set channel layout default if a Channels element was not present.
50 if (channels_ == -1) 50 if (channels_ == -1)
51 channels_ = 1; 51 channels_ = 1;
52 52
53 ChannelLayout channel_layout = GuessChannelLayout(channels_); 53 bool is_opus_discrete = false;
54 if (audio_codec == kCodecOpus && codec_private.size() >= 19) {
55 int mapping_family = codec_private[18];
56 is_opus_discrete = mapping_family == 2;
57 }
58 ChannelLayout channel_layout = is_opus_discrete && channels_ > 8
59 ? CHANNEL_LAYOUT_DISCRETE
60 : GuessChannelLayout(channels_);
54 61
55 if (channel_layout == CHANNEL_LAYOUT_UNSUPPORTED) { 62 if (channel_layout == CHANNEL_LAYOUT_UNSUPPORTED) {
56 MEDIA_LOG(ERROR, media_log_) << "Unsupported channel count " << channels_; 63 MEDIA_LOG(ERROR, media_log_) << "Unsupported channel count " << channels_;
57 return false; 64 return false;
58 } 65 }
59 66
60 int samples_per_second = samples_per_second_; 67 int samples_per_second = samples_per_second_;
61 if (output_samples_per_second_ > 0) 68 if (output_samples_per_second_ > 0)
62 samples_per_second = output_samples_per_second_; 69 samples_per_second = output_samples_per_second_;
63 70
(...skipping 11 matching lines...) Expand all
75 0.5 + 82 0.5 +
76 samples_per_second * (static_cast<double>(codec_delay) / 83 samples_per_second * (static_cast<double>(codec_delay) /
77 base::Time::kNanosecondsPerSecond); 84 base::Time::kNanosecondsPerSecond);
78 } 85 }
79 86
80 config->Initialize(audio_codec, sample_format, channel_layout, 87 config->Initialize(audio_codec, sample_format, channel_layout,
81 samples_per_second, codec_private, encryption_scheme, 88 samples_per_second, codec_private, encryption_scheme,
82 base::TimeDelta::FromMicroseconds( 89 base::TimeDelta::FromMicroseconds(
83 (seek_preroll != -1 ? seek_preroll : 0) / 1000), 90 (seek_preroll != -1 ? seek_preroll : 0) / 1000),
84 codec_delay_in_frames); 91 codec_delay_in_frames);
92 config->SetChannelsForDiscrete(channels_);
85 return config->IsValidConfig(); 93 return config->IsValidConfig();
86 } 94 }
87 95
88 bool WebMAudioClient::OnUInt(int id, int64_t val) { 96 bool WebMAudioClient::OnUInt(int id, int64_t val) {
89 if (id == kWebMIdChannels) { 97 if (id == kWebMIdChannels) {
90 if (channels_ != -1) { 98 if (channels_ != -1) {
91 MEDIA_LOG(ERROR, media_log_) << "Multiple values for id " << std::hex 99 MEDIA_LOG(ERROR, media_log_) << "Multiple values for id " << std::hex
92 << id << " specified. (" << channels_ 100 << id << " specified. (" << channels_
93 << " and " << val << ")"; 101 << " and " << val << ")";
94 return false; 102 return false;
(...skipping 26 matching lines...) Expand all
121 << " specified (" << *dst << " and " << val 129 << " specified (" << *dst << " and " << val
122 << ")"; 130 << ")";
123 return false; 131 return false;
124 } 132 }
125 133
126 *dst = val; 134 *dst = val;
127 return true; 135 return true;
128 } 136 }
129 137
130 } // namespace media 138 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_audio_decoder.cc ('k') | media/renderers/audio_renderer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698