cuda_kernels.h 2.5 KB
#pragma once
#include "cuda_runtime.h"
#include "device_launch_parameters.h"

#include <stdio.h>
#include <stdlib.h>

#include <string.h>
#include <math.h>

#include <cuda.h>

typedef enum
{
	ITU_601 = 1,
	ITU_709 = 2
} FF_ColorSpace;

namespace cuda_common
{
	cudaError_t setColorSpace(FF_ColorSpace CSC, float hue);

	cudaError_t NV12ToRGBnot(CUdeviceptr d_srcNV12, size_t nSourcePitch, unsigned char* d_dstRGB, int width, int height);
	cudaError_t CUDAToBGR(CUdeviceptr dataY, CUdeviceptr dataUV, size_t pitchY, size_t pitchUV, unsigned char* d_dstRGB, int width, int height);

	
	cudaError_t ResizeImage(float* d_srcRGB, int src_width, int src_height, float* d_dstRGB, int dst_width, int dst_height);

	cudaError_t RGB2YUV(float* d_srcRGB, int src_width, int src_height,
		unsigned char* Y, size_t yPitch, int yWidth, int yHeight,
		unsigned char* U, size_t uPitch, int uWidth, int uHeight,
		unsigned char* V, size_t vPitch, int vWidth, int vHeight);

	cudaError_t RGB2YUV(unsigned char* d_srcRGB, int src_width, int src_height,
		unsigned char* Y, size_t yPitch, int yWidth, int yHeight,
		unsigned char* U, size_t uPitch, int uWidth, int uHeight,
		unsigned char* V, size_t vPitch, int vWidth, int vHeight);

	cudaError_t PartMemCopy(unsigned char* d_srcRGB, int src_width, int src_height, unsigned char* d_dstRGB, int left, int top, int right, int bottom);
	//	cudaError_t PartMemResize(float* d_srcRGB, int src_width, int src_height, float* d_dstRGB, int left, int top, int right, int bottom);

	cudaError_t PartMemResizeBatch(unsigned char* d_srcRGB, int srcimg_width, int srcimg_height, unsigned char** d_dstRGB, int count,
		int* left, int* top, int* right, int* bottom, int *dst_w, int *dst_h,
		float submeanb, float submeang, float submeanr,
		float varianceb, float varianceg, float variancer);

	cudaError_t DrawImage(float* d_srcRGB, int src_width, int src_height, int left, int top, int right, int bottom);
	cudaError_t DrawImage(unsigned char* d_srcRGB, int src_width, int src_height, int left, int top, int right, int bottom);

	cudaError_t DrawLine(float* d_srcRGB, int src_width, int src_height, int begin_x, int begin_y, int end_x, int end_y);
}


int jpegNPP(const char *szOutputFile, float* d_srcRGB, int img_width, int img_height);
int jpegNPP(const char *szOutputFile, unsigned char* d_srcRGB, int img_width, int img_height);

int jpegNPP(const char *szOutputFile, float* d_srcRGB);
int jpegNPP(const char *szOutputFile, unsigned char* d_srcRGB);

int initTable();
int initTable(int flag, int width, int height);
int releaseJpegNPP();