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
f10524d5
Commit
f10524d5
authored
Sep 14, 2011
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ra144: use macro constants to make the code more understandable.
parent
cadd4d33
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
29 deletions
+29
-29
ra144.c
libavcodec/ra144.c
+20
-20
ra144dec.c
libavcodec/ra144dec.c
+9
-9
No files found.
libavcodec/ra144.c
View file @
f10524d5
...
@@ -1544,22 +1544,22 @@ void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset)
...
@@ -1544,22 +1544,22 @@ void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset)
int
ff_eval_refl
(
int
*
refl
,
const
int16_t
*
coefs
,
AVCodecContext
*
avctx
)
int
ff_eval_refl
(
int
*
refl
,
const
int16_t
*
coefs
,
AVCodecContext
*
avctx
)
{
{
int
b
,
i
,
j
;
int
b
,
i
,
j
;
int
buffer1
[
10
];
int
buffer1
[
LPC_ORDER
];
int
buffer2
[
10
];
int
buffer2
[
LPC_ORDER
];
int
*
bp1
=
buffer1
;
int
*
bp1
=
buffer1
;
int
*
bp2
=
buffer2
;
int
*
bp2
=
buffer2
;
for
(
i
=
0
;
i
<
10
;
i
++
)
for
(
i
=
0
;
i
<
LPC_ORDER
;
i
++
)
buffer2
[
i
]
=
coefs
[
i
];
buffer2
[
i
]
=
coefs
[
i
];
refl
[
9
]
=
bp2
[
9
];
refl
[
LPC_ORDER
-
1
]
=
bp2
[
LPC_ORDER
-
1
];
if
((
unsigned
)
bp2
[
9
]
+
0x1000
>
0x1fff
)
{
if
((
unsigned
)
bp2
[
LPC_ORDER
-
1
]
+
0x1000
>
0x1fff
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Overflow. Broken sample?
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Overflow. Broken sample?
\n
"
);
return
1
;
return
1
;
}
}
for
(
i
=
8
;
i
>=
0
;
i
--
)
{
for
(
i
=
LPC_ORDER
-
2
;
i
>=
0
;
i
--
)
{
b
=
0x1000
-
((
bp2
[
i
+
1
]
*
bp2
[
i
+
1
])
>>
12
);
b
=
0x1000
-
((
bp2
[
i
+
1
]
*
bp2
[
i
+
1
])
>>
12
);
if
(
!
b
)
if
(
!
b
)
...
@@ -1584,12 +1584,12 @@ int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx)
...
@@ -1584,12 +1584,12 @@ int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx)
*/
*/
void
ff_eval_coefs
(
int
*
coefs
,
const
int
*
refl
)
void
ff_eval_coefs
(
int
*
coefs
,
const
int
*
refl
)
{
{
int
buffer
[
10
];
int
buffer
[
LPC_ORDER
];
int
*
b1
=
buffer
;
int
*
b1
=
buffer
;
int
*
b2
=
coefs
;
int
*
b2
=
coefs
;
int
i
,
j
;
int
i
,
j
;
for
(
i
=
0
;
i
<
10
;
i
++
)
{
for
(
i
=
0
;
i
<
LPC_ORDER
;
i
++
)
{
b1
[
i
]
=
refl
[
i
]
<<
4
;
b1
[
i
]
=
refl
[
i
]
<<
4
;
for
(
j
=
0
;
j
<
i
;
j
++
)
for
(
j
=
0
;
j
<
i
;
j
++
)
...
@@ -1598,7 +1598,7 @@ void ff_eval_coefs(int *coefs, const int *refl)
...
@@ -1598,7 +1598,7 @@ void ff_eval_coefs(int *coefs, const int *refl)
FFSWAP
(
int
*
,
b1
,
b2
);
FFSWAP
(
int
*
,
b1
,
b2
);
}
}
for
(
i
=
0
;
i
<
10
;
i
++
)
for
(
i
=
0
;
i
<
LPC_ORDER
;
i
++
)
coefs
[
i
]
>>=
4
;
coefs
[
i
]
>>=
4
;
}
}
...
@@ -1606,7 +1606,7 @@ void ff_int_to_int16(int16_t *out, const int *inp)
...
@@ -1606,7 +1606,7 @@ void ff_int_to_int16(int16_t *out, const int *inp)
{
{
int
i
;
int
i
;
for
(
i
=
0
;
i
<
10
;
i
++
)
for
(
i
=
0
;
i
<
LPC_ORDER
;
i
++
)
*
out
++
=
*
inp
++
;
*
out
++
=
*
inp
++
;
}
}
...
@@ -1629,9 +1629,9 @@ unsigned int ff_rms(const int *data)
...
@@ -1629,9 +1629,9 @@ unsigned int ff_rms(const int *data)
{
{
int
i
;
int
i
;
unsigned
int
res
=
0x10000
;
unsigned
int
res
=
0x10000
;
int
b
=
10
;
int
b
=
LPC_ORDER
;
for
(
i
=
0
;
i
<
10
;
i
++
)
{
for
(
i
=
0
;
i
<
LPC_ORDER
;
i
++
)
{
res
=
(((
0x1000000
-
data
[
i
]
*
data
[
i
])
>>
12
)
*
res
)
>>
12
;
res
=
(((
0x1000000
-
data
[
i
]
*
data
[
i
])
>>
12
)
*
res
)
>>
12
;
if
(
res
==
0
)
if
(
res
==
0
)
...
@@ -1648,13 +1648,13 @@ unsigned int ff_rms(const int *data)
...
@@ -1648,13 +1648,13 @@ unsigned int ff_rms(const int *data)
int
ff_interp
(
RA144Context
*
ractx
,
int16_t
*
out
,
int
a
,
int
copyold
,
int
energy
)
int
ff_interp
(
RA144Context
*
ractx
,
int16_t
*
out
,
int
a
,
int
copyold
,
int
energy
)
{
{
int
work
[
10
];
int
work
[
LPC_ORDER
];
int
b
=
NBLOCKS
-
a
;
int
b
=
NBLOCKS
-
a
;
int
i
;
int
i
;
// Interpolate block coefficients from the this frame's forth block and
// Interpolate block coefficients from the this frame's forth block and
// last frame's forth block.
// last frame's forth block.
for
(
i
=
0
;
i
<
10
;
i
++
)
for
(
i
=
0
;
i
<
LPC_ORDER
;
i
++
)
out
[
i
]
=
(
a
*
ractx
->
lpc_coef
[
0
][
i
]
+
b
*
ractx
->
lpc_coef
[
1
][
i
])
>>
2
;
out
[
i
]
=
(
a
*
ractx
->
lpc_coef
[
0
][
i
]
+
b
*
ractx
->
lpc_coef
[
1
][
i
])
>>
2
;
if
(
ff_eval_refl
(
work
,
out
,
ractx
->
avctx
))
{
if
(
ff_eval_refl
(
work
,
out
,
ractx
->
avctx
))
{
...
@@ -1690,7 +1690,7 @@ void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs,
...
@@ -1690,7 +1690,7 @@ void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs,
int
cba_idx
,
int
cb1_idx
,
int
cb2_idx
,
int
cba_idx
,
int
cb1_idx
,
int
cb2_idx
,
int
gval
,
int
gain
)
int
gval
,
int
gain
)
{
{
uint16_t
buffer_a
[
40
];
uint16_t
buffer_a
[
BLOCKSIZE
];
uint16_t
*
block
;
uint16_t
*
block
;
int
m
[
3
];
int
m
[
3
];
...
@@ -1711,10 +1711,10 @@ void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs,
...
@@ -1711,10 +1711,10 @@ void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs,
ff_add_wav
(
block
,
gain
,
cba_idx
,
m
,
cba_idx
?
buffer_a
:
NULL
,
ff_add_wav
(
block
,
gain
,
cba_idx
,
m
,
cba_idx
?
buffer_a
:
NULL
,
ff_cb1_vects
[
cb1_idx
],
ff_cb2_vects
[
cb2_idx
]);
ff_cb1_vects
[
cb1_idx
],
ff_cb2_vects
[
cb2_idx
]);
memcpy
(
ractx
->
curr_sblock
,
ractx
->
curr_sblock
+
40
,
memcpy
(
ractx
->
curr_sblock
,
ractx
->
curr_sblock
+
BLOCKSIZE
,
10
*
sizeof
(
*
ractx
->
curr_sblock
));
LPC_ORDER
*
sizeof
(
*
ractx
->
curr_sblock
));
if
(
ff_celp_lp_synthesis_filter
(
ractx
->
curr_sblock
+
10
,
lpc_coefs
,
if
(
ff_celp_lp_synthesis_filter
(
ractx
->
curr_sblock
+
LPC_ORDER
,
lpc_coefs
,
block
,
BLOCKSIZE
,
10
,
1
,
0xfff
))
block
,
BLOCKSIZE
,
LPC_ORDER
,
1
,
0xfff
))
memset
(
ractx
->
curr_sblock
,
0
,
50
*
sizeof
(
*
ractx
->
curr_sblock
));
memset
(
ractx
->
curr_sblock
,
0
,
(
LPC_ORDER
+
BLOCKSIZE
)
*
sizeof
(
*
ractx
->
curr_sblock
));
}
}
libavcodec/ra144dec.c
View file @
f10524d5
...
@@ -59,10 +59,10 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,
...
@@ -59,10 +59,10 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,
{
{
const
uint8_t
*
buf
=
avpkt
->
data
;
const
uint8_t
*
buf
=
avpkt
->
data
;
int
buf_size
=
avpkt
->
size
;
int
buf_size
=
avpkt
->
size
;
static
const
uint8_t
sizes
[
10
]
=
{
6
,
5
,
5
,
4
,
4
,
3
,
3
,
3
,
3
,
2
};
static
const
uint8_t
sizes
[
LPC_ORDER
]
=
{
6
,
5
,
5
,
4
,
4
,
3
,
3
,
3
,
3
,
2
};
unsigned
int
refl_rms
[
4
];
// RMS of the reflection coefficients
unsigned
int
refl_rms
[
NBLOCKS
];
// RMS of the reflection coefficients
uint16_t
block_coefs
[
4
][
10
];
// LPC coefficients of each sub-block
uint16_t
block_coefs
[
NBLOCKS
][
LPC_ORDER
];
// LPC coefficients of each sub-block
unsigned
int
lpc_refl
[
10
];
// LPC reflection coefficients of the frame
unsigned
int
lpc_refl
[
LPC_ORDER
];
// LPC reflection coefficients of the frame
int
i
,
j
;
int
i
,
j
;
int
out_size
;
int
out_size
;
int16_t
*
data
=
vdata
;
int16_t
*
data
=
vdata
;
...
@@ -77,15 +77,15 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,
...
@@ -77,15 +77,15 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
}
}
if
(
buf_size
<
20
)
{
if
(
buf_size
<
FRAMESIZE
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
av_log
(
avctx
,
AV_LOG_ERROR
,
"Frame too small (%d bytes). Truncated file?
\n
"
,
buf_size
);
"Frame too small (%d bytes). Truncated file?
\n
"
,
buf_size
);
*
data_size
=
0
;
*
data_size
=
0
;
return
buf_size
;
return
buf_size
;
}
}
init_get_bits
(
&
gb
,
buf
,
20
*
8
);
init_get_bits
(
&
gb
,
buf
,
FRAMESIZE
*
8
);
for
(
i
=
0
;
i
<
10
;
i
++
)
for
(
i
=
0
;
i
<
LPC_ORDER
;
i
++
)
lpc_refl
[
i
]
=
ff_lpc_refl_cb
[
i
][
get_bits
(
&
gb
,
sizes
[
i
])];
lpc_refl
[
i
]
=
ff_lpc_refl_cb
[
i
][
get_bits
(
&
gb
,
sizes
[
i
])];
ff_eval_coefs
(
ractx
->
lpc_coef
[
0
],
lpc_refl
);
ff_eval_coefs
(
ractx
->
lpc_coef
[
0
],
lpc_refl
);
...
@@ -102,7 +102,7 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,
...
@@ -102,7 +102,7 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,
ff_int_to_int16
(
block_coefs
[
3
],
ractx
->
lpc_coef
[
0
]);
ff_int_to_int16
(
block_coefs
[
3
],
ractx
->
lpc_coef
[
0
]);
for
(
i
=
0
;
i
<
4
;
i
++
)
{
for
(
i
=
0
;
i
<
NBLOCKS
;
i
++
)
{
do_output_subblock
(
ractx
,
block_coefs
[
i
],
refl_rms
[
i
],
&
gb
);
do_output_subblock
(
ractx
,
block_coefs
[
i
],
refl_rms
[
i
],
&
gb
);
for
(
j
=
0
;
j
<
BLOCKSIZE
;
j
++
)
for
(
j
=
0
;
j
<
BLOCKSIZE
;
j
++
)
...
@@ -115,7 +115,7 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,
...
@@ -115,7 +115,7 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,
FFSWAP
(
unsigned
int
*
,
ractx
->
lpc_coef
[
0
],
ractx
->
lpc_coef
[
1
]);
FFSWAP
(
unsigned
int
*
,
ractx
->
lpc_coef
[
0
],
ractx
->
lpc_coef
[
1
]);
*
data_size
=
out_size
;
*
data_size
=
out_size
;
return
20
;
return
FRAMESIZE
;
}
}
AVCodec
ff_ra_144_decoder
=
{
AVCodec
ff_ra_144_decoder
=
{
...
...
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