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


C++ Encoder::encode方法代码示例

本文整理汇总了C++中Encoder::encode方法的典型用法代码示例。如果您正苦于以下问题:C++ Encoder::encode方法的具体用法?C++ Encoder::encode怎么用?C++ Encoder::encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Encoder的用法示例。


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

示例1: payload

inline void
invoke_reuse_helper(Encoder encoder, Decoder decoder)
{
    std::vector<uint8_t> payload(encoder->payload_size());

    std::vector<uint8_t> data_in = random_vector(encoder->block_size());
    sak::mutable_storage storage_in = sak::storage(data_in);

    encoder->set_symbols(storage_in);

    // Set the encoder non-systematic
    if(kodo::is_systematic_encoder(encoder))
        kodo::set_systematic_off(encoder);

    while( !decoder->is_complete() )
    {
        uint32_t payload_used = encoder->encode( &payload[0] );
        EXPECT_TRUE(payload_used <= encoder->payload_size());

        decoder->decode( &payload[0] );
    }

    std::vector<uint8_t> data_out(decoder->block_size(), '\0');
    decoder->copy_symbols(sak::storage(data_out));

    EXPECT_TRUE(std::equal(data_out.begin(),
                           data_out.end(),
                           data_in.begin()));

}
开发者ID:liuleger,项目名称:kodo,代码行数:30,代码来源:test_reuse.hpp

示例2: x265_encoder_encode

int x265_encoder_encode(x265_encoder *enc, x265_nal **pp_nal, uint32_t *pi_nal, x265_picture *pic_in, x265_picture *pic_out)
{
    if (!enc)
        return -1;

    Encoder *encoder = static_cast<Encoder*>(enc);
    int numEncoded;

    // While flushing, we cannot return 0 until the entire stream is flushed
    do
    {
        numEncoded = encoder->encode(pic_in, pic_out);
    }
    while (numEncoded == 0 && !pic_in && encoder->m_numDelayedPic);

    // do not allow reuse of these buffers for more than one picture. The
    // encoder now owns these analysisData buffers.
    if (pic_in)
    {
        pic_in->analysisData.intraData = NULL;
        pic_in->analysisData.interData = NULL;
    }

    if (pp_nal && numEncoded > 0)
    {
        *pp_nal = &encoder->m_nalList.m_nal[0];
        if (pi_nal) *pi_nal = encoder->m_nalList.m_numNal;
    }
    else if (pi_nal)
        *pi_nal = 0;

    return numEncoded;
}
开发者ID:JamesLinus,项目名称:x265,代码行数:33,代码来源:api.cpp

示例3: write

/**
 * Writes a description of the graph to the given stream, using the Dot 
 * language.
 * The method allows for both directed graphs and non-directed graphs, the
 * latter are required for drawing purposes (since Dot will not produce the
 * arrow heads and the splines terminate before reaching the nodes).
 * @param	str			The stream to write to
 * @param	sType		Either "graph" or "digraph"
 * @param	sEdge		The edge connector ("--" or "->")
 * @param	bWriteCall	true to write call information, false otherwise
 */
