Properly setting bpp

87 views
Skip to first unread message

mjbshaw

unread,
Nov 14, 2011, 9:16:30 PM11/14/11
to OpenJPEG
Hi, sorry to bug you all but I'm currently working on a mjp2/J2K
encoder for FFmpeg using libopenjpeg. I've got RGB working and am
working on getting YUV420/YUV422/YUV440/YUV444 working and I have a
question about the value that I should set bpp to. In the
frames_to_mj2 example code, bpp is always set to 8. Why is that? I
thought bpp was the bits per pixel, which for normal RGB should be 24,
should it not? I'm wondering because I wasn't 100% sure if I did it
right when I wrote the RGB encoder, but now the YUV portion could
potentially have values of 12, 16, or 24 for bpp.

Thanks!

szuk...@arcor.de

unread,
Nov 18, 2011, 7:11:50 PM11/18/11
to open...@googlegroups.com
On Mon, 14 Nov 2011 18:16:30 -0800 (PST), mjbshaw wrote:

>Hi, sorry to bug you all but I'm currently working on a mjp2/J2K
>encoder for FFmpeg using libopenjpeg. I've got RGB working and am
>working on getting YUV420/YUV422/YUV440/YUV444 working and I have a
>question about the value that I should set bpp to. In the
>frames_to_mj2 example code, bpp is always set to 8. Why is that?
>

frames_to_mj2 -h | less

(...)
-D : depth, precision in bits [8 .. 16]; default:8
-C : comment

winfried

szuk...@arcor.de

unread,
Nov 18, 2011, 7:20:36 PM11/18/11
to open...@googlegroups.com
On Tue, 15 Nov 2011 13:22:54 -0800 (PST), "L.Hill" wrote:

>I am writing 16 bit per component images on MacOS X. I set the
>component.prec and bpp to 16. The images save with no problems but
>MacOS Preview (image viewing tool) says that the bit depth is 8.
>
>Is this a bug ?

It is unclear.

Which program do you use for writing?
Which precision does the src file have?
Which type of dst file do you have selected?

winfried

Michael Bradshaw

unread,
Nov 18, 2011, 8:47:28 PM11/18/11
to open...@googlegroups.com

I don't think we're looking at the same frames_to_mj2... I'm looking
at the latest v1.4 sources and I'm not seeing that anywhere.

[edit]

I just saw you write to someone on the mailing list that the 1.4
sources are buggy. Dang. I thought it was the entire image's depth
at first. Doesn't look like it. Is the bpp per component,
individually, though? i.e. for YUV420 would bpp be 8 for the first
component, 2 for the second component, and 2 for the third component?
Or would bpp be 8 for each component? I'm just confused if the bpp
for each component is with respect to the image as a whole (i.e. if
one component holding Cb has a size of 640x480, while the image as a
while has a size of 1280x960, then that one component has a bpp that's
1/4 as the bpp as the Y).

I hope I've explained my confusion clearly.

Thanks,

Michael

Michael Bradshaw

unread,
Nov 18, 2011, 8:50:34 PM11/18/11
to open...@googlegroups.com

I meant "if one component holding Cb has a size of 640x480, while the
image as a *whole has a size of 1280x960, then that one component has


a bpp that's 1/4 as the bpp as the Y"

Sorry about that.

szuk...@arcor.de

unread,
Nov 18, 2011, 9:31:24 PM11/18/11
to open...@googlegroups.com
Michael B.,

the following lines refer to revision 1079 of
svn co \
http://openjpeg.googlecode.com/svn/branches/openjpeg-1.5 \
your-dir

frames_to_mj2.c:
================
line 254:
int prec = 8;/* DEFAULT */

line 610:
case 'D': /* Depth: the precision */
if(sscanf(opj_optarg, "%d", &prec) != 1) prec = 0;

line 675:
mj2_parameters.prec = prec;

line 749:
tk->depth = prec;

line 763:
yuvtoimage(tk, img, sampleno, j2k_parameters,
mj2_parameters.infile)

mj2_convert.c:
================
line 119:
is_16 = (tk->depth > 8);
prec_bytes = (is_16?2:1);

For a prec <= 8: one byte is read
For a prec > 8: two bytes are read

That means: '-D' informs about the precision of the INPUT file.

winfried

Reply all
Reply to author
Forward
0 new messages