[vlc-commits] DTV: represent guard intervals as ints rather than strings internally
Rémi Denis-Courmont
git at videolan.org
Fri Mar 25 22:57:51 CET 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Mar 25 13:26:05 2011 +0200| [223d42467bf7a3fb5ae3b6b7d1c8e8fc4d65cc1a] | committer: Rémi Denis-Courmont
DTV: represent guard intervals as ints rather than strings internally
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=223d42467bf7a3fb5ae3b6b7d1c8e8fc4d65cc1a
---
modules/access/dtv/access.c | 28 ++++++++++++++++++++++++++--
modules/access/dtv/dtv.h | 5 ++++-
modules/access/dtv/linux.c | 34 +++++++++++++++++-----------------
3 files changed, 47 insertions(+), 20 deletions(-)
diff --git a/modules/access/dtv/access.c b/modules/access/dtv/access.c
index 78ee862..3e758d5 100644
--- a/modules/access/dtv/access.c
+++ b/modules/access/dtv/access.c
@@ -583,6 +583,31 @@ static char *var_InheritModulation (vlc_object_t *obj)
return strdup (str);
}
+static unsigned var_InheritGuardInterval (vlc_object_t *obj)
+{
+ char *guard = var_InheritString (obj, "dvb-guard");
+ if (guard == NULL)
+ return VLC_GUARD_AUTO;
+
+ uint16_t a, b;
+ int v = sscanf (guard, "%"SCNu16"/%"SCNu16, &a, &b);
+ free (guard);
+ switch (v)
+ {
+ case 1:
+ /* Backward compatibility with VLC < 1.2 */
+ if (a == 0)
+ break;
+ msg_Warn (obj, "\"guard=%"PRIu16"\" option is obsolete. "
+ "Use \"guard=1/%"PRIu16" instead.", a, a);
+ b = a;
+ a = 1;
+ case 2:
+ return VLC_GUARD(a, b);
+ }
+ return VLC_GUARD_AUTO;
+}
+
/*** ATSC ***/
static int atsc_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq)
@@ -700,13 +725,12 @@ static int dvbt_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq)
char *mod = var_InheritModulation (obj);
char *fec_hp = var_InheritString (obj, "dvb-code-rate-hp");
char *fec_lp = var_InheritString (obj, "dvb-code-rate-lp");
- char *guard = var_InheritString (obj, "dvb-guard");
+ uint32_t guard = var_InheritGuardInterval (obj);
uint32_t bw = var_InheritInteger (obj, "dvb-bandwidth");
int tx = var_InheritInteger (obj, "dvb-transmission");
int h = var_InheritInteger (obj, "dvb-hierarchy");
int ret = dvb_set_dvbt (dev, freq, mod, fec_hp, fec_lp, bw, tx, guard, h);
- free (guard);
free (fec_lp);
free (fec_hp);
free (mod);
diff --git a/modules/access/dtv/dtv.h b/modules/access/dtv/dtv.h
index f4883e3..ab48aa5 100644
--- a/modules/access/dtv/dtv.h
+++ b/modules/access/dtv/dtv.h
@@ -40,6 +40,9 @@ float dvb_get_snr (dvb_device_t *);
int dvb_set_inversion (dvb_device_t *, int);
int dvb_tune (dvb_device_t *);
+#define VLC_GUARD(a,b) (((a) << 16u) | (b))
+#define VLC_GUARD_AUTO 0xFFFFFFFF
+
/* DVB-C */
int dvb_set_dvbc (dvb_device_t *, uint32_t freq, const char *mod,
uint32_t srate, const char *fec);
@@ -55,7 +58,7 @@ int dvb_set_sec (dvb_device_t *, uint32_t freq, char pol,
/* DVB-T */
int dvb_set_dvbt (dvb_device_t *, uint32_t freq, const char *mod,
const char *fec_hp, const char *fec_lp, uint32_t bandwidth,
- int transmission, const char *guard, int hierarchy);
+ int transmission, uint32_t guard, int hierarchy);
/* ATSC */
int dvb_set_atsc (dvb_device_t *, uint32_t freq, const char *mod);
diff --git a/modules/access/dtv/linux.c b/modules/access/dtv/linux.c
index 090b960..aa2a297 100644
--- a/modules/access/dtv/linux.c
+++ b/modules/access/dtv/linux.c
@@ -712,19 +712,19 @@ static int dvb_parse_transmit_mode (int i)
TRANSMISSION_MODE_AUTO);
}
-static int dvb_parse_guard (const char *str)
-{
- static const dvb_str_map_t tab[] = {
- { "", GUARD_INTERVAL_AUTO },
- /*{ "1/128", GUARD_INTERVAL_1_128 },*/
- { "1/16", GUARD_INTERVAL_1_16 },
- { "1/32", GUARD_INTERVAL_1_32 },
- { "1/4", GUARD_INTERVAL_1_4 },
- { "1/8", GUARD_INTERVAL_1_8 },
- /*{ "19/128", GUARD_INTERVAL_19_128 },*/
- /*{ "9/256", GUARD_INTERVAL_9_256 },*/
+static int dvb_parse_guard (uint32_t guard)
+{
+ static const dvb_int_map_t tab[] = {
+ /*{ VLC_GUARD(1,128), GUARD_INTERVAL_1_128 },*/
+ { VLC_GUARD(1,16), GUARD_INTERVAL_1_16 },
+ { VLC_GUARD(1,32), GUARD_INTERVAL_1_32 },
+ { VLC_GUARD(1,4), GUARD_INTERVAL_1_4 },
+ { VLC_GUARD(1,8), GUARD_INTERVAL_1_8 },
+ /*{ VLC_GUARD(19,128), GUARD_INTERVAL_19_128 },*/
+ /*{ VLC_GUARD(9,256), GUARD_INTERVAL_9_256 },*/
+ { VLC_GUARD_AUTO, GUARD_INTERVAL_AUTO },
};
- return dvb_parse_str (str, tab, sizeof (tab) / sizeof (*tab),
+ return dvb_parse_int (guard, tab, sizeof (tab) / sizeof (*tab),
GUARD_INTERVAL_AUTO);
}
@@ -743,22 +743,22 @@ static int dvb_parse_hierarchy (int i)
int dvb_set_dvbt (dvb_device_t *d, uint32_t freq, const char *modstr,
const char *fechstr, const char *feclstr, uint32_t bandwidth,
- int transmit_val, const char *guardstr, int hierarchy_val)
+ int transmit_mode, uint32_t guard, int hierarchy)
{
uint32_t mod = dvb_parse_modulation (modstr, QAM_AUTO);
uint32_t fec_hp = dvb_parse_fec (fechstr);
uint32_t fec_lp = dvb_parse_fec (feclstr);
bandwidth *= 1000000;
- uint32_t transmit_mode = dvb_parse_transmit_mode (transmit_val);
- uint32_t guard_it = dvb_parse_guard (guardstr);
- uint32_t hierarchy = dvb_parse_hierarchy (hierarchy_val);
+ transmit_mode = dvb_parse_transmit_mode (transmit_mode);
+ guard = dvb_parse_guard (guard);
+ hierarchy = dvb_parse_hierarchy (hierarchy);
return dvb_set_props (d, 10, DTV_CLEAR, 0, DTV_DELIVERY_SYSTEM, SYS_DVBT,
DTV_FREQUENCY, freq * 1000, DTV_MODULATION, mod,
DTV_CODE_RATE_HP, fec_hp, DTV_CODE_RATE_LP, fec_lp,
DTV_BANDWIDTH_HZ, bandwidth,
DTV_TRANSMISSION_MODE, transmit_mode,
- DTV_GUARD_INTERVAL, guard_it,
+ DTV_GUARD_INTERVAL, guard,
DTV_HIERARCHY, hierarchy);
}
More information about the vlc-commits
mailing list