From: Hans de Goede <j.w.r.degoede@hhs.nl>
To: Jean-Francois Moine <moinejf@free.fr>
Cc: Video 4 Linux <video4linux-list@redhat.com>
Subject: Re: v4l library - decoding of Pixart JPEG frames
Date: Sun, 17 Aug 2008 13:47:19 +0200 [thread overview]
Message-ID: <48A80FC7.6090909@hhs.nl> (raw)
In-Reply-To: <1218734045.1696.39.camel@localhost>
[-- Attachment #1: Type: text/plain, Size: 1318 bytes --]
Hi Jean, Thomas,
Jean, good to see that you are working on the pixart 73xx support, I
have a cam over here as well which didn't work at all, now with your
fixes, it atleast generates proper frames (they used too be much too
small). Unfortunately my cam still does not work, your siv.c does show
something which seems to be decoded video data, but not as it should
look like, from the looks of it we are close though.
I've made a single raw frame from my cam available here:
http://people.atrpms.net/~hdegoede/image.dat
If anyone can write code which can convert that to an image (might be
unsharp) that would be great!
I've done a first attempt at making v4lconvert handle these pixart jpeg
frames, patch attached. Warning this is a crude hack breaking regular
jpeg support. This seems to work less well with my cam then the siv.c
code, so we might need to make more changes either to v4lconvert, or
maybe to the jpeg_put_header call in pac7311.c, talking about this call,
since we are defining a custom format anyways, shouldn't we just omit
the header and send the jpeg-ish pixart frame data to userspace as is?
Thomas, I would be very much interested in your tinyjpeg version with
pixart support!
Jean, perhaps you can make some raw images from your cam available
somewhere too?
Regards,
Hans
[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 3038 bytes --]
diff -r 566aac58b414 v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h
--- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h Thu Aug 07 19:34:10 2008 +0200
+++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h Sun Aug 17 14:06:29 2008 +0200
@@ -43,6 +43,10 @@
#define V4L2_PIX_FMT_PAC207 v4l2_fourcc('P','2','0','7')
#endif
+#ifndef V4L2_PIX_FMT_PJPG
+#define V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G')
+#endif
+
#ifndef V4L2_PIX_FMT_SGBRG8
#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G','B','R','G')
#endif
diff -r 566aac58b414 v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c
--- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c Thu Aug 07 19:34:10 2008 +0200
+++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c Sun Aug 17 14:06:29 2008 +0200
@@ -48,6 +48,7 @@
V4L2_PIX_FMT_SPCA561,
V4L2_PIX_FMT_SN9C10X,
V4L2_PIX_FMT_PAC207,
+ V4L2_PIX_FMT_PJPG,
};
static const unsigned int supported_dst_pixfmts[] = {
@@ -297,6 +298,51 @@
}
switch (src_fmt->fmt.pix.pixelformat) {
+ case V4L2_PIX_FMT_PJPG:
+ {
+ unsigned char *in;
+ unsigned char *out, out_buf[src_size];
+ int in_size = src_size, out_size, header_size = 0x646;
+
+ if (src_size < header_size)
+ return needed;
+
+ memcpy(out_buf, src, header_size);
+
+ in = src + header_size;
+ out = out_buf + header_size;
+ in_size -= header_size;
+ out_size = header_size;
+
+ while(in_size > 0) {
+ int chunk_size;
+
+ if (in[0] != 0xff || in[1] != 0xff || in[2] != 0xff) {
+ fprintf(stderr, "Pixart JPEG format error, header: %02x %02x %02x\n",
+ (int)in[0], (int)in[1], (int)in[2]);
+ return needed;
+ }
+ if (in[3] == 0u)
+ chunk_size = in_size - 4;
+ else if (in[3] < 6u)
+ chunk_size = 1024 >> (in[3] - 1);
+ else {
+ fprintf(stderr, "Pixart JPEG format error: chunk_size = %d\n",
+ (int)in[3]);
+ return needed;
+ }
+
+ memcpy(out, in + 4, chunk_size);
+ in += chunk_size + 4;
+ out += chunk_size;
+ in_size -= chunk_size + 4;
+ out_size += chunk_size;
+ }
+
+ src = out_buf;
+ src_size = out_size;
+ /* fall through! */
+ }
case V4L2_PIX_FMT_MJPEG:
case V4L2_PIX_FMT_JPEG:
if (!data->jdec) {
diff -r 566aac58b414 v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg.c
--- a/v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg.c Thu Aug 07 19:34:10 2008 +0200
+++ b/v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg.c Sun Aug 17 14:06:29 2008 +0200
@@ -60,6 +60,9 @@
#define BLACK_Y 0
#define BLACK_U 127
#define BLACK_V 127
+
+#define DEBUG 1
+#define LOG2FILE 1
#if DEBUG
#if LOG2FILE
@@ -2112,6 +2115,7 @@
for (x=0; x < priv->width; x+=xstride_by_mcu)
{
decode_MCU(priv);
+ skip_nbits(priv->reservoir, priv->nbits_in_reservoir, priv->stream, 8);
convert_to_pixfmt(priv);
priv->plane[0] += bytes_per_mcu[0];
priv->plane[1] += bytes_per_mcu[1];
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
next prev parent reply other threads:[~2008-08-17 12:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-14 17:14 v4l library - decoding of Pixart JPEG frames Jean-Francois Moine
2008-08-14 18:51 ` Thomas Kaiser
2008-08-17 11:47 ` Hans de Goede [this message]
2008-08-18 7:34 ` Jean-Francois Moine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48A80FC7.6090909@hhs.nl \
--to=j.w.r.degoede@hhs.nl \
--cc=moinejf@free.fr \
--cc=video4linux-list@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox