Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSFilter: misc colour changes #23

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 48 additions & 48 deletions src/dsutil/DSUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "Mpeg2Def.h"
#include "vd.h"
#include "..\..\..\include\moreuuids.h"
#include <emmintrin.h>
#include <emmintrin.h>
#include <math.h>
#include <InitGuid.h>
#include <d3d9types.h>
Expand Down Expand Up @@ -928,53 +928,53 @@ REFERENCE_TIME HMSF2RT(DVD_HMSF_TIMECODE hmsf, double fps)
return (REFERENCE_TIME)((((REFERENCE_TIME)hmsf.bHours*60+hmsf.bMinutes)*60+hmsf.bSeconds)*1000+1.0*hmsf.bFrames*1000/fps)*10000;
}

void memsetd(void* dst, unsigned int c, size_t nbytes)
{
#ifndef _WIN64
if (!(g_cpuid.m_flags & g_cpuid.sse2)) {
__asm {
mov eax, c
mov ecx, nbytes
shr ecx, 2
mov edi, dst
cld
rep stosd
}
return;
}
#endif
size_t n = nbytes / 4;
size_t o = n - (n % 4);

__m128i val = _mm_set1_epi32 ( (int)c );
if (((uintptr_t)dst & 0x0F) == 0) { // 16-byte aligned
for (size_t i = 0; i < o; i+=4) {
_mm_store_si128( (__m128i*)&(((DWORD*)dst)[i]), val );
}
} else {
for (size_t i = 0; i < o; i+=4) {
_mm_storeu_si128( (__m128i*)&(((DWORD*)dst)[i]), val );
}
}

switch(n - o) {
case 3:
((DWORD*)dst)[o + 2] = c;
case 2:
((DWORD*)dst)[o + 1] = c;
case 1:
((DWORD*)dst)[o + 0] = c;
}
}

