diff options
Diffstat (limited to 'src/demuxers/id3.h')
-rw-r--r-- | src/demuxers/id3.h | 74 |
1 files changed, 49 insertions, 25 deletions
diff --git a/src/demuxers/id3.h b/src/demuxers/id3.h index 9d08f6817..542a17bc4 100644 --- a/src/demuxers/id3.h +++ b/src/demuxers/id3.h @@ -15,29 +15,28 @@ * * 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 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * * ID3 tag parser * * Supported versions: v1, v1.1, v2.2, v2.3, v2.4 - * - * $Id: id3.h,v 1.6 2007/03/03 01:41:16 dgp85 Exp $ */ #ifndef ID3_H #define ID3_H -#include "xine_internal.h" -#include "xineutils.h" +#include <xine/xine_internal.h> +#include <xine/xineutils.h> #include "bswap.h" /* id3v2 */ -#define FOURCC_TAG BE_FOURCC -#define ID3V22_TAG FOURCC_TAG('I', 'D', '3', 2) /* id3 v2.2 header tag */ -#define ID3V23_TAG FOURCC_TAG('I', 'D', '3', 3) /* id3 v2.3 header tag */ -#define ID3V24_TAG FOURCC_TAG('I', 'D', '3', 4) /* id3 v2.4 header tag */ -#define ID3V24_FOOTER_TAG FOURCC_TAG('3', 'D', 'I', 0) /* id3 v2.4 footer tag */ +#define ID3V22_TAG ME_FOURCC('I', 'D', '3', 2) /* id3 v2.2 header tag */ +#define ID3V23_TAG ME_FOURCC('I', 'D', '3', 3) /* id3 v2.3 header tag */ +#define ID3V24_TAG ME_FOURCC('I', 'D', '3', 4) /* id3 v2.4 header tag */ +#define ID3V24_FOOTER_TAG ME_FOURCC('3', 'D', 'I', 0) /* id3 v2.4 footer tag */ +#define ID3V2X_TAG ME_FOURCC('I', 'D', '3', 0) /* id3 v2.x header tag */ +#define ID3V2X_MASK ~ME_FOURCC( 0 , 0 , 0 , 0xFF) /* id3 v2.x header mask */ /* * ID3 v2.2 @@ -155,34 +154,59 @@ int id3v1_parse_tag (input_plugin_t *input, xine_stream_t *stream); int id3v22_parse_tag(input_plugin_t *input, xine_stream_t *stream, - int8_t *mp3_frame_header); + uint32_t id3_signature); int id3v23_parse_tag(input_plugin_t *input, xine_stream_t *stream, - int8_t *mp3_frame_header); + uint32_t id3_signature); int id3v24_parse_tag(input_plugin_t *input, xine_stream_t *stream, - int8_t *mp3_frame_header); + uint32_t id3_signature); /* Generic function that switch between the three above */ int id3v2_parse_tag(input_plugin_t *input, xine_stream_t *stream, - int8_t *mp3_frame_header); + uint32_t id3_signature); + +/** + * @brief Checks if the given buffer is an ID3 tag preamble + * @param ptr Pointer to the first 10 bytes of the ID3 tag + */ +static inline int id3v2_istag(uint32_t id3_signature) { + return (id3_signature & ID3V2X_MASK) == ID3V2X_TAG; +} + +#if 0 +/* parse an unsynchronized 16bits integer */ +static inline uint16_t _X_BE_16_synchsafe(uint8_t buf[2]) { + return ((uint16_t)(buf[0] & 0x7F) << 7) | + (uint16_t)(buf[1] & 0x7F); +} +#endif + +/* parse an unsynchronized 24bits integer */ +static inline uint32_t _X_BE_24_synchsafe(uint8_t buf[3]) { + return ((uint32_t)(buf[0] & 0x7F) << 14) | + ((uint32_t)(buf[1] & 0x7F) << 7) | + (uint32_t)(buf[2] & 0x7F); +} -static inline int id3v2_istag(uint8_t *ptr) { - return - (ptr[0] == 'I') && - (ptr[1] == 'D') && - (ptr[2] == '3'); +/* parse an unsynchronized 32bits integer */ +static inline uint32_t _X_BE_32_synchsafe(uint8_t buf[4]) { + return ((uint32_t)(buf[0] & 0x7F) << 21) | + ((uint32_t)(buf[1] & 0x7F) << 14) | + ((uint32_t)(buf[2] & 0x7F) << 7) | + (uint32_t)(buf[3] & 0x7F); } -static inline uint32_t id3v2_tagsize(uint8_t *ptr) { - return - ((uint32_t)ptr[0] << 21) + - ((uint32_t)ptr[1] << 14) + - ((uint32_t)ptr[2] << 7) + - (uint32_t)ptr[3]; +/* parse an unsynchronized 35bits integer */ +static inline uint32_t BE_35_synchsafe(uint8_t buf[5]) { + return ((uint32_t)(buf[0] & 0x07) << 28) | + ((uint32_t)(buf[1] & 0x7F) << 21) | + ((uint32_t)(buf[2] & 0x7F) << 14) | + ((uint32_t)(buf[3] & 0x7F) << 7) | + (uint32_t)(buf[4] & 0x7F); } #endif /* ID3_H */ |