Re: [FFmpeg-devel] Too many project ideas in GSOC 2022 FFmpeg

2022-02-28 Thread Michael Koch

We have 0 project ideas on our gsoc 2022 page
well we have 2 now as i copied my two from last year
If you have an idea, please add it!


Might it be possible to integrate LibRaw into FFmpeg?
https://www.libraw.org/

This could also solve the problem that import of DNG images doesn't work in 
FFmpeg.

Michael

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] 回复:Re: 回复:Re: 回复:Re: [PATCH v9 5/5]_lavc,_doc:_add_libuavs3d_video_decoder_wrapper

2022-02-28 Thread hbj515

Thanks, the license has been updated. You can check it on 
https://github.com/uavs3/uavs3d
- 原始邮件 -
发件人:"Jean-Baptiste Kempf" 
收件人:ffmpeg-devel 
主题:Re: [FFmpeg-devel] 回复:Re:  回复:Re:  [PATCH v9 
5/5]_lavc,_doc:_add_libuavs3d_video_decoder_wrapper
日期:2022年03月01日 14点15分

Your understanding is correct. BSD-3 is fine.
On Mon, 28 Feb 2022, at 23:09, hbj...@sina.com wrote:
> Sorry, the last reply was a bit ambiguous. I want to confirm that 
> uavs3d will not be flagged as "non-free", if the license is changed to 
> BSD 3-clause.If so, we will change the license soon. The BSD 3-clause 
> license is compatible with the GNU GPL, as the wiki says. 
> (https://en.wikipedia.org/wiki/BSD_licenses)
> - 原始邮件 -
> 发件人:"Jean-Baptiste Kempf" 
> 收件人:ffmpeg-devel 
> 主题:Re: [FFmpeg-devel] 回复:Re:  [PATCH v9 
> 5/5]_lavc,_doc:_add_libuavs3d_video_decoder_wrapper
> 日期:2022年03月01日 13点19分
>
> Yes. This is correct.
> On Mon, 28 Feb 2022, at 21:57, hbj...@sina.com wrote:
>> Thinks for your reminder. If uavs3d is BSD 3-clause, will uavs3d be 
>> flagged as "non-free"? We can change the license of uavs3d.
>> - 原始邮件 -
>> 发件人:"Jean-Baptiste Kempf" 
>> 收件人:hwrenx , ffmpeg-devel 
>> 抄送人:hbj 
>> 主题:Re: [FFmpeg-devel] [PATCH v9 5/5] lavc, doc: add libuavs3d video 
>> decoder wrapper
>> 日期:2022年02月26日 19点06分
>>
>> Hello,
>> On Mon, 31 Aug 2020, at 17:07, hwr...@126.com wrote:
>>> +  --enable-libuavs3d   enable AVS3 decoding via libuavs3d [no]
>> uavs3d is BSD 4-clause, and is therefore not compatible with GPLv2, 
>> GPLv3, LGPLv2.1 or LGPLv3
>> uavs3d should be flagged as "non-free" (and undistributable) then.
>> Best,
>> -- 
>> Jean-Baptiste Kempf -  President
>> +33 672 704 734
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@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-requ...@ffmpeg.org with subject "unsubscribe".
> -- 
> Jean-Baptiste Kempf -  President
> +33 672 704 734
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@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-requ...@ffmpeg.org with subject "unsubscribe".
-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters

2022-02-28 Thread Xiang, Haihao
On Mon, 2022-02-21 at 13:27 +0100, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/audio.c | 11 +--
>  libavfilter/framepool.c | 18 --
>  libavfilter/video.c | 11 +--
>  3 files changed, 18 insertions(+), 22 deletions(-)
> 
> diff --git a/libavfilter/audio.c b/libavfilter/audio.c
> index cebc9709dd..a0408226a3 100644
> --- a/libavfilter/audio.c
> +++ b/libavfilter/audio.c
> @@ -22,15 +22,13 @@
>  #include "libavutil/avassert.h"
>  #include "libavutil/channel_layout.h"
>  #include "libavutil/common.h"
> +#include "libavutil/cpu.h"
>  
>  #include "audio.h"
>  #include "avfilter.h"
>  #include "framepool.h"
>  #include "internal.h"
>  
> -#define BUFFER_ALIGN 0
> -
> -
>  AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
>  {
>  return ff_get_audio_buffer(link->dst->outputs[0], nb_samples);
> @@ -41,12 +39,13 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link,
> int nb_samples)
>  AVFrame *frame = NULL;
>  int channels = link->channels;
>  int channel_layout_nb_channels = av_get_channel_layout_nb_channels(link-
> >channel_layout);
> +int align = av_cpu_max_align();
>  
>  av_assert0(channels == channel_layout_nb_channels ||
> !channel_layout_nb_channels);
>  
>  if (!link->frame_pool) {
>  link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz,
> channels,
> -nb_samples, 
> link->format, 
> BUFFER_ALIGN);
> +nb_samples, 
> link->format, 
> align);
>  if (!link->frame_pool)
>  return NULL;
>  } else {
> @@ -62,11 +61,11 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link,
> int nb_samples)
>  }
>  
>  if (pool_channels != channels || pool_nb_samples < nb_samples ||
> -pool_format != link->format || pool_align != BUFFER_ALIGN) {
> +pool_format != link->format || pool_align != align) {
>  
>  ff_frame_pool_uninit((FFFramePool **)>frame_pool);
>  link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz,
> channels,
> -nb_samples, link-
> >format, BUFFER_ALIGN);
> +nb_samples, link-
> >format, align);
>  if (!link->frame_pool)
>  return NULL;
>  }
> diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
> index 7c63807df3..5b510c9af9 100644
> --- a/libavfilter/framepool.c
> +++ b/libavfilter/framepool.c
> @@ -76,27 +76,25 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef*
> (*alloc)(size_t size),
>  }
>  
>  if (!pool->linesize[0]) {
> -for(i = 1; i <= align; i += i) {
> -ret = av_image_fill_linesizes(pool->linesize, pool->format,
> -  FFALIGN(pool->width, i));
> -if (ret < 0) {
> -goto fail;
> -}
> -if (!(pool->linesize[0] & (pool->align - 1)))
> -break;
> +ret = av_image_fill_linesizes(pool->linesize, pool->format,
> +  FFALIGN(pool->width, align));
> +if (ret < 0) {
> +goto fail;
>  }
>  
>  for (i = 0; i < 4 && pool->linesize[i]; i++) {
>  pool->linesize[i] = FFALIGN(pool->linesize[i], pool->align);
> +if ((pool->linesize[i] & (pool->align - 1)))
> +goto fail;
>  }
>  }
>  
>  for (i = 0; i < 4 && pool->linesize[i]; i++) {
> -int h = FFALIGN(pool->height, 32);
> +int h = pool->height;
>  if (i == 1 || i == 2)
>  h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
>  
> -pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + 16 + 16
> - 1,
> +pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + align,
>   alloc);
>  if (!pool->pools[i])
>  goto fail;
> diff --git a/libavfilter/video.c b/libavfilter/video.c
> index 7ef04144e4..fa3d588044 100644
> --- a/libavfilter/video.c
> +++ b/libavfilter/video.c
> @@ -24,6 +24,7 @@
>  #include 
>  
>  #include "libavutil/buffer.h"
> +#include "libavutil/cpu.h"
>  #include "libavutil/hwcontext.h"
>  #include "libavutil/imgutils.h"
>  
> @@ -32,9 +33,6 @@
>  #include "internal.h"
>  #include "video.h"
>  
> -#define BUFFER_ALIGN 32
> -
> -
>  AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
>  {
>  return ff_get_video_buffer(link->dst->outputs[0], w, h);
> @@ -46,6 +44,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int
> w, int h)
>  int pool_width = 0;
>  int pool_height = 0;
>  int pool_align = 0;
> +int align = av_cpu_max_align();
>  enum AVPixelFormat pool_format = AV_PIX_FMT_NONE;
>  
>  if (link->hw_frames_ctx &&
> @@ -65,7 +64,7 @@ 

Re: [FFmpeg-devel] 回复:Re: 回复:Re: [PATCH v9 5/5]_lavc,_doc:_add_libuavs3d_video_decoder_wrapper

2022-02-28 Thread Jean-Baptiste Kempf
Your understanding is correct. BSD-3 is fine.

On Mon, 28 Feb 2022, at 23:09, hbj...@sina.com wrote:
> Sorry, the last reply was a bit ambiguous. I want to confirm that 
> uavs3d will not be flagged as "non-free", if the license is changed to 
> BSD 3-clause.If so, we will change the license soon. The BSD 3-clause 
> license is compatible with the GNU GPL, as the wiki says. 
> (https://en.wikipedia.org/wiki/BSD_licenses)
> - 原始邮件 -
> 发件人:"Jean-Baptiste Kempf" 
> 收件人:ffmpeg-devel 
> 主题:Re: [FFmpeg-devel] 回复:Re:  [PATCH v9 
> 5/5]_lavc,_doc:_add_libuavs3d_video_decoder_wrapper
> 日期:2022年03月01日 13点19分
>
> Yes. This is correct.
> On Mon, 28 Feb 2022, at 21:57, hbj...@sina.com wrote:
>> Thinks for your reminder. If uavs3d is BSD 3-clause, will uavs3d be 
>> flagged as "non-free"? We can change the license of uavs3d.
>> - 原始邮件 -
>> 发件人:"Jean-Baptiste Kempf" 
>> 收件人:hwrenx , ffmpeg-devel 
>> 抄送人:hbj 
>> 主题:Re: [FFmpeg-devel] [PATCH v9 5/5] lavc, doc: add libuavs3d video 
>> decoder wrapper
>> 日期:2022年02月26日 19点06分
>>
>> Hello,
>> On Mon, 31 Aug 2020, at 17:07, hwr...@126.com wrote:
>>> +  --enable-libuavs3d   enable AVS3 decoding via libuavs3d [no]
>> uavs3d is BSD 4-clause, and is therefore not compatible with GPLv2, 
>> GPLv3, LGPLv2.1 or LGPLv3
>> uavs3d should be flagged as "non-free" (and undistributable) then.
>> Best,
>> -- 
>> Jean-Baptiste Kempf -  President
>> +33 672 704 734
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@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-requ...@ffmpeg.org with subject "unsubscribe".
> -- 
> Jean-Baptiste Kempf -  President
> +33 672 704 734
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@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-requ...@ffmpeg.org with subject "unsubscribe".

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] 回复:Re: 回复:Re: [PATCH v9 5/5]_lavc,_doc:_add_libuavs3d_video_decoder_wrapper

2022-02-28 Thread hbj515
Sorry, the last reply was a bit ambiguous. I want to confirm that uavs3d will 
not be flagged as "non-free", if the license is changed to BSD 3-clause.If so, 
we will change the license soon. The BSD 3-clause license is compatible with 
the GNU GPL, as the wiki says. (https://en.wikipedia.org/wiki/BSD_licenses)
- 原始邮件 -
发件人:"Jean-Baptiste Kempf" 
收件人:ffmpeg-devel 
主题:Re: [FFmpeg-devel] 回复:Re:  [PATCH v9 
5/5]_lavc,_doc:_add_libuavs3d_video_decoder_wrapper
日期:2022年03月01日 13点19分

Yes. This is correct.
On Mon, 28 Feb 2022, at 21:57, hbj...@sina.com wrote:
> Thinks for your reminder. If uavs3d is BSD 3-clause, will uavs3d be 
> flagged as "non-free"? We can change the license of uavs3d.
> - 原始邮件 -
> 发件人:"Jean-Baptiste Kempf" 
> 收件人:hwrenx , ffmpeg-devel 
> 抄送人:hbj 
> 主题:Re: [FFmpeg-devel] [PATCH v9 5/5] lavc, doc: add libuavs3d video 
> decoder wrapper
> 日期:2022年02月26日 19点06分
>
> Hello,
> On Mon, 31 Aug 2020, at 17:07, hwr...@126.com wrote:
>> +  --enable-libuavs3d   enable AVS3 decoding via libuavs3d [no]
> uavs3d is BSD 4-clause, and is therefore not compatible with GPLv2, 
> GPLv3, LGPLv2.1 or LGPLv3
> uavs3d should be flagged as "non-free" (and undistributable) then.
> Best,
> -- 
> Jean-Baptiste Kempf -  President
> +33 672 704 734
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@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-requ...@ffmpeg.org with subject "unsubscribe".
-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] 回复:Re: [PATCH v9 5/5] lavc, doc: add libuavs3d video decoder wrapper

2022-02-28 Thread Jean-Baptiste Kempf
Yes. This is correct.

On Mon, 28 Feb 2022, at 21:57, hbj...@sina.com wrote:
> Thinks for your reminder. If uavs3d is BSD 3-clause, will uavs3d be 
> flagged as "non-free"? We can change the license of uavs3d.
> - 原始邮件 -
> 发件人:"Jean-Baptiste Kempf" 
> 收件人:hwrenx , ffmpeg-devel 
> 抄送人:hbj 
> 主题:Re: [FFmpeg-devel] [PATCH v9 5/5] lavc, doc: add libuavs3d video 
> decoder wrapper
> 日期:2022年02月26日 19点06分
>
> Hello,
> On Mon, 31 Aug 2020, at 17:07, hwr...@126.com wrote:
>> +  --enable-libuavs3d   enable AVS3 decoding via libuavs3d [no]
> uavs3d is BSD 4-clause, and is therefore not compatible with GPLv2, 
> GPLv3, LGPLv2.1 or LGPLv3
> uavs3d should be flagged as "non-free" (and undistributable) then.
> Best,
> -- 
> Jean-Baptiste Kempf -  President
> +33 672 704 734
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@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-requ...@ffmpeg.org with subject "unsubscribe".

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] 回复:Re: [PATCH v9 5/5] lavc, doc: add libuavs3d video decoder wrapper

2022-02-28 Thread hbj515

Thinks for your reminder. If uavs3d is BSD 3-clause, will uavs3d be flagged as 
"non-free"? We can change the license of uavs3d.
- 原始邮件 -
发件人:"Jean-Baptiste Kempf" 
收件人:hwrenx , ffmpeg-devel 
抄送人:hbj 
主题:Re: [FFmpeg-devel] [PATCH v9 5/5] lavc, doc: add libuavs3d video decoder 
wrapper
日期:2022年02月26日 19点06分

Hello,
On Mon, 31 Aug 2020, at 17:07, hwr...@126.com wrote:
> +  --enable-libuavs3d   enable AVS3 decoding via libuavs3d [no]
uavs3d is BSD 4-clause, and is therefore not compatible with GPLv2, GPLv3, 
LGPLv2.1 or LGPLv3
uavs3d should be flagged as "non-free" (and undistributable) then.
Best,
-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] libavformat/concatdev.c: use the unified time base

