Commit 223d4246 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

DTV: represent guard intervals as ints rather than strings internally

parent 40913091
...@@ -583,6 +583,31 @@ static char *var_InheritModulation (vlc_object_t *obj) ...@@ -583,6 +583,31 @@ static char *var_InheritModulation (vlc_object_t *obj)
return strdup (str); 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 ***/ /*** ATSC ***/
static int atsc_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq) 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) ...@@ -700,13 +725,12 @@ static int dvbt_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq)
char *mod = var_InheritModulation (obj); char *mod = var_InheritModulation (obj);
char *fec_hp = var_InheritString (obj, "dvb-code-rate-hp"); char *fec_hp = var_InheritString (obj, "dvb-code-rate-hp");
char *fec_lp = var_InheritString (obj, "dvb-code-rate-lp"); 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"); uint32_t bw = var_InheritInteger (obj, "dvb-bandwidth");
int tx = var_InheritInteger (obj, "dvb-transmission"); int tx = var_InheritInteger (obj, "dvb-transmission");
int h = var_InheritInteger (obj, "dvb-hierarchy"); int h = var_InheritInteger (obj, "dvb-hierarchy");
int ret = dvb_set_dvbt (dev, freq, mod, fec_hp, fec_lp, bw, tx, guard, h); int ret = dvb_set_dvbt (dev, freq, mod, fec_hp, fec_lp, bw, tx, guard, h);
free (guard);
free (fec_lp); free (fec_lp);
free (fec_hp); free (fec_hp);
free (mod); free (mod);
......
...@@ -40,6 +40,9 @@ float dvb_get_snr (dvb_device_t *); ...@@ -40,6 +40,9 @@ float dvb_get_snr (dvb_device_t *);
int dvb_set_inversion (dvb_device_t *, int); int dvb_set_inversion (dvb_device_t *, int);
int dvb_tune (dvb_device_t *); int dvb_tune (dvb_device_t *);
#define VLC_GUARD(a,b) (((a) << 16u) | (b))
#define VLC_GUARD_AUTO 0xFFFFFFFF
/* DVB-C */ /* DVB-C */
int dvb_set_dvbc (dvb_device_t *, uint32_t freq, const char *mod, int dvb_set_dvbc (dvb_device_t *, uint32_t freq, const char *mod,
uint32_t srate, const char *fec); uint32_t srate, const char *fec);
...@@ -55,7 +58,7 @@ int dvb_set_sec (dvb_device_t *, uint32_t freq, char pol, ...@@ -55,7 +58,7 @@ int dvb_set_sec (dvb_device_t *, uint32_t freq, char pol,
/* DVB-T */ /* DVB-T */
int dvb_set_dvbt (dvb_device_t *, uint32_t freq, const char *mod, int dvb_set_dvbt (dvb_device_t *, uint32_t freq, const char *mod,
const char *fec_hp, const char *fec_lp, uint32_t bandwidth, 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 */ /* ATSC */
int dvb_set_atsc (dvb_device_t *, uint32_t freq, const char *mod); int dvb_set_atsc (dvb_device_t *, uint32_t freq, const char *mod);
......
...@@ -712,19 +712,19 @@ static int dvb_parse_transmit_mode (int i) ...@@ -712,19 +712,19 @@ static int dvb_parse_transmit_mode (int i)
TRANSMISSION_MODE_AUTO); TRANSMISSION_MODE_AUTO);
} }
static int dvb_parse_guard (const char *str) static int dvb_parse_guard (uint32_t guard)
{ {
static const dvb_str_map_t tab[] = { static const dvb_int_map_t tab[] = {
{ "", GUARD_INTERVAL_AUTO }, /*{ VLC_GUARD(1,128), GUARD_INTERVAL_1_128 },*/
/*{ "1/128", GUARD_INTERVAL_1_128 },*/ { VLC_GUARD(1,16), GUARD_INTERVAL_1_16 },
{ "1/16", GUARD_INTERVAL_1_16 }, { VLC_GUARD(1,32), GUARD_INTERVAL_1_32 },
{ "1/32", GUARD_INTERVAL_1_32 }, { VLC_GUARD(1,4), GUARD_INTERVAL_1_4 },
{ "1/4", GUARD_INTERVAL_1_4 }, { VLC_GUARD(1,8), GUARD_INTERVAL_1_8 },
{ "1/8", GUARD_INTERVAL_1_8 }, /*{ VLC_GUARD(19,128), GUARD_INTERVAL_19_128 },*/
/*{ "19/128", GUARD_INTERVAL_19_128 },*/ /*{ VLC_GUARD(9,256), GUARD_INTERVAL_9_256 },*/
/*{ "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); GUARD_INTERVAL_AUTO);
} }
...@@ -743,22 +743,22 @@ static int dvb_parse_hierarchy (int i) ...@@ -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, int dvb_set_dvbt (dvb_device_t *d, uint32_t freq, const char *modstr,
const char *fechstr, const char *feclstr, uint32_t bandwidth, 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 mod = dvb_parse_modulation (modstr, QAM_AUTO);
uint32_t fec_hp = dvb_parse_fec (fechstr); uint32_t fec_hp = dvb_parse_fec (fechstr);
uint32_t fec_lp = dvb_parse_fec (feclstr); uint32_t fec_lp = dvb_parse_fec (feclstr);
bandwidth *= 1000000; bandwidth *= 1000000;
uint32_t transmit_mode = dvb_parse_transmit_mode (transmit_val); transmit_mode = dvb_parse_transmit_mode (transmit_mode);
uint32_t guard_it = dvb_parse_guard (guardstr); guard = dvb_parse_guard (guard);
uint32_t hierarchy = dvb_parse_hierarchy (hierarchy_val); hierarchy = dvb_parse_hierarchy (hierarchy);
return dvb_set_props (d, 10, DTV_CLEAR, 0, DTV_DELIVERY_SYSTEM, SYS_DVBT, return dvb_set_props (d, 10, DTV_CLEAR, 0, DTV_DELIVERY_SYSTEM, SYS_DVBT,
DTV_FREQUENCY, freq * 1000, DTV_MODULATION, mod, DTV_FREQUENCY, freq * 1000, DTV_MODULATION, mod,
DTV_CODE_RATE_HP, fec_hp, DTV_CODE_RATE_LP, fec_lp, DTV_CODE_RATE_HP, fec_hp, DTV_CODE_RATE_LP, fec_lp,
DTV_BANDWIDTH_HZ, bandwidth, DTV_BANDWIDTH_HZ, bandwidth,
DTV_TRANSMISSION_MODE, transmit_mode, DTV_TRANSMISSION_MODE, transmit_mode,
DTV_GUARD_INTERVAL, guard_it, DTV_GUARD_INTERVAL, guard,
DTV_HIERARCHY, hierarchy); DTV_HIERARCHY, hierarchy);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment