aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2020-07-08 18:20:27 +0200
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2020-07-08 18:20:27 +0200
commitbecb0efd507149b9771803eef91f4b1273cbe941 (patch)
tree32007f65ca4a56b79b6af27464ff2f6983d9d360
parentb47e44e0fcda64938ef5314e22da7d310d672210 (diff)
edid-decode: introduce timings_ext struct
This simplifies storing timings together with the type and flags strings. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--edid-decode.cpp31
-rw-r--r--edid-decode.h31
-rw-r--r--parse-base-block.cpp12
-rw-r--r--parse-cta-block.cpp40
4 files changed, 58 insertions, 56 deletions
diff --git a/edid-decode.cpp b/edid-decode.cpp
index 440f590..4b9ba5a 100644
--- a/edid-decode.cpp
+++ b/edid-decode.cpp
@@ -1125,38 +1125,33 @@ int edid_state::parse_edid()
msg(!fail || edid_minor >= 4, "%s", err.c_str());
}
- if (native_interlaced_timing.vact && !native_timing.vact)
+ if (native_interlaced_timing.t.vact && !native_timing.t.vact)
fail("A native interlaced timing is present, but not a native progressive timing.\n");
- if (native_interlaced_timing.vact && native_timing.vact &&
- native_interlaced_timing.vact != native_timing.vact)
+ if (native_interlaced_timing.t.vact && native_timing.t.vact &&
+ native_interlaced_timing.t.vact != native_timing.t.vact)
warn("The native interlaced frame height differs from the native progressive frame height.\n");
- if (native_timing.vact && preferred_timings.vact > native_timing.vact) {
+ if (native_timing.t.vact && preferred_timings.t.vact > native_timing.t.vact) {
warn("Native resolution of %ux%u is smaller than the preferred resolution %ux%u.\n",
- native_timing.hact, native_timing.vact,
- preferred_timings.hact, preferred_timings.vact);
+ native_timing.t.hact, native_timing.t.vact,
+ preferred_timings.t.hact, preferred_timings.t.vact);
}
if (options[OptPreferredTimings]) {
printf("\n----------------\n");
printf("\nPreferred Video Timing:\n");
- print_timings(" ", &preferred_timings,
- preferred_type.c_str(),
- preferred_flags.c_str(), true);
+ print_timings(" ", preferred_timings, true);
}
- if (options[OptNativeTimings] && (native_timing.vact || native_interlaced_timing.vact)) {
+ if (options[OptNativeTimings] &&
+ (native_timing.t.vact || native_interlaced_timing.t.vact)) {
printf("\n----------------\n");
- if (native_timing.vact) {
+ if (native_timing.t.vact) {
printf("\nNative Progressive Video Timing:\n");
- print_timings(" ", &native_timing,
- native_type.c_str(),
- native_flags.c_str(), true);
+ print_timings(" ", native_timing, true);
}
- if (native_interlaced_timing.vact) {
+ if (native_interlaced_timing.t.vact) {
printf("\nNative Interlaced Video Timing:\n");
- print_timings(" ", &native_interlaced_timing,
- native_interlaced_type.c_str(),
- native_interlaced_flags.c_str(), true);
+ print_timings(" ", native_interlaced_timing, true);
}
}
diff --git a/edid-decode.h b/edid-decode.h
index e8f2507..a2877b3 100644
--- a/edid-decode.h
+++ b/edid-decode.h
@@ -56,6 +56,17 @@ struct timings {
bool ycbcr420; // YCbCr 4:2:0 encoding
};
+struct timings_ext {
+ timings_ext()
+ {
+ memset(&t, 0, sizeof(t));
+ }
+
+ timings t;
+ std::string type;
+ std::string flags;
+};
+
struct edid_state {
edid_state()
{
@@ -65,9 +76,6 @@ struct edid_state {
min_hor_freq_hz = 0xffffff;
min_vert_freq_hz = 0xffffffff;
warnings = failures = 0;
- memset(&preferred_timings, 0, sizeof(preferred_timings));
- memset(&native_timing, 0, sizeof(native_timing));
- memset(&native_interlaced_timing, 0, sizeof(native_interlaced_timing));
preparse_total_dtds = 0;
// Base block state
@@ -110,15 +118,9 @@ struct edid_state {
unsigned block_nr;
std::string block;
std::string data_block;
- timings preferred_timings;
- std::string preferred_type;
- std::string preferred_flags;
- timings native_timing;
- std::string native_type;
- std::string native_flags;
- timings native_interlaced_timing;
- std::string native_interlaced_type;
- std::string native_interlaced_flags;
+ timings_ext preferred_timings;
+ timings_ext native_timing;
+ timings_ext native_interlaced_timing;
unsigned preparse_total_dtds;
unsigned min_hor_freq_hz;
@@ -184,6 +186,11 @@ struct edid_state {
bool print_timings(const char *prefix, const struct timings *t,
const char *type, const char *flags = "",
bool detailed = false);
+ bool print_timings(const char *prefix, const struct timings_ext &t,
+ bool detailed = false)
+ {
+ return print_timings(prefix, &t.t, t.type.c_str(), t.flags.c_str(), detailed);
+ };
void edid_gtf_mode(unsigned refresh, struct timings &t);
void edid_cvt_mode(unsigned refresh, struct timings &t);
void detailed_cvt_descriptor(const char *prefix, const unsigned char *x, bool first);
diff --git a/parse-base-block.cpp b/parse-base-block.cpp
index 2b1e40a..72e6e6f 100644
--- a/parse-base-block.cpp
+++ b/parse-base-block.cpp
@@ -1331,12 +1331,12 @@ void edid_state::detailed_timings(const char *prefix, const unsigned char *x,
bool ok = print_timings(prefix, &t, s_type.c_str(), s_flags.c_str(), true);
if (block_nr == 0 && dtd_cnt == 1) {
- preferred_timings = t;
- preferred_type = s_type;
- preferred_flags = s_flags;
- native_timing = t;
- native_type = s_type;
- native_flags = s_flags;
+ preferred_timings.t = t;
+ preferred_timings.type = s_type;
+ preferred_timings.flags = s_flags;
+ native_timing.t = t;
+ native_timing.type = s_type;
+ native_timing.flags = s_flags;
}
if ((max_display_width_mm && !t.hsize_mm) ||
diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp
index a3687eb..35f0e75 100644
--- a/parse-cta-block.cpp
+++ b/parse-cta-block.cpp
@@ -394,31 +394,31 @@ void edid_state::cta_svd(const unsigned char *x, unsigned n, bool for_ycbcr420)
print_timings(" ", t, type, flags);
}
if (override_pref) {
- preferred_timings = *t;
- preferred_type = type;
- preferred_flags = flags;
+ preferred_timings.t = *t;
+ preferred_timings.type = type;
+ preferred_timings.flags = flags;
warn("VIC %u is the preferred timing, overriding the first detailed timings. Is this intended?\n", vic);
}
if (native) {
if (t->interlaced) {
- if (native_interlaced_timing.hact &&
- (native_interlaced_timing.hact != t->hact ||
- native_interlaced_timing.vact != t->vact))
+ if (native_interlaced_timing.t.hact &&
+ (native_interlaced_timing.t.hact != t->hact ||
+ native_interlaced_timing.t.vact != t->vact))
fail("Native VIC %u overrides earlier native interlaced timing.\n", vic);
- if (!native_interlaced_timing.hact) {
- native_interlaced_timing = *t;
- native_interlaced_type = type;
- native_interlaced_flags = flags;
+ if (!native_interlaced_timing.t.hact) {
+ native_interlaced_timing.t = *t;
+ native_interlaced_timing.type = type;
+ native_interlaced_timing.flags = flags;
}
} else {
- if (native_timing.hact &&
- (native_timing.hact != t->hact ||
- native_timing.vact != t->vact))
+ if (native_timing.t.hact &&
+ (native_timing.t.hact != t->hact ||
+ native_timing.t.vact != t->vact))
fail("Native VIC %u overrides earlier native timing.\n", vic);
- if (!native_timing.hact) {
- native_timing = *t;
- native_type = type;
- native_flags = flags;
+ if (!native_timing.t.hact) {
+ native_timing.t = *t;
+ native_timing.type = type;
+ native_timing.flags = flags;
}
}
}
@@ -1962,9 +1962,9 @@ void edid_state::parse_cta_block(const unsigned char *x)
if (first_block) {
if (!(x[3] & 0x0f)) {
first_svd_might_be_preferred = true;
- memset(&native_timing, 0, sizeof(native_timing));
- memset(&native_interlaced_timing, 0,
- sizeof(native_interlaced_timing));
+ memset(&native_timing.t, 0, sizeof(native_timing.t));
+ memset(&native_interlaced_timing.t, 0,
+ sizeof(native_interlaced_timing.t));
} else if ((x[3] & 0x0f) > 1) {
warn("More than one native DTD is unusual.\n");
}

Privacy Policy