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
4ec509ce
Commit
4ec509ce
authored
May 05, 2013
by
Carl Eugen Hoyos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support demuxing of audio-only vmd files.
Reviewed-by: Paul B Mahol
parent
a07ac1f7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
sierravmd.c
libavformat/sierravmd.c
+14
-7
No files found.
libavformat/sierravmd.c
View file @
4ec509ce
...
...
@@ -64,8 +64,8 @@ typedef struct VmdDemuxContext {
static
int
vmd_probe
(
AVProbeData
*
p
)
{
int
w
,
h
;
if
(
p
->
buf_size
<
1
6
)
int
w
,
h
,
sample_rate
;
if
(
p
->
buf_size
<
80
6
)
return
0
;
/* check if the first 2 bytes of the file contain the appropriate size
* of a VMD header chunk */
...
...
@@ -73,7 +73,9 @@ static int vmd_probe(AVProbeData *p)
return
0
;
w
=
AV_RL16
(
&
p
->
buf
[
12
]);
h
=
AV_RL16
(
&
p
->
buf
[
14
]);
if
(
!
w
||
w
>
2048
||
!
h
||
h
>
2048
)
sample_rate
=
AV_RL16
(
&
p
->
buf
[
804
]);
if
((
!
w
||
w
>
2048
||
!
h
||
h
>
2048
)
&&
sample_rate
!=
22050
)
return
0
;
/* only return half certainty since this check is a bit sketchy */
...
...
@@ -84,12 +86,12 @@ static int vmd_read_header(AVFormatContext *s)
{
VmdDemuxContext
*
vmd
=
s
->
priv_data
;
AVIOContext
*
pb
=
s
->
pb
;
AVStream
*
st
=
NULL
,
*
vst
;
AVStream
*
st
=
NULL
,
*
vst
=
NULL
;
unsigned
int
toc_offset
;
unsigned
char
*
raw_frame_table
;
int
raw_frame_table_size
;
int64_t
current_offset
;
int
i
,
j
;
int
i
,
j
,
width
,
height
;
unsigned
int
total_frames
;
int64_t
current_audio_pts
=
0
;
unsigned
char
chunk
[
BYTES_PER_FRAME_RECORD
];
...
...
@@ -101,6 +103,9 @@ static int vmd_read_header(AVFormatContext *s)
if
(
avio_read
(
pb
,
vmd
->
vmd_header
,
VMD_HEADER_SIZE
)
!=
VMD_HEADER_SIZE
)
return
AVERROR
(
EIO
);
width
=
AV_RL16
(
&
vmd
->
vmd_header
[
12
]);
height
=
AV_RL16
(
&
vmd
->
vmd_header
[
14
]);
if
(
width
&&
height
)
{
if
(
vmd
->
vmd_header
[
24
]
==
'i'
&&
vmd
->
vmd_header
[
25
]
==
'v'
&&
vmd
->
vmd_header
[
26
]
==
'3'
)
vmd
->
is_indeo3
=
1
;
else
...
...
@@ -114,8 +119,8 @@ static int vmd_read_header(AVFormatContext *s)
vst
->
codec
->
codec_type
=
AVMEDIA_TYPE_VIDEO
;
vst
->
codec
->
codec_id
=
vmd
->
is_indeo3
?
AV_CODEC_ID_INDEO3
:
AV_CODEC_ID_VMDVIDEO
;
vst
->
codec
->
codec_tag
=
0
;
/* no fourcc */
vst
->
codec
->
width
=
AV_RL16
(
&
vmd
->
vmd_header
[
12
])
;
vst
->
codec
->
height
=
AV_RL16
(
&
vmd
->
vmd_header
[
14
])
;
vst
->
codec
->
width
=
width
;
vst
->
codec
->
height
=
height
;
if
(
vmd
->
is_indeo3
&&
vst
->
codec
->
width
>
320
){
vst
->
codec
->
width
>>=
1
;
vst
->
codec
->
height
>>=
1
;
...
...
@@ -123,6 +128,7 @@ static int vmd_read_header(AVFormatContext *s)
vst
->
codec
->
extradata_size
=
VMD_HEADER_SIZE
;
vst
->
codec
->
extradata
=
av_mallocz
(
VMD_HEADER_SIZE
+
FF_INPUT_BUFFER_PADDING_SIZE
);
memcpy
(
vst
->
codec
->
extradata
,
vmd
->
vmd_header
,
VMD_HEADER_SIZE
);
}
/* if sample rate is 0, assume no audio */
vmd
->
sample_rate
=
AV_RL16
(
&
vmd
->
vmd_header
[
804
]);
...
...
@@ -156,6 +162,7 @@ static int vmd_read_header(AVFormatContext *s)
num
=
st
->
codec
->
block_align
;
den
=
st
->
codec
->
sample_rate
*
st
->
codec
->
channels
;
av_reduce
(
&
num
,
&
den
,
num
,
den
,
(
1UL
<<
31
)
-
1
);
if
(
vst
)
avpriv_set_pts_info
(
vst
,
33
,
num
,
den
);
avpriv_set_pts_info
(
st
,
33
,
num
,
den
);
}
...
...
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