Ejemplo n.º 1
0
	HuffmanDecoder * operator()() const
	{
		unsigned int codeLengths[32];
		std::fill(codeLengths + 0, codeLengths + 32, 5U);
#if defined(CRYPTOPP_CXX11)
		std::unique_ptr<HuffmanDecoder> pDecoder(new HuffmanDecoder);
#else
		std::auto_ptr<HuffmanDecoder> pDecoder(new HuffmanDecoder);
#endif
		pDecoder->Initialize(codeLengths, 32);
		return pDecoder.release();
	}
Ejemplo n.º 2
0
enum AVPixelFormat CDVDVideoCodecFFmpeg::GetFormat(struct AVCodecContext * avctx, const AVPixelFormat * fmt)
{
  ICallbackHWAccel *cb = static_cast<ICallbackHWAccel*>(avctx->opaque);
  CDVDVideoCodecFFmpeg* ctx  = dynamic_cast<CDVDVideoCodecFFmpeg*>(cb);

  const char* pixFmtName = av_get_pix_fmt_name(*fmt);

  ctx->m_processInfo.SetVideoDimensions(avctx->coded_width, avctx->coded_height);

  // if frame threading is enabled hw accel is not allowed
  // 2nd condition:
  // fix an ffmpeg issue here, it calls us with an invalid profile
  // then a 2nd call with a valid one
  if(ctx->m_decoderState != STATE_HW_SINGLE ||
     (avctx->codec_id == AV_CODEC_ID_VC1 && avctx->profile == FF_PROFILE_UNKNOWN))
  {
    AVPixelFormat defaultFmt = avcodec_default_get_format(avctx, fmt);
    pixFmtName = av_get_pix_fmt_name(defaultFmt);
    ctx->m_processInfo.SetVideoPixelFormat(pixFmtName ? pixFmtName : "");
    ctx->m_processInfo.SetSwDeinterlacingMethods();
    return defaultFmt;
  }

  // hardware decoder de-selected, restore standard ffmpeg
  if (ctx->HasHardware())
  {
    ctx->SetHardware(nullptr);
    avctx->get_buffer2 = avcodec_default_get_buffer2;
    avctx->slice_flags = 0;
    av_buffer_unref(&avctx->hw_frames_ctx);
  }

  const AVPixelFormat * cur = fmt;
  while (*cur != AV_PIX_FMT_NONE)
  {
    pixFmtName = av_get_pix_fmt_name(*cur);

    auto hwaccels = CDVDFactoryCodec::GetHWAccels();
    for (auto &hwaccel : hwaccels)
    {
      IHardwareDecoder *pDecoder(CDVDFactoryCodec::CreateVideoCodecHWAccel(hwaccel, ctx->m_hints,
                                                                           ctx->m_processInfo, *cur));
      if (pDecoder)
      {
        if (pDecoder->Open(avctx, ctx->m_pCodecContext, *cur))
        {
          ctx->m_processInfo.SetVideoPixelFormat(pixFmtName ? pixFmtName : "");
          ctx->SetHardware(pDecoder);
          return *cur;
        }
      }
      SAFE_RELEASE(pDecoder);
    }
    cur++;
  }

  ctx->m_processInfo.SetVideoPixelFormat(pixFmtName ? pixFmtName : "");
  ctx->m_decoderState = STATE_HW_FAILED;
  return avcodec_default_get_format(avctx, fmt);
}
Ejemplo n.º 3
0
 HuffmanDecoder * operator()() const
 {
     unsigned int codeLengths[32];
     std::fill(codeLengths + 0, codeLengths + 32, 5);
     std::auto_ptr<HuffmanDecoder> pDecoder(new HuffmanDecoder);
     pDecoder->Initialize(codeLengths, 32);
     return pDecoder.release();
 }
Ejemplo n.º 4
0
 HuffmanDecoder * operator()() const
 {
     unsigned int codeLengths[288];
     std::fill(codeLengths + 0, codeLengths + 144, 8);
     std::fill(codeLengths + 144, codeLengths + 256, 9);
     std::fill(codeLengths + 256, codeLengths + 280, 7);
     std::fill(codeLengths + 280, codeLengths + 288, 8);
     std::auto_ptr<HuffmanDecoder> pDecoder(new HuffmanDecoder);
     pDecoder->Initialize(codeLengths, 288);
     return pDecoder.release();
 }
