/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
GRUB_MOD_LICENSE ("GPLv3+");
/* Uncomment following define to enable JPEG debug. */
//#define JPEG_DEBUG
0, 1, 8, 16, 9, 2, 3, 10,
17, 24, 32, 25, 18, 11, 4, 5,
12, 19, 26, 33, 40, 48, 41, 34,
27, 20, 13, 6, 7, 14, 21, 28,
35, 42, 49, 56, 57, 50, 43, 36,
29, 22, 15, 23, 30, 37, 44, 51,
58, 59, 52, 45, 38, 31, 39, 46,
53, 60, 61, 54, 47, 55, 62, 63
};
#ifdef JPEG_DEBUG
#endif
struct grub_jpeg_data
{
int image_width;
int image_height;
int dri;
int r1;
};
static grub_uint8_t
{
grub_uint8_t r;
r = 0;
return r;
}
static grub_uint16_t
{
r = 0;
return grub_be_to_cpu16 (r);
}
static int
{
int ret;
{
{
if (grub_jpeg_get_byte (data) != 0)
{
"jpeg: invalid 0xFF in data stream");
return 0;
}
}
}
return ret;
}
static int
{
if (num == 0)
return 0;
for (i = 1; i < num; i++)
if (!msb)
return value;
}
static int
{
int code;
unsigned i;
code = 0;
{
code <<= 1;
if (grub_jpeg_get_bit (data))
code++;
}
return 0;
}
static grub_err_t
{
unsigned i;
{
id &= 0xF;
if (id > 1)
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
"jpeg: too many huffman tables");
sizeof (count))
return grub_errno;
n = 0;
for (i = 0; i < ARRAY_SIZE (count); i++)
n += count[i];
if (grub_errno)
return grub_errno;
return grub_errno;
base = 0;
ofs = 0;
for (i = 0; i < ARRAY_SIZE (count); i++)
{
base <<= 1;
}
}
return grub_errno;
}
static grub_err_t
{
int id;
<= next_marker)
{
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
"jpeg: only 8-bit precision is supported");
if (id > 1)
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
"jpeg: too many quantization tables");
return grub_errno;
}
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
"jpeg: unknown quantization table format");
return grub_errno;
}
static grub_err_t
{
int i, cc;
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
"jpeg: only 8-bit precision is supported");
if (cc != 3)
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
"jpeg: component count must be 3");
for (i = 0; i < cc; i++)
{
if (!id)
{
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
"jpeg: sampling method not supported");
}
else if (ss != JPEG_SAMPLING_1x1)
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
"jpeg: sampling method not supported");
}
return grub_errno;
}
static grub_err_t
{
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
"jpeg: DRI marker length must be 4");
return grub_errno;
}
static void
{
int *pd;
int i;
for (i = 0; i < JPEG_UNIT_SIZE; i++, pd++)
{
{
continue;
}
}
{
{
continue;
}
}
for (i = 0; i < JPEG_UNIT_SIZE * JPEG_UNIT_SIZE; i++)
{
du[i] += 128;
if (du[i] < 0)
du[i] = 0;
if (du[i] > 255)
du[i] = 255;
}
}
static void
{
unsigned pos;
pos = 1;
{
if (!num)
break;
num >>= 4;
pos++;
}
}
static void
{
int dd;
cr -= 128;
cb -= 128;
/* Red */
if (dd < 0)
dd = 0;
if (dd > 255)
dd = 255;
/* Green */
if (dd < 0)
dd = 0;
if (dd > 255)
dd = 255;
/* Blue */
if (dd < 0)
dd = 0;
if (dd > 255)
dd = 255;
}
static grub_err_t
{
int i, cc;
if (cc != 3)
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
"jpeg: component count must be 3");
for (i = 0; i < cc; i++)
{
}
return grub_errno;
return GRUB_ERR_NONE;
}
static grub_err_t
{
{
if (grub_errno)
return grub_errno;
{
}
}
return grub_errno;
}
static void
{
}
static grub_uint8_t
{
grub_uint8_t r;
r = grub_jpeg_get_byte (data);
if (r != JPEG_ESC_CHAR)
{
return 0;
}
return grub_jpeg_get_byte (data);
}
static grub_err_t
{
while (grub_errno == 0)
{
if (grub_errno)
break;
#ifdef JPEG_DEBUG
#endif
switch (marker)
{
case JPEG_MARKER_DHT: /* Define Huffman Table. */
break;
case JPEG_MARKER_DQT: /* Define Quantization Table. */
break;
case JPEG_MARKER_SOF0: /* Start Of Frame 0. */
break;
case JPEG_MARKER_DRI: /* Define Restart Interval. */
break;
case JPEG_MARKER_SOS: /* Start Of Scan. */
if (grub_jpeg_decode_sos (data))
break;
case JPEG_MARKER_RST0: /* Restart. */
case JPEG_MARKER_RST1:
case JPEG_MARKER_RST2:
case JPEG_MARKER_RST3:
case JPEG_MARKER_RST4:
case JPEG_MARKER_RST5:
case JPEG_MARKER_RST6:
case JPEG_MARKER_RST7:
break;
case JPEG_MARKER_EOI: /* End Of Image. */
return grub_errno;
default: /* Skip unrecognized marker. */
{
if (grub_errno)
return (grub_errno);
}
}
}
return grub_errno;
}
static grub_err_t
const char *filename)
{
if (!file)
return grub_errno;
{
int i;
for (i = 0; i < 4; i++)
}
if (grub_errno != GRUB_ERR_NONE)
{
*bitmap = 0;
}
return grub_errno;
}
#if defined(JPEG_DEBUG)
static grub_err_t
{
if (argc != 1)
if (grub_errno != GRUB_ERR_NONE)
return grub_errno;
return GRUB_ERR_NONE;
}
#endif
.extension = ".jpg",
.next = 0
};
.extension = ".jpeg",
.next = 0
};
{
#if defined(JPEG_DEBUG)
"FILE", "Tests loading of JPEG bitmap.");
#endif
}
{
#if defined(JPEG_DEBUG)
#endif
}