void memsetw(void* dst, unsigned short c, size_t nbytes)
{
memsetd(dst, c << 16 | c, nbytes);

size_t n = nbytes / 2;
size_t o = (n / 2) * 2;
if ((n - o) == 1) {
((WORD*)dst)[o] = c;
void memsetd(void* dst, unsigned int c, size_t nbytes)
{
#ifndef _WIN64
if (!(g_cpuid.m_flags & g_cpuid.sse2)) {
__asm {
mov eax, c
mov ecx, nbytes
shr ecx, 2
mov edi, dst
cld
rep stosd
}
return;
}
#endif
size_t n = nbytes / 4;
size_t o = n - (n % 4);
__m128i val = _mm_set1_epi32 ( (int)c );
if (((uintptr_t)dst & 0x0F) == 0) { // 16-byte aligned
for (size_t i = 0; i < o; i+=4) {
_mm_store_si128( (__m128i*)&(((DWORD*)dst)[i]), val );
}
} else {
for (size_t i = 0; i < o; i+=4) {
_mm_storeu_si128( (__m128i*)&(((DWORD*)dst)[i]), val );
}
}
switch(n - o) {
case 3:
((DWORD*)dst)[o + 2] = c;
case 2:
((DWORD*)dst)[o + 1] = c;
case 1:
((DWORD*)dst)[o + 0] = c;
}
}
void memsetw(void* dst, unsigned short c, size_t nbytes)
{
memsetd(dst, c << 16 | c, nbytes);
size_t n = nbytes / 2;
size_t o = (n / 2) * 2;
if ((n - o) == 1) {
((WORD*)dst)[o] = c;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/dsutil/DSUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ extern CString GetDriveLabel(TCHAR drive);
extern bool GetKeyFrames(CString fn, CUIntArray& kfs);
extern DVD_HMSF_TIMECODE RT2HMSF(REFERENCE_TIME rt, double fps = 0);
extern REFERENCE_TIME HMSF2RT(DVD_HMSF_TIMECODE hmsf, double fps = 0);
extern void memsetd(void* dst, unsigned int c, size_t nbytes);
extern void memsetw(void* dst, unsigned short c, size_t nbytes);
extern void memsetd(void* dst, unsigned int c, size_t nbytes);
extern void memsetw(void* dst, unsigned short c, size_t nbytes);
extern bool ExtractBIH(const AM_MEDIA_TYPE* pmt, BITMAPINFOHEADER* bih);
extern bool ExtractBIH(IMediaSample* pMS, BITMAPINFOHEADER* bih);
extern bool ExtractDim(const AM_MEDIA_TYPE* pmt, int& w, int& h, int& arx, int& ary);
Expand Down
110 changes: 55 additions & 55 deletions src/dsutil/xy_utils.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "stdafx.h"
#include "xy_utils.h"
#include <vector>
#include <algorithm>

void MergeRects(const CAtlList<CRect>& input, CAtlList<CRect>* output)
{
#include "stdafx.h"
#include "xy_utils.h"
#include <vector>
#include <algorithm>
void MergeRects(const CAtlList<CRect>& input, CAtlList<CRect>* output)
{
if(output==NULL || input.GetCount()==0)
return;

Expand Down Expand Up @@ -105,51 +105,51 @@ void MergeRects(const CAtlList<CRect>& input, CAtlList<CRect>* output)
tempSegments[start].seg_end=rect.right;
}
}
}
for (int i=count-1;i>0;i--)
{
CAtlList<CRect>& cur_line = *tempSegments[i].rects;
CRect cur_rect = cur_line.RemoveTail();
if(tempSegments[i].top == tempSegments[i-1].bottom)
{
CAtlList<CRect>& upper_line = *tempSegments[i-1].rects;

POSITION pos = upper_line.GetTailPosition();
while(pos)
{
CRect& upper_rect = upper_line.GetPrev(pos);
while( upper_rect.right<cur_rect.right || upper_rect.left<cur_rect.left )
{
output->AddHead(cur_rect);
//if(!cur_line.IsEmpty())
cur_rect = cur_line.RemoveTail();
}
if(cur_line.IsEmpty())
break;

if(upper_rect.right==cur_rect.right && upper_rect.left==cur_rect.left)
{
upper_rect.bottom = cur_rect.bottom;
//if(!cur_line.IsEmpty())
cur_rect = cur_line.RemoveTail();
}
//else if ( upper_rect.right>cur_rect.right || upper_rect.left>cur_rect.left )
}
}
while(!cur_line.IsEmpty())
{
output->AddHead(cur_rect);
cur_rect = cur_line.RemoveTail();
}
}
if(count>0)
{
CAtlList<CRect>& cur_line = *tempSegments[0].rects;
CRect cur_rect = cur_line.RemoveTail();
while(!cur_line.IsEmpty())
{
output->AddHead(cur_rect);
cur_rect = cur_line.RemoveTail();
}
}
}
}
for (int i=count-1;i>0;i--)
{
CAtlList<CRect>& cur_line = *tempSegments[i].rects;
CRect cur_rect = cur_line.RemoveTail();
if(tempSegments[i].top == tempSegments[i-1].bottom)
{
CAtlList<CRect>& upper_line = *tempSegments[i-1].rects;
POSITION pos = upper_line.GetTailPosition();
while(pos)
{
CRect& upper_rect = upper_line.GetPrev(pos);
while( upper_rect.right<cur_rect.right || upper_rect.left<cur_rect.left )
{
output->AddHead(cur_rect);
//if(!cur_line.IsEmpty())
cur_rect = cur_line.RemoveTail();
}
if(cur_line.IsEmpty())
break;
if(upper_rect.right==cur_rect.right && upper_rect.left==cur_rect.left)
{
upper_rect.bottom = cur_rect.bottom;
//if(!cur_line.IsEmpty())
cur_rect = cur_line.RemoveTail();
}
//else if ( upper_rect.right>cur_rect.right || upper_rect.left>cur_rect.left )
}
}
while(!cur_line.IsEmpty())
{
output->AddHead(cur_rect);
cur_rect = cur_line.RemoveTail();
}
}
if(count>0)
{
CAtlList<CRect>& cur_line = *tempSegments[0].rects;
CRect cur_rect = cur_line.RemoveTail();
while(!cur_line.IsEmpty())
{
output->AddHead(cur_rect);
cur_rect = cur_line.RemoveTail();
}
}
}
10 changes: 5 additions & 5 deletions src/filters/transform/vsfilter/Copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
_T(" bitmap :%ld/%ld/%ld\t\t")\
_T(" scan line:%ld/%ld/%ld\n")\
_T(" relay key:%ld/%ld/%ld\t\t")\
_T(" clipper :%ld/%ld/%ld\n")\
_T("\n")\
_T(" clipper :%ld/%ld/%ld\n")\
_T("\n")\
_T(" FW string pool :%ld/%ld/%ld\t\t")\
_T(" FW bitmap key pool:%ld/%ld/%ld\n")\
_T(" FW bitmap key pool:%ld/%ld/%ld\n")\
,
caches_info->text_info_cache_cur_item_num, caches_info->text_info_cache_hit_count, caches_info->text_info_cache_query_count,
caches_info->word_info_cache_cur_item_num, caches_info->word_info_cache_hit_count, caches_info->word_info_cache_query_count,
Expand All @@ -322,9 +322,9 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
caches_info->scanline_cache_cur_item_num, caches_info->scanline_cache_hit_count, caches_info->scanline_cache_query_count,
caches_info->overlay_key_cache_cur_item_num, caches_info->overlay_key_cache_hit_count, caches_info->overlay_key_cache_query_count,
caches_info->clipper_cache_cur_item_num, caches_info->clipper_cache_hit_count, caches_info->clipper_cache_query_count,

