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
72d30b27
Commit
72d30b27
authored
Oct 02, 2012
by
Luca Barbato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nut: add do {} while (0) to GET_V
Make it consistent with the other function-like macros.
parent
b92dfb56
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
20 deletions
+22
-20
nutdec.c
libavformat/nutdec.c
+22
-20
No files found.
libavformat/nutdec.c
View file @
72d30b27
...
...
@@ -177,13 +177,15 @@ static int nut_probe(AVProbeData *p)
return
0
;
}
#define GET_V(dst, check) \
tmp = ffio_read_varlen(bc); \
if (!(check)) { \
av_log(s, AV_LOG_ERROR, "Error " #dst " is (%"PRId64")\n", tmp); \
return -1; \
} \
dst = tmp;
#define GET_V(dst, check) \
do { \
tmp = ffio_read_varlen(bc); \
if (!(check)) { \
av_log(s, AV_LOG_ERROR, "Error " #dst " is (%"PRId64")\n", tmp); \
return -1; \
} \
dst = tmp; \
} while (0)
static
int
skip_reserved
(
AVIOContext
*
bc
,
int64_t
pos
)
{
...
...
@@ -210,8 +212,8 @@ static int decode_main_header(NUTContext *nut)
end
=
get_packetheader
(
nut
,
bc
,
1
,
MAIN_STARTCODE
);
end
+=
avio_tell
(
bc
);
GET_V
(
tmp
,
tmp
>=
2
&&
tmp
<=
3
)
GET_V
(
stream_count
,
tmp
>
0
&&
tmp
<=
NUT_MAX_STREAMS
)
GET_V
(
tmp
,
tmp
>=
2
&&
tmp
<=
3
)
;
GET_V
(
stream_count
,
tmp
>
0
&&
tmp
<=
NUT_MAX_STREAMS
)
;
nut
->
max_distance
=
ffio_read_varlen
(
bc
);
if
(
nut
->
max_distance
>
65536
)
{
...
...
@@ -219,12 +221,12 @@ static int decode_main_header(NUTContext *nut)
nut
->
max_distance
=
65536
;
}
GET_V
(
nut
->
time_base_count
,
tmp
>
0
&&
tmp
<
INT_MAX
/
sizeof
(
AVRational
))
GET_V
(
nut
->
time_base_count
,
tmp
>
0
&&
tmp
<
INT_MAX
/
sizeof
(
AVRational
))
;
nut
->
time_base
=
av_malloc
(
nut
->
time_base_count
*
sizeof
(
AVRational
));
for
(
i
=
0
;
i
<
nut
->
time_base_count
;
i
++
)
{
GET_V
(
nut
->
time_base
[
i
].
num
,
tmp
>
0
&&
tmp
<
(
1ULL
<<
31
))
GET_V
(
nut
->
time_base
[
i
].
den
,
tmp
>
0
&&
tmp
<
(
1ULL
<<
31
))
GET_V
(
nut
->
time_base
[
i
].
num
,
tmp
>
0
&&
tmp
<
(
1ULL
<<
31
))
;
GET_V
(
nut
->
time_base
[
i
].
den
,
tmp
>
0
&&
tmp
<
(
1ULL
<<
31
))
;
if
(
av_gcd
(
nut
->
time_base
[
i
].
num
,
nut
->
time_base
[
i
].
den
)
!=
1
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"time base invalid
\n
"
);
return
AVERROR_INVALIDDATA
;
...
...
@@ -292,7 +294,7 @@ static int decode_main_header(NUTContext *nut)
if
(
end
>
avio_tell
(
bc
)
+
4
)
{
int
rem
=
1024
;
GET_V
(
nut
->
header_count
,
tmp
<
128U
)
GET_V
(
nut
->
header_count
,
tmp
<
128U
)
;
nut
->
header_count
++
;
for
(
i
=
1
;
i
<
nut
->
header_count
;
i
++
)
{
uint8_t
*
hdr
;
...
...
@@ -389,8 +391,8 @@ static int decode_stream_header(NUTContext *nut)
}
if
(
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_VIDEO
)
{
GET_V
(
st
->
codec
->
width
,
tmp
>
0
)
GET_V
(
st
->
codec
->
height
,
tmp
>
0
)
GET_V
(
st
->
codec
->
width
,
tmp
>
0
)
;
GET_V
(
st
->
codec
->
height
,
tmp
>
0
)
;
st
->
sample_aspect_ratio
.
num
=
ffio_read_varlen
(
bc
);
st
->
sample_aspect_ratio
.
den
=
ffio_read_varlen
(
bc
);
if
((
!
st
->
sample_aspect_ratio
.
num
)
!=
(
!
st
->
sample_aspect_ratio
.
den
))
{
...
...
@@ -400,9 +402,9 @@ static int decode_stream_header(NUTContext *nut)
}
ffio_read_varlen
(
bc
);
/* csp type */
}
else
if
(
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_AUDIO
)
{
GET_V
(
st
->
codec
->
sample_rate
,
tmp
>
0
)
GET_V
(
st
->
codec
->
sample_rate
,
tmp
>
0
)
;
ffio_read_varlen
(
bc
);
// samplerate_den
GET_V
(
st
->
codec
->
channels
,
tmp
>
0
)
GET_V
(
st
->
codec
->
channels
,
tmp
>
0
)
;
}
if
(
skip_reserved
(
bc
,
end
)
||
ffio_get_checksum
(
bc
))
{
av_log
(
s
,
AV_LOG_ERROR
,
...
...
@@ -447,7 +449,7 @@ static int decode_info_header(NUTContext *nut)
end
=
get_packetheader
(
nut
,
bc
,
1
,
INFO_STARTCODE
);
end
+=
avio_tell
(
bc
);
GET_V
(
stream_id_plus1
,
tmp
<=
s
->
nb_streams
)
GET_V
(
stream_id_plus1
,
tmp
<=
s
->
nb_streams
)
;
chapter_id
=
get_s
(
bc
);
chapter_start
=
ffio_read_varlen
(
bc
);
chapter_len
=
ffio_read_varlen
(
bc
);
...
...
@@ -565,7 +567,7 @@ static int find_and_decode_index(NUTContext *nut)
end
+=
avio_tell
(
bc
);
ffio_read_varlen
(
bc
);
// max_pts
GET_V
(
syncpoint_count
,
tmp
<
INT_MAX
/
8
&&
tmp
>
0
)
GET_V
(
syncpoint_count
,
tmp
<
INT_MAX
/
8
&&
tmp
>
0
)
;
syncpoints
=
av_malloc
(
sizeof
(
int64_t
)
*
syncpoint_count
);
has_keyframe
=
av_malloc
(
sizeof
(
int8_t
)
*
(
syncpoint_count
+
1
));
for
(
i
=
0
;
i
<
syncpoint_count
;
i
++
)
{
...
...
@@ -730,7 +732,7 @@ static int decode_frame_header(NUTContext *nut, int64_t *pts, int *stream_id,
if
(
flags
&
FLAG_CODED
)
flags
^=
ffio_read_varlen
(
bc
);
if
(
flags
&
FLAG_STREAM_ID
)
{
GET_V
(
*
stream_id
,
tmp
<
s
->
nb_streams
)
GET_V
(
*
stream_id
,
tmp
<
s
->
nb_streams
)
;
}
stc
=
&
nut
->
stream
[
*
stream_id
];
if
(
flags
&
FLAG_CODED_PTS
)
{
...
...
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