summaryrefslogtreecommitdiff
path: root/libavcodec/mpegaudiodecheader.h
diff options
context:
space:
mode:
authorMans Rullgard <mans@mansr.com>2011-05-19 13:44:11 +0100
committerMans Rullgard <mans@mansr.com>2011-05-20 11:05:07 +0100
commit0199e00bc80a55aacf7ecd393bf32dcd64e06739 (patch)
treefc1744a173ca698ac97881820abe68f6d7d0a043 /libavcodec/mpegaudiodecheader.h
parent984ece7503597d30e6f3bdeb67e337ea1616f880 (diff)
downloadffmpeg-0199e00bc80a55aacf7ecd393bf32dcd64e06739.tar.gz
mpegaudio: move all header parsing to mpegaudiodecheader.[ch]
Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libavcodec/mpegaudiodecheader.h')
-rw-r--r--libavcodec/mpegaudiodecheader.h41
1 files changed, 39 insertions, 2 deletions
diff --git a/libavcodec/mpegaudiodecheader.h b/libavcodec/mpegaudiodecheader.h
index 41a491b986..2991595b02 100644
--- a/libavcodec/mpegaudiodecheader.h
+++ b/libavcodec/mpegaudiodecheader.h
@@ -27,13 +27,50 @@
#ifndef AVCODEC_MPEGAUDIODECHEADER_H
#define AVCODEC_MPEGAUDIODECHEADER_H
-#include "libavutil/common.h"
-#include "mpegaudio.h"
+#include "avcodec.h"
+#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;
/* 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 */
int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header);
+/* useful helper to get mpeg audio stream infos. Return -1 if error in
+ header, otherwise the coded frame size in bytes */
+int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bitrate);
+
+/* 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;
+}
+
#endif /* AVCODEC_MPEGAUDIODECHEADER_H */