void GraphWidget::write(QTextStream& str, const QString& sType, 
	const QString& sEdge, bool bWriteCall)
{
	QFont font;
	QDictIterator<GraphNode> itr(m_dictNodes);
	GraphEdge* pEdge;
	Encoder enc;
	
	font = Config().getFont(KScopeConfig::Graph);

	// Header
	str << sType << " G {\n";
	
	// Graph attributes
	str << "\tgraph [rankdir=" << Config().getGraphOrientation() << ", "
		<< "kscope_zoom=" << m_dZoom 
		<< "];\n";
	
	// Default node attributes
	str << "\tnode [shape=box, height=\"0.01\", style=filled, "
		<< "fillcolor=\"" << Config().getColor(KScopeConfig::GraphNode).name()
		<< "\", "
		<< "fontcolor=\"" << Config().getColor(KScopeConfig::GraphText).name()
		<< "\", "
		<< "fontname=\"" << font.family() << "\", "
		<< "fontsize=" << QString::number(font.pointSize())
		<< "];\n";
	
	// Iterate over all nodes
	for (; itr.current(); ++itr) {
		// Write a node
		str << "\t" << itr.current()->getFunc() << ";\n";
		
		// Iterate over all edges leaving this node		
		QDictIterator<GraphEdge> itrEdge(itr.current()->getOutEdges());
		for (; itrEdge.current(); ++itrEdge) {
			pEdge = itrEdge.current();
			str << "\t" << pEdge->getHead()->getFunc() << sEdge
				<< pEdge->getTail()->getFunc();
				
			// Write call information
			if (bWriteCall) {
				str << " ["
					<< "kscope_file=\"" << pEdge->getFile() << "\","
					<< "kscope_line=" << pEdge->getLine() << ","
					<< "kscope_text=\"" << enc.encode(pEdge->getText()) << "\"" 
					<< "]";
			}
			
			str << ";\n";
		}
	}
	
	// Close the graph
	str << "}\n";
}
开发者ID:fredollinger,项目名称:kscope-kde4,代码行数:67,代码来源:graphwidget4.cpp

示例4: encode

  /**
   * \brief Encode to XDQP stream
   */
  void encode(Encoder& e, Reporter& reporter) {
    try {
      // TODO consider gzip compression at this top level, and using a std::ostringstream to collate values (optional setting at aggregate level)

      // no need to encode resultTypeRef as that's handled in the start() or clone() function
      // do need to encode count though
      e.encode((int)interimValues.size());
      for (auto ivi = interimValues.begin();ivi != interimValues.end();++ivi) {
        ivi->second->encode(e,reporter);
      }
    } catch (std::exception& ex) {
      reporter.error(("Exception in encode(): " + std::string(ex.what())).c_str());
    }
  }
开发者ID:adamfowleruk,项目名称:mlcplusplus,代码行数:17,代码来源:groupandaggregateudf.cpp

示例5: saveItems

/**
 * Recursively writes tree items to a file.
 * Given an item, the method writes this item and all of its siblings.
 * Child items are written recursively.
 * @param	pItem	The first item to write
 * @param	str		An initialised text stream to use for writing
 * @param	enc		An encoder for free-text strings
 */
void TreeWidget::saveItems(QListViewItem* pItem, QTextStream& str, Encoder& enc)
{
	// Iterate over all items in this level
	for (; pItem != NULL; pItem = pItem->nextSibling()) {
		// Write function parameters
		str << pItem->text(0) << " [ "
			<< "kscope_file=\"" << pItem->text(1) << "\", "
			<< "kscope_line=" << pItem->text(2) << ", "
			<< "kscope_text=\"" << enc.encode(pItem->text(3)) << "\""
			<< "]" << endl;
		
		// Write child items
		str << "{" << endl;
		saveItems(pItem->firstChild(), str, enc);
		str << "}" << endl;
	}
}
开发者ID:fredollinger,项目名称:kscope,代码行数:25,代码来源:treewidget.cpp

示例6: encode

/**
 * Does the real encoding of the instructions
 */
void Assembler::encode(string outputFile){
	ofstream output(outputFile);
	string binInst;
	for(size_t i=0;i<instructions.size();i++){
		string inst = instructions[i];
		for(size_t j=0;j<dictionary.size();j++){
			Encoder e = dictionary[j];
			if(e.match(inst)){
				binInst=e.encode(inst,i,labels);
				output<<binInst<<endl;
				binInstructions.push_back(binInst);
			}
		}
	}
	output.close();
//	cout<<"Output succesfully written to "<< endl << outputFile;
}
开发者ID:SaiKeshav,项目名称:simMIPS,代码行数:20,代码来源:MainAssembler.cpp

示例7: main