2022-02-28 Thread Gyan Doshi




On 2022-03-01 09:46 am, Ye Chuan wrote:

In some case, the input files have different time base
even though they  share the same codec and codec parameters,

So when we replace the packet, we need use the unified time base
instead of it of each stream own, which may lead to wrong pts/dts
of the output packet.
Make this optional. This 'bug' has been used to effect speed change in 
some inputs.


Regards,
Gyan



Signed-off-by: Chuan Ye 
---
libavformat/concatdec.c | 9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index 0603c6e254..f7067d5059 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -740,6 +740,7 @@ static int concat_read_packet(AVFormatContext *avf, 
AVPacket *pkt)
 ConcatStream *cs;
 AVStream *st;
 FFStream *sti;
+AVRational output_tb;

 if (cat->eof)
 return AVERROR_EOF;
@@ -782,13 +783,15 @@ static int concat_read_packet(AVFormatContext *avf, 
AVPacket *pkt)
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, >time_base),
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, >time_base));

+/* replace the pkt base on the time base of target output stream */
+output_tb = avf->streams[cs->out_stream_index]->time_base;
 delta = av_rescale_q(cat->cur_file->start_time - 
cat->cur_file->file_inpoint,
  AV_TIME_BASE_Q,
- cat->avf->streams[pkt->stream_index]->time_base);
+ output_tb);
 if (pkt->pts != AV_NOPTS_VALUE)
-pkt->pts += delta;
+pkt->pts = av_rescale_q(pkt->pts, st->time_base, output_tb) + delta;
 if (pkt->dts != AV_NOPTS_VALUE)
-pkt->dts += delta;
+pkt->dts = av_rescale_q(pkt->dts, st->time_base, output_tb) + delta;
 av_log(avf, AV_LOG_DEBUG, " -> pts:%s pts_time:%s dts:%s dts_time:%s\n",
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, >time_base),
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, >time_base));


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH] libavformat/concatdev.c: use the unified time base

2022-02-28 Thread Ye Chuan
In some case, the input files have different time base
even though they  share the same codec and codec parameters,

So when we replace the packet, we need use the unified time base
instead of it of each stream own, which may lead to wrong pts/dts
of the output packet.

Signed-off-by: Chuan Ye 
---
libavformat/concatdec.c | 9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index 0603c6e254..f7067d5059 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -740,6 +740,7 @@ static int concat_read_packet(AVFormatContext *avf, 
AVPacket *pkt)
ConcatStream *cs;
AVStream *st;
FFStream *sti;
+AVRational output_tb;

if (cat->eof)
return AVERROR_EOF;
@@ -782,13 +783,15 @@ static int concat_read_packet(AVFormatContext *avf, 
AVPacket *pkt)
   av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, >time_base),
   av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, >time_base));

+/* replace the pkt base on the time base of target output stream */
+output_tb = avf->streams[cs->out_stream_index]->time_base;
delta = av_rescale_q(cat->cur_file->start_time - 
cat->cur_file->file_inpoint,
 AV_TIME_BASE_Q,
- cat->avf->streams[pkt->stream_index]->time_base);
+ output_tb);
if (pkt->pts != AV_NOPTS_VALUE)
-pkt->pts += delta;
+pkt->pts = av_rescale_q(pkt->pts, st->time_base, output_tb) + delta;
if (pkt->dts != AV_NOPTS_VALUE)
-pkt->dts += delta;
+pkt->dts = av_rescale_q(pkt->dts, st->time_base, output_tb) + delta;
av_log(avf, AV_LOG_DEBUG, " -> pts:%s pts_time:%s dts:%s dts_time:%s\n",
   av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, >time_base),
   av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, >time_base));
-- 
2.30.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH] libavformat/concatdev.c use the unified time base

