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