linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] libdvbv5: do not adjust DVB time daylight saving
@ 2019-01-02 16:03 André Roth
  2019-01-02 16:03 ` [PATCH 2/3] libdvbv5: enable newlines in dvb strings André Roth
  2019-01-02 16:03 ` [PATCH 3/3] libdvbv5: fix array size in desc_logical_channel André Roth
  0 siblings, 2 replies; 3+ messages in thread
From: André Roth @ 2019-01-02 16:03 UTC (permalink / raw)
  To: linux-media; +Cc: abassetta, André Roth

Sets tm_isdst to -1. This makes dvb_time available
outside of EIT parsing, and struct tm to reflect the
actual values received from DVB.

Also fixes indentation.

Signed-off-by: André Roth <neolynx@gmail.com>
---
 lib/libdvbv5/tables/eit.c | 49 +++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/lib/libdvbv5/tables/eit.c b/lib/libdvbv5/tables/eit.c
index a6ba566a..40db637a 100644
--- a/lib/libdvbv5/tables/eit.c
+++ b/lib/libdvbv5/tables/eit.c
@@ -156,33 +156,32 @@ void dvb_table_eit_print(struct dvb_v5_fe_parms *parms, struct dvb_table_eit *ei
 
 void dvb_time(const uint8_t data[5], struct tm *tm)
 {
-  /* ETSI EN 300 468 V1.4.1 */
-  int year, month, day, hour, min, sec;
-  int k = 0;
-  uint16_t mjd;
-
-  mjd   = *(uint16_t *) data;
-  hour  = dvb_bcd(data[2]);
-  min   = dvb_bcd(data[3]);
-  sec   = dvb_bcd(data[4]);
-  year  = ((mjd - 15078.2) / 365.25);
-  month = ((mjd - 14956.1 - (int) (year * 365.25)) / 30.6001);
-  day   = mjd - 14956 - (int) (year * 365.25) - (int) (month * 30.6001);
-  if (month == 14 || month == 15) k = 1;
-  year += k;
-  month = month - 1 - k * 12;
-
-  tm->tm_sec   = sec;
-  tm->tm_min   = min;
-  tm->tm_hour  = hour;
-  tm->tm_mday  = day;
-  tm->tm_mon   = month - 1;
-  tm->tm_year  = year;
-  tm->tm_isdst = 1; /* dst in effect, do not adjust */
-  mktime( tm );
+	/* ETSI EN 300 468 V1.4.1 */
+	int year, month, day, hour, min, sec;
+	int k = 0;
+	uint16_t mjd;
+
+	mjd   = *(uint16_t *) data;
+	hour  = dvb_bcd(data[2]);
+	min   = dvb_bcd(data[3]);
+	sec   = dvb_bcd(data[4]);
+	year  = ((mjd - 15078.2) / 365.25);
+	month = ((mjd - 14956.1 - (int) (year * 365.25)) / 30.6001);
+	day   = mjd - 14956 - (int) (year * 365.25) - (int) (month * 30.6001);
+	if (month == 14 || month == 15) k = 1;
+	year += k;
+	month = month - 1 - k * 12;
+
+	tm->tm_sec   = sec;
+	tm->tm_min   = min;
+	tm->tm_hour  = hour;
+	tm->tm_mday  = day;
+	tm->tm_mon   = month - 1;
+	tm->tm_year  = year;
+	tm->tm_isdst = -1; /* do not adjust */
+	mktime( tm );
 }
 
-
 const char *dvb_eit_running_status_name[8] = {
 	[0] = "Undefined",
 	[1] = "Not running",
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/3] libdvbv5: enable newlines in dvb strings
  2019-01-02 16:03 [PATCH 1/3] libdvbv5: do not adjust DVB time daylight saving André Roth
@ 2019-01-02 16:03 ` André Roth
  2019-01-02 16:03 ` [PATCH 3/3] libdvbv5: fix array size in desc_logical_channel André Roth
  1 sibling, 0 replies; 3+ messages in thread
From: André Roth @ 2019-01-02 16:03 UTC (permalink / raw)
  To: linux-media; +Cc: abassetta, André Roth

Newlines in are encoded as 0x8a, convert them to '\n'

Signed-off-by: André Roth <neolynx@gmail.com>
---
 lib/libdvbv5/parse_string.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/libdvbv5/parse_string.c b/lib/libdvbv5/parse_string.c
index 6e301ac8..d354f497 100644
--- a/lib/libdvbv5/parse_string.c
+++ b/lib/libdvbv5/parse_string.c
@@ -461,11 +461,13 @@ void dvb_parse_string(struct dvb_v5_fe_parms *parms, char **dest, char **emph,
 				emphasis = 1;
 			else if (*s == 0x87 && emphasis)
 				emphasis = 0;
-			else  if (*s >= 0x20 && (*s < 0x80 || *s > 0x9f)) {
+			else if (*s >= 0x20 && (*s < 0x80 || *s > 0x9f)) {
 				*p++ = *s;
 				if (emphasis)
 					*p2++ = *s;
 			}
+			else if (*s == 0x8a)
+				*p++ = '\n';
 		}
 		*p = '\0';
 		*p2 = '\0';
@@ -495,6 +497,8 @@ void dvb_parse_string(struct dvb_v5_fe_parms *parms, char **dest, char **emph,
 				emphasis = 1;
 			else if (code == 0xe087 && emphasis)
 				emphasis = 0;
+			else if (code == 0xe08a)
+				/* newline, append code blow */ ;
 			else if (code >= 0xe080 && code <= 0xe09f)
 				continue;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 3/3] libdvbv5: fix array size in desc_logical_channel
  2019-01-02 16:03 [PATCH 1/3] libdvbv5: do not adjust DVB time daylight saving André Roth
  2019-01-02 16:03 ` [PATCH 2/3] libdvbv5: enable newlines in dvb strings André Roth
@ 2019-01-02 16:03 ` André Roth
  1 sibling, 0 replies; 3+ messages in thread
From: André Roth @ 2019-01-02 16:03 UTC (permalink / raw)
  To: linux-media; +Cc: abassetta, André Roth

This fixes the descriptor paring on 64bit systems.
Thanks to abassetta@tiscali.it for finding and patching.

Signed-off-by: André Roth <neolynx@gmail.com>
---
 lib/libdvbv5/descriptors/desc_logical_channel.c | 4 ++--
 lib/libdvbv5/dvb-file.c                         | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/libdvbv5/descriptors/desc_logical_channel.c b/lib/libdvbv5/descriptors/desc_logical_channel.c
index 7ae4d59a..1a8dc658 100644
--- a/lib/libdvbv5/descriptors/desc_logical_channel.c
+++ b/lib/libdvbv5/descriptors/desc_logical_channel.c
@@ -40,7 +40,7 @@ int dvb_desc_logical_channel_init(struct dvb_v5_fe_parms *parms,
 
 	memcpy(d->lcn, p, d->length);
 
-	len = d->length / sizeof(d->lcn);
+	len = d->length / 4;
 
 	for (i = 0; i < len; i++) {
 		bswap16(d->lcn[i].service_id);
@@ -55,7 +55,7 @@ void dvb_desc_logical_channel_print(struct dvb_v5_fe_parms *parms, const struct
 	int i;
 	size_t len;
 
-	len = d->length / sizeof(d->lcn);
+	len = d->length / 4;
 
 	for (i = 0; i < len; i++) {
 		dvb_loginfo("|           service ID[%d]     %d", i, d->lcn[i].service_id);
diff --git a/lib/libdvbv5/dvb-file.c b/lib/libdvbv5/dvb-file.c
index ffdfe292..d077271a 100644
--- a/lib/libdvbv5/dvb-file.c
+++ b/lib/libdvbv5/dvb-file.c
@@ -987,7 +987,7 @@ static char *dvb_vchannel(struct dvb_v5_fe_parms_priv *parms,
 		size_t len;
 		int r;
 
-		len = d->length / sizeof(d->lcn);
+		len = d->length / 4;
 		for (i = 0; i < len; i++) {
 			if (service_id == d->lcn[i].service_id) {
 				r = asprintf(&buf, "%d.%d",
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-02 16:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-02 16:03 [PATCH 1/3] libdvbv5: do not adjust DVB time daylight saving André Roth
2019-01-02 16:03 ` [PATCH 2/3] libdvbv5: enable newlines in dvb strings André Roth
2019-01-02 16:03 ` [PATCH 3/3] libdvbv5: fix array size in desc_logical_channel André Roth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).