int main(int argc, char ** argv)
{
	// Get the command arguments
    Command command(argc, argv);

	// Check no. of mandatory arguments (2)
    if(command.size() < 2)
    {
        cerr << "sample: Must specify 2 filenames: data, scaled data" 
             << endl;
        return 1;
    }
    
	table<double> data;
	ifstream fin(command.arg(0).c_str(), ios::in);
	fin >> data;
	fin.close();
	 
	Encoder * encoder;
	
	if(command.find("-s") != command.end())
	{
		double a = 0.0;
		if(command.find("-a") != command.end())
			command.get("-a", a);
		
		double b = 0.0;
		if(command.find("-b") != command.end())
			command.get("-b", b);
		
		encoder = new Scaler(data, a, b);
	}
	else 
	{
		encoder = new Standardiser(data);
	}
	
	encoder->encode(data);
	
	ofstream fout(command.arg(1).c_str(), ios::out);
	fout << data << endl;
	fout.close();
	
 	return 0;   
}
开发者ID:Re-bort,项目名称:NNDK,代码行数:45,代码来源:encode.cpp

示例8: encode

void Item::encode(Encoder& encoder) const
{
	encoder.encode(typeID_);
	encoder.encode(groupID_);
	encoder.encode(categoryID_);
	
	{
		AttributesMap::const_iterator i, end = attributes_.end();
		encoder.encode(attributes_.size());
		for (i = attributes_.begin(); i != end; i++)
			i->second->encode(encoder);
	}
	{
		EffectsList::const_iterator i, end = effects_.end();
		encoder.encode(effects_.size());
		for (i = effects_.begin(); i != end; i++)
			encoder.encode((*i)->getEffectID());
	}

}
开发者ID:reckhou,项目名称:eufe,代码行数:20,代码来源:Item.cpp

示例9: encode_decode_chunkwise

void encode_decode_chunkwise(bool encode, const Codec *codec,
                             const QByteArray &infile_buffer, QFile &outfile)
{
    Encoder *enc = 0;
    Decoder *dec = 0;


    QByteArray indata(inbufsize);
    QByteArray outdata(outbufsize);

    // we're going to need this below:
#define write_full_outdata_then_reset  do { \
     kdDebug( verbose ) << "  flushing output buffer." << endl; \
     if ( writing ) { \
       Q_LONG outlen = outfile.writeBlock( outdata.data(), \
					   outdata.size() ); \
       if ( outlen != (int)outdata.size() ) \
         exit(OUTFILE_WRITE_ERR); \
     } \
     oit = outdata.begin(); \
   } while ( false )

#define report_status(x,y) do { \
     kdDebug( verbose ) << "  " #x "() returned " #y " after processing " \
                        << iit - indata.begin() << " bytes of input.\n" \
			<< "   output iterator now at position " \
			<< oit - outdata.begin() << " of " \
			<< outdata.size() << endl; \
  } while ( false )

#define report_finish_status(y) do { \
     kdDebug( verbose ) << "  finish() returned " #y "\n" \
			<< "   output iterator now at position " \
			<< oit - outdata.begin() << " of " \
			<< outdata.size() << endl; \
  } while ( false )


    // Initialize the output iterators:
    QByteArray::Iterator oit = outdata.begin();
    QByteArray::Iterator oend = outdata.end();

    // Get an encoder. This one you have to delete!
    if(encode)
    {
        enc = codec->makeEncoder(withCRLF);
        assert(enc);
    }
    else
    {
        dec = codec->makeDecoder(withCRLF);
        assert(dec);
    }

    //
    // Loop over input chunks:
    //
    uint offset = 0;
    while(offset < infile_buffer.size())
    {
        uint reallyRead = QMIN(indata.size(), infile_buffer.size() - offset);
        indata.duplicate(infile_buffer.begin() + offset, reallyRead);
        offset += reallyRead;

        kdDebug(verbose) << " read " << reallyRead << " bytes (max: "
                         << indata.size() << ") from input." << endl;

        // setup input iterators:
        QByteArray::ConstIterator iit = indata.begin();
        QByteArray::ConstIterator iend = indata.begin() + reallyRead;

        if(encode)
        {
            //
            // Loop over encode() calls:
            //
            while(!enc->encode(iit, iend, oit, oend))
            {
                report_status(encode, false);
                if(oit == oend)
                    // output buffer full:
                    write_full_outdata_then_reset;
            }
            report_status(encode, true);
        }
        else
        {
            //
            // Loop over decode() calls:
            //
            while(!dec->decode(iit, iend, oit, oend))
            {
                report_status(decode, false);
                if(oit == oend)
                    // output buffer full:
                    write_full_outdata_then_reset;
            }
            report_status(decode, true);
        }
    } // end loop over input chunks
