mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
Indentation fixes
This commit is contained in:
parent
277248cdcb
commit
2efdafecd9
1 changed files with 46 additions and 52 deletions
|
@ -188,39 +188,39 @@ namespace MWRender
|
|||
diff = get_audio_clock(is) - ref_clock;
|
||||
if(diff < AV_NOSYNC_THRESHOLD) {
|
||||
// accumulate the diffs
|
||||
is->audio_diff_cum = diff + is->audio_diff_avg_coef
|
||||
* is->audio_diff_cum;
|
||||
is->audio_diff_cum = diff + is->audio_diff_avg_coef *
|
||||
is->audio_diff_cum;
|
||||
if(is->audio_diff_avg_count < AUDIO_DIFF_AVG_NB) {
|
||||
is->audio_diff_avg_count++;
|
||||
is->audio_diff_avg_count++;
|
||||
} else {
|
||||
avg_diff = is->audio_diff_cum * (1.0 - is->audio_diff_avg_coef);
|
||||
if(fabs(avg_diff) >= is->audio_diff_threshold) {
|
||||
wanted_size = samples_size + ((int)(diff * is->audio_st->codec->sample_rate) * n);
|
||||
min_size = samples_size * ((100 - SAMPLE_CORRECTION_PERCENT_MAX) / 100);
|
||||
max_size = samples_size * ((100 + SAMPLE_CORRECTION_PERCENT_MAX) / 100);
|
||||
if(wanted_size < min_size) {
|
||||
wanted_size = min_size;
|
||||
} else if (wanted_size > max_size) {
|
||||
wanted_size = max_size;
|
||||
}
|
||||
if(wanted_size < samples_size) {
|
||||
/* remove samples */
|
||||
samples_size = wanted_size;
|
||||
} else if(wanted_size > samples_size) {
|
||||
uint8_t *samples_end, *q;
|
||||
int nb;
|
||||
/* add samples by copying final sample*/
|
||||
nb = (samples_size - wanted_size);
|
||||
samples_end = (uint8_t *)samples + samples_size - n;
|
||||
q = samples_end + n;
|
||||
while(nb > 0) {
|
||||
memcpy(q, samples_end, n);
|
||||
q += n;
|
||||
nb -= n;
|
||||
}
|
||||
samples_size = wanted_size;
|
||||
}
|
||||
}
|
||||
avg_diff = is->audio_diff_cum * (1.0 - is->audio_diff_avg_coef);
|
||||
if(fabs(avg_diff) >= is->audio_diff_threshold) {
|
||||
wanted_size = samples_size + ((int)(diff * is->audio_st->codec->sample_rate) * n);
|
||||
min_size = samples_size * ((100 - SAMPLE_CORRECTION_PERCENT_MAX) / 100);
|
||||
max_size = samples_size * ((100 + SAMPLE_CORRECTION_PERCENT_MAX) / 100);
|
||||
if(wanted_size < min_size) {
|
||||
wanted_size = min_size;
|
||||
} else if (wanted_size > max_size) {
|
||||
wanted_size = max_size;
|
||||
}
|
||||
if(wanted_size < samples_size) {
|
||||
/* remove samples */
|
||||
samples_size = wanted_size;
|
||||
} else if(wanted_size > samples_size) {
|
||||
uint8_t *samples_end, *q;
|
||||
int nb;
|
||||
/* add samples by copying final sample*/
|
||||
nb = (samples_size - wanted_size);
|
||||
samples_end = (uint8_t *)samples + samples_size - n;
|
||||
q = samples_end + n;
|
||||
while(nb > 0) {
|
||||
memcpy(q, samples_end, n);
|
||||
q += n;
|
||||
nb -= n;
|
||||
}
|
||||
samples_size = wanted_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* difference is TOO big; reset diff stuff */
|
||||
|
@ -239,7 +239,7 @@ namespace MWRender
|
|||
while(is->audio_pkt_size > 0) {
|
||||
data_size = buf_size;
|
||||
len1 = avcodec_decode_audio3(is->audio_st->codec,
|
||||
(int16_t *)audio_buf, &data_size, pkt);
|
||||
(int16_t*)audio_buf, &data_size, pkt);
|
||||
|
||||
|
||||
if(len1 < 0) {
|
||||
|
@ -250,14 +250,14 @@ namespace MWRender
|
|||
is->audio_pkt_data += len1;
|
||||
is->audio_pkt_size -= len1;
|
||||
if(data_size <= 0) {
|
||||
/* No data yet, get more frames */
|
||||
/* No data yet, get more frames */
|
||||
continue;
|
||||
}
|
||||
pts = is->audio_clock;
|
||||
*pts_ptr = pts;
|
||||
n = 2 * is->audio_st->codec->channels;
|
||||
is->audio_clock += (double)data_size /
|
||||
(double)(n * is->audio_st->codec->sample_rate);
|
||||
(double)(n * is->audio_st->codec->sample_rate);
|
||||
|
||||
/* We have data, return it and come back for more later */
|
||||
return data_size;
|
||||
|
@ -296,7 +296,7 @@ namespace MWRender
|
|||
memset(is->audio_buf, 0, is->audio_buf_size);
|
||||
} else {
|
||||
audio_size = synchronize_audio(is, (int16_t *)is->audio_buf,
|
||||
audio_size, pts);
|
||||
audio_size, pts);
|
||||
is->audio_buf_size = audio_size;
|
||||
}
|
||||
is->audio_buf_index = 0;
|
||||
|
@ -397,7 +397,7 @@ namespace MWRender
|
|||
diff = vp->pts - ref_clock;
|
||||
|
||||
/* Skip or repeat the frame. Take delay into account
|
||||
FFPlay still doesn't "know if this is the best guess." */
|
||||
FFPlay still doesn't "know if this is the best guess." */
|
||||
sync_threshold = (delay > AV_SYNC_THRESHOLD) ? delay : AV_SYNC_THRESHOLD;
|
||||
if(fabs(diff) < AV_NOSYNC_THRESHOLD) {
|
||||
if(diff <= -sync_threshold) {
|
||||
|
@ -442,8 +442,7 @@ namespace MWRender
|
|||
/* wait until we have a new pic */
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(is->pictq_mutex);
|
||||
while(is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE &&
|
||||
!is->quit) {
|
||||
while(is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && !is->quit) {
|
||||
is->pictq_cond.timed_wait(lock, boost::posix_time::milliseconds(1));
|
||||
}
|
||||
}
|
||||
|
@ -458,9 +457,9 @@ namespace MWRender
|
|||
if(is->sws_context == NULL) {
|
||||
int w = is->video_st->codec->width;
|
||||
int h = is->video_st->codec->height;
|
||||
is->sws_context = sws_getContext(w, h,
|
||||
is->video_st->codec->pix_fmt, w, h,
|
||||
PIX_FMT_RGBA, SWS_BICUBIC, NULL, NULL, NULL);
|
||||
is->sws_context = sws_getContext(w, h, is->video_st->codec->pix_fmt,
|
||||
w, h, PIX_FMT_RGBA, SWS_BICUBIC,
|
||||
NULL, NULL, NULL);
|
||||
if(is->sws_context == NULL)
|
||||
throw std::runtime_error("Cannot initialize the conversion context!\n");
|
||||
}
|
||||
|
@ -468,7 +467,7 @@ namespace MWRender
|
|||
vp->data =(uint8_t*) malloc(is->video_st->codec->width * is->video_st->codec->height * 4);
|
||||
|
||||
sws_scale(is->sws_context, pFrame->data, pFrame->linesize,
|
||||
0, is->video_st->codec->height, &vp->data, is->rgbaFrame->linesize);
|
||||
0, is->video_st->codec->height, &vp->data, is->rgbaFrame->linesize);
|
||||
|
||||
|
||||
vp->pts = pts;
|
||||
|
@ -544,8 +543,7 @@ namespace MWRender
|
|||
// Save global pts to be stored in pFrame
|
||||
global_video_pkt_pts = packet->pts;
|
||||
// Decode video frame
|
||||
len1 = avcodec_decode_video2(is->video_st->codec, pFrame, &frameFinished,
|
||||
packet);
|
||||
len1 = avcodec_decode_video2(is->video_st->codec, pFrame, &frameFinished, packet);
|
||||
if(packet->dts == (int64_t)AV_NOPTS_VALUE
|
||||
&& pFrame->opaque && *(uint64_t*)pFrame->opaque != AV_NOPTS_VALUE) {
|
||||
pts = *(uint64_t *)pFrame->opaque;
|
||||
|
@ -698,12 +696,10 @@ namespace MWRender
|
|||
av_dump_format(pFormatCtx, 0, is->resourceName.c_str(), 0);
|
||||
|
||||
for(i=0; i<pFormatCtx->nb_streams; i++) {
|
||||
if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO &&
|
||||
video_index < 0) {
|
||||
if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO && video_index < 0) {
|
||||
video_index=i;
|
||||
}
|
||||
if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO &&
|
||||
audio_index < 0) {
|
||||
if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO && audio_index < 0) {
|
||||
audio_index=i;
|
||||
}
|
||||
}
|
||||
|
@ -717,15 +713,13 @@ namespace MWRender
|
|||
|
||||
if(is->videoStream >= 0 /*|| is->audioStream < 0*/)
|
||||
{
|
||||
|
||||
// main decode loop
|
||||
|
||||
for(;;) {
|
||||
if(is->quit) {
|
||||
break;
|
||||
}
|
||||
if( (is->audioStream >= 0 && is->audioq.size > MAX_AUDIOQ_SIZE) ||
|
||||
is->videoq.size > MAX_VIDEOQ_SIZE) {
|
||||
if((is->audioStream >= 0 && is->audioq.size > MAX_AUDIOQ_SIZE) ||
|
||||
is->videoq.size > MAX_VIDEOQ_SIZE) {
|
||||
boost::this_thread::sleep(boost::posix_time::milliseconds(10));
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue