Skip to content

Commit 693529a

Browse files
committed
- Use calculated CICP values instead of using config.
- Now full color range is default.
1 parent 6be0c3f commit 693529a

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3535
- `--transfer-characteristics 13` (sRGB/sYCC)
3636
- `--matrix-coefficients 5` (sYCC)
3737
- All of `--color-primaries`, `--transfer-characteristics` and `--matrix-coefficients` nor none of them must be set.
38+
- `--enable-full-color-range` is now default, as mentioned in [ISO/IEC 23000-22:2019/Amd 2:2021](https://www.iso.org/standard/81634.html).
3839
- [Use SingleItemTypeReferenceBox instead of SingleItemTypeReferenceBoxLarge](https://github.com/link-u/cavif/commit/e271be5eddf1259d7a34315ece967a5e95766f49) to make images smaller.
3940

4041
### Fixed

doc/ja_JP/usage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ AV1のプロファイルを指定する。[プロファイルごとに使える
291291

292292
### 色域
293293

294-
- `--disable-full-color-range`(初期値)
295-
- `--enable-full-color-range`
294+
- `--enable-full-color-range`(初期値)
295+
- `--disable-full-color-range`
296296

297297
例えば通常の8bitのYUVのフォーマットでは、Yの値として16-235、UとVの値として16-240しか使わないが、このフラグをenableにすると0-255のすべてを使うようになる。10/12ビットでも同様。デフォルトではfalse。
298298

src/Config.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ clipp::group Config::createCommandLineFlags() {
203203
option("--profile").doc("AV1 Profile(0=base, 1=high, 2=professional)") & integer("0=base(default), 1=high, 2=professional", aom.g_profile),
204204
option("--pix-fmt").doc("Pixel format of output image") & (parameter("yuv420").set(pixFmt, AOM_IMG_FMT_I420).doc("YUV420 format (default)") | parameter("yuv422").set(pixFmt, AOM_IMG_FMT_I422).doc("YUV422 format") | parameter("yuv444").set(pixFmt, AOM_IMG_FMT_I444).doc("YUV444 format (recommended for lossless images)")),
205205
option("--bit-depth").doc("Bit depth of output image") & (parameter("8").set(aom.g_bit_depth, AOM_BITS_8).doc("8bits per color, 24bits per pixel (default)") | parameter("10").set(aom.g_bit_depth, AOM_BITS_10).doc("10bits per color, 30bits per pixel") | parameter("12").set(aom.g_bit_depth, AOM_BITS_12).doc("12bits per color, 36bits per pixel")),
206-
option("--disable-full-color-range").doc("Use limited YUV color range (default)").set(fullColorRange, false),
207-
option("--enable-full-color-range").doc("Use full YUV color range").set(fullColorRange, true)
206+
option("--disable-full-color-range").doc("Use limited YUV color range").set(fullColorRange, false),
207+
option("--enable-full-color-range").doc("Use full YUV color range (default)").set(fullColorRange, true)
208208
);
209209

210210
// trade-offs between speed and quality.
@@ -395,16 +395,15 @@ numbers.
395395
}
396396

397397
std::optional<avif::img::ColorProfile> Config::calcColorProfile() const {
398+
avif::img::ColorProfile profile;
399+
profile.cicp = std::make_optional<avif::ColourInformationBox::CICP>();
398400
if(colorPrimaries.has_value() && transferCharacteristics.has_value() && matrixCoefficients.has_value()) {
399-
avif::img::ColorProfile profile;
400-
profile.cicp = std::make_optional<avif::ColourInformationBox::CICP>();
401401
profile.cicp->colourPrimaries = static_cast<uint16_t>(colorPrimaries.value());
402402
profile.cicp->transferCharacteristics = static_cast<uint16_t>(transferCharacteristics.value());
403403
profile.cicp->colourPrimaries = static_cast<uint16_t>(colorPrimaries.value());
404-
profile.cicp->fullRangeFlag = fullColorRange;
405-
return profile;
406404
}
407-
return {};
405+
profile.cicp->fullRangeFlag = fullColorRange;
406+
return profile;
408407
}
409408

410409
void Config::modify(aom_codec_ctx_t* aom, avif::img::ColorProfile const& colorProfile) {

src/Config.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class Config final {
9898
bool lossless = false;
9999
bool enableCDEF = false;
100100
bool enableRestoration = false;
101-
bool fullColorRange = false;
101+
bool fullColorRange = true;
102102
aom_superblock_size_t superblockSize = AOM_SUPERBLOCK_SIZE_DYNAMIC;
103103
aom_tune_metric tune = AOM_TUNE_SSIM;
104104
std::string vmafModelPath = "/usr/share/cavif/model/vmaf_v0.6.1.pkl";

src/img/Conversion.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ void convert(Config& config, avif::img::Image<rgbBits>& src, aom_image& dst) {
144144
config.pixFmt :
145145
static_cast<aom_img_fmt_t>(config.pixFmt | static_cast<unsigned int>(AOM_IMG_FMT_HIGHBITDEPTH));
146146
aom_img_alloc(&dst, pixFmt, src.width(), src.height(), 1);
147-
dst.range = config.fullColorRange ? AOM_CR_FULL_RANGE : AOM_CR_STUDIO_RANGE;
147+
avif::ColourInformationBox::CICP const cicp = src.colorProfile().cicp.value_or(avif::ColourInformationBox::CICP());
148+
dst.range = cicp.fullRangeFlag ? AOM_CR_FULL_RANGE : AOM_CR_STUDIO_RANGE;
148149
dst.monochrome = config.codec.monochrome ? 1 : 0;
149150
dst.bit_depth = config.codec.g_bit_depth;
150151

0 commit comments

Comments
 (0)