00001 /* 00002 * Xing VBR tagging for LAME. 00003 * 00004 * Copyright (c) 1999 A.L. Faber 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the 00018 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00019 * Boston, MA 02111-1307, USA. 00020 */ 00021 00022 #ifndef LAME_VRBTAG_H 00023 #define LAME_VRBTAG_H 00024 00025 00026 /* ----------------------------------------------------------- 00027 * A Vbr header may be present in the ancillary 00028 * data field of the first frame of an mp3 bitstream 00029 * The Vbr header (optionally) contains 00030 * frames total number of audio frames in the bitstream 00031 * bytes total number of bytes in the bitstream 00032 * toc table of contents 00033 00034 * toc (table of contents) gives seek points 00035 * for random access 00036 * the ith entry determines the seek point for 00037 * i-percent duration 00038 * seek point in bytes = (toc[i]/256.0) * total_bitstream_bytes 00039 * e.g. half duration seek point = (toc[50]/256.0) * total_bitstream_bytes 00040 */ 00041 00042 00043 #define FRAMES_FLAG 0x0001 00044 #define BYTES_FLAG 0x0002 00045 #define TOC_FLAG 0x0004 00046 #define VBR_SCALE_FLAG 0x0008 00047 00048 #define NUMTOCENTRIES 100 00049 00050 #define FRAMES_AND_BYTES (FRAMES_FLAG | BYTES_FLAG) 00051 00052 00053 00054 /*structure to receive extracted header */ 00055 /* toc may be NULL*/ 00056 typedef struct { 00057 int h_id; /* from MPEG header, 0=MPEG2, 1=MPEG1 */ 00058 int samprate; /* determined from MPEG header */ 00059 int flags; /* from Vbr header data */ 00060 int frames; /* total bit stream frames from Vbr header data */ 00061 int bytes; /* total bit stream bytes from Vbr header data */ 00062 int vbr_scale; /* encoded vbr scale from Vbr header data */ 00063 unsigned char toc[NUMTOCENTRIES]; /* may be NULL if toc not desired */ 00064 int headersize; /* size of VBR header, in bytes */ 00065 int enc_delay; /* encoder delay */ 00066 int enc_padding; /* encoder paddign added at end of stream */ 00067 } VBRTAGDATA; 00068 00069 int CheckVbrTag(unsigned char *buf); 00070 int GetVbrTag(VBRTAGDATA * pTagData, unsigned char *buf); 00071 00072 int SeekPoint(unsigned char TOC[NUMTOCENTRIES], int file_bytes, float percent); 00073 int InitVbrTag(lame_global_flags * gfp); 00074 int PutVbrTag(lame_global_flags const* gfp, FILE * fid); 00075 int PutLameVBR(lame_global_flags const* gfp, FILE * fpStream, uint8_t * pbtStreamBuffer, 00076 uint32_t id3v2size, uint16_t crc); 00077 void AddVbrFrame(lame_global_flags * gfp); 00078 void UpdateMusicCRC(uint16_t * crc, unsigned char *buffer, int size); 00079 00080 #endif