nsc: refactor nsc decoder #4
o move private struct to nsc_types.h o move nsc_decode() function in nsc_context as pointer
This commit is contained in:
parent
35555856ec
commit
20de74d811
@ -28,9 +28,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BYTESUM(_bs) (_bs[0] + _bs[1] + _bs[2] + _bs[3])
|
||||
#define ROUND_UP_TO(_b, _n) (_b + ((~(_b & (_n-1)) + 0x1) & (_n-1)))
|
||||
|
||||
/* NSCODEC_BITMAP_STREAM */
|
||||
struct _NSC_STREAM
|
||||
{
|
||||
@ -44,6 +41,7 @@ typedef struct _NSC_STREAM NSC_STREAM;
|
||||
|
||||
typedef struct _NSC_CONTEXT_PRIV NSC_CONTEXT_PRIV;
|
||||
|
||||
typedef struct _NSC_CONTEXT NSC_CONTEXT;
|
||||
struct _NSC_CONTEXT
|
||||
{
|
||||
uint32 OrgByteCount[4]; /* original byte length of luma, chroma orange, chroma green, alpha variable in order */
|
||||
@ -53,11 +51,14 @@ struct _NSC_CONTEXT
|
||||
uint16 height;
|
||||
uint8* bmpdata; /* final argb values in little endian order */
|
||||
uint32 bmpdata_length; /* the maximum length of the buffer that bmpdata points to */
|
||||
|
||||
void (*decode)(NSC_CONTEXT* context);
|
||||
|
||||
NSC_CONTEXT_PRIV* priv;
|
||||
};
|
||||
typedef struct _NSC_CONTEXT NSC_CONTEXT;
|
||||
|
||||
FREERDP_API NSC_CONTEXT* nsc_context_new(void);
|
||||
FREERDP_API void nsc_context_set_cpu_opt(NSC_CONTEXT* context, uint32 cpu_opt);
|
||||
FREERDP_API void nsc_process_message(NSC_CONTEXT* context, uint16 bpp,
|
||||
uint16 width, uint16 height, uint8* data, uint32 length);
|
||||
FREERDP_API void nsc_context_free(NSC_CONTEXT* context);
|
||||
|
@ -25,13 +25,14 @@
|
||||
#include <freerdp/codec/nsc.h>
|
||||
#include <freerdp/utils/memory.h>
|
||||
|
||||
#define MINMAX(_v,_l,_h) ((_v) < (_l) ? (_l) : ((_v) > (_h) ? (_h) : (_v)))
|
||||
#include "nsc_types.h"
|
||||
|
||||
struct _NSC_CONTEXT_PRIV
|
||||
{
|
||||
uint8* plane_buf[4]; /* Decompressed Plane Buffers in the respective order */
|
||||
uint32 plane_buf_length; /* Lengths of each plane buffer */
|
||||
};
|
||||
#ifndef NSC_INIT_SIMD
|
||||
#define NSC_INIT_SIMD(_nsc_context) do { } while (0)
|
||||
#endif
|
||||
|
||||
#define ROUND_UP_TO(_b, _n) (_b + ((~(_b & (_n-1)) + 0x1) & (_n-1)))
|
||||
#define MINMAX(_v,_l,_h) ((_v) < (_l) ? (_l) : ((_v) > (_h) ? (_h) : (_v)))
|
||||
|
||||
static void nsc_decode(NSC_CONTEXT* context)
|
||||
{
|
||||
@ -238,9 +239,17 @@ NSC_CONTEXT* nsc_context_new(void)
|
||||
nsc_context = xnew(NSC_CONTEXT);
|
||||
nsc_context->priv = xnew(NSC_CONTEXT_PRIV);
|
||||
|
||||
nsc_context->decode = nsc_decode;
|
||||
|
||||
return nsc_context;
|
||||
}
|
||||
|
||||
void nsc_context_set_cpu_opt(NSC_CONTEXT* context, uint32 cpu_opt)
|
||||
{
|
||||
if (cpu_opt)
|
||||
NSC_INIT_SIMD(context);
|
||||
}
|
||||
|
||||
void nsc_process_message(NSC_CONTEXT* context, uint16 bpp,
|
||||
uint16 width, uint16 height, uint8* data, uint32 length)
|
||||
{
|
||||
@ -259,5 +268,5 @@ void nsc_process_message(NSC_CONTEXT* context, uint16 bpp,
|
||||
nsc_rle_decompress_data(context);
|
||||
|
||||
/* Colorloss recover, Chroma supersample and AYCoCg to ARGB Conversion in one step */
|
||||
nsc_decode(context);
|
||||
context->decode(context);
|
||||
}
|
||||
|
40
libfreerdp-codec/nsc_types.h
Normal file
40
libfreerdp-codec/nsc_types.h
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol client.
|
||||
* NSCodec Library
|
||||
*
|
||||
* Copyright 2011 Samsung, Author Jiten Pathy
|
||||
* Copyright 2012 Vic Lee
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __NSC_TYPES_H
|
||||
#define __NSC_TYPES_H
|
||||
|
||||
#include "config.h"
|
||||
#include <freerdp/utils/debug.h>
|
||||
#include <freerdp/utils/profiler.h>
|
||||
|
||||
struct _NSC_CONTEXT_PRIV
|
||||
{
|
||||
uint8* plane_buf[4]; /* Decompressed Plane Buffers in the respective order */
|
||||
uint32 plane_buf_length; /* Lengths of each plane buffer */
|
||||
|
||||
/* profilers */
|
||||
PROFILER_DEFINE(prof_nsc_rle_decompress_data);
|
||||
PROFILER_DEFINE(prof_nsc_decode);
|
||||
PROFILER_DEFINE(prof_nsc_rle_compress_data);
|
||||
PROFILER_DEFINE(prof_nsc_encode);
|
||||
};
|
||||
|
||||
#endif /* __NSC_TYPES_H */
|
Loading…
x
Reference in New Issue
Block a user