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


C++ codec函数代码示例

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


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

示例1: TestViterbiDecodingSamples

void TestViterbiDecodingSamples() {
  {
    std::vector<int> polynomials;
    polynomials.push_back(7);
    polynomials.push_back(5);

    ViterbiCodec codec(3, polynomials);

    TestViterbiDecoding(codec,
                        "0011100001100111111000101100111011",
                        "010111001010001");

    // Inject 1 error bit.
    TestViterbiDecoding(codec,
                        "0011100001100111110000101100111011",
                        "010111001010001");
  }

  {
    std::vector<int> polynomials;
    polynomials.push_back(7);
    polynomials.push_back(6);

    ViterbiCodec codec(3, polynomials);

    TestViterbiDecoding(codec, "1011010100110000", "101100");
  }

  {
    std::vector<int> polynomials;
    polynomials.push_back(6);
    polynomials.push_back(5);

    ViterbiCodec codec(3, polynomials);

    TestViterbiDecoding(codec, "011011011101101011", "1001101");

    // Inject 2 error bits.
    TestViterbiDecoding(codec, "111011011100101011", "1001101");
  }

  {
    std::vector<int> polynomials;
    polynomials.push_back(91);
    polynomials.push_back(117);
    polynomials.push_back(121);

    ViterbiCodec codec(7, polynomials);

    TestViterbiDecoding(codec,
                        "111100101110001011110101111111001011100111",
                        "10110111");

    // Inject 4 error bits.
    TestViterbiDecoding(codec,
                        "100100101110001011110101110111001011100110",
                        "10110111");
  }
}
开发者ID:xukmin,项目名称:viterbi,代码行数:59,代码来源:viterbi_test.cpp

示例2: readSettings

/*!
  Serialize the account information to the current group of
  the given QSettings file \a conf.

  \sa readSettings()
*/
void AccountConfiguration::saveSettings(QSettings *conf) const
{
    conf->setValue("name", _userName );
    conf->setValue("email", _emailAddress );
    conf->setValue("mailuser", _mailUserName );
    {
        QMailBase64Codec codec(QMailBase64Codec::Text);
        QByteArray encoded = codec.encode(_mailPassword, "ISO-8859-1");
        QString plain;
        plain = QString::fromLatin1(encoded.constData(), encoded.length());
        conf->setValue("mailpasswordobs", plain);
    }
    conf->setValue("mailserver", _mailServer );
    conf->setValue("mailport", _mailPort);
    conf->setValue("basefolder", _baseFolder);

    conf->setValue("smtpserver", _smtpServer );
    conf->setValue("smtpport", _smtpPort);
#ifndef QT_NO_OPENSSL
    conf->setValue("smtpUsername",_smtpUsername);
    {
        QMailBase64Codec codec(QMailBase64Codec::Text);
        QByteArray encoded = codec.encode(_smtpPassword, "ISO-8859-1");
        QString plain;
        plain = QString::fromLatin1(encoded.constData(), encoded.length());
        conf->setValue("smtpPasswordObs", plain);
    }
    conf->setValue("smtpAuthentication",_smtpAuthentication);
    conf->setValue("smtpEncryption",_smtpEncryption);
    conf->setValue("mailEncryption",_mailEncryption);
#endif
    conf->setValue("usesig", _useSig);
    conf->setValue("maxmailsize", _maxMailSize);
    conf->setValue("checkinterval", _checkInterval);
    conf->setValue("intervalCheckRoamingEnabled", _intervalCheckRoamingEnabled);
    conf->setValue("pushEnabled", _pushEnabled);
    conf->remove("defaultmailserver");

    if (_useSig) {
        QString path = Qtopia::applicationFileName("qtopiamail", "") + "sig_" + QString::number(_id.toULongLong());
        QFile file(path);
        if ( file.open(QIODevice::WriteOnly) ) {    // file opened successfully
            QTextStream t( &file );        // use a text stream
            t << _sig;
            file.close();
        }
    }

    conf->setValue("synchronize", _synchronize);
    conf->setValue("deletemail", _deleteMail);

    conf->setValue("networkConfig", _networkCfg);
    conf->setValue("autoDownload", _autoDL);
}
开发者ID:Camelek,项目名称:qtmoko,代码行数:60,代码来源:accountconfiguration.cpp

