how to compress a yuv420 raw data using opj_compress in lossless
I coule compress a yuv444 raw data with this code in lossless
ffmpeg -y -i image -pix_fmt yuvj444p source.yuv
cp source.yuv source.raw
opj_compress -i source.raw -o temp.jp2 -F '%s,%s,%s,%s,u@1x1:1x1:1x1' % (width, height, 3, 8) -r 1
opj_decompress -i temp.jp2-o decoded.raw
cp decode.raw decode.yuv
but when i change the sampling mode into yuv420
ffmpeg -y -i image -pix_fmt yuvj420p source420.yuv
cp source420.yuv source420.raw
opj_compress -i source420.raw -o temp.jp2 -F '%s,%s,%s,%s,u@1x1:2x2:2x2' % (width, height, 3, 8) -r 1
opj_decompress -i temp.jp2-o decoded.raw
cp decode.raw decode.yuv
-
I know the
decoded.rawis in 444 format. I try to convert it to 420 sampling ,but it is not lossless withsource420.yuv. -
I also try to expand
source420.yuvto 444 format ,but it is not lossless withdecoded.yuv. -
In a word:I can't get a lossless result.
Note: I caculate the psnr between source.yuv/souce420.yuv and decode.yuv with ffmpeg
I try to this code below
ffmpeg -y -i image -pix_fmt yuvj420p source420.yuv
cp source420.yuv source420.raw
opj_compress -i source420.raw -o temp.jp2 -F '%s,%s,%s,%s,u@1x1:2x2:2x2' % (width, height, 3, 8) -r 1
opj_decompress -i temp.jp2-o decoded.ppm
ffmpeg -y -i decoded.ppm-pix_fmt yuvj420p decoded420.yuv
- It's different to decode into a
ppmfile and then to convert it todecoded420.yuv.
But in openjpeg code stream the information of image is in YUV format? I do not certain.
-
It lossy to convert a
YUVfile toppmfile . -
Also it's lossy to convert a
ppmtoYUVfile if not inYCoCg
So the psnr between decoded420.yuv and source420.yuv is 56.66 ,it large compare the commom psnr ,may be it can be consider as lossless ? But actually ,it's not lossless. I'm not sure if the lossy cause by the convert between ppm and YUV or other problem. Or both them.
- 444 format
It is 444 full range format. j means full range. That can have all kind of problems as it is sometimes just metadata.
expand source420.yuv to 444 format
It is impossible. It is lossly convertion from 444 to 420. It is also lossy from RGB to 444 and back.
souce420.yuv and decode.yuv
Yeah, I suppose that should be lossless, but I am not sure. Can you try all of that but with yuv420p?