libv4lconvert: fix setting/testing of supported_src_formats
authorHans Verkuil <hans.verkuil@cisco.com>
Tue, 5 Jun 2012 23:26:35 +0000 (01:26 +0200)
committerHans Verkuil <hans.verkuil@cisco.com>
Tue, 5 Jun 2012 22:04:31 +0000 (00:04 +0200)
data->supported_src_formats is a uint64_t.

This code:

data->supported_src_formats & (1 << i)

does not work since (1 << i) is a 32-bit value. It should be (1ULL << i) instead.

Interesting fact: on a 64-bit intel box (1 << 33) does a rotate, not a shift.
So (1 << 33) == 2.

On a 32-bit powerpc platform it is a proper shift, so (1 << 33) == 0.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
lib/libv4lconvert/libv4lconvert.c

index 4223ce6..e196641 100644 (file)
@@ -146,7 +146,7 @@ struct v4lconvert_data *v4lconvert_create(int fd, void *dev_ops_priv,
                                break;
 
                if (j < ARRAY_SIZE(supported_src_pixfmts)) {
-                       data->supported_src_formats |= 1 << j;
+                       data->supported_src_formats |= 1ULL << j;
                        v4lconvert_get_framesizes(data, fmt.pixelformat, j);
                        if (!supported_src_pixfmts[j].needs_conversion)
                                always_needs_conversion = 0;
@@ -245,7 +245,7 @@ int v4lconvert_enum_fmt(struct v4lconvert_data *data, struct v4l2_fmtdesc *fmt)
 
        for (i = 0; i < ARRAY_SIZE(supported_dst_pixfmts); i++)
                if (v4lconvert_supported_dst_fmt_only(data) ||
-                               !(data->supported_src_formats & (1 << i))) {
+                               !(data->supported_src_formats & (1ULL << i))) {
                        faked_fmts[no_faked_fmts] = supported_dst_pixfmts[i].fmt;
                        no_faked_fmts++;
                }
@@ -400,7 +400,7 @@ static int v4lconvert_do_try_format(struct v4lconvert_data *data,
 
        for (i = 0; i < ARRAY_SIZE(supported_src_pixfmts); i++) {
                /* is this format supported? */
-               if (!(data->supported_src_formats & (1 << i)))
+               if (!(data->supported_src_formats & (1ULL << i)))
                        continue;
 
                try_fmt = *dest_fmt;