Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
e027d0a8
Commit
e027d0a8
authored
19 years ago
by
Michael Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
switch ac3enc to av_crc
Originally committed as revision 5116 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
43a80cce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libavcodec/ac3enc.c
+3
-32
3 additions, 32 deletions
libavcodec/ac3enc.c
libavcodec/ac3tab.h
+0
-2
0 additions, 2 deletions
libavcodec/ac3tab.h
libavcodec/utils.c
+2
-0
2 additions, 0 deletions
libavcodec/utils.c
with
5 additions
and
34 deletions
libavcodec/ac3enc.c
+
3
−
32
View file @
e027d0a8
...
...
@@ -25,6 +25,7 @@
//#define DEBUG_BITALLOC
#include
"avcodec.h"
#include
"bitstream.h"
#include
"crc.h"
#include
"ac3.h"
typedef
struct
AC3EncodeContext
{
...
...
@@ -66,7 +67,6 @@ typedef struct AC3EncodeContext {
#define EXP_DIFF_THRESHOLD 1000
static
void
fft_init
(
int
ln
);
static
void
ac3_crc_init
(
void
);
static
inline
int16_t
fix15
(
float
a
)
{
...
...
@@ -886,8 +886,6 @@ static int AC3_encode_init(AVCodecContext *avctx)
xsin1
[
i
]
=
fix15
(
-
sin
(
alpha
));
}
ac3_crc_init
();
avctx
->
coded_frame
=
avcodec_alloc_frame
();
avctx
->
coded_frame
->
key_frame
=
1
;
...
...
@@ -1236,35 +1234,8 @@ static void output_audio_block(AC3EncodeContext *s,
}
}
/* compute the ac3 crc */
#define CRC16_POLY ((1 << 0) | (1 << 2) | (1 << 15) | (1 << 16))
static
void
ac3_crc_init
(
void
)
{
unsigned
int
c
,
n
,
k
;
for
(
n
=
0
;
n
<
256
;
n
++
)
{
c
=
n
<<
8
;
for
(
k
=
0
;
k
<
8
;
k
++
)
{
if
(
c
&
(
1
<<
15
))
c
=
((
c
<<
1
)
&
0xffff
)
^
(
CRC16_POLY
&
0xffff
);
else
c
=
c
<<
1
;
}
crc_table
[
n
]
=
c
;
}
}
static
unsigned
int
ac3_crc
(
uint8_t
*
data
,
int
n
,
unsigned
int
crc
)
{
int
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
crc
=
(
crc_table
[
data
[
i
]
^
(
crc
>>
8
)]
^
(
crc
<<
8
))
&
0xffff
;
}
return
crc
;
}
static
unsigned
int
mul_poly
(
unsigned
int
a
,
unsigned
int
b
,
unsigned
int
poly
)
{
unsigned
int
c
;
...
...
@@ -1342,14 +1313,14 @@ static int output_frame_end(AC3EncodeContext *s)
/* Now we must compute both crcs : this is not so easy for crc1
because it is at the beginning of the data... */
frame_size_58
=
(
frame_size
>>
1
)
+
(
frame_size
>>
3
);
crc1
=
ac3_crc
(
frame
+
4
,
(
2
*
frame_size_58
)
-
4
,
0
);
crc1
=
bswap_16
(
av_crc
(
av_crc8005
,
0
,
frame
+
4
,
2
*
frame_size_58
-
4
)
);
/* XXX: could precompute crc_inv */
crc_inv
=
pow_poly
((
CRC16_POLY
>>
1
),
(
16
*
frame_size_58
)
-
16
,
CRC16_POLY
);
crc1
=
mul_poly
(
crc_inv
,
crc1
,
CRC16_POLY
);
frame
[
2
]
=
crc1
>>
8
;
frame
[
3
]
=
crc1
;
crc2
=
ac3_crc
(
frame
+
2
*
frame_size_58
,
(
frame_size
-
frame_size_58
)
*
2
-
2
,
0
);
crc2
=
bswap_16
(
av_crc
(
av_crc8005
,
0
,
frame
+
2
*
frame_size_58
,
(
frame_size
-
frame_size_58
)
*
2
-
2
)
);
frame
[
2
*
frame_size
-
2
]
=
crc2
>>
8
;
frame
[
2
*
frame_size
-
1
]
=
crc2
;
...
...
This diff is collapsed.
Click to expand it.
libavcodec/ac3tab.h
+
0
−
2
View file @
e027d0a8
...
...
@@ -182,5 +182,3 @@ static int16_t sintab[64];
static
int16_t
fft_rev
[
512
];
static
int16_t
xcos1
[
128
];
static
int16_t
xsin1
[
128
];
static
uint16_t
crc_table
[
256
];
This diff is collapsed.
Click to expand it.
libavcodec/utils.c
+
2
−
0
View file @
e027d0a8
...
...
@@ -1221,7 +1221,9 @@ unsigned avcodec_build( void )
static
void
init_crcs
(
void
){
av_crc04C11DB7
=
av_mallocz_static
(
sizeof
(
AVCRC
)
*
257
);
av_crc8005
=
av_mallocz_static
(
sizeof
(
AVCRC
)
*
257
);
av_crc_init
(
av_crc04C11DB7
,
0
,
32
,
0x04c11db7
,
sizeof
(
AVCRC
)
*
257
);
av_crc_init
(
av_crc8005
,
0
,
16
,
0x8005
,
sizeof
(
AVCRC
)
*
257
);
}
/* must be called before any other functions */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment