<br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">digital design</b> <span dir="ltr"><<a href="mailto:developer.fpga@gmail.com">developer.fpga@gmail.com</a>></span><br>
Date: 21 March 2011 13:38<br>Subject: Re: [theora] alghorithm of working encoder in libtheora<br>To: <a href="mailto:bens@alum.mit.edu">bens@alum.mit.edu</a><br>Cc: <a href="mailto:Reply-All@xiph.org">Reply-All@xiph.org</a><br>
<br><br><br><br><div class="gmail_quote"><div><div></div><div class="h5">On 18 March 2011 23:15, Benjamin M. Schwartz <span dir="ltr"><<a href="mailto:bmschwar@fas.harvard.edu" target="_blank">bmschwar@fas.harvard.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div>On 03/18/2011 01:44 PM, digital design wrote:<br>
> Now i implement next stages of encoder^<br>
> Block1:<br>
> 1) RGB->YUV<br>
> 2) DCT of 16X16 blocks (pixel format 4:2:0)<br>
> 3) zig-zag in eatch 8*8 block from previous step and push it to bufer memory.<br>
><br>
> i push 16X16 blocks to BLOCK1 using raster order (i'm right?)<br>
> Now i'm confused - so much types of ordering. What i must do after DCT?<br>
> What is order for pass blocks to Huffman block?<br>
<br>
</div>In Theora terminology, a 16x16 unit spanning all 3 color planes (8x8 in U<br>
and V) is called a "macroblock". To encode the contents of a macroblock,<br>
you must separate out the different color planes, and form "superblocks"<br>
in each color plane. The DC coefficients of each block are then coded in<br>
"raster order", while the AC coefficients are coded in "coded order".<br>
These orders are described in sections 2.3 and 2.4 of the Theora bitstream<br>
specification.<br>
<br>
The ordering of coefficients is<br>
Y plane DC coefficients in raster order (whole plane)<br>
Y plane AC coefficient 1 in coded order (whole plane)<br>
Y plane AC coefficient 2 in coded order ...<br>
...<br>
Same for U plane<br>
Same for V plane<br>
<br>
For future questions please use Reply-All so that more people can help you.<br>
<br>
--Ben<br>
<br></blockquote></div></div><div><br>Now i create HOW-TO as reference for all hardware developers, who want create theora encoder using FPGA</div><div>Here is begin, did i miss some thig?</div><div>/*********************************************</div>
<div>** Stages of my hardware encoder (I-frame) **</div><div>*********************************************/</div><div><br></div><div>For example we have input frame 128x128 pixels RGB byer.</div><div>------------------------------------------------------------------</div>
<div>Stages of theora bitstream creation:</div><div><br></div><div>1. Convert RGB to YUV 4:2:0</div><div><br></div><div>2.DCT</div><div>extract blocks (8x8 pixels) from each plane (scan order curve)</div><div>For each block:</div>
<div>- take DCT coeffs: DC, AC(0..62)</div><div>- quantize them, acording to quantization table</div><div>- for DC coefficient make DPCM</div><div>Save results for each plane in buffer memory</div><div><br></div><div>3.Huffman stage</div>
<div><br></div><div>3.1 Extract DC coefficients for all planes (Y,U & V)</div><div><br></div><div>Extraction order: superblocks extracted scan curve order, inside superblocks</div><div>extract blocks DC coefficiens in hilbert curve order</div>
<div><br></div><div>Here is:</div><div>"Y" - "y" plane of encoded frame</div><div>"U" - "u" plane of encoded frame (subsampled)</div><div>"V" - "v" plane of encoded frame (subsampled)</div>
<div>"SBn" - superblock (4x4 of blocks(8x8pixels)), n - is superblock number </div><div>"--->" - scan curve</div><div>"DCs" - DC coefficient of each blocs inside SB</div><div><br></div><div>
-----------------------------</div><div>| Y |Y |Y |Y |</div><div>|SB20 |SB21 |SB22 |SB23 |</div><div>|--->------>---------->------</div><div>|DCs |DCs |DCs |DCs |</div><div>-----------------------------</div>
<div>| Y |Y |Y |Y |</div><div>|SB16 |SB17 |SB18 |SB19 |</div><div>|--->------>---------->------</div><div>|DCs |DCs |DCs |DCs |</div><div>---------------------------------------------------------</div>
<div>|Y |Y |Y |Y |U |U |V |V |</div><div>|SB8 |SB9 |SB10 |SB11 |SB12 |SB13 |SB14 |SB15 |</div><div>|--->------>---------->------>------>------------>---->--</div>
<div>|DCs |DCs |DCs |DCs |DCs |DCs |DCs |DCs |</div><div>---------------------------------------------------------</div><div>|Y |Y |Y |Y |U |U |V |V |</div><div>|SB0 |SB1 |SB2 |SB3 |SB4 |SB5 |SB6 |SB7 |</div>
<div>|--->------>---------->------>------>------------>---->--</div><div>|DCs |DCs |DCs |DCs |DCs |DCs |DCs |DCs |</div><div>---------------------------------------------------------</div>
<div><br></div><div>Pass extracted DC to Huffman blocks, results save in buffer memory:</div><div><br></div><div>DDR2:</div><div>+----+---------------------------------+</div><div>ADDR | VALUE |</div>
<div>+----+---------------------------------+</div><div>N | DC results after Huffman blocks |</div><div>N+1 | DC results after Huffman blocks |</div><div>.. | ... |</div><div>N+m | DC results after Huffman blocks |</div>
<div><br></div><div>3.2 the same (like 3.1) for all AC0...AC62</div><div><br></div><div>Results in buffer memory (DDR2) after Huffman</div><div><br></div><div>DDR2:</div><div>+----+----------------------------------+</div>
<div>ADDR | VALUE |</div><div>+----+----------------------------------+</div><div>N | DC results after Huffman blocks |</div><div>.. | ... |</div><div>M | AC0 results after Huffman blocks |</div>
<div>.. | ... |</div><div>J | AC1 results after Huffman blocks |</div><div>.. | ... |</div><div>I |AC62 results after Huffman blocks |</div><div><br></div>
<div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>Is scan order right and process flow right?</div><div><br></div><div>Thanks!</div><div><br></div><div><br></div>
<div><br></div><div> <br></div></div><br>
</div><br>