Move use_gl variable outside of the while loop

This commit is contained in:
twinaphex 2020-06-05 16:53:28 +02:00
parent 52e1c38cf1
commit b8c41812bf

View File

@ -692,40 +692,41 @@ void CORE_PREFIX(retro_run)(void)
frames[0] = tmp;
}
while (!decode_thread_dead && min_pts > frames[1].pts)
{
int64_t pts = 0;
if (!decode_thread_dead)
video_buffer_wait_for_finished_slot(video_buffer);
if (!decode_thread_dead)
{
uint32_t *data = video_frame_temp_buffer;
video_decoder_context_t *ctx = NULL;
video_buffer_get_finished_slot(video_buffer, &ctx);
pts = ctx->pts;
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
if (use_gl)
if (use_gl)
{
float mix_factor;
while (!decode_thread_dead && min_pts > frames[1].pts)
{
int64_t pts = 0;
if (!decode_thread_dead)
video_buffer_wait_for_finished_slot(video_buffer);
if (!decode_thread_dead)
{
unsigned y;
const uint8_t *src;
int stride, width;
unsigned y;
uint32_t *data = video_frame_temp_buffer;
video_decoder_context_t *ctx = NULL;
video_buffer_get_finished_slot(video_buffer, &ctx);
pts = ctx->pts;
#ifndef HAVE_OPENGLES
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, frames[1].pbo);
#ifdef __MACH__
data = (uint32_t*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
data = (uint32_t*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
#else
data = (uint32_t*)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER,
data = (uint32_t*)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER,
0, media.width * media.height * sizeof(uint32_t), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
#endif
#endif
src = ctx->target->data[0];
stride = ctx->target->linesize[0];
width = media.width * sizeof(uint32_t);
src = ctx->target->data[0];
stride = ctx->target->linesize[0];
width = media.width * sizeof(uint32_t);
for (y = 0; y < media.height; y++, src += stride, data += width/4)
memcpy(data, src, width);
@ -744,29 +745,13 @@ void CORE_PREFIX(retro_run)(void)
#ifndef HAVE_OPENGLES
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
#endif
video_buffer_open_slot(video_buffer, ctx);
}
else
#endif
{
unsigned y;
const uint8_t *src = ctx->target->data[0];
int stride = ctx->target->linesize[0];
size_t width = media.width * sizeof(uint32_t);
for (y = 0; y < media.height; y++, src += stride, data += width/4)
memcpy(data, src, width);
dupe = false;
}
video_buffer_open_slot(video_buffer, ctx);
frames[1].pts = av_q2d(fctx->streams[video_stream_index]->time_base) * pts;
}
frames[1].pts = av_q2d(fctx->streams[video_stream_index]->time_base) * pts;
}
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
if (use_gl)
{
float mix_factor = (min_pts - frames[0].pts) / (frames[1].pts - frames[0].pts);
mix_factor = (min_pts - frames[0].pts) / (frames[1].pts - frames[0].pts);
if (!temporal_interpolation)
mix_factor = 1.0f;
@ -808,6 +793,36 @@ void CORE_PREFIX(retro_run)(void)
else
#endif
{
while (!decode_thread_dead && min_pts > frames[1].pts)
{
int64_t pts = 0;
if (!decode_thread_dead)
video_buffer_wait_for_finished_slot(video_buffer);
if (!decode_thread_dead)
{
unsigned y;
const uint8_t *src;
int stride, width;
uint32_t *data = video_frame_temp_buffer;
video_decoder_context_t *ctx = NULL;
video_buffer_get_finished_slot(video_buffer, &ctx);
pts = ctx->pts;
src = ctx->target->data[0];
stride = ctx->target->linesize[0];
width = media.width * sizeof(uint32_t);
for (y = 0; y < media.height; y++, src += stride, data += width/4)
memcpy(data, src, width);
dupe = false;
video_buffer_open_slot(video_buffer, ctx);
}
frames[1].pts = av_q2d(fctx->streams[video_stream_index]->time_base) * pts;
}
CORE_PREFIX(video_cb)(dupe ? NULL : video_frame_temp_buffer,
media.width, media.height, media.width * sizeof(uint32_t));
}