示例3: encode

static QByteArray encode(const QByteArray& input, QMailMessageBody::TransferEncoding encoding)
{
    if (encoding == QMailMessageBody::Base64)
    {
        QMailBase64Codec codec(QMailBase64Codec::Text);
        return codec.encode(input);
    }
    else if (encoding == QMailMessageBody::QuotedPrintable)
    {
        QMailQuotedPrintableCodec codec(QMailQuotedPrintableCodec::Text, QMailQuotedPrintableCodec::Rfc2045);
        return codec.encode(input);
    }

    return input;
}
开发者ID:jose-g,项目名称:qt-labs-messagingframework,代码行数:15,代码来源:tst_qmailmessagebody.cpp

示例4: codec

SkAndroidCodec* SkAndroidCodec::NewFromStream(SkStream* stream, SkPngChunkReader* chunkReader) {
    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream, chunkReader));
    if (nullptr == codec) {
        return nullptr;
    }

    switch (codec->getEncodedFormat()) {
#ifdef SK_CODEC_DECODES_PNG
        case kPNG_SkEncodedFormat:
        case kICO_SkEncodedFormat:
#endif
#ifdef SK_CODEC_DECODES_JPEG
        case kJPEG_SkEncodedFormat:
#endif
#ifdef SK_CODEC_DECODES_GIF
        case kGIF_SkEncodedFormat:
#endif
        case kBMP_SkEncodedFormat:
        case kWBMP_SkEncodedFormat:
            return new SkSampledCodec(codec.detach());
#ifdef SK_CODEC_DECODES_WEBP
        case kWEBP_SkEncodedFormat:
            return new SkWebpAdapterCodec((SkWebpCodec*) codec.detach());
#endif
#ifdef SK_CODEC_DECODES_RAW
        case kRAW_SkEncodedFormat:
            return new SkRawAdapterCodec((SkRawCodec*)codec.detach());
#endif
        default:
            return nullptr;
    }
}
开发者ID:YangchenVR,项目名称:skia,代码行数:32,代码来源:SkAndroidCodec.cpp

示例5: test_dimensions

static void test_dimensions(skiatest::Reporter* r, const char path[]) {
    // Create the codec from the resource file
    SkAutoTDelete<SkStream> stream(resource(path));
    if (!stream) {
        SkDebugf("Missing resource '%s'\n", path);
        return;
    }
    SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.detach()));
    if (!codec) {
        ERRORF(r, "Unable to create codec '%s'", path);
        return;
    }

    // Check that the decode is successful for a variety of scales
    for (int sampleSize = 1; sampleSize < 32; sampleSize++) {
        // Scale the output dimensions
        SkISize scaledDims = codec->getSampledDimensions(sampleSize);
        SkImageInfo scaledInfo = codec->getInfo()
                .makeWH(scaledDims.width(), scaledDims.height())
                .makeColorType(kN32_SkColorType);

        // Set up for the decode
        size_t rowBytes = scaledDims.width() * sizeof(SkPMColor);
        size_t totalBytes = scaledInfo.getSafeSize(rowBytes);
        SkAutoTMalloc<SkPMColor> pixels(totalBytes);

        SkAndroidCodec::AndroidOptions options;
        options.fSampleSize = sampleSize;
        SkCodec::Result result =
                codec->getAndroidPixels(scaledInfo, pixels.get(), rowBytes, &options);
        REPORTER_ASSERT(r, SkCodec::kSuccess == result);
    }
}
开发者ID:atyenoria,项目名称:skia,代码行数:33,代码来源:CodexTest.cpp

示例6: getString

