If chroma subsampling used is 4:2:0 , then Cb and Cr is downsampled by half , but there is no change mentioned in Y channel . Then how does the total image dimension becomes half after this step ?
For eg: if an image dimension is 480x378 pixels , how does it change to 240x189 pixels ? How this is done in libjpeg.c ?
The dimensions don't change - the image remains the same width and height it was before. The number of bytes is halved, because initially you have 3 channels of R, G and B and afterwards, in their place, you have:
the Y
channel which has the same number of bytes as Red channel because it is full resolution,
the Cb
channel, which is subsampled by a factor 2 in each direction so it is 1/4 the size of the Green channel,
the Cr
channel, which is subsampled by a factor 2 in each direction so it is 1/4 the size of the Blue channel.
So now you have 1 channel of Y, 1/4 channel of Cb, 1/4 channel of Cr, so in total you have 1.5 channels whereas before, you used to have 3 channels (R, G and B). So, you have 1.5 instead of 3, i.e. half the data.