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
3df787a1
Commit
3df787a1
authored
Apr 14, 2014
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'flac' of
https://github.com/FernetMenta/FFmpeg
Merged-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parents
46d5625f
d8b19ee6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
4 deletions
+66
-4
flac_parser.c
libavcodec/flac_parser.c
+13
-0
flacdec.c
libavformat/flacdec.c
+45
-0
acodec-flac
tests/ref/seek/acodec-flac
+8
-4
No files found.
libavcodec/flac_parser.c
View file @
3df787a1
...
...
@@ -489,6 +489,14 @@ static int get_best_header(FLACParseContext* fpc, const uint8_t **poutbuf,
&
fpc
->
wrap_buf
,
&
fpc
->
wrap_buf_allocated_size
);
if
(
fpc
->
pc
->
flags
&
PARSER_FLAG_USE_CODEC_TS
){
if
(
header
->
fi
.
is_var_size
)
fpc
->
pc
->
pts
=
header
->
fi
.
frame_or_sample_num
;
else
if
(
header
->
best_child
)
fpc
->
pc
->
pts
=
header
->
fi
.
frame_or_sample_num
*
header
->
fi
.
blocksize
;
}
fpc
->
best_header_valid
=
0
;
fpc
->
last_fi_valid
=
1
;
fpc
->
last_fi
=
header
->
fi
;
...
...
@@ -516,6 +524,11 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
s
->
duration
=
fi
.
blocksize
;
if
(
!
avctx
->
sample_rate
)
avctx
->
sample_rate
=
fi
.
samplerate
;
if
(
fpc
->
pc
->
flags
&
PARSER_FLAG_USE_CODEC_TS
){
fpc
->
pc
->
pts
=
fi
.
frame_or_sample_num
;
if
(
!
fi
.
is_var_size
)
fpc
->
pc
->
pts
*=
fi
.
blocksize
;
}
}
*
poutbuf
=
buf
;
*
poutbuf_size
=
buf_size
;
...
...
libavformat/flacdec.c
View file @
3df787a1
...
...
@@ -162,12 +162,57 @@ static int flac_probe(AVProbeData *p)
return
AVPROBE_SCORE_EXTENSION
;
}
static
av_unused
int64_t
flac_read_timestamp
(
AVFormatContext
*
s
,
int
stream_index
,
int64_t
*
ppos
,
int64_t
pos_limit
)
{
AVPacket
pkt
,
out_pkt
;
AVStream
*
st
=
s
->
streams
[
stream_index
];
int
ret
;
if
(
avio_seek
(
s
->
pb
,
*
ppos
,
SEEK_SET
)
<
0
)
return
AV_NOPTS_VALUE
;
av_init_packet
(
&
pkt
);
st
->
parser
=
av_parser_init
(
st
->
codec
->
codec_id
);
if
(
!
st
->
parser
){
return
AV_NOPTS_VALUE
;
}
st
->
parser
->
flags
|=
PARSER_FLAG_USE_CODEC_TS
;
for
(;;){
ret
=
ff_raw_read_partial_packet
(
s
,
&
pkt
);
if
(
ret
<
0
){
if
(
ret
==
AVERROR
(
EAGAIN
))
continue
;
else
return
AV_NOPTS_VALUE
;
}
av_init_packet
(
&
out_pkt
);
ret
=
av_parser_parse2
(
st
->
parser
,
st
->
codec
,
&
out_pkt
.
data
,
&
out_pkt
.
size
,
pkt
.
data
,
pkt
.
size
,
pkt
.
pts
,
pkt
.
dts
,
*
ppos
);
if
(
out_pkt
.
size
){
int
size
=
out_pkt
.
size
;
av_free_packet
(
&
out_pkt
);
if
(
st
->
parser
->
pts
!=
AV_NOPTS_VALUE
){
// seeking may not have started from beginning of a frame
// calculate frame start position from next frame backwards
*
ppos
=
st
->
parser
->
next_frame_offset
-
size
;
return
st
->
parser
->
pts
;
}
}
}
return
AV_NOPTS_VALUE
;
}
AVInputFormat
ff_flac_demuxer
=
{
.
name
=
"flac"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"raw FLAC"
),
.
read_probe
=
flac_probe
,
.
read_header
=
flac_read_header
,
.
read_packet
=
ff_raw_read_partial_packet
,
.
read_timestamp
=
flac_read_timestamp
,
.
flags
=
AVFMT_GENERIC_INDEX
,
.
extensions
=
"flac"
,
.
raw_codec_id
=
AV_CODEC_ID_FLAC
,
...
...
tests/ref/seek/acodec-flac
View file @
3df787a1
...
...
@@ -5,14 +5,16 @@ ret: 0 st:-1 flags:1 ts: 1.894167
ret: 0 st: 0 flags:1 dts: 1.880816 pts: 1.880816 pos: 86742 size: 2191
ret: 0 st: 0 flags:0 ts: 0.788345
ret: 0 st: 0 flags:1 dts: 0.809796 pts: 0.809796 pos: 27366 size: 615
ret:-1 st: 0 flags:1 ts:-0.317506
ret: 0 st: 0 flags:1 ts:-0.317506
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 8256 size: 614
ret: 0 st:-1 flags:0 ts: 2.576668
ret: 0 st: 0 flags:1 dts: 2.586122 pts: 2.586122 pos: 145606 size: 2384
ret: 0 st:-1 flags:1 ts: 1.470835
ret: 0 st: 0 flags:1 dts: 1.462857 pts: 1.462857 pos: 53388 size: 1851
ret: 0 st: 0 flags:0 ts: 0.365011
ret: 0 st: 0 flags:1 dts: 0.365714 pts: 0.365714 pos: 16890 size: 614
ret:-1 st: 0 flags:1 ts:-0.740839
ret: 0 st: 0 flags:1 ts:-0.740839
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 8256 size: 614
ret: 0 st:-1 flags:0 ts: 2.153336
ret: 0 st: 0 flags:1 dts: 2.168163 pts: 2.168163 pos: 110531 size: 2143
ret: 0 st:-1 flags:1 ts: 1.047503
...
...
@@ -39,11 +41,13 @@ ret: 0 st: 0 flags:1 ts: 1.989184
ret: 0 st: 0 flags:1 dts: 1.985306 pts: 1.985306 pos: 95508 size: 2169
ret: 0 st:-1 flags:0 ts: 0.883340
ret: 0 st: 0 flags:1 dts: 0.888163 pts: 0.888163 pos: 29211 size: 620
ret:-1 st:-1 flags:1 ts:-0.222493
ret: 0 st:-1 flags:1 ts:-0.222493
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 8256 size: 614
ret: 0 st: 0 flags:0 ts: 2.671678
ret: 0 st: 0 flags:1 dts: 2.690612 pts: 2.690612 pos: 155154 size: 2394
ret: 0 st: 0 flags:1 ts: 1.565850
ret: 0 st: 0 flags:1 dts: 1.541224 pts: 1.541224 pos: 59082 size: 1974
ret: 0 st:-1 flags:0 ts: 0.460008
ret: 0 st: 0 flags:1 dts: 0.470204 pts: 0.470204 pos: 19353 size: 608
ret:-1 st:-1 flags:1 ts:-0.645825
ret: 0 st:-1 flags:1 ts:-0.645825
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 8256 size: 614
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