<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>compression &#8211; Huahua&#8217;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/tag/compression/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog</link>
	<description></description>
	<lastBuildDate>Sat, 26 Apr 2025 15:13:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>

<image>
	<url>https://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/cropped-photo-32x32.jpg</url>
	<title>compression &#8211; Huahua&#8217;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Nikon Z8/Z9 Video Format / Bitrate / Compression ratio &#124; NRAW &#124; ProRes &#124; ProRes RAW &#124; H.265</title>
		<link>https://zxi.mytechroad.com/blog/photography/nikon-z8-prores-prores-raw-bitrate-and-compression-ratio/</link>
					<comments>https://zxi.mytechroad.com/blog/photography/nikon-z8-prores-prores-raw-bitrate-and-compression-ratio/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sat, 15 Jun 2024 17:26:28 +0000</pubDate>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[bitrate]]></category>
		<category><![CDATA[codec]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[nikon]]></category>
		<category><![CDATA[nraw]]></category>
		<category><![CDATA[prores]]></category>
		<category><![CDATA[prores raw]]></category>
		<category><![CDATA[z8]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=10121</guid>

					<description><![CDATA[The Nikon official site didn&#8217;t provide the birate for ProRes / ProRes RAW, I did some test my self, here&#8217;re the results. I only tested&#8230;]]></description>
										<content:encoded><![CDATA[
<p>The <a href="https://onlinemanual.nikonimglib.com/z8/en/video_frame_size_and_rate_options_41.html">Nikon official site</a> didn&#8217;t provide the birate for ProRes / ProRes RAW, I did some test my self, here&#8217;re the results. I only tested fullframe (FX) in ~4K resolution. </p>



<h2 class="wp-block-heading">ProRes Raw 12Bit</h2>



<style type="text/css">
	table.tableizer-table {
		font-size: 14px;
		border: 1px solid #CCC; 
		font-family: Arial, Helvetica, sans-serif;
	} 
	.tableizer-table td {
		padding: 4px;
		margin: 3px;
		border: 1px solid #CCC;
	}
	.tableizer-table th {
		background-color: #104E8B; 
		color: #FFF;
		font-weight: bold;
	}
</style>
<table class="tableizer-table">
<thead><tr class="tableizer-firstrow"><th>Resolution / FPS</th><th>Bitrate (Mbps)</th><th>Compression Ratio</th></tr></thead><tbody>
 <tr><td>4140 x 2330 60p</td><td>3350</td><td>1.977</td></tr>
 <tr><td>4140 x 2330 50p</td><td>2810</td><td>1.964</td></tr>
 <tr><td>4140 x 2330 30p</td><td>1620</td><td>2.044</td></tr>
 <tr><td>4140 x 2330 25p</td><td>1360</td><td>2.029</td></tr>
 <tr><td>4140 x 2330 24p</td><td>1280</td><td>2.070</td></tr>
</tbody></table>



<p>ProRes Raw has a very low compression ratio of 2, which suggests that it might be lossless compressed, which takes more spaces than Nikon&#8217;s lossy N-RAW, 2.5x of the high quality and 4.5x of the normal quality!</p>



<h2 class="wp-block-heading">ProRes HQ 422 10Bit</h2>



<style type="text/css">
	table.tableizer-table {
		font-size: 14px;
		border: 1px solid #CCC; 
		font-family: Arial, Helvetica, sans-serif;
	} 
	.tableizer-table td {
		padding: 4px;
		margin: 3px;
		border: 1px solid #CCC;
	}
	.tableizer-table th {
		background-color: #104E8B; 
		color: #FFF;
		font-weight: bold;
	}
</style>
<table class="tableizer-table">
<thead><tr class="tableizer-firstrow"><th>Resolution / FPS</th><th>Bitrate (Mbps)</th><th>Compression Ratio</th></tr></thead><tbody>
 <tr><td>3840 x 2160 60p</td><td>1800</td><td>5.273</td></tr>
 <tr><td>3840 x 2160 50p</td><td>1500</td><td>5.273</td></tr>
 <tr><td>3840 x 2160 30p</td><td>910</td><td>5.215</td></tr>
 <tr><td>3840 x 2160 25p</td><td>760</td><td>5.204</td></tr>
 <tr><td>3840 x 2160 24p</td><td>730</td><td>5.201</td></tr>
</tbody></table>



<p>With compression ratio of 5.2, ProRes is still 2x the size of the normal quality n-raw!  Though the former one has 1.5x number of pixels to deal with (YUV422 vs Bayer). </p>



<p>I hope Nikon could provide more options for ProRes via firmware updates. A 10x~12x compression ratio version (ProRes LT 422) will be very useful to balance between quality and disk space.</p>



<h2 class="wp-block-heading">H.265 420 10 bit</h2>



<style type="text/css">
	table.tableizer-table {
		font-size: 14px;
		border: 1px solid #CCC; 
		font-family: Arial, Helvetica, sans-serif;
	} 
	.tableizer-table td {
		padding: 4px;
		margin: 3px;
		border: 1px solid #CCC;
	}
	.tableizer-table th {
		background-color: #104E8B; 
		color: #FFF;
		font-weight: bold;
	}
</style>
<table class="tableizer-table">
<thead><tr class="tableizer-firstrow"><th>Resolution / FPS</th><th>Bitrate (Mbps)</th><th>Compression Ratio</th></tr></thead><tbody>
 <tr><td>7680 x 4320 30p</td><td>400</td><td>47.461</td></tr>
 <tr><td>7680 x 4320 25p</td><td>400</td><td>39.551</td></tr>
 <tr><td>7680 x 4320 24p</td><td>400</td><td>37.969</td></tr>
 <tr><td>3840 x 2160 120p</td><td>400</td><td>47.461</td></tr>
 <tr><td>3840 x 2160 100p</td><td>400</td><td>39.551</td></tr>
 <tr><td>3840 x 2160 60p</td><td>340</td><td>27.918</td></tr>
 <tr><td>3840 x 2160 50p</td><td>340</td><td>23.265</td></tr>
 <tr><td>3840 x 2160 30p</td><td>190</td><td>24.979</td></tr>
 <tr><td>3840 x 2160 25p</td><td>190</td><td>20.816</td></tr>
 <tr><td>3840 x 2160 24p</td><td>190</td><td>19.984</td></tr>
</tbody></table>



<p>For H.265, there is no option for all-intra, and only in 420. Compression ratio is much higher given long GOP. One thing to note, that bitrate is variable depend on the content, i.e. very dark scene will have a much lower bitrate (&lt;100Mbps for 4K60).</p>



<h2 class="wp-block-heading">NRAW High Quality 12 bit</h2>



<style type="text/css">
	table.tableizer-table {
		font-size: 14px;
		border: 1px solid #CCC; 
		font-family: Arial, Helvetica, sans-serif;
	} 
	.tableizer-table td {
		padding: 4px;
		margin: 3px;
		border: 1px solid #CCC;
	}
	.tableizer-table th {
		background-color: #104E8B; 
		color: #FFF;
		font-weight: bold;
	}
</style>
<table class="tableizer-table">
<thead><tr class="tableizer-firstrow"><th>Resolution / FPS</th><th>Bitrate (Mbps)</th><th>Compression Ratio</th></tr></thead><tbody>
 <tr><td>8256 x 4644 60p</td><td>5780</td><td>4.555</td></tr>
 <tr><td>8256 x 4644 50p</td><td>4810</td><td>4.561</td></tr>
 <tr><td>8256 x 4644 30p</td><td>2890</td><td>4.555</td></tr>
 <tr><td>8256 x 4644 25p</td><td>2410</td><td>4.552</td></tr>
 <tr><td>8256 x 4644 24p</td><td>2310</td><td>4.559</td></tr>
 <tr><td>4128 x 2322 120p</td><td>3840</td><td>3.428</td></tr>
 <tr><td>4128 x 2322 100p</td><td>2900</td><td>3.783</td></tr>
 <tr><td>4128 x 2322 60p</td><td>1740</td><td>3.783</td></tr>
 <tr><td>4128 x 2322 50p</td><td>1450</td><td>3.783</td></tr>
 <tr><td>4128 x 2322 30p</td><td>870</td><td>3.783</td></tr>
 <tr><td>4128 x 2322 25p</td><td>730</td><td>3.757</td></tr>
 <tr><td>4128 x 2322 24p</td><td>700</td><td>3.761</td></tr>
</tbody></table>



<p>First of all, given 4.5 compression ratio, NRAW is definitely a lossy codec. Interesting thing is that 8K&#8217;s compression ratio is higher than 4K&#8217;s. 4.5 vs 3.7.</p>



<h2 class="wp-block-heading">NRAW Normal Quality 12 bit</h2>



<style type="text/css">
	table.tableizer-table {
		font-size: 14px;
		border: 1px solid #CCC; 
		font-family: Arial, Helvetica, sans-serif;
	} 
	.tableizer-table td {
		padding: 4px;
		margin: 3px;
		border: 1px solid #CCC;
	}
	.tableizer-table th {
		background-color: #104E8B; 
		color: #FFF;
		font-weight: bold;
	}
</style>
<table class="tableizer-table">
<thead><tr class="tableizer-firstrow"><th>Resolution / FPS</th><th>Bitrate (Mbps)</th><th>Compression Ratio</th></tr></thead><tbody>
 <tr><td>8256 x 4644 60p</td><td>3470</td><td>7.587</td></tr>
 <tr><td>8256 x 4644 50p</td><td>2890</td><td>7.591</td></tr>
 <tr><td>8256 x 4644 30p</td><td>1740</td><td>7.565</td></tr>
 <tr><td>8256 x 4644 25p</td><td>1450</td><td>7.565</td></tr>
 <tr><td>8256 x 4644 24p</td><td>1390</td><td>7.576</td></tr>
 <tr><td>4128 x 2322 120p</td><td>1750</td><td>7.522</td></tr>
 <tr><td>4128 x 2322 100p</td><td>1460</td><td>7.513</td></tr>
 <tr><td>4128 x 2322 60p</td><td>880</td><td>7.479</td></tr>
 <tr><td>4128 x 2322 50p</td><td>730</td><td>7.513</td></tr>
 <tr><td>4128 x 2322 30p</td><td>440</td><td>7.479</td></tr>
 <tr><td>4128 x 2322 25p</td><td>370</td><td>7.412</td></tr>
 <tr><td>4128 x 2322 24p</td><td>350</td><td>7.522</td></tr>
</tbody></table>



<p>For normal quality, the compression ratio is even higher, reaching 7.5:1 which is not bad for all-intra. </p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/photography/nikon-z8-prores-prores-raw-bitrate-and-compression-ratio/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>花花酱 LeetCode 1178. Number of Valid Words for Each Puzzle</title>
		<link>https://zxi.mytechroad.com/blog/hashtable/leetcode-1178-number-of-valid-words-for-each-puzzle/</link>
					<comments>https://zxi.mytechroad.com/blog/hashtable/leetcode-1178-number-of-valid-words-for-each-puzzle/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Mon, 02 Sep 2019 01:28:10 +0000</pubDate>
				<category><![CDATA[Hashtable]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[frequency]]></category>
		<category><![CDATA[hard]]></category>
		<category><![CDATA[hashtable]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[subset]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=5521</guid>

					<description><![CDATA[With respect to a given&#160;puzzle&#160;string, a&#160;word&#160;is&#160;valid&#160;if both the following conditions are satisfied: word&#160;contains the first letter of&#160;puzzle. For each letter in&#160;word, that letter is in&#160;puzzle.For&#8230;]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="花花酱 LeetCode 1178. Number of Valid Words for Each Puzzle - 刷题找工作 EP267" width="500" height="375" src="https://www.youtube.com/embed/qOrmhPX-gAU?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>

With respect to a given&nbsp;<code>puzzle</code>&nbsp;string, a&nbsp;<code>word</code>&nbsp;is&nbsp;<em>valid</em>&nbsp;if both the following conditions are satisfied:</p>



<ul class="wp-block-list"><li><code>word</code>&nbsp;contains the first letter of&nbsp;<code>puzzle</code>.</li><li>For each letter in&nbsp;<code>word</code>, that letter is in&nbsp;<code>puzzle</code>.<br>For example, if the puzzle is &#8220;abcdefg&#8221;, then valid words are &#8220;faced&#8221;, &#8220;cabbage&#8221;, and &#8220;baggage&#8221;; while invalid words are &#8220;beefed&#8221; (doesn&#8217;t include &#8220;a&#8221;) and &#8220;based&#8221; (includes &#8220;s&#8221; which isn&#8217;t in the puzzle).</li></ul>



<p>Return an array&nbsp;<code>answer</code>, where&nbsp;<code>answer[i]</code>&nbsp;is the number of words in the given word list&nbsp;<code>words</code>&nbsp;that are valid with respect to the puzzle&nbsp;<code>puzzles[i]</code>.</p>



<p><strong>Example :</strong></p>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> 
words = ["aaaa","asas","able","ability","actt","actor","access"], 
puzzles = ["aboveyz","abrodyz","abslute","absoryz","actresz","gaswxyz"]
<strong>Output:</strong> [1,1,3,2,4,0]
<strong>Explanation:</strong>
1 valid word&nbsp;for "aboveyz" : "aaaa" 
1 valid word&nbsp;for "abrodyz" : "aaaa"
3 valid words for "abslute" : "aaaa", "asas", "able"
2 valid words for&nbsp;"absoryz" : "aaaa", "asas"
4 valid words for&nbsp;"actresz" : "aaaa", "asas", "actt", "access"
There're&nbsp;no valid words for&nbsp;"gaswxyz" cause none of the words in the list contains letter 'g'.
</pre>



<p><strong>Constraints:</strong></p>



<ul class="wp-block-list"><li><code>1 &lt;= words.length &lt;= 10^5</code></li><li><code>4 &lt;= words[i].length &lt;= 50</code></li><li><code>1 &lt;= puzzles.length &lt;= 10^4</code></li><li><code>puzzles[i].length == 7</code></li><li><code>words[i][j]</code>,&nbsp;<code>puzzles[i][j]</code>&nbsp;are English lowercase letters.</li><li>Each&nbsp;<code>puzzles[i]&nbsp;</code>doesn&#8217;t contain repeated characters.</li></ul>



<h2 class="wp-block-heading"><strong>Solution: Subsets</strong></h2>



<p>Preprocessing: <br>Compress each word to a bit map, and compute the frequency of each bit map.<br>Since there are at most |words| bitmaps while its value ranging from 0 to 2^26, thus it&#8217;s better to use a hashtable instead of an array.</p>



<p>Query:<br>Use the same way to compress a puzzle into a bit map.<br>Try all subsets (at most 128) of the puzzle (the bit of the first character is be must), and check how many words match each subset.</p>



<p>words = [&#8220;aaaa&#8221;,&#8221;asas&#8221;,&#8221;able&#8221;,&#8221;ability&#8221;,&#8221;actt&#8221;,&#8221;actor&#8221;,&#8221;access&#8221;], <br>puzzle = &#8220;abslute&#8221;<br>bitmap(&#8220;aaaa&#8221;)  = {0}<br>bitmap(&#8220;asas&#8221;) = {0, 18}<br>bitmap(&#8220;able&#8221;) = {0,1,4,11}<br>bitmap(&#8220;actt&#8221;) = {0, 2, 19}<br>bitmap(&#8220;actor&#8221;) = {0, 2, 14, 17, 19}<br>bitmap(&#8220;access&#8221;) = {0, 2, 4, 18}<br><br>bitmap(&#8220;abslute&#8221;) = {0, 1, 4, 11, 18, 19, 20}<br></p>



<p>Time complexity: O(sum(len(w_i)) + |puzzles|)<br>Space complexity: O(|words|)</p>



<div class="responsive-tabs">
<h2 class="tabtitle">C++</h2>
<div class="tabcontent">

<pre class="urvanov-syntax-highlighter-plain-tag">// Author: Huahua, 136 ms, 29.7 MB
class Solution {
public:
  vector&lt;int&gt; findNumOfValidWords(vector&lt;string&gt;&amp; words, vector&lt;string&gt;&amp; puzzles) {
    vector&lt;int&gt; ans;    
    unordered_map&lt;int, int&gt; freq;
    for (const string&amp; word : words) {
      int mask = 0;
      for (char c : word)
        mask |= 1 &lt;&lt; (c - 'a');
      ++freq[mask];
    }    
    for (const string&amp; p : puzzles) {
      int mask = 0;      
      for (char c : p)
        mask |= 1 &lt;&lt; (c - 'a');
      int first = p[0] - 'a';
      int curr = mask;
      int total = 0;
      while (curr) {
        if ((curr &gt;&gt; first) &amp; 1) {
          auto it = freq.find(curr);
          if (it != freq.end()) total += it-&gt;second;
        }
        curr = (curr - 1) &amp; mask;
      }
      ans.push_back(total);
    }
    return ans;
  }
};</pre>
</div></div>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/hashtable/leetcode-1178-number-of-valid-words-for-each-puzzle/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>花花酱 LeetCode 443. String Compression</title>
		<link>https://zxi.mytechroad.com/blog/string/leetcode-443-string-compression/</link>
					<comments>https://zxi.mytechroad.com/blog/string/leetcode-443-string-compression/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sat, 24 Mar 2018 19:50:55 +0000</pubDate>
				<category><![CDATA[String]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[in place]]></category>
		<category><![CDATA[run length]]></category>
		<guid isPermaLink="false">http://zxi.mytechroad.com/blog/?p=2354</guid>

					<description><![CDATA[Problem 题目大意：对一个string进行in-place的run length encoding。 https://leetcode.com/problems/string-compression/description/ Given an array of characters, compress it in-place. The length after compression must always be smaller than or equal to the&#8230;]]></description>
										<content:encoded><![CDATA[<h1><strong>Problem</strong></h1>
<p>题目大意：对一个string进行in-place的run length encoding。</p>
<p><a href="https://leetcode.com/problems/string-compression/description/">https://leetcode.com/problems/string-compression/description/</a></p>
<p>Given an array of characters, compress it <a href="https://en.wikipedia.org/wiki/In-place_algorithm" target="_blank" rel="noopener"><b>in-place</b></a>.</p>
<p>The length after compression must always be smaller than or equal to the original array.</p>
<p>Every element of the array should be a <b>character</b> (not int) of length 1.</p>
<p>After you are done <b>modifying the input array <a href="https://en.wikipedia.org/wiki/In-place_algorithm" target="_blank" rel="noopener">in-place</a></b>, return the new length of the array.</p>
<p><b>Follow up:</b><br />
Could you solve it using only O(1) extra space?</p>
<p><b>Example 1:</b></p>
<pre class="crayon:false"><b>Input:</b>
["a","a","b","b","c","c","c"]

<b>Output:</b>
Return 6, and the first 6 characters of the input array should be: ["a","2","b","2","c","3"]

<b>Explanation:</b>
"aa" is replaced by "a2". "bb" is replaced by "b2". "ccc" is replaced by "c3".
</pre>
<p><b>Example 2:</b></p>
<pre class="crayon:false"><b>Input:</b>
["a"]

<b>Output:</b>
Return 1, and the first 1 characters of the input array should be: ["a"]

<b>Explanation:</b>
Nothing is replaced.
</pre>
<p><b>Example 3:</b></p>
<pre class="crayon:false  "><b>Input:</b>
["a","b","b","b","b","b","b","b","b","b","b","b","b"]

<b>Output:</b>
Return 4, and the first 4 characters of the input array should be: ["a","b","1","2"].

<b>Explanation:</b>
Since the character "a" does not repeat, it is not compressed. "bbbbbbbbbbbb" is replaced by "b12".
Notice each digit has it's own entry in the array.
</pre>
<p><b>Note:</b></p>
<ol>
<li>All characters have an ASCII value in <code>[35, 126]</code>.</li>
<li><code>1 &lt;= len(chars) &lt;= 1000</code>.</li>
</ol>
<h1><strong>Solution</strong></h1>
<p>Time complexity: O(n)</p>
<p>Space complexity: O(1)</p>
<p>C++</p><pre class="urvanov-syntax-highlighter-plain-tag">// Author: Huahua
// Running time: 9 ms
class Solution {
public:
  int compress(vector&lt;char&gt;&amp; chars) {
    const int n = chars.size();
    int p = 0;
    for (int i = 1; i &lt;= n; ++i) {
      int count = 1;
      while (i &lt; n &amp;&amp; chars[i] == chars[i - 1]) { ++i; ++count; }
      chars[p++] = chars[i - 1];
      if (count == 1) continue;
      for (char c : to_string(count))
        chars[p++] = c;
    }
    return p;
  }
};</pre><p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/string/leetcode-443-string-compression/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