void LLFloaterBuyCurrencyHTML::navigateToFinalURL()
{
	// URL for actual currency buy contents is in XUI file
	std::string buy_currency_url = getString( "buy_currency_url" );

	// replace [LANGUAGE] meta-tag with view language
	LLStringUtil::format_map_t replace;

	// viewer language
	replace[ "[LANGUAGE]" ] = LLUI::getLanguage();

	// flag that specific amount requested 
	replace[ "[SPECIFIC_AMOUNT]" ] = ( mSpecificSumRequested ? "y":"n" );

	// amount requested
	std::ostringstream codec( "" );
	codec << mSum;
	replace[ "[SUM]" ] = codec.str();

	// users' current balance
	codec.clear();
	codec.str( "" );
	codec << gStatusBar->getBalance();
	replace[ "[BAL]" ] = codec.str();

	// message - "This cost L$x,xxx for example
	replace[ "[MSG]" ] = LLURI::escape( mMessage );
	LLStringUtil::format( buy_currency_url, replace );

	// write final URL to debug console
	llinfos << "Buy currency HTML prased URL is " << buy_currency_url << llendl;

	// kick off the navigation
	mBrowser->navigateTo( buy_currency_url, "text/html" );
}
开发者ID:jimjesus,项目名称:kittyviewer,代码行数:35,代码来源:llfloaterbuycurrencyhtml.cpp

示例7: get_bitmap

bool get_bitmap(sk_sp<SkData> fileBits, DiffResource& resource, bool sizeOnly) {
    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fileBits));
    if (!codec) {
        SkDebugf("ERROR: could not create codec for <%s>\n", resource.fFullPath.c_str());
        resource.fStatus = DiffResource::kCouldNotDecode_Status;
        return false;
    }

    if (!resource.fBitmap.setInfo(codec->getInfo().makeColorType(kN32_SkColorType))) {
        SkDebugf("ERROR: could not set bitmap info for <%s>\n", resource.fFullPath.c_str());
        resource.fStatus = DiffResource::kCouldNotDecode_Status;
        return false;
    }

    if (sizeOnly) {
        return true;
    }

    if (!resource.fBitmap.tryAllocPixels()) {
        SkDebugf("ERROR: could not allocate pixels for <%s>\n", resource.fFullPath.c_str());
        resource.fStatus = DiffResource::kCouldNotDecode_Status;
        return false;
    }

    if (SkCodec::kSuccess != codec->getPixels(resource.fBitmap.info(),
            resource.fBitmap.getPixels(), resource.fBitmap.rowBytes())) {
        SkDebugf("ERROR: codec failed for basePath <%s>\n", resource.fFullPath.c_str());
        resource.fStatus = DiffResource::kCouldNotDecode_Status;
        return false;
    }

    resource.fStatus = DiffResource::kDecoded_Status;
    return true;
}
开发者ID:aseprite,项目名称:skia,代码行数:34,代码来源:skdiff_utils.cpp

示例8: QByteArray

void PlayerSubtitle::onPlayerStart()
{
    if (!m_enabled)
        return;
    if (!autoLoad()) {
        if (m_file == m_sub->fileName())
            return;
        m_sub->setFileName(m_file);
        m_sub->setFuzzyMatch(false);
        if (m_file.isEmpty()) {
            const int n = m_player->currentSubtitleStream();
            if (n >= 0 && !m_tracks.isEmpty() && m_tracks.size() <= n) {
                m_sub->processHeader(QByteArray(), QByteArray()); // reset
                return;
            }
            QVariantMap track = m_tracks[n].toMap();
            QByteArray codec(track.value("codec").toByteArray());
            QByteArray data(track.value("extra").toByteArray());
            m_sub->processHeader(codec, data);
        } else {
            m_sub->loadAsync();
        }
        return;
    }
    if (m_file != m_sub->fileName())
        return;
    if (!m_player)
        return;
    // autoLoad was false then reload then true then reload
    // previous loaded is user selected subtitle
    m_sub->setFileName(getSubtitleBasePath(m_player->file()));
    m_sub->setFuzzyMatch(true);
    m_sub->loadAsync();
    return;
}
开发者ID:elearning2015,项目名称:QtAV,代码行数:35,代码来源:PlayerSubtitle.cpp

示例9: attributes

