Libav 0.7.1
|
00001 /* 00002 * MPEG Audio header decoder 00003 * Copyright (c) 2001, 2002 Fabrice Bellard 00004 * 00005 * This file is part of Libav. 00006 * 00007 * Libav is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * Libav is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with Libav; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00027 #ifndef AVCODEC_MPEGAUDIODECHEADER_H 00028 #define AVCODEC_MPEGAUDIODECHEADER_H 00029 00030 #include "avcodec.h" 00031 00032 #define MP3_MASK 0xFFFE0CCF 00033 00034 #define MPA_DECODE_HEADER \ 00035 int frame_size; \ 00036 int error_protection; \ 00037 int layer; \ 00038 int sample_rate; \ 00039 int sample_rate_index; /* between 0 and 8 */ \ 00040 int bit_rate; \ 00041 int nb_channels; \ 00042 int mode; \ 00043 int mode_ext; \ 00044 int lsf; 00045 00046 typedef struct MPADecodeHeader { 00047 MPA_DECODE_HEADER 00048 } MPADecodeHeader; 00049 00050 /* header decoding. MUST check the header before because no 00051 consistency check is done there. Return 1 if free format found and 00052 that the frame size must be computed externally */ 00053 int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header); 00054 00055 /* useful helper to get mpeg audio stream infos. Return -1 if error in 00056 header, otherwise the coded frame size in bytes */ 00057 int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bitrate); 00058 00059 /* fast header check for resync */ 00060 static inline int ff_mpa_check_header(uint32_t header){ 00061 /* header */ 00062 if ((header & 0xffe00000) != 0xffe00000) 00063 return -1; 00064 /* layer check */ 00065 if ((header & (3<<17)) == 0) 00066 return -1; 00067 /* bit rate */ 00068 if ((header & (0xf<<12)) == 0xf<<12) 00069 return -1; 00070 /* frequency */ 00071 if ((header & (3<<10)) == 3<<10) 00072 return -1; 00073 return 0; 00074 } 00075 00076 #endif /* AVCODEC_MPEGAUDIODECHEADER_H */