You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avformat/flacdec/flac_read_timestamp: dont modify AVStream state
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -167,17 +167,19 @@ static av_unused int64_t flac_read_timestamp(AVFormatContext *s, int stream_inde
|
|||||||
{
|
{
|
||||||
AVPacket pkt, out_pkt;
|
AVPacket pkt, out_pkt;
|
||||||
AVStream *st = s->streams[stream_index];
|
AVStream *st = s->streams[stream_index];
|
||||||
|
AVCodecParserContext *parser;
|
||||||
int ret;
|
int ret;
|
||||||
|
int64_t pts = AV_NOPTS_VALUE;
|
||||||
|
|
||||||
if (avio_seek(s->pb, *ppos, SEEK_SET) < 0)
|
if (avio_seek(s->pb, *ppos, SEEK_SET) < 0)
|
||||||
return AV_NOPTS_VALUE;
|
return AV_NOPTS_VALUE;
|
||||||
|
|
||||||
av_init_packet(&pkt);
|
av_init_packet(&pkt);
|
||||||
st->parser = av_parser_init(st->codec->codec_id);
|
parser = av_parser_init(st->codec->codec_id);
|
||||||
if (!st->parser){
|
if (!parser){
|
||||||
return AV_NOPTS_VALUE;
|
return AV_NOPTS_VALUE;
|
||||||
}
|
}
|
||||||
st->parser->flags |= PARSER_FLAG_USE_CODEC_TS;
|
parser->flags |= PARSER_FLAG_USE_CODEC_TS;
|
||||||
|
|
||||||
for (;;){
|
for (;;){
|
||||||
ret = ff_raw_read_partial_packet(s, &pkt);
|
ret = ff_raw_read_partial_packet(s, &pkt);
|
||||||
@@ -188,22 +190,24 @@ static av_unused int64_t flac_read_timestamp(AVFormatContext *s, int stream_inde
|
|||||||
return AV_NOPTS_VALUE;
|
return AV_NOPTS_VALUE;
|
||||||
}
|
}
|
||||||
av_init_packet(&out_pkt);
|
av_init_packet(&out_pkt);
|
||||||
ret = av_parser_parse2(st->parser, st->codec,
|
ret = av_parser_parse2(parser, st->codec,
|
||||||
&out_pkt.data, &out_pkt.size, pkt.data, pkt.size,
|
&out_pkt.data, &out_pkt.size, pkt.data, pkt.size,
|
||||||
pkt.pts, pkt.dts, *ppos);
|
pkt.pts, pkt.dts, *ppos);
|
||||||
|
|
||||||
if (out_pkt.size){
|
if (out_pkt.size){
|
||||||
int size = out_pkt.size;
|
int size = out_pkt.size;
|
||||||
av_free_packet(&out_pkt);
|
av_free_packet(&out_pkt);
|
||||||
if (st->parser->pts != AV_NOPTS_VALUE){
|
if (parser->pts != AV_NOPTS_VALUE){
|
||||||
// seeking may not have started from beginning of a frame
|
// seeking may not have started from beginning of a frame
|
||||||
// calculate frame start position from next frame backwards
|
// calculate frame start position from next frame backwards
|
||||||
*ppos = st->parser->next_frame_offset - size;
|
*ppos = parser->next_frame_offset - size;
|
||||||
return st->parser->pts;
|
pts = parser->pts;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return AV_NOPTS_VALUE;
|
av_parser_close(parser);
|
||||||
|
return pts;
|
||||||
}
|
}
|
||||||
|
|
||||||
AVInputFormat ff_flac_demuxer = {
|
AVInputFormat ff_flac_demuxer = {
|
||||||
|
Reference in New Issue
Block a user