当前位置: 首页>>代码示例>>C++>>正文


C++ Codec类代码示例

本文整理汇总了C++中Codec的典型用法代码示例。如果您正苦于以下问题:C++ Codec类的具体用法?C++ Codec怎么用?C++ Codec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Codec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: encode

Bytes
encode(const Unicode& ustring,
       const Bytes& encoding)
{
  Codec* codec = lookup(encoding);
  Bytes bstring = codec->encode(bstring);
  delete codec;
  return bstring;
}
开发者ID:pombredanne,项目名称:quirinus,代码行数:9,代码来源:encode.cpp

示例2: decodeArray

const_byteptr decodeArray(Codec const& codec, Uint *xs, unsigned n, const_byteptr p, const_byteptr end) {
    if (codec.k_max_bytes * n + p > end)
        for (unsigned i = 0; i < n; ++i)
            p = codec.decode(xs[i], p, end);
    else
        for (unsigned i = 0; i < n; ++i)
            p = codec.decode(xs[i], p);
    return p;
}
开发者ID:SlyryD,项目名称:carmel,代码行数:9,代码来源:leb128.hpp

示例3: encodeArray

byteptr encodeArray(Codec const& codec, byteptr p, byteptr end, Uint const* xs, unsigned n) {
    if (codec.k_max_bytes * n + p > end)
        for (unsigned i = 0; i < n; ++i)
            p = codec.encode(p, end, xs[i]);
    else
        for (unsigned i = 0; i < n; ++i)
            p = codec.encode(p, xs[i]);
    return p;
}
开发者ID:SlyryD,项目名称:carmel,代码行数:9,代码来源:leb128.hpp

示例4: main

int main() {
    Codec s;
    vector<int> preorder({1, 2, 4, 3}), inorder({4, 2, 1, 3});
    TreeNode *root = buildTree(preorder, inorder);
    root->print();
    cout << s.serialize(root) << endl;
    TreeNode* node = s.deserialize(s.serialize(root));
    node->print();
    return 0;
}
开发者ID:zsmountain,项目名称:leetcode,代码行数:10,代码来源:serialize_and_deserialize_binary_tree.cpp

示例5: main

int main(void) {
	Codec codec;
	vector<string> strs = {"", "vn"};
	string encoded_string = codec.encode(strs);
	vector<string> strs2 = codec.decode(encoded_string);
	assert(strs.size() == strs2.size());
	for (size_t i = 0; i < strs.size(); i++) assert(strs[i] == strs2[i]);
	cout << "\nPassed All\n";
	return 0;
}
开发者ID:yuanhui-yang,项目名称:LeetCode-Online-Judge,代码行数:10,代码来源:encode-and-decode-strings.cpp

示例6: OGRE_FREE

	//-----------------------------------------------------------------------------
	Image & Image::load(DataStreamPtr& stream, const String& type )
	{
		if( m_pBuffer && m_bAutoDelete )
		{
			OGRE_FREE(m_pBuffer, MEMCATEGORY_GENERAL);
			m_pBuffer = NULL;
		}

		Codec * pCodec = 0;
		if (!type.empty())
		{
			// use named codec
			pCodec = Codec::getCodec(type);
		}
		else
		{
			// derive from magic number
			// read the first 32 bytes or file size, if less
			size_t magicLen = std::min(stream->size(), (size_t)32);
			char magicBuf[32];
			stream->read(magicBuf, magicLen);
			// return to start
			stream->seek(0);
			pCodec = Codec::getCodec(magicBuf, magicLen);
		}

		if( !pCodec )
			OGRE_EXCEPT(
			Exception::ERR_INVALIDPARAMS, 
			"Unable to load image - unable to identify codec. Check file extension "
			"and file format.",
			"Image::load" );

		Codec::DecodeResult res = pCodec->decode(stream);

		ImageCodec::ImageData* pData = 
			static_cast<ImageCodec::ImageData*>(res.second.getPointer());

		m_uWidth = pData->width;
		m_uHeight = pData->height;
		m_uDepth = pData->depth;
		m_uSize = pData->size;
		m_uNumMipmaps = pData->num_mipmaps;
		m_uFlags = pData->flags;

		// Get the format and compute the pixel size
		m_eFormat = pData->format;
		m_ucPixelSize = static_cast<uchar>(PixelUtil::getNumElemBytes( m_eFormat ));
		// Just use internal buffer of returned memory stream
		m_pBuffer = res.first->getPtr();
		// Make sure stream does not delete
		res.first->setFreeOnClose(false);

		return *this;
	}
开发者ID:jjiezheng,项目名称:pap_full,代码行数:56,代码来源:OgreImage.cpp

示例7: main

int main()
{
	Codec codec;
	string data = "null";
	TreeNode* root = codec.deserialize(data);
	// print_tree(root);
	auto ret = codec.serialize(root);
	cout<<ret<<endl;

	return 0;
}
开发者ID:zhangguof,项目名称:LeetCode,代码行数:11,代码来源:Serialize_and_Deserialize_Binary_Tree.cpp

