Ejemplo n.º 1
0
void TffdshowPageEnc::codec2dlg(void)
{
    codecId = (AVCodecID)cfgGet(IDFF_enc_codecId);
    SendDlgItemMessage(m_hwnd, IDC_CBX_FOURCC, CB_RESETCONTENT, 0, 0);
    int cnt = cbxGetItemCount(IDC_CBX_ENCODER);
    for (int i = 0; i < cnt; i++)
        if (((Tencoder*)cbxGetItemData(IDC_CBX_ENCODER, i))->id == codecId) {
            cbxSetCurSel(IDC_CBX_ENCODER, i);
            const Tencoder *enc;
            deciE->getEncoder(codecId, &enc);
            if (enc) {
                for (Tfourccs::const_iterator f = enc->fourccs.begin(); f != enc->fourccs.end(); f++) {
                    char fccs[5] = "1234";
                    memcpy(fccs, &*f, 4);
                    if (fccs[0]) {
                        cbxAdd(IDC_CBX_FOURCC, text<char_t>(fccs), *f);
                    }
                }
                static const int idFourcc[] = {IDC_LBL_FOURCC, IDC_CBX_FOURCC, 0};
                if (cbxGetItemCount(IDC_CBX_FOURCC) == 0) {
                    enable(false, idFourcc);
                } else {
                    enable(true, idFourcc);
                    fourcc2dlg();
                }
                SendDlgItemMessage(m_hwnd, IDC_CBX_MODES, CB_RESETCONTENT, 0, 0);
                if (sup_CBR(codecId) && codecId != AV_CODEC_ID_MJPEG) {
                    cbxAdd(IDC_CBX_MODES, _(IDC_CBX_MODES, encModeNames[ENC_MODE::CBR]), ENC_MODE::CBR);
                }
                if (sup_VBR_QUAL(codecId)) {
                    cbxAdd(IDC_CBX_MODES, _(IDC_CBX_MODES, encModeNames[ENC_MODE::VBR_QUAL]), ENC_MODE::VBR_QUAL);
                }
                if (sup_VBR_QUANT(codecId)) {
                    cbxAdd(IDC_CBX_MODES, _(IDC_CBX_MODES, encModeNames[ENC_MODE::VBR_QUANT]), ENC_MODE::VBR_QUANT);
                }
                static const int idModes[] = {IDC_LBL_MODES, IDC_CBX_MODES, 0};
                enable(cbxGetItemCount(IDC_CBX_MODES) != 0, idModes);
                qmin = TcoSettings::getMinMaxQuant(codecId).first;
                qmax = TcoSettings::getMinMaxQuant(codecId).second;
                quick2dlg(true);
            }
            return;
        }
}
Ejemplo n.º 2
0
STDMETHODIMP_(LRESULT) TffdshowEnc::begin(const BITMAPINFOHEADER *inhdr)
{
    if (!findEncLib()) {
        return ICERR_ERROR;
    }

    int nom, den;
    if (lavc_reduce(&nom, &den, fpsRate, fpsScale, 10000)) {
        fpsRate = nom;
        fpsScale = den;
    }

    dbgInit();
    getOut(inhdr->biWidth, inhdr->biHeight, &outDx, &outDy);
    ownStoreExt = false;

    if (enccsps.empty()) {
        enc->getCompressColorspaces(enccsps, outDx, outDy);
        if (enccsps.empty()) {
            return ICERR_BADFORMAT;
        }
    }
    enccsp = enccsps[0];

    cfgcomode = coSettings->mode;
    switch (cfgcomode) {
        case ENC_MODE::CBR:
            if (!sup_CBR(coSettings->codecId)) {
                cfgcomode = ENC_MODE::UNKNOWN;
            }
            break;
        case ENC_MODE::VBR_QUAL:
            if (!sup_VBR_QUAL(coSettings->codecId)) {
                cfgcomode = ENC_MODE::UNKNOWN;
            }
            break;
        case ENC_MODE::VBR_QUANT:
            if (!sup_VBR_QUANT(coSettings->codecId)) {
                cfgcomode = ENC_MODE::UNKNOWN;
            }
            break;
    }

    if (coSettings->storeExt && !ownStoreExt && coSettings->storeExtFlnm[0]) {
        mux = Tmuxer::getMuxer(coSettings->muxer, this);
    } else {
        mux = NULL;
    }
    enc->setCoSettings(oldCodecId);
    LRESULT res = enc->beginCompress(cfgcomode, enccsp, Trect(0, 0, outDx, outDy));
    if (res != ICERR_OK) {
        return res;
    }

    dx = inhdr->biWidth;
    dy = inhdr->biHeight;
    totalsize = keyspacing = 0;
    if (coSettings->isProc && ffproc) {
        ffproc->begin(dx, dy, fpsRate, fpsScale);
    }

    if (mux) {
        mux->writeHeader(extradata.data, extradata.size, 1, biOutput.bmiHeader);
    }

    memset(&params, 0, sizeof(params));
    encStats.init(outDx, outDy, enccsp);
    outputdebug = globalSettings->outputdebug;
    outputdebugfile = globalSettings->outputdebugfile;

    working = true;
    firstrun = true;
    return ICERR_OK;
}