[decoders] change the API to allow more flexability in the future

This commit is contained in:
Geoffrey McRae 2018-05-15 19:19:39 +10:00
parent 332d53e016
commit 3a2d612b41
3 changed files with 25 additions and 27 deletions

View File

@ -39,7 +39,7 @@ static LG_OutFormat lgd_null_get_out_format (void * opaque);
static unsigned int lgd_null_get_frame_pitch (void * opaque);
static unsigned int lgd_null_get_frame_stride(void * opaque);
static bool lgd_null_decode (void * opaque, const uint8_t * src, size_t srcSize);
static bool lgd_null_get_buffer (void * opaque, uint8_t * dst, size_t dstSize);
static const uint8_t * lgd_null_get_buffer (void * opaque);
static bool lgd_null_create(void ** opaque)
{
@ -96,14 +96,13 @@ static bool lgd_null_decode(void * opaque, const uint8_t * src, size_t srcSize)
return true;
}
static bool lgd_null_get_buffer(void * opaque, uint8_t * dst, size_t dstSize)
static const uint8_t * lgd_null_get_buffer(void * opaque)
{
struct Inst * this = (struct Inst *)opaque;
if (!this->src)
return false;
return NULL;
memcpySSE(dst, this->src, dstSize);
return true;
return this->src;
}
const LG_Decoder LGD_NULL =

View File

@ -42,7 +42,7 @@ typedef LG_OutFormat (* LG_DecoderGetOutFormat )(void * opaque);
typedef unsigned int (* LG_DecoderGetFramePitch )(void * opaque);
typedef unsigned int (* LG_DecoderGetFrameStride)(void * opaque);
typedef bool (* LG_DecoderDecode )(void * opaque, const uint8_t * src, size_t srcSize);
typedef bool (* LG_DecoderGetBuffer )(void * opaque, uint8_t * dst, size_t dstSize);
typedef const uint8_t * (* LG_DecoderGetBuffer )(void * opaque);
typedef bool (* LG_DecoderInitGLTexture )(void * opaque, GLenum target, GLuint texture, void ** ref);
typedef void (* LG_DecoderFreeGLTexture )(void * opaque, void * ref);

View File

@ -1070,17 +1070,16 @@ static bool draw_frame(struct Inst * this)
this->fences[this->texIndex] = NULL;
}
if (!this->decoder->get_buffer(
this->decoderData,
this->texPixels[this->texIndex],
this->texSize
))
const uint8_t * data = this->decoder->get_buffer(this->decoderData);
if (!data)
{
LG_UNLOCK(this->formatLock);
DEBUG_ERROR("Failed to get the buffer from the decoder");
return false;
}
memcpySSE(this->texPixels[this->texIndex], data, this->texSize);
if (this->amdPinnedMemSupport)
this->fences[this->texIndex] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);