forked from mirror/openmw-tes3mp
Move audio_clock to the decoder where it's used
This commit is contained in:
parent
4561c22e2b
commit
0edc87825d
1 changed files with 11 additions and 10 deletions
|
@ -58,11 +58,10 @@ struct VideoPicture {
|
||||||
struct VideoState {
|
struct VideoState {
|
||||||
VideoState()
|
VideoState()
|
||||||
: videoStream(-1), audioStream(-1), av_sync_type(0), external_clock_base(0),
|
: videoStream(-1), audioStream(-1), av_sync_type(0), external_clock_base(0),
|
||||||
audio_clock(0), audio_st(NULL), audio_diff_cum(0), audio_diff_avg_coef(0),
|
audio_st(NULL), audio_diff_cum(0), audio_diff_avg_coef(0), audio_diff_threshold(0),
|
||||||
audio_diff_threshold(0), audio_diff_avg_count(0), frame_last_pts(0),
|
audio_diff_avg_count(0), frame_last_pts(0), frame_last_delay(0), video_clock(0),
|
||||||
frame_last_delay(0), video_clock(0), video_st(NULL), rgbaFrame(NULL), pictq_size(0),
|
video_st(NULL), rgbaFrame(NULL), pictq_size(0), pictq_rindex(0), pictq_windex(0),
|
||||||
pictq_rindex(0), pictq_windex(0), quit(false), refresh(0), format_ctx(0),
|
quit(false), refresh(0), format_ctx(0), sws_context(NULL), display_ready(0)
|
||||||
sws_context(NULL), display_ready(0)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
~VideoState()
|
~VideoState()
|
||||||
|
@ -114,7 +113,6 @@ struct VideoState {
|
||||||
int av_sync_type;
|
int av_sync_type;
|
||||||
uint64_t external_clock_base;
|
uint64_t external_clock_base;
|
||||||
|
|
||||||
double audio_clock;
|
|
||||||
AVStream *audio_st;
|
AVStream *audio_st;
|
||||||
PacketQueue audioq;
|
PacketQueue audioq;
|
||||||
double audio_diff_cum; /* used for AV difference average computation */
|
double audio_diff_cum; /* used for AV difference average computation */
|
||||||
|
@ -256,6 +254,8 @@ class MovieAudioDecoder : public MWSound::Sound_Decoder
|
||||||
ssize_t mFramePos;
|
ssize_t mFramePos;
|
||||||
ssize_t mFrameSize;
|
ssize_t mFrameSize;
|
||||||
|
|
||||||
|
double audio_clock;
|
||||||
|
|
||||||
/* Add or subtract samples to get a better sync, return number of bytes to
|
/* Add or subtract samples to get a better sync, return number of bytes to
|
||||||
* skip (negative means to duplicate). */
|
* skip (negative means to duplicate). */
|
||||||
int synchronize_audio()
|
int synchronize_audio()
|
||||||
|
@ -310,8 +310,8 @@ class MovieAudioDecoder : public MWSound::Sound_Decoder
|
||||||
if(!got_frame || frame->nb_samples <= 0)
|
if(!got_frame || frame->nb_samples <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
is->audio_clock += (double)frame->nb_samples /
|
this->audio_clock += (double)frame->nb_samples /
|
||||||
(double)is->audio_st->codec->sample_rate;
|
(double)is->audio_st->codec->sample_rate;
|
||||||
|
|
||||||
/* We have data, return it and come back for more later */
|
/* We have data, return it and come back for more later */
|
||||||
return frame->nb_samples * av_get_bytes_per_sample(is->audio_st->codec->sample_fmt) *
|
return frame->nb_samples * av_get_bytes_per_sample(is->audio_st->codec->sample_fmt) *
|
||||||
|
@ -328,7 +328,7 @@ class MovieAudioDecoder : public MWSound::Sound_Decoder
|
||||||
|
|
||||||
/* if update, update the audio clock w/pts */
|
/* if update, update the audio clock w/pts */
|
||||||
if((uint64_t)pkt->pts != AV_NOPTS_VALUE)
|
if((uint64_t)pkt->pts != AV_NOPTS_VALUE)
|
||||||
is->audio_clock = av_q2d(is->audio_st->time_base)*pkt->pts;
|
this->audio_clock = av_q2d(is->audio_st->time_base)*pkt->pts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,6 +348,7 @@ public:
|
||||||
, mFrame(avcodec_alloc_frame())
|
, mFrame(avcodec_alloc_frame())
|
||||||
, mFramePos(0)
|
, mFramePos(0)
|
||||||
, mFrameSize(0)
|
, mFrameSize(0)
|
||||||
|
, audio_clock(0.0)
|
||||||
{ }
|
{ }
|
||||||
virtual ~MovieAudioDecoder()
|
virtual ~MovieAudioDecoder()
|
||||||
{
|
{
|
||||||
|
@ -473,7 +474,7 @@ public:
|
||||||
{
|
{
|
||||||
ssize_t clock_delay = (mFrameSize-mFramePos) / is->audio_st->codec->channels /
|
ssize_t clock_delay = (mFrameSize-mFramePos) / is->audio_st->codec->channels /
|
||||||
av_get_bytes_per_sample(is->audio_st->codec->sample_fmt);
|
av_get_bytes_per_sample(is->audio_st->codec->sample_fmt);
|
||||||
return (size_t)(is->audio_clock*is->audio_st->codec->sample_rate) - clock_delay;
|
return (size_t)(this->audio_clock*is->audio_st->codec->sample_rate) - clock_delay;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue