Scan8 [16 + 2*4] content

Source: Internet
Author: User

Scan8 is hard to understand. The answer is as follows:

Static const int x264_scan8 [16 + 2*4] =
{
/* Luma */
4 + 1*8, 5 + 1*8, 4 + 2*8, 5 + 2*8,
6 + 1*8, 7 + 1*8, 6 + 2*8, 7 + 2*8,
4 + 3*8, 5 + 3*8, 4 + 4*8, 5 + 4*8,
6 + 3*8, 7 + 3*8, 6 + 4*8, 7 + 4*8,

/* CB */
1 + 1*8, 2 + 1*8,
1 + 2*8, 2 + 2*8,

/* Cr */
1 + 4*8, 2 + 4*8,
1 + 5*8, 2 + 5*8,
};

/*
0 1 2 3 4 5 6 7
0
1 B l
2 B l
3 L
4 R L
5 r
*/
The above two maps can be used.

 

Scan8 is to facilitate access to memory such as mv_cache, ref_cache, non_zero_count_cache, and mvd_cache, while a filled array contains the index numbers specified in the memory above.
For example, scan8 [0] = 12, and this 12 is the value in the above memory. Generally, the value in the upper left corner of macroblock, whether it is MV or non_zero_count, is used to fully understand the above memory structure, then all the problems will be solved.

 

 

 

Attachment is a previously analyzed note for a problem.
In ffmepg, a few important caches are generally set according to this idea.
Hope to help you understand the cache!

 

 

1. Why is the color and Luma degree the same matrix value?
2. H-> what is block_offset?

  1. For (I = 0; I <16; I ++ ){
  2. H-> block_offset [I] = 4*(scan8 [I]-scan8 [0]) & 7) + 4 * s-> linesize * (scan8 [I]-scan8 [0])> 3 );
  3. H-> block_offset [24 + I] = 4*(scan8 [I]-scan8 [0]) & 7) + 8 * s-> linesize * (scan8 [I]-scan8 [0])> 3 );
  4. }
  5. For (I = 0; I <4; I ++ ){
  6. H-> block_offset [16 + I] =
  7. H-> block_offset [20 + I] = 4*(scan8 [I]-scan8 [0]) & 7) + 4 * s-> uvlinesize * (scan8 [I]-scan8 [0])> 3 );
  8. H-> block_offset [24 + 16 + I] =
  9. H-> block_offset [24 + 20 + I] = 4*(scan8 [I]-scan8 [0]) & 7) + 8 * s-> uvlinesize * (scan8 [I]-scan8 [0])> 3 );
  10. }
Copy code
1. It should be to save memory and facilitate the index of the bright color of the same MB in an array. I don't know if this explanation is correct.
2. block_offset: The Block offset is 16 + 8, which is more obvious. 16 brightness, two (8, each of which is 4) color.
If you remember correctly, this offset should be used for the YUV pixel storage index.

Thanks to Juanny's document, it is very helpful to understand the element values in x264_scan8. This is mainly an intermediate addressing matrix, it allows you to conveniently find the color and brightness of MB in the corresponding cache and zero_count.

 

 

 

 

 

 

Scan8 [] is actually the scanning sequence and storage location of 4x4 blocks. You can see the function of scan8 in the 8x8 matrix. t indicates the block on the current block, L indicates the Left Block of the current block. They are used to predict the intra prediction mode and motion vector of the current block, and play a caching role. We can see that this design saves memory than JM, and is very clever. Other caching designs in the program are similar.

 

 

 

 

 

T

 

 

T

 

 

 

 

 

T

 

 

T

 

 

T

 

 

T

 

 

L

 

 

16

 

 

17

 

 

L

 

 

0

 

 

1

 

 

4

 

 

5

 

 

L

 

 

18

 

 

19

 

 

L

 

 

2

 

 

3

 

 

6

 

 

7

 

 

 

 

 

T

 

 

T

 

 

L

 

 

8

 

 

9

 

 

12

 

 

13

 

 

L

 

 

20

 

 

21

 

 

L

 

 

10

 

 

11

 

 

14

 

 

15

 

 

L

 

 

22

 

 

23

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.