Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
f44059d2
Commit
f44059d2
authored
Oct 27, 2011
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dca: return proper error codes instead of -1
parent
46e1af3b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
24 deletions
+25
-24
dca.c
libavcodec/dca.c
+25
-24
No files found.
libavcodec/dca.c
View file @
f44059d2
...
@@ -529,15 +529,15 @@ static int dca_parse_frame_header(DCAContext * s)
...
@@ -529,15 +529,15 @@ static int dca_parse_frame_header(DCAContext * s)
s
->
sample_blocks
=
get_bits
(
&
s
->
gb
,
7
)
+
1
;
s
->
sample_blocks
=
get_bits
(
&
s
->
gb
,
7
)
+
1
;
s
->
frame_size
=
get_bits
(
&
s
->
gb
,
14
)
+
1
;
s
->
frame_size
=
get_bits
(
&
s
->
gb
,
14
)
+
1
;
if
(
s
->
frame_size
<
95
)
if
(
s
->
frame_size
<
95
)
return
-
1
;
return
AVERROR_INVALIDDATA
;
s
->
amode
=
get_bits
(
&
s
->
gb
,
6
);
s
->
amode
=
get_bits
(
&
s
->
gb
,
6
);
s
->
sample_rate
=
dca_sample_rates
[
get_bits
(
&
s
->
gb
,
4
)];
s
->
sample_rate
=
dca_sample_rates
[
get_bits
(
&
s
->
gb
,
4
)];
if
(
!
s
->
sample_rate
)
if
(
!
s
->
sample_rate
)
return
-
1
;
return
AVERROR_INVALIDDATA
;
s
->
bit_rate_index
=
get_bits
(
&
s
->
gb
,
5
);
s
->
bit_rate_index
=
get_bits
(
&
s
->
gb
,
5
);
s
->
bit_rate
=
dca_bit_rates
[
s
->
bit_rate_index
];
s
->
bit_rate
=
dca_bit_rates
[
s
->
bit_rate_index
];
if
(
!
s
->
bit_rate
)
if
(
!
s
->
bit_rate
)
return
-
1
;
return
AVERROR_INVALIDDATA
;
s
->
downmix
=
get_bits
(
&
s
->
gb
,
1
);
s
->
downmix
=
get_bits
(
&
s
->
gb
,
1
);
s
->
dynrange
=
get_bits
(
&
s
->
gb
,
1
);
s
->
dynrange
=
get_bits
(
&
s
->
gb
,
1
);
...
@@ -627,7 +627,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
...
@@ -627,7 +627,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
int
j
,
k
;
int
j
,
k
;
if
(
get_bits_left
(
&
s
->
gb
)
<
0
)
if
(
get_bits_left
(
&
s
->
gb
)
<
0
)
return
-
1
;
return
AVERROR_INVALIDDATA
;
if
(
!
base_channel
)
{
if
(
!
base_channel
)
{
s
->
subsubframes
[
s
->
current_subframe
]
=
get_bits
(
&
s
->
gb
,
2
)
+
1
;
s
->
subsubframes
[
s
->
current_subframe
]
=
get_bits
(
&
s
->
gb
,
2
)
+
1
;
...
@@ -659,7 +659,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
...
@@ -659,7 +659,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
else
if
(
s
->
bitalloc_huffman
[
j
]
==
7
)
{
else
if
(
s
->
bitalloc_huffman
[
j
]
==
7
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Invalid bit allocation index
\n
"
);
"Invalid bit allocation index
\n
"
);
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
else
{
}
else
{
s
->
bitalloc
[
j
][
k
]
=
s
->
bitalloc
[
j
][
k
]
=
get_bitalloc
(
&
s
->
gb
,
&
dca_bitalloc_index
,
s
->
bitalloc_huffman
[
j
]);
get_bitalloc
(
&
s
->
gb
,
&
dca_bitalloc_index
,
s
->
bitalloc_huffman
[
j
]);
...
@@ -668,7 +668,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
...
@@ -668,7 +668,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
if
(
s
->
bitalloc
[
j
][
k
]
>
26
)
{
if
(
s
->
bitalloc
[
j
][
k
]
>
26
)
{
// av_log(s->avctx,AV_LOG_DEBUG,"bitalloc index [%i][%i] too big (%i)\n",
// av_log(s->avctx,AV_LOG_DEBUG,"bitalloc index [%i][%i] too big (%i)\n",
// j, k, s->bitalloc[j][k]);
// j, k, s->bitalloc[j][k]);
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
}
}
}
}
}
...
@@ -686,7 +686,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
...
@@ -686,7 +686,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
}
}
if
(
get_bits_left
(
&
s
->
gb
)
<
0
)
if
(
get_bits_left
(
&
s
->
gb
)
<
0
)
return
-
1
;
return
AVERROR_INVALIDDATA
;
for
(
j
=
base_channel
;
j
<
s
->
prim_channels
;
j
++
)
{
for
(
j
=
base_channel
;
j
<
s
->
prim_channels
;
j
++
)
{
const
uint32_t
*
scale_table
;
const
uint32_t
*
scale_table
;
...
@@ -724,7 +724,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
...
@@ -724,7 +724,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
}
}
if
(
get_bits_left
(
&
s
->
gb
)
<
0
)
if
(
get_bits_left
(
&
s
->
gb
)
<
0
)
return
-
1
;
return
AVERROR_INVALIDDATA
;
/* Scale factors for joint subband coding */
/* Scale factors for joint subband coding */
for
(
j
=
base_channel
;
j
<
s
->
prim_channels
;
j
++
)
{
for
(
j
=
base_channel
;
j
<
s
->
prim_channels
;
j
++
)
{
...
@@ -1055,7 +1055,7 @@ static int decode_blockcode(int code, int levels, int *values)
...
@@ -1055,7 +1055,7 @@ static int decode_blockcode(int code, int levels, int *values)
return
0
;
return
0
;
else
{
else
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"ERROR: block code look-up failed
\n
"
);
av_log
(
NULL
,
AV_LOG_ERROR
,
"ERROR: block code look-up failed
\n
"
);
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
}
}
}
...
@@ -1095,7 +1095,7 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index)
...
@@ -1095,7 +1095,7 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index)
for
(
k
=
base_channel
;
k
<
s
->
prim_channels
;
k
++
)
{
for
(
k
=
base_channel
;
k
<
s
->
prim_channels
;
k
++
)
{
if
(
get_bits_left
(
&
s
->
gb
)
<
0
)
if
(
get_bits_left
(
&
s
->
gb
)
<
0
)
return
-
1
;
return
AVERROR_INVALIDDATA
;
for
(
l
=
0
;
l
<
s
->
vq_start_subband
[
k
];
l
++
)
{
for
(
l
=
0
;
l
<
s
->
vq_start_subband
[
k
];
l
++
)
{
int
m
;
int
m
;
...
@@ -1274,12 +1274,13 @@ static int dca_subframe_footer(DCAContext * s, int base_channel)
...
@@ -1274,12 +1274,13 @@ static int dca_subframe_footer(DCAContext * s, int base_channel)
static
int
dca_decode_block
(
DCAContext
*
s
,
int
base_channel
,
int
block_index
)
static
int
dca_decode_block
(
DCAContext
*
s
,
int
base_channel
,
int
block_index
)
{
{
int
ret
;
/* Sanity check */
/* Sanity check */
if
(
s
->
current_subframe
>=
s
->
subframes
)
{
if
(
s
->
current_subframe
>=
s
->
subframes
)
{
av_log
(
s
->
avctx
,
AV_LOG_DEBUG
,
"check failed: %i>%i"
,
av_log
(
s
->
avctx
,
AV_LOG_DEBUG
,
"check failed: %i>%i"
,
s
->
current_subframe
,
s
->
subframes
);
s
->
current_subframe
,
s
->
subframes
);
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
}
if
(
!
s
->
current_subsubframe
)
{
if
(
!
s
->
current_subsubframe
)
{
...
@@ -1287,16 +1288,16 @@ static int dca_decode_block(DCAContext * s, int base_channel, int block_index)
...
@@ -1287,16 +1288,16 @@ static int dca_decode_block(DCAContext * s, int base_channel, int block_index)
av_log
(
s
->
avctx
,
AV_LOG_DEBUG
,
"DSYNC dca_subframe_header
\n
"
);
av_log
(
s
->
avctx
,
AV_LOG_DEBUG
,
"DSYNC dca_subframe_header
\n
"
);
#endif
#endif
/* Read subframe header */
/* Read subframe header */
if
(
dca_subframe_header
(
s
,
base_channel
,
block_index
))
if
(
(
ret
=
dca_subframe_header
(
s
,
base_channel
,
block_index
)
))
return
-
1
;
return
ret
;
}
}
/* Read subsubframe */
/* Read subsubframe */
#ifdef TRACE
#ifdef TRACE
av_log
(
s
->
avctx
,
AV_LOG_DEBUG
,
"DSYNC dca_subsubframe
\n
"
);
av_log
(
s
->
avctx
,
AV_LOG_DEBUG
,
"DSYNC dca_subsubframe
\n
"
);
#endif
#endif
if
(
dca_subsubframe
(
s
,
base_channel
,
block_index
))
if
(
(
ret
=
dca_subsubframe
(
s
,
base_channel
,
block_index
)
))
return
-
1
;
return
ret
;
/* Update state */
/* Update state */
s
->
current_subsubframe
++
;
s
->
current_subsubframe
++
;
...
@@ -1309,8 +1310,8 @@ static int dca_decode_block(DCAContext * s, int base_channel, int block_index)
...
@@ -1309,8 +1310,8 @@ static int dca_decode_block(DCAContext * s, int base_channel, int block_index)
av_log
(
s
->
avctx
,
AV_LOG_DEBUG
,
"DSYNC dca_subframe_footer
\n
"
);
av_log
(
s
->
avctx
,
AV_LOG_DEBUG
,
"DSYNC dca_subframe_footer
\n
"
);
#endif
#endif
/* Read subframe footer */
/* Read subframe footer */
if
(
dca_subframe_footer
(
s
,
base_channel
))
if
(
(
ret
=
dca_subframe_footer
(
s
,
base_channel
)
))
return
-
1
;
return
ret
;
}
}
return
0
;
return
0
;
...
@@ -1353,7 +1354,7 @@ static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * ds
...
@@ -1353,7 +1354,7 @@ static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * ds
flush_put_bits
(
&
pb
);
flush_put_bits
(
&
pb
);
return
(
put_bits_count
(
&
pb
)
+
7
)
>>
3
;
return
(
put_bits_count
(
&
pb
)
+
7
)
>>
3
;
default:
default:
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
}
}
}
...
@@ -1649,9 +1650,9 @@ static int dca_decode_frame(AVCodecContext * avctx,
...
@@ -1649,9 +1650,9 @@ static int dca_decode_frame(AVCodecContext * avctx,
s
->
dca_buffer_size
=
dca_convert_bitstream
(
buf
,
buf_size
,
s
->
dca_buffer
,
s
->
dca_buffer_size
=
dca_convert_bitstream
(
buf
,
buf_size
,
s
->
dca_buffer
,
DCA_MAX_FRAME_SIZE
+
DCA_MAX_EXSS_HEADER_SIZE
);
DCA_MAX_FRAME_SIZE
+
DCA_MAX_EXSS_HEADER_SIZE
);
if
(
s
->
dca_buffer_size
==
-
1
)
{
if
(
s
->
dca_buffer_size
==
AVERROR_INVALIDDATA
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Not a valid DCA frame
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Not a valid DCA frame
\n
"
);
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
}
init_get_bits
(
&
s
->
gb
,
s
->
dca_buffer
,
s
->
dca_buffer_size
*
8
);
init_get_bits
(
&
s
->
gb
,
s
->
dca_buffer
,
s
->
dca_buffer_size
*
8
);
...
@@ -1798,7 +1799,7 @@ static int dca_decode_frame(AVCodecContext * avctx,
...
@@ -1798,7 +1799,7 @@ static int dca_decode_frame(AVCodecContext * avctx,
if
(
channels
>
!!
s
->
lfe
&&
if
(
channels
>
!!
s
->
lfe
&&
s
->
channel_order_tab
[
channels
-
1
-
!!
s
->
lfe
]
<
0
)
s
->
channel_order_tab
[
channels
-
1
-
!!
s
->
lfe
]
<
0
)
return
-
1
;
return
AVERROR_INVALIDDATA
;
if
(
avctx
->
request_channels
==
2
&&
s
->
prim_channels
>
2
)
{
if
(
avctx
->
request_channels
==
2
&&
s
->
prim_channels
>
2
)
{
channels
=
2
;
channels
=
2
;
...
@@ -1807,7 +1808,7 @@ static int dca_decode_frame(AVCodecContext * avctx,
...
@@ -1807,7 +1808,7 @@ static int dca_decode_frame(AVCodecContext * avctx,
}
}
}
else
{
}
else
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Non standard configuration %d !
\n
"
,
s
->
amode
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Non standard configuration %d !
\n
"
,
s
->
amode
);
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
}
...
@@ -1823,13 +1824,13 @@ static int dca_decode_frame(AVCodecContext * avctx,
...
@@ -1823,13 +1824,13 @@ static int dca_decode_frame(AVCodecContext * avctx,
if
(
avctx
->
channels
!=
channels
)
{
if
(
avctx
->
channels
!=
channels
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"DCA decoder does not support number of "
av_log
(
avctx
,
AV_LOG_ERROR
,
"DCA decoder does not support number of "
"channels changing in stream. Skipping frame.
\n
"
);
"channels changing in stream. Skipping frame.
\n
"
);
return
-
1
;
return
AVERROR_PATCHWELCOME
;
}
}
out_size
=
256
/
8
*
s
->
sample_blocks
*
channels
*
out_size
=
256
/
8
*
s
->
sample_blocks
*
channels
*
av_get_bytes_per_sample
(
avctx
->
sample_fmt
);
av_get_bytes_per_sample
(
avctx
->
sample_fmt
);
if
(
*
data_size
<
out_size
)
if
(
*
data_size
<
out_size
)
return
-
1
;
return
AVERROR
(
EINVAL
)
;
*
data_size
=
out_size
;
*
data_size
=
out_size
;
/* filter to get final output */
/* filter to get final output */
...
...
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