diff mbox series

[FFmpeg-devel] avformat/wavdec: allow to change max size of single demuxed packet

Message ID 20200828001004.26729-1-onemda@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel] avformat/wavdec: allow to change max size of single demuxed packet
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Paul B Mahol Aug. 28, 2020, 12:10 a.m. UTC
Can make demuxing much faster, expecially for files with
huge number of channels.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavformat/wavdec.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

Comments

Andreas Rheinhardt Aug. 28, 2020, 12:46 a.m. UTC | #1
Paul B Mahol:
> Can make demuxing much faster, expecially for files with
> huge number of channels.
> 
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavformat/wavdec.c | 21 ++++++++++++++++++---
>  1 file changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
> index e1b2115434..5b3c481421 100644
> --- a/libavformat/wavdec.c
> +++ b/libavformat/wavdec.c
> @@ -56,6 +56,7 @@ typedef struct WAVDemuxContext {
>      int smv_eof;
>      int audio_eof;
>      int ignore_length;
> +    int max_size;
>      int spdif;
>      int smv_cur_pt;
>      int smv_given_first;
> @@ -628,8 +629,6 @@ static int64_t find_guid(AVIOContext *pb, const uint8_t guid1[16])
>      return AVERROR_EOF;
>  }
>  
> -#define MAX_SIZE 4096
> -
>  static int wav_read_packet(AVFormatContext *s, AVPacket *pkt)
>  {
>      int ret, size;
> @@ -706,7 +705,7 @@ smv_out:
>          wav->data_end = avio_tell(s->pb) + left;
>      }
>  
> -    size = MAX_SIZE;
> +    size = wav->max_size;
>      if (st->codecpar->block_align > 1) {
>          if (size < st->codecpar->block_align)
>              size = st->codecpar->block_align;
> @@ -759,6 +758,7 @@ static int wav_read_seek(AVFormatContext *s,
>  #define DEC AV_OPT_FLAG_DECODING_PARAM
>  static const AVOption demux_options[] = {
>      { "ignore_length", "Ignore length", OFFSET(ignore_length), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
> +    { "max_size",      "max size of single packet", OFFSET(max_size), AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
>      { NULL },
>  };
>  
> @@ -906,6 +906,20 @@ static int w64_read_header(AVFormatContext *s)
>      return 0;
>  }
>  
> +#define OFFSET(x) offsetof(WAVDemuxContext, x)
> +#define DEC AV_OPT_FLAG_DECODING_PARAM
> +static const AVOption w64_demux_options[] = {
> +    { "max_size", "max size of single packet", OFFSET(max_size), AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
> +    { NULL },

The ',' is unnecessary: Nothing will ever be added after the sentinel.

> +};

You can use &demux_options[1] instead of w64_demux_options (but add a
comment for this).

> +
> +static const AVClass w64_demuxer_class = {
> +    .class_name = "W64 demuxer",
> +    .item_name  = av_default_item_name,
> +    .option     = w64_demux_options,
> +    .version    = LIBAVUTIL_VERSION_INT,
> +};
> +
>  AVInputFormat ff_w64_demuxer = {
>      .name           = "w64",
>      .long_name      = NULL_IF_CONFIG_SMALL("Sony Wave64"),
> @@ -916,5 +930,6 @@ AVInputFormat ff_w64_demuxer = {
>      .read_seek      = wav_read_seek,
>      .flags          = AVFMT_GENERIC_INDEX,
>      .codec_tag      = (const AVCodecTag * const []) { ff_codec_wav_tags, 0 },
> +    .priv_class     = &w64_demuxer_class,
>  };
>  #endif /* CONFIG_W64_DEMUXER */
>
Paul B Mahol Aug. 28, 2020, 8:38 a.m. UTC | #2
On 8/28/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
> Paul B Mahol:
>> Can make demuxing much faster, expecially for files with
>> huge number of channels.
>>
>> Signed-off-by: Paul B Mahol <onemda@gmail.com>
>> ---
>>  libavformat/wavdec.c | 21 ++++++++++++++++++---
>>  1 file changed, 18 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
>> index e1b2115434..5b3c481421 100644
>> --- a/libavformat/wavdec.c
>> +++ b/libavformat/wavdec.c
>> @@ -56,6 +56,7 @@ typedef struct WAVDemuxContext {
>>      int smv_eof;
>>      int audio_eof;
>>      int ignore_length;
>> +    int max_size;
>>      int spdif;
>>      int smv_cur_pt;
>>      int smv_given_first;
>> @@ -628,8 +629,6 @@ static int64_t find_guid(AVIOContext *pb, const
>> uint8_t guid1[16])
>>      return AVERROR_EOF;
>>  }
>>
>> -#define MAX_SIZE 4096
>> -
>>  static int wav_read_packet(AVFormatContext *s, AVPacket *pkt)
>>  {
>>      int ret, size;
>> @@ -706,7 +705,7 @@ smv_out:
>>          wav->data_end = avio_tell(s->pb) + left;
>>      }
>>
>> -    size = MAX_SIZE;
>> +    size = wav->max_size;
>>      if (st->codecpar->block_align > 1) {
>>          if (size < st->codecpar->block_align)
>>              size = st->codecpar->block_align;
>> @@ -759,6 +758,7 @@ static int wav_read_seek(AVFormatContext *s,
>>  #define DEC AV_OPT_FLAG_DECODING_PARAM
>>  static const AVOption demux_options[] = {
>>      { "ignore_length", "Ignore length", OFFSET(ignore_length),
>> AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
>> +    { "max_size",      "max size of single packet", OFFSET(max_size),
>> AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
>>      { NULL },
>>  };
>>
>> @@ -906,6 +906,20 @@ static int w64_read_header(AVFormatContext *s)
>>      return 0;
>>  }
>>
>> +#define OFFSET(x) offsetof(WAVDemuxContext, x)
>> +#define DEC AV_OPT_FLAG_DECODING_PARAM
>> +static const AVOption w64_demux_options[] = {
>> +    { "max_size", "max size of single packet", OFFSET(max_size),
>> AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
>> +    { NULL },
>
> The ',' is unnecessary: Nothing will ever be added after the sentinel.
>
>> +};
>
> You can use &demux_options[1] instead of w64_demux_options (but add a
> comment for this).

How the comment should look like?

>
>> +
>> +static const AVClass w64_demuxer_class = {
>> +    .class_name = "W64 demuxer",
>> +    .item_name  = av_default_item_name,
>> +    .option     = w64_demux_options,
>> +    .version    = LIBAVUTIL_VERSION_INT,
>> +};
>> +
>>  AVInputFormat ff_w64_demuxer = {
>>      .name           = "w64",
>>      .long_name      = NULL_IF_CONFIG_SMALL("Sony Wave64"),
>> @@ -916,5 +930,6 @@ AVInputFormat ff_w64_demuxer = {
>>      .read_seek      = wav_read_seek,
>>      .flags          = AVFMT_GENERIC_INDEX,
>>      .codec_tag      = (const AVCodecTag * const []) { ff_codec_wav_tags,
>> 0 },
>> +    .priv_class     = &w64_demuxer_class,
>>  };
>>  #endif /* CONFIG_W64_DEMUXER */
>>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Andreas Rheinhardt Aug. 28, 2020, 8:41 a.m. UTC | #3
Paul B Mahol:
> On 8/28/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
>> Paul B Mahol:
>>> Can make demuxing much faster, expecially for files with
>>> huge number of channels.
>>>
>>> Signed-off-by: Paul B Mahol <onemda@gmail.com>
>>> ---
>>>  libavformat/wavdec.c | 21 ++++++++++++++++++---
>>>  1 file changed, 18 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
>>> index e1b2115434..5b3c481421 100644
>>> --- a/libavformat/wavdec.c
>>> +++ b/libavformat/wavdec.c
>>> @@ -56,6 +56,7 @@ typedef struct WAVDemuxContext {
>>>      int smv_eof;
>>>      int audio_eof;
>>>      int ignore_length;
>>> +    int max_size;
>>>      int spdif;
>>>      int smv_cur_pt;
>>>      int smv_given_first;
>>> @@ -628,8 +629,6 @@ static int64_t find_guid(AVIOContext *pb, const
>>> uint8_t guid1[16])
>>>      return AVERROR_EOF;
>>>  }
>>>
>>> -#define MAX_SIZE 4096
>>> -
>>>  static int wav_read_packet(AVFormatContext *s, AVPacket *pkt)
>>>  {
>>>      int ret, size;
>>> @@ -706,7 +705,7 @@ smv_out:
>>>          wav->data_end = avio_tell(s->pb) + left;
>>>      }
>>>
>>> -    size = MAX_SIZE;
>>> +    size = wav->max_size;
>>>      if (st->codecpar->block_align > 1) {
>>>          if (size < st->codecpar->block_align)
>>>              size = st->codecpar->block_align;
>>> @@ -759,6 +758,7 @@ static int wav_read_seek(AVFormatContext *s,
>>>  #define DEC AV_OPT_FLAG_DECODING_PARAM
>>>  static const AVOption demux_options[] = {
>>>      { "ignore_length", "Ignore length", OFFSET(ignore_length),
>>> AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
>>> +    { "max_size",      "max size of single packet", OFFSET(max_size),
>>> AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
>>>      { NULL },
>>>  };
>>>
>>> @@ -906,6 +906,20 @@ static int w64_read_header(AVFormatContext *s)
>>>      return 0;
>>>  }
>>>
>>> +#define OFFSET(x) offsetof(WAVDemuxContext, x)
>>> +#define DEC AV_OPT_FLAG_DECODING_PARAM
>>> +static const AVOption w64_demux_options[] = {
>>> +    { "max_size", "max size of single packet", OFFSET(max_size),
>>> AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
>>> +    { NULL },
>>
>> The ',' is unnecessary: Nothing will ever be added after the sentinel.
>>
>>> +};
>>
>> You can use &demux_options[1] instead of w64_demux_options (but add a
>> comment for this).
> 
> How the comment should look like?
> 

I thought of a comment for demux_options like "Hint: The options are
partially shared with the Wave64 demuxer."

>>
>>> +
>>> +static const AVClass w64_demuxer_class = {
>>> +    .class_name = "W64 demuxer",
>>> +    .item_name  = av_default_item_name,
>>> +    .option     = w64_demux_options,
>>> +    .version    = LIBAVUTIL_VERSION_INT,
>>> +};
>>> +
>>>  AVInputFormat ff_w64_demuxer = {
>>>      .name           = "w64",
>>>      .long_name      = NULL_IF_CONFIG_SMALL("Sony Wave64"),
>>> @@ -916,5 +930,6 @@ AVInputFormat ff_w64_demuxer = {
>>>      .read_seek      = wav_read_seek,
>>>      .flags          = AVFMT_GENERIC_INDEX,
>>>      .codec_tag      = (const AVCodecTag * const []) { ff_codec_wav_tags,
>>> 0 },
>>> +    .priv_class     = &w64_demuxer_class,
>>>  };
>>>  #endif /* CONFIG_W64_DEMUXER */
>>>
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
Paul B Mahol Aug. 28, 2020, 8:47 a.m. UTC | #4
On 8/28/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
> Paul B Mahol:
>> On 8/28/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
>>> Paul B Mahol:
>>>> Can make demuxing much faster, expecially for files with
>>>> huge number of channels.
>>>>
>>>> Signed-off-by: Paul B Mahol <onemda@gmail.com>
>>>> ---
>>>>  libavformat/wavdec.c | 21 ++++++++++++++++++---
>>>>  1 file changed, 18 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
>>>> index e1b2115434..5b3c481421 100644
>>>> --- a/libavformat/wavdec.c
>>>> +++ b/libavformat/wavdec.c
>>>> @@ -56,6 +56,7 @@ typedef struct WAVDemuxContext {
>>>>      int smv_eof;
>>>>      int audio_eof;
>>>>      int ignore_length;
>>>> +    int max_size;
>>>>      int spdif;
>>>>      int smv_cur_pt;
>>>>      int smv_given_first;
>>>> @@ -628,8 +629,6 @@ static int64_t find_guid(AVIOContext *pb, const
>>>> uint8_t guid1[16])
>>>>      return AVERROR_EOF;
>>>>  }
>>>>
>>>> -#define MAX_SIZE 4096
>>>> -
>>>>  static int wav_read_packet(AVFormatContext *s, AVPacket *pkt)
>>>>  {
>>>>      int ret, size;
>>>> @@ -706,7 +705,7 @@ smv_out:
>>>>          wav->data_end = avio_tell(s->pb) + left;
>>>>      }
>>>>
>>>> -    size = MAX_SIZE;
>>>> +    size = wav->max_size;
>>>>      if (st->codecpar->block_align > 1) {
>>>>          if (size < st->codecpar->block_align)
>>>>              size = st->codecpar->block_align;
>>>> @@ -759,6 +758,7 @@ static int wav_read_seek(AVFormatContext *s,
>>>>  #define DEC AV_OPT_FLAG_DECODING_PARAM
>>>>  static const AVOption demux_options[] = {
>>>>      { "ignore_length", "Ignore length", OFFSET(ignore_length),
>>>> AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
>>>> +    { "max_size",      "max size of single packet", OFFSET(max_size),
>>>> AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
>>>>      { NULL },
>>>>  };
>>>>
>>>> @@ -906,6 +906,20 @@ static int w64_read_header(AVFormatContext *s)
>>>>      return 0;
>>>>  }
>>>>
>>>> +#define OFFSET(x) offsetof(WAVDemuxContext, x)
>>>> +#define DEC AV_OPT_FLAG_DECODING_PARAM
>>>> +static const AVOption w64_demux_options[] = {
>>>> +    { "max_size", "max size of single packet", OFFSET(max_size),
>>>> AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
>>>> +    { NULL },
>>>
>>> The ',' is unnecessary: Nothing will ever be added after the sentinel.
>>>
>>>> +};
>>>
>>> You can use &demux_options[1] instead of w64_demux_options (but add a
>>> comment for this).
>>
>> How the comment should look like?
>>
>
> I thought of a comment for demux_options like "Hint: The options are
> partially shared with the Wave64 demuxer."

More like Warning instead of Hint.
So some other developer does not add option that does not make sense for w64.

>
>>>
>>>> +
>>>> +static const AVClass w64_demuxer_class = {
>>>> +    .class_name = "W64 demuxer",
>>>> +    .item_name  = av_default_item_name,
>>>> +    .option     = w64_demux_options,
>>>> +    .version    = LIBAVUTIL_VERSION_INT,
>>>> +};
>>>> +
>>>>  AVInputFormat ff_w64_demuxer = {
>>>>      .name           = "w64",
>>>>      .long_name      = NULL_IF_CONFIG_SMALL("Sony Wave64"),
>>>> @@ -916,5 +930,6 @@ AVInputFormat ff_w64_demuxer = {
>>>>      .read_seek      = wav_read_seek,
>>>>      .flags          = AVFMT_GENERIC_INDEX,
>>>>      .codec_tag      = (const AVCodecTag * const []) {
>>>> ff_codec_wav_tags,
>>>> 0 },
>>>> +    .priv_class     = &w64_demuxer_class,
>>>>  };
>>>>  #endif /* CONFIG_W64_DEMUXER */
>>>>
>>>
>>> _______________________________________________
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel@ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>> To unsubscribe, visit link above, or email
>>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Paul B Mahol Aug. 28, 2020, 8:50 a.m. UTC | #5
On 8/28/20, Paul B Mahol <onemda@gmail.com> wrote:
> On 8/28/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
>> Paul B Mahol:
>>> On 8/28/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
>>>> Paul B Mahol:
>>>>> Can make demuxing much faster, expecially for files with
>>>>> huge number of channels.
>>>>>
>>>>> Signed-off-by: Paul B Mahol <onemda@gmail.com>
>>>>> ---
>>>>>  libavformat/wavdec.c | 21 ++++++++++++++++++---
>>>>>  1 file changed, 18 insertions(+), 3 deletions(-)
>>>>>
>>>>> diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
>>>>> index e1b2115434..5b3c481421 100644
>>>>> --- a/libavformat/wavdec.c
>>>>> +++ b/libavformat/wavdec.c
>>>>> @@ -56,6 +56,7 @@ typedef struct WAVDemuxContext {
>>>>>      int smv_eof;
>>>>>      int audio_eof;
>>>>>      int ignore_length;
>>>>> +    int max_size;
>>>>>      int spdif;
>>>>>      int smv_cur_pt;
>>>>>      int smv_given_first;
>>>>> @@ -628,8 +629,6 @@ static int64_t find_guid(AVIOContext *pb, const
>>>>> uint8_t guid1[16])
>>>>>      return AVERROR_EOF;
>>>>>  }
>>>>>
>>>>> -#define MAX_SIZE 4096
>>>>> -
>>>>>  static int wav_read_packet(AVFormatContext *s, AVPacket *pkt)
>>>>>  {
>>>>>      int ret, size;
>>>>> @@ -706,7 +705,7 @@ smv_out:
>>>>>          wav->data_end = avio_tell(s->pb) + left;
>>>>>      }
>>>>>
>>>>> -    size = MAX_SIZE;
>>>>> +    size = wav->max_size;
>>>>>      if (st->codecpar->block_align > 1) {
>>>>>          if (size < st->codecpar->block_align)
>>>>>              size = st->codecpar->block_align;
>>>>> @@ -759,6 +758,7 @@ static int wav_read_seek(AVFormatContext *s,
>>>>>  #define DEC AV_OPT_FLAG_DECODING_PARAM
>>>>>  static const AVOption demux_options[] = {
>>>>>      { "ignore_length", "Ignore length", OFFSET(ignore_length),
>>>>> AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
>>>>> +    { "max_size",      "max size of single packet", OFFSET(max_size),
>>>>> AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
>>>>>      { NULL },
>>>>>  };
>>>>>
>>>>> @@ -906,6 +906,20 @@ static int w64_read_header(AVFormatContext *s)
>>>>>      return 0;
>>>>>  }
>>>>>
>>>>> +#define OFFSET(x) offsetof(WAVDemuxContext, x)
>>>>> +#define DEC AV_OPT_FLAG_DECODING_PARAM
>>>>> +static const AVOption w64_demux_options[] = {
>>>>> +    { "max_size", "max size of single packet", OFFSET(max_size),
>>>>> AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
>>>>> +    { NULL },
>>>>
>>>> The ',' is unnecessary: Nothing will ever be added after the sentinel.
>>>>
>>>>> +};
>>>>
>>>> You can use &demux_options[1] instead of w64_demux_options (but add a
>>>> comment for this).
>>>
>>> How the comment should look like?
>>>
>>
>> I thought of a comment for demux_options like "Hint: The options are
>> partially shared with the Wave64 demuxer."
>
> More like Warning instead of Hint.
> So some other developer does not add option that does not make sense for
> w64.

Problem is demux_options are under ifdef so can not be shared as is.
What about using macro to define max_size option or just keep it as in
this patch.

>
>>
>>>>
>>>>> +
>>>>> +static const AVClass w64_demuxer_class = {
>>>>> +    .class_name = "W64 demuxer",
>>>>> +    .item_name  = av_default_item_name,
>>>>> +    .option     = w64_demux_options,
>>>>> +    .version    = LIBAVUTIL_VERSION_INT,
>>>>> +};
>>>>> +
>>>>>  AVInputFormat ff_w64_demuxer = {
>>>>>      .name           = "w64",
>>>>>      .long_name      = NULL_IF_CONFIG_SMALL("Sony Wave64"),
>>>>> @@ -916,5 +930,6 @@ AVInputFormat ff_w64_demuxer = {
>>>>>      .read_seek      = wav_read_seek,
>>>>>      .flags          = AVFMT_GENERIC_INDEX,
>>>>>      .codec_tag      = (const AVCodecTag * const []) {
>>>>> ff_codec_wav_tags,
>>>>> 0 },
>>>>> +    .priv_class     = &w64_demuxer_class,
>>>>>  };
>>>>>  #endif /* CONFIG_W64_DEMUXER */
>>>>>
>>>>
>>>> _______________________________________________
>>>> ffmpeg-devel mailing list
>>>> ffmpeg-devel@ffmpeg.org
>>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>
>>>> To unsubscribe, visit link above, or email
>>>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>> _______________________________________________
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel@ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>> To unsubscribe, visit link above, or email
>>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
Paul B Mahol Aug. 31, 2020, 3:23 p.m. UTC | #6
On 8/28/20, Paul B Mahol <onemda@gmail.com> wrote:
> On 8/28/20, Paul B Mahol <onemda@gmail.com> wrote:
>> On 8/28/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
>>> Paul B Mahol:
>>>> On 8/28/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
>>>>> Paul B Mahol:
>>>>>> Can make demuxing much faster, expecially for files with
>>>>>> huge number of channels.
>>>>>>
>>>>>> Signed-off-by: Paul B Mahol <onemda@gmail.com>
>>>>>> ---
>>>>>>  libavformat/wavdec.c | 21 ++++++++++++++++++---
>>>>>>  1 file changed, 18 insertions(+), 3 deletions(-)
>>>>>>
>>>>>> diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
>>>>>> index e1b2115434..5b3c481421 100644
>>>>>> --- a/libavformat/wavdec.c
>>>>>> +++ b/libavformat/wavdec.c
>>>>>> @@ -56,6 +56,7 @@ typedef struct WAVDemuxContext {
>>>>>>      int smv_eof;
>>>>>>      int audio_eof;
>>>>>>      int ignore_length;
>>>>>> +    int max_size;
>>>>>>      int spdif;
>>>>>>      int smv_cur_pt;
>>>>>>      int smv_given_first;
>>>>>> @@ -628,8 +629,6 @@ static int64_t find_guid(AVIOContext *pb, const
>>>>>> uint8_t guid1[16])
>>>>>>      return AVERROR_EOF;
>>>>>>  }
>>>>>>
>>>>>> -#define MAX_SIZE 4096
>>>>>> -
>>>>>>  static int wav_read_packet(AVFormatContext *s, AVPacket *pkt)
>>>>>>  {
>>>>>>      int ret, size;
>>>>>> @@ -706,7 +705,7 @@ smv_out:
>>>>>>          wav->data_end = avio_tell(s->pb) + left;
>>>>>>      }
>>>>>>
>>>>>> -    size = MAX_SIZE;
>>>>>> +    size = wav->max_size;
>>>>>>      if (st->codecpar->block_align > 1) {
>>>>>>          if (size < st->codecpar->block_align)
>>>>>>              size = st->codecpar->block_align;
>>>>>> @@ -759,6 +758,7 @@ static int wav_read_seek(AVFormatContext *s,
>>>>>>  #define DEC AV_OPT_FLAG_DECODING_PARAM
>>>>>>  static const AVOption demux_options[] = {
>>>>>>      { "ignore_length", "Ignore length", OFFSET(ignore_length),
>>>>>> AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
>>>>>> +    { "max_size",      "max size of single packet",
>>>>>> OFFSET(max_size),
>>>>>> AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
>>>>>>      { NULL },
>>>>>>  };
>>>>>>
>>>>>> @@ -906,6 +906,20 @@ static int w64_read_header(AVFormatContext *s)
>>>>>>      return 0;
>>>>>>  }
>>>>>>
>>>>>> +#define OFFSET(x) offsetof(WAVDemuxContext, x)
>>>>>> +#define DEC AV_OPT_FLAG_DECODING_PARAM
>>>>>> +static const AVOption w64_demux_options[] = {
>>>>>> +    { "max_size", "max size of single packet", OFFSET(max_size),
>>>>>> AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
>>>>>> +    { NULL },
>>>>>
>>>>> The ',' is unnecessary: Nothing will ever be added after the sentinel.
>>>>>
>>>>>> +};
>>>>>
>>>>> You can use &demux_options[1] instead of w64_demux_options (but add a
>>>>> comment for this).
>>>>
>>>> How the comment should look like?
>>>>
>>>
>>> I thought of a comment for demux_options like "Hint: The options are
>>> partially shared with the Wave64 demuxer."
>>
>> More like Warning instead of Hint.
>> So some other developer does not add option that does not make sense for
>> w64.
>
> Problem is demux_options are under ifdef so can not be shared as is.
> What about using macro to define max_size option or just keep it as in
> this patch.

Gonna apply with removed comma after {NULL} in w64 options.

>
>>
>>>
>>>>>
>>>>>> +
>>>>>> +static const AVClass w64_demuxer_class = {
>>>>>> +    .class_name = "W64 demuxer",
>>>>>> +    .item_name  = av_default_item_name,
>>>>>> +    .option     = w64_demux_options,
>>>>>> +    .version    = LIBAVUTIL_VERSION_INT,
>>>>>> +};
>>>>>> +
>>>>>>  AVInputFormat ff_w64_demuxer = {
>>>>>>      .name           = "w64",
>>>>>>      .long_name      = NULL_IF_CONFIG_SMALL("Sony Wave64"),
>>>>>> @@ -916,5 +930,6 @@ AVInputFormat ff_w64_demuxer = {
>>>>>>      .read_seek      = wav_read_seek,
>>>>>>      .flags          = AVFMT_GENERIC_INDEX,
>>>>>>      .codec_tag      = (const AVCodecTag * const []) {
>>>>>> ff_codec_wav_tags,
>>>>>> 0 },
>>>>>> +    .priv_class     = &w64_demuxer_class,
>>>>>>  };
>>>>>>  #endif /* CONFIG_W64_DEMUXER */
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> ffmpeg-devel mailing list
>>>>> ffmpeg-devel@ffmpeg.org
>>>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>>
>>>>> To unsubscribe, visit link above, or email
>>>>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>> _______________________________________________
>>>> ffmpeg-devel mailing list
>>>> ffmpeg-devel@ffmpeg.org
>>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>
>>>> To unsubscribe, visit link above, or email
>>>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>>
>>>
>>> _______________________________________________
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel@ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>> To unsubscribe, visit link above, or email
>>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>
>
diff mbox series

Patch

diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index e1b2115434..5b3c481421 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -56,6 +56,7 @@  typedef struct WAVDemuxContext {
     int smv_eof;
     int audio_eof;
     int ignore_length;
+    int max_size;
     int spdif;
     int smv_cur_pt;
     int smv_given_first;
@@ -628,8 +629,6 @@  static int64_t find_guid(AVIOContext *pb, const uint8_t guid1[16])
     return AVERROR_EOF;
 }
 
-#define MAX_SIZE 4096
-
 static int wav_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
     int ret, size;
@@ -706,7 +705,7 @@  smv_out:
         wav->data_end = avio_tell(s->pb) + left;
     }
 
-    size = MAX_SIZE;
+    size = wav->max_size;
     if (st->codecpar->block_align > 1) {
         if (size < st->codecpar->block_align)
             size = st->codecpar->block_align;
@@ -759,6 +758,7 @@  static int wav_read_seek(AVFormatContext *s,
 #define DEC AV_OPT_FLAG_DECODING_PARAM
 static const AVOption demux_options[] = {
     { "ignore_length", "Ignore length", OFFSET(ignore_length), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
+    { "max_size",      "max size of single packet", OFFSET(max_size), AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
     { NULL },
 };
 
@@ -906,6 +906,20 @@  static int w64_read_header(AVFormatContext *s)
     return 0;
 }
 
+#define OFFSET(x) offsetof(WAVDemuxContext, x)
+#define DEC AV_OPT_FLAG_DECODING_PARAM
+static const AVOption w64_demux_options[] = {
+    { "max_size", "max size of single packet", OFFSET(max_size), AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
+    { NULL },
+};
+
+static const AVClass w64_demuxer_class = {
+    .class_name = "W64 demuxer",
+    .item_name  = av_default_item_name,
+    .option     = w64_demux_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
 AVInputFormat ff_w64_demuxer = {
     .name           = "w64",
     .long_name      = NULL_IF_CONFIG_SMALL("Sony Wave64"),
@@ -916,5 +930,6 @@  AVInputFormat ff_w64_demuxer = {
     .read_seek      = wav_read_seek,
     .flags          = AVFMT_GENERIC_INDEX,
     .codec_tag      = (const AVCodecTag * const []) { ff_codec_wav_tags, 0 },
+    .priv_class     = &w64_demuxer_class,
 };
 #endif /* CONFIG_W64_DEMUXER */