예제 #1
0
void TdeinterlacePage::init(void)
{
    panel = NULL;
    dscalerstart = 0;
    place = GetDlgItem(m_hwnd, IDC_PLC_DEINT);
    RECT parentr;
    GetWindowRect(m_hwnd, &parentr);
    GetWindowRect(place, &placer);
    OffsetRect(&placer, -parentr.left, -parentr.top);
    cbxSetDroppedWidth(IDC_CBX_DEINT_METHOD, 300);
    const char_t *dsflnm = cfgGetStr(IDFF_dscalerDIflnm);
    const char_t *dsdir = cfgGetStr(IDFF_dscalerPath);
    if (dsdir[0] == '\0' && dsflnm[0] != '\0') {
        char_t dsdir1[MAX_PATH];
        extractfilepath(dsflnm, dsdir1);
        cfgSet(IDFF_dscalerPath, dsdir1);
    }
}
예제 #2
0
bool TsubtitlesFile::init(const TsubtitlesSettings *cfg, const char_t *IsubFlnm, double Ifps, bool watch, int checkOnly)
{
    if (!cfg->is || !cfg->isSubFiles) {
        DPRINTF(_l("TsubtitlesFile::init subtitles files disabled is(%d), isSubFiles(%d)"), cfg->is, cfg->isSubFiles);
        return false;
    }

    if (!IsubFlnm || (checkOnly == 2 || stricmp(subFlnm, IsubFlnm) != 0)) {
        ff_strncpy(subFlnm, IsubFlnm ? IsubFlnm : _l(""), countof(subFlnm));
    }
    if (checkOnly < 2) {
        fps = Ifps;
        done();
    }
    if (subFlnm[0] == '\0') {
        return false;
    }
    if (f != NULL) {
        fclose(f);
        f = NULL;
    }
    f = fopen(subFlnm, _l("rb"));
    if (!f) {
        return false;
    }
    fs = TstreamFile(f, TfontSettings::GDI_charset_to_code_page(deci->getParam2(IDFF_fontCharset)));
    sub_format = Tsubreader::sub_autodetect(fs, ffcfg);
    if (sub_format != Tsubreader::SUB_INVALID && checkOnly != 2) {
        fs.rewind();
        if ((sub_format & Tsubreader::SUB_FORMATMASK) == Tsubreader::SUB_PGS) {
            if (!cfg->pgs) {
                DPRINTF(_l("TsubtitlesFile::init Blu-Ray subtitles detected but disabled by user"));
                return false;
            }
            DPRINTF(_l("TsubtitlesFile::init Blu-Ray subtitles detected"));
            subs = new TsubreaderPGS(deci, fs, fps, cfg, ffcfg);
        } else if ((sub_format & Tsubreader::SUB_FORMATMASK) == Tsubreader::SUB_VOBSUB) {
            if (cfg->vobsub) {
                subs = new TsubreaderVobsub(fs,subFlnm,deci);
                int deflang = subs->findlang(cfg->deflang);
                if (deflang == 0) {
                    deflang = subs->findlang(cfg->deflang2);
                }
                subs->setLang(deflang);
            }
        } else {
            if ((sub_format & Tsubreader::SUB_FORMATMASK) == Tsubreader::SUB_SSA && !deci->getParam2(IDFF_subSSA)) {
                DPRINTF(_l("TsubtitlesFile::init SSA subtitles detected but disabled by user"));
                return false;
            }
            if (((sub_format & Tsubreader::SUB_FORMATMASK) == Tsubreader::SUB_SUBVIEWER
                    || (sub_format & Tsubreader::SUB_FORMATMASK) == Tsubreader::SUB_SUBVIEWER2) && !cfg->isSubText) {
                DPRINTF(_l("TsubtitlesFile::init text subtitles detected but disabled by user"));
                return false;
            }
            DPRINTF(_l("TsubtitlesFile::init text subtitles detected"));
            subs = new TsubreaderMplayer(fs, sub_format, fps, cfg, ffcfg, false);
        }
    }
    // Keep the file descriptor opened if SUB_KEEP_FILE_OPENED flag is present
    if ((sub_format & Tsubreader::SUB_KEEP_FILE_OPENED) == 0) {
        fclose(f);
        f = NULL;
    }
    if (checkOnly == 2) {
        return sub_format != Tsubreader::SUB_INVALID;
    }

    // We can have empty subtitles if the file is read progressively
    if (!subs || (subs->empty() && ((sub_format & Tsubreader::SUB_KEEP_FILE_OPENED) == 0))) {
        if (subs) {
            delete subs;
        }
        subs = NULL;
        subFlnm[0] = '\0';
        return false;
    }
    if (!checkOnly) {
        //subs->adjust_subs_time(6.0);
        Tsubtitles::init();
        ffstring subPath;
        extractfilepath(subFlnm, subPath);
        if (watch) {
            hwatch = FindFirstChangeNotification(subPath.c_str(), FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_SIZE);
            lastwritetime = fileLastWriteTime(subFlnm);
        }
    }
    return true;
}
int initShaderWithFile(std::string vertname, std::string fragname) {
    
    GLhandleARB my_program, my_vertex_shader,my_fragment_shader;
    int Vcompiled,Fcompiled,FShaderLength,VShaderLength;
    std::string fname,vname,my_fragment_shader_source, my_vertex_shader_source,lErrors;
    // Create Shader And Program Objects
    int result = 0;
    Vcompiled = 0;
    Fcompiled = 0;
    fname = fragname;
    vname = vertname;
    if (!fileexists(fname)){
        fname = extractfilepath(fname);
        vname = vertname;
    }
    if (!fileexists(vname)){
        vname = extractfilepath(vname);
    }
    if ((!(fileexists(fname))) || (!(fileexists(vname)))) {
        std::cout << "Unable to find GLSL shaders " << fname << " " << vname << std::endl;
    }
    
    //    char** tmpArray = new char*[1];
    //    tmpArray[0] = (char*)my_fragment_shader_source.c_str();
    //    char** tmpArray2 = new char*[1];
    //    tmpArray2[0] = (char*)my_vertex_shader_source.c_str();
    //    
    //    loadshader((char*)fname.c_str(), (GLchar**)tmpArray);
    //    loadshader((char*)vname.c_str(), (GLchar**)tmpArray2);
    
    //loadshader((char*)fname.c_str(), (GLchar**)my_fragment_shader_source.c_str());
    //loadshader((char*)vname.c_str(), (GLchar**)my_vertex_shader_source.c_str());
    my_fragment_shader_source = LoadStr( fname);
    my_vertex_shader_source = LoadStr( vname);
    my_program = glCreateProgramObjectARB();
    my_vertex_shader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
    my_fragment_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
    // Load Shader Sources
    FShaderLength = (int)my_fragment_shader_source.length();
    VShaderLength = (int)my_vertex_shader_source.length();
    const char * tmp1 = (const char *)my_vertex_shader_source.c_str();
    const char * tmp2 = (const char *)my_fragment_shader_source.c_str();
    
    glShaderSourceARB(my_vertex_shader, 1, &tmp1, NULL);
    glShaderSourceARB(my_fragment_shader, 1, &tmp2, NULL);
    // Compile The Shaders
    glCompileShaderARB(my_vertex_shader);
    glGetObjectParameterivARB(my_vertex_shader,GL_OBJECT_COMPILE_STATUS_ARB, &Vcompiled);
    glCompileShaderARB(my_fragment_shader);
    glGetObjectParameterivARB(my_fragment_shader,GL_OBJECT_COMPILE_STATUS_ARB, &Fcompiled);
    // Attach The Shader Objects To The Program Object
    glAttachObjectARB(my_program, my_vertex_shader);
    glAttachObjectARB(my_program, my_fragment_shader);
    // Link The Program Object
    glLinkProgramARB(my_program);
    if ((Vcompiled!=1) || (Fcompiled!=1)){
        //        lErrors := CheckForErrors(my_program);
        //        if lErrors <> '' then
        //            showDebug('GLSL shader error '+lErrors);
        //        end;
        //        result := my_program ;
        std::cout << "shader has errors!" << std::endl;
    }
    
    //result = my_program
    int i = 0;
    memcpy(&i, &my_program, sizeof(my_program));
    result = i;
    
    if (result == 0){
        std::cout << "Unable to load or compile shader" << std::endl;
    }
    
    return result;
}