//.........这里部分代码省略.........
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:101,代码来源:test_kmime_codec.cpp

示例10: oplug_mpegff

uint8_t oplug_mpegff(const char *name, ADM_OUT_FORMAT type)
{
AVDMGenericVideoStream *_incoming;
//EncoderFFMPEGMpeg1  *encoder;
Encoder  *encoder;

ADMMpegMuxer	*muxer=NULL;
FILE 		*file=NULL;
uint8_t		audioBuffer[48000];
uint32_t	audioLen=0;
uint32_t _w,_h,_fps1000,_page,total;	
AVDMGenericAudioStream	*audio;
uint32_t len,flags;
uint32_t size;
ADM_MUXER_TYPE mux;
uint32_t  audio_encoding=0;
uint32_t  real_framenum=0;
uint8_t   ret=0;
uint32_t  sample_target=0;
uint32_t  total_sample=0;
ADMBitstream bitstream(0);
uint32_t audioSum=0;

        twoPass=new char[strlen(name)+6];
        twoFake=new char[strlen(name)+6];
  
        strcpy(twoPass,name);
        strcat(twoPass,".stat");
        /* orig: strcat(twoFake,".fake"); */

        strcpy(twoFake,name);
        strcat(twoFake,".fake");
 
        _incoming = getLastVideoFilter (frameStart,frameEnd-frameStart);
        _w=_incoming->getInfo()->width;
        _h=_incoming->getInfo()->height;
        _fps1000=_incoming->getInfo()->fps1000;
        _page=_w*_h;
        _page+=_page>>1;

        total=_incoming->getInfo()->nb_frames;
        if(!total) return 0;	
        
        switch(type)
        {
            default:
                    ADM_assert(0);
            case ADM_ES:
                        // Else open file (if possible)                       
                        mux=MUXER_NONE;
                        break;
            case ADM_TS:
                    if(!currentaudiostream)
                    {
                      GUI_Error_HIG(_("There is no audio track"), NULL);
                        return 0;
                    }
                    audio=mpt_getAudioStream();
                    mux=MUXER_TS;
                    break;
            case ADM_PS:
            
            {
                if(!currentaudiostream)
                {
                  GUI_Error_HIG(_("There is no audio track"), NULL);
                        return 0;
                }
                audio=mpt_getAudioStream();
                // Have to check the type
                // If it is mpeg2 we use DVD-PS
                // If it is mpeg1 we use VCD-PS
                // Later check if it is SVCD
                if(!audio)
                {
                  GUI_Error_HIG(_("Audio track is not suitable"), NULL);
                        return 0;
                }
                // Check
                WAVHeader *hdr=audio->getInfo();	
                audio_encoding=hdr->encoding;
                if(current_codec==CodecXVCD ||current_codec==CodecVCD)
                {
                        if(hdr->frequency!=44100 ||  hdr->encoding != WAV_MP2)
                        {
                            GUI_Error_HIG(("Incompatible audio"),_( "For VCD, audio must be 44.1 kHz MP2."));
                            deleteAudioFilter(audio);
                            return 0;
                        }
                        mux=MUXER_VCD;
                        printf("X*CD: Using VCD PS\n");
                }else
                {    
                        aviInfo info;
                        video_body->getVideoInfo(&info);
                        if(hdr->frequency==44100 && _w==480&&hdr->encoding == WAV_MP2 ) // SVCD ?
                        {
                            mux=MUXER_SVCD;
                            printf("X*VCD: Using SVCD PS\n");
                        }
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:avidemux-svn,代码行数:101,代码来源:oplug_vcdff.cpp


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