2022-02-28 Thread Ye Chuan
in some case, the input files have different time base
even though they  share the same codec and codec parameters,

so when we replace the packet, we need use the unified time base
instead of it of each stream own, which may lead to wrong pts/dts
of the output packet.

Signed-off-by: Chuan Ye 
mailto:yechuan0...@hotmail.com>>
---
libavformat/concatdec.c | 9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index 0603c6e254..f7067d5059 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -740,6 +740,7 @@ static int concat_read_packet(AVFormatContext *avf, 
AVPacket *pkt)
 ConcatStream *cs;
 AVStream *st;
 FFStream *sti;
+AVRational output_tb;

 if (cat->eof)
 return AVERROR_EOF;
@@ -782,13 +783,15 @@ static int concat_read_packet(AVFormatContext *avf, 
AVPacket *pkt)
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, >time_base),
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, >time_base));

+/* replace the pkt base on the time base of target output stream */
+output_tb = avf->streams[cs->out_stream_index]->time_base;
 delta = av_rescale_q(cat->cur_file->start_time - 
cat->cur_file->file_inpoint,
  AV_TIME_BASE_Q,
- cat->avf->streams[pkt->stream_index]->time_base);
+ output_tb);
 if (pkt->pts != AV_NOPTS_VALUE)
-pkt->pts += delta;
+pkt->pts = av_rescale_q(pkt->pts, st->time_base, output_tb) + delta;
 if (pkt->dts != AV_NOPTS_VALUE)
-pkt->dts += delta;
+pkt->dts = av_rescale_q(pkt->dts, st->time_base, output_tb) + delta;
 av_log(avf, AV_LOG_DEBUG, " -> pts:%s pts_time:%s dts:%s dts_time:%s\n",
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, >time_base),
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, >time_base));
--
2.30.1 (Apple Git-130)



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 2/2] avcodec: add pcm-bluray encoder

2022-02-28 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/pcm-blurayenc.c | 291 +
 3 files changed, 293 insertions(+)
 create mode 100644 libavcodec/pcm-blurayenc.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 6076b4ad80..e34a9ae862 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -800,6 +800,7 @@ OBJS-$(CONFIG_ZMBV_ENCODER)+= zmbvenc.o
 # (AD)PCM decoders/encoders
 OBJS-$(CONFIG_PCM_ALAW_DECODER)   += pcm.o
 OBJS-$(CONFIG_PCM_ALAW_ENCODER)   += pcm.o
+OBJS-$(CONFIG_PCM_BLURAY_ENCODER) += pcm-blurayenc.o
 OBJS-$(CONFIG_PCM_BLURAY_DECODER) += pcm-bluray.o
 OBJS-$(CONFIG_PCM_DVD_DECODER)+= pcm-dvd.o
 OBJS-$(CONFIG_PCM_DVD_ENCODER)+= pcm-dvdenc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index d1e10197de..1be67e3ec3 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -531,6 +531,7 @@ extern const AVCodec ff_xma2_decoder;
 /* PCM codecs */
 extern const AVCodec ff_pcm_alaw_encoder;
 extern const AVCodec ff_pcm_alaw_decoder;
+extern const AVCodec ff_pcm_bluray_encoder;
 extern const AVCodec ff_pcm_bluray_decoder;
 extern const AVCodec ff_pcm_dvd_encoder;
 extern const AVCodec ff_pcm_dvd_decoder;