xy_fw_info->xy_fw_string_w.cur_item_num, xy_fw_info->xy_fw_string_w.hit_count, xy_fw_info->xy_fw_string_w.query_count,
xy_fw_info->xy_fw_grouped_draw_items_hash_key.cur_item_num, xy_fw_info->xy_fw_grouped_draw_items_hash_key.hit_count, xy_fw_info->xy_fw_grouped_draw_items_hash_key.query_count
xy_fw_info->xy_fw_grouped_draw_items_hash_key.cur_item_num, xy_fw_info->xy_fw_grouped_draw_items_hash_key.hit_count, xy_fw_info->xy_fw_grouped_draw_items_hash_key.query_count
);
msg += tmp;
delete []caches_info;
Expand Down
20 changes: 16 additions & 4 deletions src/filters/transform/vsfilter/DirectVobSubFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2287,10 +2287,22 @@ void CDirectVobSubFilter::SetYuvMatrix()
}
else
{
yuv_matrix = (extformat.VideoTransferMatrix == DXVA2_VideoTransferMatrix_BT709 ||
extformat.VideoTransferMatrix == DXVA2_VideoTransferMatrix_SMPTE240M ||
m_xy_size_opt[SIZE_ORIGINAL_VIDEO].cx > m_bt601Width ||
m_xy_size_opt[SIZE_ORIGINAL_VIDEO].cy > m_bt601Height) ? ColorConvTable::BT709 : ColorConvTable::BT601;
switch (extformat.VideoTransferMatrix)
{
// FIXME: ColorConvTable doesn't support SMPTE240M.
// Since it's more similar to BT709 than BT601, prefer the former.
case DXVA2_VideoTransferMatrix_SMPTE240M: // -fallthrough
case DXVA2_VideoTransferMatrix_BT709:
yuv_matrix = ColorConvTable::BT709;
break;
case DXVA2_VideoTransferMatrix_BT601:
yuv_matrix = ColorConvTable::BT601;
TheOneric marked this conversation as resolved.
Show resolved Hide resolved
break;
default:
yuv_matrix = (m_xy_size_opt[SIZE_ORIGINAL_VIDEO].cx > m_bt601Width ||
m_xy_size_opt[SIZE_ORIGINAL_VIDEO].cy > m_bt601Height) ?
ColorConvTable::BT709 : ColorConvTable::BT601;
}
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/filters/transform/vsfilter/IDirectVobSubXy.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ namespace DirectVobSubXyOptions
struct XyFlyWeightInfo
{
CacheInfo xy_fw_string_w;
CacheInfo xy_fw_grouped_draw_items_hash_key;
CacheInfo xy_fw_grouped_draw_items_hash_key;
};
enum LayoutSizeOpt
{
Expand Down
21 changes: 12 additions & 9 deletions src/filters/transform/vsfilter/csriapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,13 @@ CSRIAPI int csri_request_fmt(csri_inst *inst, const struct csri_fmt *fmt)
// Check if pixel format is supported
switch (fmt->pixfmt) {
case CSRI_F_BGR_:
case CSRI_F_BGR:
case CSRI_F_YUY2:
case CSRI_F_YV12:
case CSRI_F_BGRA:
inst->pixfmt = fmt->pixfmt;
break;

case CSRI_F_BGR: // guliverkli2-VSFilter and old xy-VSFilter used to
case CSRI_F_YUY2: // support those formats, but they were dropped in
case CSRI_F_YV12: // 50d3b3b7ab712ee2419f48de14db1b01a8406e43
default:
return -1;
}
Expand All @@ -136,19 +137,21 @@ CSRIAPI void csri_render(csri_inst *inst, struct csri_frame *frame, double time)
spd.w = inst->screen_res.cx;
spd.h = inst->screen_res.cy;
switch (inst->pixfmt) {
// xy-VSFilter treats BGR_ as having an alpha channel since 2014,
// specifically commit 6a6f7cb39a446aa761abe40ffc94d659fe4a4c3f
case CSRI_F_BGR_:
case CSRI_F_BGRA:
spd.type = MSP_RGBA;
spd.bpp = 32;
spd.bits = frame->planes[0];
spd.pitch = frame->strides[0];
break;

default:
ASSERT(0);
CString msg;
msg.Format(_T("Anything other then RGB32 is NOT supported!"));
MessageBox(NULL, msg, _T("Warning"), MB_OKCANCEL|MB_ICONWARNING);
int o = 0; o=o/o;
ASSERT(0);
CString msg;
msg.Format(_T("Anything other than BGR(A)32 is NOT supported!"));
MessageBox(NULL, msg, _T("Warning"), MB_OKCANCEL|MB_ICONWARNING);
return;
}
spd.vidrect = inst->video_rect;
Expand Down Expand Up @@ -176,4 +179,4 @@ static struct csri_info csri_vsfilter_info = {
CSRIAPI struct csri_info *csri_renderer_info(csri_rend *rend) { return &csri_vsfilter_info; }
CSRIAPI csri_rend *csri_renderer_byname(const char *name, const char *specific) { return &csri_vsfilter; }
CSRIAPI csri_rend *csri_renderer_default() { return &csri_vsfilter; }
CSRIAPI csri_rend *csri_renderer_next(csri_rend *prev) { return 0; }
CSRIAPI csri_rend *csri_renderer_next(csri_rend *prev) { return 0; }
8 changes: 4 additions & 4 deletions src/filters/transform/vsfilter/once_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class OnceLogger

s_entered[id]++;
if(logger.isEnabledFor(TRACE_LOG_LEVEL))
{
{
std::wostringstream buff;
buff<<LOG4CPLUS_TEXT("ENTER :")<<msg;
// logger.forcedLog(TRACE_LOG_LEVEL, LOG4CPLUS_TEXT("ENTER at ")<<_start<<LOG4CPLUS_TEXT(" ms: ")<<msg, file, line);
Expand All @@ -51,9 +51,9 @@ class OnceLogger
static int s_entered[256];
int id;

log4cplus::Logger logger;
log4cplus::tstring msg;
const char* file;
log4cplus::Logger logger;
log4cplus::tstring msg;
const char* file;
int line;
};

Expand Down
Loading