1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-20 14:11:32 +00:00

Indentation fixes

This commit is contained in:
Chris Robinson 2012-12-11 20:11:48 -08:00
parent 277248cdcb
commit 2efdafecd9

View file

@ -188,39 +188,39 @@ namespace MWRender
diff = get_audio_clock(is) - ref_clock; diff = get_audio_clock(is) - ref_clock;
if(diff < AV_NOSYNC_THRESHOLD) { if(diff < AV_NOSYNC_THRESHOLD) {
// accumulate the diffs // accumulate the diffs
is->audio_diff_cum = diff + is->audio_diff_avg_coef is->audio_diff_cum = diff + is->audio_diff_avg_coef *
* is->audio_diff_cum; is->audio_diff_cum;
if(is->audio_diff_avg_count < AUDIO_DIFF_AVG_NB) { if(is->audio_diff_avg_count < AUDIO_DIFF_AVG_NB) {
is->audio_diff_avg_count++; is->audio_diff_avg_count++;
} else { } else {
avg_diff = is->audio_diff_cum * (1.0 - is->audio_diff_avg_coef); avg_diff = is->audio_diff_cum * (1.0 - is->audio_diff_avg_coef);
if(fabs(avg_diff) >= is->audio_diff_threshold) { if(fabs(avg_diff) >= is->audio_diff_threshold) {
wanted_size = samples_size + ((int)(diff * is->audio_st->codec->sample_rate) * n); wanted_size = samples_size + ((int)(diff * is->audio_st->codec->sample_rate) * n);
min_size = samples_size * ((100 - SAMPLE_CORRECTION_PERCENT_MAX) / 100); min_size = samples_size * ((100 - SAMPLE_CORRECTION_PERCENT_MAX) / 100);
max_size = samples_size * ((100 + SAMPLE_CORRECTION_PERCENT_MAX) / 100); max_size = samples_size * ((100 + SAMPLE_CORRECTION_PERCENT_MAX) / 100);
if(wanted_size < min_size) { if(wanted_size < min_size) {
wanted_size = min_size; wanted_size = min_size;
} else if (wanted_size > max_size) { } else if (wanted_size > max_size) {
wanted_size = max_size; wanted_size = max_size;
} }
if(wanted_size < samples_size) { if(wanted_size < samples_size) {
/* remove samples */ /* remove samples */
samples_size = wanted_size; samples_size = wanted_size;
} else if(wanted_size > samples_size) { } else if(wanted_size > samples_size) {
uint8_t *samples_end, *q; uint8_t *samples_end, *q;
int nb; int nb;
/* add samples by copying final sample*/ /* add samples by copying final sample*/
nb = (samples_size - wanted_size); nb = (samples_size - wanted_size);
samples_end = (uint8_t *)samples + samples_size - n; samples_end = (uint8_t *)samples + samples_size - n;
q = samples_end + n; q = samples_end + n;
while(nb > 0) { while(nb > 0) {
memcpy(q, samples_end, n); memcpy(q, samples_end, n);
q += n; q += n;
nb -= n; nb -= n;
} }
samples_size = wanted_size; samples_size = wanted_size;
} }
} }
} }
} else { } else {
/* difference is TOO big; reset diff stuff */ /* difference is TOO big; reset diff stuff */
@ -239,7 +239,7 @@ namespace MWRender
while(is->audio_pkt_size > 0) { while(is->audio_pkt_size > 0) {
data_size = buf_size; data_size = buf_size;
len1 = avcodec_decode_audio3(is->audio_st->codec, 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) { if(len1 < 0) {
@ -250,14 +250,14 @@ namespace MWRender
is->audio_pkt_data += len1; is->audio_pkt_data += len1;
is->audio_pkt_size -= len1; is->audio_pkt_size -= len1;
if(data_size <= 0) { if(data_size <= 0) {
/* No data yet, get more frames */ /* No data yet, get more frames */
continue; continue;
} }
pts = is->audio_clock; pts = is->audio_clock;
*pts_ptr = pts; *pts_ptr = pts;
n = 2 * is->audio_st->codec->channels; n = 2 * is->audio_st->codec->channels;
is->audio_clock += (double)data_size / 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 */ /* We have data, return it and come back for more later */
return data_size; return data_size;
@ -296,7 +296,7 @@ namespace MWRender
memset(is->audio_buf, 0, is->audio_buf_size); memset(is->audio_buf, 0, is->audio_buf_size);
} else { } else {
audio_size = synchronize_audio(is, (int16_t *)is->audio_buf, 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_size = audio_size;
} }
is->audio_buf_index = 0; is->audio_buf_index = 0;
@ -397,7 +397,7 @@ namespace MWRender
diff = vp->pts - ref_clock; diff = vp->pts - ref_clock;
/* Skip or repeat the frame. Take delay into account /* 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; sync_threshold = (delay > AV_SYNC_THRESHOLD) ? delay : AV_SYNC_THRESHOLD;
if(fabs(diff) < AV_NOSYNC_THRESHOLD) { if(fabs(diff) < AV_NOSYNC_THRESHOLD) {
if(diff <= -sync_threshold) { if(diff <= -sync_threshold) {
@ -442,8 +442,7 @@ namespace MWRender
/* wait until we have a new pic */ /* wait until we have a new pic */
{ {
boost::unique_lock<boost::mutex> lock(is->pictq_mutex); boost::unique_lock<boost::mutex> lock(is->pictq_mutex);
while(is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && while(is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && !is->quit) {
!is->quit) {
is->pictq_cond.timed_wait(lock, boost::posix_time::milliseconds(1)); is->pictq_cond.timed_wait(lock, boost::posix_time::milliseconds(1));
} }
} }
@ -458,9 +457,9 @@ namespace MWRender
if(is->sws_context == NULL) { if(is->sws_context == NULL) {
int w = is->video_st->codec->width; int w = is->video_st->codec->width;
int h = is->video_st->codec->height; int h = is->video_st->codec->height;
is->sws_context = sws_getContext(w, h, is->sws_context = sws_getContext(w, h, is->video_st->codec->pix_fmt,
is->video_st->codec->pix_fmt, w, h, w, h, PIX_FMT_RGBA, SWS_BICUBIC,
PIX_FMT_RGBA, SWS_BICUBIC, NULL, NULL, NULL); NULL, NULL, NULL);
if(is->sws_context == NULL) if(is->sws_context == NULL)
throw std::runtime_error("Cannot initialize the conversion context!\n"); 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); 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, 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; vp->pts = pts;
@ -544,8 +543,7 @@ namespace MWRender
// Save global pts to be stored in pFrame // Save global pts to be stored in pFrame
global_video_pkt_pts = packet->pts; global_video_pkt_pts = packet->pts;
// Decode video frame // Decode video frame
len1 = avcodec_decode_video2(is->video_st->codec, pFrame, &frameFinished, len1 = avcodec_decode_video2(is->video_st->codec, pFrame, &frameFinished, packet);
packet);
if(packet->dts == (int64_t)AV_NOPTS_VALUE if(packet->dts == (int64_t)AV_NOPTS_VALUE
&& pFrame->opaque && *(uint64_t*)pFrame->opaque != AV_NOPTS_VALUE) { && pFrame->opaque && *(uint64_t*)pFrame->opaque != AV_NOPTS_VALUE) {
pts = *(uint64_t *)pFrame->opaque; pts = *(uint64_t *)pFrame->opaque;
@ -698,12 +696,10 @@ namespace MWRender
av_dump_format(pFormatCtx, 0, is->resourceName.c_str(), 0); av_dump_format(pFormatCtx, 0, is->resourceName.c_str(), 0);
for(i=0; i<pFormatCtx->nb_streams; i++) { for(i=0; i<pFormatCtx->nb_streams; i++) {
if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO && if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO && video_index < 0) {
video_index < 0) {
video_index=i; video_index=i;
} }
if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO && if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO && audio_index < 0) {
audio_index < 0) {
audio_index=i; audio_index=i;
} }
} }
@ -717,15 +713,13 @@ namespace MWRender
if(is->videoStream >= 0 /*|| is->audioStream < 0*/) if(is->videoStream >= 0 /*|| is->audioStream < 0*/)
{ {
// main decode loop // main decode loop
for(;;) { for(;;) {
if(is->quit) { if(is->quit) {
break; break;
} }
if( (is->audioStream >= 0 && is->audioq.size > MAX_AUDIOQ_SIZE) || if((is->audioStream >= 0 && is->audioq.size > MAX_AUDIOQ_SIZE) ||
is->videoq.size > MAX_VIDEOQ_SIZE) { is->videoq.size > MAX_VIDEOQ_SIZE) {
boost::this_thread::sleep(boost::posix_time::milliseconds(10)); boost::this_thread::sleep(boost::posix_time::milliseconds(10));
continue; continue;
} }