From be86554e656212868188b26156247839fd9d7c58 Mon Sep 17 00:00:00 2001 From: OKA Motofumi Date: Thu, 1 Sep 2016 03:47:42 +0900 Subject: [PATCH] version 0.1.1 --- build/msvcX/DGDecode/DGDecode.vcxproj | 3 +++ src/dgdecode/AVISynthAPI.cpp | 30 ++++++++++----------------- src/dgdecode/MPEG2Decoder.h | 3 +-- src/dgdecode/idct_llm_float_avx2.cpp | 4 ++++ src/dgdecode/misc.cpp | 5 +++-- src/dgdecode/misc.h | 7 ++++--- src/dgdecode/vfapidec.cpp | 23 +++++++++----------- 7 files changed, 36 insertions(+), 39 deletions(-) diff --git a/build/msvcX/DGDecode/DGDecode.vcxproj b/build/msvcX/DGDecode/DGDecode.vcxproj index 5229462..903c792 100644 --- a/build/msvcX/DGDecode/DGDecode.vcxproj +++ b/build/msvcX/DGDecode/DGDecode.vcxproj @@ -82,6 +82,7 @@ false + $(ProjectName)64 @@ -127,6 +128,8 @@ AnySuitable StreamingSIMDExtensions2 Fast + true + Speed Windows diff --git a/src/dgdecode/AVISynthAPI.cpp b/src/dgdecode/AVISynthAPI.cpp index 5af8004..791e99b 100644 --- a/src/dgdecode/AVISynthAPI.cpp +++ b/src/dgdecode/AVISynthAPI.cpp @@ -37,7 +37,7 @@ #include "idct.h" -#define VERSION "MPEG2DecPlus 0.1.0" +#define VERSION "MPEG2DecPlus 0.1.1" MPEG2Source::MPEG2Source(const char* d2v, int cpu, int idct, int iPP, @@ -49,11 +49,6 @@ MPEG2Source::MPEG2Source(const char* d2v, int cpu, int idct, int iPP, { int status; - /* override */ - m_decoder.refinit = false; - m_decoder.fpuinit = false; - m_decoder.luminit = false; - //if (iPP != -1 && iPP != 0 && iPP != 1) // env->ThrowError("MPEG2Source: iPP must be set to -1, 0, or 1!"); @@ -214,9 +209,6 @@ void MPEG2Source::override(int ovr_idct) constexpr uint32_t MAGIC_NUMBER = 0xdeadbeef; -constexpr uint32_t PROGRESSIVE = 0x00000001; -constexpr int COLORIMETRY_SHIFT = 2; - bool PutHintingData(uint8_t *video, uint32_t hint) { @@ -282,7 +274,7 @@ PVideoFrame __stdcall MPEG2Source::GetFrame(int n, IScriptEnvironment* env) PVideoFrame frame = env->NewVideoFrame(vi); YV12PICT out = {}; - if (m_decoder.upConv != 2) { // YV12 || YV16 + if (m_decoder.upConv != 2) { // YV12 or YV16 output out.y = frame->GetWritePtr(PLANAR_Y); out.u = frame->GetWritePtr(PLANAR_U); out.v = frame->GetWritePtr(PLANAR_V); @@ -292,7 +284,7 @@ PVideoFrame __stdcall MPEG2Source::GetFrame(int n, IScriptEnvironment* env) out.uvwidth = frame->GetRowSize(PLANAR_U); out.yheight = frame->GetHeight(PLANAR_Y); out.uvheight = frame->GetHeight(PLANAR_V); - } else { + } else { // YV24 output out.y = bufY; out.u = bufU; out.v = bufV; @@ -354,8 +346,7 @@ PVideoFrame __stdcall MPEG2Source::GetFrame(int n, IScriptEnvironment* env) } } - if (m_decoder.info == 1) - { + if (m_decoder.info == 1) { char msg1[1024]; sprintf(msg1,"%s\n" "---------------------------------------\n" @@ -393,9 +384,8 @@ PVideoFrame __stdcall MPEG2Source::GetFrame(int n, IScriptEnvironment* env) Matrix_s, m_decoder.GOPList[gop]->matrix, m_decoder.avgquant, m_decoder.minquant, m_decoder.maxquant); env->ApplyMessage(&frame, vi, msg1, 150, 0xdfffbf, 0x0, 0x0); - } - else if (m_decoder.info == 2) - { + + } else if (m_decoder.info == 2) { dprintf("MPEG2DecPlus: %s\n", VERSION); dprintf("MPEG2DecPlus: Source: %s\n", m_decoder.Infilename[m_decoder.GOPList[gop]->file]); dprintf("MPEG2DecPlus: Frame Rate: %3.6f fps (%u/%u) %s\n", @@ -414,9 +404,11 @@ PVideoFrame __stdcall MPEG2Source::GetFrame(int n, IScriptEnvironment* env) dprintf("MPEG2DecPlus: Progressive Frame: %s\n", m_decoder.FrameList[raw].pf ? "True" : "False"); dprintf("MPEG2DecPlus: Colorimetry: %s (%d)\n", Matrix_s, m_decoder.GOPList[gop]->matrix); dprintf("MPEG2DecPlus: Quants: %d/%d/%d (avg/min/max)\n", m_decoder.avgquant, m_decoder.minquant, m_decoder.maxquant); - } - else if (m_decoder.info == 3) - { + + } else if (m_decoder.info == 3) { + constexpr uint32_t PROGRESSIVE = 0x00000001; + constexpr int COLORIMETRY_SHIFT = 2; + hint = 0; if (m_decoder.FrameList[raw].pf == 1) hint |= PROGRESSIVE; hint |= ((m_decoder.GOPList[gop]->matrix & 7) << COLORIMETRY_SHIFT); diff --git a/src/dgdecode/MPEG2Decoder.h b/src/dgdecode/MPEG2Decoder.h index 97cfb5b..414449a 100644 --- a/src/dgdecode/MPEG2Decoder.h +++ b/src/dgdecode/MPEG2Decoder.h @@ -140,7 +140,6 @@ class MPEG2DEC_API CMPEG2Decoder friend class MPEG2Source; protected: - bool refinit,fpuinit,luminit; int moderate_h, moderate_v, pp_mode; // getbit.cpp @@ -282,7 +281,7 @@ class MPEG2DEC_API CMPEG2Decoder // global values uint8_t *backward_reference_frame[3], *forward_reference_frame[3]; uint8_t *auxframe[3], *current_frame[3]; - uint8_t *u422, *v422; + // uint8_t *u422, *v422; YV12PICT *auxFrame1; YV12PICT *auxFrame2; YV12PICT *saved_active; diff --git a/src/dgdecode/idct_llm_float_avx2.cpp b/src/dgdecode/idct_llm_float_avx2.cpp index 8a468b4..763d0a6 100644 --- a/src/dgdecode/idct_llm_float_avx2.cpp +++ b/src/dgdecode/idct_llm_float_avx2.cpp @@ -1,3 +1,7 @@ +#ifndef __AVX2__ +#error arch:avx2 is not set. +#endif + #include #include "idct.h" diff --git a/src/dgdecode/misc.cpp b/src/dgdecode/misc.cpp index e1862d3..5b19b41 100644 --- a/src/dgdecode/misc.cpp +++ b/src/dgdecode/misc.cpp @@ -45,8 +45,9 @@ size_t __cdecl dprintf(char* fmt, ...) } -void fast_copy(const uint8_t* src, const int src_stride, uint8_t* dst, const int dst_stride, - const int horizontal_size, int vertical_size) noexcept +void __stdcall +fast_copy(const uint8_t* src, const int src_stride, uint8_t* dst, + const int dst_stride, const int horizontal_size, int vertical_size) noexcept { if (vertical_size == 0) { return; diff --git a/src/dgdecode/misc.h b/src/dgdecode/misc.h index d707c6b..902263b 100644 --- a/src/dgdecode/misc.h +++ b/src/dgdecode/misc.h @@ -28,9 +28,10 @@ #include #include -void fast_copy(const uint8_t *src, const int src_stride, uint8_t *dst, - const int dst_stride, const int horizontal_size, - const int vertical_size) noexcept; +void __stdcall +fast_copy(const uint8_t *src, const int src_stride, uint8_t *dst, + const int dst_stride, const int horizontal_size, + const int vertical_size) noexcept; size_t __cdecl dprintf(char* fmt, ...); diff --git a/src/dgdecode/vfapidec.cpp b/src/dgdecode/vfapidec.cpp index da49622..c1991c1 100644 --- a/src/dgdecode/vfapidec.cpp +++ b/src/dgdecode/vfapidec.cpp @@ -69,7 +69,7 @@ CMPEG2Decoder::CMPEG2Decoder() i420 = false; pc_scale = 1; maxquant = minquant = avgquant = 0; - u422 = v422 = NULL; + //u422 = v422 = NULL; DirectAccess = NULL; FrameList = NULL; GOPList = NULL; @@ -246,9 +246,9 @@ int CMPEG2Decoder::Open(const char *path) // these are labeled u422 and v422, but I'm only using them as a temporary // storage place for YV12 chroma before upsampling to 4:2:2 so that's why its // /4 and not /2 -- (tritical - 1/05/2005) - int tpitch = (((Chroma_Width+15)>>4)<<4); // mod 16 chroma pitch needed to work with YV12PICTs - u422 = (unsigned char*)_aligned_malloc((tpitch * Coded_Picture_Height / 2)+2048, 32); - v422 = (unsigned char*)_aligned_malloc((tpitch * Coded_Picture_Height / 2)+2048, 32); + // int tpitch = (((Chroma_Width+15)>>4)<<4); // mod 16 chroma pitch needed to work with YV12PICTs + // u422 = (unsigned char*)_aligned_malloc((tpitch * Coded_Picture_Height / 2)+2048, 32); + // v422 = (unsigned char*)_aligned_malloc((tpitch * Coded_Picture_Height / 2)+2048, 32); auxFrame1 = create_YV12PICT(Coded_Picture_Height,Coded_Picture_Width,chroma_format+1); auxFrame2 = create_YV12PICT(Coded_Picture_Height,Coded_Picture_Width,chroma_format+1); } @@ -826,16 +826,13 @@ __except(EXCEPTION_EXECUTE_HANDLER) void CMPEG2Decoder::Close() { int i; - CMPEG2Decoder* in = this; - if (in->VF_File) - { - fclose(in->VF_File); - in->VF_File = NULL; + if (VF_File) { + fclose(VF_File); + VF_File = NULL; } - while (File_Limit) - { + while (File_Limit) { File_Limit--; _close(Infile[File_Limit]); _aligned_free(Infilename[File_Limit]); @@ -852,8 +849,8 @@ void CMPEG2Decoder::Close() _aligned_free(backwardQP); _aligned_free(auxQP); - if (u422 != NULL) _aligned_free(u422); - if (v422 != NULL) _aligned_free(v422); + // if (u422 != NULL) _aligned_free(u422); + // if (v422 != NULL) _aligned_free(v422); destroy_YV12PICT(auxFrame1); destroy_YV12PICT(auxFrame2);