Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
0199e00b
Commit
0199e00b
authored
May 19, 2011
by
Mans Rullgard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mpegaudio: move all header parsing to mpegaudiodecheader.[ch]
Signed-off-by:
Mans Rullgard
<
mans@mansr.com
>
parent
984ece75
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
80 deletions
+79
-80
mp3_header_compress_bsf.c
libavcodec/mp3_header_compress_bsf.c
+1
-1
mp3_header_decompress_bsf.c
libavcodec/mp3_header_decompress_bsf.c
+1
-1
mpegaudio.h
libavcodec/mpegaudio.h
+1
-37
mpegaudio_parser.c
libavcodec/mpegaudio_parser.c
+0
-39
mpegaudiodecheader.c
libavcodec/mpegaudiodecheader.c
+37
-0
mpegaudiodecheader.h
libavcodec/mpegaudiodecheader.h
+39
-2
No files found.
libavcodec/mp3_header_compress_bsf.c
View file @
0199e00b
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "avcodec.h"
#include "mpegaudio.h"
#include "mpegaudio
decheader
.h"
static
int
mp3_header_compress
(
AVBitStreamFilterContext
*
bsfc
,
AVCodecContext
*
avctx
,
const
char
*
args
,
static
int
mp3_header_compress
(
AVBitStreamFilterContext
*
bsfc
,
AVCodecContext
*
avctx
,
const
char
*
args
,
...
...
libavcodec/mp3_header_decompress_bsf.c
View file @
0199e00b
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "avcodec.h"
#include "mpegaudio.h"
#include "mpegaudio
decheader
.h"
#include "mpegaudiodata.h"
#include "mpegaudiodata.h"
...
...
libavcodec/mpegaudio.h
View file @
0199e00b
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
# define CONFIG_FLOAT 0
# define CONFIG_FLOAT 0
#endif
#endif
#include
"avcodec.h"
#include
<stdint.h>
/* max frame size, in samples */
/* max frame size, in samples */
#define MPA_FRAME_SIZE 1152
#define MPA_FRAME_SIZE 1152
...
@@ -47,8 +47,6 @@
...
@@ -47,8 +47,6 @@
#define MPA_DUAL 2
#define MPA_DUAL 2
#define MPA_MONO 3
#define MPA_MONO 3
#define MP3_MASK 0xFFFE0CCF
#ifndef FRAC_BITS
#ifndef FRAC_BITS
#define FRAC_BITS 23
/* fractional bits for sb_samples and dct */
#define FRAC_BITS 23
/* fractional bits for sb_samples and dct */
#define WFRAC_BITS 16
/* fractional bits for window */
#define WFRAC_BITS 16
/* fractional bits for window */
...
@@ -72,40 +70,6 @@ typedef int32_t MPA_INT;
...
@@ -72,40 +70,6 @@ typedef int32_t MPA_INT;
typedef
int16_t
OUT_INT
;
typedef
int16_t
OUT_INT
;
#endif
#endif
#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
;
int
ff_mpa_l2_select_table
(
int
bitrate
,
int
nb_channels
,
int
freq
,
int
lsf
);
int
ff_mpa_l2_select_table
(
int
bitrate
,
int
nb_channels
,
int
freq
,
int
lsf
);
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_MPEGAUDIO_H */
#endif
/* AVCODEC_MPEGAUDIO_H */
libavcodec/mpegaudio_parser.c
View file @
0199e00b
...
@@ -38,45 +38,6 @@ typedef struct MpegAudioParseContext {
...
@@ -38,45 +38,6 @@ typedef struct MpegAudioParseContext {
#define SAME_HEADER_MASK \
#define SAME_HEADER_MASK \
(0xffe00000 | (3 << 17) | (3 << 10) | (3 << 19))
(0xffe00000 | (3 << 17) | (3 << 10) | (3 << 19))
/* 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
*
bit_rate
)
{
MPADecodeHeader
s1
,
*
s
=
&
s1
;
if
(
ff_mpa_check_header
(
head
)
!=
0
)
return
-
1
;
if
(
ff_mpegaudio_decode_header
(
s
,
head
)
!=
0
)
{
return
-
1
;
}
switch
(
s
->
layer
)
{
case
1
:
avctx
->
codec_id
=
CODEC_ID_MP1
;
*
frame_size
=
384
;
break
;
case
2
:
avctx
->
codec_id
=
CODEC_ID_MP2
;
*
frame_size
=
1152
;
break
;
default:
case
3
:
avctx
->
codec_id
=
CODEC_ID_MP3
;
if
(
s
->
lsf
)
*
frame_size
=
576
;
else
*
frame_size
=
1152
;
break
;
}
*
sample_rate
=
s
->
sample_rate
;
*
channels
=
s
->
nb_channels
;
*
bit_rate
=
s
->
bit_rate
;
avctx
->
sub_id
=
s
->
layer
;
return
s
->
frame_size
;
}
static
int
mpegaudio_parse
(
AVCodecParserContext
*
s1
,
static
int
mpegaudio_parse
(
AVCodecParserContext
*
s1
,
AVCodecContext
*
avctx
,
AVCodecContext
*
avctx
,
const
uint8_t
**
poutbuf
,
int
*
poutbuf_size
,
const
uint8_t
**
poutbuf
,
int
*
poutbuf_size
,
...
...
libavcodec/mpegaudiodecheader.c
View file @
0199e00b
...
@@ -108,3 +108,40 @@ int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header)
...
@@ -108,3 +108,40 @@ int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header)
#endif
#endif
return
0
;
return
0
;
}
}
int
ff_mpa_decode_header
(
AVCodecContext
*
avctx
,
uint32_t
head
,
int
*
sample_rate
,
int
*
channels
,
int
*
frame_size
,
int
*
bit_rate
)
{
MPADecodeHeader
s1
,
*
s
=
&
s1
;
if
(
ff_mpa_check_header
(
head
)
!=
0
)
return
-
1
;
if
(
ff_mpegaudio_decode_header
(
s
,
head
)
!=
0
)
{
return
-
1
;
}
switch
(
s
->
layer
)
{
case
1
:
avctx
->
codec_id
=
CODEC_ID_MP1
;
*
frame_size
=
384
;
break
;
case
2
:
avctx
->
codec_id
=
CODEC_ID_MP2
;
*
frame_size
=
1152
;
break
;
default:
case
3
:
avctx
->
codec_id
=
CODEC_ID_MP3
;
if
(
s
->
lsf
)
*
frame_size
=
576
;
else
*
frame_size
=
1152
;
break
;
}
*
sample_rate
=
s
->
sample_rate
;
*
channels
=
s
->
nb_channels
;
*
bit_rate
=
s
->
bit_rate
;
avctx
->
sub_id
=
s
->
layer
;
return
s
->
frame_size
;
}
libavcodec/mpegaudiodecheader.h
View file @
0199e00b
...
@@ -27,13 +27,50 @@
...
@@ -27,13 +27,50 @@
#ifndef AVCODEC_MPEGAUDIODECHEADER_H
#ifndef AVCODEC_MPEGAUDIODECHEADER_H
#define AVCODEC_MPEGAUDIODECHEADER_H
#define AVCODEC_MPEGAUDIODECHEADER_H
#include "libavutil/common.h"
#include "avcodec.h"
#include "mpegaudio.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
/* header decoding. MUST check the header before because no
consistency check is done there. Return 1 if free format found and
consistency check is done there. Return 1 if free format found and
that the frame size must be computed externally */
that the frame size must be computed externally */
int
ff_mpegaudio_decode_header
(
MPADecodeHeader
*
s
,
uint32_t
header
);
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 */
#endif
/* AVCODEC_MPEGAUDIODECHEADER_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment