<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[copy eveery second byte]]></title><description><![CDATA[<p>Hallo ich möchte von nem byte array mit Bildaten jedes zweite Byte in ein neues Array kopieren. (YUV -&gt; gray)</p>
<p>memcpy kann mir ja nur das gesammte Array kopieren.<br />
und for schleife ist zu langsamm</p>
<p>compiler ist gcc.<br />
ach so ja und sprache ist c++</p>
<p>vielen dank schonmal<br />
Felix</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/321410/copy-eveery-second-byte</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Jul 2026 08:01:27 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/321410.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 10 Nov 2013 15:52:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to copy eveery second byte on Sun, 10 Nov 2013 15:52:00 GMT]]></title><description><![CDATA[<p>Hallo ich möchte von nem byte array mit Bildaten jedes zweite Byte in ein neues Array kopieren. (YUV -&gt; gray)</p>
<p>memcpy kann mir ja nur das gesammte Array kopieren.<br />
und for schleife ist zu langsamm</p>
<p>compiler ist gcc.<br />
ach so ja und sprache ist c++</p>
<p>vielen dank schonmal<br />
Felix</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2364742</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2364742</guid><dc:creator><![CDATA[flexbex]]></dc:creator><pubDate>Sun, 10 Nov 2013 15:52:00 GMT</pubDate></item><item><title><![CDATA[Reply to copy eveery second byte on Sun, 10 Nov 2013 16:03:50 GMT]]></title><description><![CDATA[<blockquote>
<p>und for schleife ist zu langsamm</p>
</blockquote>
<p>Wut?</p>
<pre><code>unsigned char* resptr = zweitesarray;
for( unsigned char* ptr = array; ptr &lt; array + sizeof(array); ptr += 2 )
    *resptr++ = *ptr;
</code></pre>
<p>Oder so ähnlich.</p>
<blockquote>
<p>ach so ja und sprache ist c++</p>
</blockquote>
<p>Das hoffe ich doch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2364745</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2364745</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Sun, 10 Nov 2013 16:03:50 GMT</pubDate></item><item><title><![CDATA[Reply to copy eveery second byte on Sun, 10 Nov 2013 16:18:21 GMT]]></title><description><![CDATA[<p>ok ein Denkfehler hab ich bei mir schonmal gefunden ich kann natürlich die 2er iteration im Schleifen kopf machen . Ich hatte das nochmal extra gemacht.;-)<br />
problem sehe ich aber sonst noch das ich bei jedem byte nen abgleich machen muss ob ich schon am ende bin.<br />
Ich hatte letztens was cooles gefunden<br />
<a href="http://en.wikipedia.org/wiki/Duff%27s_device" rel="nofollow">http://en.wikipedia.org/wiki/Duff's_device</a><br />
das könnte ich ja auch mal probieren</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2364751</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2364751</guid><dc:creator><![CDATA[flexbex]]></dc:creator><pubDate>Sun, 10 Nov 2013 16:18:21 GMT</pubDate></item><item><title><![CDATA[Reply to copy eveery second byte on Sun, 10 Nov 2013 16:28:42 GMT]]></title><description><![CDATA[<p>flexbex schrieb:</p>
<blockquote>
<p>Ich hatte letztens was cooles gefunden<br />
<a href="http://en.wikipedia.org/wiki/Duff%27s_device" rel="nofollow">http://en.wikipedia.org/wiki/Duff's_device</a><br />
das könnte ich ja auch mal probieren</p>
</blockquote>
<p>Das erzeugt aber meiner Erfahrung nach heutzutage langsameren Code als eine naive Schleife. Probier's aber trotzdem mal aus, allein schon wegen dem Coolnessfaktor <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2364754</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2364754</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sun, 10 Nov 2013 16:28:42 GMT</pubDate></item><item><title><![CDATA[Reply to copy eveery second byte on Sun, 10 Nov 2013 16:29:21 GMT]]></title><description><![CDATA[<p>Der Compiler sollte (hoffentlich) loop-unrolling selber versuchen, zumindest mit -O3.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2364755</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2364755</guid><dc:creator><![CDATA[Marthog]]></dc:creator><pubDate>Sun, 10 Nov 2013 16:29:21 GMT</pubDate></item><item><title><![CDATA[Reply to copy eveery second byte on Sun, 10 Nov 2013 16:29:49 GMT]]></title><description><![CDATA[<p>flexbex schrieb:</p>
<blockquote>
<p><a href="http://en.wikipedia.org/wiki/Duff%27s_device" rel="nofollow">http://en.wikipedia.org/wiki/Duff's_device</a><br />
das könnte ich ja auch mal probieren</p>
</blockquote>
<p>Völlig falscher Optimierungs-Ansatz. Das können alle Compiler schon.</p>
<p>Nehme deinen Code, paste ihn in <a href="http://gcc.godbolt.org/" rel="nofollow">http://gcc.godbolt.org/</a> und vergleiche mit oder ohne deine Mikrooptimierungen. Ist beides gleich.</p>
<p>Was etwas bringt, ist das SSE3, insbesondere die PSHUFB Instruction.</p>
<p>Ich bringe es aber nicht fertig, besseren Assemblercode als der Compiler zu schreiben, deshalb nimm einfach die einfachste Implementierung</p>
<pre><code class="language-cpp">void everysecond(unsigned char *__restrict dest, unsigned char *__restrict src, size_t n)
{
   for (; n--; src += 2)
    *dest++ = *src;
}
</code></pre>
<p>und kompiliere mit O3 -march=native.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2364756</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2364756</guid><dc:creator><![CDATA[pshufb]]></dc:creator><pubDate>Sun, 10 Nov 2013 16:29:49 GMT</pubDate></item><item><title><![CDATA[Reply to copy eveery second byte on Sun, 10 Nov 2013 16:35:05 GMT]]></title><description><![CDATA[<p>danke schonmal für die Seite die ist ja super.<br />
Kannte ich noch nich. Werds mir ma anschauen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2364758</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2364758</guid><dc:creator><![CDATA[flexbex]]></dc:creator><pubDate>Sun, 10 Nov 2013 16:35:05 GMT</pubDate></item><item><title><![CDATA[Reply to copy eveery second byte on Sun, 10 Nov 2013 18:37:00 GMT]]></title><description><![CDATA[<p>Habs jetzt so gemacht:</p>
<pre><code>for (i = 0; i &lt; 2 * cropY * imgSizeX; i += 2 * imgSizeX) {
			for (j=0; j &lt; 2 * cropX; j += 2) {
				*(targetBuffer++) = *(sourceBuffer + j + i);
 }
}
</code></pre>
<p>durch cropX und cropY wird das Bild noch beschnitten gleichzeitig</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2364779</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2364779</guid><dc:creator><![CDATA[flexbex]]></dc:creator><pubDate>Sun, 10 Nov 2013 18:37:00 GMT</pubDate></item><item><title><![CDATA[Reply to copy eveery second byte on Sun, 10 Nov 2013 21:49:32 GMT]]></title><description><![CDATA[<p>Die for-schleife könntest du noch mit OpenMP oder etwas vergleichhbaren parallelisieren, sodass mehrere Threads daran arbeiten.<br />
Auf jeden Fall wird das ganze ziemlich unübersichtlich und du solltest unbedingt gründlich und viel kommentieren. Gerade bei solchen hochoptimierten Ausschnitten ist es durchaus vernünftig, mehr Zeilen Kommentar zu haben als Code.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2364832</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2364832</guid><dc:creator><![CDATA[Marthog]]></dc:creator><pubDate>Sun, 10 Nov 2013 21:49:32 GMT</pubDate></item></channel></rss>