Skip to content

Commit

Permalink
Work on colors
Browse files Browse the repository at this point in the history
  • Loading branch information
emericg committed Aug 21, 2024
1 parent dcb1d8a commit 474e661
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 34 deletions.
15 changes: 1 addition & 14 deletions mini_analyser/src/mainwindow_datas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,20 +1126,7 @@ int MainWindow::printVideoDetails()
else
ui->label_video_color_space->setText("YCbCr (best guess)");

if (t->color_subsampling == SS_4444)
ui->label_video_color_subsampling->setText("4:4:4:4");
else if (t->color_subsampling == SS_444)
ui->label_video_color_subsampling->setText("4:4:4");
else if (t->color_subsampling == SS_422)
ui->label_video_color_subsampling->setText("4:2:2");
else if (t->color_subsampling == SS_420)
ui->label_video_color_subsampling->setText("4:2:0");
else if (t->color_subsampling == SS_411)
ui->label_video_color_subsampling->setText("4:1:1");
else if (t->color_subsampling == SS_400)
ui->label_video_color_subsampling->setText("4:0:0");
else
ui->label_video_color_subsampling->setText("4:2:0 (best guess)");
ui->label_video_color_subsampling->setText(getChromaSubsamplingQString((ChromaSubSampling_e)t->color_subsampling));
}
else
{
Expand Down
42 changes: 30 additions & 12 deletions mini_analyser/src/minivideo_utils_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,20 +670,38 @@ QString getStereoModeQString(const StereoMode_e stereoMode)

QString getHdrModeQString(const HdrMode_e hdrMode)
{
QString hdr_mode_qstr;

if (hdrMode == HLG)
hdr_mode_qstr = "HDR10";
else if (hdrMode == HDR10)
hdr_mode_qstr = "HDR10";
else if (hdrMode == HDR10plus)
hdr_mode_qstr = "HDR10+";
else if (hdrMode == DolbyVision)
hdr_mode_qstr = "Dolby Vision";
// product names, not translated, so we can use the function from minivideo
return QString::fromLatin1(getHdrModeString(hdrMode));
}

/* ************************************************************************** */

QString getChromaSubsamplingQString(const ChromaSubSampling_e subsampling)
{
// technical terms, not translated, so we can use the function from minivideo
return QString::fromLatin1(getChromaSubsamplingString(subsampling));
}

QString getChromaLocationQString(const ChromaLocation_e location)
{
QString loc_qstr;

if (location == CHROMA_LOC_LEFT)
loc_qstr = QObject::tr("Left");
else if (location == CHROMA_LOC_CENTER)
loc_qstr = QObject::tr("Center");
else if (location == CHROMA_LOC_TOPLEFT)
loc_qstr = QObject::tr("Top left");
else if (location == CHROMA_LOC_TOP)
loc_qstr = QObject::tr("Top");
else if (location == CHROMA_LOC_BOTTOMLEFT)
loc_qstr = QObject::tr("Bottom left");
else if (location == CHROMA_LOC_BOTTOM)
loc_qstr = QObject::tr("Bottom");
else
hdr_mode_qstr = "SDR";
loc_qstr = QObject::tr("Unknown");

return hdr_mode_qstr;
return loc_qstr;
}

/* ************************************************************************** */
Expand Down
4 changes: 4 additions & 0 deletions mini_analyser/src/minivideo_utils_qt.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ QString getContainerQString(const Containers_e container, const bool long_descri

QString getCodecQString(const StreamType_e type, const Codecs_e codec, const bool long_description);

QString getChromaSubsamplingQString(const ChromaSubSampling_e subsampling);

QString getChromaLocationQString(const ChromaLocation_e location);

/*!
* \brief Get a readable language string.
* \param languageCode[in]: ISO 639-2 or ISO 639-3 language code.
Expand Down
14 changes: 13 additions & 1 deletion minivideo/src/bitstream_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,9 @@ bool computeCodecsSpecifics(MediaFile_t *media)

if (track->stream_codec == CODEC_H264 && track->avcC)
{
// Handle H.264 profile & level
if (avcC->sps_count > 0 && avcC->sps_array[0])
{
// H.264 profile & level
track->stream_codec_profile = getH264CodecProfile(
avcC->sps_array[0]->profile_idc,
avcC->sps_array[0]->constraint_setX_flag[0],
Expand All @@ -569,6 +569,18 @@ bool computeCodecsSpecifics(MediaFile_t *media)
track->max_ref_frames = avcC->sps_array[0]->max_num_ref_frames;
track->color_depth = avcC->sps_array[0]->BitDepthY;

// Chroma
if (avcC->sps_array[0]->chroma_format_idc == 0)
track->color_subsampling = CHROMA_SS_400;
else if (avcC->sps_array[0]->chroma_format_idc == 1)
track->color_subsampling = CHROMA_SS_420;
else if (avcC->sps_array[0]->chroma_format_idc == 2)
track->color_subsampling = CHROMA_SS_422;
else if (avcC->sps_array[0]->chroma_format_idc == 3)
track->color_subsampling = CHROMA_SS_444;
else
track->color_subsampling = CHROMA_SS_420;

if (avcC->sps_array[0]->vui)
{
track->color_range = avcC->sps_array[0]->vui->video_full_range_flag;
Expand Down
9 changes: 3 additions & 6 deletions minivideo/src/demuxer/mp4/mp4_stsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1963,12 +1963,9 @@ int parse_colr(Bitstream_t *bitstr, Mp4Box_t *box_header, Mp4Track_t *track, Mp4
if (track->color_range) track->color_range = colour_range;
}

if (track->color_matrix == 0 && track->color_matrix && track->color_matrix)
{
track->color_primaries = colour_primaries;
track->color_transfer = transfer_characteristics;
track->color_matrix = colour_primaries;
}
track->color_primaries = colour_primaries;
track->color_transfer = transfer_characteristics;
track->color_matrix = matrix_coefficients;
}
else if (colour_type == fourcc_be("rICC"))
{
Expand Down
2 changes: 1 addition & 1 deletion minivideo/src/minivideo_codecs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ const char *getChromaSubsamplingString(const ChromaSubSampling_e subsampling)
case CHROMA_SS_411:
return "4:1:1";
case CHROMA_SS_420:
return "4:2:0+";
return "4:2:0";
case CHROMA_SS_421:
return "4:2:1";
case CHROMA_SS_422:
Expand Down

0 comments on commit 474e661

Please sign in to comment.