libeplayer3: use av_rescale for pts calulations

Origin commit data
------------------
Branch: master
Commit: 91712236fe
Author: martii <m4rtii@gmx.de>
Date: 2014-04-18 (Fri, 18 Apr 2014)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
martii
2014-04-18 11:16:44 +02:00
parent a678fc046e
commit 2b2a43de82
6 changed files with 9 additions and 10 deletions

View File

@@ -61,9 +61,9 @@ int64_t calcPts(AVFormatContext *avfc, AVStream * stream, int64_t pts)
if (pts == AV_NOPTS_VALUE)
return INVALID_PTS_VALUE;
pts = 90000 * pts * stream->time_base.num / stream->time_base.den;
pts = av_rescale(90000ll * stream->time_base.num, pts, stream->time_base.den);
if (avfc->start_time != AV_NOPTS_VALUE)
pts -= 90000 * avfc->start_time / AV_TIME_BASE;
pts -= av_rescale(90000ll, avfc->start_time, AV_TIME_BASE);
if (pts < 0)
return INVALID_PTS_VALUE;
@@ -422,8 +422,8 @@ bool Input::UpdateTracks()
AVDictionaryEntry* title = av_dict_get(ch->metadata, "title", NULL, 0);
Chapter chapter;
chapter.title = title ? title->value : "";
chapter.start = AV_TIME_BASE * ch->start * ch->time_base.num / ch->time_base.den;
chapter.end = AV_TIME_BASE * ch->end * ch->time_base.num / ch->time_base.den;
chapter.start = av_rescale(ch->time_base.num * AV_TIME_BASE, ch->start, ch->time_base.den);
chapter.end = av_rescale(ch->time_base.num * AV_TIME_BASE, ch->end, ch->time_base.den);
chapters.push_back(chapter);
}
player->SetChapters(chapters);
@@ -447,7 +447,7 @@ bool Input::UpdateTracks()
if (stream->duration == AV_NOPTS_VALUE)
track.duration = avfc->duration;
else
track.duration = AV_TIME_BASE * stream->duration * stream->time_base.num / stream->time_base.den;
track.duration = av_rescale(stream->time_base.num * AV_TIME_BASE, stream->duration, stream->time_base.den);
switch (stream->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO: {

View File

@@ -60,7 +60,7 @@ bool WriterDIVX::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, A
unsigned int FakeStartCode = (Version << 8) | PES_VERSION_FAKE_START_CODE;
BitPacker_t ld = { FakeHeaders, 0, 32 };
unsigned int usecPerFrame = AV_TIME_BASE * stream->r_frame_rate.den / stream->r_frame_rate.num;
unsigned int usecPerFrame = av_rescale(AV_TIME_BASE, stream->r_frame_rate.den, stream->r_frame_rate.num);
/* Create info record for frame parser */
/* divx4 & 5

View File

@@ -75,7 +75,7 @@ bool WriterH264::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, A
int ic = 0;
struct iovec iov[128];
TimeDelta = 1000 * stream->r_frame_rate.num / stream->r_frame_rate.den;
TimeDelta = av_rescale(1000ll, stream->r_frame_rate.num, stream->r_frame_rate.den);
TimeScale = (TimeDelta < 23970) ? 1001 : 1000; /* fixme: revise this */
if ((packet->size > 3)

View File

@@ -326,7 +326,6 @@ bool WriterPCM::Write(int fd, AVFormatContext *avfc, AVStream *stream, AVPacket
fprintf(stderr, "av_samples_alloc: %d\n", -e);
continue;
}
// FIXME. PTS calculation is probably broken.
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);

View File

@@ -89,7 +89,7 @@ bool WriterVC1::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, AV
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
uint8_t PesPayload[128];
uint8_t *PesPtr;
unsigned int usecPerFrame = AV_TIME_BASE * stream->r_frame_rate.den / stream->r_frame_rate.num;
unsigned int usecPerFrame = av_rescale(AV_TIME_BASE, stream->r_frame_rate.den, stream->r_frame_rate.num);
struct iovec iov[2];

View File

@@ -78,7 +78,7 @@ bool WriterWMV::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, AV
uint8_t PesPacket[PES_MIN_HEADER_SIZE + 128];
uint8_t *PesPtr;
unsigned int MetadataLength;
unsigned int usecPerFrame = AV_TIME_BASE * stream->r_frame_rate.den / stream->r_frame_rate.num;
unsigned int usecPerFrame = av_rescale(AV_TIME_BASE, stream->r_frame_rate.den, stream->r_frame_rate.num);
PesPtr = &PesPacket[PES_MIN_HEADER_SIZE];