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
75439bb3
Commit
75439bb3
authored
Feb 03, 2015
by
Diego Biurrun
Committed by
Vittorio Giovara
Feb 03, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
siff: K&R formatting cosmetics
parent
11e05533
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
40 deletions
+41
-40
siff.c
libavformat/siff.c
+41
-40
No files found.
libavformat/siff.c
View file @
75439bb3
...
@@ -21,10 +21,11 @@
...
@@ -21,10 +21,11 @@
#include "libavutil/channel_layout.h"
#include "libavutil/channel_layout.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "avformat.h"
#include "internal.h"
#include "internal.h"
enum
SIFFTags
{
enum
SIFFTags
{
TAG_SIFF
=
MKTAG
(
'S'
,
'I'
,
'F'
,
'F'
),
TAG_SIFF
=
MKTAG
(
'S'
,
'I'
,
'F'
,
'F'
),
TAG_BODY
=
MKTAG
(
'B'
,
'O'
,
'D'
,
'Y'
),
TAG_BODY
=
MKTAG
(
'B'
,
'O'
,
'D'
,
'Y'
),
TAG_VBHD
=
MKTAG
(
'V'
,
'B'
,
'H'
,
'D'
),
TAG_VBHD
=
MKTAG
(
'V'
,
'B'
,
'H'
,
'D'
),
...
@@ -33,7 +34,7 @@ enum SIFFTags{
...
@@ -33,7 +34,7 @@ enum SIFFTags{
TAG_SOUN
=
MKTAG
(
'S'
,
'O'
,
'U'
,
'N'
),
TAG_SOUN
=
MKTAG
(
'S'
,
'O'
,
'U'
,
'N'
),
};
};
enum
VBFlags
{
enum
VBFlags
{
VB_HAS_GMC
=
0x01
,
VB_HAS_GMC
=
0x01
,
VB_HAS_AUDIO
=
0x04
,
VB_HAS_AUDIO
=
0x04
,
VB_HAS_VIDEO
=
0x08
,
VB_HAS_VIDEO
=
0x08
,
...
@@ -41,7 +42,7 @@ enum VBFlags{
...
@@ -41,7 +42,7 @@ enum VBFlags{
VB_HAS_LENGTH
=
0x20
VB_HAS_LENGTH
=
0x20
};
};
typedef
struct
SIFFContext
{
typedef
struct
SIFFContext
{
int
frames
;
int
frames
;
int
cur_frame
;
int
cur_frame
;
int
rate
;
int
rate
;
...
@@ -58,7 +59,7 @@ typedef struct SIFFContext{
...
@@ -58,7 +59,7 @@ typedef struct SIFFContext{
int
flags
;
int
flags
;
uint8_t
gmc
[
4
];
uint8_t
gmc
[
4
];
}
SIFFContext
;
}
SIFFContext
;
static
int
siff_probe
(
AVProbeData
*
p
)
static
int
siff_probe
(
AVProbeData
*
p
)
{
{
...
@@ -92,15 +93,15 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb)
...
@@ -92,15 +93,15 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb)
AVStream
*
st
;
AVStream
*
st
;
int
width
,
height
;
int
width
,
height
;
if
(
avio_rl32
(
pb
)
!=
TAG_VBHD
){
if
(
avio_rl32
(
pb
)
!=
TAG_VBHD
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Header chunk is missing
\n
"
);
av_log
(
s
,
AV_LOG_ERROR
,
"Header chunk is missing
\n
"
);
return
-
1
;
return
-
1
;
}
}
if
(
avio_rb32
(
pb
)
!=
32
)
{
if
(
avio_rb32
(
pb
)
!=
32
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Header chunk size is incorrect
\n
"
);
av_log
(
s
,
AV_LOG_ERROR
,
"Header chunk size is incorrect
\n
"
);
return
-
1
;
return
-
1
;
}
}
if
(
avio_rl16
(
pb
)
!=
1
)
{
if
(
avio_rl16
(
pb
)
!=
1
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Incorrect header version
\n
"
);
av_log
(
s
,
AV_LOG_ERROR
,
"Incorrect header version
\n
"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -108,7 +109,7 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb)
...
@@ -108,7 +109,7 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb)
height
=
avio_rl16
(
pb
);
height
=
avio_rl16
(
pb
);
avio_skip
(
pb
,
4
);
avio_skip
(
pb
,
4
);
c
->
frames
=
avio_rl16
(
pb
);
c
->
frames
=
avio_rl16
(
pb
);
if
(
!
c
->
frames
)
{
if
(
!
c
->
frames
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"File contains no frames ???
\n
"
);
av_log
(
s
,
AV_LOG_ERROR
,
"File contains no frames ???
\n
"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -116,7 +117,7 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb)
...
@@ -116,7 +117,7 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb)
c
->
rate
=
avio_rl16
(
pb
);
c
->
rate
=
avio_rl16
(
pb
);
c
->
block_align
=
c
->
rate
*
(
c
->
bits
>>
3
);
c
->
block_align
=
c
->
rate
*
(
c
->
bits
>>
3
);
avio_skip
(
pb
,
16
);
//zeroes
avio_skip
(
pb
,
16
);
//
zeroes
st
=
avformat_new_stream
(
s
,
NULL
);
st
=
avformat_new_stream
(
s
,
NULL
);
if
(
!
st
)
if
(
!
st
)
...
@@ -140,15 +141,15 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb)
...
@@ -140,15 +141,15 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb)
static
int
siff_parse_soun
(
AVFormatContext
*
s
,
SIFFContext
*
c
,
AVIOContext
*
pb
)
static
int
siff_parse_soun
(
AVFormatContext
*
s
,
SIFFContext
*
c
,
AVIOContext
*
pb
)
{
{
if
(
avio_rl32
(
pb
)
!=
TAG_SHDR
){
if
(
avio_rl32
(
pb
)
!=
TAG_SHDR
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Header chunk is missing
\n
"
);
av_log
(
s
,
AV_LOG_ERROR
,
"Header chunk is missing
\n
"
);
return
-
1
;
return
-
1
;
}
}
if
(
avio_rb32
(
pb
)
!=
8
)
{
if
(
avio_rb32
(
pb
)
!=
8
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Header chunk size is incorrect
\n
"
);
av_log
(
s
,
AV_LOG_ERROR
,
"Header chunk size is incorrect
\n
"
);
return
-
1
;
return
-
1
;
}
}
avio_skip
(
pb
,
4
);
//unknown value
avio_skip
(
pb
,
4
);
//
unknown value
c
->
rate
=
avio_rl16
(
pb
);
c
->
rate
=
avio_rl16
(
pb
);
c
->
bits
=
avio_rl16
(
pb
);
c
->
bits
=
avio_rl16
(
pb
);
c
->
block_align
=
c
->
rate
*
(
c
->
bits
>>
3
);
c
->
block_align
=
c
->
rate
*
(
c
->
bits
>>
3
);
...
@@ -163,10 +164,10 @@ static int siff_read_header(AVFormatContext *s)
...
@@ -163,10 +164,10 @@ static int siff_read_header(AVFormatContext *s)
if
(
avio_rl32
(
pb
)
!=
TAG_SIFF
)
if
(
avio_rl32
(
pb
)
!=
TAG_SIFF
)
return
-
1
;
return
-
1
;
avio_skip
(
pb
,
4
);
//ignore size
avio_skip
(
pb
,
4
);
//
ignore size
tag
=
avio_rl32
(
pb
);
tag
=
avio_rl32
(
pb
);
if
(
tag
!=
TAG_VBV1
&&
tag
!=
TAG_SOUN
){
if
(
tag
!=
TAG_VBV1
&&
tag
!=
TAG_SOUN
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Not a VBV file
\n
"
);
av_log
(
s
,
AV_LOG_ERROR
,
"Not a VBV file
\n
"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -175,11 +176,11 @@ static int siff_read_header(AVFormatContext *s)
...
@@ -175,11 +176,11 @@ static int siff_read_header(AVFormatContext *s)
return
-
1
;
return
-
1
;
if
(
tag
==
TAG_SOUN
&&
siff_parse_soun
(
s
,
c
,
pb
)
<
0
)
if
(
tag
==
TAG_SOUN
&&
siff_parse_soun
(
s
,
c
,
pb
)
<
0
)
return
-
1
;
return
-
1
;
if
(
avio_rl32
(
pb
)
!=
MKTAG
(
'B'
,
'O'
,
'D'
,
'Y'
)){
if
(
avio_rl32
(
pb
)
!=
MKTAG
(
'B'
,
'O'
,
'D'
,
'Y'
))
{
av_log
(
s
,
AV_LOG_ERROR
,
"'BODY' chunk is missing
\n
"
);
av_log
(
s
,
AV_LOG_ERROR
,
"'BODY' chunk is missing
\n
"
);
return
-
1
;
return
-
1
;
}
}
avio_skip
(
pb
,
4
);
//ignore size
avio_skip
(
pb
,
4
);
//
ignore size
return
0
;
return
0
;
}
}
...
@@ -189,20 +190,20 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -189,20 +190,20 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt)
SIFFContext
*
c
=
s
->
priv_data
;
SIFFContext
*
c
=
s
->
priv_data
;
int
size
;
int
size
;
if
(
c
->
has_video
){
if
(
c
->
has_video
)
{
if
(
c
->
cur_frame
>=
c
->
frames
)
if
(
c
->
cur_frame
>=
c
->
frames
)
return
AVERROR
(
EIO
);
return
AVERROR
(
EIO
);
if
(
c
->
curstrm
==
-
1
){
if
(
c
->
curstrm
==
-
1
)
{
c
->
pktsize
=
avio_rl32
(
s
->
pb
)
-
4
;
c
->
pktsize
=
avio_rl32
(
s
->
pb
)
-
4
;
c
->
flags
=
avio_rl16
(
s
->
pb
);
c
->
flags
=
avio_rl16
(
s
->
pb
);
c
->
gmcsize
=
(
c
->
flags
&
VB_HAS_GMC
)
?
4
:
0
;
c
->
gmcsize
=
(
c
->
flags
&
VB_HAS_GMC
)
?
4
:
0
;
if
(
c
->
gmcsize
)
if
(
c
->
gmcsize
)
avio_read
(
s
->
pb
,
c
->
gmc
,
c
->
gmcsize
);
avio_read
(
s
->
pb
,
c
->
gmc
,
c
->
gmcsize
);
c
->
sndsize
=
(
c
->
flags
&
VB_HAS_AUDIO
)
?
avio_rl32
(
s
->
pb
)
:
0
;
c
->
sndsize
=
(
c
->
flags
&
VB_HAS_AUDIO
)
?
avio_rl32
(
s
->
pb
)
:
0
;
c
->
curstrm
=
!!
(
c
->
flags
&
VB_HAS_AUDIO
);
c
->
curstrm
=
!!
(
c
->
flags
&
VB_HAS_AUDIO
);
}
}
if
(
!
c
->
curstrm
){
if
(
!
c
->
curstrm
)
{
size
=
c
->
pktsize
-
c
->
sndsize
;
size
=
c
->
pktsize
-
c
->
sndsize
;
if
(
av_new_packet
(
pkt
,
size
)
<
0
)
if
(
av_new_packet
(
pkt
,
size
)
<
0
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
...
@@ -212,20 +213,20 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -212,20 +213,20 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt)
avio_read
(
s
->
pb
,
pkt
->
data
+
2
+
c
->
gmcsize
,
size
-
c
->
gmcsize
-
2
);
avio_read
(
s
->
pb
,
pkt
->
data
+
2
+
c
->
gmcsize
,
size
-
c
->
gmcsize
-
2
);
pkt
->
stream_index
=
0
;
pkt
->
stream_index
=
0
;
c
->
curstrm
=
-
1
;
c
->
curstrm
=
-
1
;
}
else
{
}
else
{
if
((
size
=
av_get_packet
(
s
->
pb
,
pkt
,
c
->
sndsize
-
4
))
<
0
)
if
((
size
=
av_get_packet
(
s
->
pb
,
pkt
,
c
->
sndsize
-
4
))
<
0
)
return
AVERROR
(
EIO
);
return
AVERROR
(
EIO
);
pkt
->
stream_index
=
1
;
pkt
->
stream_index
=
1
;
pkt
->
duration
=
size
;
pkt
->
duration
=
size
;
c
->
curstrm
=
0
;
c
->
curstrm
=
0
;
}
}
if
(
!
c
->
cur_frame
||
c
->
curstrm
)
if
(
!
c
->
cur_frame
||
c
->
curstrm
)
pkt
->
flags
|=
AV_PKT_FLAG_KEY
;
pkt
->
flags
|=
AV_PKT_FLAG_KEY
;
if
(
c
->
curstrm
==
-
1
)
if
(
c
->
curstrm
==
-
1
)
c
->
cur_frame
++
;
c
->
cur_frame
++
;
}
else
{
}
else
{
size
=
av_get_packet
(
s
->
pb
,
pkt
,
c
->
block_align
);
size
=
av_get_packet
(
s
->
pb
,
pkt
,
c
->
block_align
);
if
(
size
<=
0
)
if
(
size
<=
0
)
return
AVERROR
(
EIO
);
return
AVERROR
(
EIO
);
pkt
->
duration
=
size
;
pkt
->
duration
=
size
;
}
}
...
...
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