| 
									
										
										
										
											2007-05-20 13:40:07 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * MPEG Audio header decoder | 
					
						
							| 
									
										
										
										
											2009-01-19 15:46:40 +00:00
										 |  |  |  * Copyright (c) 2001, 2002 Fabrice Bellard | 
					
						
							| 
									
										
										
										
											2007-05-20 13:40:07 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This file is part of FFmpeg. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * FFmpeg is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU Lesser General Public | 
					
						
							|  |  |  |  * License as published by the Free Software Foundation; either | 
					
						
							|  |  |  |  * version 2.1 of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * FFmpeg 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 | 
					
						
							|  |  |  |  * Lesser General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU Lesser General Public | 
					
						
							|  |  |  |  * License along with FFmpeg; if not, write to the Free Software | 
					
						
							|  |  |  |  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2010-04-20 14:45:34 +00:00
										 |  |  |  * @file | 
					
						
							| 
									
										
										
										
											2007-05-20 13:40:07 +00:00
										 |  |  |  * MPEG Audio header decoder. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-31 07:39:47 +00:00
										 |  |  | #ifndef AVCODEC_MPEGAUDIODECHEADER_H
 | 
					
						
							|  |  |  | #define AVCODEC_MPEGAUDIODECHEADER_H
 | 
					
						
							| 
									
										
										
										
											2007-05-20 13:40:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-19 13:44:11 +01:00
										 |  |  | #include "avcodec.h"
 | 
					
						
							| 
									
										
										
										
											2007-05-20 13:40:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-19 13:44:11 +01:00
										 |  |  | #define MP3_MASK 0xFFFE0CCF
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define MPA_DECODE_HEADER \
 | 
					
						
							|  |  |  |     int frame_size; \ | 
					
						
							|  |  |  |     int error_protection; \ | 
					
						
							|  |  |  |     int layer; \ | 
					
						
							|  |  |  |     int sample_rate; \ | 
					
						
							|  |  |  |     int sample_rate_index; /* between 0 and 8 */ \ | 
					
						
							|  |  |  |     int bit_rate; \ | 
					
						
							|  |  |  |     int nb_channels; \ | 
					
						
							|  |  |  |     int mode; \ | 
					
						
							|  |  |  |     int mode_ext; \ | 
					
						
							|  |  |  |     int lsf; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct MPADecodeHeader { | 
					
						
							|  |  |  |   MPA_DECODE_HEADER | 
					
						
							|  |  |  | } MPADecodeHeader; | 
					
						
							| 
									
										
										
										
											2007-05-20 13:40:07 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* header decoding. MUST check the header before because no
 | 
					
						
							|  |  |  |    consistency check is done there. Return 1 if free format found and | 
					
						
							|  |  |  |    that the frame size must be computed externally */ | 
					
						
							| 
									
										
										
										
											2011-10-17 09:28:53 +02:00
										 |  |  | int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header); | 
					
						
							| 
									
										
										
										
											2007-05-20 13:40:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-19 13:44:11 +01:00
										 |  |  | /* useful helper to get mpeg audio stream infos. Return -1 if error in
 | 
					
						
							|  |  |  |    header, otherwise the coded frame size in bytes */ | 
					
						
							| 
									
										
										
										
											2011-10-17 09:28:53 +02:00
										 |  |  | int avpriv_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bitrate); | 
					
						
							| 
									
										
										
										
											2011-05-19 13:44:11 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* fast header check for resync */ | 
					
						
							|  |  |  | static inline int ff_mpa_check_header(uint32_t header){ | 
					
						
							|  |  |  |     /* header */ | 
					
						
							|  |  |  |     if ((header & 0xffe00000) != 0xffe00000) | 
					
						
							|  |  |  |         return -1; | 
					
						
							|  |  |  |     /* layer check */ | 
					
						
							|  |  |  |     if ((header & (3<<17)) == 0) | 
					
						
							|  |  |  |         return -1; | 
					
						
							|  |  |  |     /* bit rate */ | 
					
						
							|  |  |  |     if ((header & (0xf<<12)) == 0xf<<12) | 
					
						
							|  |  |  |         return -1; | 
					
						
							|  |  |  |     /* frequency */ | 
					
						
							|  |  |  |     if ((header & (3<<10)) == 3<<10) | 
					
						
							|  |  |  |         return -1; | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-31 07:39:47 +00:00
										 |  |  | #endif /* AVCODEC_MPEGAUDIODECHEADER_H */
 |