Index: media/midi/midi_message_util.cc |
diff --git a/media/midi/midi_message_util.cc b/media/midi/midi_message_util.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e4e2b62426284ef8b2c26365a92bcb854e8a0061 |
--- /dev/null |
+++ b/media/midi/midi_message_util.cc |
@@ -0,0 +1,34 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "media/midi/midi_message_util.h" |
+ |
+namespace media { |
+ |
+size_t GetMIDIMessageLength(uint8 status_byte) { |
+ if (status_byte < 0x80) |
+ return 0; |
+ if (0x80 <= status_byte && status_byte <= 0xbf) |
+ return 3; |
+ if (0xc0 <= status_byte && status_byte <= 0xdf) |
+ return 2; |
+ if (0xe0 <= status_byte && status_byte <= 0xef) |
+ return 3; |
+ if (status_byte == 0xf0) |
+ return 0; |
+ if (status_byte == 0xf1) |
+ return 2; |
+ if (status_byte == 0xf2) |
+ return 3; |
+ if (status_byte == 0xf3) |
+ return 2; |
+ if (0xf4 <= status_byte && status_byte <= 0xf6) |
+ return 1; |
+ if (status_byte == 0xf7) |
+ return 0; |
+ // 0xf8 <= status_byte && status_byte <= 0xff |
+ return 1; |
+} |
+ |
+} // namespace media |