Ejemplo n.º 5
0
CCodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder(
    const uint8_t* src_buf,
    uint32_t src_size,
    int width,
    int height,
    int nComps,
    FX_BOOL ColorTransform) {
  if (!src_buf || src_size == 0)
    return nullptr;

  std::unique_ptr<CCodec_JpegDecoder> pDecoder(new CCodec_JpegDecoder);
  if (!pDecoder->Create(src_buf, src_size, width, height, nComps,
                        ColorTransform)) {
    return nullptr;
  }
  return pDecoder.release();
}
Ejemplo n.º 6
0
CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith(
    CJBig2_ArithDecoder* pArithDecoder,
    std::vector<JBig2ArithCtx>* gbContext,
    std::vector<JBig2ArithCtx>* grContext) {
  CJBig2_Image** SDNEWSYMS;
  FX_DWORD HCHEIGHT, NSYMSDECODED;
  int32_t HCDH;
  FX_DWORD SYMWIDTH, TOTWIDTH;
  int32_t DW;
  CJBig2_Image* BS;
  FX_DWORD I, J, REFAGGNINST;
  FX_BOOL* EXFLAGS;
  FX_DWORD EXINDEX;
  FX_BOOL CUREXFLAG;
  FX_DWORD EXRUNLENGTH;
  FX_DWORD nTmp;
  FX_DWORD SBNUMSYMS;
  uint8_t SBSYMCODELEN;
  int32_t RDXI, RDYI;
  CJBig2_Image** SBSYMS;
  std::unique_ptr<CJBig2_ArithIaidDecoder> IAID;
  std::unique_ptr<CJBig2_SymbolDict> pDict;
  std::unique_ptr<CJBig2_ArithIntDecoder> IADH(new CJBig2_ArithIntDecoder);
  std::unique_ptr<CJBig2_ArithIntDecoder> IADW(new CJBig2_ArithIntDecoder);
  std::unique_ptr<CJBig2_ArithIntDecoder> IAAI(new CJBig2_ArithIntDecoder);
  std::unique_ptr<CJBig2_ArithIntDecoder> IARDX(new CJBig2_ArithIntDecoder);
  std::unique_ptr<CJBig2_ArithIntDecoder> IARDY(new CJBig2_ArithIntDecoder);
  std::unique_ptr<CJBig2_ArithIntDecoder> IAEX(new CJBig2_ArithIntDecoder);
  std::unique_ptr<CJBig2_ArithIntDecoder> IADT(new CJBig2_ArithIntDecoder);
  std::unique_ptr<CJBig2_ArithIntDecoder> IAFS(new CJBig2_ArithIntDecoder);
  std::unique_ptr<CJBig2_ArithIntDecoder> IADS(new CJBig2_ArithIntDecoder);
  std::unique_ptr<CJBig2_ArithIntDecoder> IAIT(new CJBig2_ArithIntDecoder);
  std::unique_ptr<CJBig2_ArithIntDecoder> IARI(new CJBig2_ArithIntDecoder);
  std::unique_ptr<CJBig2_ArithIntDecoder> IARDW(new CJBig2_ArithIntDecoder);
  std::unique_ptr<CJBig2_ArithIntDecoder> IARDH(new CJBig2_ArithIntDecoder);
  nTmp = 0;
  while ((FX_DWORD)(1 << nTmp) < (SDNUMINSYMS + SDNUMNEWSYMS)) {
    nTmp++;
  }
  IAID.reset(new CJBig2_ArithIaidDecoder((uint8_t)nTmp));
  SDNEWSYMS = FX_Alloc(CJBig2_Image*, SDNUMNEWSYMS);
  FXSYS_memset(SDNEWSYMS, 0, SDNUMNEWSYMS * sizeof(CJBig2_Image*));

  HCHEIGHT = 0;
  NSYMSDECODED = 0;
  while (NSYMSDECODED < SDNUMNEWSYMS) {
    BS = nullptr;
    IADH->decode(pArithDecoder, &HCDH);
    HCHEIGHT = HCHEIGHT + HCDH;
    if ((int)HCHEIGHT < 0 || (int)HCHEIGHT > JBIG2_MAX_IMAGE_SIZE) {
      goto failed;
    }
    SYMWIDTH = 0;
    TOTWIDTH = 0;
    for (;;) {
      if (!IADW->decode(pArithDecoder, &DW))
        break;

      if (NSYMSDECODED >= SDNUMNEWSYMS)
        goto failed;

      SYMWIDTH = SYMWIDTH + DW;
      if ((int)SYMWIDTH < 0 || (int)SYMWIDTH > JBIG2_MAX_IMAGE_SIZE)
        goto failed;

      if (HCHEIGHT == 0 || SYMWIDTH == 0) {
        TOTWIDTH = TOTWIDTH + SYMWIDTH;
        SDNEWSYMS[NSYMSDECODED] = nullptr;
        NSYMSDECODED = NSYMSDECODED + 1;
        continue;
      }
      TOTWIDTH = TOTWIDTH + SYMWIDTH;
      if (SDREFAGG == 0) {
        std::unique_ptr<CJBig2_GRDProc> pGRD(new CJBig2_GRDProc());
        pGRD->MMR = 0;
        pGRD->GBW = SYMWIDTH;
        pGRD->GBH = HCHEIGHT;
        pGRD->GBTEMPLATE = SDTEMPLATE;
        pGRD->TPGDON = 0;
        pGRD->USESKIP = 0;
        pGRD->GBAT[0] = SDAT[0];
        pGRD->GBAT[1] = SDAT[1];
        pGRD->GBAT[2] = SDAT[2];
        pGRD->GBAT[3] = SDAT[3];
        pGRD->GBAT[4] = SDAT[4];
        pGRD->GBAT[5] = SDAT[5];
        pGRD->GBAT[6] = SDAT[6];
        pGRD->GBAT[7] = SDAT[7];
        BS = pGRD->decode_Arith(pArithDecoder, gbContext->data());
        if (!BS) {
          goto failed;
        }
      } else {
        IAAI->decode(pArithDecoder, (int*)&REFAGGNINST);
        if (REFAGGNINST > 1) {
          std::unique_ptr<CJBig2_TRDProc> pDecoder(new CJBig2_TRDProc());
          pDecoder->SBHUFF = SDHUFF;
          pDecoder->SBREFINE = 1;
          pDecoder->SBW = SYMWIDTH;
          pDecoder->SBH = HCHEIGHT;
          pDecoder->SBNUMINSTANCES = REFAGGNINST;
          pDecoder->SBSTRIPS = 1;
          pDecoder->SBNUMSYMS = SDNUMINSYMS + NSYMSDECODED;
          SBNUMSYMS = pDecoder->SBNUMSYMS;
          nTmp = 0;
          while ((FX_DWORD)(1 << nTmp) < SBNUMSYMS) {
            nTmp++;
          }
          SBSYMCODELEN = (uint8_t)nTmp;
          pDecoder->SBSYMCODELEN = SBSYMCODELEN;
          SBSYMS = FX_Alloc(CJBig2_Image*, SBNUMSYMS);
          JBIG2_memcpy(SBSYMS, SDINSYMS, SDNUMINSYMS * sizeof(CJBig2_Image*));
          JBIG2_memcpy(SBSYMS + SDNUMINSYMS, SDNEWSYMS,
                       NSYMSDECODED * sizeof(CJBig2_Image*));
          pDecoder->SBSYMS = SBSYMS;
          pDecoder->SBDEFPIXEL = 0;
          pDecoder->SBCOMBOP = JBIG2_COMPOSE_OR;
          pDecoder->TRANSPOSED = 0;
          pDecoder->REFCORNER = JBIG2_CORNER_TOPLEFT;
          pDecoder->SBDSOFFSET = 0;
          std::unique_ptr<CJBig2_HuffmanTable> SBHUFFFS(new CJBig2_HuffmanTable(
              HuffmanTable_B6, FX_ArraySize(HuffmanTable_B6),
              HuffmanTable_HTOOB_B6));
          std::unique_ptr<CJBig2_HuffmanTable> SBHUFFDS(new CJBig2_HuffmanTable(
              HuffmanTable_B8, FX_ArraySize(HuffmanTable_B8),
              HuffmanTable_HTOOB_B8));
          std::unique_ptr<CJBig2_HuffmanTable> SBHUFFDT(new CJBig2_HuffmanTable(
              HuffmanTable_B11, FX_ArraySize(HuffmanTable_B11),
              HuffmanTable_HTOOB_B11));
          std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRDW(
              new CJBig2_HuffmanTable(HuffmanTable_B15,
                                      FX_ArraySize(HuffmanTable_B15),
                                      HuffmanTable_HTOOB_B15));
          std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRDH(
              new CJBig2_HuffmanTable(HuffmanTable_B15,
                                      FX_ArraySize(HuffmanTable_B15),
                                      HuffmanTable_HTOOB_B15));
          std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRDX(
              new CJBig2_HuffmanTable(HuffmanTable_B15,
                                      FX_ArraySize(HuffmanTable_B15),
                                      HuffmanTable_HTOOB_B15));
          std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRDY(
              new CJBig2_HuffmanTable(HuffmanTable_B15,
                                      FX_ArraySize(HuffmanTable_B15),
                                      HuffmanTable_HTOOB_B15));
          std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRSIZE(
              new CJBig2_HuffmanTable(HuffmanTable_B1,
                                      FX_ArraySize(HuffmanTable_B1),
                                      HuffmanTable_HTOOB_B1));
          pDecoder->SBHUFFFS = SBHUFFFS.get();
          pDecoder->SBHUFFDS = SBHUFFDS.get();
          pDecoder->SBHUFFDT = SBHUFFDT.get();
          pDecoder->SBHUFFRDW = SBHUFFRDW.get();
          pDecoder->SBHUFFRDH = SBHUFFRDH.get();
          pDecoder->SBHUFFRDX = SBHUFFRDX.get();
          pDecoder->SBHUFFRDY = SBHUFFRDY.get();
          pDecoder->SBHUFFRSIZE = SBHUFFRSIZE.get();
          pDecoder->SBRTEMPLATE = SDRTEMPLATE;
          pDecoder->SBRAT[0] = SDRAT[0];
          pDecoder->SBRAT[1] = SDRAT[1];
          pDecoder->SBRAT[2] = SDRAT[2];
          pDecoder->SBRAT[3] = SDRAT[3];
          JBig2IntDecoderState ids;
          ids.IADT = IADT.get();
          ids.IAFS = IAFS.get();
          ids.IADS = IADS.get();
          ids.IAIT = IAIT.get();
          ids.IARI = IARI.get();
          ids.IARDW = IARDW.get();
          ids.IARDH = IARDH.get();
          ids.IARDX = IARDX.get();
          ids.IARDY = IARDY.get();
          ids.IAID = IAID.get();
          BS = pDecoder->decode_Arith(pArithDecoder, grContext->data(), &ids);
          if (!BS) {
            FX_Free(SBSYMS);
            goto failed;
          }
          FX_Free(SBSYMS);
        } else if (REFAGGNINST == 1) {
          SBNUMSYMS = SDNUMINSYMS + NSYMSDECODED;
          FX_DWORD IDI;
          IAID->decode(pArithDecoder, &IDI);
          IARDX->decode(pArithDecoder, &RDXI);
          IARDY->decode(pArithDecoder, &RDYI);
          if (IDI >= SBNUMSYMS) {
            goto failed;
          }
          SBSYMS = FX_Alloc(CJBig2_Image*, SBNUMSYMS);
          JBIG2_memcpy(SBSYMS, SDINSYMS, SDNUMINSYMS * sizeof(CJBig2_Image*));
          JBIG2_memcpy(SBSYMS + SDNUMINSYMS, SDNEWSYMS,
                       NSYMSDECODED * sizeof(CJBig2_Image*));
          if (!SBSYMS[IDI]) {
            FX_Free(SBSYMS);
            goto failed;
          }
          std::unique_ptr<CJBig2_GRRDProc> pGRRD(new CJBig2_GRRDProc());
          pGRRD->GRW = SYMWIDTH;
          pGRRD->GRH = HCHEIGHT;
          pGRRD->GRTEMPLATE = SDRTEMPLATE;
          pGRRD->GRREFERENCE = SBSYMS[IDI];
          pGRRD->GRREFERENCEDX = RDXI;
          pGRRD->GRREFERENCEDY = RDYI;
          pGRRD->TPGRON = 0;
          pGRRD->GRAT[0] = SDRAT[0];
          pGRRD->GRAT[1] = SDRAT[1];
          pGRRD->GRAT[2] = SDRAT[2];
          pGRRD->GRAT[3] = SDRAT[3];
          BS = pGRRD->decode(pArithDecoder, grContext->data());
          if (!BS) {
            FX_Free(SBSYMS);
            goto failed;
          }
          FX_Free(SBSYMS);
        }
      }
void CKS_Import_File_Browser::EventValueChange(ge::IControl* pControl, tint32 iValueNew)
{
	GetParmMan()->ControlUpdate(miPaneID, pControl->GetID(), iValueNew);

	switch(pControl->GetID()) {
		case giCtrl_File_List:
			{
				tbool bIsDoubleClick = (iValueNew == -2);
				if (iValueNew >= -1) {
					miLatestGenuineIndex = iValueNew;
				}

				tint32 iIndex = miLatestGenuineIndex; //pControl->GetValue();
				std::list<SItemInfo>::const_iterator it = mItems.begin();
				while (iIndex > 0) {
					iIndex--;
					it++;
				}
				SItemInfo Info = *it;
				if (Info.bDir == true) {
					mpImportGUI->PreviewStop();
					miLatestSelectedFile = -1;

					std::string sPath(msPath);
					sPath += Info.sName;
					sPath += ":";
					if (bIsDoubleClick) {
						mpImportGUI->BrowseToDir(sPath);
					}
				}
				else {
					tbool bSameFile = (miLatestGenuineIndex == miLatestSelectedFile);

					if (bSameFile) {
						// Same file
						if (bIsDoubleClick) {
							// Add file to import list
							std::string sPathName(msPath);
							sPathName += Info.sName;
							mpImportGUI->AddFile(sPathName);
						}
					}
					else {
						// New file - read its info

						// First we need to stop previewing (may crash on read info if we don't)
						mpImportGUI->PreviewStop();

						// Get info
						miLatestSelectedFile = miLatestGenuineIndex;
						std::string sPathName(msPath);
						sPathName += Info.sName;
						CAutoDelete<IFile> pFile(IFile::Create());
						if (pFile->Open(sPathName.c_str(), IFile::FileRead)) {
							ac::IDecoder* pdec = ac::IDecoder::Create(pFile);
							if (pdec) {
								// Attempt to test file - if it fails ignore it
								pdec->TestFile(pFile);
								// Now we have tried to decipher file - we pretend it succeeded
								CAutoDelete<ac::IDecoder> pDecoder(pdec);
								ac::EAudioCodec Codec = pDecoder->GetAudioCodec();
								if (Codec == ac::geAudioCodecWave) {
									mpImportGUI->SetType(0);
									ac::EQuality eQ = ac::geQualityUnknown;
									tint32 iBitDepth = pdec->miLastInputBitWidth;
									if (iBitDepth == 16)
										eQ = ac::geQualityLossless16;
									else if (iBitDepth == 24)
										eQ = ac::geQualityLossless24;
									tint32 iSampleRate = pdec->miOutputSampleFreq;
									tint32 iChannels = pdec->miOutputChannels;
									mpImportGUI->SetInfo(eQ, iSampleRate, iChannels);
								}
								else if (Codec == geAudioCodecVorbis) {
									mpImportGUI->SetType(1);
									tint32 iSampleRate = pdec->miOutputSampleFreq;
									tint32 iChannels = pdec->miOutputChannels;
									mpImportGUI->SetInfo(pdec->meLowestInputQuality, iSampleRate, iChannels);
								}
								else {
									mpImportGUI->SetType(2);
									tint32 iSampleRate = pdec->miOutputSampleFreq;
									tint32 iChannels = pdec->miOutputChannels;
									mpImportGUI->SetInfo(pdec->meLowestInputQuality, iSampleRate, iChannels);
								}
							}
						}
					}
				}
			}
			break;
	}
} // EventValueChange