void EntityEditor::submitChanges()
{
	if (mRootAdapter->hasChanges()) {
		Atlas::Message::Element rootElement = mRootAdapter->getSelectedChangedElements();
		if (rootElement.isMap()) {
			std::map<std::string, ::Atlas::Message::Element> attributes(rootElement.asMap());
			if (attributes.size()) {

				std::stringstream ss;

				Atlas::Message::QueuedDecoder decoder;

				Atlas::Codecs::XML codec(ss, decoder);
				Atlas::Formatter formatter(ss, codec);
				Atlas::Message::Encoder encoder(formatter);
				formatter.streamBegin();
				encoder.streamMessageElement(attributes);
				formatter.streamEnd();
				S_LOG_VERBOSE("Sending attribute update to server:\n" << ss.str());

				EmberServices::getSingleton().getServerService().setAttributes(&mEntity, attributes);
			}
		}
	}
}
开发者ID:Laefy,项目名称:ember,代码行数:25,代码来源:EntityEditor.cpp

示例10: main

int main( int argc, char* argv[] )
{
  //! [Creating a Convolutional code]
  //! [Creating a Convolutional code structure]
  //! [Creating a trellis]
  /*
   We are creating a trellis structure with 1 input bit.
   The constraint length is 4, which means there are 3 registers associated
   with the input bit.
   There are two output bits, the first one with generator 4 (in octal) associated
   with the input bit.
   */
  fec::Trellis trellis({4}, {{013, 017}}, {015});
  //! [Creating a trellis]
  
  /*
   The trellis is used to create a code structure.
   We specify that one bloc will conatins 1024 branches before being terminated.
   */
  auto options = fec::Convolutional::Options(trellis, 1024);
  options.termination(fec::Convolutional::Tail);
  options.algorithm(fec::Approximate);
  //! [Creating a Convolutional code structure]
  
  /*
   A code is created and ready to operate
   */
  std::unique_ptr<fec::Codec> codec(new fec::Convolutional(options));
  //! [Creating a Convolutional code]
  
  std::cout << per(codec, 3.0) << std::endl;
  
  return 0;
}
开发者ID:eti-p-doray,项目名称:FeCl,代码行数:34,代码来源:Convolutional.cpp

示例11: codec

/*!
    Returns the string \a value encoded into base-64 encoded form.
*/
QString QMailServiceConfiguration::encodeValue(const QString &value)
{
    // TODO: Shouldn't this be UTF-8?
    QMailBase64Codec codec(QMailBase64Codec::Text);
    QByteArray encoded(codec.encode(value, "ISO-8859-1"));
    return QString::fromLatin1(encoded.constData(), encoded.length());
}
开发者ID:blammit,项目名称:messagingframework,代码行数:10,代码来源:qmailserviceconfiguration.cpp

示例12: codec

void ColorCodecBench::decodeAndXformQCMS() {
    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fEncoded));
#ifdef SK_DEBUG
    const SkCodec::Result result =
#endif
    codec->startScanlineDecode(fSrcInfo);
    SkASSERT(SkCodec::kSuccess == result);

    SkAutoTCallVProc<qcms_profile, qcms_profile_release>
            srcSpace(qcms_profile_from_memory(fSrcData->data(), fSrcData->size()));
    SkASSERT(srcSpace);

    SkAutoTCallVProc<qcms_transform, qcms_transform_release>
            transform (qcms_transform_create(srcSpace, QCMS_DATA_RGBA_8, fDstSpaceQCMS.get(),
                                             QCMS_DATA_RGBA_8, QCMS_INTENT_PERCEPTUAL));
    SkASSERT(transform);

#ifdef SK_PMCOLOR_IS_RGBA
    qcms_output_type outType = QCMS_OUTPUT_RGBX;
#else
    qcms_output_type outType = QCMS_OUTPUT_BGRX;
#endif

    void* dst = fDst.get();
    for (int y = 0; y < fSrcInfo.height(); y++) {
#ifdef SK_DEBUG
        const int rows =
#endif
        codec->getScanlines(fSrc.get(), 1, 0);
        SkASSERT(1 == rows);

        qcms_transform_data_type(transform, fSrc.get(), dst, fSrcInfo.width(), outType);
        dst = SkTAddOffset<void>(dst, fDstInfo.minRowBytes());
    }
}
开发者ID:aseprite,项目名称:skia,代码行数:35,代码来源:ColorCodecBench.cpp

