/* * mp3plot - Bitrate analysis tool * * Copyright (C) 2007 Toni Corvera * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // $Id: mp3_element.cc 711 2007-05-17 22:52:34Z $ #include "mp3_element.h" namespace net_outlyer { namespace mp3 { // -- MP3 Element -- (Common code of tags and frames) void mp3element::check(const std::ifstream & in, const std::string & failed_on) throw (e_read_failure) { if (!in.good()) { throw e_read_failure("Failed to read " + failed_on, EX_IOERR); } } // FIXME: requires O(1) uint8_t mp3element::bitrate_index(uint16_t kbps) { for (int i=0; i<0x0f; ++i) { if (BITRATE_TABLE[i] == kbps) { return i; } } return BITRATE_TABLE_LEN - 1; } } // namespace mp3 } // namespace net_outlyer /* vim:set ts=4 et ai: */