diff mbox series

[FFmpeg-devel,v2,6/6] avformat: remove some mpegts details from AVStream

Message ID 20201229191933.17281-1-cus@passwd.hu
State Accepted
Commit 2e2891383e596314a9888ba9b99d6987c82d7c9b
Headers show
Series None | expand

Commit Message

Marton Balint Dec. 29, 2020, 7:19 p.m. UTC
These fields were added to support -merge_pmt_versions, but the mpegts demuxer
is also keeping track its programs internally, so that should be a better place
to handle it.

Also it is not a very good idea to keep fields like program_num or
pmt_stream_idx in an AVStream, because a single stream can be part of multiple
programs, multiple PMTs, so the stream attributes can refer to any program the
stream is part of.

Since they are not part of public API, lets simply remove them, or rather
replace them with placeholders for ABI compatibility with libavdevice.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavformat/avformat.h | 12 ++++++------
 libavformat/mpegts.c   |  9 ---------
 2 files changed, 6 insertions(+), 15 deletions(-)

Comments

James Almer Dec. 29, 2020, 8:35 p.m. UTC | #1
On 12/29/2020 4:19 PM, Marton Balint wrote:
> These fields were added to support -merge_pmt_versions, but the mpegts demuxer
> is also keeping track its programs internally, so that should be a better place
> to handle it.
> 
> Also it is not a very good idea to keep fields like program_num or
> pmt_stream_idx in an AVStream, because a single stream can be part of multiple
> programs, multiple PMTs, so the stream attributes can refer to any program the
> stream is part of.
> 
> Since they are not part of public API, lets simply remove them, or rather
> replace them with placeholders for ABI compatibility with libavdevice.
> 
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>   libavformat/avformat.h | 12 ++++++------
>   libavformat/mpegts.c   |  9 ---------
>   2 files changed, 6 insertions(+), 15 deletions(-)
> 
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index 4865c56cc3..523cf34d55 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -1096,12 +1096,12 @@ typedef struct AVStream {
>        */
>       int stream_identifier;
>   
> -    /**
> -     * Details of the MPEG-TS program which created this stream.
> -     */
> -    int program_num;
> -    int pmt_version;
> -    int pmt_stream_idx;
> +#if LIBAVFORMAT_VERSION_MAJOR < 59
> +    // kept for ABI compatibility only, do not access in any way
> +    int unused8;
> +    int unused9;
> +    int unused10;
> +#endif
>   
>       /**
>        * An opaque field for libavformat internal usage.
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index 9a3fd56ece..b9a3152e81 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -2406,9 +2406,6 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
>                   if (!pes->st)
>                       goto out;
>                   pes->st->id = pes->pid;
> -                pes->st->program_num = h->id;
> -                pes->st->pmt_version = h->version;
> -                pes->st->pmt_stream_idx = i;
>               }
>               st = pes->st;
>           } else if (is_pes_stream(stream_type, prog_reg_desc)) {
> @@ -2428,9 +2425,6 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
>                   if (!st)
>                       goto out;
>                   st->id = pes->pid;
> -                st->program_num = h->id;
> -                st->pmt_version = h->version;
> -                st->pmt_stream_idx = i;
>               }
>           } else {
>               int idx = ff_find_stream_index(ts->stream, pid);
> @@ -2445,9 +2439,6 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
>                   if (!st)
>                       goto out;
>                   st->id = pid;
> -                st->program_num = h->id;
> -                st->pmt_version = h->version;
> -                st->pmt_stream_idx = i;
>                   st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
>                   if (stream_type == 0x86 && prog_reg_desc == AV_RL32("CUEI")) {
>                       mpegts_find_stream_type(st, stream_type, SCTE_types);

LGTM.
diff mbox series

Patch

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 4865c56cc3..523cf34d55 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1096,12 +1096,12 @@  typedef struct AVStream {
      */
     int stream_identifier;
 
-    /**
-     * Details of the MPEG-TS program which created this stream.
-     */
-    int program_num;
-    int pmt_version;
-    int pmt_stream_idx;
+#if LIBAVFORMAT_VERSION_MAJOR < 59
+    // kept for ABI compatibility only, do not access in any way
+    int unused8;
+    int unused9;
+    int unused10;
+#endif
 
     /**
      * An opaque field for libavformat internal usage.
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 9a3fd56ece..b9a3152e81 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2406,9 +2406,6 @@  static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
                 if (!pes->st)
                     goto out;
                 pes->st->id = pes->pid;
-                pes->st->program_num = h->id;
-                pes->st->pmt_version = h->version;
-                pes->st->pmt_stream_idx = i;
             }
             st = pes->st;
         } else if (is_pes_stream(stream_type, prog_reg_desc)) {
@@ -2428,9 +2425,6 @@  static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
                 if (!st)
                     goto out;
                 st->id = pes->pid;
-                st->program_num = h->id;
-                st->pmt_version = h->version;
-                st->pmt_stream_idx = i;
             }
         } else {
             int idx = ff_find_stream_index(ts->stream, pid);
@@ -2445,9 +2439,6 @@  static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
                 if (!st)
                     goto out;
                 st->id = pid;
-                st->program_num = h->id;
-                st->pmt_version = h->version;
-                st->pmt_stream_idx = i;
                 st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
                 if (stream_type == 0x86 && prog_reg_desc == AV_RL32("CUEI")) {
                     mpegts_find_stream_type(st, stream_type, SCTE_types);