diff --git a/libavcodec/pcm-blurayenc.c b/libavcodec/pcm-blurayenc.c
new file mode 100644
index 00..c7b6981454
--- /dev/null
+++ b/libavcodec/pcm-blurayenc.c
@@ -0,0 +1,291 @@
+/*
+ * LPCM codecs for PCM formats found in Blu-ray m2ts streams
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/channel_layout.h"
+#include "avcodec.h"
+#include "bytestream.h"
+#include "encode.h"
+#include "internal.h"
+
+typedef struct BlurayPCMEncContext {
+uint16_t header;  // Header added to every frame
+} BlurayPCMEncContext;
+
+static av_cold int pcm_bluray_encode_init(AVCodecContext *avctx)
+{
+BlurayPCMEncContext *s = avctx->priv_data;
+uint8_t ch_layout;
+int quant, freq;
+
+switch (avctx->sample_rate) {
+case 48000:
+freq = 1;
+break;
+case 96000:
+freq = 4;
+break;
+case 192000:
+freq = 5;
+break;
+}
+
+switch (avctx->sample_fmt) {
+case AV_SAMPLE_FMT_S16:
+avctx->bits_per_coded_sample = 16;
+quant = 1;
+break;
+case AV_SAMPLE_FMT_S32:
+avctx->bits_per_coded_sample = 24;
+quant = 3;
+break;
+}
+
+switch (avctx->channel_layout) {
+case AV_CH_LAYOUT_MONO:
+ch_layout = 1;
+break;
+case AV_CH_LAYOUT_STEREO:
+ch_layout = 3;
+break;
+case AV_CH_LAYOUT_SURROUND:
+ch_layout = 4;
+break;
+case AV_CH_LAYOUT_2_1:
+ch_layout = 5;
+break;
+case AV_CH_LAYOUT_4POINT0:
+ch_layout = 6;
+break;
+case AV_CH_LAYOUT_2_2:
+ch_layout = 7;
+break;
+case AV_CH_LAYOUT_5POINT0:
+ch_layout = 8;
+break;
+case AV_CH_LAYOUT_5POINT1:
+ch_layout = 9;
+break;
+case AV_CH_LAYOUT_7POINT0:
+ch_layout = 10;
+break;
+case AV_CH_LAYOUT_7POINT1:
+ch_layout = 11;
+break;
+default:
+return AVERROR_BUG;
+}
+
+s->header = (((ch_layout << 4) | freq) << 8) | (quant << 6);
+
+return 0;
+}
+
+static int pcm_bluray_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
+   const AVFrame *frame, int *got_packet_ptr)
+{
+BlurayPCMEncContext *s = avctx->priv_data;
+int sample_size, samples, channel, num_dest_channels;
+const int16_t *src16;
+const int32_t *src32;
+unsigned pkt_size;
+PutByteContext pb;
+int ret;
+
+num_dest_channels = FFALIGN(avctx->channels, 2);
+sample_size = (num_dest_channels *
+   (avctx->sample_fmt == AV_SAMPLE_FMT_S16 ? 16 : 24)) >> 3;
+samples = frame->nb_samples;
+
+pkt_size = sample_size * samples + 4;
+
+if ((ret = ff_get_encode_buffer(avctx, avpkt, pkt_size, 0)) < 0)
+return ret;
+
+AV_WB16(avpkt->data, pkt_size - 4);
+AV_WB16(avpkt->data + 2, s->header);
+
+src16 = (const int16_t *)frame->data[0];

[FFmpeg-devel] [PATCH 1/2] avformat/mpegtsenc: fix muxing pcm-bluray

2022-02-28 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavformat/mpegtsenc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 971b3f55d8..20dce56122 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -2097,6 +2097,10 @@ static int mpegts_write_packet_internal(AVFormatContext 
*s, AVPacket *pkt)
 ts_st->dvb_ac3_desc = dvb_ac3_desc;
 }
 av_free(hdr);
+} else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_BLURAY && 
ts->m2ts_mode) {
+mpegts_write_pes(s, st, buf, size, pts, dts,
+ pkt->flags & AV_PKT_FLAG_KEY, stream_id);
+return 0;
 }
 
 if (ts_st->payload_size && (ts_st->payload_size + size > 
ts->pes_payload_size ||
-- 
2.33.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v6 3/5] avcodec/libjxl: add Jpeg XL encoding via libjxl

2022-02-28 Thread Leo Izen
This commit adds encoding support to libavcodec
for Jpeg XL images via the external library libjxl.
---
 configure  |   3 +-
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libjxlenc.c | 383 +
 4 files changed, 387 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/libjxlenc.c

diff --git a/configure b/configure
index 15ab437472..0731308a67 100755
--- a/configure
+++ b/configure
@@ -240,7 +240,7 @@ External library support:
   --enable-libiec61883 enable iec61883 via libiec61883 [no]
   --enable-libilbc enable iLBC de/encoding via libilbc [no]
   --enable-libjack enable JACK audio sound server [no]
-  --enable-libjxl  enable JPEG XL decoding via libjxl [no]
+  --enable-libjxl  enable JPEG XL de/encoding via libjxl [no]
   --enable-libklvanc   enable Kernel Labs VANC processing [no]
   --enable-libkvazaar  enable HEVC encoding via libkvazaar [no]
   --enable-liblensfun  enable lensfun lens correction [no]
@@ -3326,6 +3326,7 @@ libgsm_ms_encoder_deps="libgsm"
 libilbc_decoder_deps="libilbc"
 libilbc_encoder_deps="libilbc"
 libjxl_decoder_deps="libjxl libjxl_threads"
+libjxl_encoder_deps="libjxl libjxl_threads"
 libkvazaar_encoder_deps="libkvazaar"
 libmodplug_demuxer_deps="libmodplug"
 libmp3lame_encoder_deps="libmp3lame"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index dbc25fad85..47cf33e9b5 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1054,6 +1054,7 @@ OBJS-$(CONFIG_LIBGSM_MS_ENCODER)  += libgsmenc.o
 OBJS-$(CONFIG_LIBILBC_DECODER)+= libilbc.o
 OBJS-$(CONFIG_LIBILBC_ENCODER)+= libilbc.o
 OBJS-$(CONFIG_LIBJXL_DECODER) += libjxldec.o libjxl.o
+OBJS-$(CONFIG_LIBJXL_ENCODER) += libjxlenc.o libjxl.o
 OBJS-$(CONFIG_LIBKVAZAAR_ENCODER) += libkvazaar.o
 OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o
 OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER)  += libopencore-amr.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index b41da3b0de..2e50991652 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -745,6 +745,7 @@ extern const AVCodec ff_libgsm_ms_decoder;
 extern const AVCodec ff_libilbc_encoder;
 extern const AVCodec ff_libilbc_decoder;
 extern const AVCodec ff_libjxl_decoder;
+extern const AVCodec ff_libjxl_encoder;
 extern const AVCodec ff_libmp3lame_encoder;
 extern const AVCodec ff_libopencore_amrnb_encoder;
 extern const AVCodec ff_libopencore_amrnb_decoder;
diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c
new file mode 100644
index 00..987661061a
--- /dev/null
+++ b/libavcodec/libjxlenc.c
@@ -0,0 +1,383 @@
+/*
+ * JPEG XL encoding support via libjxl
+ * Copyright (c) 2021 Leo Izen 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * JPEG XL encoder using libjxl
+ */
+
+#include "libavutil/avutil.h"
+#include "libavutil/error.h"
+#include "libavutil/frame.h"
+#include "libavutil/libm.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/pixfmt.h"
+#include "libavutil/version.h"
+
+#include "avcodec.h"
+#include "internal.h"
+
+#include 
+#include 
+#include "libjxl.h"
+
+typedef struct LibJxlEncodeContext {
+AVClass *class;
+void *runner;
+JxlEncoder *encoder;
+JxlEncoderFrameSettings *options;
+int effort;
+float distance;
+int modular;
+uint8_t *buffer;
+size_t buffer_size;
+} LibJxlEncodeContext;
+
+/**
+ * Map a quality setting for -qscale roughly from libjpeg
+ * quality numbers to libjxl's butteraugli distance for
+ * photographic content.
+ *
+ * Setting distance explicitly is preferred, but this will
+ * allow qscale to be used as a fallback.
+ *
+ * This function is continuous and injective on [0, 100] which
+ * makes it monotonic.
+ *
+ * @param  quality 0.0 to 100.0 quality setting, libjpeg quality
+ * @return Butteraugli distance between 0.0 and 15.0
+ */
+static float quality_to_distance(float quality){
+if (quality >= 100.0) {
+return 0.0;
+} else if (quality >= 90.0) {
+return (100.0 - quality) * 0.10;
+} else if (quality >= 30.0) {
+return 0.1 + (100.0 - quality) * 0.09;

[FFmpeg-devel] [PATCH v6 2/5] avcodec/libjxl: add Jpeg XL decoding via libjxl

2022-02-28 Thread Leo Izen
This commit adds decoding support to libavcodec
for Jpeg XL images via the external library libjxl.
---
 MAINTAINERS   |   1 +
 configure |   5 +
 doc/general_contents.texi |   7 +
 libavcodec/Makefile   |   1 +
 libavcodec/allcodecs.c|   1 +
 libavcodec/libjxl.c   |  70 ++
 libavcodec/libjxl.h   |  48 +++
 libavcodec/libjxldec.c| 276 ++
 8 files changed, 409 insertions(+)
 create mode 100644 libavcodec/libjxl.c
 create mode 100644 libavcodec/libjxl.h
 create mode 100644 libavcodec/libjxldec.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 3e9e6f4d3e..89cf3b8c82 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -194,6 +194,7 @@ Codecs:
   libcodec2.c   Tomas Härdin
   libdirac* David Conrad
   libdavs2.cHuiwen Ren
+  libjxl*.c, libjxl.h   Leo Izen
   libgsm.c  Michel Bardiaux
   libkvazaar.c  Arttu Ylä-Outinen
   libopenh264enc.c  Martin Storsjo, Linjie Fu
diff --git a/configure b/configure
index 8c69ab0c86..15ab437472 100755
--- a/configure
+++ b/configure
@@ -240,6 +240,7 @@ External library support:
   --enable-libiec61883 enable iec61883 via libiec61883 [no]
   --enable-libilbc enable iLBC de/encoding via libilbc [no]
   --enable-libjack enable JACK audio sound server [no]
+  --enable-libjxl  enable JPEG XL decoding via libjxl [no]
   --enable-libklvanc   enable Kernel Labs VANC processing [no]
   --enable-libkvazaar  enable HEVC encoding via libkvazaar [no]
   --enable-liblensfun  enable lensfun lens correction [no]
@@ -1832,6 +1833,7 @@ EXTERNAL_LIBRARY_LIST="
 libiec61883
 libilbc
 libjack
+libjxl
 libklvanc
 libkvazaar
 libmodplug
@@ -3323,6 +3325,7 @@ libgsm_ms_decoder_deps="libgsm"
 libgsm_ms_encoder_deps="libgsm"
 libilbc_decoder_deps="libilbc"
 libilbc_encoder_deps="libilbc"
+libjxl_decoder_deps="libjxl libjxl_threads"
 libkvazaar_encoder_deps="libkvazaar"
 libmodplug_demuxer_deps="libmodplug"
 libmp3lame_encoder_deps="libmp3lame"
@@ -6534,6 +6537,8 @@ enabled libgsm&& { for gsm_hdr in "gsm.h" 
"gsm/gsm.h"; do
check_lib libgsm "${gsm_hdr}" gsm_create 
-lgsm && break;
done || die "ERROR: libgsm not found"; }
 enabled libilbc   && require libilbc ilbc.h WebRtcIlbcfix_InitDecode 
-lilbc $pthreads_extralibs
+enabled libjxl&& require_pkg_config libjxl "libjxl >= 0.7.0" 
jxl/decode.h JxlDecoderVersion &&
+ require_pkg_config libjxl_threads "libjxl_threads 
>= 0.7.0" jxl/thread_parallel_runner.h JxlThreadParallelRunner
 enabled libklvanc && require libklvanc libklvanc/vanc.h 
klvanc_context_create -lklvanc
 enabled libkvazaar&& require_pkg_config libkvazaar "kvazaar >= 0.8.1" 
kvazaar.h kvz_api_get
 enabled liblensfun&& require_pkg_config liblensfun lensfun lensfun.h 
lf_db_new
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index df1692c8df..2778e20091 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -171,6 +171,13 @@ Go to @url{https://github.com/TimothyGu/libilbc} and 
follow the instructions for
 installing the library. Then pass @code{--enable-libilbc} to configure to
 enable it.
 
+@section libjxl
+
+JPEG XL is an image format intended to fully replace legacy JPEG for an 
extended
+period of life. See @url{https://jpegxl.info/} for more information, and see
+@url{https://github.com/libjxl/libjxl} for the library source. You can pass
+@code{--enable-libjxl} to configure in order enable the libjxl wrapper.
+
 @section libvpx
 
 FFmpeg can make use of the libvpx library for VP8/VP9 decoding and encoding.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3707209699..dbc25fad85 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1053,6 +1053,7 @@ OBJS-$(CONFIG_LIBGSM_MS_DECODER)  += libgsmdec.o
 OBJS-$(CONFIG_LIBGSM_MS_ENCODER)  += libgsmenc.o
 OBJS-$(CONFIG_LIBILBC_DECODER)+= libilbc.o
 OBJS-$(CONFIG_LIBILBC_ENCODER)+= libilbc.o
+OBJS-$(CONFIG_LIBJXL_DECODER) += libjxldec.o libjxl.o
 OBJS-$(CONFIG_LIBKVAZAAR_ENCODER) += libkvazaar.o
 OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o
 OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER)  += libopencore-amr.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index d1e10197de..b41da3b0de 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -744,6 +744,7 @@ extern const AVCodec ff_libgsm_ms_encoder;
 extern const AVCodec ff_libgsm_ms_decoder;
 extern const AVCodec ff_libilbc_encoder;
 extern const AVCodec ff_libilbc_decoder;
+extern const AVCodec ff_libjxl_decoder;
 extern const AVCodec ff_libmp3lame_encoder;
 extern const AVCodec 

[FFmpeg-devel] [PATCH v6 5/5] fate/jpegxl: add JPEG XL demux and parse FATE test

2022-02-28 Thread Leo Izen
Add a fate test for the JPEG XL parser in libavcodec and
its image2 wrapper inside libavformat.
---
 tests/fate/image.mak| 10 ++
 tests/ref/fate/jxl-parse-codestream |  6 ++
 tests/ref/fate/jxl-parse-container  |  6 ++
 3 files changed, 22 insertions(+)
 create mode 100644 tests/ref/fate/jxl-parse-codestream
 create mode 100644 tests/ref/fate/jxl-parse-container

diff --git a/tests/fate/image.mak b/tests/fate/image.mak
index 573d398915..15b6145c58 100644
--- a/tests/fate/image.mak
+++ b/tests/fate/image.mak
@@ -357,6 +357,16 @@ FATE_JPEGLS-$(call DEMDEC, IMAGE2, JPEGLS) += 
$(FATE_JPEGLS)
 FATE_IMAGE += $(FATE_JPEGLS-yes)
 fate-jpegls: $(FATE_JPEGLS-yes)
 
+FATE_JPEGXL += fate-jxl-parse-codestream
+fate-jxl-parse-codestream: CMD = framecrc -i $(TARGET_SAMPLES)/jxl/belgium.jxl 
-c:v copy
+
+FATE_JPEGXL += fate-jxl-parse-container
+fate-jxl-parse-container: CMD = framecrc -i 
$(TARGET_SAMPLES)/jxl/lenna-256.jxl -c:v copy
+
+FATE_JPEGXL-$(call DEMDEC, IMAGE2) += $(FATE_JPEGXL)
+FATE_IMAGE += $(FATE_JPEGXL-yes)
+fate-jxl: $(FATE_JPEGXL-yes)
+
 FATE_IMAGE-$(call DEMDEC, IMAGE2, QDRAW) += fate-pict
 fate-pict: CMD = framecrc -i $(TARGET_SAMPLES)/quickdraw/TRU256.PCT -pix_fmt 
rgb24
 
diff --git a/tests/ref/fate/jxl-parse-codestream 
b/tests/ref/fate/jxl-parse-codestream
new file mode 100644
index 00..b2fe5035ac
--- /dev/null
+++ b/tests/ref/fate/jxl-parse-codestream
@@ -0,0 +1,6 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: jpegxl
+#dimensions 0: 768x512
+#sar 0: 0/1
+0,  0,  0,1,   32, 0xa2930a20
diff --git a/tests/ref/fate/jxl-parse-container 
b/tests/ref/fate/jxl-parse-container
new file mode 100644
index 00..99233d612a
--- /dev/null
+++ b/tests/ref/fate/jxl-parse-container
@@ -0,0 +1,6 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: jpegxl
+#dimensions 0: 256x256
+#sar 0: 0/1
+0,  0,  0,1, 8088, 0xbbfea9bd
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v6 4/5] avformat/image2: add Jpeg XL as image2 format

2022-02-28 Thread Leo Izen
This commit adds support to libavformat for muxing
and demuxing Jpeg XL images as image2 streams.
---
 libavformat/allformats.c |  1 +
 libavformat/img2.c   |  1 +
 libavformat/img2dec.c| 26 ++
 libavformat/img2enc.c|  6 +++---
 libavformat/mov.c|  1 +
 libavformat/version.h|  4 ++--
 6 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d066a7745b..24e0dd3389 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -508,6 +508,7 @@ extern const AVInputFormat  ff_image_gif_pipe_demuxer;
 extern const AVInputFormat  ff_image_j2k_pipe_demuxer;
 extern const AVInputFormat  ff_image_jpeg_pipe_demuxer;
 extern const AVInputFormat  ff_image_jpegls_pipe_demuxer;
+extern const AVInputFormat  ff_image_jpegxl_pipe_demuxer;
 extern const AVInputFormat  ff_image_pam_pipe_demuxer;
 extern const AVInputFormat  ff_image_pbm_pipe_demuxer;
 extern const AVInputFormat  ff_image_pcx_pipe_demuxer;
diff --git a/libavformat/img2.c b/libavformat/img2.c
index 4153102c92..13b1b997b8 100644
--- a/libavformat/img2.c
+++ b/libavformat/img2.c
@@ -87,6 +87,7 @@ const IdStrMap ff_img_tags[] = {
 { AV_CODEC_ID_GEM,"img"  },
 { AV_CODEC_ID_GEM,"ximg" },
 { AV_CODEC_ID_GEM,"timg" },
+{ AV_CODEC_ID_JPEGXL, "jxl"  },
 { AV_CODEC_ID_NONE,   NULL   }
 };
 
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 8608252d83..33818e256a 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -30,6 +30,9 @@
 #include "libavutil/parseutils.h"
 #include "libavutil/intreadwrite.h"
 #include "libavcodec/gif.h"
+#if CONFIG_JPEGXL_PARSER
+#include "libavcodec/jpegxl.h"
+#endif /* CONFIG_JPEGXL_PARSER */
 #include "avformat.h"
 #include "avio_internal.h"
 #include "internal.h"
@@ -834,6 +837,26 @@ static int jpegls_probe(const AVProbeData *p)
 return 0;
 }
 
+#if CONFIG_JPEGXL_PARSER
+static int jpegxl_probe(const AVProbeData *p)
+{
+const uint8_t *b = p->buf;
+
+/* ISOBMFF-based container */
+/* 0x4a584c20 == "JXL " */
+if (AV_RL64(b) == FF_JPEGXL_CONTAINER_SIGNATURE_LE)
+return AVPROBE_SCORE_EXTENSION + 1;
+/* Raw codestreams all start with 0xff0a */
+if (AV_RL16(b) != FF_JPEGXL_CODESTREAM_SIGNATURE_LE)
+return 0;
+if (avpriv_jpegxl_verify_codestream_header(NULL, p->buf, p->buf_size, 5) 
== 0)
+return AVPROBE_SCORE_MAX - 2;
+else
+return 0;
+}
+#endif /* CONFIG_JPEGXL_PARSER */
+
+
 static int pcx_probe(const AVProbeData *p)
 {
 const uint8_t *b = p->buf;
@@ -1163,6 +1186,9 @@ IMAGEAUTO_DEMUXER(gif,   GIF)
 IMAGEAUTO_DEMUXER_EXT(j2k,   JPEG2000, J2K)
 IMAGEAUTO_DEMUXER_EXT(jpeg,  MJPEG, JPEG)
 IMAGEAUTO_DEMUXER(jpegls,JPEGLS)
+#if CONFIG_JPEGXL_PARSER
+IMAGEAUTO_DEMUXER(jpegxl,JPEGXL)
+#endif /* CONFIG_JPEGXL_PARSER */
 IMAGEAUTO_DEMUXER(pam,   PAM)
 IMAGEAUTO_DEMUXER(pbm,   PBM)
 IMAGEAUTO_DEMUXER(pcx,   PCX)
diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index ded91d6b98..6ac430c6dd 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -261,9 +261,9 @@ static const AVClass img2mux_class = {
 const AVOutputFormat ff_image2_muxer = {
 .name   = "image2",
 .long_name  = NULL_IF_CONFIG_SMALL("image2 sequence"),
-.extensions = 
"bmp,dpx,exr,jls,jpeg,jpg,ljpg,pam,pbm,pcx,pfm,pgm,pgmyuv,png,"
-  
"ppm,sgi,tga,tif,tiff,jp2,j2c,j2k,xwd,sun,ras,rs,im1,im8,im24,"
-  "sunras,xbm,xface,pix,y",
+.extensions = 
"bmp,dpx,exr,jls,jpeg,jpg,jxl,ljpg,pam,pbm,pcx,pfm,pgm,pgmyuv,"
+  
"png,ppm,sgi,tga,tif,tiff,jp2,j2c,j2k,xwd,sun,ras,rs,im1,im8,"
+  "im24,sunras,xbm,xface,pix,y",
 .priv_data_size = sizeof(VideoMuxData),
 .video_codec= AV_CODEC_ID_MJPEG,
 .write_header   = write_header,
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 5e26267810..dbe6c85105 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7435,6 +7435,7 @@ static int mov_probe(const AVProbeData *p)
 if (tag == MKTAG('f','t','y','p') &&
(   AV_RL32(p->buf + offset + 8) == MKTAG('j','p','2',' 
')
 || AV_RL32(p->buf + offset + 8) == MKTAG('j','p','x',' 
')
+|| AV_RL32(p->buf + offset + 8) == MKTAG('j','x','l',' 
')
 )) {
 score = FFMAX(score, 5);
 } else {
diff --git a/libavformat/version.h b/libavformat/version.h
index 26234573b8..0f89af47e6 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,8 +32,8 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  59
-#define LIBAVFORMAT_VERSION_MINOR  17
-#define LIBAVFORMAT_VERSION_MICRO 102

[FFmpeg-devel] [PATCH v6 1/5] avcodec/jpegxl: add Jpeg XL image codec and parser

2022-02-28 Thread Leo Izen
This commit adds support to libavcodec to read and parse
encoded Jpeg XL images. Jpeg XL is intended to be an
extended-life replacement to legacy mjpeg.
---
 MAINTAINERS|   2 +
 libavcodec/Makefile|   1 +
 libavcodec/codec_desc.c|   9 +
 libavcodec/codec_id.h  |   1 +
 libavcodec/jpegxl.h|  43 ++
 libavcodec/jpegxl_parser.c | 925 +
 libavcodec/parsers.c   |   1 +
 libavcodec/version.h   |   4 +-
 8 files changed, 984 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/jpegxl.h
 create mode 100644 libavcodec/jpegxl_parser.c

diff --git a/MAINTAINERS b/MAINTAINERS
index f33ccbd1d9..3e9e6f4d3e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -187,6 +187,7 @@ Codecs:
   interplayvideo.c  Mike Melanson
   jni*, ffjni*  Matthieu Bouron
   jpeg2000* Nicolas Bertrand
+  jpegxl.h, jpegxl_parser.c Leo Izen
   jvdec.c   Peter Ross
   lcl*.cRoberto Togni, Reimar Doeffinger
   libcelt_dec.c Nicolas George
@@ -614,6 +615,7 @@ Haihao Xiang (haihao) 1F0C 31E8 B4FE F7A4 4DC1 DC99 
E0F5 76D4 76FC 437F
 Jaikrishnan Menon 61A1 F09F 01C9 2D45 78E1 C862 25DC 8831 AF70 D368
 James Almer   7751 2E8C FD94 A169 57E6 9A7A 1463 01AD 7376 59E0
 Jean Delvare  7CA6 9F44 60F1 BDC4 1FD2 C858 A552 6B9B B3CD 4E6A
+Leo Izen (thebombzen) B6FD 3CFC 7ACF 83FC 9137 6945 5A71 C331 FD2F A19A
 Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE
 Lynne FE50 139C 6805 72CA FD52 1F8D A2FE A5F0 3F03 4464
 Michael Niedermayer   9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 6076b4ad80..3707209699 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -43,6 +43,7 @@ OBJS = ac3_parser.o   
  \
dv_profile.o \
encode.o \
imgconvert.o \
+   jpegxl_parser.o  \
jni.o\
mathtables.o \
mediacodec.o \
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 725c687b00..475b41914b 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1863,6 +1863,15 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("GEM Raster image"),
 .props = AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_JPEGXL,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "jpegxl",
+.long_name = NULL_IF_CONFIG_SMALL("JPEG XL"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
+ AV_CODEC_PROP_LOSSLESS,
+.mime_types= MT("image/jxl"),
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index ab265ec584..551a516446 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -308,6 +308,7 @@ enum AVCodecID {
 AV_CODEC_ID_SIMBIOSIS_IMX,
 AV_CODEC_ID_SGA_VIDEO,
 AV_CODEC_ID_GEM,
+AV_CODEC_ID_JPEGXL,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/jpegxl.h b/libavcodec/jpegxl.h
new file mode 100644
index 00..bf2c1999c8
--- /dev/null
+++ b/libavcodec/jpegxl.h
@@ -0,0 +1,43 @@
+/*
+ * JPEG XL header
+ * Copyright (c) 2021 Leo Izen 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * JPEG XL header
+ */
+
+#ifndef AVCODEC_JPEGXL_H
+#define AVCODEC_JPEGXL_H
+
+#include 
+
+/* these are also used in avformat/img2dec.c */
+#define FF_JPEGXL_CODESTREAM_SIGNATURE_LE 0x0aff
+#define 

Re: [FFmpeg-devel] [PATCH] lavu: make av_get_media_type_string() never return NULL

2022-02-28 Thread Scott Theisen

On 2/23/22 02:52, Anton Khirnov wrote:

Quoting Andreas Rheinhardt (2022-02-02 03:13:12)

Who sets invalid media types?
(In case of fftools/*: If they don't set it themselves, they (and all
our users) should be able to rely on our libraries to not set invalid
values. The same goes for all demuxers (as they set this value
themselves). Checks are only necessary where the media type comes from
the user; this means muxers (where the check should be done generically)
and possibly avfiltergraph.c (I am pretty sure that the type has already
been checked earlier for filters).)

Some demuxer code in lavf looks like it might result in a TYPE_UNKNOWN
AVStream. E.g. argo_brp, avi, both asfdecs, gxf.


Also, in libavcodec/codec_desc.c, avcodec_get_type(AV_CODEC_ID_NONE) 
will return AVMEDIA_TYPE_UNKNOWN.  The mpegts demuxer, for example, will 
set (or more likely leave) AV_CODEC_ID_NONE as the AVCodecID of a stream 
if it can't identify the codec.  This is probably true of all demuxers.


-Scott Theisen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/setts_bsf: add an option to set output time base

2022-02-28 Thread Paul B Mahol
lgtm
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/setts_bsf: stop repeatedly setting values that don't change between packets

2022-02-28 Thread Paul B Mahol
lgtm
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 2/2] avcodec: add pcm-bluray encoder

2022-02-28 Thread Michael Niedermayer
On Sat, Feb 26, 2022 at 08:31:43PM +0100, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/Makefile|   1 +
>  libavcodec/allcodecs.c |   1 +
>  libavcodec/pcm-blurayenc.c | 291 +
>  3 files changed, 293 insertions(+)
>  create mode 100644 libavcodec/pcm-blurayenc.c
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 6076b4ad80..e34a9ae862 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -800,6 +800,7 @@ OBJS-$(CONFIG_ZMBV_ENCODER)+= zmbvenc.o
>  # (AD)PCM decoders/encoders
>  OBJS-$(CONFIG_PCM_ALAW_DECODER)   += pcm.o
>  OBJS-$(CONFIG_PCM_ALAW_ENCODER)   += pcm.o
> +OBJS-$(CONFIG_PCM_BLURAY_ENCODER) += pcm-blurayenc.o
>  OBJS-$(CONFIG_PCM_BLURAY_DECODER) += pcm-bluray.o
>  OBJS-$(CONFIG_PCM_DVD_DECODER)+= pcm-dvd.o
>  OBJS-$(CONFIG_PCM_DVD_ENCODER)+= pcm-dvdenc.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index d1e10197de..1be67e3ec3 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -531,6 +531,7 @@ extern const AVCodec ff_xma2_decoder;
>  /* PCM codecs */
>  extern const AVCodec ff_pcm_alaw_encoder;
>  extern const AVCodec ff_pcm_alaw_decoder;
> +extern const AVCodec ff_pcm_bluray_encoder;
>  extern const AVCodec ff_pcm_bluray_decoder;
>  extern const AVCodec ff_pcm_dvd_encoder;
>  extern const AVCodec ff_pcm_dvd_decoder;
> diff --git a/libavcodec/pcm-blurayenc.c b/libavcodec/pcm-blurayenc.c
> new file mode 100644
> index 00..9201ad9690
> --- /dev/null
> +++ b/libavcodec/pcm-blurayenc.c
> @@ -0,0 +1,291 @@
> +/*
> + * LPCM codecs for PCM formats found in Blu-ray m2ts streams
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include "libavutil/channel_layout.h"
> +#include "avcodec.h"
> +#include "bytestream.h"
> +#include "encode.h"
> +#include "internal.h"
> +
> +typedef struct BlurayPCMEncContext {
> +uint16_t header;  // Header added to every frame
> +} BlurayPCMEncContext;
> +
> +static av_cold int pcm_bluray_encode_init(AVCodecContext *avctx)
> +{
> +BlurayPCMEncContext *s = avctx->priv_data;
> +uint8_t ch_layout;
> +int quant, freq;
> +
> +switch (avctx->sample_rate) {
> +case 48000:
> +freq = 1;
> +break;
> +case 96000:
> +freq = 4;
> +break;
> +case 192000:
> +freq = 5;
> +break;
> +}
> +
> +switch (avctx->sample_fmt) {
> +case AV_SAMPLE_FMT_S16:
> +avctx->bits_per_coded_sample = 16;
> +quant = 1;
> +break;
> +case AV_SAMPLE_FMT_S32:
> +avctx->bits_per_coded_sample = 24;
> +quant = 3;
> +break;
> +}
> +
> +switch (avctx->channel_layout) {
> +case AV_CH_LAYOUT_MONO:
> +ch_layout = 1;
> +break;
> +case AV_CH_LAYOUT_STEREO:
> +ch_layout = 3;
> +break;
> +case AV_CH_LAYOUT_SURROUND:
> +ch_layout = 4;
> +break;
> +case AV_CH_LAYOUT_2_1:
> +ch_layout = 5;
> +break;
> +case AV_CH_LAYOUT_4POINT0:
> +ch_layout = 6;
> +break;
> +case AV_CH_LAYOUT_2_2:
> +ch_layout = 7;
> +break;
> +case AV_CH_LAYOUT_5POINT0:
> +ch_layout = 8;
> +break;
> +case AV_CH_LAYOUT_5POINT1:
> +ch_layout = 9;
> +break;
> +case AV_CH_LAYOUT_7POINT0:
> +ch_layout = 10;
> +break;
> +case AV_CH_LAYOUT_7POINT1:
> +ch_layout = 11;
> +break;
> +default:
> +return AVERROR_BUG;
> +}
> +
> +s->header = (((ch_layout << 4) | freq) << 8) | (quant << 6);
> +
> +return 0;
> +}
> +
> +static int pcm_bluray_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
> +   const AVFrame *frame, int *got_packet_ptr)
> +{
> +BlurayPCMEncContext *s = avctx->priv_data;
> +int sample_size, samples, channel, num_dest_channels;
> +const int16_t *src16;
> +const int32_t *src32;
> +unsigned pkt_size;
> +PutByteContext pb;
> +int ret;
> +
> +num_dest_channels = FFALIGN(avctx->channels, 2);
> +sample_size = (num_dest_channels *
> +

Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vf_tpad: if there is no frame to clone return early

2022-02-28 Thread Thierry Foucu
On Sun, Feb 27, 2022 at 3:54 AM Paul B Mahol  wrote:

> On Fri, Feb 25, 2022 at 10:08 PM Thierry Foucu  wrote:
>
> > On Thu, Feb 24, 2022 at 11:50 PM Paul B Mahol  wrote:
> >
> > > On Thu, Feb 24, 2022 at 11:21 PM Thierry Foucu 
> wrote:
> > >
> > > > On Thu, Feb 24, 2022 at 2:19 PM Thierry Foucu 
> > wrote:
> > > >
> > > > >
> > > > >
> > > > > On Thu, Feb 24, 2022 at 1:50 PM Paul B Mahol 
> > wrote:
> > > > >
> > > > >> On Thu, Feb 24, 2022 at 10:36 PM Thierry Foucu 
> > > > wrote:
> > > > >>
> > > > >> > On Thu, Feb 24, 2022 at 1:28 PM Paul B Mahol 
> > > > wrote:
> > > > >> >
> > > > >> > > On Thu, Feb 24, 2022 at 10:12 PM Thierry Foucu <
> > tfo...@gmail.com>
> > > > >> wrote:
> > > > >> > >
> > > > >> > > > On Thu, Feb 24, 2022 at 12:30 PM Paul B Mahol <
> > g...@videolan.org
> > > >
> > > > >> > wrote:
> > > > >> > > >
> > > > >> > > > > ffmpeg | branch: master | Paul B Mahol 
> |
> > > Thu
> > > > >> Feb
> > > > >> > 24
> > > > >> > > > > 20:32:41 2022 +0100|
> > > [3715f2f8643695940582ce040b7a052cccfb9db2]
> > > > |
> > > > >> > > > > committer: Paul B Mahol
> > > > >> > > > >
> > > > >> > > > > avfilter/vf_tpad: if there is no frame to clone return
> early
> > > > >> > > > >
> > > > >> > > > > >
> > > > >> > > > >
> > > > >> > > >
> > > > >> > >
> > > > >> >
> > > > >>
> > > >
> > >
> >
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3715f2f8643695940582ce040b7a052cccfb9db2
> > > > >> > > > > ---
> > > > >> > > > >
> > > > >> > > > >  libavfilter/vf_tpad.c | 5 +
> > > > >> > > > >  1 file changed, 5 insertions(+)
> > > > >> > > > >
> > > > >> > > > > diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
> > > > >> > > > > index e5acece1e4..120dbcb4d3 100644
> > > > >> > > > > --- a/libavfilter/vf_tpad.c
> > > > >> > > > > +++ b/libavfilter/vf_tpad.c
> > > > >> > > > > @@ -148,6 +148,11 @@ static int activate(AVFilterContext
> > *ctx)
> > > > >> > > > >frame->data,
> frame->linesize,
> > > > >> > > > >0, 0, frame->width,
> > > > frame->height);
> > > > >> > > > >  } else if (s->stop_mode == 1) {
> > > > >> > > > > +if (!s->cache_stop) {
> > > > >> > > > > +s->pad_stop = 0;
> > > > >> > > > > +ff_outlink_set_status(outlink,
> AVERROR_EOF,
> > > > >> s->pts);
> > > > >> > > > > +return 0;
> > > > >> > > > > +}
> > > > >> > > > >  frame = av_frame_clone(s->cache_stop);
> > > > >> > > > >  if (!frame)
> > > > >> > > > >  return AVERROR(ENOMEM);
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > > The problem with this solution is that the tpad will then
> not
> > do
> > > > >> what
> > > > >> > we
> > > > >> > > > are expecting, which is padding video track, and the output
> > file
> > > > >> will
> > > > >> > not
> > > > >> > > > have the desired duration.
> > > > >> > > > Will it not be better to just output black frame (aka
> > stop_mode
> > > ==
> > > > >> 0) ,
> > > > >> > > > something like that?
> > > > >> > > >
> > > > >> > >
> > > > >> > > I doubt that, clone is clone, there is no point in padding
> > stream
> > > > that
> > > > >> > have
> > > > >> > > no frames at all.
> > > > >> > >
> > > > >> > >
> > > > >> > >
> > > > >> > The sample I forwarded to JB has video frames. The problem was
> > that
> > > > >> there
> > > > >> > was a re-init of the filter chain after a resolution change and
> > > after
> > > > >> the
> > > > >> > re-init, there were no frames but got frames before the re-init.
> > > > >> > I will understand for a media file which has NEVER received a
> > video
> > > > >> frame
> > > > >> > and in this case, this is the correct solution.
> > > > >> >
> > > > >>
> > > > >> Hmm, so you encode output with resolution change, why not use
> scale
> > > > filter
> > > > >> as first filter and then no resolution ever change for rest of
> > graph?
> > > > >> Adding support for resolution changes to all filters is very time
> > > > >> consuming
> > > > >> task and I see no real benefit in doing that now.
> > > > >>
> > > > >
> > > > > We do have the scale filter in front of the tpad filter. Here is
> the
> > > > > filter chain we are using
> > > > >
> > > > >
> > > >
> > >
> >
> idet=1.04:1.5,yadif=0:-1:1,scale=+528:+864:flags=bicubic,setsar=1,fps=fps=16.601,tpad=stop_mode=clone:stop_duration=2808ms
> > > > >
> > > >
> > >
> > > Is this just increasing size instead of setting constant one?
> > >
> >
> > Nope. It will just scale the video to 528x864
> >
>
> Then why filter is still reinited then?
> Looks like serious bug to me.
>

Here is the verbose log when running ffmpeg with the filter chain. The
input resolution went from 1280x692 then changed to 1280x720 followed by
1280x718
And from the log, it is clear that the filter chain is being re-initialize.

Input #0, matroska,webm, from '/tmp/crash_tpad':
  Metadata:
ENCODER : Lavf58.76.100
  Duration: 00:08:07.44, start: 

[FFmpeg-devel] [PATCH 2/2] avcodec/setts_bsf: add an option to set output time base

2022-02-28 Thread James Almer
And a relevant constant to use it in expressions.

Signed-off-by: James Almer 
---
 doc/bitstream_filters.texi |  3 +++
 libavcodec/setts_bsf.c | 11 ++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 87c984185d..b11d357941 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -800,6 +800,9 @@ The next input duration.
 @item TB
 The timebase of stream packet belongs.
 
+@item TB_OUT
+The output timebase.
+
 @item SR
 The sample rate of stream packet belongs.
 
diff --git a/libavcodec/setts_bsf.c b/libavcodec/setts_bsf.c
index d574449838..e2c1997d0c 100644
--- a/libavcodec/setts_bsf.c
+++ b/libavcodec/setts_bsf.c
@@ -47,7 +47,8 @@ static const char *const var_names[] = {
 "DURATION",///< original duration in the file of the frame
 "STARTPTS",///< PTS at start of movie
 "STARTDTS",///< DTS at start of movie
-"TB",  ///< timebase of the stream
+"TB",  ///< input timebase of the stream
+"TB_OUT",  ///< output timebase of the stream
 "SR",  ///< sample rate of the stream
 "NOPTS",   ///< The AV_NOPTS_VALUE constant
 NULL
@@ -72,6 +73,7 @@ enum var_name {
 VAR_STARTPTS,
 VAR_STARTDTS,
 VAR_TB,
+VAR_TB_OUT,
 VAR_SR,
 VAR_NOPTS,
 VAR_VARS_NB
@@ -90,6 +92,8 @@ typedef struct SetTSContext {
 int64_t start_pts;
 int64_t start_dts;
 
+AVRational time_base;
+
 double var_values[VAR_VARS_NB];
 
 AVExpr *ts_expr;
@@ -141,11 +145,15 @@ static int setts_init(AVBSFContext *ctx)
 }
 }
 
+if (s->time_base.den)
+ctx->time_base_out = s->time_base;
+
 s->frame_number= 0;
 s->start_pts   = AV_NOPTS_VALUE;
 s->start_dts   = AV_NOPTS_VALUE;
 s->var_values[VAR_NOPTS] = AV_NOPTS_VALUE;
 s->var_values[VAR_TB]= ctx->time_base_in.den ? 
av_q2d(ctx->time_base_in) : 0;
+s->var_values[VAR_TB_OUT]= ctx->time_base_out.den ? 
av_q2d(ctx->time_base_out) : 0;
 s->var_values[VAR_SR]= ctx->par_in->sample_rate;
 
 return 0;
@@ -251,6 +259,7 @@ static const AVOption options[] = {
 { "pts", "set expression for packet PTS", OFFSET(pts_str), 
AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
 { "dts", "set expression for packet DTS", OFFSET(dts_str), 
AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
 { "duration", "set expression for packet duration", OFFSET(duration_str), 
AV_OPT_TYPE_STRING, {.str="DURATION"}, 0, 0, FLAGS },
+{ "time_base", "set output timebase", OFFSET(time_base), 
AV_OPT_TYPE_RATIONAL, {.dbl=0}, 0, 0, FLAGS },
 { NULL },
 };
 
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 1/2] avcodec/setts_bsf: stop repeatedly setting values that don't change between packets

2022-02-28 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/setts_bsf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/setts_bsf.c b/libavcodec/setts_bsf.c
index eadc4e4d34..d574449838 100644
--- a/libavcodec/setts_bsf.c
+++ b/libavcodec/setts_bsf.c
@@ -145,6 +145,8 @@ static int setts_init(AVBSFContext *ctx)
 s->start_pts   = AV_NOPTS_VALUE;
 s->start_dts   = AV_NOPTS_VALUE;
 s->var_values[VAR_NOPTS] = AV_NOPTS_VALUE;
+s->var_values[VAR_TB]= ctx->time_base_in.den ? 
av_q2d(ctx->time_base_in) : 0;
+s->var_values[VAR_SR]= ctx->par_in->sample_rate;
 
 return 0;
 }
@@ -187,8 +189,6 @@ static int setts_filter(AVBSFContext *ctx, AVPacket *pkt)
 s->var_values[VAR_NEXT_DUR]= pkt->duration;
 s->var_values[VAR_STARTPTS]= s->start_pts;
 s->var_values[VAR_STARTDTS]= s->start_dts;
-s->var_values[VAR_TB]  = ctx->time_base_out.den ? 
av_q2d(ctx->time_base_out) : 0;
-s->var_values[VAR_SR]  = ctx->par_in->sample_rate;
 
 new_ts = llrint(av_expr_eval(s->ts_expr, s->var_values, NULL));
 new_duration = llrint(av_expr_eval(s->duration_expr, s->var_values, NULL));
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v2 1/5] avutil: [loongarch] Update loongson_intrinsics.h to v1.1.0

2022-02-28 Thread Michael Niedermayer
On Mon, Feb 28, 2022 at 04:19:55PM +0800, 殷时友 wrote:
> 
> 
> > 2022年2月21日 下午11:00,Michael Niedermayer  写道:
> > 
> > On Thu, Feb 17, 2022 at 07:11:47PM +0800, Hao Chen wrote:
> >> The loongson_intrinsics.h file is updated from v1.0.3 version
> >> to v1.1.0. Some spelling mistakes are fixed and new functions are added.
> >> 
> >> Signed-off-by: Hao Chen 
> >> ---
> >> libavutil/loongarch/loongson_intrinsics.h | 1697 +++--
> >> 1 file changed, 884 insertions(+), 813 deletions(-)
> >> 
> >> diff --git a/libavutil/loongarch/loongson_intrinsics.h 
> >> b/libavutil/loongarch/loongson_intrinsics.h
> >> index 6e0439f829..eb256863c8 100644
> >> --- a/libavutil/loongarch/loongson_intrinsics.h
> >> +++ b/libavutil/loongarch/loongson_intrinsics.h
> >> @@ -33,7 +33,7 @@
> >>  *Xiwei Gu   
> >>  *Lu Wang
> >>  *
> >> - * This file is a header file for loongarch builtin extention.
> >> + * This file is a header file for loongarch builtin extension.
> >>  *
> >>  */
> >> 
> >> @@ -42,50 +42,50 @@
> >> 
> >> /**
> >>  * MAJOR version: Macro usage changes.
> >> - * MINOR version: Add new functions, or bug fix.
> >> + * MINOR version: Add new functions, or bug fixes.
> >>  * MICRO version: Comment changes or implementation changes.
> >>  */
> >> #define LSOM_VERSION_MAJOR 1
> >> -#define LSOM_VERSION_MINOR 0
> >> -#define LSOM_VERSION_MICRO 3
> >> +#define LSOM_VERSION_MINOR 1
> >> +#define LSOM_VERSION_MICRO 0
> >> 
> >> #define DUP2_ARG1(_INS, _IN0, _IN1, _OUT0, _OUT1) \
> >> -{ \
> >> -_OUT0 = _INS(_IN0); \
> >> -_OUT1 = _INS(_IN1); \
> >> -}
> >> +  {   \
> >> +_OUT0 = _INS(_IN0);   \
> >> +_OUT1 = _INS(_IN1);   \
> >> +  }
> >> 
> >> #define DUP2_ARG2(_INS, _IN0, _IN1, _IN2, _IN3, _OUT0, _OUT1) \
> >> -{ \
> >> -_OUT0 = _INS(_IN0, _IN1); \
> >> -_OUT1 = _INS(_IN2, _IN3); \
> >> -}
> >> +  {   \
> >> +_OUT0 = _INS(_IN0, _IN1); \
> >> +_OUT1 = _INS(_IN2, _IN3); \
> >> +  }
> > 
> > These style changes differ from the recommandition in doc/developer.texi
> > is that intentional ?
> > 
> > thx
> 
> 
> Can we keep this style in here, it’s helpful for us to maintain this header 
> file
> which used for some other projects too. Thanks very much.

yes, it makes sense to keep the style under these circumstances

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v2] tools/target_bsf_fuzzer: simplify the loop feeding packets to the filter

2022-02-28 Thread Michael Niedermayer
On Fri, Feb 25, 2022 at 06:46:30PM -0300, James Almer wrote:
> And use a single AVPacket for the entire process.
> This more closely follows the suggested API usage in the doxy.
> 
> Signed-off-by: James Almer 
> ---
>  tools/target_bsf_fuzzer.c | 41 +++
>  1 file changed, 16 insertions(+), 25 deletions(-)

should be ok if tested (for example with a past testcase showing some anomaly)

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v8 1/1] avformat: Add IPFS protocol support.

2022-02-28 Thread Tomas Härdin
sön 2022-02-27 klockan 15:29 +0100 skrev Mark Gaiser:
> Ping 2
> 
> I'd really like to get this merged!
> This kinda blocks me right now from proceeding with IPFS integration
> in
> Kodi, MPV and VLC. Implementations in those (who rely on ffmpeg) are
> significantly easier once this patch is finally landed in ffmpeg.

I'd like to hear at least one other dev chime in on this one

/Tomas

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 1/4 v2] ffmpeg: flush delayed frames in codec copy scenarios

2022-02-28 Thread James Almer

On 2/23/2022 12:03 PM, James Almer wrote:

Bitstream filters inserted between the input and output were
never drained, resulting packets being lost if the bsf had any
buffered.

Signed-off-by: James Almer 
---
Now also flushing packets when forcing a record duration.

  fftools/ffmpeg.c| 13 -
  fftools/ffmpeg.h|  1 +
  fftools/ffmpeg_filter.c |  1 +
  fftools/ffmpeg_opt.c|  4 
  4 files changed, 14 insertions(+), 5 deletions(-)


Will apply.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v2] tools/target_bsf_fuzzer: simplify the loop feeding packets to the filter

2022-02-28 Thread James Almer

On 2/25/2022 6:46 PM, James Almer wrote:

And use a single AVPacket for the entire process.
This more closely follows the suggested API usage in the doxy.

Signed-off-by: James Almer 
---
  tools/target_bsf_fuzzer.c | 41 +++
  1 file changed, 16 insertions(+), 25 deletions(-)


Ping.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v2 1/5] avutil: [loongarch] Update loongson_intrinsics.h to v1.1.0

2022-02-28 Thread 殷时友


> 2022年2月21日 下午11:00,Michael Niedermayer  写道:
> 
> On Thu, Feb 17, 2022 at 07:11:47PM +0800, Hao Chen wrote:
>> The loongson_intrinsics.h file is updated from v1.0.3 version
>> to v1.1.0. Some spelling mistakes are fixed and new functions are added.
>> 
>> Signed-off-by: Hao Chen 
>> ---
>> libavutil/loongarch/loongson_intrinsics.h | 1697 +++--
>> 1 file changed, 884 insertions(+), 813 deletions(-)
>> 
>> diff --git a/libavutil/loongarch/loongson_intrinsics.h 
>> b/libavutil/loongarch/loongson_intrinsics.h
>> index 6e0439f829..eb256863c8 100644
>> --- a/libavutil/loongarch/loongson_intrinsics.h
>> +++ b/libavutil/loongarch/loongson_intrinsics.h
>> @@ -33,7 +33,7 @@
>>  *Xiwei Gu   
>>  *Lu Wang
>>  *
>> - * This file is a header file for loongarch builtin extention.
>> + * This file is a header file for loongarch builtin extension.
>>  *
>>  */
>> 
>> @@ -42,50 +42,50 @@
>> 
>> /**
>>  * MAJOR version: Macro usage changes.
>> - * MINOR version: Add new functions, or bug fix.
>> + * MINOR version: Add new functions, or bug fixes.
>>  * MICRO version: Comment changes or implementation changes.
>>  */
>> #define LSOM_VERSION_MAJOR 1
>> -#define LSOM_VERSION_MINOR 0
>> -#define LSOM_VERSION_MICRO 3
>> +#define LSOM_VERSION_MINOR 1
>> +#define LSOM_VERSION_MICRO 0
>> 
>> #define DUP2_ARG1(_INS, _IN0, _IN1, _OUT0, _OUT1) \
>> -{ \
>> -_OUT0 = _INS(_IN0); \
>> -_OUT1 = _INS(_IN1); \
>> -}
>> +  {   \
>> +_OUT0 = _INS(_IN0);   \
>> +_OUT1 = _INS(_IN1);   \
>> +  }
>> 
>> #define DUP2_ARG2(_INS, _IN0, _IN1, _IN2, _IN3, _OUT0, _OUT1) \
>> -{ \
>> -_OUT0 = _INS(_IN0, _IN1); \
>> -_OUT1 = _INS(_IN2, _IN3); \
>> -}
>> +  {   \
>> +_OUT0 = _INS(_IN0, _IN1); \
>> +_OUT1 = _INS(_IN2, _IN3); \
>> +  }
> 
> These style changes differ from the recommandition in doc/developer.texi
> is that intentional ?
> 
> thx


Can we keep this style in here, it’s helpful for us to maintain this header file
which used for some other projects too. Thanks very much.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".