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
fa412150
Commit
fa412150
authored
Nov 20, 2017
by
James Almer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/ttaenc: add tta_init()
Signed-off-by:
James Almer
<
jamrial@gmail.com
>
parent
e97667c8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
10 deletions
+22
-10
ttaenc.c
libavformat/ttaenc.c
+22
-10
No files found.
libavformat/ttaenc.c
View file @
fa412150
...
...
@@ -35,16 +35,17 @@ typedef struct TTAMuxContext {
int
last_frame
;
}
TTAMuxContext
;
static
int
tta_
write_header
(
AVFormatContext
*
s
)
static
int
tta_
init
(
AVFormatContext
*
s
)
{
TTAMuxContext
*
tta
=
s
->
priv_data
;
AVCodecParameters
*
par
=
s
->
streams
[
0
]
->
codecpar
;
int
ret
;
AVCodecParameters
*
par
;
if
(
s
->
nb_streams
!=
1
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Only one stream is supported
\n
"
);
return
AVERROR
(
EINVAL
);
}
par
=
s
->
streams
[
0
]
->
codecpar
;
if
(
par
->
codec_id
!=
AV_CODEC_ID_TTA
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Unsupported codec
\n
"
);
return
AVERROR
(
EINVAL
);
...
...
@@ -54,6 +55,23 @@ static int tta_write_header(AVFormatContext *s)
return
AVERROR_INVALIDDATA
;
}
/* Prevent overflow */
if
(
par
->
sample_rate
>
0x7FFFFFu
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Sample rate too large
\n
"
);
return
AVERROR
(
EINVAL
);
}
tta
->
frame_size
=
par
->
sample_rate
*
256
/
245
;
avpriv_set_pts_info
(
s
->
streams
[
0
],
64
,
1
,
par
->
sample_rate
);
return
0
;
}
static
int
tta_write_header
(
AVFormatContext
*
s
)
{
TTAMuxContext
*
tta
=
s
->
priv_data
;
AVCodecParameters
*
par
=
s
->
streams
[
0
]
->
codecpar
;
int
ret
;
if
((
ret
=
avio_open_dyn_buf
(
&
tta
->
seek_table
))
<
0
)
return
ret
;
...
...
@@ -66,13 +84,6 @@ static int tta_write_header(AVFormatContext *s)
avio_wl16
(
s
->
pb
,
par
->
channels
);
avio_wl16
(
s
->
pb
,
par
->
bits_per_raw_sample
);
avio_wl32
(
s
->
pb
,
par
->
sample_rate
);
/* Prevent overflow */
if
(
par
->
sample_rate
>
0x7FFFFFu
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Sample rate too large
\n
"
);
return
AVERROR
(
EINVAL
);
}
tta
->
frame_size
=
par
->
sample_rate
*
256
/
245
;
avpriv_set_pts_info
(
s
->
streams
[
0
],
64
,
1
,
par
->
sample_rate
);
return
0
;
}
...
...
@@ -167,6 +178,7 @@ AVOutputFormat ff_tta_muxer = {
.
priv_data_size
=
sizeof
(
TTAMuxContext
),
.
audio_codec
=
AV_CODEC_ID_TTA
,
.
video_codec
=
AV_CODEC_ID_NONE
,
.
init
=
tta_init
,
.
write_header
=
tta_write_header
,
.
write_packet
=
tta_write_packet
,
.
write_trailer
=
tta_write_trailer
,
...
...
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