mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
libeplayer3/writer/pcm: simplify pts handling
This commit is contained in:
@@ -154,6 +154,7 @@ bool Input::Play()
|
||||
for (i = 0; i < avfc->nb_streams; i++)
|
||||
if (avfc->streams[i]->codec && avfc->streams[i]->codec->codec)
|
||||
avcodec_flush_buffers(avfc->streams[i]->codec);
|
||||
player->output.ClearAudio();
|
||||
player->output.ClearVideo();
|
||||
}
|
||||
|
||||
@@ -193,7 +194,7 @@ bool Input::Play()
|
||||
}
|
||||
if (!player->isBackWard) {
|
||||
int64_t pts = calcPts(avfc, stream, packet.pts);
|
||||
if (!player->output.Write(avfc, stream, &packet, pts)) {
|
||||
if (!player->output.Write(avfc, stream, &packet, _videoTrack ? pts : 0)) {
|
||||
if (warnAudioWrite)
|
||||
warnAudioWrite--;
|
||||
else {
|
||||
|
@@ -230,7 +230,7 @@ void WriterPCM::Init()
|
||||
|
||||
extern int64_t calcPts(AVFormatContext *, AVStream *, int64_t);
|
||||
|
||||
bool WriterPCM::Write(int fd, AVFormatContext *avfc, AVStream *stream, AVPacket *packet, int64_t pts)
|
||||
bool WriterPCM::Write(int fd, AVFormatContext * /*avfc*/, AVStream *stream, AVPacket *packet, int64_t pts)
|
||||
{
|
||||
if (fd < 0)
|
||||
return false;
|
||||
@@ -322,15 +322,6 @@ bool WriterPCM::Write(int fd, AVFormatContext *avfc, AVStream *stream, AVPacket
|
||||
}
|
||||
}
|
||||
|
||||
int64_t next_in_pts = av_rescale(av_frame_get_best_effort_timestamp(decoded_frame),
|
||||
stream->time_base.num * (int64_t)out_sample_rate * c->sample_rate,
|
||||
stream->time_base.den);
|
||||
int64_t next_out_pts = av_rescale(swr_next_pts(swr, next_in_pts),
|
||||
stream->time_base.den,
|
||||
stream->time_base.num * (int64_t)out_sample_rate * c->sample_rate);
|
||||
|
||||
pts = calcPts(avfc, stream, next_out_pts);
|
||||
|
||||
int in_samples = decoded_frame->nb_samples;
|
||||
int out_samples = av_rescale_rnd(swr_get_delay(swr, c->sample_rate) + in_samples, out_sample_rate, c->sample_rate, AV_ROUND_UP);
|
||||
|
||||
@@ -345,6 +336,7 @@ bool WriterPCM::Write(int fd, AVFormatContext *avfc, AVStream *stream, AVPacket
|
||||
writePCM(fd, pts, output, out_samples * sizeof(short) * out_channels);
|
||||
|
||||
av_free(output);
|
||||
pts = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user