diff mbox series

[FFmpeg-devel] avformat/mpegts: add a ts_id exported option

Message ID 20240219024837.26580-1-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel] avformat/mpegts: add a ts_id exported option | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 fail Make fate failed
andriy/make_x86 success Make finished
andriy/make_fate_x86 fail Make fate failed

Commit Message

James Almer Feb. 19, 2024, 2:48 a.m. UTC
Replaces AVFormatContext.ts_id

Signed-off-by: James Almer <jamrial@gmail.com>
---
To be pushed as part of the bump set.

 libavformat/avformat.h | 6 ------
 libavformat/mpegts.c   | 9 +++++++--
 2 files changed, 7 insertions(+), 8 deletions(-)

Comments

Andreas Rheinhardt Feb. 19, 2024, 11:20 a.m. UTC | #1
James Almer:
> Replaces AVFormatContext.ts_id
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> To be pushed as part of the bump set.
> 
>  libavformat/avformat.h | 6 ------
>  libavformat/mpegts.c   | 9 +++++++--
>  2 files changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index 50bbd1949b..affc5fde07 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -1538,12 +1538,6 @@ typedef struct AVFormatContext {
>  #define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 ///< Shift timestamps so they are non negative
>  #define AVFMT_AVOID_NEG_TS_MAKE_ZERO         2 ///< Shift timestamps so that they start at 0
>  
> -    /**
> -     * Transport stream id.
> -     * This will be moved into demuxer private options. Thus no API/ABI compatibility
> -     */
> -    int ts_id;
> -
>      /**
>       * Audio preload in microseconds.
>       * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index 1cf390e98e..36fded8db8 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -167,6 +167,8 @@ struct MpegTSContext {
>      int merge_pmt_versions;
>      int max_packet_size;
>  
> +    int id;
> +
>      /******************************************/
>      /* private mpegts data */
>      /* scan context */
> @@ -184,7 +186,10 @@ struct MpegTSContext {
>  };
>  
>  #define MPEGTS_OPTIONS \
> -    { "resync_size",   "set size limit for looking up a new synchronization", offsetof(MpegTSContext, resync_size), AV_OPT_TYPE_INT,  { .i64 =  MAX_RESYNC_SIZE}, 0, INT_MAX,  AV_OPT_FLAG_DECODING_PARAM }
> +    { "resync_size",   "set size limit for looking up a new synchronization", \
> +        offsetof(MpegTSContext, resync_size), AV_OPT_TYPE_INT, { .i64 =  MAX_RESYNC_SIZE}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, \
> +    { "ts_id", "transport stream id", \
> +        offsetof(MpegTSContext, id), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, AV_OPT_FLAG_EXPORT|AV_OPT_FLAG_READONLY }
>  
>  static const AVOption options[] = {
>      MPEGTS_OPTIONS,
> @@ -2554,7 +2559,7 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
>  
>      if (skip_identical(h, tssf))
>          return;
> -    ts->stream->ts_id = h->id;
> +    ts->id = h->id;
>  
>      for (;;) {
>          sid = get16(&p, p_end);

Patchwork shows that several ts fate tests fail with this patch,
presumably because ffprobe prints exported options (see
print_private_data()).
Anyway, I don't see why you not add the option now and remove the public
field with the bump.

- Andreas
James Almer Feb. 19, 2024, 2:10 p.m. UTC | #2
On 2/19/2024 8:20 AM, Andreas Rheinhardt wrote:
> James Almer:
>> Replaces AVFormatContext.ts_id
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>> To be pushed as part of the bump set.
>>
>>   libavformat/avformat.h | 6 ------
>>   libavformat/mpegts.c   | 9 +++++++--
>>   2 files changed, 7 insertions(+), 8 deletions(-)
>>
>> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
>> index 50bbd1949b..affc5fde07 100644
>> --- a/libavformat/avformat.h
>> +++ b/libavformat/avformat.h
>> @@ -1538,12 +1538,6 @@ typedef struct AVFormatContext {
>>   #define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 ///< Shift timestamps so they are non negative
>>   #define AVFMT_AVOID_NEG_TS_MAKE_ZERO         2 ///< Shift timestamps so that they start at 0
>>   
>> -    /**
>> -     * Transport stream id.
>> -     * This will be moved into demuxer private options. Thus no API/ABI compatibility
>> -     */
>> -    int ts_id;
>> -
>>       /**
>>        * Audio preload in microseconds.
>>        * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
>> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
>> index 1cf390e98e..36fded8db8 100644
>> --- a/libavformat/mpegts.c
>> +++ b/libavformat/mpegts.c
>> @@ -167,6 +167,8 @@ struct MpegTSContext {
>>       int merge_pmt_versions;
>>       int max_packet_size;
>>   
>> +    int id;
>> +
>>       /******************************************/
>>       /* private mpegts data */
>>       /* scan context */
>> @@ -184,7 +186,10 @@ struct MpegTSContext {
>>   };
>>   
>>   #define MPEGTS_OPTIONS \
>> -    { "resync_size",   "set size limit for looking up a new synchronization", offsetof(MpegTSContext, resync_size), AV_OPT_TYPE_INT,  { .i64 =  MAX_RESYNC_SIZE}, 0, INT_MAX,  AV_OPT_FLAG_DECODING_PARAM }
>> +    { "resync_size",   "set size limit for looking up a new synchronization", \
>> +        offsetof(MpegTSContext, resync_size), AV_OPT_TYPE_INT, { .i64 =  MAX_RESYNC_SIZE}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, \
>> +    { "ts_id", "transport stream id", \
>> +        offsetof(MpegTSContext, id), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, AV_OPT_FLAG_EXPORT|AV_OPT_FLAG_READONLY }
>>   
>>   static const AVOption options[] = {
>>       MPEGTS_OPTIONS,
>> @@ -2554,7 +2559,7 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
>>   
>>       if (skip_identical(h, tssf))
>>           return;
>> -    ts->stream->ts_id = h->id;
>> +    ts->id = h->id;
>>   
>>       for (;;) {
>>           sid = get16(&p, p_end);
> 
> Patchwork shows that several ts fate tests fail with this patch,
> presumably because ffprobe prints exported options (see
> print_private_data()).

Amended locally with the updated refs.

> Anyway, I don't see why you not add the option now and remove the public
> field with the bump.

Ok, will do that and apply now.

Thanks.
diff mbox series

Patch

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 50bbd1949b..affc5fde07 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1538,12 +1538,6 @@  typedef struct AVFormatContext {
 #define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 ///< Shift timestamps so they are non negative
 #define AVFMT_AVOID_NEG_TS_MAKE_ZERO         2 ///< Shift timestamps so that they start at 0
 
-    /**
-     * Transport stream id.
-     * This will be moved into demuxer private options. Thus no API/ABI compatibility
-     */
-    int ts_id;
-
     /**
      * Audio preload in microseconds.
      * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 1cf390e98e..36fded8db8 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -167,6 +167,8 @@  struct MpegTSContext {
     int merge_pmt_versions;
     int max_packet_size;
 
+    int id;
+
     /******************************************/
     /* private mpegts data */
     /* scan context */
@@ -184,7 +186,10 @@  struct MpegTSContext {
 };
 
 #define MPEGTS_OPTIONS \
-    { "resync_size",   "set size limit for looking up a new synchronization", offsetof(MpegTSContext, resync_size), AV_OPT_TYPE_INT,  { .i64 =  MAX_RESYNC_SIZE}, 0, INT_MAX,  AV_OPT_FLAG_DECODING_PARAM }
+    { "resync_size",   "set size limit for looking up a new synchronization", \
+        offsetof(MpegTSContext, resync_size), AV_OPT_TYPE_INT, { .i64 =  MAX_RESYNC_SIZE}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, \
+    { "ts_id", "transport stream id", \
+        offsetof(MpegTSContext, id), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, AV_OPT_FLAG_EXPORT|AV_OPT_FLAG_READONLY }
 
 static const AVOption options[] = {
     MPEGTS_OPTIONS,
@@ -2554,7 +2559,7 @@  static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
 
     if (skip_identical(h, tssf))
         return;
-    ts->stream->ts_id = h->id;
+    ts->id = h->id;
 
     for (;;) {
         sid = get16(&p, p_end);