示例13: streamDeleter

SkCodec* SkCodec::NewFromStream(SkStream* stream) {
    if (!stream) {
        return NULL;
    }

    SkAutoTDelete<SkStream> streamDeleter(stream);
    
    SkAutoTDelete<SkCodec> codec(NULL);
    for (uint32_t i = 0; i < SK_ARRAY_COUNT(gDecoderProcs); i++) {
        DecoderProc proc = gDecoderProcs[i];
        const bool correctFormat = proc.IsFormat(stream);
        if (!stream->rewind()) {
            return NULL;
        }
        if (correctFormat) {
            codec.reset(proc.NewFromStream(streamDeleter.detach()));
            break;
        }
    }

    // Set the max size at 128 megapixels (512 MB for kN32).
    // This is about 4x smaller than a test image that takes a few minutes for
    // dm to decode and draw.
    const int32_t maxSize = 1 << 27;
    if (codec && codec->getInfo().width() * codec->getInfo().height() > maxSize) {
        SkCodecPrintf("Error: Image size too large, cannot decode.\n");
        return NULL;
    } else {
        return codec.detach();
    }
}
开发者ID:webbjiang,项目名称:skia,代码行数:31,代码来源:SkCodec.cpp

示例14: main

int main(int argc, char **argv)
{
  struct stat sbuf;
  const char *fname = "test.jpg";
  FlowImage image("image");
  if (stat(fname, &sbuf))
    toast("stat error");
  printf("file has %d bytes.\n", sbuf.st_size);
  if (sbuf.st_size <= 0)
    toast("file has zero size.\n");
  image.set_data_size(sbuf.st_size);
  FILE *f = fopen(fname, "rb");
  int num_read = fread(image.data, 1, sbuf.st_size, f);
  if (num_read != sbuf.st_size)
    toast("couldn't read entire file\n");
  printf("read %d bytes\n", num_read);
  image.compression = "jpeg";
  image.colorspace = "rgb24";
  image.width = 200;
  image.height = 153;
  ImageCodec<FlowImage> codec(&image);
  uint8_t *raster;
  if (!(raster = codec.get_raster()))
    printf("couldn't get raster\n");
  else
  {
    printf("got raster of %d bytes\n", codec.get_raster_size());
    codec.write_file("out.ppm");
    codec.write_file("out.jpg", 5);
  }

  return 0;
}
开发者ID:janfrs,项目名称:kwc-ros-pkg,代码行数:33,代码来源:get_raster.cpp

示例15: TEST

TEST(TextCodecLatin1Test, QuestionMarksAndSurrogates) {
  WTF::TextEncoding encoding("windows-1252");
  std::unique_ptr<WTF::TextCodec> codec(newTextCodec(encoding));

  {
    const LChar testCase[] = {0xd1, 0x16, 0x86};
    size_t testCaseSize = WTF_ARRAY_LENGTH(testCase);
    CString result = codec->encode(testCase, testCaseSize,
                                   WTF::QuestionMarksForUnencodables);
    EXPECT_STREQ("\xd1\x16?", result.data());
  }
  {
    const UChar testCase[] = {0xd9f0, 0xdcd9};
    size_t testCaseSize = WTF_ARRAY_LENGTH(testCase);
    CString result = codec->encode(testCase, testCaseSize,
                                   WTF::QuestionMarksForUnencodables);
    EXPECT_STREQ("?", result.data());
  }
  {
    const UChar testCase[] = {0xd9f0, 0xdcd9, 0xd9f0, 0xdcd9};
    size_t testCaseSize = WTF_ARRAY_LENGTH(testCase);
    CString result = codec->encode(testCase, testCaseSize,
                                   WTF::QuestionMarksForUnencodables);
    EXPECT_STREQ("??", result.data());
  }
}
开发者ID:mirror,项目名称:chromium,代码行数:26,代码来源:TextCodecLatin1Test.cpp


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