From 773d63e7a458f58150742e70bce0f1c33745676f Mon Sep 17 00:00:00 2001 From: martii Date: Mon, 21 Apr 2014 14:00:51 +0200 Subject: [PATCH] libeplayer3/writer/pcm: simplify pts handling Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/103037e239216d1f6521f67b9ffcffee5b374848 Author: martii Date: 2014-04-21 (Mon, 21 Apr 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libeplayer3/input.cpp | 3 ++- libeplayer3/writer/pcm.cpp | 12 ++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/libeplayer3/input.cpp b/libeplayer3/input.cpp index 86a3197..a9b1480 100644 --- a/libeplayer3/input.cpp +++ b/libeplayer3/input.cpp @@ -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 { diff --git a/libeplayer3/writer/pcm.cpp b/libeplayer3/writer/pcm.cpp index 11aba34..a8dcb4c 100644 --- a/libeplayer3/writer/pcm.cpp +++ b/libeplayer3/writer/pcm.cpp @@ -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; }