/** * \fn encodeBlockMultiChannel * \brief encode a block when # of channels is > 2 * @param count * @return */ bool AUDMEncoder_Lavcodec::encodeBlockMultiChannels(int count, uint8_t *dest,int &encoded) { encoded=0; AVPacket pkt; // out av_init_packet(&pkt); pkt.size=5000; pkt.data=dest; if(!count) { return lastBlock(&pkt,encoded); } int gotPacket; int channel=wavheader.channels; int nbBlocks=count/channel; _frame->channels=wavheader.channels; _frame->channel_layout=CONTEXT->channel_layout; _frame->nb_samples=nbBlocks; CHANNEL_TYPE *f=_incoming->getChannelMapping(); CHANNEL_TYPE *o=channelMapping; int er; if( CONTEXT->sample_fmt == AV_SAMPLE_FMT_FLTP) { // reorder and de-interleave reorderToPlanar(&(tmpbuffer[tmphead]),planarBuffer,nbBlocks,f,o); er=avcodec_fill_audio_frame(_frame, channel, AV_SAMPLE_FMT_FLTP, (uint8_t *)planarBuffer, count*sizeof(float), 0); }else { dither16(&(tmpbuffer[tmphead]),count,channel); er=avcodec_fill_audio_frame(_frame, channel, AV_SAMPLE_FMT_S16, (uint8_t *)&(tmpbuffer[tmphead]), count*sizeof(uint16_t), 0); } if(er<0) { printError("Fill audio",er); return false; } int nbout = avcodec_encode_audio2(CONTEXT, &pkt,_frame,&gotPacket); if(nbout>=0 && gotPacket) { cprintf("Got %d bytes \n",pkt.size); encoded=pkt.size; } else { printError("Encoding",nbout); return false; } return true; }
QDateTime TextDocument::timestamp() const { if (d.visible) { if (TextBlockMessageData* block = static_cast<TextBlockMessageData*>(lastBlock().userData())) return block->data.timestamp(); } return d.timestamp; }
int inHeap(int *p) { //printf("Address is: %p\n",p); if ((*p) >= firstBlock()) { if ((*p) <= lastBlock()) { return 1; } } return 0; }
int *getHeader(int *p) { int *next = firstBlock(); while (next != lastBlock()) { if (*p >= next) { if (*p <= nextBlock(next)) { return next; } } next++; } }
void TextDocument::setVisible(bool visible) { if (d.visible != visible) { if (visible) { if (d.dirty > 0) flush(); } else { d.uc = 0; if (TextBlockMessageData* block = static_cast<TextBlockMessageData*>(lastBlock().userData())) d.timestamp = block->data.timestamp(); } d.visible = visible; } }
void TextDocument::append(const MessageData& data) { if (!data.isEmpty()) { MessageData last; if (!d.queue.isEmpty()) last = d.queue.last(); else if (TextBlockMessageData* block = static_cast<TextBlockMessageData*>(lastBlock().userData())) last = block->data; if (!last.isEmpty() && data.type() != IrcMessage::Unknown && data.timestamp().date() != last.timestamp().date()) { MessageData dc; dc.setFormat(QString("<p class='date'>%1</p>").arg(data.timestamp().date().toString(Qt::ISODate))); append(dc); } MessageData msg = data; const bool merge = last.canMerge(data); if (merge) { msg.merge(last); msg.setFormat(formatSummary(msg.getEvents())); if (!d.queue.isEmpty()) d.queue.replace(d.queue.count() - 1, msg); } else { if (d.timestamp < data.timestamp()) ++d.uc; else d.uc = 0; } if (!d.batch && (d.dirty == 0 || d.visible)) { QTextCursor cursor(this); cursor.beginEditBlock(); if (merge) { cursor.movePosition(QTextCursor::End); cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor); cursor.removeSelectedText(); cursor.deletePreviousChar(); } insert(cursor, msg); cursor.endEditBlock(); } else { if (!d.batch && d.dirty <= 0) { d.dirty = startTimer(delay); delay += 1000; } if (!merge) d.queue += msg; } } }
void sweep() { int *ptr = firstBlock(); while (ptr != lastBlock()) { if (isMarked(ptr)) { *ptr = (*ptr) - 2; } else { if (isAllocated(ptr)) { (*ptr)--; } } ptr = nextBlock(ptr); } coalesce(); }
template<> bool QConsoleWidget::_pf<bool, IsInEditorLastLine>( QConsoleWidget * thisp) { auto doc_ = thisp->document(); auto block_ = doc_->lastBlock(); auto tpos = thisp->textCursor().position(); if (block_.contains(tpos) == false) { return false; } auto blayout = block_.layout(); if (blayout) { if (blayout->lineCount()) { auto line0 = blayout->lineAt(blayout->lineCount()-1); auto line1 = blayout->lineForTextPosition(tpos - block_.position()); return (line0.lineNumber() == line1.lineNumber()); } } return false; }
void TextDocument::append(const MessageData& data) { if (!data.isEmpty()) { MessageData last; if (!d.queue.isEmpty()) last = d.queue.last(); else if (TextBlockMessageData* block = static_cast<TextBlockMessageData*>(lastBlock().userData())) last = block->data; MessageData msg = data; const bool merge = last.canMerge(data); if (merge) { msg.merge(last); msg.setFormat(formatSummary(msg.getEvents())); if (!d.queue.isEmpty()) d.queue.replace(d.queue.count() - 1, msg); } else { ++d.uc; } if (d.dirty == 0 || d.visible) { QTextCursor cursor(this); cursor.beginEditBlock(); if (merge) { cursor.movePosition(QTextCursor::End); cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor); cursor.removeSelectedText(); cursor.deletePreviousChar(); } insert(cursor, msg); cursor.endEditBlock(); } else { if (d.dirty <= 0) { d.dirty = startTimer(delay); delay += 1000; } if (!merge) d.queue += msg; } } }