diff --git a/C++CLI/Converter/Converter.cpp b/C++CLI/Converter/Converter.cpp deleted file mode 100644 index 36235c6..0000000 --- a/C++CLI/Converter/Converter.cpp +++ /dev/null @@ -1,359 +0,0 @@ -#include "pch.h" -#include "Converter.h" -#include - -enum -{ - FLAGS = 0x40080100 -}; - -#define READUV(U,V) (yuv2rgb565_table1[256 + (U)] + yuv2rgb565_table1[512 + (V)]) -#define READY(Y) yuv2rgb565_table1[Y] -#define FIXUP(Y) \ -do { \ - int tmp = (Y) & FLAGS; \ - if (tmp != 0) \ - { \ - tmp -= tmp>>8; \ - (Y) |= tmp; \ - tmp = FLAGS & ~(Y>>1); \ - (Y) += tmp>>8; \ - } \ -} while (0 == 1) - -#define STORE(Y,DSTPTR) \ -do { \ - unsigned int Y2 = (Y); \ - unsigned char *DSTPTR2 = (DSTPTR); \ - (DSTPTR2)[0] = (Y2); \ - (DSTPTR2)[1] = (Y2)>>22; \ - (DSTPTR2)[2] = (Y2)>>11; \ -} while (0 == 1) -extern "C" -void Yuv420P2RGB_(unsigned char* dst_ptr, - const unsigned char* y_ptr, - const unsigned char* u_ptr, - const unsigned char* v_ptr, - signed int width, - signed int height, - signed int y_span, - signed int uv_span, - signed int dst_span, - - signed int dither) -{ - height -= 1; - while (height > 0) - { - height -= width << 16; - height += 1 << 16; -#pragma clang loop vectorize(assume_safety) - while (height < 0) - { - /* Do 2 column pairs */ - unsigned int uv, y0, y1; - - uv = READUV(*u_ptr++, *v_ptr++); - y1 = uv + READY(y_ptr[y_span]); - y0 = uv + READY(*y_ptr++); - FIXUP(y1); - FIXUP(y0); - STORE(y1, &dst_ptr[dst_span]); - STORE(y0, dst_ptr); - dst_ptr += 3; - y1 = uv + READY(y_ptr[y_span]); - y0 = uv + READY(*y_ptr++); - FIXUP(y1); - FIXUP(y0); - STORE(y1, &dst_ptr[dst_span]); - STORE(y0, dst_ptr); - dst_ptr += 3; - height += (2 << 16); - } - if ((height >> 16) == 0) - { - /* Trailing column pair */ - unsigned int uv, y0, y1; - - uv = READUV(*u_ptr, *v_ptr); - y1 = uv + READY(y_ptr[y_span]); - y0 = uv + READY(*y_ptr++); - FIXUP(y1); - FIXUP(y0); - STORE(y0, &dst_ptr[dst_span]); - STORE(y1, dst_ptr); - dst_ptr += 3; - } - dst_ptr += dst_span * 2 - width * 3; - y_ptr += y_span * 2 - width; - u_ptr += uv_span - (width >> 1); - v_ptr += uv_span - (width >> 1); - height = (height << 16) >> 16; - height -= 2; - } - if (height == 0) - { - /* Trail row */ - height -= width << 16; - height += 1 << 16; -#pragma clang loop vectorize(assume_safety) - while (height < 0) - { - /* Do a row pair */ - unsigned int uv, y0, y1; - - uv = READUV(*u_ptr++, *v_ptr++); - y1 = uv + READY(*y_ptr++); - y0 = uv + READY(*y_ptr++); - FIXUP(y1); - FIXUP(y0); - STORE(y1, dst_ptr); - dst_ptr += 3; - STORE(y0, dst_ptr); - dst_ptr += 3; - height += (2 << 16); - } - if ((height >> 16) == 0) - { - /* Trailing pix */ - unsigned int uv, y0; - - uv = READUV(*u_ptr++, *v_ptr++); - y0 = uv + READY(*y_ptr++); - FIXUP(y0); - STORE(y0, dst_ptr); - dst_ptr += 3; - } - } - -}; - -void BGRAtoYUV420Planar_(unsigned char* bgra, unsigned char* dst, int width, int height, int stride) -{ - const int frameSize = width * height; - int yIndex = 0; - int vIndex = frameSize; - int uIndex = frameSize + (frameSize / 4); - //int r, g, b, y, u, v; - int index = 0; - - const int hi = height / 2; - const int wi = width / 2; - const int nextLineStride = 2 * stride - (4 * width); - unsigned char* buffer = dst; - for (int j = 0; j < hi; ++j) - { -#pragma clang loop unroll_count(2) -#pragma clang loop vectorize(assume_safety) - //#pragma clang loop vectorize_width(32) interleave_count(8) - for (int i = 0; i < wi; ++i) - { - int b = bgra[index]; - int g = bgra[index + 1]; - int r = bgra[index + 2]; - - int b1 = bgra[index + 4]; - int g1 = bgra[index + 5]; - int r1 = bgra[index + 6]; - - int nextLineIdx = index + stride; - int b2 = bgra[nextLineIdx]; - int g2 = bgra[nextLineIdx + 1]; - int r2 = bgra[nextLineIdx + 2]; - - int b3 = bgra[nextLineIdx + 4]; - int g3 = bgra[nextLineIdx + 5]; - int r3 = bgra[nextLineIdx + 6]; - - int nextLineYIdx = yIndex + width; - - buffer[yIndex] = ((25 * b + 129 * g + 66 * r) >> 8) + 16; - buffer[yIndex + 1] = ((25 * b1 + 129 * g1 + 66 * r1) >> 8) + 16; - buffer[nextLineYIdx] = ((25 * b2 + 129 * g2 + 66 * r2) >> 8) + 16; - buffer[nextLineYIdx + 1] = ((25 * b3 + 129 * g3 + 66 * r3) >> 8) + 16; - - buffer[uIndex++] = ((112 * r + -94 * g + -18 * b) >> 8) + 128; - buffer[vIndex++] = ((-38 * r + -74 * g + 112 * b) >> 8) + 128; - yIndex += 2; - index += 8; - } - index += nextLineStride; - yIndex += width; - - } - -} - -void RGBAtoYUV420Planar_(unsigned char* bgra, unsigned char* dst, int width, int height, int stride) -{ - const int frameSize = width * height; - int yIndex = 0; - int vIndex = frameSize; - int uIndex = frameSize + (frameSize / 4); - //int r, g, b, y, u, v; - int index = 0; - - const int hi = height / 2; - const int wi = width / 2; - const int nextLineStride = 2 * stride - (4 * width); - unsigned char* buffer = dst; - for (int j = 0; j < hi; ++j) - { -#pragma clang loop unroll_count(2) -#pragma clang loop vectorize(assume_safety) - //#pragma clang loop vectorize_width(32) interleave_count(8) - for (int i = 0; i < wi; ++i) - { - int r = bgra[index]; - int g = bgra[index + 1]; - int b = bgra[index + 2]; - - int r1 = bgra[index + 4]; - int g1 = bgra[index + 5]; - int b1 = bgra[index + 6]; - - int nextLineIdx = index + stride; - int r2 = bgra[nextLineIdx]; - int g2 = bgra[nextLineIdx + 1]; - int b2 = bgra[nextLineIdx + 2]; - - int r3 = bgra[nextLineIdx + 4]; - int g3 = bgra[nextLineIdx + 5]; - int b3 = bgra[nextLineIdx + 6]; - - int nextLineYIdx = yIndex + width; - - buffer[yIndex] = ((25 * b + 129 * g + 66 * r) >> 8) + 16; - buffer[yIndex + 1] = ((25 * b1 + 129 * g1 + 66 * r1) >> 8) + 16; - buffer[nextLineYIdx] = ((25 * b2 + 129 * g2 + 66 * r2) >> 8) + 16; - buffer[nextLineYIdx + 1] = ((25 * b3 + 129 * g3 + 66 * r3) >> 8) + 16; - - buffer[uIndex++] = ((112 * r + -94 * g + -18 * b) >> 8) + 128; - buffer[vIndex++] = ((-38 * r + -74 * g + 112 * b) >> 8) + 128; - yIndex += 2; - index += 8; - } - index += nextLineStride; - yIndex += width; - - } - -} - -void BGRtoYUV420Planar_(unsigned char* bgra, unsigned char* dst, int width, int height, int stride) -{ - const int frameSize = width * height; - int yIndex = 0; - int vIndex = frameSize; - int uIndex = frameSize + (frameSize / 4); - //int r, g, b, y, u, v; - int index = 0; - - const int hi = height / 2; - const int wi = width / 2; - const int nextLineSttride = 2*stride -(3*width); - unsigned char* buffer = dst; - for (int j = 0; j < hi; ++j) - { -#pragma clang loop unroll_count(2) -#pragma clang loop vectorize(assume_safety) - //#pragma clang loop vectorize_width(32) interleave_count(8) - for (int i = 0; i < wi; ++i) - { - int b = bgra[index]; - int g = bgra[index + 1]; - int r = bgra[index + 2]; - - int b1 = bgra[index + 3]; - int g1 = bgra[index + 4]; - int r1 = bgra[index + 5]; - - int nextLineIdx = index + stride; - int b2 = bgra[nextLineIdx]; - int g2 = bgra[nextLineIdx + 1]; - int r2 = bgra[nextLineIdx + 2]; - - int b3 = bgra[nextLineIdx + 3]; - int g3 = bgra[nextLineIdx + 4]; - int r3 = bgra[nextLineIdx + 5]; - - int nextLineYIdx = yIndex + width; - - buffer[yIndex] = ((25 * b + 129 * g + 66 * r) >> 8) + 16; - buffer[yIndex + 1] = ((25 * b1 + 129 * g1 + 66 * r1) >> 8) + 16; - buffer[nextLineYIdx] = ((25 * b2 + 129 * g2 + 66 * r2) >> 8) + 16; - buffer[nextLineYIdx + 1] = ((25 * b3 + 129 * g3 + 66 * r3) >> 8) + 16; - - buffer[uIndex++] = ((112 * r + -94 * g + -18 * b) >> 8) + 128; - buffer[vIndex++] = ((-38 * r + -74 * g + 112 * b) >> 8) + 128; - yIndex += 2; - index += 6; - } - index += nextLineSttride; - yIndex +=width; - - } - -} - -void RGBtoYUV420Planar_(unsigned char* bgra, unsigned char* dst, int width, int height, int stride) -{ - const int frameSize = width * height; - int yIndex = 0; - int vIndex = frameSize; - int uIndex = frameSize + (frameSize / 4); - //int r, g, b, y, u, v; - int index = 0; - - const int hi = height / 2; - const int wi = width / 2; - const int nextLineSttride = 2 * stride - (3 * width); - unsigned char* buffer = dst; - for (int j = 0; j < hi; ++j) - { -#pragma clang loop unroll_count(2) -#pragma clang loop vectorize(assume_safety) - //#pragma clang loop vectorize_width(32) interleave_count(8) - for (int i = 0; i < wi; ++i) - { - int r = bgra[index]; - int g = bgra[index + 1]; - int b = bgra[index + 2]; - - int r1 = bgra[index + 3]; - int g1 = bgra[index + 4]; - int b1 = bgra[index + 5]; - - int nextLineIdx = index + stride; - int r2 = bgra[nextLineIdx]; - int g2 = bgra[nextLineIdx + 1]; - int b2 = bgra[nextLineIdx + 2]; - - int r3 = bgra[nextLineIdx + 3]; - int g3 = bgra[nextLineIdx + 4]; - int b3 = bgra[nextLineIdx + 5]; - - int nextLineYIdx = yIndex + width; - - buffer[yIndex] = ((25 * b + 129 * g + 66 * r) >> 8) + 16; - buffer[yIndex + 1] = ((25 * b1 + 129 * g1 + 66 * r1) >> 8) + 16; - buffer[nextLineYIdx] = ((25 * b2 + 129 * g2 + 66 * r2) >> 8) + 16; - buffer[nextLineYIdx + 1] = ((25 * b3 + 129 * g3 + 66 * r3) >> 8) + 16; - - buffer[uIndex++] = ((112 * r + -94 * g + -18 * b) >> 8) + 128; - buffer[vIndex++] = ((-38 * r + -74 * g + 112 * b) >> 8) + 128; - yIndex += 2; - index += 6; - } - index += nextLineSttride; - yIndex += width; - - } - -} - - - - - - diff --git a/C++CLI/Converter/Converter.h b/C++CLI/Converter/Converter.h deleted file mode 100644 index 7e62969..0000000 --- a/C++CLI/Converter/Converter.h +++ /dev/null @@ -1,800 +0,0 @@ -#pragma once -#include "pch.h" -//typedef unsigned int uint32_t; -//typedef signed int int32_t; -//typedef unsigned short uint16_t; -//typedef signed short int16_t; -//typedef unsigned char uint8_t; - -extern "C" __declspec(dllexport) void Yuv420P2RGB_(unsigned char* dst_ptr, - const unsigned char* y_ptr, - const unsigned char* u_ptr, - const unsigned char* v_ptr, - signed int width, - signed int height, - signed int y_span, - signed int uv_span, - signed int dst_span, - signed int dither); - -extern "C" __declspec(dllexport) void BGRAtoYUV420Planar_(unsigned char* bgra, unsigned char* dst, int width, int height, int stride); -extern "C" __declspec(dllexport) void BGRtoYUV420Planar_(unsigned char* bgr, unsigned char* dst, int width, int height, int stride); -extern "C" __declspec(dllexport) void RGBAtoYUV420Planar_(unsigned char* bgr, unsigned char* dst, int width, int height, int stride); -extern "C" __declspec(dllexport) void RGBtoYUV420Planar_(unsigned char* bgr, unsigned char* dst, int width, int height, int stride); - -//void __cdecl BGRAtoYUV420Planar_(unsigned char* bgra, unsigned char* dst, int width, int height, int stride); - -const unsigned int yuv2rgb565_table1[256 * 3] = -{ - /* y_table */ - 0x7FFFFFEDU, - 0x7FFFFFEFU, - 0x7FFFFFF0U, - 0x7FFFFFF1U, - 0x7FFFFFF2U, - 0x7FFFFFF3U, - 0x7FFFFFF4U, - 0x7FFFFFF6U, - 0x7FFFFFF7U, - 0x7FFFFFF8U, - 0x7FFFFFF9U, - 0x7FFFFFFAU, - 0x7FFFFFFBU, - 0x7FFFFFFDU, - 0x7FFFFFFEU, - 0x7FFFFFFFU, - 0x80000000U, - 0x80400801U, - 0x80A01002U, - 0x80E01803U, - 0x81202805U, - 0x81803006U, - 0x81C03807U, - 0x82004008U, - 0x82604809U, - 0x82A0500AU, - 0x82E0600CU, - 0x8340680DU, - 0x8380700EU, - 0x83C0780FU, - 0x84208010U, - 0x84608811U, - 0x84A09813U, - 0x8500A014U, - 0x8540A815U, - 0x8580B016U, - 0x85E0B817U, - 0x8620C018U, - 0x8660D01AU, - 0x86C0D81BU, - 0x8700E01CU, - 0x8740E81DU, - 0x87A0F01EU, - 0x87E0F81FU, - 0x88210821U, - 0x88811022U, - 0x88C11823U, - 0x89012024U, - 0x89412825U, - 0x89A13026U, - 0x89E14028U, - 0x8A214829U, - 0x8A81502AU, - 0x8AC1582BU, - 0x8B01602CU, - 0x8B61682DU, - 0x8BA1782FU, - 0x8BE18030U, - 0x8C418831U, - 0x8C819032U, - 0x8CC19833U, - 0x8D21A034U, - 0x8D61B036U, - 0x8DA1B837U, - 0x8E01C038U, - 0x8E41C839U, - 0x8E81D03AU, - 0x8EE1D83BU, - 0x8F21E83DU, - 0x8F61F03EU, - 0x8FC1F83FU, - 0x90020040U, - 0x90420841U, - 0x90A21042U, - 0x90E22044U, - 0x91222845U, - 0x91823046U, - 0x91C23847U, - 0x92024048U, - 0x92624849U, - 0x92A2504AU, - 0x92E2604CU, - 0x9342684DU, - 0x9382704EU, - 0x93C2784FU, - 0x94228050U, - 0x94628851U, - 0x94A29853U, - 0x9502A054U, - 0x9542A855U, - 0x9582B056U, - 0x95E2B857U, - 0x9622C058U, - 0x9662D05AU, - 0x96C2D85BU, - 0x9702E05CU, - 0x9742E85DU, - 0x97A2F05EU, - 0x97E2F85FU, - 0x98230861U, - 0x98831062U, - 0x98C31863U, - 0x99032064U, - 0x99632865U, - 0x99A33066U, - 0x99E34068U, - 0x9A434869U, - 0x9A83506AU, - 0x9AC3586BU, - 0x9B23606CU, - 0x9B63686DU, - 0x9BA3786FU, - 0x9BE38070U, - 0x9C438871U, - 0x9C839072U, - 0x9CC39873U, - 0x9D23A074U, - 0x9D63B076U, - 0x9DA3B877U, - 0x9E03C078U, - 0x9E43C879U, - 0x9E83D07AU, - 0x9EE3D87BU, - 0x9F23E87DU, - 0x9F63F07EU, - 0x9FC3F87FU, - 0xA0040080U, - 0xA0440881U, - 0xA0A41082U, - 0xA0E42084U, - 0xA1242885U, - 0xA1843086U, - 0xA1C43887U, - 0xA2044088U, - 0xA2644889U, - 0xA2A4588BU, - 0xA2E4608CU, - 0xA344688DU, - 0xA384708EU, - 0xA3C4788FU, - 0xA4248090U, - 0xA4649092U, - 0xA4A49893U, - 0xA504A094U, - 0xA544A895U, - 0xA584B096U, - 0xA5E4B897U, - 0xA624C098U, - 0xA664D09AU, - 0xA6C4D89BU, - 0xA704E09CU, - 0xA744E89DU, - 0xA7A4F09EU, - 0xA7E4F89FU, - 0xA82508A1U, - 0xA88510A2U, - 0xA8C518A3U, - 0xA90520A4U, - 0xA96528A5U, - 0xA9A530A6U, - 0xA9E540A8U, - 0xAA4548A9U, - 0xAA8550AAU, - 0xAAC558ABU, - 0xAB2560ACU, - 0xAB6568ADU, - 0xABA578AFU, - 0xAC0580B0U, - 0xAC4588B1U, - 0xAC8590B2U, - 0xACE598B3U, - 0xAD25A0B4U, - 0xAD65B0B6U, - 0xADA5B8B7U, - 0xAE05C0B8U, - 0xAE45C8B9U, - 0xAE85D0BAU, - 0xAEE5D8BBU, - 0xAF25E8BDU, - 0xAF65F0BEU, - 0xAFC5F8BFU, - 0xB00600C0U, - 0xB04608C1U, - 0xB0A610C2U, - 0xB0E620C4U, - 0xB12628C5U, - 0xB18630C6U, - 0xB1C638C7U, - 0xB20640C8U, - 0xB26648C9U, - 0xB2A658CBU, - 0xB2E660CCU, - 0xB34668CDU, - 0xB38670CEU, - 0xB3C678CFU, - 0xB42680D0U, - 0xB46690D2U, - 0xB4A698D3U, - 0xB506A0D4U, - 0xB546A8D5U, - 0xB586B0D6U, - 0xB5E6B8D7U, - 0xB626C8D9U, - 0xB666D0DAU, - 0xB6C6D8DBU, - 0xB706E0DCU, - 0xB746E8DDU, - 0xB7A6F0DEU, - 0xB7E6F8DFU, - 0xB82708E1U, - 0xB88710E2U, - 0xB8C718E3U, - 0xB90720E4U, - 0xB96728E5U, - 0xB9A730E6U, - 0xB9E740E8U, - 0xBA4748E9U, - 0xBA8750EAU, - 0xBAC758EBU, - 0xBB2760ECU, - 0xBB6768EDU, - 0xBBA778EFU, - 0xBC0780F0U, - 0xBC4788F1U, - 0xBC8790F2U, - 0xBCE798F3U, - 0xBD27A0F4U, - 0xBD67B0F6U, - 0xBDC7B8F7U, - 0xBE07C0F8U, - 0xBE47C8F9U, - 0xBEA7D0FAU, - 0xBEE7D8FBU, - 0xBF27E8FDU, - 0xBF87F0FEU, - 0xBFC7F8FFU, - 0xC0080100U, - 0xC0480901U, - 0xC0A81102U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - /* u_table */ - 0x0C400103U, - 0x0C200105U, - 0x0C200107U, - 0x0C000109U, - 0x0BE0010BU, - 0x0BC0010DU, - 0x0BA0010FU, - 0x0BA00111U, - 0x0B800113U, - 0x0B600115U, - 0x0B400117U, - 0x0B400119U, - 0x0B20011BU, - 0x0B00011DU, - 0x0AE0011FU, - 0x0AE00121U, - 0x0AC00123U, - 0x0AA00125U, - 0x0A800127U, - 0x0A600129U, - 0x0A60012BU, - 0x0A40012DU, - 0x0A20012FU, - 0x0A000131U, - 0x0A000132U, - 0x09E00134U, - 0x09C00136U, - 0x09A00138U, - 0x09A0013AU, - 0x0980013CU, - 0x0960013EU, - 0x09400140U, - 0x09400142U, - 0x09200144U, - 0x09000146U, - 0x08E00148U, - 0x08C0014AU, - 0x08C0014CU, - 0x08A0014EU, - 0x08800150U, - 0x08600152U, - 0x08600154U, - 0x08400156U, - 0x08200158U, - 0x0800015AU, - 0x0800015CU, - 0x07E0015EU, - 0x07C00160U, - 0x07A00162U, - 0x07A00164U, - 0x07800166U, - 0x07600168U, - 0x0740016AU, - 0x0720016CU, - 0x0720016EU, - 0x07000170U, - 0x06E00172U, - 0x06C00174U, - 0x06C00176U, - 0x06A00178U, - 0x0680017AU, - 0x0660017CU, - 0x0660017EU, - 0x06400180U, - 0x06200182U, - 0x06000184U, - 0x05E00185U, - 0x05E00187U, - 0x05C00189U, - 0x05A0018BU, - 0x0580018DU, - 0x0580018FU, - 0x05600191U, - 0x05400193U, - 0x05200195U, - 0x05200197U, - 0x05000199U, - 0x04E0019BU, - 0x04C0019DU, - 0x04C0019FU, - 0x04A001A1U, - 0x048001A3U, - 0x046001A5U, - 0x044001A7U, - 0x044001A9U, - 0x042001ABU, - 0x040001ADU, - 0x03E001AFU, - 0x03E001B1U, - 0x03C001B3U, - 0x03A001B5U, - 0x038001B7U, - 0x038001B9U, - 0x036001BBU, - 0x034001BDU, - 0x032001BFU, - 0x032001C1U, - 0x030001C3U, - 0x02E001C5U, - 0x02C001C7U, - 0x02A001C9U, - 0x02A001CBU, - 0x028001CDU, - 0x026001CFU, - 0x024001D1U, - 0x024001D3U, - 0x022001D5U, - 0x020001D7U, - 0x01E001D8U, - 0x01E001DAU, - 0x01C001DCU, - 0x01A001DEU, - 0x018001E0U, - 0x016001E2U, - 0x016001E4U, - 0x014001E6U, - 0x012001E8U, - 0x010001EAU, - 0x010001ECU, - 0x00E001EEU, - 0x00C001F0U, - 0x00A001F2U, - 0x00A001F4U, - 0x008001F6U, - 0x006001F8U, - 0x004001FAU, - 0x004001FCU, - 0x002001FEU, - 0x00000200U, - 0xFFE00202U, - 0xFFC00204U, - 0xFFC00206U, - 0xFFA00208U, - 0xFF80020AU, - 0xFF60020CU, - 0xFF60020EU, - 0xFF400210U, - 0xFF200212U, - 0xFF000214U, - 0xFF000216U, - 0xFEE00218U, - 0xFEC0021AU, - 0xFEA0021CU, - 0xFEA0021EU, - 0xFE800220U, - 0xFE600222U, - 0xFE400224U, - 0xFE200226U, - 0xFE200228U, - 0xFE000229U, - 0xFDE0022BU, - 0xFDC0022DU, - 0xFDC0022FU, - 0xFDA00231U, - 0xFD800233U, - 0xFD600235U, - 0xFD600237U, - 0xFD400239U, - 0xFD20023BU, - 0xFD00023DU, - 0xFCE0023FU, - 0xFCE00241U, - 0xFCC00243U, - 0xFCA00245U, - 0xFC800247U, - 0xFC800249U, - 0xFC60024BU, - 0xFC40024DU, - 0xFC20024FU, - 0xFC200251U, - 0xFC000253U, - 0xFBE00255U, - 0xFBC00257U, - 0xFBC00259U, - 0xFBA0025BU, - 0xFB80025DU, - 0xFB60025FU, - 0xFB400261U, - 0xFB400263U, - 0xFB200265U, - 0xFB000267U, - 0xFAE00269U, - 0xFAE0026BU, - 0xFAC0026DU, - 0xFAA0026FU, - 0xFA800271U, - 0xFA800273U, - 0xFA600275U, - 0xFA400277U, - 0xFA200279U, - 0xFA20027BU, - 0xFA00027CU, - 0xF9E0027EU, - 0xF9C00280U, - 0xF9A00282U, - 0xF9A00284U, - 0xF9800286U, - 0xF9600288U, - 0xF940028AU, - 0xF940028CU, - 0xF920028EU, - 0xF9000290U, - 0xF8E00292U, - 0xF8E00294U, - 0xF8C00296U, - 0xF8A00298U, - 0xF880029AU, - 0xF860029CU, - 0xF860029EU, - 0xF84002A0U, - 0xF82002A2U, - 0xF80002A4U, - 0xF80002A6U, - 0xF7E002A8U, - 0xF7C002AAU, - 0xF7A002ACU, - 0xF7A002AEU, - 0xF78002B0U, - 0xF76002B2U, - 0xF74002B4U, - 0xF74002B6U, - 0xF72002B8U, - 0xF70002BAU, - 0xF6E002BCU, - 0xF6C002BEU, - 0xF6C002C0U, - 0xF6A002C2U, - 0xF68002C4U, - 0xF66002C6U, - 0xF66002C8U, - 0xF64002CAU, - 0xF62002CCU, - 0xF60002CEU, - 0xF60002CFU, - 0xF5E002D1U, - 0xF5C002D3U, - 0xF5A002D5U, - 0xF5A002D7U, - 0xF58002D9U, - 0xF56002DBU, - 0xF54002DDU, - 0xF52002DFU, - 0xF52002E1U, - 0xF50002E3U, - 0xF4E002E5U, - 0xF4C002E7U, - 0xF4C002E9U, - 0xF4A002EBU, - 0xF48002EDU, - 0xF46002EFU, - 0xF46002F1U, - 0xF44002F3U, - 0xF42002F5U, - 0xF40002F7U, - 0xF3E002F9U, - 0xF3E002FBU, - /* v_table */ - 0x1A09A000U, - 0x19E9A800U, - 0x19A9B800U, - 0x1969C800U, - 0x1949D000U, - 0x1909E000U, - 0x18C9E800U, - 0x18A9F800U, - 0x186A0000U, - 0x182A1000U, - 0x180A2000U, - 0x17CA2800U, - 0x17AA3800U, - 0x176A4000U, - 0x172A5000U, - 0x170A6000U, - 0x16CA6800U, - 0x168A7800U, - 0x166A8000U, - 0x162A9000U, - 0x160AA000U, - 0x15CAA800U, - 0x158AB800U, - 0x156AC000U, - 0x152AD000U, - 0x14EAE000U, - 0x14CAE800U, - 0x148AF800U, - 0x146B0000U, - 0x142B1000U, - 0x13EB2000U, - 0x13CB2800U, - 0x138B3800U, - 0x134B4000U, - 0x132B5000U, - 0x12EB6000U, - 0x12CB6800U, - 0x128B7800U, - 0x124B8000U, - 0x122B9000U, - 0x11EBA000U, - 0x11ABA800U, - 0x118BB800U, - 0x114BC000U, - 0x112BD000U, - 0x10EBE000U, - 0x10ABE800U, - 0x108BF800U, - 0x104C0000U, - 0x100C1000U, - 0x0FEC2000U, - 0x0FAC2800U, - 0x0F8C3800U, - 0x0F4C4000U, - 0x0F0C5000U, - 0x0EEC5800U, - 0x0EAC6800U, - 0x0E6C7800U, - 0x0E4C8000U, - 0x0E0C9000U, - 0x0DEC9800U, - 0x0DACA800U, - 0x0D6CB800U, - 0x0D4CC000U, - 0x0D0CD000U, - 0x0CCCD800U, - 0x0CACE800U, - 0x0C6CF800U, - 0x0C4D0000U, - 0x0C0D1000U, - 0x0BCD1800U, - 0x0BAD2800U, - 0x0B6D3800U, - 0x0B2D4000U, - 0x0B0D5000U, - 0x0ACD5800U, - 0x0AAD6800U, - 0x0A6D7800U, - 0x0A2D8000U, - 0x0A0D9000U, - 0x09CD9800U, - 0x098DA800U, - 0x096DB800U, - 0x092DC000U, - 0x090DD000U, - 0x08CDD800U, - 0x088DE800U, - 0x086DF800U, - 0x082E0000U, - 0x07EE1000U, - 0x07CE1800U, - 0x078E2800U, - 0x076E3800U, - 0x072E4000U, - 0x06EE5000U, - 0x06CE5800U, - 0x068E6800U, - 0x064E7800U, - 0x062E8000U, - 0x05EE9000U, - 0x05CE9800U, - 0x058EA800U, - 0x054EB800U, - 0x052EC000U, - 0x04EED000U, - 0x04AED800U, - 0x048EE800U, - 0x044EF000U, - 0x042F0000U, - 0x03EF1000U, - 0x03AF1800U, - 0x038F2800U, - 0x034F3000U, - 0x030F4000U, - 0x02EF5000U, - 0x02AF5800U, - 0x028F6800U, - 0x024F7000U, - 0x020F8000U, - 0x01EF9000U, - 0x01AF9800U, - 0x016FA800U, - 0x014FB000U, - 0x010FC000U, - 0x00EFD000U, - 0x00AFD800U, - 0x006FE800U, - 0x004FF000U, - 0x00100000U, - 0xFFD01000U, - 0xFFB01800U, - 0xFF702800U, - 0xFF303000U, - 0xFF104000U, - 0xFED05000U, - 0xFEB05800U, - 0xFE706800U, - 0xFE307000U, - 0xFE108000U, - 0xFDD09000U, - 0xFD909800U, - 0xFD70A800U, - 0xFD30B000U, - 0xFD10C000U, - 0xFCD0D000U, - 0xFC90D800U, - 0xFC70E800U, - 0xFC30F000U, - 0xFBF10000U, - 0xFBD11000U, - 0xFB911800U, - 0xFB712800U, - 0xFB313000U, - 0xFAF14000U, - 0xFAD14800U, - 0xFA915800U, - 0xFA516800U, - 0xFA317000U, - 0xF9F18000U, - 0xF9D18800U, - 0xF9919800U, - 0xF951A800U, - 0xF931B000U, - 0xF8F1C000U, - 0xF8B1C800U, - 0xF891D800U, - 0xF851E800U, - 0xF831F000U, - 0xF7F20000U, - 0xF7B20800U, - 0xF7921800U, - 0xF7522800U, - 0xF7123000U, - 0xF6F24000U, - 0xF6B24800U, - 0xF6925800U, - 0xF6526800U, - 0xF6127000U, - 0xF5F28000U, - 0xF5B28800U, - 0xF5729800U, - 0xF552A800U, - 0xF512B000U, - 0xF4F2C000U, - 0xF4B2C800U, - 0xF472D800U, - 0xF452E800U, - 0xF412F000U, - 0xF3D30000U, - 0xF3B30800U, - 0xF3731800U, - 0xF3532800U, - 0xF3133000U, - 0xF2D34000U, - 0xF2B34800U, - 0xF2735800U, - 0xF2336800U, - 0xF2137000U, - 0xF1D38000U, - 0xF1B38800U, - 0xF1739800U, - 0xF133A800U, - 0xF113B000U, - 0xF0D3C000U, - 0xF093C800U, - 0xF073D800U, - 0xF033E000U, - 0xF013F000U, - 0xEFD40000U, - 0xEF940800U, - 0xEF741800U, - 0xEF342000U, - 0xEEF43000U, - 0xEED44000U, - 0xEE944800U, - 0xEE745800U, - 0xEE346000U, - 0xEDF47000U, - 0xEDD48000U, - 0xED948800U, - 0xED549800U, - 0xED34A000U, - 0xECF4B000U, - 0xECD4C000U, - 0xEC94C800U, - 0xEC54D800U, - 0xEC34E000U, - 0xEBF4F000U, - 0xEBB50000U, - 0xEB950800U, - 0xEB551800U, - 0xEB352000U, - 0xEAF53000U, - 0xEAB54000U, - 0xEA954800U, - 0xEA555800U, - 0xEA156000U, - 0xE9F57000U, - 0xE9B58000U, - 0xE9958800U, - 0xE9559800U, - 0xE915A000U, - 0xE8F5B000U, - 0xE8B5C000U, - 0xE875C800U, - 0xE855D800U, - 0xE815E000U, - 0xE7F5F000U, - 0xE7B60000U, - 0xE7760800U, - 0xE7561800U, - 0xE7162000U, - 0xE6D63000U, - 0xE6B64000U, - 0xE6764800U, - 0xE6365800U -}; \ No newline at end of file diff --git a/C++CLI/Converter/Converter.vcxproj b/C++CLI/Converter/Converter.vcxproj deleted file mode 100644 index 658411f..0000000 --- a/C++CLI/Converter/Converter.vcxproj +++ /dev/null @@ -1,174 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {93266d21-efd2-4d7c-9075-fa72d71bc015} - Converter - 10.0 - - - - DynamicLibrary - true - ClangCL - Unicode - - - DynamicLibrary - false - ClangCL - true - Unicode - - - StaticLibrary - true - ClangCL - Unicode - - - DynamicLibrary - false - ClangCL - Unicode - - - - - - - - - - - - - - - - - - - - - $(ProjectName)32 - - - $(ProjectName)32 - - - $(ProjectName)64 - - - $(ProjectName)64 - - - - Level3 - true - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - true - Use - pch.h - - - - - true - - - - - Level3 - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - true - Use - pch.h - -Rpass-analysis=loop-vectorize -Rpass=loop-vectorize -Rpass-missed=loop-vectorize %(AdditionalOptions) - stdcpp20 - Full - AdvancedVectorExtensions2 - - - - - true - true - true - - - - - Level3 - true - _DEBUG;_LIB;%(PreprocessorDefinitions) - true - Use - pch.h - - - - - true - - - - - Level3 - true - NDEBUG;_LIB;%(PreprocessorDefinitions) - true - Use - pch.h - AdvancedVectorExtensions2 - Full - -Rpass=loop-vectorize %(AdditionalOptions) - Fast - false - - - - - true - true - true - - - - - - - - - - - Create - Create - Create - Create - - - - - - \ No newline at end of file diff --git a/C++CLI/Converter/Converter.vcxproj.filters b/C++CLI/Converter/Converter.vcxproj.filters deleted file mode 100644 index 0f669bc..0000000 --- a/C++CLI/Converter/Converter.vcxproj.filters +++ /dev/null @@ -1,36 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/C++CLI/Converter/framework.h b/C++CLI/Converter/framework.h deleted file mode 100644 index 3209b4a..0000000 --- a/C++CLI/Converter/framework.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers diff --git a/C++CLI/Converter/pch.cpp b/C++CLI/Converter/pch.cpp deleted file mode 100644 index 64b7eef..0000000 --- a/C++CLI/Converter/pch.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// pch.cpp: source file corresponding to the pre-compiled header - -#include "pch.h" - -// When you are using pre-compiled headers, this source file is necessary for compilation to succeed. diff --git a/C++CLI/Converter/pch.h b/C++CLI/Converter/pch.h deleted file mode 100644 index 885d5d6..0000000 --- a/C++CLI/Converter/pch.h +++ /dev/null @@ -1,13 +0,0 @@ -// pch.h: This is a precompiled header file. -// Files listed below are compiled only once, improving build performance for future builds. -// This also affects IntelliSense performance, including code completion and many code browsing features. -// However, files listed here are ALL re-compiled if any one of them is updated between builds. -// Do not add files here that you will be updating frequently as this negates the performance advantage. - -#ifndef PCH_H -#define PCH_H - -// add headers that you want to pre-compile here -#include "framework.h" - -#endif //PCH_H diff --git a/C++CLI/Converter/penmp b/C++CLI/Converter/penmp deleted file mode 100644 index e69de29..0000000 diff --git a/C++CLI/Examples/H264SharpCLIdotNET/Converter32.dll b/C++CLI/Examples/H264SharpCLIdotNET/Converter32.dll deleted file mode 100644 index 31ecb7c..0000000 Binary files a/C++CLI/Examples/H264SharpCLIdotNET/Converter32.dll and /dev/null differ diff --git a/C++CLI/Examples/H264SharpCLIdotNET/Converter64.dll b/C++CLI/Examples/H264SharpCLIdotNET/Converter64.dll deleted file mode 100644 index 1584dba..0000000 Binary files a/C++CLI/Examples/H264SharpCLIdotNET/Converter64.dll and /dev/null differ diff --git a/C++CLI/Examples/H264SharpCLIdotNET/H264SharpCLI.NET-Test.csproj b/C++CLI/Examples/H264SharpCLIdotNET/H264SharpCLI.NET-Test.csproj deleted file mode 100644 index bb5fbf9..0000000 --- a/C++CLI/Examples/H264SharpCLIdotNET/H264SharpCLI.NET-Test.csproj +++ /dev/null @@ -1,36 +0,0 @@ - - - - Exe - net6.0 - enable - enable - - - - - - - - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - diff --git a/C++CLI/Examples/H264SharpCLIdotNET/Program.cs b/C++CLI/Examples/H264SharpCLIdotNET/Program.cs deleted file mode 100644 index 5578a51..0000000 --- a/C++CLI/Examples/H264SharpCLIdotNET/Program.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Drawing; -using System.Diagnostics; -using System.Threading; -using System.Drawing.Imaging; -using H264Sharp; - -namespace EncoderTest -{ - internal class Program - { - static H264Sharp.Encoder encoder; - static H264Sharp.Decoder decoder; - static void Main(string[] args) - { - decoder = new H264Sharp.Decoder(); - encoder = new H264Sharp.Encoder(); - - var img = System.Drawing.Image.FromFile("ocean.jpg"); - int w = img.Width; - int h = img.Height; - var bmp = new Bitmap(img); - - Console.WriteLine($"Image Loaded with Width{w}, Height:{h}"); - - encoder.Initialize(w, h, bps: 200_000_000, fps: 30, H264Sharp.Encoder.ConfigType.CameraBasic); - - // Emulating video frames - Stopwatch sw = Stopwatch.StartNew(); - for (int i = 0; i < 100; i++) - { - if (encoder.Encode(bmp, out EncodedFrame[] frames)) - { - foreach (var frame in frames) - { - //frame.CopyTo(bb,0); - - if (decoder.Decode(frame.Data, frame.Length, noDelay: true, out DecodingState ds, out Bitmap b)) - { - b.Dispose(); - // bmp.Save("t.bmp"); - } - } - - } - } - Console.WriteLine("\n Time: " + sw.ElapsedMilliseconds); - - Console.ReadLine(); - } - - - } -} diff --git a/C++CLI/Examples/H264SharpCLIdotNET/ocean.jpg b/C++CLI/Examples/H264SharpCLIdotNET/ocean.jpg deleted file mode 100644 index 04b3932..0000000 Binary files a/C++CLI/Examples/H264SharpCLIdotNET/ocean.jpg and /dev/null differ diff --git a/C++CLI/Examples/H264SharpCLIdotNET/openh264-2.3.1-win32.dll b/C++CLI/Examples/H264SharpCLIdotNET/openh264-2.3.1-win32.dll deleted file mode 100644 index 89604e8..0000000 Binary files a/C++CLI/Examples/H264SharpCLIdotNET/openh264-2.3.1-win32.dll and /dev/null differ diff --git a/C++CLI/Examples/H264SharpCLIdotNET/openh264-2.3.1-win64.dll b/C++CLI/Examples/H264SharpCLIdotNET/openh264-2.3.1-win64.dll deleted file mode 100644 index dd33080..0000000 Binary files a/C++CLI/Examples/H264SharpCLIdotNET/openh264-2.3.1-win64.dll and /dev/null differ diff --git a/C++CLI/Examples/H264SharpNetFramework/App.config b/C++CLI/Examples/H264SharpNetFramework/App.config deleted file mode 100644 index 56efbc7..0000000 --- a/C++CLI/Examples/H264SharpNetFramework/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/C++CLI/Examples/H264SharpNetFramework/Converter32.dll b/C++CLI/Examples/H264SharpNetFramework/Converter32.dll deleted file mode 100644 index 31ecb7c..0000000 Binary files a/C++CLI/Examples/H264SharpNetFramework/Converter32.dll and /dev/null differ diff --git a/C++CLI/Examples/H264SharpNetFramework/Converter64.dll b/C++CLI/Examples/H264SharpNetFramework/Converter64.dll deleted file mode 100644 index 1584dba..0000000 Binary files a/C++CLI/Examples/H264SharpNetFramework/Converter64.dll and /dev/null differ diff --git a/C++CLI/Examples/H264SharpNetFramework/H264Sharp64.dll b/C++CLI/Examples/H264SharpNetFramework/H264Sharp64.dll deleted file mode 100644 index 8c8574a..0000000 Binary files a/C++CLI/Examples/H264SharpNetFramework/H264Sharp64.dll and /dev/null differ diff --git a/C++CLI/Examples/H264SharpNetFramework/H264SharpCLI.NetFramework-Test.csproj b/C++CLI/Examples/H264SharpNetFramework/H264SharpCLI.NetFramework-Test.csproj deleted file mode 100644 index 16973d2..0000000 --- a/C++CLI/Examples/H264SharpNetFramework/H264SharpCLI.NetFramework-Test.csproj +++ /dev/null @@ -1,101 +0,0 @@ - - - - - Debug - AnyCPU - {EFEF9D91-ED87-4784-8FCA-76508FF91B66} - Exe - H264SharpNetFramework - H264SharpNetFramework - v4.7.2 - 512 - true - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - 7.3 - prompt - true - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - 7.3 - prompt - true - - - - False - ..\..\x64\Release\H264Sharp64.dll - - - - - - - - - - - - - - - - - - .editorconfig - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - \ No newline at end of file diff --git a/C++CLI/Examples/H264SharpNetFramework/Program.cs b/C++CLI/Examples/H264SharpNetFramework/Program.cs deleted file mode 100644 index 681cb69..0000000 --- a/C++CLI/Examples/H264SharpNetFramework/Program.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Drawing; -using System.Diagnostics; -using System.Threading; -using System.Drawing.Imaging; -using H264Sharp; - -namespace EncoderTest -{ - internal class Program - { - static H264Sharp.Encoder encoder; - static H264Sharp.Decoder decoder; - static void Main(string[] args) - { - decoder = new H264Sharp.Decoder(); - encoder = new H264Sharp.Encoder(); - - var img = System.Drawing.Image.FromFile("ocean.jpg"); - int w = img.Width; - int h = img.Height; - var bmp = new Bitmap(img); - - Console.WriteLine($"Image Loaded with Width{w}, Height:{h}"); - - encoder.Initialize(w, h, bps: 200_000_000, fps: 30, H264Sharp.Encoder.ConfigType.CameraBasic); - - // Emulating video frames - Stopwatch sw = Stopwatch.StartNew(); - for (int i = 0; i < 100; i++) - { - if (encoder.Encode(bmp, out EncodedFrame[] frames)) - { - foreach (var frame in frames) - { - //frame.CopyTo(bb,0); - - if (decoder.Decode(frame.Data, frame.Length, noDelay: true, out DecodingState ds, out Bitmap b)) - { - b.Dispose(); - // bmp.Save("t.bmp"); - } - } - - } - } - Console.WriteLine("\n Time: " + sw.ElapsedMilliseconds); - - Console.ReadLine(); - } - - - } -} diff --git a/C++CLI/Examples/H264SharpNetFramework/Properties/AssemblyInfo.cs b/C++CLI/Examples/H264SharpNetFramework/Properties/AssemblyInfo.cs deleted file mode 100644 index 995c665..0000000 --- a/C++CLI/Examples/H264SharpNetFramework/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("H264SharpNetFramework")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("H264SharpNetFramework")] -[assembly: AssemblyCopyright("Copyright © 2024")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("efef9d91-ed87-4784-8fca-76508ff91b66")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/C++CLI/Examples/H264SharpNetFramework/ocean.jpg b/C++CLI/Examples/H264SharpNetFramework/ocean.jpg deleted file mode 100644 index 04b3932..0000000 Binary files a/C++CLI/Examples/H264SharpNetFramework/ocean.jpg and /dev/null differ diff --git a/C++CLI/Examples/H264SharpNetFramework/openh264-2.3.1-win32.dll b/C++CLI/Examples/H264SharpNetFramework/openh264-2.3.1-win32.dll deleted file mode 100644 index 89604e8..0000000 Binary files a/C++CLI/Examples/H264SharpNetFramework/openh264-2.3.1-win32.dll and /dev/null differ diff --git a/C++CLI/Examples/H264SharpNetFramework/openh264-2.3.1-win64.dll b/C++CLI/Examples/H264SharpNetFramework/openh264-2.3.1-win64.dll deleted file mode 100644 index dd33080..0000000 Binary files a/C++CLI/Examples/H264SharpNetFramework/openh264-2.3.1-win64.dll and /dev/null differ diff --git a/C++CLI/H264SharpCLI/AssemblyInfo.cpp b/C++CLI/H264SharpCLI/AssemblyInfo.cpp deleted file mode 100644 index 34e5d3f..0000000 --- a/C++CLI/H264SharpCLI/AssemblyInfo.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "pch.h" - -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::CompilerServices; -using namespace System::Runtime::InteropServices; -using namespace System::Security::Permissions; - -[assembly:AssemblyTitleAttribute(L"OpenH264Wrapper2")]; -[assembly:AssemblyDescriptionAttribute(L"")]; -[assembly:AssemblyConfigurationAttribute(L"")]; -[assembly:AssemblyCompanyAttribute(L"")]; -[assembly:AssemblyProductAttribute(L"OpenH264Wrapper2")]; -[assembly:AssemblyCopyrightAttribute(L"Copyright (c) 2023")]; -[assembly:AssemblyTrademarkAttribute(L"")]; -[assembly:AssemblyCultureAttribute(L"")]; - -[assembly:AssemblyVersionAttribute(L"1.0.*")]; - -[assembly:ComVisible(false)]; diff --git a/C++CLI/H264SharpCLI/Converter.lib b/C++CLI/H264SharpCLI/Converter.lib deleted file mode 100644 index 35f7edb..0000000 Binary files a/C++CLI/H264SharpCLI/Converter.lib and /dev/null differ diff --git a/C++CLI/H264SharpCLI/ConverterLocal.cpp b/C++CLI/H264SharpCLI/ConverterLocal.cpp deleted file mode 100644 index d3327ea..0000000 --- a/C++CLI/H264SharpCLI/ConverterLocal.cpp +++ /dev/null @@ -1,333 +0,0 @@ -#include "pch.h" - -void BGRAtoYUV420Planar(unsigned char* bgra, unsigned char* dst, int width, int height, int stride) -{ - const int frameSize = width * height; - int yIndex = 0; - int vIndex = frameSize; - int uIndex = frameSize + (frameSize / 4); - int index = 0; - - const int hi = height / 2; - const int wi = width / 2; - const int nextLineStride = 2 * stride - (4 * width); - unsigned char* buffer = dst; - for (int j = 0; j < hi; ++j) - { - for (int i = 0; i < wi; ++i) - { - int b = bgra[index]; - int g = bgra[index + 1]; - int r = bgra[index + 2]; - - int b1 = bgra[index + 4]; - int g1 = bgra[index + 5]; - int r1 = bgra[index + 6]; - - int nextLineIdx = index + stride; - int b2 = bgra[nextLineIdx]; - int g2 = bgra[nextLineIdx + 1]; - int r2 = bgra[nextLineIdx + 2]; - - int b3 = bgra[nextLineIdx + 4]; - int g3 = bgra[nextLineIdx + 5]; - int r3 = bgra[nextLineIdx + 6]; - - int nextLineYIdx = yIndex + width; - - buffer[yIndex] = ((25 * b + 129 * g + 66 * r) >> 8) + 16; - buffer[yIndex + 1] = ((25 * b1 + 129 * g1 + 66 * r1) >> 8) + 16; - buffer[nextLineYIdx] = ((25 * b2 + 129 * g2 + 66 * r2) >> 8) + 16; - buffer[nextLineYIdx + 1] = ((25 * b3 + 129 * g3 + 66 * r3) >> 8) + 16; - - buffer[uIndex++] = ((112 * r + -94 * g + -18 * b) >> 8) + 128; - buffer[vIndex++] = ((-38 * r + -74 * g + 112 * b) >> 8) + 128; - yIndex += 2; - index += 8; - } - index += nextLineStride; - yIndex += width; - - } - -} - -void RGBAtoYUV420Planar(unsigned char* bgra, unsigned char* dst, int width, int height, int stride) -{ - const int frameSize = width * height; - int yIndex = 0; - int vIndex = frameSize; - int uIndex = frameSize + (frameSize / 4); - int index = 0; - - const int hi = height / 2; - const int wi = width / 2; - const int nextLineStride = 2 * stride - (4 * width); - unsigned char* buffer = dst; - for (int j = 0; j < hi; ++j) - { - for (int i = 0; i < wi; ++i) - { - int r = bgra[index]; - int g = bgra[index + 1]; - int b = bgra[index + 2]; - - int r1 = bgra[index + 4]; - int g1 = bgra[index + 5]; - int b1 = bgra[index + 6]; - - int nextLineIdx = index + stride; - int r2 = bgra[nextLineIdx]; - int g2 = bgra[nextLineIdx + 1]; - int b2 = bgra[nextLineIdx + 2]; - - int r3 = bgra[nextLineIdx + 4]; - int g3 = bgra[nextLineIdx + 5]; - int b3 = bgra[nextLineIdx + 6]; - - int nextLineYIdx = yIndex + width; - - buffer[yIndex] = ((25 * b + 129 * g + 66 * r) >> 8) + 16; - buffer[yIndex + 1] = ((25 * b1 + 129 * g1 + 66 * r1) >> 8) + 16; - buffer[nextLineYIdx] = ((25 * b2 + 129 * g2 + 66 * r2) >> 8) + 16; - buffer[nextLineYIdx + 1] = ((25 * b3 + 129 * g3 + 66 * r3) >> 8) + 16; - - buffer[uIndex++] = ((112 * r + -94 * g + -18 * b) >> 8) + 128; - buffer[vIndex++] = ((-38 * r + -74 * g + 112 * b) >> 8) + 128; - yIndex += 2; - index += 8; - } - index += nextLineStride; - yIndex += width; - - } - -} - -void BGRtoYUV420Planar(unsigned char* bgra, unsigned char* dst, int width, int height, int stride) -{ - const int frameSize = width * height; - int yIndex = 0; - int vIndex = frameSize; - int uIndex = frameSize + (frameSize / 4); - int index = 0; - - const int hi = height / 2; - const int wi = width / 2; - const int nextLineSttride = 2 * stride - (3 * width); - unsigned char* buffer = dst; - for (int j = 0; j < hi; ++j) - { - for (int i = 0; i < wi; ++i) - { - int b = bgra[index]; - int g = bgra[index + 1]; - int r = bgra[index + 2]; - - int b1 = bgra[index + 3]; - int g1 = bgra[index + 4]; - int r1 = bgra[index + 5]; - - int nextLineIdx = index + stride; - int b2 = bgra[nextLineIdx]; - int g2 = bgra[nextLineIdx + 1]; - int r2 = bgra[nextLineIdx + 2]; - - int b3 = bgra[nextLineIdx + 3]; - int g3 = bgra[nextLineIdx + 4]; - int r3 = bgra[nextLineIdx + 5]; - - int nextLineYIdx = yIndex + width; - - buffer[yIndex] = ((25 * b + 129 * g + 66 * r) >> 8) + 16; - buffer[yIndex + 1] = ((25 * b1 + 129 * g1 + 66 * r1) >> 8) + 16; - buffer[nextLineYIdx] = ((25 * b2 + 129 * g2 + 66 * r2) >> 8) + 16; - buffer[nextLineYIdx + 1] = ((25 * b3 + 129 * g3 + 66 * r3) >> 8) + 16; - - buffer[uIndex++] = ((112 * r + -94 * g + -18 * b) >> 8) + 128; - buffer[vIndex++] = ((-38 * r + -74 * g + 112 * b) >> 8) + 128; - yIndex += 2; - index += 6; - } - index += nextLineSttride; - yIndex += width; - - } - -} - -void RGBtoYUV420Planar(unsigned char* bgra, unsigned char* dst, int width, int height, int stride) -{ - const int frameSize = width * height; - int yIndex = 0; - int vIndex = frameSize; - int uIndex = frameSize + (frameSize / 4); - int index = 0; - - const int hi = height / 2; - const int wi = width / 2; - const int nextLineSttride = 2 * stride - (3 * width); - unsigned char* buffer = dst; - for (int j = 0; j < hi; ++j) - { - for (int i = 0; i < wi; ++i) - { - int r = bgra[index]; - int g = bgra[index + 1]; - int b = bgra[index + 2]; - - int r1 = bgra[index + 3]; - int g1 = bgra[index + 4]; - int b1 = bgra[index + 5]; - - int nextLineIdx = index + stride; - int r2 = bgra[nextLineIdx]; - int g2 = bgra[nextLineIdx + 1]; - int b2 = bgra[nextLineIdx + 2]; - - int r3 = bgra[nextLineIdx + 3]; - int g3 = bgra[nextLineIdx + 4]; - int b3 = bgra[nextLineIdx + 5]; - - int nextLineYIdx = yIndex + width; - - buffer[yIndex] = ((25 * b + 129 * g + 66 * r) >> 8) + 16; - buffer[yIndex + 1] = ((25 * b1 + 129 * g1 + 66 * r1) >> 8) + 16; - buffer[nextLineYIdx] = ((25 * b2 + 129 * g2 + 66 * r2) >> 8) + 16; - buffer[nextLineYIdx + 1] = ((25 * b3 + 129 * g3 + 66 * r3) >> 8) + 16; - - buffer[uIndex++] = ((112 * r + -94 * g + -18 * b) >> 8) + 128; - buffer[vIndex++] = ((-38 * r + -74 * g + 112 * b) >> 8) + 128; - yIndex += 2; - index += 6; - } - index += nextLineSttride; - yIndex += width; - - } - -} - -enum -{ - FLAGS = 0x40080100 -}; - -#define READUV(U,V) (yuv2rgb565_table1[256 + (U)] + yuv2rgb565_table1[512 + (V)]) -#define READY(Y) yuv2rgb565_table1[Y] -#define FIXUP(Y) \ -do { \ - int tmp = (Y) & FLAGS; \ - if (tmp != 0) \ - { \ - tmp -= tmp>>8; \ - (Y) |= tmp; \ - tmp = FLAGS & ~(Y>>1); \ - (Y) += tmp>>8; \ - } \ -} while (0 == 1) - -#define STORE(Y,DSTPTR) \ -do { \ - unsigned int Y2 = (Y); \ - unsigned char *DSTPTR2 = (DSTPTR); \ - (DSTPTR2)[0] = (Y2); \ - (DSTPTR2)[1] = (Y2)>>22; \ - (DSTPTR2)[2] = (Y2)>>11; \ -} while (0 == 1) - -void Yuv420P2Rgb(unsigned char* dst_ptr, - const unsigned char* y_ptr, - const unsigned char* u_ptr, - const unsigned char* v_ptr, - signed int width, - signed int height, - signed int y_span, - signed int uv_span, - signed int dst_span, - - signed int dither) -{ - height -= 1; - while (height > 0) - { - height -= width << 16; - height += 1 << 16; - while (height < 0) - { - /* Do 2 column pairs */ - unsigned int uv, y0, y1; - - uv = READUV(*u_ptr++, *v_ptr++); - y1 = uv + READY(y_ptr[y_span]); - y0 = uv + READY(*y_ptr++); - FIXUP(y1); - FIXUP(y0); - STORE(y1, &dst_ptr[dst_span]); - STORE(y0, dst_ptr); - dst_ptr += 3; - y1 = uv + READY(y_ptr[y_span]); - y0 = uv + READY(*y_ptr++); - FIXUP(y1); - FIXUP(y0); - STORE(y1, &dst_ptr[dst_span]); - STORE(y0, dst_ptr); - dst_ptr += 3; - height += (2 << 16); - } - if ((height >> 16) == 0) - { - /* Trailing column pair */ - unsigned int uv, y0, y1; - - uv = READUV(*u_ptr, *v_ptr); - y1 = uv + READY(y_ptr[y_span]); - y0 = uv + READY(*y_ptr++); - FIXUP(y1); - FIXUP(y0); - STORE(y0, &dst_ptr[dst_span]); - STORE(y1, dst_ptr); - dst_ptr += 3; - } - dst_ptr += dst_span * 2 - width * 3; - y_ptr += y_span * 2 - width; - u_ptr += uv_span - (width >> 1); - v_ptr += uv_span - (width >> 1); - height = (height << 16) >> 16; - height -= 2; - } - if (height == 0) - { - /* Trail row */ - height -= width << 16; - height += 1 << 16; - while (height < 0) - { - /* Do a row pair */ - unsigned int uv, y0, y1; - - uv = READUV(*u_ptr++, *v_ptr++); - y1 = uv + READY(*y_ptr++); - y0 = uv + READY(*y_ptr++); - FIXUP(y1); - FIXUP(y0); - STORE(y1, dst_ptr); - dst_ptr += 3; - STORE(y0, dst_ptr); - dst_ptr += 3; - height += (2 << 16); - } - if ((height >> 16) == 0) - { - /* Trailing pix */ - unsigned int uv, y0; - - uv = READUV(*u_ptr++, *v_ptr++); - y0 = uv + READY(*y_ptr++); - FIXUP(y0); - STORE(y0, dst_ptr); - dst_ptr += 3; - } - } - -}; \ No newline at end of file diff --git a/C++CLI/H264SharpCLI/ConverterLocal.h b/C++CLI/H264SharpCLI/ConverterLocal.h deleted file mode 100644 index 3fe7e16..0000000 --- a/C++CLI/H264SharpCLI/ConverterLocal.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include"pch.h" - - void BGRAtoYUV420Planar(unsigned char* rgba, unsigned char* dst, int width, int height, int stride); - void BGRtoYUV420Planar(unsigned char* rgba, unsigned char* dst, int width, int height, int stride); - void RGBAtoYUV420Planar(unsigned char* rgba, unsigned char* dst, int width, int height, int stride); - void RGBtoYUV420Planar(unsigned char* rgb, unsigned char* dst, int width, int height, int stride); - void Yuv420P2Rgb(unsigned char* dst_ptr, - const unsigned char* y_ptr, - const unsigned char* u_ptr, - const unsigned char* v_ptr, - signed int width, - signed int height, - signed int y_span, - signed int uv_span, - signed int dst_span, - signed int dither); - diff --git a/C++CLI/H264SharpCLI/Decoder.cpp b/C++CLI/H264SharpCLI/Decoder.cpp deleted file mode 100644 index db0dfd5..0000000 --- a/C++CLI/H264SharpCLI/Decoder.cpp +++ /dev/null @@ -1,311 +0,0 @@ -#include "pch.h" -#include // PtrToStringChars -#include -#include -#using -#include "Decoder.h" - -using namespace System::Drawing; -using namespace System::Drawing::Imaging; -using namespace System::Runtime::InteropServices; - -namespace H264Sharp { - - - Decoder::Decoder() - { - const wchar_t* dllName = is64Bit() ? L"openh264-2.3.1-win64.dll" : L"openh264-2.3.1-win32.dll"; - Create(dllName); - } - Decoder::Decoder(String^ dllName) - { - pin_ptr dllname = PtrToStringChars(dllName); - Create(dllname); - } - void Decoder::Create(const wchar_t* dllname) - { - // Try to load converter library, if cant find we use the C++/ClI version. - const wchar_t* converterDll = is64Bit() ? L"Converter64.dll" : L"Converter32.dll"; - HMODULE lib = NULL; - const DWORD Avx2 = 40; - if (!IsProcessorFeaturePresent(Avx2)) - { - std::cout << "Unable to use ConverterDLL because AVX2 instructions are not supported! Falling back to CLI convertors" << std::endl; - } - else - { - lib = LoadLibrary(converterDll); - - } - - if (lib != NULL) - { - Bgra2Yuv420 = (Yuv2Rgb)GetProcAddress(lib, "Yuv420P2RGB_"); - if (Bgra2Yuv420 == NULL) - throw gcnew System::DllNotFoundException(String::Format("{0}", GetLastError())); - } - else { - auto ss = is64Bit() ? "Converter64.dll" : "Converter32.dll"; - std::cout << "Decoder: Unable to load " << ss << ", make sure to include it on your executable path. Falling back to CLI convertors" << std::endl; - Bgra2Yuv420 = (Yuv2Rgb)Yuv420P2Rgb; - } - - innerBuffer = 0; - // Load Open h264 dll. We need to load create and destroy methods. - //pin_ptr dllname = PtrToStringChars(dllName); - HMODULE hDll = LoadLibrary(dllname); - if (hDll == NULL) { - bool _64 = is64Bit(); - auto err = GetLastError(); - throw gcnew System::DllNotFoundException(String::Format("Unable to load '{0}, ErrorCode: {1}'", (_64 ? "openh264-2.3.1-win64.dll" : "openh264-2.3.1-win64.dll"), err)); - } - dllname = nullptr; - - CreateDecoderFunc = (WelsCreateDecoderFunc)GetProcAddress(hDll, "WelsCreateDecoder"); - if (CreateDecoderFunc == NULL) - { - auto err = GetLastError(); - throw gcnew System::DllNotFoundException(String::Format("Unable to load WelsCreateDecoder func, error code: {1}", err)); - } - - DestroyDecoderFunc = (WelsDestroyDecoderFunc)GetProcAddress(hDll, "WelsDestroyDecoder"); - if (DestroyDecoderFunc == NULL) throw gcnew System::DllNotFoundException(String::Format("Unable to load WelsDestroyDecoder func in '{0}'")); - - ISVCDecoder* dec = nullptr; - int rc = CreateDecoderFunc(&dec); - decoder = dec; - if (rc != 0) throw gcnew System::DllNotFoundException(String::Format("Unable to call WelsCreateSVCDecoder func in '{0}'")); - - rc = Initialize(); - if (rc != 0) throw gcnew System::InvalidOperationException("Error occurred during initializing decoder."); - - - } - - int Decoder::Initialize() - { - SDecodingParam decParam; - memset(&decParam, 0, sizeof(SDecodingParam)); - decParam.uiTargetDqLayer = UCHAR_MAX; - decParam.eEcActiveIdc = ERROR_CON_SLICE_COPY; - decParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_SVC; - int rc = decoder->Initialize(&decParam); - if (rc != 0) return -1; - - return 0; - } - - bool Decoder::Decode(array^ frame, int startIdx, int length, bool noDelay, [Out]DecodingState% rc, [Out]H264Sharp::Yuv420p^% yuv) - { - pin_ptr p = &frame[startIdx]; - unsigned char* pby = p; - return Decode(pby, length, noDelay, rc, yuv); - } - - bool Decoder::Decode(array^ frame, int startIdx, int length, bool noDelay, [Out]DecodingState% rc, [Out]H264Sharp::RgbImage^% rgb) - { - pin_ptr p = &frame[startIdx]; - unsigned char* pby = p; - return Decode(pby, length, noDelay, rc, rgb); - } - - bool Decoder::Decode(array^ frame, int startIdx, int length, bool noDelay, [Out]DecodingState% rc,[Out]Bitmap^% bmp) - { - pin_ptr p = &frame[startIdx]; - unsigned char* pby = p; - return Decode(pby, length, noDelay, rc, bmp); - } - bool Decoder::Decode(IntPtr frame, int length, bool noDelay, [Out]DecodingState% rc, [Out]H264Sharp::Yuv420p^% yuv) - { - void* ptr = frame.ToPointer(); - unsigned char* p = reinterpret_cast(ptr); - return Decode(p, length, noDelay, rc, yuv); - } - bool Decoder::Decode(IntPtr frame, int length, bool noDelay, [Out]DecodingState% rc, [Out]Bitmap^% bmp) - { - void* ptr = frame.ToPointer(); - unsigned char* p = reinterpret_cast(ptr); - return Decode(p, length, noDelay, rc, bmp); - } - bool Decoder::Decode(IntPtr frame, int length, bool noDelay, [Out]DecodingState% rc, [Out]H264Sharp::RgbImage^% rgb) - { - void* ptr = frame.ToPointer(); - unsigned char* p = reinterpret_cast(ptr); - return Decode(p, length, noDelay, rc, rgb); - } - - bool Decoder::Decode(unsigned char* frame, int length, bool noDelay, [Out]DecodingState% rc, [Out]H264Sharp::Yuv420p^% yuv) - { - DecodingState statusCode; - bool success; - YuvNative res = DecodeInternal(frame, length, noDelay, statusCode, success); - if (success) - { - yuv = gcnew Yuv420p(res.Y, res.U, res.V,res.width, res.height, res.stride, res.stride2, res.stride2); - } - rc = statusCode; - return success; - } - - long avg = 0; - bool Decoder::Decode(unsigned char* frame, int length, bool noDelay, [Out]DecodingState% rc, [Out]H264Sharp::RgbImage^% rgb) - { - DecodingState statusCode; - bool success; - YuvNative res = DecodeInternal(frame, length, noDelay, statusCode, success); - if(success) - { - byte* rgbBytes = YUV420PtoRGB(res.Y, res.U, res.V, res.width, res.height, res.stride,res.stride2); - rgb = gcnew RgbImage(rgbBytes, res.width, res.height, res.width*3); - - } - rc = statusCode; - return success; - } - - bool Decoder::Decode(unsigned char* frame, int length, bool noDelay, [Out]DecodingState% rc, [Out]Bitmap^% bmp) - { - DecodingState statusCode; - bool success; - YuvNative res = DecodeInternal(frame, length, noDelay, statusCode, success); - if (success) - { - byte* rgb = YUV420PtoRGB(res.Y, res.U, res.V, res.width, res.height, res.stride,res.stride2); - bmp = RGBtoBitmap(rgb, res.width, res.height); - } - rc = statusCode; - return success; - } - inline bool HasFlag(int value, int flag) - { - return (value & (int)flag) == (int)flag; - } - YuvNative Decoder::DecodeInternal(unsigned char* frame, int length, bool noDelay, DecodingState& rcc, bool& succes) - { - succes = false; - YuvNative yuv; - - unsigned char* buffer[3]; - - SBufferInfo bufInfo; memset(&bufInfo, 0x00, sizeof(bufInfo)); - int rc = -1; - - if (noDelay) - rc = decoder->DecodeFrameNoDelay(frame, length, buffer, &bufInfo); - else - rc = decoder->DecodeFrame2(frame, length, buffer, &bufInfo); - - rcc = (DecodingState)rc; - //if (rc!=0 ) return yuv; - - //if (HasFlag(rc, dsRefLost) ) return yuv; - if (bufInfo.iBufferStatus != 1) return yuv; - - memset(&yuv, 0x00, sizeof(yuv)); - - yuv.width = bufInfo.UsrData.sSystemBuffer.iWidth; - yuv.height = bufInfo.UsrData.sSystemBuffer.iHeight; - yuv.stride = bufInfo.UsrData.sSystemBuffer.iStride[0]; - yuv.Y = bufInfo.pDst[0]; - yuv.U = bufInfo.pDst[1]; - yuv.V = bufInfo.pDst[2]; - yuv.stride2 = bufInfo.UsrData.sSystemBuffer.iStride[1]; - succes = true; - return yuv; - } - - Decoder::~Decoder() - { - this->!Decoder(); - } - - - Decoder::!Decoder() - { - delete innerBuffer; - decoder->Uninitialize(); - DestroyDecoderFunc(decoder); - } - - byte* Decoder::YUV420PtoRGB(byte* yplane, byte* uplane, byte* vplane, int width, int height, int stride,int stride2) - { - - // Caching the decode buffer. - if (innerBufLen ==0 || innerBufLen != width * height * 3) - { - delete innerBuffer; - innerBuffer = new byte[width * height * 3]; - innerBufLen = width * height * 3; - } - //auto t_start = std::chrono::high_resolution_clock::now(); - - Bgra2Yuv420(innerBuffer, yplane, uplane, vplane, width, height, stride, stride2, width * 3, 0); - - /*auto t_end = std::chrono::high_resolution_clock::now(); - double elapsed_time_ms = std::chrono::duration(t_end - t_start).count(); - std::cout << elapsed_time_ms << std::endl;*/ - return innerBuffer; - - //byte* rgbBytes = innerBuffer; - //byte* result =(byte*)innerBuffer; - //byte* rgb = result; - //// - //for (int y = 0; y < height; y++) - //{ - // int rowIdx = (stride * y); - // int uvpIdx = (stride / 2) * (y / 2); - - // byte* pYp = yplane + rowIdx; - // byte* pUp = uplane + uvpIdx; - // byte* pVp = vplane + uvpIdx; - - // for (int x = 0; x < width; x += 2) - // { - // int C1 = ((pYp[0] - 16) * 298) + 128; - // int C2 = ((pYp[1] - 16) * 298) + 128; - - // const int D = *pUp - 128; - // int D1 = (D) * 100; - // int D5 = (D) * 516; - - // const int E = *pVp - 128; - // int E4 = (E) * 409; - // int E2 = (E) * 208; - // int DE = -D1 - E2; - // //-- - - // int R1 = (C1 + E4 ) >> 8; - // int G1 = (C1 + DE ) >> 8; - // int B1 = (C1 + D5 ) >> 8; - - // int R2 = (C2 + E4 ) >> 8; - // int G2 = (C2 + DE ) >> 8; - // int B2 = (C2 + D5 ) >> 8; - - // rgb[0] = (byte)(B1 < 0 ? 0 : B1 > 255 ? 255 : B1); - // rgb[1] = (byte)(G1 < 0 ? 0 : G1 > 255 ? 255 : G1); - // rgb[2] = (byte)(R1 < 0 ? 0 : R1 > 255 ? 255 : R1); - - // rgb[3] = (byte)(B2 < 0 ? 0 : B2 > 255 ? 255 : B2); - // rgb[4] = (byte)(G2 < 0 ? 0 : G2 > 255 ? 255 : G2); - // rgb[5] = (byte)(R2 < 0 ? 0 : R2 > 255 ? 255 : R2); - - // rgb += 6; - // pYp += 2; - // pUp += 1; - // pVp += 1; - // } - // - //} - // - - //return result; - } - - Bitmap^ Decoder::RGBtoBitmap(byte* rgb, int width, int height) - { - Bitmap^ bmp = gcnew Bitmap(width, height, width * 3 , System::Drawing::Imaging::PixelFormat::Format24bppRgb, System::IntPtr(rgb)); - return bmp; - - } -} diff --git a/C++CLI/H264SharpCLI/Decoder.h b/C++CLI/H264SharpCLI/Decoder.h deleted file mode 100644 index 2986552..0000000 --- a/C++CLI/H264SharpCLI/Decoder.h +++ /dev/null @@ -1,84 +0,0 @@ -#pragma once -#include "pch.h" -#using - -using namespace System; - -namespace H264Sharp -{ - public enum class DecodingState { - /** - * Errors derived from bitstream parsing - */ - dsErrorFree = 0x00, ///< bit stream error-free - dsFramePending = 0x01, ///< need more throughput to generate a frame output, - dsRefLost = 0x02, ///< layer lost at reference frame with temporal id 0 - dsBitstreamError = 0x04, ///< error bitstreams(maybe broken internal frame) the decoder cared - dsDepLayerLost = 0x08, ///< dependented layer is ever lost - dsNoParamSets = 0x10, ///< no parameter set NALs involved - dsDataErrorConcealed = 0x20, ///< current data error concealed specified - dsRefListNullPtrs = 0x40, ///^ frame, int startIdx, int length, bool noDelay, DecodingState% rc, H264Sharp::Yuv420p^% yuv); - bool Decode(array^ frame, int startIdx, int length, bool noDelay, DecodingState% rc, H264Sharp::RgbImage^% rgb); - bool Decode(array^frame, int startIdx, int length, bool noDelay, DecodingState% rc, System::Drawing::Bitmap^% bitmap); - - private: - unsigned char* innerBuffer = nullptr; - int innerBufLen = 0; - ISVCDecoder* decoder = nullptr; - - typedef int(__cdecl* WelsCreateDecoderFunc)(ISVCDecoder** ppDecoder); - WelsCreateDecoderFunc CreateDecoderFunc; - typedef void(__cdecl* WelsDestroyDecoderFunc)(ISVCDecoder* ppDecoder); - WelsDestroyDecoderFunc DestroyDecoderFunc; - - void Create(const wchar_t* dllName); - int Initialize(); - - YuvNative Decoder::DecodeInternal(unsigned char* frame, int length, bool noDelay, DecodingState& rc, bool& success); - byte* YUV420PtoRGB(byte* yplane, byte* uplane, byte* vplane, int width, int height, int stride, int stride2); - static System::Drawing::Bitmap^ RGBtoBitmap(byte* rgb, int width, int height); - - ~Decoder(); - !Decoder(); - - }; -} diff --git a/C++CLI/H264SharpCLI/EncodedFrame.h b/C++CLI/H264SharpCLI/EncodedFrame.h deleted file mode 100644 index 47451aa..0000000 --- a/C++CLI/H264SharpCLI/EncodedFrame.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include "pch.h" -namespace H264Sharp { - - public ref class EncodedFrame - { - public: - unsigned char* Data; - IntPtr DataPointer; - int Length; - int LayerNum; - FrameType Type; - EncodedFrame(unsigned char* data, int lenght,int layerNum, FrameType frameType); - array^ ToByteArray(); - void CopyTo(array^ destination, int startIndex); - }; - -} - - diff --git a/C++CLI/H264SharpCLI/Encoder.cpp b/C++CLI/H264SharpCLI/Encoder.cpp deleted file mode 100644 index 9f9ba1d..0000000 --- a/C++CLI/H264SharpCLI/Encoder.cpp +++ /dev/null @@ -1,436 +0,0 @@ -#include "pch.h" -#include -#using -#include -#include -#include "Encoder.h" - -using namespace System::Drawing; -using namespace System::Drawing::Imaging; -using namespace System::Runtime::InteropServices; - -namespace H264Sharp { - -#pragma region Setup - - Encoder::Encoder() - { - const wchar_t* dllName = is64Bit() ? L"openh264-2.3.1-win64.dll" : L"openh264-2.3.1-win32.dll"; - Create(dllName); - } - Encoder::Encoder(String^ dllName) - { - pin_ptr dllname = PtrToStringChars(dllName); - Create(dllname); - } - void Encoder::Create(const wchar_t* dllname) - { - const wchar_t* converterDll = is64Bit() ? L"Converter64.dll" : L"Converter32.dll"; - const DWORD Avx2 = 40; - HMODULE lib = NULL; - if (!IsProcessorFeaturePresent(Avx2)) - { - std::cout << "Unable to use ConverterDLL because AVX2 instructions are not supported! Falling back to CLI convertors" << std::endl; - } - else - { - lib = LoadLibrary(converterDll); - } - if (lib != NULL) - { - Bgra2Yuv420 = (Covert2Yuv420)GetProcAddress(lib, "BGRAtoYUV420Planar_"); - if (Bgra2Yuv420 == NULL) - throw gcnew System::DllNotFoundException(String::Format("{0}", GetLastError())); - - Bgr2Yuv420 = (Covert2Yuv420)GetProcAddress(lib, "BGRtoYUV420Planar_"); - if (Bgr2Yuv420 == NULL) - throw gcnew System::DllNotFoundException(String::Format("{0}", GetLastError())); - - Rgb2Yuv420 = (Covert2Yuv420)GetProcAddress(lib, "RGBtoYUV420Planar_"); - if (Rgb2Yuv420 == NULL) - throw gcnew System::DllNotFoundException(String::Format("{0}", GetLastError())); - - Rgba2Yuv420 = (Covert2Yuv420)GetProcAddress(lib, "RGBAtoYUV420Planar_"); - if (Rgba2Yuv420 == NULL) - throw gcnew System::DllNotFoundException(String::Format("{0}", GetLastError())); - } - else { - auto ss = is64Bit() ? "Converter64.dll" : "Converter32.dll"; - std::cout << "Encoder: Unable to load " << ss << ", make sure to include it on your executable path. Falling back to CLI convertors" << std::endl; - Bgra2Yuv420 = BGRAtoYUV420Planar; - Bgr2Yuv420 = BGRtoYUV420Planar; - Rgba2Yuv420 = RGBtoYUV420Planar; - Rgba2Yuv420 = RGBtoYUV420Planar; - } - - - // Load Open h264 DLL - HMODULE hDll = LoadLibrary(dllname); - if (hDll == NULL) - { - auto err = GetLastError(); - bool _64 = is64Bit(); - - throw gcnew System::DllNotFoundException(String::Format("Unable to load '{0}' Code: {1}", _64 ? "openh264-2.3.1-win64.dll" : "openh264-2.3.1-win64.dll", err)); - } - dllname = nullptr; - - // Load Function - CreateEncoderFunc = (WelsCreateSVCEncoder)GetProcAddress(hDll, "WelsCreateSVCEncoder"); - if (CreateEncoderFunc == NULL) - { - auto err = GetLastError(); - throw gcnew System::DllNotFoundException(String::Format("Unable to load WelsCreateSVCEncoder func in WelsCreateSVCEncoderFunc Code: {0}'", err)); - } - DestroyEncoderFunc = (WelsDestroySVCEncoder)GetProcAddress(hDll, "WelsDestroySVCEncoder"); - if (DestroyEncoderFunc == NULL) - { - auto err = GetLastError(); - throw gcnew System::DllNotFoundException(String::Format("Unable to load WelsDestroySVCEncoder func in 'WelsDestroySVCEncoderFunc' Code{0}", err)); - } - - - ISVCEncoder* enc = nullptr; - int rc = CreateEncoderFunc(&enc); - encoder = enc; - if (rc != 0) throw gcnew System::DllNotFoundException(String::Format("Unable to call WelsCreateSVCEncoder func in '{0}'")); - - } - - int Encoder::Initialize(int width, int height, int bps, float fps, ConfigType configNo) - { - return InitializeInternal(width, height, bps, fps, configNo); - }; - - int Encoder::InitializeInternal(int width, int height, int bps, float fps, ConfigType configType) - { - int rc = 0; - SEncParamBase base; - memset(&base, 0, sizeof(SEncParamBase)); - int videoFormat = 0; - SliceModeEnum sliceMode = SM_FIXEDSLCNUM_SLICE; - SEncParamExt param; - SSpatialLayerConfig* spatial_config = nullptr; - memset(¶m, 0, sizeof(SEncParamExt)); - switch (configType) - { - case ConfigType::CameraBasic: - - base.iPicWidth = width; - base.iPicHeight = height; - base.fMaxFrameRate = fps; - base.iUsageType = CAMERA_VIDEO_REAL_TIME; - base.iTargetBitrate = bps; - base.iRCMode = RC_BITRATE_MODE; - rc = encoder->Initialize(&base); - break; - - case ConfigType::ScreenCaptureBasic: - - base.iPicWidth = width; - base.iPicHeight = height; - base.fMaxFrameRate = fps; - base.iUsageType = SCREEN_CONTENT_REAL_TIME; - base.iTargetBitrate = bps; - base.iRCMode = RC_BITRATE_MODE; - rc = encoder->Initialize(&base); - break; - - case ConfigType::CameraCaptureAdvanced: - - encoder->GetDefaultParams(¶m); - param.iUsageType = CAMERA_VIDEO_REAL_TIME; - param.iRCMode = RC_BITRATE_MODE; - param.iComplexityMode = LOW_COMPLEXITY; - param.iMinQp = 1; - param.iMaxQp = 51; - param.bEnableFrameSkip = false; - param.bPrefixNalAddingCtrl = true; - param.bIsLosslessLink = false; - param.bEnableLongTermReference = true; - param.uiMaxNalSize = 1500; - - spatial_config = ¶m.sSpatialLayers[0]; - spatial_config->uiProfileIdc = PRO_BASELINE; - param.iPicWidth = spatial_config->iVideoWidth = width; - param.iPicHeight = spatial_config->iVideoHeight = height; - param.fMaxFrameRate = spatial_config->fFrameRate = fps; - param.iTargetBitrate = spatial_config->iSpatialBitrate = bps; - param.iMaxBitrate = spatial_config->iMaxSpatialBitrate = bps; - spatial_config->sSliceArgument.uiSliceMode = SM_FIXEDSLCNUM_SLICE; - spatial_config->sSliceArgument.uiSliceNum = 0; - - param.iMultipleThreadIdc = 2; - - param.iNumRefFrame = -1; - param.uiIntraPeriod = -1; // 12 - FFMPEG - param.iLTRRefNum = 0; - param.iLtrMarkPeriod = 30; - rc = encoder->InitializeExt(¶m); - videoFormat = videoFormatI420; - rc = encoder->SetOption(ENCODER_OPTION_DATAFORMAT, &videoFormat); - break; - - case ConfigType::ScreenCaptureAdvanced: - param; - encoder->GetDefaultParams(¶m); - param.iUsageType = SCREEN_CONTENT_REAL_TIME; - param.fMaxFrameRate = fps; - param.iPicWidth = width; - param.iPicHeight = height; - param.iTargetBitrate = bps; - param.bEnableDenoise = false; - param.iSpatialLayerNum = 1; - param.bEnableAdaptiveQuant = false; - param.bEnableFrameSkip = false; - param.bPrefixNalAddingCtrl = false; - param.bIsLosslessLink = false; - param.bFixRCOverShoot = true; - param.bEnableLongTermReference = false; - param.iMinQp = 1; - param.iMaxQp = 51; - - sliceMode = SM_FIXEDSLCNUM_SLICE; - //SM_SIZELIMITED_SLICE with multi-thread is still under testing - /*if (sliceMode != SM_SINGLE_SLICE && sliceMode != SM_SIZELIMITED_SLICE)*/ - param.iMultipleThreadIdc = 2; - for (int i = 0; i < param.iSpatialLayerNum; i++) { - param.sSpatialLayers[i].iVideoWidth = width >> (param.iSpatialLayerNum - 1 - i); - param.sSpatialLayers[i].iVideoHeight = height >> (param.iSpatialLayerNum - 1 - i); - param.sSpatialLayers[i].fFrameRate = fps; - param.sSpatialLayers[i].iSpatialBitrate = param.iTargetBitrate; - param.sSpatialLayers[i].sSliceArgument.uiSliceNum = 16; - param.sSpatialLayers[i].sSliceArgument.uiSliceMode = sliceMode; - if (sliceMode == SM_SIZELIMITED_SLICE) { - param.sSpatialLayers[i].sSliceArgument.uiSliceSizeConstraint = 600; - param.uiMaxNalSize = 1500; - } - } - param.iTargetBitrate *= param.iSpatialLayerNum; - rc = encoder->InitializeExt(¶m); - videoFormat = videoFormatI420; - rc = encoder->SetOption(ENCODER_OPTION_DATAFORMAT, &videoFormat); - break; - - default: - - base.iPicWidth = width; - base.iPicHeight = height; - base.fMaxFrameRate = fps; - base.iUsageType = CAMERA_VIDEO_REAL_TIME; - base.iTargetBitrate = bps; - base.iRCMode = RC_BITRATE_MODE; - rc = encoder->Initialize(&base); - break; - } - - if (rc != 0) return -1; - - buffer_size = width * height * 3 / 2; - i420_buffer = new unsigned char[buffer_size]; - pic = new SSourcePicture(); - pic->iPicWidth = width; - pic->iPicHeight = height; - pic->iColorFormat = videoFormatI420; - pic->iStride[0] = pic->iPicWidth; - pic->iStride[1] = pic->iStride[2] = pic->iPicWidth >> 1; - pic->pData[0] = i420_buffer; - pic->pData[1] = pic->pData[0] + width * height; - pic->pData[2] = pic->pData[1] + (width * height >> 2); - - bsi = new SFrameBSInfo(); - memset(bsi, 0x00, sizeof(SFrameBSInfo)); - - bool t = true; - encoder->SetOption(ENCODER_OPTION_ENABLE_SSEI, &t); - std::cout << "Encoder Set" << std::endl; - return 0; - }; - -#pragma endregion - - - bool Encoder::Encode(Bitmap^ bmp, [Out]array^% frame) - { - if (pic->iPicWidth != bmp->Width || pic->iPicHeight != bmp->Height) throw gcnew System::ArgumentException("Image width and height must be same."); - int width = bmp->Width; - int height = bmp->Height; - BitmapData^ bmpDat = bmp->LockBits(System::Drawing::Rectangle(0, 0, width, height), ImageLockMode::ReadOnly, System::Drawing::Imaging::PixelFormat::Format32bppArgb); - byte* bmpScan = (byte*)bmpDat->Scan0.ToPointer(); - - EnsureCapacity(width * height * 3); - - //Both 32bpp and 24 bpp encodes the pixels in 4 bytes.. Yea.. - if (bmp->PixelFormat == PixelFormat::Format32bppArgb || bmp->PixelFormat == PixelFormat::Format24bppRgb) - { - //auto t_start = std::chrono::high_resolution_clock::now(); - - Bgra2Yuv420(bmpScan, innerBuffer, width, height, bmpDat->Stride); - - /* auto t_end = std::chrono::high_resolution_clock::now(); - double elapsed_time_ms = std::chrono::duration(t_end - t_start).count(); - std::cout << elapsed_time_ms << std::endl;*/ - - bmp->UnlockBits(bmpDat); - return Encode(innerBuffer, frame); - } - else { - throw gcnew System::NotImplementedException("Bmp Pixel format is not supported"); - } - - - } - - - bool Encoder::Encode(RgbImage^ rgb, [Out]array^% frame) - { - int width = rgb->Width; - int height = rgb->Height; - int stride = rgb->Stride; - EnsureCapacity(width * height * 3); - Rgb2Yuv420(rgb->ImageBytes, innerBuffer, width, height, stride); - return Encode(innerBuffer, frame); - - } - bool Encoder::Encode(RgbaImage^ rgb, [Out]array^% frame) - { - int width = rgb->Width; - int height = rgb->Height; - int stride = rgb->Stride; - EnsureCapacity(width * height * 3); - - Rgba2Yuv420(rgb->ImageBytes, innerBuffer, width, height, stride); - return Encode(innerBuffer, frame); - - } - bool Encoder::Encode(BgrImage^ rgb, [Out]array^% frame) - { - int width = rgb->Width; - int height = rgb->Height; - int stride = rgb->Stride; - EnsureCapacity(width * height * 3); - - //auto t_start = std::chrono::high_resolution_clock::now(); - - Bgr2Yuv420(rgb->ImageBytes, innerBuffer, width, height, stride); - - //auto t_end = std::chrono::high_resolution_clock::now(); - //double elapsed_time_ms = std::chrono::duration(t_end - t_start).count(); - //std::cout << elapsed_time_ms << std::endl; - return Encode(innerBuffer, frame); - - } - - bool Encoder::Encode(BgraImage^ rgb, [Out]array^% frame) - { - int width = rgb->Width; - int height = rgb->Height; - int stride = rgb->Stride; - EnsureCapacity(width * height * 3); - - Bgra2Yuv420(rgb->ImageBytes, innerBuffer, width, height, stride); - - return Encode(innerBuffer, frame); - - } - - bool Encoder::Encode(array^ i420, int startIndex, [Out]array^% frame) - { - pin_ptr ptr = &i420[startIndex]; - bool res = Encode(innerBuffer, frame); - - ptr = nullptr; // unpin - return res; - } - bool Encoder::Encode(IntPtr^ i420, array^% frame) { - void* ptr = i420->ToPointer(); - unsigned char* p = reinterpret_cast(ptr); - return Encode(p, frame); - } - - bool Encoder::Encode(unsigned char* i420, [Out]array^% frame) - { - //memcpy(i420_buffer, i420, buffer_size); - - pic->pData[0] = i420; - pic->pData[1] = pic->pData[0] + pic->iPicWidth * pic->iPicHeight; - pic->pData[2] = pic->pData[1] + (pic->iPicWidth * pic->iPicHeight >> 2); - - //bsi = new SFrameBSInfo(); - //memset(bsi, 0x00, sizeof(SFrameBSInfo)); - int resultCode = encoder->EncodeFrame(pic, bsi); - if (resultCode != 0) { - return false; - } - - if (bsi->eFrameType != videoFrameTypeSkip) { - frame = GetEncodedFrames(dynamic_cast(*bsi)); - return true; - } - return false; - } - - array^ Encoder::GetEncodedFrames(const SFrameBSInfo% info) - { - array^ nals = gcnew array(info.iLayerNum); - for (int i = 0; i < info.iLayerNum; ++i) - { - const SLayerBSInfo& layerInfo = info.sLayerInfo[i]; - int layerSize = 0; - for (int j = 0; j < layerInfo.iNalCount; ++j) - { - layerSize += layerInfo.pNalLengthInByte[j]; - } - - nals[i] = gcnew EncodedFrame(layerInfo.pBsBuf, layerSize, i, (FrameType)info.eFrameType); - } - return nals; - } - - int Encoder::ForceIntraFrame() - { - return encoder->ForceIntraFrame(true); - } - - void H264Sharp::Encoder::SetMaxBitrate(int target) - { - SBitrateInfo param; - - memset(¶m, 0, sizeof(SBitrateInfo)); - param.iBitrate = target; - param.iLayer = SPATIAL_LAYER_ALL; - encoder->SetOption(ENCODER_OPTION_MAX_BITRATE, ¶m); - encoder->SetOption(ENCODER_OPTION_BITRATE, ¶m); - } - void H264Sharp::Encoder::SetTargetFps(float target) - { - encoder->SetOption(ENCODER_OPTION_FRAME_RATE, &target); - } - - - Encoder::~Encoder() - { - this->!Encoder(); - } - - Encoder::!Encoder() - { - encoder->Uninitialize(); - DestroyEncoderFunc(encoder); - - delete[] i420_buffer; - delete pic; - delete bsi; - delete[] innerBuffer; - } - void Encoder::EnsureCapacity(int capacity) - { - if (innerBufLen == 0 || innerBufLen < capacity) - { - delete[] innerBuffer; - innerBuffer = new byte[capacity]; - innerBufLen = capacity; - } - } - -} diff --git a/C++CLI/H264SharpCLI/Encoder.h b/C++CLI/H264SharpCLI/Encoder.h deleted file mode 100644 index b905ad2..0000000 --- a/C++CLI/H264SharpCLI/Encoder.h +++ /dev/null @@ -1,59 +0,0 @@ -#pragma once -#include "pch.h" -#using -using namespace System; - -namespace H264Sharp { - - typedef void (*Covert2Yuv420)(unsigned char* bgra, unsigned char* dst, int width, int height, int stride); - static Covert2Yuv420 Bgra2Yuv420; - static Covert2Yuv420 Bgr2Yuv420; - static Covert2Yuv420 Rgba2Yuv420; - static Covert2Yuv420 Rgb2Yuv420; - - public ref class Encoder - { - public: - Encoder(String^ dllName); - Encoder(); - - enum class ConfigType { CameraBasic, ScreenCaptureBasic, CameraCaptureAdvanced, ScreenCaptureAdvanced }; - int Initialize(int width, int height, int bps, float fps, ConfigType configNo); - - bool Encode(System::Drawing::Bitmap ^bmp, array^% frame); - bool Encode(BgrImage ^bgr, array^% frame); - bool Encode(BgraImage ^bgra, array^% frame); - bool Encode(RgbImage ^rgb, array^% frame); - bool Encode(RgbaImage ^rgba, array^% frame); - bool Encode(array ^i420, int startIndex, array^% frame); - bool Encode(unsigned char* i420, array^% frame); - bool Encode(IntPtr^ i420, array^% frame); - - int ForceIntraFrame(); - void SetMaxBitrate(int target); - void SetTargetFps(float target); - - private: - int buffer_size = 0; - unsigned char* i420_buffer = nullptr; - unsigned char* innerBuffer = nullptr; - int innerBufLen = 0; - - ISVCEncoder* encoder; - SSourcePicture* pic; - SFrameBSInfo* bsi; - - typedef int(__stdcall* WelsCreateSVCEncoder)(ISVCEncoder** ppEncoder); - WelsCreateSVCEncoder CreateEncoderFunc; - typedef void(__stdcall* WelsDestroySVCEncoder)(ISVCEncoder* ppEncoder); - WelsDestroySVCEncoder DestroyEncoderFunc; - - void Create(const wchar_t* dllName); - int InitializeInternal(int width, int height, int bps, float fps, ConfigType configType); - void EnsureCapacity(int capacity); - array^ GetEncodedFrames(const SFrameBSInfo% info); - - ~Encoder(); - !Encoder(); - }; -} diff --git a/C++CLI/H264SharpCLI/H264Sharp.vcxproj b/C++CLI/H264SharpCLI/H264Sharp.vcxproj deleted file mode 100644 index fa474ca..0000000 --- a/C++CLI/H264SharpCLI/H264Sharp.vcxproj +++ /dev/null @@ -1,176 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 17.0 - {372F0CEE-61CE-42AE-B820-523972D864AC} - v4.7.2 - ManagedCProj - H264Sharp - 10.0 - true - H264SharpCLI - - - - DynamicLibrary - true - v143 - true - Unicode - - - DynamicLibrary - false - v143 - true - Unicode - true - - - DynamicLibrary - v143 - true - Unicode - - - DynamicLibrary - v143 - true - Unicode - true - - - - - - - - - - - - - - - - - - - - - - $(ProjectName)64 - - - $(ProjectName)32 - - - - - Use - pch.h - Level3 - _DEBUG;%(PreprocessorDefinitions) - true - Disabled - MultiThreadedDebugDLL - - - %(AdditionalDependencies) - - - - - Use - pch.h - Level3 - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - %(AdditionalDependencies) - - - - - Use - pch.h - Level3 - WIN32;NDEBUG;%(PreprocessorDefinitions) - /Qvec-report:2 %(AdditionalOptions) - Full - - - - - - - - Use - pch.h - Level3 - Full - AdvancedVectorExtensions2 - - - %(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/C++CLI/H264SharpCLI/H264Sharp.vcxproj.filters b/C++CLI/H264SharpCLI/H264Sharp.vcxproj.filters deleted file mode 100644 index a8f86d5..0000000 --- a/C++CLI/H264SharpCLI/H264Sharp.vcxproj.filters +++ /dev/null @@ -1,76 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/C++CLI/H264SharpCLI/H264SharpCore.vcxproj b/C++CLI/H264SharpCLI/H264SharpCore.vcxproj deleted file mode 100644 index 6879b15..0000000 --- a/C++CLI/H264SharpCLI/H264SharpCore.vcxproj +++ /dev/null @@ -1,174 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 17.0 - {C8CD810B-FF89-4FE6-9B62-471F69CCF3EE} - netcoreapp3.1 - ManagedCProj - H264Sharp - 10.0 - true - H264SharpCLINetCore - - - - DynamicLibrary - true - v143 - NetCore - Unicode - - - DynamicLibrary - false - v143 - true - Unicode - true - - - DynamicLibrary - v143 - true - Unicode - - - DynamicLibrary - v143 - true - Unicode - true - - - - - - - - - - - - - - - - - - - - - $(ProjectName)64 - - - $(ProjectName)64 - - - $(ProjectName)32 - - - $(ProjectName)32 - - - - Use - pch.h - Level3 - _DEBUG;%(PreprocessorDefinitions) - true - Disabled - MultiThreadedDebugDLL - - - %(AdditionalDependencies) - - - - - Use - pch.h - Level3 - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - %(AdditionalDependencies) - - - - - Use - pch.h - Level3 - WIN32;NDEBUG;%(PreprocessorDefinitions) - /Qvec-report:2 %(AdditionalOptions) - Full - - - - - - - - Use - pch.h - Level3 - Full - AdvancedVectorExtensions2 - - - %(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - - - - - - - - - - - - - \ No newline at end of file diff --git a/C++CLI/H264SharpCLI/H264SharpCore.vcxproj.filters b/C++CLI/H264SharpCLI/H264SharpCore.vcxproj.filters deleted file mode 100644 index a8f86d5..0000000 --- a/C++CLI/H264SharpCLI/H264SharpCore.vcxproj.filters +++ /dev/null @@ -1,76 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/C++CLI/H264SharpCLI/ImageTypes.h b/C++CLI/H264SharpCLI/ImageTypes.h deleted file mode 100644 index 6432977..0000000 --- a/C++CLI/H264SharpCLI/ImageTypes.h +++ /dev/null @@ -1,859 +0,0 @@ -#pragma once -#include "pch.h" -using namespace System; -namespace H264Sharp { - - public ref struct BgrImage - { - public: - int Width; - int Height; - int Stride; - unsigned char* ImageBytes; - BgrImage(unsigned char* imageBytes, int width, int height, int stride); - BgrImage(array^ sourceArray,int startIndex, int width, int height, int stride); - - }; - public ref struct RgbImage - { - public: - int Width; - int Height; - int Stride; - unsigned char* ImageBytes; - RgbImage(unsigned char* imageBytes, int width, int height, int stride); - RgbImage(array^ sourceArray, int startIndex, int width, int height, int stride); - - }; - public ref struct BgraImage - { - public: - int Width; - int Height; - int Stride; - unsigned char* ImageBytes; - BgraImage(unsigned char* imageBytes, int width, int height, int stride); - BgraImage(array^ sourceArray, int startIndex, int width, int height, int stride); - - }; - public ref struct RgbaImage - { - public: - int Width; - int Height; - int Stride; - unsigned char* ImageBytes; - RgbaImage(unsigned char* imageBytes, int width, int height, int stride); - RgbaImage(array^ sourceArray, int startIndex, int width, int height, int stride); - - }; - typedef struct YuvNative { - unsigned char* Y; - unsigned char* U; - unsigned char* V; - int width; - int height; - int stride; - int stride2; - }; - public ref class Yuv420p - { - public: - unsigned char* Y; - unsigned char* U; - unsigned char* V; - int width; - int height; - int strideY; - int strideU; - int strideV; - Yuv420p(unsigned char* Y, unsigned char* U, unsigned char* V, int width, int height, int strideY, int strideuu, int strideV); - - }; - public ref class EncodedFrame - { - public: - unsigned char* DataPointer; - IntPtr Data; - int Length; - int LayerNum; - FrameType Type; - EncodedFrame(unsigned char* data, int lenght, int layerNum, FrameType frameType); - array^ ToByteArray(); - void CopyTo(array^ destination, int startIndex); - }; -} - const unsigned int yuv2rgb565_table1[256 * 3] = - { - /* y_table */ - 0x7FFFFFEDU, - 0x7FFFFFEFU, - 0x7FFFFFF0U, - 0x7FFFFFF1U, - 0x7FFFFFF2U, - 0x7FFFFFF3U, - 0x7FFFFFF4U, - 0x7FFFFFF6U, - 0x7FFFFFF7U, - 0x7FFFFFF8U, - 0x7FFFFFF9U, - 0x7FFFFFFAU, - 0x7FFFFFFBU, - 0x7FFFFFFDU, - 0x7FFFFFFEU, - 0x7FFFFFFFU, - 0x80000000U, - 0x80400801U, - 0x80A01002U, - 0x80E01803U, - 0x81202805U, - 0x81803006U, - 0x81C03807U, - 0x82004008U, - 0x82604809U, - 0x82A0500AU, - 0x82E0600CU, - 0x8340680DU, - 0x8380700EU, - 0x83C0780FU, - 0x84208010U, - 0x84608811U, - 0x84A09813U, - 0x8500A014U, - 0x8540A815U, - 0x8580B016U, - 0x85E0B817U, - 0x8620C018U, - 0x8660D01AU, - 0x86C0D81BU, - 0x8700E01CU, - 0x8740E81DU, - 0x87A0F01EU, - 0x87E0F81FU, - 0x88210821U, - 0x88811022U, - 0x88C11823U, - 0x89012024U, - 0x89412825U, - 0x89A13026U, - 0x89E14028U, - 0x8A214829U, - 0x8A81502AU, - 0x8AC1582BU, - 0x8B01602CU, - 0x8B61682DU, - 0x8BA1782FU, - 0x8BE18030U, - 0x8C418831U, - 0x8C819032U, - 0x8CC19833U, - 0x8D21A034U, - 0x8D61B036U, - 0x8DA1B837U, - 0x8E01C038U, - 0x8E41C839U, - 0x8E81D03AU, - 0x8EE1D83BU, - 0x8F21E83DU, - 0x8F61F03EU, - 0x8FC1F83FU, - 0x90020040U, - 0x90420841U, - 0x90A21042U, - 0x90E22044U, - 0x91222845U, - 0x91823046U, - 0x91C23847U, - 0x92024048U, - 0x92624849U, - 0x92A2504AU, - 0x92E2604CU, - 0x9342684DU, - 0x9382704EU, - 0x93C2784FU, - 0x94228050U, - 0x94628851U, - 0x94A29853U, - 0x9502A054U, - 0x9542A855U, - 0x9582B056U, - 0x95E2B857U, - 0x9622C058U, - 0x9662D05AU, - 0x96C2D85BU, - 0x9702E05CU, - 0x9742E85DU, - 0x97A2F05EU, - 0x97E2F85FU, - 0x98230861U, - 0x98831062U, - 0x98C31863U, - 0x99032064U, - 0x99632865U, - 0x99A33066U, - 0x99E34068U, - 0x9A434869U, - 0x9A83506AU, - 0x9AC3586BU, - 0x9B23606CU, - 0x9B63686DU, - 0x9BA3786FU, - 0x9BE38070U, - 0x9C438871U, - 0x9C839072U, - 0x9CC39873U, - 0x9D23A074U, - 0x9D63B076U, - 0x9DA3B877U, - 0x9E03C078U, - 0x9E43C879U, - 0x9E83D07AU, - 0x9EE3D87BU, - 0x9F23E87DU, - 0x9F63F07EU, - 0x9FC3F87FU, - 0xA0040080U, - 0xA0440881U, - 0xA0A41082U, - 0xA0E42084U, - 0xA1242885U, - 0xA1843086U, - 0xA1C43887U, - 0xA2044088U, - 0xA2644889U, - 0xA2A4588BU, - 0xA2E4608CU, - 0xA344688DU, - 0xA384708EU, - 0xA3C4788FU, - 0xA4248090U, - 0xA4649092U, - 0xA4A49893U, - 0xA504A094U, - 0xA544A895U, - 0xA584B096U, - 0xA5E4B897U, - 0xA624C098U, - 0xA664D09AU, - 0xA6C4D89BU, - 0xA704E09CU, - 0xA744E89DU, - 0xA7A4F09EU, - 0xA7E4F89FU, - 0xA82508A1U, - 0xA88510A2U, - 0xA8C518A3U, - 0xA90520A4U, - 0xA96528A5U, - 0xA9A530A6U, - 0xA9E540A8U, - 0xAA4548A9U, - 0xAA8550AAU, - 0xAAC558ABU, - 0xAB2560ACU, - 0xAB6568ADU, - 0xABA578AFU, - 0xAC0580B0U, - 0xAC4588B1U, - 0xAC8590B2U, - 0xACE598B3U, - 0xAD25A0B4U, - 0xAD65B0B6U, - 0xADA5B8B7U, - 0xAE05C0B8U, - 0xAE45C8B9U, - 0xAE85D0BAU, - 0xAEE5D8BBU, - 0xAF25E8BDU, - 0xAF65F0BEU, - 0xAFC5F8BFU, - 0xB00600C0U, - 0xB04608C1U, - 0xB0A610C2U, - 0xB0E620C4U, - 0xB12628C5U, - 0xB18630C6U, - 0xB1C638C7U, - 0xB20640C8U, - 0xB26648C9U, - 0xB2A658CBU, - 0xB2E660CCU, - 0xB34668CDU, - 0xB38670CEU, - 0xB3C678CFU, - 0xB42680D0U, - 0xB46690D2U, - 0xB4A698D3U, - 0xB506A0D4U, - 0xB546A8D5U, - 0xB586B0D6U, - 0xB5E6B8D7U, - 0xB626C8D9U, - 0xB666D0DAU, - 0xB6C6D8DBU, - 0xB706E0DCU, - 0xB746E8DDU, - 0xB7A6F0DEU, - 0xB7E6F8DFU, - 0xB82708E1U, - 0xB88710E2U, - 0xB8C718E3U, - 0xB90720E4U, - 0xB96728E5U, - 0xB9A730E6U, - 0xB9E740E8U, - 0xBA4748E9U, - 0xBA8750EAU, - 0xBAC758EBU, - 0xBB2760ECU, - 0xBB6768EDU, - 0xBBA778EFU, - 0xBC0780F0U, - 0xBC4788F1U, - 0xBC8790F2U, - 0xBCE798F3U, - 0xBD27A0F4U, - 0xBD67B0F6U, - 0xBDC7B8F7U, - 0xBE07C0F8U, - 0xBE47C8F9U, - 0xBEA7D0FAU, - 0xBEE7D8FBU, - 0xBF27E8FDU, - 0xBF87F0FEU, - 0xBFC7F8FFU, - 0xC0080100U, - 0xC0480901U, - 0xC0A81102U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - 0xC0E82104U, - /* u_table */ - 0x0C400103U, - 0x0C200105U, - 0x0C200107U, - 0x0C000109U, - 0x0BE0010BU, - 0x0BC0010DU, - 0x0BA0010FU, - 0x0BA00111U, - 0x0B800113U, - 0x0B600115U, - 0x0B400117U, - 0x0B400119U, - 0x0B20011BU, - 0x0B00011DU, - 0x0AE0011FU, - 0x0AE00121U, - 0x0AC00123U, - 0x0AA00125U, - 0x0A800127U, - 0x0A600129U, - 0x0A60012BU, - 0x0A40012DU, - 0x0A20012FU, - 0x0A000131U, - 0x0A000132U, - 0x09E00134U, - 0x09C00136U, - 0x09A00138U, - 0x09A0013AU, - 0x0980013CU, - 0x0960013EU, - 0x09400140U, - 0x09400142U, - 0x09200144U, - 0x09000146U, - 0x08E00148U, - 0x08C0014AU, - 0x08C0014CU, - 0x08A0014EU, - 0x08800150U, - 0x08600152U, - 0x08600154U, - 0x08400156U, - 0x08200158U, - 0x0800015AU, - 0x0800015CU, - 0x07E0015EU, - 0x07C00160U, - 0x07A00162U, - 0x07A00164U, - 0x07800166U, - 0x07600168U, - 0x0740016AU, - 0x0720016CU, - 0x0720016EU, - 0x07000170U, - 0x06E00172U, - 0x06C00174U, - 0x06C00176U, - 0x06A00178U, - 0x0680017AU, - 0x0660017CU, - 0x0660017EU, - 0x06400180U, - 0x06200182U, - 0x06000184U, - 0x05E00185U, - 0x05E00187U, - 0x05C00189U, - 0x05A0018BU, - 0x0580018DU, - 0x0580018FU, - 0x05600191U, - 0x05400193U, - 0x05200195U, - 0x05200197U, - 0x05000199U, - 0x04E0019BU, - 0x04C0019DU, - 0x04C0019FU, - 0x04A001A1U, - 0x048001A3U, - 0x046001A5U, - 0x044001A7U, - 0x044001A9U, - 0x042001ABU, - 0x040001ADU, - 0x03E001AFU, - 0x03E001B1U, - 0x03C001B3U, - 0x03A001B5U, - 0x038001B7U, - 0x038001B9U, - 0x036001BBU, - 0x034001BDU, - 0x032001BFU, - 0x032001C1U, - 0x030001C3U, - 0x02E001C5U, - 0x02C001C7U, - 0x02A001C9U, - 0x02A001CBU, - 0x028001CDU, - 0x026001CFU, - 0x024001D1U, - 0x024001D3U, - 0x022001D5U, - 0x020001D7U, - 0x01E001D8U, - 0x01E001DAU, - 0x01C001DCU, - 0x01A001DEU, - 0x018001E0U, - 0x016001E2U, - 0x016001E4U, - 0x014001E6U, - 0x012001E8U, - 0x010001EAU, - 0x010001ECU, - 0x00E001EEU, - 0x00C001F0U, - 0x00A001F2U, - 0x00A001F4U, - 0x008001F6U, - 0x006001F8U, - 0x004001FAU, - 0x004001FCU, - 0x002001FEU, - 0x00000200U, - 0xFFE00202U, - 0xFFC00204U, - 0xFFC00206U, - 0xFFA00208U, - 0xFF80020AU, - 0xFF60020CU, - 0xFF60020EU, - 0xFF400210U, - 0xFF200212U, - 0xFF000214U, - 0xFF000216U, - 0xFEE00218U, - 0xFEC0021AU, - 0xFEA0021CU, - 0xFEA0021EU, - 0xFE800220U, - 0xFE600222U, - 0xFE400224U, - 0xFE200226U, - 0xFE200228U, - 0xFE000229U, - 0xFDE0022BU, - 0xFDC0022DU, - 0xFDC0022FU, - 0xFDA00231U, - 0xFD800233U, - 0xFD600235U, - 0xFD600237U, - 0xFD400239U, - 0xFD20023BU, - 0xFD00023DU, - 0xFCE0023FU, - 0xFCE00241U, - 0xFCC00243U, - 0xFCA00245U, - 0xFC800247U, - 0xFC800249U, - 0xFC60024BU, - 0xFC40024DU, - 0xFC20024FU, - 0xFC200251U, - 0xFC000253U, - 0xFBE00255U, - 0xFBC00257U, - 0xFBC00259U, - 0xFBA0025BU, - 0xFB80025DU, - 0xFB60025FU, - 0xFB400261U, - 0xFB400263U, - 0xFB200265U, - 0xFB000267U, - 0xFAE00269U, - 0xFAE0026BU, - 0xFAC0026DU, - 0xFAA0026FU, - 0xFA800271U, - 0xFA800273U, - 0xFA600275U, - 0xFA400277U, - 0xFA200279U, - 0xFA20027BU, - 0xFA00027CU, - 0xF9E0027EU, - 0xF9C00280U, - 0xF9A00282U, - 0xF9A00284U, - 0xF9800286U, - 0xF9600288U, - 0xF940028AU, - 0xF940028CU, - 0xF920028EU, - 0xF9000290U, - 0xF8E00292U, - 0xF8E00294U, - 0xF8C00296U, - 0xF8A00298U, - 0xF880029AU, - 0xF860029CU, - 0xF860029EU, - 0xF84002A0U, - 0xF82002A2U, - 0xF80002A4U, - 0xF80002A6U, - 0xF7E002A8U, - 0xF7C002AAU, - 0xF7A002ACU, - 0xF7A002AEU, - 0xF78002B0U, - 0xF76002B2U, - 0xF74002B4U, - 0xF74002B6U, - 0xF72002B8U, - 0xF70002BAU, - 0xF6E002BCU, - 0xF6C002BEU, - 0xF6C002C0U, - 0xF6A002C2U, - 0xF68002C4U, - 0xF66002C6U, - 0xF66002C8U, - 0xF64002CAU, - 0xF62002CCU, - 0xF60002CEU, - 0xF60002CFU, - 0xF5E002D1U, - 0xF5C002D3U, - 0xF5A002D5U, - 0xF5A002D7U, - 0xF58002D9U, - 0xF56002DBU, - 0xF54002DDU, - 0xF52002DFU, - 0xF52002E1U, - 0xF50002E3U, - 0xF4E002E5U, - 0xF4C002E7U, - 0xF4C002E9U, - 0xF4A002EBU, - 0xF48002EDU, - 0xF46002EFU, - 0xF46002F1U, - 0xF44002F3U, - 0xF42002F5U, - 0xF40002F7U, - 0xF3E002F9U, - 0xF3E002FBU, - /* v_table */ - 0x1A09A000U, - 0x19E9A800U, - 0x19A9B800U, - 0x1969C800U, - 0x1949D000U, - 0x1909E000U, - 0x18C9E800U, - 0x18A9F800U, - 0x186A0000U, - 0x182A1000U, - 0x180A2000U, - 0x17CA2800U, - 0x17AA3800U, - 0x176A4000U, - 0x172A5000U, - 0x170A6000U, - 0x16CA6800U, - 0x168A7800U, - 0x166A8000U, - 0x162A9000U, - 0x160AA000U, - 0x15CAA800U, - 0x158AB800U, - 0x156AC000U, - 0x152AD000U, - 0x14EAE000U, - 0x14CAE800U, - 0x148AF800U, - 0x146B0000U, - 0x142B1000U, - 0x13EB2000U, - 0x13CB2800U, - 0x138B3800U, - 0x134B4000U, - 0x132B5000U, - 0x12EB6000U, - 0x12CB6800U, - 0x128B7800U, - 0x124B8000U, - 0x122B9000U, - 0x11EBA000U, - 0x11ABA800U, - 0x118BB800U, - 0x114BC000U, - 0x112BD000U, - 0x10EBE000U, - 0x10ABE800U, - 0x108BF800U, - 0x104C0000U, - 0x100C1000U, - 0x0FEC2000U, - 0x0FAC2800U, - 0x0F8C3800U, - 0x0F4C4000U, - 0x0F0C5000U, - 0x0EEC5800U, - 0x0EAC6800U, - 0x0E6C7800U, - 0x0E4C8000U, - 0x0E0C9000U, - 0x0DEC9800U, - 0x0DACA800U, - 0x0D6CB800U, - 0x0D4CC000U, - 0x0D0CD000U, - 0x0CCCD800U, - 0x0CACE800U, - 0x0C6CF800U, - 0x0C4D0000U, - 0x0C0D1000U, - 0x0BCD1800U, - 0x0BAD2800U, - 0x0B6D3800U, - 0x0B2D4000U, - 0x0B0D5000U, - 0x0ACD5800U, - 0x0AAD6800U, - 0x0A6D7800U, - 0x0A2D8000U, - 0x0A0D9000U, - 0x09CD9800U, - 0x098DA800U, - 0x096DB800U, - 0x092DC000U, - 0x090DD000U, - 0x08CDD800U, - 0x088DE800U, - 0x086DF800U, - 0x082E0000U, - 0x07EE1000U, - 0x07CE1800U, - 0x078E2800U, - 0x076E3800U, - 0x072E4000U, - 0x06EE5000U, - 0x06CE5800U, - 0x068E6800U, - 0x064E7800U, - 0x062E8000U, - 0x05EE9000U, - 0x05CE9800U, - 0x058EA800U, - 0x054EB800U, - 0x052EC000U, - 0x04EED000U, - 0x04AED800U, - 0x048EE800U, - 0x044EF000U, - 0x042F0000U, - 0x03EF1000U, - 0x03AF1800U, - 0x038F2800U, - 0x034F3000U, - 0x030F4000U, - 0x02EF5000U, - 0x02AF5800U, - 0x028F6800U, - 0x024F7000U, - 0x020F8000U, - 0x01EF9000U, - 0x01AF9800U, - 0x016FA800U, - 0x014FB000U, - 0x010FC000U, - 0x00EFD000U, - 0x00AFD800U, - 0x006FE800U, - 0x004FF000U, - 0x00100000U, - 0xFFD01000U, - 0xFFB01800U, - 0xFF702800U, - 0xFF303000U, - 0xFF104000U, - 0xFED05000U, - 0xFEB05800U, - 0xFE706800U, - 0xFE307000U, - 0xFE108000U, - 0xFDD09000U, - 0xFD909800U, - 0xFD70A800U, - 0xFD30B000U, - 0xFD10C000U, - 0xFCD0D000U, - 0xFC90D800U, - 0xFC70E800U, - 0xFC30F000U, - 0xFBF10000U, - 0xFBD11000U, - 0xFB911800U, - 0xFB712800U, - 0xFB313000U, - 0xFAF14000U, - 0xFAD14800U, - 0xFA915800U, - 0xFA516800U, - 0xFA317000U, - 0xF9F18000U, - 0xF9D18800U, - 0xF9919800U, - 0xF951A800U, - 0xF931B000U, - 0xF8F1C000U, - 0xF8B1C800U, - 0xF891D800U, - 0xF851E800U, - 0xF831F000U, - 0xF7F20000U, - 0xF7B20800U, - 0xF7921800U, - 0xF7522800U, - 0xF7123000U, - 0xF6F24000U, - 0xF6B24800U, - 0xF6925800U, - 0xF6526800U, - 0xF6127000U, - 0xF5F28000U, - 0xF5B28800U, - 0xF5729800U, - 0xF552A800U, - 0xF512B000U, - 0xF4F2C000U, - 0xF4B2C800U, - 0xF472D800U, - 0xF452E800U, - 0xF412F000U, - 0xF3D30000U, - 0xF3B30800U, - 0xF3731800U, - 0xF3532800U, - 0xF3133000U, - 0xF2D34000U, - 0xF2B34800U, - 0xF2735800U, - 0xF2336800U, - 0xF2137000U, - 0xF1D38000U, - 0xF1B38800U, - 0xF1739800U, - 0xF133A800U, - 0xF113B000U, - 0xF0D3C000U, - 0xF093C800U, - 0xF073D800U, - 0xF033E000U, - 0xF013F000U, - 0xEFD40000U, - 0xEF940800U, - 0xEF741800U, - 0xEF342000U, - 0xEEF43000U, - 0xEED44000U, - 0xEE944800U, - 0xEE745800U, - 0xEE346000U, - 0xEDF47000U, - 0xEDD48000U, - 0xED948800U, - 0xED549800U, - 0xED34A000U, - 0xECF4B000U, - 0xECD4C000U, - 0xEC94C800U, - 0xEC54D800U, - 0xEC34E000U, - 0xEBF4F000U, - 0xEBB50000U, - 0xEB950800U, - 0xEB551800U, - 0xEB352000U, - 0xEAF53000U, - 0xEAB54000U, - 0xEA954800U, - 0xEA555800U, - 0xEA156000U, - 0xE9F57000U, - 0xE9B58000U, - 0xE9958800U, - 0xE9559800U, - 0xE915A000U, - 0xE8F5B000U, - 0xE8B5C000U, - 0xE875C800U, - 0xE855D800U, - 0xE815E000U, - 0xE7F5F000U, - 0xE7B60000U, - 0xE7760800U, - 0xE7561800U, - 0xE7162000U, - 0xE6D63000U, - 0xE6B64000U, - 0xE6764800U, - 0xE6365800U - }; diff --git a/C++CLI/H264SharpCLI/ImageTypyes.cpp b/C++CLI/H264SharpCLI/ImageTypyes.cpp deleted file mode 100644 index 44d3086..0000000 --- a/C++CLI/H264SharpCLI/ImageTypyes.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include "pch.h" -using namespace System; - -H264Sharp::BgrImage::BgrImage(unsigned char* imageBytes, int width, int height, int stride) -{ - ImageBytes = imageBytes; - Width = width; - Height = height; - Stride = stride; - -} - -H264Sharp::BgrImage::BgrImage(array^ sourceArray, int startIndex, int width, int height, int stride) -{ - pin_ptr ptr = &sourceArray[startIndex]; - ImageBytes = ptr; - Width = width; - Height = height; - Stride = stride; -} - -H264Sharp::RgbImage::RgbImage(unsigned char* imageBytes, int width, int height, int stride) -{ - ImageBytes = imageBytes; - Width = width; - Height = height; - Stride = stride; - -} - -H264Sharp::RgbImage::RgbImage(array^ sourceArray, int startIndex, int width, int height, int stride) -{ - pin_ptr ptr = &sourceArray[startIndex]; - ImageBytes = ptr; - Width = width; - Height = height; - Stride = stride; -} - -H264Sharp::BgraImage::BgraImage(unsigned char* imageBytes, int width, int height, int stride) -{ - ImageBytes = imageBytes; - Width = width; - Height = height; - Stride = stride; -} -H264Sharp::BgraImage::BgraImage(array^ sourceArray, int startIndex, int width, int height, int stride) -{ - pin_ptr ptr = &sourceArray[startIndex]; - ImageBytes = ptr; - Width = width; - Height = height; - Stride = stride; -} -H264Sharp::RgbaImage::RgbaImage(unsigned char* imageBytes, int width, int height, int stride) -{ - ImageBytes = imageBytes; - Width = width; - Height = height; - Stride = stride; - -} -H264Sharp::RgbaImage::RgbaImage(array^ sourceArray, int startIndex, int width, int height, int stride) -{ - pin_ptr ptr = &sourceArray[startIndex]; - ImageBytes = ptr; - Width = width; - Height = height; - Stride = stride; -} -H264Sharp::Yuv420p::Yuv420p(unsigned char* YY, unsigned char* UU, unsigned char* VV, int width_, int height_, int stride_Y, int stride_U, int stride_V) -{ - Y = YY; - U = UU; - V = VV; - width = width_; - height = height_; - strideY = stride_Y; - strideU = stride_U; - strideV = stride_V; -} - -H264Sharp::EncodedFrame::EncodedFrame(unsigned char* data, int lenght, int layerNum, FrameType frameType) -{ - DataPointer = data; - Data = (System::IntPtr)data; - Length = lenght; - LayerNum = layerNum; - Type = frameType; -} -array^ H264Sharp::EncodedFrame::ToByteArray() -{ - array^ data = gcnew array(Length); - System::Runtime::InteropServices::Marshal::Copy(Data, data, 0, Length); - return data; -} - -void H264Sharp::EncodedFrame::CopyTo(array^ destination, int startIndex) -{ - pin_ptr ptr = &destination[startIndex]; - memcpy(ptr, DataPointer, Length); - ptr = nullptr; -} \ No newline at end of file diff --git a/C++CLI/H264SharpCLI/Resource.h b/C++CLI/H264SharpCLI/Resource.h deleted file mode 100644 index d5ac7c4..0000000 --- a/C++CLI/H264SharpCLI/Resource.h +++ /dev/null @@ -1,3 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by app.rc diff --git a/C++CLI/H264SharpCLI/Source.cpp b/C++CLI/H264SharpCLI/Source.cpp deleted file mode 100644 index 6da3e45..0000000 --- a/C++CLI/H264SharpCLI/Source.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "pch.h"; \ No newline at end of file diff --git a/C++CLI/H264SharpCLI/app.ico b/C++CLI/H264SharpCLI/app.ico deleted file mode 100644 index 789d7cc..0000000 Binary files a/C++CLI/H264SharpCLI/app.ico and /dev/null differ diff --git a/C++CLI/H264SharpCLI/app.rc b/C++CLI/H264SharpCLI/app.rc deleted file mode 100644 index eab4306..0000000 Binary files a/C++CLI/H264SharpCLI/app.rc and /dev/null differ diff --git a/C++CLI/H264SharpCLI/codec_api.h b/C++CLI/H264SharpCLI/codec_api.h deleted file mode 100644 index 564374a..0000000 --- a/C++CLI/H264SharpCLI/codec_api.h +++ /dev/null @@ -1,592 +0,0 @@ -/*! - *@page License - * - * \copy - * Copyright (c) 2013, Cisco Systems - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef WELS_VIDEO_CODEC_SVC_API_H__ -#define WELS_VIDEO_CODEC_SVC_API_H__ - -#ifndef __cplusplus -#if defined(_MSC_VER) && (_MSC_VER < 1800) -typedef unsigned char bool; -#else -#include -#endif -#endif - -#include "codec_app_def.h" -#include "codec_def.h" - -#if defined(_WIN32) || defined(__cdecl) -#define EXTAPI __cdecl -#else -#define EXTAPI -#endif - - /** - * @file codec_api.h - */ - - /** - * @page Overview - * * This page is for openh264 codec API usage. - * * For how to use the encoder,please refer to page UsageExampleForEncoder - * * For how to use the decoder,please refer to page UsageExampleForDecoder - * * For more detail about ISVEncoder,please refer to page ISVCEncoder - * * For more detail about ISVDecoder,please refer to page ISVCDecoder - */ - - /** - * @page DecoderUsageExample - * - * @brief - * * An example for using the decoder for Decoding only or Parsing only - * - * Step 1:decoder declaration - * @code - * - * //decoder declaration - * ISVCDecoder *pSvcDecoder; - * //input: encoded bitstream start position; should include start code prefix - * unsigned char *pBuf =...; - * //input: encoded bit stream length; should include the size of start code prefix - * int iSize =...; - * //output: [0~2] for Y,U,V buffer for Decoding only - * unsigned char *pData[3] =...; - * //in-out: for Decoding only: declare and initialize the output buffer info, this should never co-exist with Parsing only - * SBufferInfo sDstBufInfo; - * memset(&sDstBufInfo, 0, sizeof(SBufferInfo)); - * //in-out: for Parsing only: declare and initialize the output bitstream buffer info for parse only, this should never co-exist with Decoding only - * SParserBsInfo sDstParseInfo; - * memset(&sDstParseInfo, 0, sizeof(SParserBsInfo)); - * sDstParseInfo.pDstBuff = new unsigned char[PARSE_SIZE]; //In Parsing only, allocate enough buffer to save transcoded bitstream for a frame - * - * @endcode - * - * Step 2:decoder creation - * @code - * WelsCreateDecoder(&pSvcDecoder); - * @endcode - * - * Step 3:declare required parameter, used to differentiate Decoding only and Parsing only - * @code - * SDecodingParam sDecParam = {0}; - * sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_AVC; - * //for Parsing only, the assignment is mandatory - * sDecParam.bParseOnly = true; - * @endcode - * - * Step 4:initialize the parameter and decoder context, allocate memory - * @code - * pSvcDecoder->Initialize(&sDecParam); - * @endcode - * - * Step 5:do actual decoding process in slice level; - * this can be done in a loop until data ends - * @code - * //for Decoding only - * iRet = pSvcDecoder->DecodeFrameNoDelay(pBuf, iSize, pData, &sDstBufInfo); - * //or - * iRet = pSvcDecoder->DecodeFrame2(pBuf, iSize, pData, &sDstBufInfo); - * //for Parsing only - * iRet = pSvcDecoder->DecodeParser(pBuf, iSize, &sDstParseInfo); - * //decode failed - * If (iRet != 0){ - * //error handling (RequestIDR or something like that) - * } - * //for Decoding only, pData can be used for render. - * if (sDstBufInfo.iBufferStatus==1){ - * //output handling (pData[0], pData[1], pData[2]) - * } - * //for Parsing only, sDstParseInfo can be used for, e.g., HW decoding - * if (sDstBufInfo.iNalNum > 0){ - * //Hardware decoding sDstParseInfo; - * } - * //no-delay decoding can be realized by directly calling DecodeFrameNoDelay(), which is the recommended usage. - * //no-delay decoding can also be realized by directly calling DecodeFrame2() again with NULL input, as in the following. In this case, decoder would immediately reconstruct the input data. This can also be used similarly for Parsing only. Consequent decoding error and output indication should also be considered as above. - * iRet = pSvcDecoder->DecodeFrame2(NULL, 0, pData, &sDstBufInfo); - * //judge iRet, sDstBufInfo.iBufferStatus ... - * @endcode - * - * Step 6:uninitialize the decoder and memory free - * @code - * pSvcDecoder->Uninitialize(); - * @endcode - * - * Step 7:destroy the decoder - * @code - * DestroyDecoder(pSvcDecoder); - * @endcode - * - */ - - /** - * @page EncoderUsageExample1 - * - * @brief - * * An example for using encoder with basic parameter - * - * Step1:setup encoder - * @code - * ISVCEncoder* encoder_; - * int rv = WelsCreateSVCEncoder (&encoder_); - * assert (rv == 0); - * assert (encoder_ != NULL); - * @endcode - * - * Step2:initilize with basic parameter - * @code - * SEncParamBase param; - * memset (¶m, 0, sizeof (SEncParamBase)); - * param.iUsageType = usageType; //from EUsageType enum - * param.fMaxFrameRate = frameRate; - * param.iPicWidth = width; - * param.iPicHeight = height; - * param.iTargetBitrate = 5000000; - * encoder_->Initialize (¶m); - * @endcode - * - * Step3:set option, set option during encoding process - * @code - * encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &g_LevelSetting); - * int videoFormat = videoFormatI420; - * encoder_->SetOption (ENCODER_OPTION_DATAFORMAT, &videoFormat); - * @endcode - * - * Step4: encode and store ouput bistream - * @code - * int frameSize = width * height * 3 / 2; - * BufferedData buf; - * buf.SetLength (frameSize); - * assert (buf.Length() == (size_t)frameSize); - * SFrameBSInfo info; - * memset (&info, 0, sizeof (SFrameBSInfo)); - * SSourcePicture pic; - * memset (&pic, 0, sizeof (SsourcePicture)); - * pic.iPicWidth = width; - * pic.iPicHeight = height; - * pic.iColorFormat = videoFormatI420; - * pic.iStride[0] = pic.iPicWidth; - * pic.iStride[1] = pic.iStride[2] = pic.iPicWidth >> 1; - * pic.pData[0] = buf.data(); - * pic.pData[1] = pic.pData[0] + width * height; - * pic.pData[2] = pic.pData[1] + (width * height >> 2); - * for(int num = 0;numEncodeFrame (&pic, &info); - * assert (rv == cmResultSuccess); - * if (info.eFrameType != videoFrameTypeSkip) { - * //output bitstream handling - * } - * } - * @endcode - * - * Step5:teardown encoder - * @code - * if (encoder_) { - * encoder_->Uninitialize(); - * WelsDestroySVCEncoder (encoder_); - * } - * @endcode - * - */ - - /** - * @page EncoderUsageExample2 - * - * @brief - * * An example for using the encoder with extension parameter. - * * The same operation on Step 1,3,4,5 with Example-1 - * - * Step 2:initialize with extension parameter - * @code - * SEncParamExt param; - * encoder_->GetDefaultParams (¶m); - * param.iUsageType = usageType; - * param.fMaxFrameRate = frameRate; - * param.iPicWidth = width; - * param.iPicHeight = height; - * param.iTargetBitrate = 5000000; - * param.bEnableDenoise = denoise; - * param.iSpatialLayerNum = layers; - * //SM_DYN_SLICE don't support multi-thread now - * if (sliceMode != SM_SINGLE_SLICE && sliceMode != SM_DYN_SLICE) - * param.iMultipleThreadIdc = 2; - * - * for (int i = 0; i < param.iSpatialLayerNum; i++) { - * param.sSpatialLayers[i].iVideoWidth = width >> (param.iSpatialLayerNum - 1 - i); - * param.sSpatialLayers[i].iVideoHeight = height >> (param.iSpatialLayerNum - 1 - i); - * param.sSpatialLayers[i].fFrameRate = frameRate; - * param.sSpatialLayers[i].iSpatialBitrate = param.iTargetBitrate; - * - * param.sSpatialLayers[i].sSliceCfg.uiSliceMode = sliceMode; - * if (sliceMode == SM_DYN_SLICE) { - * param.sSpatialLayers[i].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 600; - * param.uiMaxNalSize = 1500; - * } - * } - * param.iTargetBitrate *= param.iSpatialLayerNum; - * encoder_->InitializeExt (¶m); - * int videoFormat = videoFormatI420; - * encoder_->SetOption (ENCODER_OPTION_DATAFORMAT, &videoFormat); - * - * @endcode - */ - - - - -#ifdef __cplusplus - /** - * @brief Endocder definition - */ -class ISVCEncoder { -public: - /** - * @brief Initialize the encoder - * @param pParam basic encoder parameter - * @return CM_RETURN: 0 - success; otherwise - failed; - */ - virtual int EXTAPI Initialize(const SEncParamBase* pParam) = 0; - - /** - * @brief Initilaize encoder by using extension parameters. - * @param pParam extension parameter for encoder - * @return CM_RETURN: 0 - success; otherwise - failed; - */ - virtual int EXTAPI InitializeExt(const SEncParamExt* pParam) = 0; - - /** - * @brief Get the default extension parameters. - * If you want to change some parameters of encoder, firstly you need to get the default encoding parameters, - * after that you can change part of parameters you want to. - * @param pParam extension parameter for encoder - * @return CM_RETURN: 0 - success; otherwise - failed; - * */ - virtual int EXTAPI GetDefaultParams(SEncParamExt* pParam) = 0; - /// uninitialize the encoder - virtual int EXTAPI Uninitialize() = 0; - - /** - * @brief Encode one frame - * @param kpSrcPic the pointer to the source luminance plane - * chrominance data: - * CbData = kpSrc + m_iMaxPicWidth * m_iMaxPicHeight; - * CrData = CbData + (m_iMaxPicWidth * m_iMaxPicHeight)/4; - * the application calling this interface needs to ensure the data validation between the location - * @param pBsInfo output bit stream - * @return 0 - success; otherwise -failed; - */ - virtual int EXTAPI EncodeFrame(const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo) = 0; - - /** - * @brief Encode the parameters from output bit stream - * @param pBsInfo output bit stream - * @return 0 - success; otherwise - failed; - */ - virtual int EXTAPI EncodeParameterSets(SFrameBSInfo* pBsInfo) = 0; - - /** - * @brief Force encoder to encoder frame as IDR if bIDR set as true - * @param bIDR true: force encoder to encode frame as IDR frame;false, return 1 and nothing to do - * @return 0 - success; otherwise - failed; - */ - virtual int EXTAPI ForceIntraFrame(bool bIDR, int iLayerId = -1) = 0; - - /** - * @brief Set option for encoder, detail option type, please refer to enumurate ENCODER_OPTION. - * @param pOption option for encoder such as InDataFormat, IDRInterval, SVC Encode Param, Frame Rate, Bitrate,... - * @return CM_RETURN: 0 - success; otherwise - failed; - */ - virtual int EXTAPI SetOption(ENCODER_OPTION eOptionId, void* pOption) = 0; - - /** - * @brief Get option for encoder, detail option type, please refer to enumurate ENCODER_OPTION. - * @param pOption option for encoder such as InDataFormat, IDRInterval, SVC Encode Param, Frame Rate, Bitrate,... - * @return CM_RETURN: 0 - success; otherwise - failed; - */ - virtual int EXTAPI GetOption(ENCODER_OPTION eOptionId, void* pOption) = 0; - virtual ~ISVCEncoder() {} -}; - - - -/** -* @brief Decoder definition -*/ -class ISVCDecoder { -public: - - /** - * @brief Initilaize decoder - * @param pParam parameter for decoder - * @return 0 - success; otherwise - failed; - */ - virtual long EXTAPI Initialize(const SDecodingParam* pParam) = 0; - - /// Uninitialize the decoder - virtual long EXTAPI Uninitialize() = 0; - - /** - * @brief Decode one frame - * @param pSrc the h264 stream to be decoded - * @param iSrcLen the length of h264 stream - * @param ppDst buffer pointer of decoded data (YUV) - * @param pStride output stride - * @param iWidth output width - * @param iHeight output height - * @return 0 - success; otherwise -failed; - */ - virtual DECODING_STATE EXTAPI DecodeFrame(const unsigned char* pSrc, - const int iSrcLen, - unsigned char** ppDst, - int* pStride, - int& iWidth, - int& iHeight) = 0; - - /** - * @brief For slice level DecodeFrameNoDelay() (4 parameters input), - * whatever the function return value is, the output data - * of I420 format will only be available when pDstInfo->iBufferStatus == 1,. - * This function will parse and reconstruct the input frame immediately if it is complete - * It is recommended as the main decoding function for H.264/AVC format input - * @param pSrc the h264 stream to be decoded - * @param iSrcLen the length of h264 stream - * @param ppDst buffer pointer of decoded data (YUV) - * @param pDstInfo information provided to API(width, height, etc.) - * @return 0 - success; otherwise -failed; - */ - virtual DECODING_STATE EXTAPI DecodeFrameNoDelay(const unsigned char* pSrc, - const int iSrcLen, - unsigned char** ppDst, - SBufferInfo* pDstInfo) = 0; - - /** - * @brief For slice level DecodeFrame2() (4 parameters input), - * whatever the function return value is, the output data - * of I420 format will only be available when pDstInfo->iBufferStatus == 1,. - * (e.g., in multi-slice cases, only when the whole picture - * is completely reconstructed, this variable would be set equal to 1.) - * @param pSrc the h264 stream to be decoded - * @param iSrcLen the length of h264 stream - * @param ppDst buffer pointer of decoded data (YUV) - * @param pDstInfo information provided to API(width, height, etc.) - * @return 0 - success; otherwise -failed; - */ - virtual DECODING_STATE EXTAPI DecodeFrame2(const unsigned char* pSrc, - const int iSrcLen, - unsigned char** ppDst, - SBufferInfo* pDstInfo) = 0; - - - /** - * @brief This function gets a decoded ready frame remaining in buffers after the last frame has been decoded. - * Use GetOption with option DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER to get the number of frames remaining in buffers. - * Note that it is only applicable for profile_idc != 66 - * @param ppDst buffer pointer of decoded data (YUV) - * @param pDstInfo information provided to API(width, height, etc.) - * @return 0 - success; otherwise -failed; - */ - virtual DECODING_STATE EXTAPI FlushFrame(unsigned char** ppDst, - SBufferInfo* pDstInfo) = 0; - - /** - * @brief This function parse input bitstream only, and rewrite possible SVC syntax to AVC syntax - * @param pSrc the h264 stream to be decoded - * @param iSrcLen the length of h264 stream - * @param pDstInfo bit stream info - * @return 0 - success; otherwise -failed; - */ - virtual DECODING_STATE EXTAPI DecodeParser(const unsigned char* pSrc, - const int iSrcLen, - SParserBsInfo* pDstInfo) = 0; - - /** - * @brief This API does not work for now!! This is for future use to support non-I420 color format output. - * @param pSrc the h264 stream to be decoded - * @param iSrcLen the length of h264 stream - * @param pDst buffer pointer of decoded data (YUV) - * @param iDstStride output stride - * @param iDstLen bit stream info - * @param iWidth output width - * @param iHeight output height - * @param iColorFormat output color format - * @return to do ... - */ - virtual DECODING_STATE EXTAPI DecodeFrameEx(const unsigned char* pSrc, - const int iSrcLen, - unsigned char* pDst, - int iDstStride, - int& iDstLen, - int& iWidth, - int& iHeight, - int& iColorFormat) = 0; - - /** - * @brief Set option for decoder, detail option type, please refer to enumurate DECODER_OPTION. - * @param pOption option for decoder such as OutDataFormat, Eos Flag, EC method, ... - * @return CM_RETURN: 0 - success; otherwise - failed; - */ - virtual long EXTAPI SetOption(DECODER_OPTION eOptionId, void* pOption) = 0; - - /** - * @brief Get option for decoder, detail option type, please refer to enumurate DECODER_OPTION. - * @param pOption option for decoder such as OutDataFormat, Eos Flag, EC method, ... - * @return CM_RETURN: 0 - success; otherwise - failed; - */ - virtual long EXTAPI GetOption(DECODER_OPTION eOptionId, void* pOption) = 0; - virtual ~ISVCDecoder() {} -}; - - -extern "C" -{ -#else - -typedef struct ISVCEncoderVtbl ISVCEncoderVtbl; -typedef const ISVCEncoderVtbl* ISVCEncoder; -struct ISVCEncoderVtbl { - - int (*Initialize) (ISVCEncoder*, const SEncParamBase* pParam); - int (*InitializeExt) (ISVCEncoder*, const SEncParamExt* pParam); - - int (*GetDefaultParams) (ISVCEncoder*, SEncParamExt* pParam); - - int (*Uninitialize) (ISVCEncoder*); - - int (*EncodeFrame) (ISVCEncoder*, const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo); - int (*EncodeParameterSets) (ISVCEncoder*, SFrameBSInfo* pBsInfo); - - int (*ForceIntraFrame) (ISVCEncoder*, bool bIDR); - - int (*SetOption) (ISVCEncoder*, ENCODER_OPTION eOptionId, void* pOption); - int (*GetOption) (ISVCEncoder*, ENCODER_OPTION eOptionId, void* pOption); -}; - -typedef struct ISVCDecoderVtbl ISVCDecoderVtbl; -typedef const ISVCDecoderVtbl* ISVCDecoder; -struct ISVCDecoderVtbl { - long (*Initialize) (ISVCDecoder*, const SDecodingParam* pParam); - long (*Uninitialize) (ISVCDecoder*); - - DECODING_STATE(*DecodeFrame) (ISVCDecoder*, const unsigned char* pSrc, - const int iSrcLen, - unsigned char** ppDst, - int* pStride, - int* iWidth, - int* iHeight); - - DECODING_STATE(*DecodeFrameNoDelay) (ISVCDecoder*, const unsigned char* pSrc, - const int iSrcLen, - unsigned char** ppDst, - SBufferInfo* pDstInfo); - - DECODING_STATE(*DecodeFrame2) (ISVCDecoder*, const unsigned char* pSrc, - const int iSrcLen, - unsigned char** ppDst, - SBufferInfo* pDstInfo); - - DECODING_STATE(*FlushFrame) (ISVCDecoder*, unsigned char** ppDst, - SBufferInfo* pDstInfo); - - DECODING_STATE(*DecodeParser) (ISVCDecoder*, const unsigned char* pSrc, - const int iSrcLen, - SParserBsInfo* pDstInfo); - - DECODING_STATE(*DecodeFrameEx) (ISVCDecoder*, const unsigned char* pSrc, - const int iSrcLen, - unsigned char* pDst, - int iDstStride, - int* iDstLen, - int* iWidth, - int* iHeight, - int* iColorFormat); - - long (*SetOption) (ISVCDecoder*, DECODER_OPTION eOptionId, void* pOption); - long (*GetOption) (ISVCDecoder*, DECODER_OPTION eOptionId, void* pOption); -}; -#endif - -typedef void (*WelsTraceCallback) (void* ctx, int level, const char* string); - -/** @brief Create encoder - * @param ppEncoder encoder - * @return 0 - success; otherwise - failed; -*/ -int WelsCreateSVCEncoder(ISVCEncoder** ppEncoder); - - -/** @brief Destroy encoder -* @param pEncoder encoder - * @return void -*/ -void WelsDestroySVCEncoder(ISVCEncoder* pEncoder); - - -/** @brief Get the capability of decoder - * @param pDecCapability decoder capability - * @return 0 - success; otherwise - failed; -*/ -int WelsGetDecoderCapability(SDecoderCapability* pDecCapability); - - -/** @brief Create decoder - * @param ppDecoder decoder - * @return 0 - success; otherwise - failed; -*/ -long WelsCreateDecoder(ISVCDecoder** ppDecoder); - - -/** @brief Destroy decoder - * @param pDecoder decoder - * @return void -*/ -void WelsDestroyDecoder(ISVCDecoder* pDecoder); - -/** @brief Get codec version - * Note, old versions of Mingw (GCC < 4.7) are buggy and use an - * incorrect/different ABI for calling this function, making it - * incompatible with MSVC builds. - * @return The linked codec version -*/ -H264SharpVersion WelsGetCodecVersion(void); - -/** @brief Get codec version - * @param pVersion struct to fill in with the version -*/ -void WelsGetCodecVersionEx(H264SharpVersion* pVersion); - -#ifdef __cplusplus -} -#endif - -#endif//WELS_VIDEO_CODEC_SVC_API_H__ \ No newline at end of file diff --git a/C++CLI/H264SharpCLI/codec_app_def.h b/C++CLI/H264SharpCLI/codec_app_def.h deleted file mode 100644 index ccd64fa..0000000 --- a/C++CLI/H264SharpCLI/codec_app_def.h +++ /dev/null @@ -1,812 +0,0 @@ -/*! - * \copy - * Copyright (c) 2013, Cisco Systems - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - - - -#ifndef WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__ -#define WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__ - /** - * @file codec_app_def.h - * @brief Data and /or structures introduced in Cisco H264Sharp application - */ - -#include "codec_def.h" - /* Constants */ -#define MAX_TEMPORAL_LAYER_NUM 4 -#define MAX_SPATIAL_LAYER_NUM 4 -#define MAX_QUALITY_LAYER_NUM 4 - -#define MAX_LAYER_NUM_OF_FRAME 128 -#define MAX_NAL_UNITS_IN_LAYER 128 ///< predetermined here, adjust it later if need - -#define MAX_RTP_PAYLOAD_LEN 1000 -#define AVERAGE_RTP_PAYLOAD_LEN 800 - - -#define SAVED_NALUNIT_NUM_TMP ( (MAX_SPATIAL_LAYER_NUM*MAX_QUALITY_LAYER_NUM) + 1 + MAX_SPATIAL_LAYER_NUM ) ///< SPS/PPS + SEI/SSEI + PADDING_NAL -#define MAX_SLICES_NUM_TMP ( ( MAX_NAL_UNITS_IN_LAYER - SAVED_NALUNIT_NUM_TMP ) / 3 ) - - -#define AUTO_REF_PIC_COUNT -1 ///< encoder selects the number of reference frame automatically -#define UNSPECIFIED_BIT_RATE 0 ///< to do: add detail comment - -/** - * @brief Struct of H264Sharp version - */ - /// - /// E.g. SDK version is 1.2.0.0, major version number is 1, minor version number is 2, and revision number is 0. -typedef struct _tagVersion { - unsigned int uMajor; ///< The major version number - unsigned int uMinor; ///< The minor version number - unsigned int uRevision; ///< The revision number - unsigned int uReserved; ///< The reserved number, it should be 0. -} H264SharpVersion; - -/** -* @brief Decoding status -*/ -typedef enum { - /** - * Errors derived from bitstream parsing - */ - dsErrorFree = 0x00, ///< bit stream error-free - dsFramePending = 0x01, ///< need more throughput to generate a frame output, - dsRefLost = 0x02, ///< layer lost at reference frame with temporal id 0 - dsBitstreamError = 0x04, ///< error bitstreams(maybe broken internal frame) the decoder cared - dsDepLayerLost = 0x08, ///< dependented layer is ever lost - dsNoParamSets = 0x10, ///< no parameter set NALs involved - dsDataErrorConcealed = 0x20, ///< current data error concealed specified - dsRefListNullPtrs = 0x40, /// do not write any of the following information to the header - unsigned char - uiVideoFormat; // EVideoFormatSPS; 3 bits in header; 0-5 => component, kpal, ntsc, secam, mac, undef - bool bFullRange; // false => analog video data range [16, 235]; true => full data range [0,255] - bool bColorDescriptionPresent; // false => do not write any of the following three items to the header - unsigned char - uiColorPrimaries; // EColorPrimaries; 8 bits in header; 0 - 9 => ???, bt709, undef, ???, bt470m, bt470bg, - // smpte170m, smpte240m, film, bt2020 - unsigned char - uiTransferCharacteristics; // ETransferCharacteristics; 8 bits in header; 0 - 15 => ???, bt709, undef, ???, bt470m, bt470bg, smpte170m, - // smpte240m, linear, log100, log316, iec61966-2-4, bt1361e, iec61966-2-1, bt2020-10, bt2020-12 - unsigned char - uiColorMatrix; // EColorMatrix; 8 bits in header (corresponds to FFmpeg "colorspace"); 0 - 10 => GBR, bt709, - // undef, ???, fcc, bt470bg, smpte170m, smpte240m, YCgCo, bt2020nc, bt2020c - - bool bAspectRatioPresent; ///< aspect ratio present in VUI - ESampleAspectRatio eAspectRatio; ///< aspect ratio idc - unsigned short sAspectRatioExtWidth; ///< use if aspect ratio idc == 255 - unsigned short sAspectRatioExtHeight; ///< use if aspect ratio idc == 255 - -} SSpatialLayerConfig; - -/** -* @brief Encoder usage type -*/ -typedef enum { - CAMERA_VIDEO_REAL_TIME, ///< camera video for real-time communication - SCREEN_CONTENT_REAL_TIME, ///< screen content signal - CAMERA_VIDEO_NON_REAL_TIME, - SCREEN_CONTENT_NON_REAL_TIME, - INPUT_CONTENT_TYPE_ALL, -} EUsageType; - -/** -* @brief Enumulate the complexity mode -*/ -typedef enum { - LOW_COMPLEXITY = 0, ///< the lowest compleixty,the fastest speed, - MEDIUM_COMPLEXITY, ///< medium complexity, medium speed,medium quality - HIGH_COMPLEXITY ///< high complexity, lowest speed, high quality -} ECOMPLEXITY_MODE; - -/** - * @brief Enumulate for the stategy of SPS/PPS strategy - */ -typedef enum { - CONSTANT_ID = 0, ///< constant id in SPS/PPS - INCREASING_ID = 0x01, ///< SPS/PPS id increases at each IDR - SPS_LISTING = 0x02, ///< using SPS in the existing list if possible - SPS_LISTING_AND_PPS_INCREASING = 0x03, - SPS_PPS_LISTING = 0x06, -} EParameterSetStrategy; - -// TODO: Refine the parameters definition. -/** -* @brief SVC Encoding Parameters -*/ -typedef struct TagEncParamBase { - EUsageType - iUsageType; ///< application type; please refer to the definition of EUsageType - - int iPicWidth; ///< width of picture in luminance samples (the maximum of all layers if multiple spatial layers presents) - int iPicHeight; ///< height of picture in luminance samples((the maximum of all layers if multiple spatial layers presents) - int iTargetBitrate; ///< target bitrate desired, in unit of bps - RC_MODES iRCMode; ///< rate control mode - float fMaxFrameRate; ///< maximal input frame rate - -} SEncParamBase, * PEncParamBase; - -/** -* @brief SVC Encoding Parameters extention -*/ -typedef struct TagEncParamExt { - EUsageType - iUsageType; ///< same as in TagEncParamBase - - int iPicWidth; ///< same as in TagEncParamBase - int iPicHeight; ///< same as in TagEncParamBase - int iTargetBitrate; ///< same as in TagEncParamBase - RC_MODES iRCMode; ///< same as in TagEncParamBase - float fMaxFrameRate; ///< same as in TagEncParamBase - - int iTemporalLayerNum; ///< temporal layer number, max temporal layer = 4 - int iSpatialLayerNum; ///< spatial layer number,1<= iSpatialLayerNum <= MAX_SPATIAL_LAYER_NUM, MAX_SPATIAL_LAYER_NUM = 4 - SSpatialLayerConfig sSpatialLayers[MAX_SPATIAL_LAYER_NUM]; - - ECOMPLEXITY_MODE iComplexityMode; - unsigned int uiIntraPeriod; ///< period of Intra frame - int iNumRefFrame; ///< number of reference frame used - EParameterSetStrategy - eSpsPpsIdStrategy; ///< different stategy in adjust ID in SPS/PPS: 0- constant ID, 1-additional ID, 6-mapping and additional - bool bPrefixNalAddingCtrl; ///< false:not use Prefix NAL; true: use Prefix NAL - bool bEnableSSEI; ///< false:not use SSEI; true: use SSEI -- TODO: planning to remove the interface of SSEI - bool bSimulcastAVC; ///< (when encoding more than 1 spatial layer) false: use SVC syntax for higher layers; true: use Simulcast AVC - int iPaddingFlag; ///< 0:disable padding;1:padding - int iEntropyCodingModeFlag; ///< 0:CAVLC 1:CABAC. - - /* rc control */ - bool bEnableFrameSkip; ///< False: don't skip frame even if VBV buffer overflow.True: allow skipping frames to keep the bitrate within limits - int iMaxBitrate; ///< the maximum bitrate, in unit of bps, set it to UNSPECIFIED_BIT_RATE if not needed - int iMaxQp; ///< the maximum QP encoder supports - int iMinQp; ///< the minmum QP encoder supports - unsigned int uiMaxNalSize; ///< the maximum NAL size. This value should be not 0 for dynamic slice mode - - /*LTR settings*/ - bool bEnableLongTermReference; ///< 1: on, 0: off - int iLTRRefNum; ///< the number of LTR(long term reference),TODO: not supported to set it arbitrary yet - unsigned int iLtrMarkPeriod; ///< the LTR marked period that is used in feedback. - /* multi-thread settings*/ - unsigned short - iMultipleThreadIdc; ///< 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; lager than 1: count number of threads; - bool bUseLoadBalancing; ///< only used when uiSliceMode=1 or 3, will change slicing of a picture during the run-time of multi-thread encoding, so the result of each run may be different - - /* Deblocking loop filter */ - int iLoopFilterDisableIdc; ///< 0: on, 1: off, 2: on except for slice boundaries - int iLoopFilterAlphaC0Offset; ///< AlphaOffset: valid range [-6, 6], default 0 - int iLoopFilterBetaOffset; ///< BetaOffset: valid range [-6, 6], default 0 - /*pre-processing feature*/ - bool bEnableDenoise; ///< denoise control - bool bEnableBackgroundDetection; ///< background detection control //VAA_BACKGROUND_DETECTION //BGD cmd - bool bEnableAdaptiveQuant; ///< adaptive quantization control - bool bEnableFrameCroppingFlag; ///< enable frame cropping flag: TRUE always in application - bool bEnableSceneChangeDetect; - - bool bIsLosslessLink; ///< LTR advanced setting - bool bFixRCOverShoot; ///< fix rate control overshooting - int iIdrBitrateRatio; ///< the target bits of IDR is (idr_bitrate_ratio/100) * average target bit per frame. -} SEncParamExt; - -/** -* @brief Define a new struct to show the property of video bitstream. -*/ -typedef struct { - unsigned int size; ///< size of the struct - VIDEO_BITSTREAM_TYPE eVideoBsType; ///< video stream type (AVC/SVC) -} SVideoProperty; - -/** -* @brief SVC Decoding Parameters, reserved here and potential applicable in the future -*/ -typedef struct TagSVCDecodingParam { - char* pFileNameRestructed; ///< file name of reconstructed frame used for PSNR calculation based debug - - unsigned int uiCpuLoad; ///< CPU load - unsigned char uiTargetDqLayer; ///< setting target dq layer id - - ERROR_CON_IDC eEcActiveIdc; ///< whether active error concealment feature in decoder - bool bParseOnly; ///< decoder for parse only, no reconstruction. When it is true, SPS/PPS size should not exceed SPS_PPS_BS_SIZE (128). Otherwise, it will return error info - - SVideoProperty sVideoProperty; ///< video stream property -} SDecodingParam, * PDecodingParam; - -/** -* @brief Bitstream inforamtion of a layer being encoded -*/ -typedef struct { - unsigned char uiTemporalId; - unsigned char uiSpatialId; - unsigned char uiQualityId; - EVideoFrameType eFrameType; - unsigned char uiLayerType; - - /** - * The sub sequence layers are ordered hierarchically based on their dependency on each other so that any picture in a layer shall not be - * predicted from any picture on any higher layer. - */ - int iSubSeqId; ///< refer to D.2.11 Sub-sequence information SEI message semantics - int iNalCount; ///< count number of NAL coded already - int* pNalLengthInByte; ///< length of NAL size in byte from 0 to iNalCount-1 - unsigned char* pBsBuf; ///< buffer of bitstream contained -} SLayerBSInfo, * PLayerBSInfo; - -/** -* @brief Frame bit stream info -*/ -typedef struct { - int iLayerNum; - SLayerBSInfo sLayerInfo[MAX_LAYER_NUM_OF_FRAME]; - - EVideoFrameType eFrameType; - int iFrameSizeInBytes; - long long uiTimeStamp; -} SFrameBSInfo, * PFrameBSInfo; - -/** -* @brief Structure for source picture -*/ -typedef struct Source_Picture_s { - int iColorFormat; ///< color space type - int iStride[4]; ///< stride for each plane pData - unsigned char* pData[4]; ///< plane pData - int iPicWidth; ///< luma picture width in x coordinate - int iPicHeight; ///< luma picture height in y coordinate - long long uiTimeStamp; ///< timestamp of the source picture, unit: millisecond -} SSourcePicture; -/** -* @brief Structure for bit rate info -*/ -typedef struct TagBitrateInfo { - LAYER_NUM iLayer; - int iBitrate; ///< the maximum bitrate -} SBitrateInfo; - -/** -* @brief Structure for dump layer info -*/ -typedef struct TagDumpLayer { - int iLayer; - char* pFileName; -} SDumpLayer; - -/** -* @brief Structure for profile info in layer -* -*/ -typedef struct TagProfileInfo { - int iLayer; - EProfileIdc uiProfileIdc; ///< the profile info -} SProfileInfo; - -/** -* @brief Structure for level info in layer -* -*/ -typedef struct TagLevelInfo { - int iLayer; - ELevelIdc uiLevelIdc; ///< the level info -} SLevelInfo; -/** -* @brief Structure for dilivery status -* -*/ -typedef struct TagDeliveryStatus { - bool bDeliveryFlag; ///< 0: the previous frame isn't delivered,1: the previous frame is delivered - int iDropFrameType; ///< the frame type that is dropped; reserved - int iDropFrameSize; ///< the frame size that is dropped; reserved -} SDeliveryStatus; - -/** -* @brief The capability of decoder, for SDP negotiation -*/ -typedef struct TagDecoderCapability { - int iProfileIdc; ///< profile_idc - int iProfileIop; ///< profile-iop - int iLevelIdc; ///< level_idc - int iMaxMbps; ///< max-mbps - int iMaxFs; ///< max-fs - int iMaxCpb; ///< max-cpb - int iMaxDpb; ///< max-dpb - int iMaxBr; ///< max-br - bool bRedPicCap; ///< redundant-pic-cap -} SDecoderCapability; - -/** -* @brief Structure for parse only output -*/ -typedef struct TagParserBsInfo { - int iNalNum; ///< total NAL number in current AU - int* pNalLenInByte; ///< each nal length - unsigned char* pDstBuff; ///< outputted dst buffer for parsed bitstream - int iSpsWidthInPixel; ///< required SPS width info - int iSpsHeightInPixel; ///< required SPS height info - unsigned long long uiInBsTimeStamp; ///< input BS timestamp - unsigned long long uiOutBsTimeStamp; ///< output BS timestamp -} SParserBsInfo, * PParserBsInfo; - -/** -* @brief Structure for encoder statistics -*/ -typedef struct TagVideoEncoderStatistics { - unsigned int uiWidth; ///< the width of encoded frame - unsigned int uiHeight; ///< the height of encoded frame - //following standard, will be 16x aligned, if there are multiple spatial, this is of the highest - float fAverageFrameSpeedInMs; ///< average_Encoding_Time - - // rate control related - float fAverageFrameRate; ///< the average frame rate in, calculate since encoding starts, supposed that the input timestamp is in unit of ms - float fLatestFrameRate; ///< the frame rate in, in the last second, supposed that the input timestamp is in unit of ms (? useful for checking BR, but is it easy to calculate? - unsigned int uiBitRate; ///< sendrate in Bits per second, calculated within the set time-window - unsigned int uiAverageFrameQP; ///< the average QP of last encoded frame - - unsigned int uiInputFrameCount; ///< number of frames - unsigned int uiSkippedFrameCount; ///< number of frames - - unsigned int uiResolutionChangeTimes; ///< uiResolutionChangeTimes - unsigned int uiIDRReqNum; ///< number of IDR requests - unsigned int uiIDRSentNum; ///< number of actual IDRs sent - unsigned int uiLTRSentNum; ///< number of LTR sent/marked - - long long iStatisticsTs; ///< Timestamp of updating the statistics - - unsigned long iTotalEncodedBytes; - unsigned long iLastStatisticsBytes; - unsigned long iLastStatisticsFrameCount; -} SEncoderStatistics; - -/** -* @brief Structure for decoder statistics -*/ -typedef struct TagVideoDecoderStatistics { - unsigned int uiWidth; ///< the width of encode/decode frame - unsigned int uiHeight; ///< the height of encode/decode frame - float fAverageFrameSpeedInMs; ///< average_Decoding_Time - float fActualAverageFrameSpeedInMs; ///< actual average_Decoding_Time, including freezing pictures - unsigned int uiDecodedFrameCount; ///< number of frames - unsigned int uiResolutionChangeTimes; ///< uiResolutionChangeTimes - unsigned int uiIDRCorrectNum; ///< number of correct IDR received - //EC on related - unsigned int - uiAvgEcRatio; ///< when EC is on, the average ratio of total EC areas, can be an indicator of reconstruction quality - unsigned int - uiAvgEcPropRatio; ///< when EC is on, the rough average ratio of propogate EC areas, can be an indicator of reconstruction quality - unsigned int uiEcIDRNum; ///< number of actual unintegrity IDR or not received but eced - unsigned int uiEcFrameNum; ///< - unsigned int uiIDRLostNum; ///< number of whole lost IDR - unsigned int - uiFreezingIDRNum; ///< number of freezing IDR with error (partly received), under resolution change - unsigned int uiFreezingNonIDRNum; ///< number of freezing non-IDR with error - int iAvgLumaQp; ///< average luma QP. default: -1, no correct frame outputted - int iSpsReportErrorNum; ///< number of Sps Invalid report - int iSubSpsReportErrorNum; ///< number of SubSps Invalid report - int iPpsReportErrorNum; ///< number of Pps Invalid report - int iSpsNoExistNalNum; ///< number of Sps NoExist Nal - int iSubSpsNoExistNalNum; ///< number of SubSps NoExist Nal - int iPpsNoExistNalNum; ///< number of Pps NoExist Nal - - unsigned int uiProfile; ///< Profile idc in syntax - unsigned int uiLevel; ///< level idc according to Annex A-1 - - int iCurrentActiveSpsId; ///< current active SPS id - int iCurrentActivePpsId; ///< current active PPS id - - unsigned int iStatisticsLogInterval; ///< frame interval of statistics log -} SDecoderStatistics; // in building, coming soon - -/** -* @brief Structure for sample aspect ratio (SAR) info in VUI -*/ -typedef struct TagVuiSarInfo { - unsigned int uiSarWidth; ///< SAR width - unsigned int uiSarHeight; ///< SAR height - bool bOverscanAppropriateFlag; ///< SAR overscan flag -} SVuiSarInfo, * PVuiSarInfo; - -#endif//WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__ \ No newline at end of file diff --git a/C++CLI/H264SharpCLI/codec_def.h b/C++CLI/H264SharpCLI/codec_def.h deleted file mode 100644 index 561796b..0000000 --- a/C++CLI/H264SharpCLI/codec_def.h +++ /dev/null @@ -1,216 +0,0 @@ -/*! - * \copy - * Copyright (c) 2013, Cisco Systems - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef WELS_VIDEO_CODEC_DEFINITION_H__ -#define WELS_VIDEO_CODEC_DEFINITION_H__ - - /** - * @file codec_def.h - */ - - /** - * @brief Enumerate the type of video format - */ -typedef enum { - videoFormatRGB = 1, ///< rgb color formats - videoFormatRGBA = 2, - videoFormatRGB555 = 3, - videoFormatRGB565 = 4, - videoFormatBGR = 5, - videoFormatBGRA = 6, - videoFormatABGR = 7, - videoFormatARGB = 8, - - videoFormatYUY2 = 20, ///< yuv color formats - videoFormatYVYU = 21, - videoFormatUYVY = 22, - videoFormatI420 = 23, ///< the same as IYUV - videoFormatYV12 = 24, - videoFormatInternal = 25, ///< only used in SVC decoder testbed - - videoFormatNV12 = 26, ///< new format for output by DXVA decoding - - videoFormatVFlip = 0x80000000 -} EVideoFormatType; - -/** -* @brief Enumerate video frame type -*/ -typedef enum { - videoFrameTypeInvalid, ///< encoder not ready or parameters are invalidate - videoFrameTypeIDR, ///< IDR frame in H.264 - videoFrameTypeI, ///< I frame type - videoFrameTypeP, ///< P frame type - videoFrameTypeSkip, ///< skip the frame based encoder kernel - videoFrameTypeIPMixed ///< a frame where I and P slices are mixing, not supported yet -} EVideoFrameType; - -/** -* @brief Enumerate return type -*/ -typedef enum { - cmResultSuccess, ///< successful - cmInitParaError, ///< parameters are invalid - cmUnknownReason, - cmMallocMemeError, ///< malloc a memory error - cmInitExpected, ///< initial action is expected - cmUnsupportedData -} CM_RETURN; - -/** -* @brief Enumulate the nal unit type -*/ -enum ENalUnitType { - NAL_UNKNOWN = 0, - NAL_SLICE = 1, - NAL_SLICE_DPA = 2, - NAL_SLICE_DPB = 3, - NAL_SLICE_DPC = 4, - NAL_SLICE_IDR = 5, ///< ref_idc != 0 - NAL_SEI = 6, ///< ref_idc == 0 - NAL_SPS = 7, - NAL_PPS = 8 - ///< ref_idc == 0 for 6,9,10,11,12 -}; - -/** -* @brief NRI: eNalRefIdc -*/ -enum ENalPriority { - NAL_PRIORITY_DISPOSABLE = 0, - NAL_PRIORITY_LOW = 1, - NAL_PRIORITY_HIGH = 2, - NAL_PRIORITY_HIGHEST = 3 -}; - -#define IS_PARAMETER_SET_NAL(eNalRefIdc, eNalType) \ -( (eNalRefIdc == NAL_PRIORITY_HIGHEST) && (eNalType == (NAL_SPS|NAL_PPS) || eNalType == NAL_SPS) ) - -#define IS_IDR_NAL(eNalRefIdc, eNalType) \ -( (eNalRefIdc == NAL_PRIORITY_HIGHEST) && (eNalType == NAL_SLICE_IDR) ) - -#define FRAME_NUM_PARAM_SET (-1) -#define FRAME_NUM_IDR 0 - -/** - * @brief eDeblockingIdc - */ -enum { - DEBLOCKING_IDC_0 = 0, - DEBLOCKING_IDC_1 = 1, - DEBLOCKING_IDC_2 = 2 -}; -#define DEBLOCKING_OFFSET (6) -#define DEBLOCKING_OFFSET_MINUS (-6) - -/* Error Tools definition */ -typedef unsigned short ERR_TOOL; - -/** - @brief to do -*/ -enum { - ET_NONE = 0x00, ///< NONE Error Tools - ET_IP_SCALE = 0x01, ///< IP Scalable - ET_FMO = 0x02, ///< Flexible Macroblock Ordering - ET_IR_R1 = 0x04, ///< Intra Refresh in predifined 2% MB - ET_IR_R2 = 0x08, ///< Intra Refresh in predifined 5% MB - ET_IR_R3 = 0x10, ///< Intra Refresh in predifined 10% MB - ET_FEC_HALF = 0x20, ///< Forward Error Correction in 50% redundency mode - ET_FEC_FULL = 0x40, ///< Forward Error Correction in 100% redundency mode - ET_RFS = 0x80 ///< Reference Frame Selection -}; - -/** -* @brief Information of coded Slice(=NAL)(s) -*/ -typedef struct SliceInformation { - unsigned char* pBufferOfSlices; ///< base buffer of coded slice(s) - int iCodedSliceCount; ///< number of coded slices - unsigned int* pLengthOfSlices; ///< array of slices length accordingly by number of slice - int iFecType; ///< FEC type[0, 50%FEC, 100%FEC] - unsigned char uiSliceIdx; ///< index of slice in frame [FMO: 0,..,uiSliceCount-1; No FMO: 0] - unsigned char uiSliceCount; ///< count number of slice in frame [FMO: 2-8; No FMO: 1] - char iFrameIndex; ///< index of frame[-1, .., idr_interval-1] - unsigned char uiNalRefIdc; ///< NRI, priority level of slice(NAL) - unsigned char uiNalType; ///< NAL type - unsigned char - uiContainingFinalNal; ///< whether final NAL is involved in buffer of coded slices, flag used in Pause feature in T27 -} SliceInfo, * PSliceInfo; - -/** -* @brief thresholds of the initial, maximal and minimal rate -*/ -typedef struct { - int iWidth; ///< frame width - int iHeight; ///< frame height - int iThresholdOfInitRate; ///< threshold of initial rate - int iThresholdOfMaxRate; ///< threshold of maximal rate - int iThresholdOfMinRate; ///< threshold of minimal rate - int iMinThresholdFrameRate; ///< min frame rate min - int iSkipFrameRate; ///< skip to frame rate min - int iSkipFrameStep; ///< how many frames to skip -} SRateThresholds, * PRateThresholds; - -/** -* @brief Structure for decoder memery -*/ -typedef struct TagSysMemBuffer { - int iWidth; ///< width of decoded pic for display - int iHeight; ///< height of decoded pic for display - int iFormat; ///< type is "EVideoFormatType" - int iStride[2]; ///< stride of 2 component -} SSysMEMBuffer; - -/** -* @brief Buffer info -*/ -typedef struct TagBufferInfo { - int iBufferStatus; ///< 0: one frame data is not ready; 1: one frame data is ready - unsigned long long uiInBsTimeStamp; ///< input BS timestamp - unsigned long long uiOutYuvTimeStamp; ///< output YUV timestamp, when bufferstatus is 1 - union { - SSysMEMBuffer sSystemBuffer; ///< memory info for one picture - } UsrData; ///< output buffer info - unsigned char* pDst[3]; //point to picture YUV data -} SBufferInfo; - - -/** -* @brief In a GOP, multiple of the key frame number, derived from -* the number of layers(index or array below) -*/ -static const char kiKeyNumMultiple[] = { - 1, 1, 2, 4, 8, 16, -}; - -#endif//WELS_VIDEO_CODEC_DEFINITION_H__ \ No newline at end of file diff --git a/C++CLI/H264SharpCLI/codec_ver.h b/C++CLI/H264SharpCLI/codec_ver.h deleted file mode 100644 index 575b4ca..0000000 --- a/C++CLI/H264SharpCLI/codec_ver.h +++ /dev/null @@ -1,15 +0,0 @@ -//The current file is auto-generated by script: generate_codec_ver.sh -#ifndef CODEC_VER_H -#define CODEC_VER_H - -#include "codec_app_def.h" - -static const H264SharpVersion g_stCodecVersion = { 2, 3, 0, 2206 }; -static const char* const g_strCodecVer = "H264Sharp version:2.3.0.2206"; - -#define OPENH264_MAJOR (2) -#define OPENH264_MINOR (3) -#define OPENH264_REVISION (0) -#define OPENH264_RESERVED (2206) - -#endif // CODEC_VER_H \ No newline at end of file diff --git a/C++CLI/H264SharpCLI/pch.cpp b/C++CLI/H264SharpCLI/pch.cpp deleted file mode 100644 index 34d0f10..0000000 --- a/C++CLI/H264SharpCLI/pch.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// pch.cpp: source file corresponding to the pre-compiled header -#include "pch.h" - -// When you are using pre-compiled headers, this source file is necessary for compilation to succeed. diff --git a/C++CLI/H264SharpCLI/pch.h b/C++CLI/H264SharpCLI/pch.h deleted file mode 100644 index e2af31d..0000000 --- a/C++CLI/H264SharpCLI/pch.h +++ /dev/null @@ -1,31 +0,0 @@ -// pch.h: This is a precompiled header file. -// Files listed below are compiled only once, improving build performance for future builds. -// This also affects IntelliSense performance, including code completion and many code browsing features. -// However, files listed here are ALL re-compiled if any one of them is updated between builds. -// Do not add files here that you will be updating frequently as this negates the performance advantage. - -#ifndef PCH_H -#define PCH_H -public enum class FrameType { Invalid, IDR, I, P, Skip, IPMixed }; - -// add headers that you want to pre-compile here -#include "Windows.h" -#include "codec_api.h" -#include "codec_app_def.h" -#include "codec_def.h" -#include "codec_ver.h" -#include "ImageTypes.h" -#include "ConverterLocal.h" - -static bool is64Bit() { - const int* pInt = nullptr; - if (sizeof(pInt) == 8) - { - return true; - } - else if (sizeof(pInt) == 4) - { - return false; - } -} -#endif //PCH_H \ No newline at end of file diff --git a/Examples/AVRecord/AVRecord.csproj b/Examples/AVRecord/AVRecord.csproj index 19f37ed..964c320 100644 --- a/Examples/AVRecord/AVRecord.csproj +++ b/Examples/AVRecord/AVRecord.csproj @@ -24,15 +24,9 @@ - - PreserveNewest - PreserveNewest - - PreserveNewest - diff --git a/Examples/AVRecord/H264SharpNative-win64.dll b/Examples/AVRecord/H264SharpNative-win64.dll deleted file mode 100644 index cd8f9cb..0000000 Binary files a/Examples/AVRecord/H264SharpNative-win64.dll and /dev/null differ diff --git a/Examples/AVRecord/MainWindow.xaml.cs b/Examples/AVRecord/MainWindow.xaml.cs index ae81aab..97abd0c 100644 --- a/Examples/AVRecord/MainWindow.xaml.cs +++ b/Examples/AVRecord/MainWindow.xaml.cs @@ -83,6 +83,7 @@ public MainWindow() param.iIdrBitrateRatio = 400; param.fMaxFrameRate = 30; + //encoder.SetOption(ENCODER_OPTION.ENCODER_OPTION_TRACE_LEVEL, TRACE_LEVEL.WELS_LOG_QUIET); encoder.Initialize(param); diff --git a/Examples/AVRecord/openh264-2.5.0-win64.dll b/Examples/AVRecord/openh264-2.5.0-win64.dll deleted file mode 100644 index 28eb46e..0000000 Binary files a/Examples/AVRecord/openh264-2.5.0-win64.dll and /dev/null differ diff --git a/Examples/H264SharpNativePInvoke/Program.cs b/Examples/H264SharpNativePInvoke/Program.cs index 04a4aa8..532f5d9 100644 --- a/Examples/H264SharpNativePInvoke/Program.cs +++ b/Examples/H264SharpNativePInvoke/Program.cs @@ -22,7 +22,6 @@ static void Main(string[] args) encoder.ConverterNumberOfThreads = 4; decoder.ConverterNumberOfThreads = 4; decoder.EnableSSEYUVConversion = true; - decoder.Initialize(); var img = System.Drawing.Image.FromFile("ocean 1920x1080.jpg"); //var img = System.Drawing.Image.FromFile("ocean 3840x2160.jpg"); @@ -30,7 +29,6 @@ static void Main(string[] args) int h = img.Height; var bmp = new Bitmap(img); Console.WriteLine($"{w}x{h}"); - encoder.Initialize(w, h, 200_000_000, 30, ConfigType.CameraBasic); Console.WriteLine("Initialised Encoder"); diff --git a/H264Sharp/H264Sharp.csproj b/H264Sharp/H264Sharp.csproj index d95ac81..2051b5c 100644 --- a/H264Sharp/H264Sharp.csproj +++ b/H264Sharp/H264Sharp.csproj @@ -5,7 +5,7 @@ True True H264Sharp - 1.4.0 + 1.4.1 https://github.com/ReferenceType/H264Sharp ReferenceType https://github.com/ReferenceType/H264Sharp @@ -22,6 +22,8 @@ Licence.txt true True + False + bin\Release\netstandard2.0\MyKey.snk @@ -53,6 +55,15 @@ \ + + + + Always + + + Always + + diff --git a/H264Sharp/runtimes/linux32/native/H264SharpNative-linux32.so b/H264Sharp/runtimes/linux32/native/H264SharpNative-linux32.so deleted file mode 100644 index 5b3a3f8..0000000 Binary files a/H264Sharp/runtimes/linux32/native/H264SharpNative-linux32.so and /dev/null differ diff --git a/H264Sharp/runtimes/linux64/native/H264SharpNative-linux64.so b/H264Sharp/runtimes/linux64/native/H264SharpNative-linux64.so index fef8cdb..7102159 100644 Binary files a/H264Sharp/runtimes/linux64/native/H264SharpNative-linux64.so and b/H264Sharp/runtimes/linux64/native/H264SharpNative-linux64.so differ diff --git a/H264Sharp/runtimes/linux86/native/H264SharpNative-linux32.so b/H264Sharp/runtimes/linux86/native/H264SharpNative-linux32.so new file mode 100644 index 0000000..54a82f1 Binary files /dev/null and b/H264Sharp/runtimes/linux86/native/H264SharpNative-linux32.so differ diff --git a/H264Sharp/runtimes/linux32/native/libopenh264-2.4.1-linux32.7.so b/H264Sharp/runtimes/linux86/native/libopenh264-2.4.1-linux32.7.so similarity index 100% rename from H264Sharp/runtimes/linux32/native/libopenh264-2.4.1-linux32.7.so rename to H264Sharp/runtimes/linux86/native/libopenh264-2.4.1-linux32.7.so diff --git a/H264Sharp/runtimes/win-x64/native/H264SharpNative-win64.dll b/H264Sharp/runtimes/win-x64/native/H264SharpNative-win64.dll index cd8f9cb..efdafc3 100644 Binary files a/H264Sharp/runtimes/win-x64/native/H264SharpNative-win64.dll and b/H264Sharp/runtimes/win-x64/native/H264SharpNative-win64.dll differ diff --git a/H264Sharp/runtimes/win-x86/native/H264SharpNative-win32.dll b/H264Sharp/runtimes/win-x86/native/H264SharpNative-win32.dll index a2a128e..2dfda8a 100644 Binary files a/H264Sharp/runtimes/win-x86/native/H264SharpNative-win32.dll and b/H264Sharp/runtimes/win-x86/native/H264SharpNative-win32.dll differ diff --git a/H264SharpNative/CMakeLists.txt b/H264SharpNative/CMakeLists.txt index fe0044a..39237bb 100644 --- a/H264SharpNative/CMakeLists.txt +++ b/H264SharpNative/CMakeLists.txt @@ -55,7 +55,8 @@ if (CMAKE_VERSION VERSION_GREATER 3.12) set_property(TARGET CMakeProject1 PROPERTY CXX_STANDARD 17) endif() #output name -#H264SharpNative-linux64.so +#H264SharpNative-linux64.so +#H264SharpNative-linux64.so set_target_properties(CMakeProject1 PROPERTIES PREFIX "") set_target_properties(CMakeProject1 PROPERTIES OUTPUT_NAME "H264SharpNative-linux64") diff --git a/H264SharpNative/Encoder.cpp b/H264SharpNative/Encoder.cpp index a28188a..0164158 100644 --- a/H264SharpNative/Encoder.cpp +++ b/H264SharpNative/Encoder.cpp @@ -457,6 +457,7 @@ namespace H264Sharp { void Encoder::PrintParam(const TagEncParamExt& param) { + return; std::cout << "iUsageType" << " " << param.iUsageType << "\n"; std::cout << "iPicWidth" << " " << param.iPicWidth << "\n"; std::cout << "iPicHeight" << " " << param.iPicHeight << "\n";