Add basic nclc tag support
Sets nclc tags based on the selected output color space. Also adds a Rec.709 OETF to the config
This commit is contained in:
@@ -76,6 +76,7 @@ public:
|
||||
void set_video_pix_fmt(const QString& s) { video_pix_fmt_ = s; }
|
||||
void set_video_is_image_sequence(bool s) { video_is_image_sequence_ = s; }
|
||||
void set_video_color_range(YUVRange r) { video_color_range_ = r; }
|
||||
void set_color_transform(const ColorTransform& color_transform) { color_transform_ = color_transform; }
|
||||
|
||||
const QString& filename() const { return filename_; }
|
||||
|
||||
@@ -91,6 +92,7 @@ public:
|
||||
const QString& video_pix_fmt() const { return video_pix_fmt_; }
|
||||
bool video_is_image_sequence() const { return video_is_image_sequence_; }
|
||||
YUVRange video_color_range() const { return video_color_range_; }
|
||||
const ColorTransform& color_transform() const { return color_transform_; }
|
||||
|
||||
bool audio_enabled() const { return audio_enabled_; }
|
||||
const ExportCodec::Codec &audio_codec() const { return audio_codec_; }
|
||||
@@ -125,6 +127,7 @@ private:
|
||||
QString video_pix_fmt_;
|
||||
bool video_is_image_sequence_;
|
||||
YUVRange video_color_range_;
|
||||
ColorTransform color_transform_;
|
||||
|
||||
bool audio_enabled_;
|
||||
ExportCodec::Codec audio_codec_;
|
||||
|
||||
@@ -220,6 +220,10 @@ bool FFmpegEncoder::WriteFrame(FramePtr frame, rational time)
|
||||
encoded_frame->height = frame->height();
|
||||
encoded_frame->format = video_codec_ctx_->pix_fmt;
|
||||
encoded_frame->color_range = video_codec_ctx_->color_range;
|
||||
encoded_frame->color_trc = video_codec_ctx_->color_trc;
|
||||
encoded_frame->color_primaries = video_codec_ctx_->color_primaries;
|
||||
encoded_frame->colorspace = video_codec_ctx_->colorspace;
|
||||
|
||||
|
||||
// Set interlacing
|
||||
if (frame->video_params().interlacing() != VideoParams::kInterlaceNone) {
|
||||
@@ -647,6 +651,20 @@ bool FFmpegEncoder::InitializeStream(AVMediaType type, AVStream** stream_ptr, AV
|
||||
if (params().video_buffer_size() > 0) {
|
||||
codec_ctx->rc_buffer_size = static_cast<int>(params().video_buffer_size());
|
||||
}
|
||||
|
||||
if (params().format() == ExportFormat::Format::kFormatQuickTime) {
|
||||
// nclc tags. See https://ffmpeg.org/doxygen/4.0/pixfmt_8h.html#ad384ee5a840bafd73daef08e6d9cafe7
|
||||
if (params().color_transform().output().contains("sRGB")) {
|
||||
codec_ctx->color_primaries = AVCOL_PRI_BT709;
|
||||
codec_ctx->color_trc = AVCOL_TRC_BT709;
|
||||
codec_ctx->colorspace = AVCOL_SPC_BT709;
|
||||
} else { // Assume Rec.709
|
||||
codec_ctx->color_primaries = AVCOL_PRI_BT709;
|
||||
codec_ctx->color_trc = AVCOL_TRC_BT709;
|
||||
codec_ctx->colorspace = AVCOL_SPC_BT709;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} else if (type == AVMEDIA_TYPE_AUDIO) {
|
||||
|
||||
@@ -281,6 +281,20 @@ colorspaces:
|
||||
- !<MatrixTransform> {matrix: [0.606530, 0.220408, 0.123479, 0, 0.267989, 0.832731, -0.100720, 0, -0.029442, -0.086611, 1.204861, 0, 0, 0, 0, 1]}
|
||||
- !<ColorSpaceTransform> {src: CIE-XYZ D65, dst: reference}
|
||||
|
||||
- !<ColorSpace>
|
||||
name: Rec.709 OETF
|
||||
family: Camera Footage
|
||||
equalitygroup: ""
|
||||
bitdepth: 32f
|
||||
description: |
|
||||
Rec.709 OETF
|
||||
isdata: false
|
||||
allocation: uniform
|
||||
allocationvars: [0, 1]
|
||||
to_reference: !<GroupTransform>
|
||||
children:
|
||||
- !<FileTransform> {src: rec709_to_linear.spi1d, interpolation: linear}
|
||||
|
||||
- !<ColorSpace>
|
||||
name: Non-Colour Data
|
||||
family:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -54,16 +54,6 @@ void ExportParams::set_video_scaling_method(const ExportParams::VideoScalingMeth
|
||||
video_scaling_method_ = video_scaling_method;
|
||||
}
|
||||
|
||||
const ColorTransform &ExportParams::color_transform() const
|
||||
{
|
||||
return color_transform_;
|
||||
}
|
||||
|
||||
void ExportParams::set_color_transform(const ColorTransform &color_transform)
|
||||
{
|
||||
color_transform_ = color_transform;
|
||||
}
|
||||
|
||||
QMatrix4x4 ExportParams::GenerateMatrix(ExportParams::VideoScalingMethod method,
|
||||
int source_width, int source_height,
|
||||
int dest_width, int dest_height)
|
||||
@@ -103,7 +93,7 @@ void ExportParams::Save(QXmlStreamWriter *writer) const
|
||||
writer->writeTextElement(QStringLiteral("customrangeout"), custom_range_.out().toString());
|
||||
|
||||
// FIXME: Change this when color chains are implemented
|
||||
writer->writeTextElement(QStringLiteral("color"), color_transform_.output());
|
||||
writer->writeTextElement(QStringLiteral("color"), color_transform().output());
|
||||
|
||||
EncodingParams::Save(writer);
|
||||
|
||||
|
||||
@@ -46,9 +46,6 @@ public:
|
||||
const VideoScalingMethod& video_scaling_method() const;
|
||||
void set_video_scaling_method(const VideoScalingMethod& video_scaling_method);
|
||||
|
||||
const ColorTransform& color_transform() const;
|
||||
void set_color_transform(const ColorTransform& color_transform);
|
||||
|
||||
static QMatrix4x4 GenerateMatrix(ExportParams::VideoScalingMethod method,
|
||||
int source_width, int source_height,
|
||||
int dest_width, int dest_height);
|
||||
@@ -61,8 +58,6 @@ private:
|
||||
bool has_custom_range_;
|
||||
TimeRange custom_range_;
|
||||
|
||||
ColorTransform color_transform_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user