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
d0a3e89d
Commit
d0a3e89d
authored
9 years ago
by
Alexandra Khirnova
Committed by
Luca Barbato
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
dcadec: make a number of samples per subband per subsubframe a named constant
Signed-off-by:
Luca Barbato
<
lu_zero@gentoo.org
>
parent
8ae1d87a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavcodec/dcadec.c
+21
-19
21 additions, 19 deletions
libavcodec/dcadec.c
with
21 additions
and
19 deletions
libavcodec/dcadec.c
+
21
−
19
View file @
d0a3e89d
...
@@ -139,6 +139,8 @@ static const uint64_t dca_core_channel_layout[] = {
...
@@ -139,6 +139,8 @@ static const uint64_t dca_core_channel_layout[] = {
#define DCA_NSYNCAUX 0x9A1105A0
#define DCA_NSYNCAUX 0x9A1105A0
#define SAMPLES_PER_SUBBAND 8 // number of samples per subband per subsubframe
/** Bit allocation */
/** Bit allocation */
typedef
struct
BitAlloc
{
typedef
struct
BitAlloc
{
int
offset
;
///< code values offset
int
offset
;
///< code values offset
...
@@ -536,7 +538,7 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index)
...
@@ -536,7 +538,7 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index)
}
}
static
void
qmf_32_subbands
(
DCAContext
*
s
,
int
chans
,
static
void
qmf_32_subbands
(
DCAContext
*
s
,
int
chans
,
float
samples_in
[
32
][
8
],
float
*
samples_out
,
float
samples_in
[
32
][
SAMPLES_PER_SUBBAND
],
float
*
samples_out
,
float
scale
)
float
scale
)
{
{
const
float
*
prCoeff
;
const
float
*
prCoeff
;
...
@@ -584,7 +586,7 @@ static QMF64_table *qmf64_precompute(void)
...
@@ -584,7 +586,7 @@ static QMF64_table *qmf64_precompute(void)
/* FIXME: Totally unoptimized. Based on the reference code and
/* FIXME: Totally unoptimized. Based on the reference code and
* http://multimedia.cx/mirror/dca-transform.pdf, with guessed tweaks
* http://multimedia.cx/mirror/dca-transform.pdf, with guessed tweaks
* for doubling the size. */
* for doubling the size. */
static
void
qmf_64_subbands
(
DCAContext
*
s
,
int
chans
,
float
samples_in
[
64
][
8
],
static
void
qmf_64_subbands
(
DCAContext
*
s
,
int
chans
,
float
samples_in
[
64
][
SAMPLES_PER_SUBBAND
],
float
*
samples_out
,
float
scale
)
float
*
samples_out
,
float
scale
)
{
{
float
raXin
[
64
];
float
raXin
[
64
];
...
@@ -595,7 +597,7 @@ static void qmf_64_subbands(DCAContext *s, int chans, float samples_in[64][8],
...
@@ -595,7 +597,7 @@ static void qmf_64_subbands(DCAContext *s, int chans, float samples_in[64][8],
for
(
i
=
s
->
subband_activity
[
chans
];
i
<
64
;
i
++
)
for
(
i
=
s
->
subband_activity
[
chans
];
i
<
64
;
i
++
)
raXin
[
i
]
=
0
.
0
;
raXin
[
i
]
=
0
.
0
;
for
(
subindex
=
0
;
subindex
<
8
;
subindex
++
)
{
for
(
subindex
=
0
;
subindex
<
SAMPLES_PER_SUBBAND
;
subindex
++
)
{
for
(
i
=
0
;
i
<
s
->
subband_activity
[
chans
];
i
++
)
for
(
i
=
0
;
i
<
s
->
subband_activity
[
chans
];
i
++
)
raXin
[
i
]
=
samples_in
[
i
][
subindex
];
raXin
[
i
]
=
samples_in
[
i
][
subindex
];
...
@@ -786,8 +788,8 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
...
@@ -786,8 +788,8 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
const
float
*
quant_step_table
;
const
float
*
quant_step_table
;
/* FIXME */
/* FIXME */
float
(
*
subband_samples
)[
DCA_SUBBANDS
][
8
]
=
s
->
subband_samples
[
block_index
];
float
(
*
subband_samples
)[
DCA_SUBBANDS
][
SAMPLES_PER_SUBBAND
]
=
s
->
subband_samples
[
block_index
];
LOCAL_ALIGNED_16
(
int32_t
,
block
,
[
8
*
DCA_SUBBANDS
]);
LOCAL_ALIGNED_16
(
int32_t
,
block
,
[
SAMPLES_PER_SUBBAND
*
DCA_SUBBANDS
]);
/*
/*
* Audio data
* Audio data
...
@@ -825,7 +827,7 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
...
@@ -825,7 +827,7 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
*/
*/
if
(
!
abits
)
{
if
(
!
abits
)
{
rscale
[
l
]
=
0
;
rscale
[
l
]
=
0
;
memset
(
block
+
8
*
l
,
0
,
8
*
sizeof
(
block
[
0
]));
memset
(
block
+
SAMPLES_PER_SUBBAND
*
l
,
0
,
SAMPLES_PER_SUBBAND
*
sizeof
(
block
[
0
]));
}
else
{
}
else
{
/* Deal with transients */
/* Deal with transients */
int
sfi
=
s
->
transition_mode
[
k
][
l
]
&&
subsubframe
>=
s
->
transition_mode
[
k
][
l
];
int
sfi
=
s
->
transition_mode
[
k
][
l
]
&&
subsubframe
>=
s
->
transition_mode
[
k
][
l
];
...
@@ -843,7 +845,7 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
...
@@ -843,7 +845,7 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
block_code1
=
get_bits
(
&
s
->
gb
,
size
);
block_code1
=
get_bits
(
&
s
->
gb
,
size
);
block_code2
=
get_bits
(
&
s
->
gb
,
size
);
block_code2
=
get_bits
(
&
s
->
gb
,
size
);
err
=
decode_blockcodes
(
block_code1
,
block_code2
,
err
=
decode_blockcodes
(
block_code1
,
block_code2
,
levels
,
block
+
8
*
l
);
levels
,
block
+
SAMPLES_PER_SUBBAND
*
l
);
if
(
err
)
{
if
(
err
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"ERROR: block code look-up failed
\n
"
);
"ERROR: block code look-up failed
\n
"
);
...
@@ -851,20 +853,20 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
...
@@ -851,20 +853,20 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
}
}
}
else
{
}
else
{
/* no coding */
/* no coding */
for
(
m
=
0
;
m
<
8
;
m
++
)
for
(
m
=
0
;
m
<
SAMPLES_PER_SUBBAND
;
m
++
)
block
[
8
*
l
+
m
]
=
get_sbits
(
&
s
->
gb
,
abits
-
3
);
block
[
SAMPLES_PER_SUBBAND
*
l
+
m
]
=
get_sbits
(
&
s
->
gb
,
abits
-
3
);
}
}
}
else
{
}
else
{
/* Huffman coded */
/* Huffman coded */
for
(
m
=
0
;
m
<
8
;
m
++
)
for
(
m
=
0
;
m
<
SAMPLES_PER_SUBBAND
;
m
++
)
block
[
8
*
l
+
m
]
=
get_bitalloc
(
&
s
->
gb
,
block
[
SAMPLES_PER_SUBBAND
*
l
+
m
]
=
get_bitalloc
(
&
s
->
gb
,
&
dca_smpl_bitalloc
[
abits
],
sel
);
&
dca_smpl_bitalloc
[
abits
],
sel
);
}
}
}
}
}
}
s
->
fmt_conv
.
int32_to_float_fmul_array8
(
&
s
->
fmt_conv
,
subband_samples
[
k
][
0
],
s
->
fmt_conv
.
int32_to_float_fmul_array8
(
&
s
->
fmt_conv
,
subband_samples
[
k
][
0
],
block
,
rscale
,
8
*
s
->
vq_start_subband
[
k
]);
block
,
rscale
,
SAMPLES_PER_SUBBAND
*
s
->
vq_start_subband
[
k
]);
for
(
l
=
0
;
l
<
s
->
vq_start_subband
[
k
];
l
++
)
{
for
(
l
=
0
;
l
<
s
->
vq_start_subband
[
k
];
l
++
)
{
int
m
;
int
m
;
...
@@ -883,7 +885,7 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
...
@@ -883,7 +885,7 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
ff_dca_adpcm_vb
[
s
->
prediction_vq
[
k
][
l
]][
3
]
*
ff_dca_adpcm_vb
[
s
->
prediction_vq
[
k
][
l
]][
3
]
*
s
->
subband_samples_hist
[
k
][
l
][
0
])
*
s
->
subband_samples_hist
[
k
][
l
][
0
])
*
(
1
.
0
f
/
8192
);
(
1
.
0
f
/
8192
);
for
(
m
=
1
;
m
<
8
;
m
++
)
{
for
(
m
=
1
;
m
<
SAMPLES_PER_SUBBAND
;
m
++
)
{
float
sum
=
ff_dca_adpcm_vb
[
s
->
prediction_vq
[
k
][
l
]][
0
]
*
float
sum
=
ff_dca_adpcm_vb
[
s
->
prediction_vq
[
k
][
l
]][
0
]
*
subband_samples
[
k
][
l
][
m
-
1
];
subband_samples
[
k
][
l
][
m
-
1
];
for
(
n
=
2
;
n
<=
4
;
n
++
)
for
(
n
=
2
;
n
<=
4
;
n
++
)
...
@@ -908,7 +910,7 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
...
@@ -908,7 +910,7 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
s
->
debug_flag
|=
0x01
;
s
->
debug_flag
|=
0x01
;
}
}
s
->
dcadsp
.
decode_hf
(
subband_samples
[
k
],
s
->
high_freq_vq
[
k
],
s
->
dcadsp
.
decode_hf
(
subband_samples
[
k
],
s
->
high_freq_vq
[
k
],
ff_dca_high_freq_vq
,
subsubframe
*
8
,
ff_dca_high_freq_vq
,
subsubframe
*
SAMPLES_PER_SUBBAND
,
s
->
scale_factor
[
k
],
s
->
vq_start_subband
[
k
],
s
->
scale_factor
[
k
],
s
->
vq_start_subband
[
k
],
s
->
subband_activity
[
k
]);
s
->
subband_activity
[
k
]);
}
}
...
@@ -932,7 +934,7 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
...
@@ -932,7 +934,7 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
static
int
dca_filter_channels
(
DCAContext
*
s
,
int
block_index
,
int
upsample
)
static
int
dca_filter_channels
(
DCAContext
*
s
,
int
block_index
,
int
upsample
)
{
{
float
(
*
subband_samples
)[
DCA_SUBBANDS
][
8
]
=
s
->
subband_samples
[
block_index
];
float
(
*
subband_samples
)[
DCA_SUBBANDS
][
SAMPLES_PER_SUBBAND
]
=
s
->
subband_samples
[
block_index
];
int
k
;
int
k
;
if
(
upsample
)
{
if
(
upsample
)
{
...
@@ -1377,7 +1379,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1377,7 +1379,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
s
->
profile
=
FF_PROFILE_DTS
;
s
->
profile
=
FF_PROFILE_DTS
;
for
(
i
=
0
;
i
<
(
s
->
sample_blocks
/
8
);
i
++
)
{
for
(
i
=
0
;
i
<
(
s
->
sample_blocks
/
SAMPLES_PER_SUBBAND
);
i
++
)
{
if
((
ret
=
dca_decode_block
(
s
,
0
,
i
)))
{
if
((
ret
=
dca_decode_block
(
s
,
0
,
i
)))
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"error decoding block
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"error decoding block
\n
"
);
return
ret
;
return
ret
;
...
@@ -1404,7 +1406,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1404,7 +1406,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
avctx
->
channels
=
channels
;
avctx
->
channels
=
channels
;
/* get output buffer */
/* get output buffer */
frame
->
nb_samples
=
256
*
(
s
->
sample_blocks
/
8
);
frame
->
nb_samples
=
256
*
(
s
->
sample_blocks
/
SAMPLES_PER_SUBBAND
);
if
(
s
->
exss_ext_mask
&
DCA_EXT_EXSS_XLL
)
{
if
(
s
->
exss_ext_mask
&
DCA_EXT_EXSS_XLL
)
{
int
xll_nb_samples
=
s
->
xll_segments
*
s
->
xll_smpl_in_seg
;
int
xll_nb_samples
=
s
->
xll_segments
*
s
->
xll_smpl_in_seg
;
/* Check for invalid/unsupported conditions first */
/* Check for invalid/unsupported conditions first */
...
@@ -1470,7 +1472,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1470,7 +1472,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
}
}
/* filter to get final output */
/* filter to get final output */
for
(
i
=
0
;
i
<
(
s
->
sample_blocks
/
8
);
i
++
)
{
for
(
i
=
0
;
i
<
(
s
->
sample_blocks
/
SAMPLES_PER_SUBBAND
);
i
++
)
{
int
ch
;
int
ch
;
unsigned
block
=
upsample
?
512
:
256
;
unsigned
block
=
upsample
?
512
:
256
;
for
(
ch
=
0
;
ch
<
channels
;
ch
++
)
for
(
ch
=
0
;
ch
<
channels
;
ch
++
)
...
@@ -1492,7 +1494,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1492,7 +1494,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
}
}
/* update lfe history */
/* update lfe history */
lfe_samples
=
2
*
s
->
lfe
*
(
s
->
sample_blocks
/
8
);
lfe_samples
=
2
*
s
->
lfe
*
(
s
->
sample_blocks
/
SAMPLES_PER_SUBBAND
);
for
(
i
=
0
;
i
<
2
*
s
->
lfe
*
4
;
i
++
)
for
(
i
=
0
;
i
<
2
*
s
->
lfe
*
4
;
i
++
)
s
->
lfe_data
[
i
]
=
s
->
lfe_data
[
i
+
lfe_samples
];
s
->
lfe_data
[
i
]
=
s
->
lfe_data
[
i
+
lfe_samples
];
...
...
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