本文整理汇总了C++中Coder类的典型用法代码示例。如果您正苦于以下问题:C++ Coder类的具体用法?C++ Coder怎么用?C++ Coder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Coder类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Viewer
void Editor::open(const QFileInfo &info)
{
if (!info.exists() || !info.isFile())
return;
int index = files->findData(info.absoluteFilePath());
if (index >= 0) {
files->setCurrentIndex(index);
return;
}
QWidget *widget;
if (QString(ALLOWED_IMAGE_EXTENSIONS).contains(info.suffix())) {
Viewer *viewer = new Viewer(tabs);
viewer->open(info);
widget = viewer;
} else if (QString(ALLOWED_TEXT_EXTENSIONS).contains(info.suffix())) {
Coder *coder = new Coder(tabs);
coder->open(info);
widget = coder;
} else
return;
QIcon icon = (editables.contains(info.suffix()) ? ::icon(info.suffix()) : ::icon("file"));
index = tabs->addTab(widget, icon, info.fileName());
files->addItem(icon, info.fileName(), info.absoluteFilePath());
files->setCurrentIndex(index);
tabs->setTabToolTip(index, info.absoluteFilePath());
widget->setFocus();
widget->setProperty("path", info.absoluteFilePath());
}
示例2:
int
Coder::getBuffer(struct AVCodecContext *s, AVFrame *frame, int flags) {
Coder* coder = static_cast<Coder*>(s->opaque);
if (!coder)
return avcodec_default_get_buffer2(s, frame, flags);
if (!(coder->mCodec->getCapabilities() & Codec::CAP_DR1))
return avcodec_default_get_buffer2(s, frame, flags);
return coder->prepareFrame(frame, flags);
}
示例3: new
Coder* Coder::createWithArchiver(Archiver* archiver)
{
Coder* ref = new (std::nothrow) Coder();
if (ref && ref->initWithArchiver(archiver)) {
ref->autorelease();
return ref;
} else {
CC_SAFE_RELEASE(ref);
return nullptr;
}
}
示例4: widget
void EditorTabs::onEditCut()
{
int i;
if ((i = currentIndex()) >= 0)
{
QWidget *w = widget(i);
Coder *c;
if (w && (c = dynamic_cast<Coder *>(w)))
{
c->cut();
}
}
}
示例5: save
void Editor::save(const bool all)
{
int index = all ? 0 : files->currentIndex();
if (index < 0)
return;
do {
Coder *coder = qobject_cast<Coder *>(tabs->widget(index));
if (coder != nullptr)
coder->save();
else {
Viewer *viewer = qobject_cast<Viewer *>(tabs->widget(index));
if (viewer != nullptr)
viewer->save();
}
index++;
} while (all && (index < files->count()));
}
示例6: objectIsSaved
void Archiver::generateValueMap(EncodableObject* object)
{
if (object == nullptr ||
objectIsSaved(object))
{
return;
}
addUniqueObject(object);
Coder* coder = Coder::createWithArchiver(this);
object->encodeWithCoder(coder);
//coder->addObjectValuesToValueMap();
addValueMap(coder->getValueMap(), getReferenceIndexOfObject(object));
}
示例7: set_trace_callback
void set_trace_callback(Coder& coder, PyObject* function)
{
auto callback = [function](
const std::string& zone, const std::string& message)
{
boost::python::call<void>(function, zone, message);
};
coder.set_trace_callback(callback);
}
示例8: test_coder_array
void test_coder_array(Coder<vT, bsT> &coder, vT *arr, uint64_t npoints) {
unsigned char *outbits = static_cast<unsigned char*>(
calloc(npoints*BUF_SCALE_FACTOR+12, sizeof(vT)));
uint64_t outsize = sizeof(vT)*(npoints*BUF_SCALE_FACTOR+12);
uint64_t insize = npoints;
outbits = coder.enc(outbits, &outsize, static_cast<vT*>(arr), insize);
vT* dout = static_cast<vT*>(malloc(sizeof(vT)*(npoints*BUF_SCALE_FACTOR+12)));
dout = coder.dec(dout, &insize, outbits, outsize);
if ( memcmp(dout, arr, npoints*sizeof(vT)) ) {
cout << "Roundtrip error!" << endl;
cout << " in:";
print_arr(arr, min(static_cast<uint64_t>(20), npoints));
cout << endl;
cout << "out:";
print_arr(dout, min(static_cast<uint64_t>(20), npoints));
}
free(dout);
free(outbits);
}
示例9: read_subtree
bool read_subtree(int pos, Ranges &subrange, Tree &tree) {
PropertyDecisionNode &n = tree[pos];
int p = n.property = coder.read_int(0,nb_properties)-1;
if (p != -1) {
int oldmin = subrange[p].first;
int oldmax = subrange[p].second;
if (oldmin >= oldmax) {
e_printf( "Invalid tree. Aborting tree decoding.\n");
return false;
}
n.count = coder.read_int(CONTEXT_TREE_MIN_COUNT, CONTEXT_TREE_MAX_COUNT); // * CONTEXT_TREE_COUNT_QUANTIZATION;
assert(oldmin < oldmax);
int splitval = n.splitval = coder.read_int(oldmin, oldmax-1);
int childID = n.childID = tree.size();
// e_printf( "Pos %i: prop %i splitval %i in [%i..%i]\n", pos, n.property, splitval, oldmin, oldmax-1);
tree.push_back(PropertyDecisionNode());
tree.push_back(PropertyDecisionNode());
// > splitval
subrange[p].first = splitval+1;
if (!read_subtree(childID, subrange, tree)) return false;
// <= splitval
subrange[p].first = oldmin;
subrange[p].second = splitval;
if (!read_subtree(childID+1, subrange, tree)) return false;
subrange[p].second = oldmax;
}
return true;
}
示例10: read_int
int read_int(Properties &properties, int nbits) {
#ifdef STATS
symbols++;
#endif
CompoundSymbolChances<BitChance,bits> &chances = find_leaf(properties);
set_selection_and_update_property_sums(properties,chances);
CompoundSymbolChances<BitChance,bits> &chances2 = find_leaf(properties);
return coder.read_int(chances2, selection, nbits);
}
示例11: write_int
void write_int(Properties &properties, int nbits, int val) {
#ifdef STATS
symbols++;
#endif
CompoundSymbolChances<BitChance,bits> &chances = find_leaf(properties);
set_selection_and_update_property_sums(properties,chances);
CompoundSymbolChances<BitChance,bits> &chances2 = find_leaf(properties);
coder.write_int(chances2, selection, nbits, val);
}
示例12: write_subtree
void write_subtree(int pos, Ranges &subrange, const Tree &tree) {
const PropertyDecisionNode &n = tree[pos];
int p = n.property;
coder.write_int(0,nb_properties,p+1);
if (p != -1) {
coder.write_int(CONTEXT_TREE_MIN_COUNT, CONTEXT_TREE_MAX_COUNT, n.count);
// printf("From properties 0..%i, split node at PROPERTY %i\n",nb_properties-1,p);
int oldmin = subrange[p].first;
int oldmax = subrange[p].second;
assert(oldmin < oldmax);
coder.write_int(oldmin, oldmax-1, n.splitval);
// e_printf( "Pos %i: prop %i splitval %i in [%i..%i]\n", pos, n.property, n.splitval, oldmin, oldmax-1);
// > splitval
subrange[p].first = n.splitval+1;
write_subtree(n.childID, subrange, tree);
// <= splitval
subrange[p].first = oldmin;
subrange[p].second = n.splitval;
write_subtree(n.childID+1, subrange, tree);
subrange[p].second = oldmax;
}
}
示例13: write_int
void write_int(Properties &properties, int min, int max, int val) {
CompoundSymbolChances<BitChance,bits> &chances = find_leaf(properties);
set_selection_and_update_property_sums(properties,chances);
CompoundSymbolChances<BitChance,bits> &chances2 = find_leaf(properties);
coder.write_int(chances2, selection, min, max, val);
}
示例14: read_int
int read_int(Properties &properties, int min, int max) {
CompoundSymbolChances<BitChance,bits> &chances = find_leaf(properties);
set_selection_and_update_property_sums(properties,chances);
CompoundSymbolChances<BitChance,bits> &chances2 = find_leaf(properties);
return coder.read_int(chances2, selection, min, max);
}