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
6bf4c1d7
Commit
6bf4c1d7
authored
Oct 21, 2015
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
r3d: do not create the audio stream until we know the sample rate
parent
9f1eccb9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
12 deletions
+25
-12
r3d.c
libavformat/r3d.c
+25
-12
No files found.
libavformat/r3d.c
View file @
6bf4c1d7
...
@@ -29,6 +29,8 @@ typedef struct R3DContext {
...
@@ -29,6 +29,8 @@ typedef struct R3DContext {
unsigned
video_offsets_count
;
unsigned
video_offsets_count
;
unsigned
*
video_offsets
;
unsigned
*
video_offsets
;
unsigned
rdvo_offset
;
unsigned
rdvo_offset
;
int
audio_channels
;
}
R3DContext
;
}
R3DContext
;
typedef
struct
Atom
{
typedef
struct
Atom
{
...
@@ -52,6 +54,7 @@ static int read_atom(AVFormatContext *s, Atom *atom)
...
@@ -52,6 +54,7 @@ static int read_atom(AVFormatContext *s, Atom *atom)
static
int
r3d_read_red1
(
AVFormatContext
*
s
)
static
int
r3d_read_red1
(
AVFormatContext
*
s
)
{
{
AVStream
*
st
=
avformat_new_stream
(
s
,
NULL
);
AVStream
*
st
=
avformat_new_stream
(
s
,
NULL
);
R3DContext
*
r3d
=
s
->
priv_data
;
char
filename
[
258
];
char
filename
[
258
];
int
tmp
;
int
tmp
;
int
av_unused
tmp2
;
int
av_unused
tmp2
;
...
@@ -89,17 +92,8 @@ static int r3d_read_red1(AVFormatContext *s)
...
@@ -89,17 +92,8 @@ static int r3d_read_red1(AVFormatContext *s)
st
->
avg_frame_rate
=
framerate
;
st
->
avg_frame_rate
=
framerate
;
}
}
tmp
=
avio_r8
(
s
->
pb
);
// audio channels
r3d
->
audio_channels
=
avio_r8
(
s
->
pb
);
// audio channels
av_log
(
s
,
AV_LOG_TRACE
,
"audio channels %d
\n
"
,
tmp
);
av_log
(
s
,
AV_LOG_TRACE
,
"audio channels %d
\n
"
,
tmp
);
if
(
tmp
>
0
)
{
AVStream
*
ast
=
avformat_new_stream
(
s
,
NULL
);
if
(
!
ast
)
return
AVERROR
(
ENOMEM
);
ast
->
codec
->
codec_type
=
AVMEDIA_TYPE_AUDIO
;
ast
->
codec
->
codec_id
=
AV_CODEC_ID_PCM_S32BE
;
ast
->
codec
->
channels
=
tmp
;
avpriv_set_pts_info
(
ast
,
32
,
1
,
st
->
time_base
.
den
);
}
avio_read
(
s
->
pb
,
filename
,
257
);
avio_read
(
s
->
pb
,
filename
,
257
);
filename
[
sizeof
(
filename
)
-
1
]
=
0
;
filename
[
sizeof
(
filename
)
-
1
]
=
0
;
...
@@ -183,6 +177,11 @@ static int r3d_read_header(AVFormatContext *s)
...
@@ -183,6 +177,11 @@ static int r3d_read_header(AVFormatContext *s)
return
-
1
;
return
-
1
;
}
}
/* we cannot create the audio stream now because we do not know the
* sample rate */
if
(
r3d
->
audio_channels
)
s
->
ctx_flags
|=
AVFMTCTX_NOHEADER
;
s
->
internal
->
data_offset
=
avio_tell
(
s
->
pb
);
s
->
internal
->
data_offset
=
avio_tell
(
s
->
pb
);
av_log
(
s
,
AV_LOG_TRACE
,
"data offset %#"
PRIx64
"
\n
"
,
s
->
internal
->
data_offset
);
av_log
(
s
,
AV_LOG_TRACE
,
"data offset %#"
PRIx64
"
\n
"
,
s
->
internal
->
data_offset
);
if
(
!
s
->
pb
->
seekable
)
if
(
!
s
->
pb
->
seekable
)
...
@@ -271,13 +270,26 @@ static int r3d_read_redv(AVFormatContext *s, AVPacket *pkt, Atom *atom)
...
@@ -271,13 +270,26 @@ static int r3d_read_redv(AVFormatContext *s, AVPacket *pkt, Atom *atom)
static
int
r3d_read_reda
(
AVFormatContext
*
s
,
AVPacket
*
pkt
,
Atom
*
atom
)
static
int
r3d_read_reda
(
AVFormatContext
*
s
,
AVPacket
*
pkt
,
Atom
*
atom
)
{
{
AVStream
*
st
=
s
->
streams
[
1
];
R3DContext
*
r3d
=
s
->
priv_data
;
AVStream
*
st
;
int
av_unused
tmp
,
tmp2
;
int
av_unused
tmp
,
tmp2
;
int
samples
,
size
;
int
samples
,
size
;
int64_t
pos
=
avio_tell
(
s
->
pb
);
int64_t
pos
=
avio_tell
(
s
->
pb
);
unsigned
dts
;
unsigned
dts
;
int
ret
;
int
ret
;
if
(
s
->
nb_streams
<
2
)
{
st
=
avformat_new_stream
(
s
,
NULL
);
if
(
!
st
)
return
AVERROR
(
ENOMEM
);
st
->
codec
->
codec_type
=
AVMEDIA_TYPE_AUDIO
;
st
->
codec
->
codec_id
=
AV_CODEC_ID_PCM_S32BE
;
st
->
codec
->
channels
=
r3d
->
audio_channels
;
avpriv_set_pts_info
(
st
,
32
,
1
,
s
->
streams
[
0
]
->
time_base
.
den
);
}
else
{
st
=
s
->
streams
[
1
];
}
dts
=
avio_rb32
(
s
->
pb
);
dts
=
avio_rb32
(
s
->
pb
);
st
->
codec
->
sample_rate
=
avio_rb32
(
s
->
pb
);
st
->
codec
->
sample_rate
=
avio_rb32
(
s
->
pb
);
...
@@ -321,6 +333,7 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
...
@@ -321,6 +333,7 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
static
int
r3d_read_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
)
static
int
r3d_read_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
)
{
{
R3DContext
*
r3d
=
s
->
priv_data
;
Atom
atom
;
Atom
atom
;
int
err
=
0
;
int
err
=
0
;
...
@@ -337,7 +350,7 @@ static int r3d_read_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -337,7 +350,7 @@ static int r3d_read_packet(AVFormatContext *s, AVPacket *pkt)
return
0
;
return
0
;
break
;
break
;
case
MKTAG
(
'R'
,
'E'
,
'D'
,
'A'
):
case
MKTAG
(
'R'
,
'E'
,
'D'
,
'A'
):
if
(
s
->
nb_streams
<
2
)
if
(
!
r3d
->
audio_channels
)
return
-
1
;
return
-
1
;
if
(
s
->
streams
[
1
]
->
discard
==
AVDISCARD_ALL
)
if
(
s
->
streams
[
1
]
->
discard
==
AVDISCARD_ALL
)
goto
skip
;
goto
skip
;
...
...
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