summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/muxers.texi7
-rw-r--r--libavformat/mpegts.h2
-rw-r--r--libavformat/mpegtsenc.c17
-rw-r--r--libavformat/version.h2
4 files changed, 19 insertions, 9 deletions
diff --git a/doc/muxers.texi b/doc/muxers.texi
index 09ded7d48a..5d7ff1ab3b 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1582,11 +1582,12 @@ Advanced Codec Digital HDTV service.
@end table
@item mpegts_pmt_start_pid @var{integer}
-Set the first PID for PMT. Default is @code{0x1000}. Max is @code{0x1f00}.
+Set the first PID for PMTs. Default is @code{0x1000}, minimum is @code{0x0020},
+maximum is @code{0x1ffa}.
@item mpegts_start_pid @var{integer}
-Set the first PID for data packets. Default is @code{0x0100}. Max is
-@code{0x0f00}.
+Set the first PID for elementary streams. Default is @code{0x0100}, minimum is
+@code{0x0020}, maximum is @code{0x1ffa}.
@item mpegts_m2ts_mode @var{boolean}
Enable m2ts mode if set to @code{1}. Default value is @code{-1} which
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index ecc3d3374c..86a3eba4e2 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -58,6 +58,8 @@
#define SIT_PID 0x001F /* Selection Information Table */
/* PID from 0x0020 to 0x1FFA may be assigned as needed to PMT, elementary
* streams and other data tables */
+#define FIRST_OTHER_PID 0x0020
+#define LAST_OTHER_PID 0x1FFA
/* PID 0x1FFB is used by DigiCipher 2/ATSC MGT metadata */
/* PID from 0x1FFC to 0x1FFE may be assigned as needed to PMT, elementary
* streams and other data tables */
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 9f8f1715c9..b578539240 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -914,17 +914,24 @@ static int mpegts_init(AVFormatContext *s)
* this range are assigned a calculated pid. */
if (st->id < 16) {
ts_st->pid = ts->start_pid + i;
- } else if (st->id < 0x1FFF) {
- ts_st->pid = st->id;
} else {
+ ts_st->pid = st->id;
+ }
+ if (ts_st->pid >= 0x1FFF) {
av_log(s, AV_LOG_ERROR,
"Invalid stream id %d, must be less than 8191\n", st->id);
ret = AVERROR(EINVAL);
goto fail;
}
for (j = 0; j < ts->nb_services; j++) {
+ if (ts->services[j]->pmt.pid > LAST_OTHER_PID) {
+ av_log(s, AV_LOG_ERROR,
+ "Invalid PMT PID %d, must be less than %d\n", ts->services[j]->pmt.pid, LAST_OTHER_PID + 1);
+ ret = AVERROR(EINVAL);
+ goto fail;
+ }
if (ts_st->pid == ts->services[j]->pmt.pid) {
- av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", ts_st->pid);
+ av_log(s, AV_LOG_ERROR, "PID %d cannot be both elementary and PMT PID\n", ts_st->pid);
ret = AVERROR(EINVAL);
goto fail;
}
@@ -1888,10 +1895,10 @@ static const AVOption options[] = {
AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
{ "mpegts_pmt_start_pid", "Set the first pid of the PMT.",
offsetof(MpegTSWrite, pmt_start_pid), AV_OPT_TYPE_INT,
- { .i64 = 0x1000 }, 0x0010, 0x1f00, AV_OPT_FLAG_ENCODING_PARAM },
+ { .i64 = 0x1000 }, FIRST_OTHER_PID, LAST_OTHER_PID, AV_OPT_FLAG_ENCODING_PARAM },
{ "mpegts_start_pid", "Set the first pid.",
offsetof(MpegTSWrite, start_pid), AV_OPT_TYPE_INT,
- { .i64 = 0x0100 }, 0x0010, 0x0f00, AV_OPT_FLAG_ENCODING_PARAM },
+ { .i64 = 0x0100 }, FIRST_OTHER_PID, LAST_OTHER_PID, AV_OPT_FLAG_ENCODING_PARAM },
{ "mpegts_m2ts_mode", "Enable m2ts mode.",
offsetof(MpegTSWrite, m2ts_mode), AV_OPT_TYPE_BOOL,
{ .i64 = -1 }, -1, 1, AV_OPT_FLAG_ENCODING_PARAM },
diff --git a/libavformat/version.h b/libavformat/version.h
index bac54aed9d..213b66b45f 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -33,7 +33,7 @@
// Also please add any ticket numbers that you believe might be affected here
#define LIBAVFORMAT_VERSION_MAJOR 58
#define LIBAVFORMAT_VERSION_MINOR 35
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \