Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README files #1

Merged
merged 1 commit into from
Nov 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ from SjpegEncodeParam can be triggered from the keyboard.

Please read the instructions in the INSTALL file.

Basically, you can use the supplied Makefile or generate your build with
cmake:

. `make -j`, or
. `mkdir build && cd build && cmake ../ && make -j`

* Discussion list
*****************

Expand Down
59 changes: 37 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
____ __ __ __ ____ ____ ____
____ __ __ __ ____ ____ ____
/ __\__) / \ \/ _ \ / / _ \
_\_ \ (/ / __/ /_/ __/
\_____/___/__//_/\__/_/_____/_____/
Expand All @@ -21,80 +21,95 @@
The main header is src/sjpeg.h.
This is mainly just one function to call, defined in src/sjpeg.h

```
size_t SjpegCompress(const uint8_t* rgb, int width, int height,
int quality, uint8_t** out_data);
```

This function will make a lot of automatic decisions based on input samples.

There is a more fine-tuned variant available too:

```
size_t SjpegEncode(const uint8_t* const data,
int W, int H, int stride,
uint8_t** const out_data,
int quality, int compression_method,
int yuv_mode);
```

as well as functions with a C++ string-based API.

Also included in the library: some helper functions to inspect JPEG bitstream.
They are meant to help re-processing a JPEG source:
SjpegDimensions(): quickly get the JPEG picture dimensions.
SjpegFindQuantizer(): return the quantization matrices
SjpegEstimateQuality(): return an estimate of the encoding quality
`SjpegDimensions()`: quickly get the JPEG picture dimensions.
`SjpegFindQuantizer()`: return the quantization matrices
`SjpegEstimateQuality()`: return an estimate of the encoding quality

The library comes primarily with a plain-C API, but a C++ version is available
too, that uses std::string as interface.
too, that uses `std::string` as interface.


# SjpegEncodeParam interface:
## SjpegEncodeParam interface:

This should be the most fine-tuned use of the library: SjpegEncodeParam gives
access to a lot of fine controls (C++ only). See src/sjpeg.h for details.
access to a lot of fine controls (C++ only). See `src/sjpeg.h` for details.

In particular, using SjpegEncodeParam is the recommended way of re-compressing
a JPEG input. Here is the recipe:
* use SjpegFindQuantizer to extract the quantization matrices from the source
* use SjpegEncodeParam::SetQuantMatrix() to transfer them to the encoding
parameters (with a reduction factor if necessary)
* call sjpeg::SjpegEncode() with this parameter

Alternatively, one can use SjpegEstimateQuality() and
SjpegEncodeParam::SetQuality() to pass a quality factor instead of the matrices.
* use `SjpegFindQuantizer` to extract the quantization matrices from the source
* use `SjpegEncodeParam::SetQuantMatrix()` to transfer them to the encoding parameters (with a reduction factor if necessary)
* call `sjpeg::SjpegEncode()` with this parameter

SjpegEncodeParam is also useful for transfering some metadata to the final
Alternately, one can use `SjpegEstimateQuality()` and
`SjpegEncodeParam::SetQuality()` to pass a quality factor instead of the matrices.

`SjpegEncodeParam` is also useful for transfering some metadata to the final
JPEG bitstream.

# 'Riskiness' score:
## 'Riskiness' score:

The riskiness score is a decision score to help decide between using YUV 4:2:0
and YUV 4:4:4 downsampling. The function to call is:

```
int SjpegRiskiness(const uint8_t* rgb, int width, int height, int step, float* risk);
```

which returns a recommendation for 'yuv_mode' to use in the above API.

# The 'sjpeg' command line tool:
## The 'sjpeg' command line tool:

`examples/sjpeg` is a very simple tool to compress a PNG/JPEG file to JPEG.

examples/sjpeg is a very simple tool to compress a PNG/JPEG file to JPEG.
`sjpeg in.png -o out.jpg -q 70 # compress the PNG source with quality 70`

sjpeg in.png -o out.jpg -q 70 # compress the PNG source with quality 70
sjpeg in.jpg -o out.jpg -r 90 # recompress JPEG input to ~90%
`sjpeg in.jpg -o out.jpg -r 90 # recompress JPEG input to ~90% `

sjpeg has various options to change the encoding method. Just try `sjpeg -h`.

# The 'vjpeg' command line tool:
## The 'vjpeg' command line tool:

![vjpeg UI](https://github.com/webmproject/sjpeg/examples/vjpeg_sample.jpg "the vjpeg interface")

examples/vjpeg is a (non-essential) visualization tool, built with OpenGL/GLUT.
It allows changing the compression parameters with the keyboard, and visually
inspect the result. This is mostly educational, since most of the parameters
from SjpegEncodeParam can be triggered from the keyboard.
from `SjpegEncodeParam` can be triggered from the keyboard.

# Building the library and tools:

Please read the instructions in the INSTALL file.

Basically, you can use the supplied Makefile or generate your build with
cmake:

* `make -j`, or
* `mkdir build && cd build && cmake ../ && make -j`

# Discussion list

The following forum can be used to report bugs or just discuss sjpeg:

https://groups.google.com/forum/#!forum/sjpeg
[https://groups.google.com/forum/#!forum/sjpeg]([https://groups.google.com/forum/#!forum/sjpeg)
Binary file added examples/vjpeg_sample.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.