mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
libeplayer3: use av_rescale for pts calulations
This commit is contained in:
@@ -61,9 +61,9 @@ int64_t calcPts(AVFormatContext *avfc, AVStream * stream, int64_t pts)
|
|||||||
if (pts == AV_NOPTS_VALUE)
|
if (pts == AV_NOPTS_VALUE)
|
||||||
return INVALID_PTS_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)
|
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)
|
if (pts < 0)
|
||||||
return INVALID_PTS_VALUE;
|
return INVALID_PTS_VALUE;
|
||||||
@@ -422,8 +422,8 @@ bool Input::UpdateTracks()
|
|||||||
AVDictionaryEntry* title = av_dict_get(ch->metadata, "title", NULL, 0);
|
AVDictionaryEntry* title = av_dict_get(ch->metadata, "title", NULL, 0);
|
||||||
Chapter chapter;
|
Chapter chapter;
|
||||||
chapter.title = title ? title->value : "";
|
chapter.title = title ? title->value : "";
|
||||||
chapter.start = AV_TIME_BASE * ch->start * 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_TIME_BASE * ch->end * ch->time_base.num / 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);
|
chapters.push_back(chapter);
|
||||||
}
|
}
|
||||||
player->SetChapters(chapters);
|
player->SetChapters(chapters);
|
||||||
@@ -447,7 +447,7 @@ bool Input::UpdateTracks()
|
|||||||
if (stream->duration == AV_NOPTS_VALUE)
|
if (stream->duration == AV_NOPTS_VALUE)
|
||||||
track.duration = avfc->duration;
|
track.duration = avfc->duration;
|
||||||
else
|
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) {
|
switch (stream->codec->codec_type) {
|
||||||
case AVMEDIA_TYPE_VIDEO: {
|
case AVMEDIA_TYPE_VIDEO: {
|
||||||
|
@@ -60,7 +60,7 @@ bool WriterDIVX::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, A
|
|||||||
unsigned int FakeStartCode = (Version << 8) | PES_VERSION_FAKE_START_CODE;
|
unsigned int FakeStartCode = (Version << 8) | PES_VERSION_FAKE_START_CODE;
|
||||||
BitPacker_t ld = { FakeHeaders, 0, 32 };
|
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 */
|
/* Create info record for frame parser */
|
||||||
/* divx4 & 5
|
/* divx4 & 5
|
||||||
|
@@ -75,7 +75,7 @@ bool WriterH264::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, A
|
|||||||
int ic = 0;
|
int ic = 0;
|
||||||
struct iovec iov[128];
|
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 */
|
TimeScale = (TimeDelta < 23970) ? 1001 : 1000; /* fixme: revise this */
|
||||||
|
|
||||||
if ((packet->size > 3)
|
if ((packet->size > 3)
|
||||||
|
@@ -326,7 +326,6 @@ bool WriterPCM::Write(int fd, AVFormatContext *avfc, AVStream *stream, AVPacket
|
|||||||
fprintf(stderr, "av_samples_alloc: %d\n", -e);
|
fprintf(stderr, "av_samples_alloc: %d\n", -e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// FIXME. PTS calculation is probably broken.
|
|
||||||
int64_t next_in_pts = av_rescale(av_frame_get_best_effort_timestamp(decoded_frame),
|
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.num * (int64_t)out_sample_rate * c->sample_rate,
|
||||||
stream->time_base.den);
|
stream->time_base.den);
|
||||||
|
@@ -89,7 +89,7 @@ bool WriterVC1::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, AV
|
|||||||
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
||||||
uint8_t PesPayload[128];
|
uint8_t PesPayload[128];
|
||||||
uint8_t *PesPtr;
|
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];
|
struct iovec iov[2];
|
||||||
|
|
||||||
|
|
||||||
|
@@ -78,7 +78,7 @@ bool WriterWMV::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, AV
|
|||||||
uint8_t PesPacket[PES_MIN_HEADER_SIZE + 128];
|
uint8_t PesPacket[PES_MIN_HEADER_SIZE + 128];
|
||||||
uint8_t *PesPtr;
|
uint8_t *PesPtr;
|
||||||
unsigned int MetadataLength;
|
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];
|
PesPtr = &PesPacket[PES_MIN_HEADER_SIZE];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user