Commit fba7471e authored by Göran Weinholt's avatar Göran Weinholt
Browse files

Merge branch 'SI_fixes' into 'master'

SI fixes

See merge request !1
parents a775d9a2 3188fccc
Pipeline #356743560 passed with stage
in 36 seconds
......@@ -1064,10 +1064,15 @@ static int vbi_dvb_open(struct vbi *vbi, const char *vbi_name, const char *progn
printf("Using command line specified teletext PID 0x%x\n", vbi->txtpid);
goto txtpidfound;
}
/* parse PAT to enumerate services and to find the PMT PIDs */
r = dvb_get_table(vbi->fd, 0, 0, tbl, sizeof(tbl));
if (r == -1)
goto outerr;
if (r < 12) {
error("PAT too short\n");
goto outerr;
}
if (!(tbl[5] & 1)) {
error("PAT not active (current_next_indicator == 0)");
goto outerr;
......@@ -1076,11 +1081,7 @@ static int vbi_dvb_open(struct vbi *vbi, const char *vbi_name, const char *progn
error("PAT has multiple sections");
goto outerr;
}
if (r < 13) {
error("PAT too short\n");
goto outerr;
}
r -= 13;
r -= 12; // header+CRC
for (i = 0; i < (unsigned)r; i += 4) {
if (progcnt >= sizeof(progtbl)/sizeof(progtbl[0])) {
error("Program table overflow");
......@@ -1092,10 +1093,15 @@ static int vbi_dvb_open(struct vbi *vbi, const char *vbi_name, const char *progn
progtbl[progcnt].pmtpid = ((tbl[10 + i] << 8) | tbl[11 + i]) & 0x1fff;
progcnt++;
}
/* find the SDT to get the station names */
r = dvb_get_table(vbi->fd, 0x11, 0x42, tbl, sizeof(tbl));
if (r == -1)
goto outerr;
if (r < 15) {
error("SDT too short\n");
goto outerr;
}
if (!(tbl[5] & 1)) {
error("SDT not active (current_next_indicator == 0)");
goto outerr;
......@@ -1104,10 +1110,7 @@ static int vbi_dvb_open(struct vbi *vbi, const char *vbi_name, const char *progn
error("SDT has multiple sections");
goto outerr;
}
if (r < 12) {
error("SDT too short\n");
goto outerr;
}
r -= 4; // CRC
i = 11;
while (i < (unsigned)r - 1) {
k = (tbl[i] << 8) | tbl[i+1]; /* service ID */
......@@ -1137,6 +1140,7 @@ static int vbi_dvb_open(struct vbi *vbi, const char *vbi_name, const char *progn
j += 2 + tbl[j + 1];
}
}
/* parse PMT's to find Teletext Services */
for (l = 0; l < progcnt; l++) {
progtbl[l].txtpid = 0x1fff;
......@@ -1148,6 +1152,7 @@ static int vbi_dvb_open(struct vbi *vbi, const char *vbi_name, const char *progn
case 0x19: // H.264/AVC HD digital television service
case 0x1c: // H.264/AVC frame compatible plano-stereoscopic HD digital television service
case 0x1f: // HEVC digital television service
case 0x20: // HEVC digital television service with HDR and/or a frame rate of 100 Hz, 120 000/1 001 Hz, or 120 Hz
break;
default:
continue; /* service is not digital TV */
......@@ -1158,6 +1163,10 @@ static int vbi_dvb_open(struct vbi *vbi, const char *vbi_name, const char *progn
r = dvb_get_table(vbi->fd, progtbl[l].pmtpid, 0x02, tbl, sizeof(tbl));
if (r == -1)
goto outerr;
if (r < 16) {
error("PMT pid 0x%x too short\n", progtbl[l].pmtpid);
goto outerr;
}
if (!(tbl[5] & 1)) {
error("PMT pid 0x%x not active (current_next_indicator == 0)", progtbl[l].pmtpid);
goto outerr;
......@@ -1166,12 +1175,9 @@ static int vbi_dvb_open(struct vbi *vbi, const char *vbi_name, const char *progn
error("PMT pid 0x%x has multiple sections", progtbl[l].pmtpid);
goto outerr;
}
if (r < 13) {
error("PMT pid 0x%x too short\n", progtbl[l].pmtpid);
goto outerr;
}
r -= 4; // CRC
i = 12 + (((tbl[10] << 8) | tbl[11]) & 0x0fff); /* skip program info section */
while (i <= (unsigned)r-6) {
while (i < (unsigned)r - 1) {
j = i + 5;
i = j + (((tbl[i + 3] << 8) | tbl[i + 4]) & 0x0fff);
if (tbl[j - 5] != 0x06) /* teletext streams have type 0x06 */
......
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