示例8: freeMemory

    //-----------------------------------------------------------------------------
    Image & Image::load(DataStreamPtr& stream, const String& type )
    {
        freeMemory();

        Codec * pCodec = 0;
        if (!type.empty())
        {
            // use named codec
            pCodec = Codec::getCodec(type);
        }
        else
        {
            // derive from magic number
            // read the first 32 bytes or file size, if less
            size_t magicLen = std::min(stream->size(), (size_t)32);
            char magicBuf[32];
            stream->read(magicBuf, magicLen);
            // return to start
            stream->seek(0);
            pCodec = Codec::getCodec(magicBuf, magicLen);

      if( !pCodec )
        OGRE_EXCEPT(
        Exception::ERR_INVALIDPARAMS, 
        "Unable to load image: Image format is unknown. Unable to identify codec. "
        "Check it or specify format explicitly.",
        "Image::load" );
        }

        Codec::DecodeResult res = pCodec->decode(stream);

        ImageCodec::ImageData* pData = 
            static_cast<ImageCodec::ImageData*>(res.second.getPointer());

        mWidth = pData->width;
        mHeight = pData->height;
        mDepth = pData->depth;
        mBufSize = pData->size;
        mNumMipmaps = pData->num_mipmaps;
        mFlags = pData->flags;

        // Get the format and compute the pixel size
        mFormat = pData->format;
        mPixelSize = static_cast<uchar>(PixelUtil::getNumElemBytes( mFormat ));
        // Just use internal buffer of returned memory stream
        mBuffer = res.first->getPtr();
        // Make sure stream does not delete
        res.first->setFreeOnClose(false);
        // make sure we delete
        mAutoDelete = true;

        return *this;
    }
开发者ID:ballisticwhisper,项目名称:ogre,代码行数:54,代码来源:OgreImage.cpp

示例9: OgreGuard

	//-----------------------------------------------------------------------------
	Image & Image::load(const String& strFileName, const String& group)
	{
		OgreGuard( "Image::load" );

		freeData();

		String strExt;

		size_t pos = strFileName.find_last_of(".");
		if( pos == String::npos )
			OGRE_EXCEPT(
			Exception::ERR_INVALIDPARAMS, 
			"Unable to load image file '" + strFileName + "' - invalid extension.",
			"Image::load" );

		while( pos != strFileName.length() - 1 )
			strExt += strFileName[++pos];

		Codec * pCodec = Codec::getCodec(strExt);
		if( !pCodec )
			OGRE_EXCEPT(
			Exception::ERR_INVALIDPARAMS, 
			"Unable to load image file '" + strFileName + "' - invalid extension.",
			"Image::load" );

		DataStreamPtr encoded = 
			ResourceGroupManager::getSingleton().openResource(strFileName, group);

		Codec::DecodeResult res = pCodec->decode(encoded);

		ImageCodec::ImageData* pData = 
			static_cast<ImageCodec::ImageData*>(res.second.getPointer());

		// Get the format and compute the pixel size
		m_uWidth = pData->width;
		m_uHeight = pData->height;
		m_uDepth = pData->depth;
		m_uSize = pData->size;
		m_eFormat = pData->format;
		m_uNumMipmaps = pData->num_mipmaps;
		m_ucPixelSize = PixelUtil::getNumElemBytes( m_eFormat );
		m_uFlags = pData->flags;

		// re-use the decoded buffer
		m_pBuffer = res.first->getPtr();
		// ensure we don't delete when stream is closed
		res.first->setFreeOnClose(false);

		OgreUnguardRet( *this );
	}
开发者ID:brock7,项目名称:TianLong,代码行数:51,代码来源:OgreImage.cpp

示例10: main

// Your Codec object will be instantiated and called as such:
// Codec codec;
// codec.decode(codec.encode(strs));
//
int main() {
  Codec codec;
  vector<string> strs;
  strs.push_back("hello");
  strs.push_back("");
  strs.push_back("gaobo");
  string coded_str = codec.encode(strs);
  cout << "coded str: " << coded_str << endl;
  vector<string> decoded_strs = codec.decode(coded_str);
  for (int i = 0; i < decoded_strs.size(); i++) {
    cout << decoded_strs[i] << endl;
  }
  return 0;
}
开发者ID:seven-gao,项目名称:alg,代码行数:18,代码来源:encode_decode_strings.cpp

示例11: clear_if

void CodecContext::open(const Codec &codec, AVDictionary **options, error_code &ec)
{
    clear_if(ec);

    if (m_isOpened || !isValid()) {
        throws_if(ec, m_isOpened ? Errors::CodecAlreadyOpened : Errors::CodecInvalid);
        return;
    }

    int stat = avcodec_open2(m_raw, codec.isNull() ? m_raw->codec : codec.raw(), options);
    if (stat < 0)
        throws_if(ec, stat, ffmpeg_category());
    else
        m_isOpened = true;
}
开发者ID:Adenilson,项目名称:avcpp,代码行数:15,代码来源:codeccontext.cpp

