0

I was asked in the test on what will be the size of the video of 10 seconds displayed at 25fps assuming each chroma sample takes 4 bits, luminance component takes 8 bits and 4:2:0 chroma sampling is used in image object of 32x32 pixels?

This was my solution: 10 x 25 x (8 x 2) x (8 x 4) x 32 x 32

Was my solution correct? If not how could it be rectified?

HQuser
  • 640
  • 10
  • 26
  • Where does the 25, and the 2 come from? – szatmary Jun 15 '19 at 14:18
  • @szatmary Sorry, mistyped question, fixed it. 25 is FPS and 2 is from 4:"2":0 – HQuser Jun 15 '19 at 17:21
  • Please correct the question to fix the type-o. Also, did you read the wikipedia on a [Chrome subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling#4:2:0) – szatmary Jun 15 '19 at 17:47
  • Me and @szatmary had an argument about the correctness of my answer. Please let us know the right answer, after you get the results of your exam (and also the accurate question if possible). – Rotem Jun 18 '19 at 17:04
  • @Rotem acknowledged. I will do it once I get the results... – HQuser Jun 18 '19 at 18:58
  • @Rotem it turns out my answer was correct, now I am not totally sure whether my professor concept was right or not but that's how it went – HQuser Sep 26 '19 at 19:08

1 Answers1

1

Sorry, but your answer is wrong!

YUV420 format means that each 2x2 pixels has 2 chroma components (one U and one V), and 4 lumma components.

List of components of 2x2 pixels (4 pixels):
4 Y Elements
1 U Element
1 V Element

A drawing may help you count:

Y     Y
  U,V  
Y     Y

Size of Y (lumma) data size in bits is:
10 x 25 x 32 x 32 x 8 = 2048000 bits

Size of U chroma data size in bits is:
(10 x 25 x 32 x 32 x 4)/4 = 256000 bits (we need to divide by 4, because each 4 pixels has only one U element).

Size of V chroma data size in bits is the same a U: 256000 bits

Total size in bits:
10 x 25 x 32 x 32 x 8 + 2 x (10 x 25 x 32 x 32 x 4)/4 = 2560000 bits.

Most of the time size is measured in bytes (not in bits).
Size in bytes is 2560000 / 8 = 320000 Bytes.


Other way to look at the problem is computing the average bits per pixel:
Each pixel has a Y element (8 bits).

Each 4 pixels have 1 U (4 bits) and 1 V (4 bits)
8 bits per 4 pixels, gives an average of 2 bits per pixel for chroma.

Average: 10 bits per pixel.

Total size in bits: 10 x 25 x 32 x 32 x 10 = 2560000 bits = 320000 Bytes.

Rotem
  • 30,366
  • 4
  • 32
  • 65
  • Except yuv420 is 12 bits per pixel (8 + 2 × 8/4) – szatmary Jun 18 '19 at 15:18
  • @szatmary in the most common format, YUV420 is 12 bits per pixel (when Y, U,V are all 8 bits), but in the question, it is given: **"each chroma sample takes 4 bits"**, so the there are only 10 bits per pixel... – Rotem Jun 18 '19 at 15:54
  • 8+4 = 12. OP means U+V = 4 bits per pixel. Not 4 for U and 4 for V. That would be 4:2:2 – szatmary Jun 18 '19 at 16:22
  • @szatmary As I understand it "each chroma sample takes 4 bits", means 4 for U and 4 for V. Instead of common 4:2:0 format where there are 8 for U and 8 for V, in our case there are only 4 for U and 4 for V. – Rotem Jun 18 '19 at 16:28
  • We have to read between the lines a bit. OP is a little confused, and not really sure how subsampling works. It’s way more likely that they meant 2+2=4 than dealing with a non standard hybrid 4:2:2/4:2:0 format. – szatmary Jun 18 '19 at 16:33
  • @szatmary I am not talking about hybrid 4:2:2/4:2:0, I am talking about 4:2:0, where there are only 4 bits for U and 4 bits for V (instead of the familiar 8 for U and 8 for V as you know it). You do agree that in the familiar 4:2:0 there are 8 bits for U and 8 for V right? And an average of 12 bits per pixel right? – Rotem Jun 18 '19 at 16:37
  • In a single pixel? No that’s wrong. There are 8 luma bits, 2 Cr, 2 Cb. 8/8/8 would be 4:4:4 (8+8+8 does not equal 12) – szatmary Jun 18 '19 at 16:39
  • @szatmary 8 for U and 8 for V, but each such `U,V` are common to 4 pixels. – Rotem Jun 18 '19 at 16:41
  • I see where your coming from. But I still believe that it is more likely that OP had a bit of ambiguity in the question than they have a file with 4 bits of color. I don’t even think there is a 4cc code for that. – szatmary Jun 18 '19 at 16:52
  • @szatmary an average of 4 bits of color information per pixel is the most common 4:2:0 format. It **"was asked in the test"**, so I assumed it's a little tricky (I had to assume the teacher gave non-standard example for academic purposes). It is possible that I was wrong. – Rotem Jun 18 '19 at 17:01
  • Lol. You keep switching back and forth between storage bits per pixel and display bit per pixel and assuming I’m wrong, and I keep switching to try to match your switching. Also, I am 99% sure this was not a trick question. – szatmary Jun 18 '19 at 17:05
  • @szatmary I am sorry for my inconsistencies, and there is a good chance that you are right (I read the question carefully and still not convinced). I think **Each 4 pixels have 1 U (4 bits) and 1 V (4 bits)** is a valid assumption. – Rotem Jun 18 '19 at 17:18