Skip to content

Commit

Permalink
0.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-huet committed Dec 7, 2014
1 parent 5603437 commit 0f4bd5b
Show file tree
Hide file tree
Showing 15 changed files with 873 additions and 473 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version 0.9.1:

- Added new meta data tags: ICC profile, XMP and thumbnail.
- Disabled metadata copying by default.
- Use same chroma pixel position as JPEG for 4:2:2 and 4:2:0.

version 0.9:

- Initial release.
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ USE_JCTVC=y
#USE_JCTVC_HIGH_BIT_DEPTH=y
# Enable the cross compilation for Windows
#CONFIG_WIN32=y
# Enable for compilation on MacOS X
#CONFIG_APPLE=y
# Installation prefix
prefix=/usr/local

Expand Down Expand Up @@ -43,13 +45,18 @@ CFLAGS+=-DRExt__HIGH_BIT_DEPTH_SUPPORT
endif

# Emscriptem config
EMLDFLAGS:=-s "EXPORTED_FUNCTIONS=['_bpg_decoder_open','_bpg_decoder_get_info','_bpg_decoder_start','_bpg_decoder_get_line','_bpg_decoder_close','_malloc','_free']"
EMLDFLAGS:=-s "EXPORTED_FUNCTIONS=['_bpg_decoder_open','_bpg_decoder_decode','_bpg_decoder_get_info','_bpg_decoder_start','_bpg_decoder_get_line','_bpg_decoder_close','_malloc','_free']"
EMLDFLAGS+=-s NO_FILESYSTEM=1 -s NO_BROWSER=1 -s TOTAL_MEMORY=33554432
#EMLDFLAGS+=-O1 --post-js post.js
EMLDFLAGS+=-O3 --memory-init-file 0 --closure 1 --post-js post.js
EMCFLAGS:=$(CFLAGS)

LDFLAGS= -g -Wl,--gc-sections
LDFLAGS=-g
ifdef CONFIG_APPLE
LDFLAGS+=-Wl,-dead_strip
else
LDFLAGS+=-Wl,--gc-sections
endif
CFLAGS+=-g
CXXFLAGS=$(CFLAGS)

Expand Down Expand Up @@ -113,8 +120,13 @@ ifdef CONFIG_WIN32
LIBS:=-lz
LDFLAGS+=-static
else
LIBS:=-lrt -lm -lpthread
endif
ifdef CONFIG_APPLE
LIBS:=
else
LIBS:=-lrt
endif # !CONFIG_APPLE
LIBS+=-lm -lpthread
endif # !CONFIG_WIN32

BPGENC_LIBS+=-lpng -ljpeg $(LIBS)

Expand Down
21 changes: 20 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ BPG Image Encoder and Decoder
mode is less tested that the lossy mode but it usually gives better
results that PNG on photographic images.

- There is a difference of interpreation of the quantizer parameter
- There is a difference of interpretation of the quantizer parameter
(-q option) between the x265 and JCTVC encoder. The default value is
optimized for the JCTVC encoder, not for x265. We will try to align
the x265 value to JCTVC in the future.
Expand All @@ -61,6 +61,25 @@ BPG Image Encoder and Decoder
Makefile define: USE_JCTVC_HIGH_BIT_DEPTH. The encoder is sligthly
slower in this case.

- Color space and chroma format:

* For JPEG input, the color space of the input image is not
modified (it is YCbCr, RGB, YCbCrK or CMYK). The chroma is
subsampled according to the preferred chroma format ('-f'
option). Images with vertically subsampled chroma are currently
not supported.

* For PNG input, grayscale images are not modified. For RGB
images, the input image is converted to the preferred color
space ('-c' option). Its chroma is then subsampled according to
the preferred chroma format.

* grayscale images are kept unmodified.

- By default, bpgenc does not copy the metadata. You can copy them
with the '-keepmetadata' option. For JPEG input, EXIF, ICCP and XMP
are copied. For PNG input, ICCP is copied.

3) FFmpeg modifications
-----------------------

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9
0.9.1
61 changes: 46 additions & 15 deletions bpgdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,13 @@ static void png_save(BPGDecoderContext *img, const char *filename, int bit_depth
}
#endif /* USE_PNG */



static void bpg_show_info(const char *filename)
static void bpg_show_info(const char *filename, int show_extensions)
{
uint8_t buf[BPG_DECODER_INFO_BUF_SIZE];
int buf_len, ret;
uint8_t *buf;
int buf_len, ret, buf_len_max;
FILE *f;
BPGImageInfo p_s, *p = &p_s;
BPGExtensionData *first_md, *md;
static const char *format_str[4] = {
"Gray",
"4:2:0",
Expand All @@ -188,15 +187,34 @@ static void bpg_show_info(const char *filename)
"YCbCrK",
"CMYK",
};

static const char *extension_tag_str[] = {
"Unknown",
"EXIF",
"ICC profile",
"XMP",
"Thumbnail",
};

f = fopen(filename, "rb");
if (!f) {
fprintf(stderr, "Could not open %s\n", filename);
exit(1);
}

buf_len = fread(buf, 1, sizeof(buf), f);
ret = bpg_decoder_get_info_from_buf(p, buf, buf_len);
if (show_extensions) {
fseek(f, 0, SEEK_END);
buf_len_max = ftell(f);
fseek(f, 0, SEEK_SET);
} else {
/* if no extension are shown, just need the header */
buf_len_max = BPG_DECODER_INFO_BUF_SIZE;
}
buf = malloc(buf_len_max);
buf_len = fread(buf, 1, buf_len_max, f);

ret = bpg_decoder_get_info_from_buf(p, show_extensions ? &first_md : NULL,
buf, buf_len);
free(buf);
fclose(f);
if (ret < 0) {
fprintf(stderr, "Not a BPG image\n");
Expand All @@ -208,6 +226,19 @@ static void bpg_show_info(const char *filename)
p->has_alpha,
format_str[p->format],
p->bit_depth);
if (first_md) {
const char *tag_name;
printf("Extension data:\n");
for(md = first_md; md != NULL; md = md->next) {
if (md->tag <= 4)
tag_name = extension_tag_str[md->tag];
else
tag_name = extension_tag_str[0];
printf(" tag=%d (%s) length=%d\n",
md->tag, tag_name, md->buf_len);
}
bpg_decoder_free_extension_data(first_md);
}
}

static void help(void)
Expand All @@ -217,7 +248,7 @@ static void help(void)
"Options:\n"
"-o outfile.[ppm|png] set the output filename (default = out.png)\n"
"-b bit_depth PNG output only: use bit_depth per component (8 or 16, default = 8)\n"
"-i display information about the picture\n");
"-i display information about the image\n");
exit(1);
}

Expand Down Expand Up @@ -261,7 +292,7 @@ int main(int argc, char **argv)
filename = argv[optind++];

if (show_info) {
bpg_show_info(filename);
bpg_show_info(filename, 1);
return 0;
}

Expand All @@ -283,14 +314,14 @@ int main(int argc, char **argv)

fclose(f);

img = bpg_decoder_open(buf, buf_len);
free(buf);

if (!img) {
img = bpg_decoder_open();

if (bpg_decoder_decode(img, buf, buf_len) < 0) {
fprintf(stderr, "Could not decode image\n");
exit(1);
}

free(buf);

#ifdef USE_PNG
p = strrchr(outfilename, '.');
if (p)
Expand Down
Loading

0 comments on commit 0f4bd5b

Please sign in to comment.