示例12: getFileExtFromMagic

    //---------------------------------------------------------------------
    String Image::getFileExtFromMagic(DataStreamPtr stream)
    {
        // read the first 32 bytes or file size, if less
        size_t magicLen = std::min(stream->size(), (size_t)32);
        char magicBuf[32];
        stream->read(magicBuf, magicLen);
        // return to start
        stream->seek(0);
        Codec* pCodec = Codec::getCodec(magicBuf, magicLen);

        if(pCodec)
            return pCodec->getType();
        else
            return BLANKSTRING;

    }
开发者ID:ballisticwhisper,项目名称:ogre,代码行数:17,代码来源:OgreImage.cpp

示例13: LOG4CXX_DEBUG

void Mixer::remoteStartTransmission(const ::Ice::Current& curr) {
	stringstream a;
	stringstream b;
	LOG4CXX_DEBUG(logger, string("Mixer::remoteStartTransmission()"));

	IPV4Address *tmpAddr = new IPV4Address(getRemoteAddressFromConnection(curr.con));
	a << string("Mixer::remoteStartTransmission() rem hostAddr: ") << tmpAddr->getHostname();
	LOG4CXX_DEBUG(logger, a.str());

	TerminalInfo *info = remoteHostsM[tmpAddr->getHostname()];
	if (remoteHostsM.find(tmpAddr->getHostname()) == remoteHostsM.end()  ) {
		cout << "ERROR info not found\n";
	}

	if (this->currentState != States::PASSIVE_CONNECTED) {
		LOG4CXX_DEBUG(logger, string("Mixer::remoteStartTransmission() bad state"));
	} else {
		changeState(States::PASSIVE_OPERATIONAL);

		cout << "TRANSCEIVER STARTED\n";

		// TODO start RTP.RTCP transmission
		CodecFactory codecfactory;
		Codec* codecInc = codecfactory.getCodec(AudioCodec::PCMU); // HACK
		// 		Codec* codecInc = codecfactory.getCodec(info->incomingCodec);
		Codec* codecOut = codecfactory.getCodec(AudioCodec::PCMU);
		//		Codec* codecOut = codecfactory.getCodec(info->outgoingCodec); // HACK

		info->transport = new TransportCCRTP();
		info->transport->setParams(codecInc->getFrameCount(), codecInc->getFrameSize());
		info->transport->setLocalEndpoint("0.0.0.0", localRTPPort);
		info->transport->setRemoteEndpoint(info->address, info->rtpPort);
		info->buf = new RingBuffer(1024*1024, 1);
		// 		b << "Mixer::remoteStartTransmission() creating transport,
		localRTPPort += 2;

		stringstream a;
		a << "rem address: " << info->address << " port: " << info->rtpPort;
		LOG4CXX_DEBUG(logger, a.str());

		info->transport->start();

		LOG4CXX_DEBUG(logger, string("Mixer::remoteStartTransmission() transmission started"));
	}
}
开发者ID:fffaraz,项目名称:Multimedia,代码行数:45,代码来源:mixer.cpp

示例14: CodecFactory

bool MainObject::StartCodec()
{
  Codec *codec;

  if((codec=
    CodecFactory(sir_config->audioFormat(),sir_ringbuffers[sir_codecs.size()],
		 this))==NULL) {
    Log(LOG_ERR,
	QString().sprintf("unsupported codec type \"%s\"",
	      (const char *)Codec::codecTypeText(Codec::TypeMpegL3).toUtf8()));
    return false;
  }
  if(sir_config->audioBitrateQuantity()>0) {
    codec->
     setBitrate(sir_config->audioBitrate(sir_config->audioBitrateQuantity()-1));
  }
  else {
    codec->setBitrate(0);
  }
  codec->setChannels(sir_config->audioChannels());
  codec->setQuality(sir_config->audioQuality());
  codec->setSourceSamplerate(sir_audio_device->deviceSamplerate());
  codec->setStreamSamplerate(sir_config->audioSamplerate());
  codec->setCompleteFrames(sir_config->audioAtomicFrames());

  sir_codecs.push_back(codec);

  return sir_codecs.back()->start();
}
开发者ID:ElvishArtisan,项目名称:GlassCoder,代码行数:29,代码来源:glasscoder.cpp

示例15: main

int main(int argc, char const *argv[])
{
	/* code */
	TreeNode* n1 = new TreeNode(5);
	TreeNode* n2 = new TreeNode(4);
	TreeNode* n3 = new TreeNode(2);
	n1 -> left = n2;
	n1 -> right = n3;
	TreeNode* n4 = new TreeNode(11);
	n2 ->right = n4;
	TreeNode* n5 = new TreeNode(7);
	TreeNode* n6 = new TreeNode(8);
	n3 -> left = n5;
	n3 -> right = n6;

	Codec c;
	string test = "5,4,#,11,#,#,2,7,#,#,8,#,#,";

	//c.dfs(n1);


	cout << "---------" << endl;
	c.dfs(c.deserialize(test));
	cout  << endl;

	cout << c.serialize(n1)<<endl;
	cout << test<<endl;
	c.dfs(c.deserialize(c.serialize(n1)));

	return 0;
}
开发者ID:qfu,项目名称:LeetCode_1,代码行数:31,代码来源:H_297_Serialize_and_Deserialize_Binary_Tree.cpp


注:本文中的Codec类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。