Re: [FFmpeg-devel] Playback issue on Sony TVs caused by btrt box

2022-02-21 Thread Marton Balint



On Mon, 21 Feb 2022, Eran Kornblau wrote:



On Mon, Feb 21, 2022 at 5:07 PM Eran Kornblau  wrote:


Hi all,

We've recently upgraded our ffmpeg version, and we got a playback issue on some 
Sony TV models that are playing HBBTV/DASH+DRM - video plays fine, audio 
doesn't play at all.
Listing here some of the affected models (not pasting all, the list is long...) 
- KDL-32W600D, KDL-40W650D, KDL-48W650D, KDL-43W750D, KDL-49W750D, KDL-55W650D.

After some investigation, we found the cause was the addition of the
'btrt' atom to the mp4 –
https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
ub.com%2FFFmpeg%2FFFmpeg%2Fcommit%2F3838e8fc210aa09a9f9058506c0ce80b6a
d9b9c3data=04%7C01%7C%7Cc96aade7b4354115844508d9f5665925%7C0c5037
48de3f4e2597e26819d53a42b6%7C1%7C0%7C637810642206022682%7CUnknown%7CTW
FpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6
Mn0%3D%7C3000sdata=Na7ZxDQTby8Xq9CjB51lJyP1IOMdwLqoRLNODUC4nX0%3D
reserved=0 The TV decoder expects to get the sinf atom right
after esds, and doesn't properly handle the btrt atom in between (our
packager adds the sinf atom at the end of the original stsd entry that was read 
from the mp4 file).

Since, in my understanding, the btrt atom was added mostly for reporting 
reasons, IMHO, it should be a config option - off by default.
I would happily submit a patch for it, but sending this first, in case there 
are any concerns/objections.



In case the use case was unknown, the primary reason for adding this was to 
utilize this box to inform a media server of an incoming live stream's bit 
rate, since the overall bit rate cannot be calculated for something that isn't 
done yet
(https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdashif-documents.azurewebsites.net%2FIngest%2Fmaster%2FDASH-IF-Ingest.htmldata=04%7C01%7C%7Cc96aade7b4354115844508d9f5665925%7C0c503748de3f4e2597e26819d53a42b6%7C1%7C0%7C637810642206178898%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=auOsZ4L7jR35BZxi45Onk9UQWoio2xOzJ%2BqcdN7yASk%3Dreserved=0
as an example of one such use case). This being an alternative to nonstandard 
things such as ISML manifests.

Additionally, since it seemed to be specified at the end of the given 
structures, I added it at the end of these given boxes. Apparently thus it made 
your live patching of that box no longer compatible with these parsers, since 
you just append your required things to the end of it. Am I understanding 
things correctly?



Our code adds the sinf box after the existing stsd entry, it is correct also 
when btrt is present, as an evidence to this - playback works fine on all other 
devices.
The problem, in my understanding, is in the decoder present on the affected 
Sony TV models - it seems the decoder is making an assumption that the sinf box 
should come right after the esds box,
while AFAIK, the spec does not mandate any order. Verbatim response we got from Sony: 
"btrt box in the audio chunk is causing the TV decoder to fail. TV decoder is 
expecting sinf box after esds box.".

So, even though it seems the TV decoder is the culprit, since the btrt atom can 
cause such failures, IMHO it should be omitted by default.
Users who need the benefits this atom provides, will be able to enable this 
functionality, of course.


Ability to turn it off is OK, changing default to not write it does not 
seem right.


Also you are poiting at btrt atom, but in fact sony said: "TV decoder 
expecting sinf box after sdds box", so the proper fix seems to be to 
change the order of the atoms, and add a big fat warning to the code that 
because of some sony TV models, sinf box must be immediately after esds 
box. Is this doable?


Thanks,
Marton



Thanks

Eran


Jan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmpeg-develdata=04%7C01%7C%7Cc96aade7b4354115844508d9f5665925%7C0c503748de3f4e2597e26819d53a42b6%7C1%7C0%7C637810642206178898%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=OBl349gLsGcHI%2FY%2FukRf%2BrulgovZ1t8%2BE511hsxcH%2FI%3Dreserved=0

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".

___
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] avformat: Add check for ff_get_extradata

2022-02-21 Thread Jiasheng Jiang
As the potential failure of the memory allocation, the ff_get_extradata()
could return error if fails.
Therefore, it should be better to deal with the return value of the
ff_get_extradata() and return error if fails.

Fixes: 2d720069a9 ("avformat: add aix demuxer")
Signed-off-by: Jiasheng Jiang 
---
 libavformat/aixdec.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/aixdec.c b/libavformat/aixdec.c
index 59c3d60da3..89f73b6913 100644
--- a/libavformat/aixdec.c
+++ b/libavformat/aixdec.c
@@ -40,7 +40,7 @@ static int aix_read_header(AVFormatContext *s)
 unsigned segment_list_offset = 0x20;
 unsigned segment_list_entry_size = 0x10;
 unsigned size;
-int i;
+int i, ret;
 
 avio_skip(s->pb, 4);
 first_offset = avio_rb32(s->pb) + 8;
@@ -77,7 +77,9 @@ static int aix_read_header(AVFormatContext *s)
 if (size <= 8)
 return AVERROR_INVALIDDATA;
 avio_skip(s->pb, 8);
-ff_get_extradata(s, s->streams[i]->codecpar, s->pb, size - 8);
+ret = ff_get_extradata(s, s->streams[i]->codecpar, s->pb, size - 8);
+if (ret < 0)
+return ret;
 }
 
 return 0;
-- 
2.25.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] avcodec/magicyuvenc: Add check for av_frame_clone

2022-02-21 Thread Jiasheng Jiang
As the potential failure of the memory allocation,
the 'p' could be NULL pointer.
Therefore, it should be better to check it in order
to avoid the dereferencing of the NULL pointer.

Fixes: 3729ae659f ("avcodec: add MagicYUV encoder")
Signed-off-by: Jiasheng Jiang 
---
 libavcodec/magicyuvenc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c
index ab32d4cee3..b763916b87 100644
--- a/libavcodec/magicyuvenc.c
+++ b/libavcodec/magicyuvenc.c
@@ -454,6 +454,8 @@ static int magy_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 if (s->correlate) {
 uint8_t *r, *g, *b;
 AVFrame *p = av_frame_clone(frame);
+if (!p)
+return AVERROR(ENOMEM);
 
 g = p->data[0];
 b = p->data[1];
-- 
2.25.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] fftools/ffmpeg_filter: Add check for av_memdup

2022-02-21 Thread Jiasheng Jiang
As the potential failure of the av_malloc(), the av_memdup()
could return NULL if fails.
Therefore, it should be better to check it and return error
if fails, like the av_buffer_ref().

Fixes: 535a835e51 ("ffmpeg: use display matrix frame side data for 
autorotation")
Signed-off-by: Jiasheng Jiang 
---
 fftools/ffmpeg_filter.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 2c3f21985f..cdaa0d8165 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1161,8 +1161,11 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, 
const AVFrame *frame)
 
 av_freep(>displaymatrix);
 sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX);
-if (sd)
+if (sd) {
 ifilter->displaymatrix = av_memdup(sd->data, sizeof(int32_t) * 9);
+if (!ifilter->displaymatrix)
+return AVERROR(ENOMEM);
+}
 
 if (frame->hw_frames_ctx) {
 ifilter->hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx);
-- 
2.25.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 2/2] lavc/bsf: improve doxy

2022-02-21 Thread Anton Khirnov
---
 libavcodec/bsf.h | 24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/libavcodec/bsf.h b/libavcodec/bsf.h
index ba8b48f222..611beab885 100644
--- a/libavcodec/bsf.h
+++ b/libavcodec/bsf.h
@@ -167,9 +167,9 @@ const AVBitStreamFilter *av_bsf_iterate(void **opaque);
  * av_bsf_init() before sending any data to the filter.
  *
  * @param filter the filter for which to allocate an instance.
- * @param ctx a pointer into which the pointer to the newly-allocated context
- *will be written. It must be freed with av_bsf_free() after the
- *filtering is done.
+ * @param[out] ctx a pointer into which the pointer to the newly-allocated 
context
+ * will be written. It must be freed with av_bsf_free() after 
the
+ * filtering is done.
  *
  * @return 0 on success, a negative AVERROR code on failure
  */
@@ -195,9 +195,11 @@ int av_bsf_init(AVBSFContext *ctx);
  * sending more empty packets does nothing) and will cause the filter to output
  * any packets it may have buffered internally.
  *
- * @return 0 on success. AVERROR(EAGAIN) if packets need to be retrieved from 
the
- * filter (using av_bsf_receive_packet()) before new input can be consumed. 
Another
- * negative AVERROR value if an error occurs.
+ * @return
+ *  - 0 on success.
+ *  - AVERROR(EAGAIN) if packets need to be retrieved from the filter (using
+ *av_bsf_receive_packet()) before new input can be consumed.
+ *  - Another negative AVERROR value if an error occurs.
  */
 int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt);
 
@@ -214,10 +216,12 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt);
  * overwritten by the returned data. On failure, pkt is not
  * touched.
  *
- * @return 0 on success. AVERROR(EAGAIN) if more packets need to be sent to the
- * filter (using av_bsf_send_packet()) to get more output. AVERROR_EOF if there
- * will be no further output from the filter. Another negative AVERROR value if
- * an error occurs.
+ * @return
+ *  - 0 on success.
+ *  - AVERROR(EAGAIN) if more packets need to be sent to the filter (using
+ *av_bsf_send_packet()) to get more output.
+ *  - AVERROR_EOF if there will be no further output from the filter.
+ *  - Another negative AVERROR value if an error occurs.
  *
  * @note one input packet may result in several output packets, so after 
sending
  * a packet with av_bsf_send_packet(), this function needs to be called
-- 
2.34.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] lavc/bsf: add general documentation

2022-02-21 Thread Anton Khirnov
Also, place the BSF api docs in their own doxygen group.
---
 libavcodec/bsf.h | 23 ++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/libavcodec/bsf.h b/libavcodec/bsf.h
index 8c5355d186..ba8b48f222 100644
--- a/libavcodec/bsf.h
+++ b/libavcodec/bsf.h
@@ -30,7 +30,28 @@
 #include "packet.h"
 
 /**
- * @addtogroup lavc_core
+ * @defgroup lavc_bsf Bitstream filters
+ * @ingroup libavc
+ *
+ * Bitstream filters transform encoded media data without decoding it. This
+ * allows e.g. manipulating various header values. Bitstream filters operate on
+ * @ref AVPacket "AVPackets".
+ *
+ * The bitstream filtering API is centered around two structures:
+ * AVBitStreamFilter and AVBSFContext. The former represents a bitstream filter
+ * in abstract, the latter a specific filtering process. Obtain an
+ * AVBitStreamFilter using av_bsf_get_by_name() or av_bsf_iterate(), then pass
+ * it to av_bsf_alloc() to create an AVBSFContext. Fill in the user-settable
+ * AVBSFContext fields, as described in its documentation, then call
+ * av_bsf_init() to prepare the filter context for use.
+ *
+ * Submit packets for filtering using av_bsf_send_packet(), obtain filtered
+ * results with av_bsf_receive_packet(). When no more input packets will be
+ * sent, submit a NULL AVPacket to signal the end of the stream to the filter.
+ * av_bsf_receive_packet() will then return trailing packets, if any are
+ * produced by the filter.
+ *
+ * Finally, free the filter context with av_bsf_free().
  * @{
  */
 
-- 
2.34.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 v1] avfilter/vf_gblur_vulkan: add sizeV option

2022-02-21 Thread Wu, Jianhua
Lynne:
> Sent: Tuesday, February 22, 2022 1:38 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v1] avfilter/vf_gblur_vulkan: add sizeV
> option
> 
> 18 Feb 2022, 16:24 by toq...@outlook.com:
> 
> >> 29 Jan 2022, 13:34 by toqsxw at outlook.com:
> >>
> >>> Ping.
> >>>
>  From: Wu, Jianhua
>  Sent: 2022年1月21日 19:42
>  To: ffmpeg-devel at ffmpeg.org
>  Cc: Wu, Jianhua
>  Subject: [FFmpeg-devel] [PATCH v1] avfilter/vf_gblur_vulkan: add
>  sizeV option
> 
>  [PATCH 1/5] avfilter/vf_gblur_vulkan: add sizeV option [PATCH 2/5]
>  avfilter:add shader_vulkan filter [PATCH 3/5]
>  avfilter/vf_blend_vulkan: add multiply blend mode [PATCH 4/5]
>  avutil/vulkan: don't use strlen as loop >condition [PATCH 5/5]
>  avfilter/scale_vulkan: use RET for checking return value
> 
>  Patches attached.
> 
> >>>
> >>> Hi there,
> >>>
> >>> Any update?
> >>>
> >>
> >> Sorry, haven't forgotten, but been busy with FFTs lately.
> >> Will try to review and test the patches soon.
> >>
> >
> > Hi there,
> >
> > I'm sorry for bothering you. If there is any update on this thread,
> > please do let me know.
> >
> 
> Pushed all except the strlen() in a loop condition and the shader filter.
> I pushed a different, smaller version for the strlen patch.
> 
Maybe you don't need to use strlen() at all. That patch could be applied
separately if you preferred to apply the shader_vulkan filter in the future.

> As for a shader filter, I'd like something that's a lot less minimal.
> You should expose the frame number, framerate (with an avoption to set it),
> pixel format to the shader. Keep in mind the API will be fixed, so we need to
> get this right the first time hopefully.

Frame number and framerate are okay to set if I can get them from FFmpeg API,
but pixel format may not be ideal to expose for there is a lot of pixel formats 
in
FFmpeg. Exposing a pixel format means we need to expose all values related to
pixel formats. Instead, we could expose two functions like

vec4 pixel = av_read_pixel(intput_images, av_position) 
av_write_pixel(ouput_images, pixel, positions)

so the user shader could only concentrate on the vector4 pixel variable and 
don't
need to care about what pixel format is. Or simply expose the subsampling 
scheme,
444, 420, or 422, and color space, YUV, and RGB.

> Also, correct the name style. We don't use camelcase for variables, and we
> use "av_" instead of "ff_" for public API, which a shader sort of is IMO.

Got it.

> You should expose alpha planes as well.
Could you elaborate it further?

> Finally, could you implement N-inputs and M-outputs, configurable via
> avoptions? That way, someone could make a custom blend filter without a
> separate avfilter which takes multiple inputs. Or a separator filter.
> Or a simple source filter that just produces an image pattern.
> 
Sounds great! However, at the present, I've no idea about how this could be 
done.
I think the current filter is already useful already for I could make some 
great video
effects just like Shadertoy. More extensions need further contributions.

Thanks,
Jianhua

___
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/4] lavc/vaapi_encode_h265: Add P frame to GPB frame support for hevc_vaapi

2022-02-21 Thread Xiang, Haihao
On Mon, 2022-02-21 at 12:06 +, Mark Thompson wrote:
> On 21/02/2022 02:13, Fei Wang wrote:
> > From: Linjie Fu 
> > 
> > Use GPB frames to replace regular P frames if backend driver does not
> > support it.
> > 
> > - GPB:
> >  Generalized P and B picture. P frames replaced by B frames with
> >  forward-predict only, L0 == L1. Normal B frames still have 2
> >  different ref_lists and allow bi-prediction
> > 
> > Signed-off-by: Linjie Fu 
> > Signed-off-by: Fei Wang 
> > ---
> >   libavcodec/vaapi_encode.c  | 33 +++--
> >   libavcodec/vaapi_encode.h  |  1 +
> >   libavcodec/vaapi_encode_h265.c | 15 +++
> >   3 files changed, 47 insertions(+), 2 deletions(-)
> 
> This always fails immediately on current iHD
> (7e357b4bea76b2fe2522e6af41ae02ea69cec49e):
> 
> $ ./ffmpeg_g -v 44 -y -hwaccel vaapi -hwaccel_output_format vaapi -i in.mp4
> -an -c:v hevc_vaapi -low_power 1 out.mp4
> ...
> [hevc_vaapi @ 0x560e81d45e80] Using input frames context (format vaapi) with
> hevc_vaapi encoder.
> [hevc_vaapi @ 0x560e81d45e80] Input surface format is nv12.
> [hevc_vaapi @ 0x560e81d45e80] Using VAAPI profile VAProfileHEVCMain (17).
> [hevc_vaapi @ 0x560e81d45e80] Using VAAPI entrypoint VAEntrypointEncSliceLP
> (8).
> [hevc_vaapi @ 0x560e81d45e80] Using VAAPI render target format YUV420 (0x1).
> [hevc_vaapi @ 0x560e81d45e80] Using CTU size 64x64, min CB size 8x8.
> [hevc_vaapi @ 0x560e81d45e80] No quality level set; using default (25).
> [hevc_vaapi @ 0x560e81d45e80] RC mode: CQP.
> [hevc_vaapi @ 0x560e81d45e80] RC quality: 25.
> [hevc_vaapi @ 0x560e81d45e80] RC framerate: 3/1001 (29.97 fps).
> [hevc_vaapi @ 0x560e81d45e80] Use GPB B frames to replace regular P frames.
> [hevc_vaapi @ 0x560e81d45e80] Using intra, GPB-B-frames and B-frames
> (supported references: 3 / 3).
> [hevc_vaapi @ 0x560e81d45e80] All wanted packed headers available (wanted 0xd,
> found 0x1f).
> [hevc_vaapi @ 0x560e81d45e80] Using level 4.
> ...
> [hevc_vaapi @ 0x560e81d45e80] Failed to end picture encode issue: 24 (internal
> encoding error).
> [hevc_vaapi @ 0x560e81d45e80] Encode failed: -5.
> Video encoding failed
> ...
> $ cat /proc/cpuinfo | grep 'model name' | head -1
> model name  : Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
> $ uname -v
> #1 SMP PREEMPT Debian 5.16.7-2 (2022-02-09)
> 
> Do you get this too, or is your setup different somehow?

Hi Mark,

I tested this patchset with iHD (7e357b4bea76b2fe2522e6af41ae02ea69cec49e) on
CFL (low_power=0), RKL and DG1, i965 on SKL, and didn't see this issue before.
This day I reproduced this issue on ICL. It seems iHD driver doesn't return
right values for ICL.  

> 
> > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> > index 3bf379b1a0..95eca7c288 100644
> > --- a/libavcodec/vaapi_encode.c
> > +++ b/libavcodec/vaapi_encode.c
> > @@ -1845,6 +1845,30 @@ static av_cold int
> > vaapi_encode_init_gop_structure(AVCodecContext *avctx)
> >   ref_l1 = attr.value >> 16 & 0x;
> >   }
> >   
> > +ctx->p_to_gpb = 0;
> > +
> > +#if VA_CHECK_VERSION(1, 9, 0)
> > +attr = (VAConfigAttrib) { VAConfigAttribPredictionDirection };
> > +vas = vaGetConfigAttributes(ctx->hwctx->display,
> > +ctx->va_profile,
> > +ctx->va_entrypoint,
> > +, 1);
> 
> This probably shouldn't be done at all if the user has selected a codec
> without B-frames or a configuration which is intra-only, because the log
> message is confusing:
> 
> [mjpeg_vaapi @ 0x55b90d72ee00] Driver does not report whether support GPB, use
> regular P frames.
> [mjpeg_vaapi @ 0x55b90d72ee00] Using intra frames only.
> 
> > +if (vas != VA_STATUS_SUCCESS) {
> > +av_log(avctx, AV_LOG_WARNING, "Failed to query prediction direction
> > "
> > +   "attribute: %d (%s).\n", vas, vaErrorStr(vas));
> 
> And fail?

4/4 also ignores the error. It would be better to handle the error in the same
way and update 4/4 too. 

> 
> > +} else if (attr.value == VA_ATTRIB_NOT_SUPPORTED) {
> > +av_log(avctx, AV_LOG_VERBOSE, "Driver does not report whether "
> > +   "support GPB, use regular P frames.\n");
> 
> "support GPB" is a strange thing to say.  It's a constraint - any driver which
> supports B-frames will let you have the same thing in both RefPicLists, but
> some require it because they don't support P-frames.
> 
> So maybe something like "Driver does not report any additional prediction
> constraints, using P-frames."?
> 
> > +} else {
> > +if (attr.value & VA_PREDICTION_DIRECTION_BI_NOT_EMPTY) {
> > +ctx->p_to_gpb = 1;
> > +av_log(avctx, AV_LOG_VERBOSE, "Use GPB B frames to replace "
> > +   "regular P frames.\n");
> 
> Maybe "Driver does not support P-frames, replacing them with B-frames."?
> 
> > +} else
> > +av_log(avctx, AV_LOG_VERBOSE, "Use regular 

Re: [FFmpeg-devel] [PATCH v1] avfilter/vf_gblur_vulkan: add sizeV option

2022-02-21 Thread Lynne
18 Feb 2022, 16:24 by toq...@outlook.com:

>> 29 Jan 2022, 13:34 by toqsxw at outlook.com:
>>
>>> Ping.
>>>
 From: Wu, Jianhua
 Sent: 2022年1月21日 19:42
 To: ffmpeg-devel at ffmpeg.org
 Cc: Wu, Jianhua
 Subject: [FFmpeg-devel] [PATCH v1] avfilter/vf_gblur_vulkan: add sizeV 
 option

 [PATCH 1/5] avfilter/vf_gblur_vulkan: add sizeV option [PATCH 2/5] 
 avfilter:add shader_vulkan filter [PATCH 3/5] avfilter/vf_blend_vulkan: 
 add multiply blend mode [PATCH 4/5] avutil/vulkan: don't use strlen as 
 loop >condition [PATCH 5/5] avfilter/scale_vulkan: use RET for checking 
 return value

 Patches attached.

>>>
>>> Hi there,
>>>
>>> Any update?
>>>
>>
>> Sorry, haven't forgotten, but been busy with FFTs lately.
>> Will try to review and test the patches soon.
>>
>
> Hi there,
>
> I'm sorry for bothering you. If there is any update on this
> thread, please do let me know. 
>

Pushed all except the strlen() in a loop condition and the shader filter.
I pushed a different, smaller version for the strlen patch.

As for a shader filter, I'd like something that's a lot less minimal.
You should expose the frame number, framerate (with an avoption to set it),
pixel format to the shader. Keep in mind the API will be fixed, so
we need to get this right the first time hopefully.
Also, correct the name style. We don't use camelcase for variables,
and we use "av_" instead of "ff_" for public API, which a shader sort of is IMO.
You should expose alpha planes as well.
Finally, could you implement N-inputs and M-outputs, configurable via
avoptions? That way, someone could make a custom blend filter without
a separate avfilter which takes multiple inputs. Or a separator filter.
Or a simple source filter that just produces an image pattern.
___
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] libavfilter: zscale performance optimization >4x

2022-02-21 Thread Lynne
19 Feb 2022, 14:58 by niva...@gmail.com:

> By ffmpeg threading support implementation via frame slicing and doing
> zimg_filter_graph_build that used to take 30-60% of each frame processig
> only if necessary (some parameters changed)
> the performance increase vs original version
> in video downscale and color conversion  >4x is seen
> on 64 cores Intel Xeon, 3x on i7-6700K (4 cores with HT)
>
> Signed-off-by: Victoria Zhislina 
>

Can't you patch such a feature into the upstream instead?
___
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 v3] avformat/nutdec: Add check for avformat_new_stream

2022-02-21 Thread Jiasheng Jiang
As the potential failure of the memory allocation,
the avformat_new_stream() could return NULL pointer.
Therefore, it should be better to check it and return
error if fails.
Also, the caller, nut_read_header(), needs to deal with
the return value of the decode_main_header() and return
error if memory allocation fails.
And 'time_base_count' has already checked and it
will return AVERROR_INVALIDDATA if fails, which is different
from ENOMEM.

Fixes: 619d8e2e58 ("updating nut demuxer to latest spec no muxing yet no index 
yet no seeking yet libnuts crcs dont match mine (didnt investigate yet) 
samplerate is stored wrong by libnut (demuxer has a workaround) code is not 
clean or beautifull yet, but i thought its better to commit early before 
someone unneccesarily wastes his time duplicating the work demuxer split from 
muxer")

Signed-off-by: Jiasheng Jiang 
---
Changelog:

v1 -> v2

* Change 1. Add the error handling for ENOMEM from decode_main_header()
in nut_read_header().
* Change 2. Check for the 'time_base_count'.

v2 -> v3

* Change 1. Remove the check for 'time_base_count'.
* Change 2. Change the av_free to av_freep.
---
 libavformat/nutdec.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 0a8a700acf..32a4f6bbcb 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -351,8 +351,13 @@ static int decode_main_header(NUTContext *nut)
 ret = AVERROR(ENOMEM);
 goto fail;
 }
-for (i = 0; i < stream_count; i++)
-avformat_new_stream(s, NULL);
+for (i = 0; i < stream_count; i++) {
+if (!avformat_new_stream(s, NULL)) {
+av_freep(nut->stream);
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+}
 
 return 0;
 fail:
@@ -800,19 +805,23 @@ static int nut_read_header(AVFormatContext *s)
 NUTContext *nut = s->priv_data;
 AVIOContext *bc = s->pb;
 int64_t pos;
-int initialized_stream_count;
+int initialized_stream_count, ret;
 
 nut->avf = s;
 
 /* main header */
 pos = 0;
+ret = 0;
 do {
+if (ret == AVERROR(ENOMEM))
+return ret;
+
 pos = find_startcode(bc, MAIN_STARTCODE, pos) + 1;
 if (pos < 0 + 1) {
 av_log(s, AV_LOG_ERROR, "No main startcode found.\n");
 return AVERROR_INVALIDDATA;
 }
-} while (decode_main_header(nut) < 0);
+} while ((ret = decode_main_header(nut)) < 0);
 
 /* stream headers */
 pos = 0;
-- 
2.25.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] avformat/nutdec: Add check for avformat_new_stream

2022-02-21 Thread Jiasheng Jiang
Michael Niedermayer:
>> diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
>> index 0a8a700acf..4cbccb20d9 100644
>> --- a/libavformat/nutdec.c
>> +++ b/libavformat/nutdec.c
>> @@ -220,6 +220,10 @@ static int decode_main_header(NUTContext *nut)
>>  }
>>  
>>  GET_V(nut->time_base_count, tmp > 0 && tmp < INT_MAX / 
>> sizeof(AVRational) && tmp < length/2);
>> +
>> +if (nut->time_base_count > NUT_MAX_STREAMS)
>> +return AVERROR_INVALIDDATA;
>
> the code already checks against length/2. If you want to add to that
> that should be done at the same level and
> such a change should explain why the existing check is insufficent as
> well as why the new is correct
> and it should be in a patch seperate from other changes
> also a file with NUT_MAX_STREAMS streams could use more timebases in principle
> timebases need a lot less space than streams so they could have a slightly
> higher limit

Thanks, I will remove the check in v3.

>> +
>>  nut->time_base = av_malloc_array(nut->time_base_count, 
>> sizeof(AVRational));
>>  if (!nut->time_base)
>>  return AVERROR(ENOMEM);
>> @@ -351,8 +355,13 @@ static int decode_main_header(NUTContext *nut)
>>  ret = AVERROR(ENOMEM);
>>  goto fail;
>>  }
>> -for (i = 0; i < stream_count; i++)
>> -avformat_new_stream(s, NULL);
>> +for (i = 0; i < stream_count; i++) {
>> +if (!avformat_new_stream(s, NULL)) {
>> +av_free(nut->stream);
> 
> freeing something and not clearing the pointer is a bad idea in general

You are right.
I will change av_free to av_freep.

Jiang

___
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-21 Thread James Almer




On 2/21/2022 3:14 PM, Paul B Mahol wrote:

On Mon, Feb 21, 2022 at 6:57 PM James Almer  wrote:




On 2/21/2022 9:27 AM, 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)))


Wont this check always succeed?



Works here fine, it just there for case of possible programming error in
future.
It never enters that condition here.


Ok, LGTM then.





+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();
  

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

2022-02-21 Thread Michael Niedermayer
On Mon, Feb 21, 2022 at 08:59:16AM -0800, Pierre-Anthony Lemieux wrote:
> Hi Michael,
> 
> What is the typical size of a successful GSOC project? Any good
> example(s) from the past?

for past Results
see: (and replace teh year by other years)
https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2020/Results

but also keep in mind it makes a big difference if the student had
previously outside gsoc contributed to FFmpeg

also this year there are multiple changes in GSOC 
there will be 2 project sizes and more people will be eligible IIUC

Thanks


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

"You are 36 times more likely to die in a bathtub than at the hands of a
terrorist. Also, you are 2.5 times more likely to become a president and
2 times more likely to become an astronaut, than to die in a terrorist
attack." -- Thoughty2



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] Playback issue on Sony TVs caused by btrt box

2022-02-21 Thread Jan Ekström
On Mon, Feb 21, 2022 at 5:07 PM Eran Kornblau  wrote:
>
> Hi all,
>
> We've recently upgraded our ffmpeg version, and we got a playback issue on 
> some Sony TV models that are playing HBBTV/DASH+DRM - video plays fine, audio 
> doesn't play at all.
> Listing here some of the affected models (not pasting all, the list is 
> long...) - KDL-32W600D, KDL-40W650D, KDL-48W650D, KDL-43W750D, KDL-49W750D, 
> KDL-55W650D.
>
> After some investigation, we found the cause was the addition of the 'btrt' 
> atom to the mp4 –
> https://github.com/FFmpeg/FFmpeg/commit/3838e8fc210aa09a9f9058506c0ce80b6ad9b9c3
> The TV decoder expects to get the sinf atom right after esds, and doesn't 
> properly handle the btrt atom in between
> (our packager adds the sinf atom at the end of the original stsd entry that 
> was read from the mp4 file).
>
> Since, in my understanding, the btrt atom was added mostly for reporting 
> reasons, IMHO, it should be a config option - off by default.
> I would happily submit a patch for it, but sending this first, in case there 
> are any concerns/objections.
>

In case the use case was unknown, the primary reason for adding this
was to utilize this box to inform a media server of an incoming live
stream's bit rate, since the overall bit rate cannot be calculated for
something that isn't done yet
(https://dashif-documents.azurewebsites.net/Ingest/master/DASH-IF-Ingest.html
as an example of one such use case). This being an alternative to
nonstandard things such as ISML manifests.

Additionally, since it seemed to be specified at the end of the given
structures, I added it at the end of these given boxes. Apparently
thus it made your live patching of that box no longer compatible with
these parsers, since you just append your required things to the end
of it. Am I understanding things correctly?

Jan
___
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-21 Thread Paul B Mahol
On Mon, Feb 21, 2022 at 6:57 PM James Almer  wrote:

>
>
> On 2/21/2022 9:27 AM, 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)))
>
> Wont this check always succeed?
>
>
Works here fine, it just there for case of possible programming error in
future.
It never enters that condition here.


> > +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 

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

2022-02-21 Thread James Almer




On 2/21/2022 9:27 AM, 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)))


Wont this check always succeed?


+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 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int 
w, int h)
  
  if (!link->frame_pool) {

  link->frame_pool = 

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

2022-02-21 Thread Pierre-Anthony Lemieux
Hi Michael,

What is the typical size of a successful GSOC project? Any good
example(s) from the past?

Best,

-- Pierre

On Mon, Feb 21, 2022 at 4:12 AM Michael Niedermayer
 wrote:
>
> Hi all
>
> 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!
> If you had one in 2021 or prior which was not finished and the project
> still makes sense, please copy it to the 2022 page
>
> https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2022
>
> google doesnt like empty idea pages when they review it!
>
> Thanks!
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Never trust a computer, one day, it may think you are the virus. -- Compn
> ___
> 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 4/6] ffmpeg: don't skip packets before a keyframe was seen if a bsf with delay is used

2022-02-21 Thread Anton Khirnov
Quoting James Almer (2022-02-15 13:12:51)
> On 2/15/2022 9:03 AM, Anton Khirnov wrote:
> > Quoting James Almer (2022-02-15 12:48:09)
> >>
> >>
> >> On 2/15/2022 8:41 AM, Anton Khirnov wrote:
> >>> Quoting James Almer (2022-02-14 23:41:54)
>  A keyframe could be buffered in the bsf and not be output until more 
>  packets
>  had been fed to it.
> 
>  Signed-off-by: James Almer 
>  ---
> fftools/ffmpeg.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> 
>  diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
>  index 6aa0986f02..48d9016b4c 100644
>  --- a/fftools/ffmpeg.c
>  +++ b/fftools/ffmpeg.c
>  @@ -2026,7 +2026,8 @@ static void do_streamcopy(InputStream *ist, 
>  OutputStream *ost, const AVPacket *p
> }
> 
> if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) &&
>  -!ost->copy_initial_nonkeyframes)
>  +!ost->copy_initial_nonkeyframes &&
>  +!(ost->bsf_ctx && ost->bsf_ctx->filter->capabilities & 
>  AV_BSF_CAP_DELAY))
> return;
> >>>
> >>> Wouldn't it be simpler to add an OutputStream field that tracks whether
> >>> we've seen a keyframe packet yet? No new API required.
> >>
> >> Probably. It would also only trigger when a keyframe was seen instead of
> >> unconditionally for all delay flagged bsfs.
> >>
> >> I still think this new API is a good addition, either way. Only a
> >> handful of bsfs buffer packets and require the caller to flush them
> >> after sending NULL (av1_frame_merge, vp9_superframe, and setts after
> >> this set) so library users could have all this time never signaled EOF
> >> and never noticed anything wrong, much like it happened here.
> >> The presence of this flag might help library users know they really need
> >> to signal EOF.
> > 
> > I don't see where the advantage would be. The callers still need to have
> > the flushing code, so might as well always call it.
> 
> Then we probably need to enforce it in the doxy, or at least strongly 
> suggest it with a @note or @warning line to ensure you get complete output.
> Right now it's optional, mentioned as "If you send a NULL packet, it 
> will trigger EOF", meaning not doing so is still a valid scenario, and 
> there's nothing letting the user know he's got packets stuck in the bsf 
> even after receive_packet() returned EAGAIN if they don't.

The doxy for av_bsf_send_packet() already says:
If pkt is empty, it signals the end of the stream and will cause the
filter to output any packets it may have buffered internally.

But I can write something more explicit.

-- 
Anton Khirnov
___
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] libavfilter: zscale performance optimization >4x

2022-02-21 Thread Victoria Zhislina
Hi, Anton. Thanks for your input. But the patch does the single thing
described in the commit message - improves performance >4 :)  Sorry.
This patch creation is based on real experience and on real measurement.
 Please notice  I don't write ">40x" so it is not an advertisement :).
 Right you are, under the hood it does 2 main things and one small
additional one combined to achieve the performance gain mentioned in the
commit message :)
However the changes are extremely local - they cover just a couple of
functions in a single file and  It doesn't make sense to split them. It
seems to me split will make ffmpeg-devel mail list and ffmpeg  git log
dirtier, not cleaner.
So let's wait for the Paul B Mahol opinion - it is his code that I've
modified.

On Mon, Feb 21, 2022 at 2:22 PM Anton Khirnov  wrote:

> > libavfilter: zscale performance optimization >4x
>
> This reads like an advertisement rather than a useful description. It
> should say what the patch does, performance improvement numbers should
> be mentioned in the commit message body.
>
> Quoting Victoria Zhislina (2022-02-21 09:20:55)
> > By ffmpeg threading support implementation via frame slicing and doing
> > zimg_filter_graph_build that used to take 30-60% of each frame processig
> > only if necessary (some parameters changed)
> > the performance increase vs original version
> > in video downscale and color conversion  >4x is seen
> > on 64 cores Intel Xeon, 3x on i7-6700K (4 cores with HT)
>
> This implies the patch does multiple unrelated things. Then it should be
> split in multiple patches, unless some important factor prevents that
> (then that factor should be described in the commit message).
>
> --
> Anton Khirnov
> ___
> 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 v2 1/5] avutil: [loongarch] Update loongson_intrinsics.h to v1.1.0

2022-02-21 Thread 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

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

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


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 195/281] audiotoolbox: convert to new channel layout API

2022-02-21 Thread Anton Khirnov
Quoting James Almer (2022-01-13 03:02:28)
> From: Anton Khirnov 
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/audiotoolboxdec.c | 27 +-
>  libavcodec/audiotoolboxenc.c | 95 
>  2 files changed, 57 insertions(+), 65 deletions(-)
> 
> diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
> index 9939fef218..8edf9bd463 100644
> --- a/libavcodec/audiotoolboxdec.c
> +++ b/libavcodec/audiotoolboxdec.c
> @@ -166,8 +166,8 @@ static int ffat_update_ctx(AVCodecContext *avctx)
> , )) {
>  if (format.mSampleRate)
>  avctx->sample_rate = format.mSampleRate;
> -avctx->channels = format.mChannelsPerFrame;
> -avctx->channel_layout = 
> av_get_default_channel_layout(avctx->channels);
> +av_channel_layout_uninit(>ch_layout);
> +av_get_default_channel_layout(>ch_layout, 
> format.mChannelsPerFrame);

Looks wrong

> @@ -364,11 +365,11 @@ static av_cold int ffat_create_decoder(AVCodecContext 
> *avctx,
>  #endif
>  } else {
>  in_format.mSampleRate = avctx->sample_rate ? avctx->sample_rate : 
> 44100;
> -in_format.mChannelsPerFrame = avctx->channels ? avctx->channels : 1;
> +in_format.mChannelsPerFrame = avctx->ch_layout.nb_channels ? 
> avctx->ch_layout.nb_channels : 1;
>  }
>  
>  avctx->sample_rate = out_format.mSampleRate = in_format.mSampleRate;
> -avctx->channels = out_format.mChannelsPerFrame = 
> in_format.mChannelsPerFrame;
> +avctx->ch_layout.nb_channels = out_format.mChannelsPerFrame = 
> in_format.mChannelsPerFrame;

Should probably uninit+set order.

> diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
> index 9245aa9dc4..aeda1c36fd 100644
> --- a/libavcodec/audiotoolboxenc.c
> +++ b/libavcodec/audiotoolboxenc.c
> @@ -278,10 +272,7 @@ static av_cold int ffat_init_encoder(AVCodecContext 
> *avctx)
>  return AVERROR_UNKNOWN;
>  }
>  
> -if (!avctx->channel_layout)
> -avctx->channel_layout = 
> av_get_default_channel_layout(avctx->channels);

I suspect this will break unspec channel layouts that previously worked.

-- 
Anton Khirnov
___
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] lavfi/vf_libplacebo: support custom .cube LUTs

2022-02-21 Thread Niklas Haas
On Mon, 21 Feb 2022 12:38:54 +0100 Anton Khirnov  wrote:
> Quoting Niklas Haas (2022-02-21 12:36:23)
> > On Mon, 21 Feb 2022 12:33:19 +0100 Anton Khirnov  wrote:
> > > Non-overridable IO in random places is evil.
> > 
> > Can you recommend a better way of accomplishing this?
> 
> How large are these? Can they be set directly as binary AVOptions?
> We could invent syntax for ffmpeg.c to provide the contents of a file as
> an option value.

Yes, I think that's a good idea in general. That would also apply
retroactively to the custom_shader_path / custom_shader_bin options.

Typically, these LUTs are around 1MB in size, but I also have LUTs as
large as 100 MB.

Syntax-wise, my proposal would be `option=@filename.cube`, matching e.g.
`curl -F src=@filename`.
___
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 v7 1/1] avformat: Add IPFS protocol support.

2022-02-21 Thread Tomas Härdin
tor 2022-02-17 klockan 15:26 +0100 skrev Mark Gaiser:
> > 
> > > +
> > > +    // Test $IPFS_GATEWAY.
> > > +    if (getenv("IPFS_GATEWAY") != NULL) {
> > > +    if (snprintf(c->gateway_buffer, sizeof(c-
> > > >gateway_buffer),
> > > "%s",
> > > + getenv("IPFS_GATEWAY")) >= sizeof(c-
> > > > gateway_buffer)) {
> > > +    av_log(h, AV_LOG_ERROR, "The IPFS_GATEWAY
> > > environment
> > > variable exceeds the maximum length. We allow a max of %li
> > > characters\n", sizeof(c->gateway_buffer));
> > 
> > nit: seems a bit weird to break the if but not the av_log()
> > Also this should be %zu not %li
> > 
> 
> The compiler doesn't complain about this one.
> How do you know %zu is right? I used this table and it knows nothing
> about
> %z...
> https://www.cplusplus.com/reference/cstdio/printf/

sizeof() returns size_t

/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".


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

2022-02-21 Thread Paul B Mahol
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 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int 
w, int h)
 
 if (!link->frame_pool) {
 link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h,
-link->format, 
BUFFER_ALIGN);
+link->format, align);

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

2022-02-21 Thread Michael Niedermayer
Hi all

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!
If you had one in 2021 or prior which was not finished and the project
still makes sense, please copy it to the 2022 page

https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2022

google doesnt like empty idea pages when they review it!

Thanks!

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Never trust a computer, one day, it may think you are the virus. -- Compn


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] avfilter/framepool: fix alignment requirements for audio and video filters

2022-02-21 Thread James Almer




On 2/21/2022 8:33 AM, Paul B Mahol wrote:

On Mon, Feb 21, 2022 at 2:54 AM James Almer  wrote:




On 2/20/2022 7:02 PM, Paul B Mahol wrote:

Signed-off-by: Paul B Mahol 
---
   libavfilter/audio.c | 11 +--
   libavfilter/framepool.c | 16 ++--
   libavfilter/video.c | 11 +--
   3 files changed, 16 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..ebfd5dc0e0 100644
--- a/libavfilter/framepool.c
+++ b/libavfilter/framepool.c
@@ -76,14 +76,10 @@ 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++) {
@@ -92,11 +88,11 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef*

(*alloc)(size_t size),

   }

   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,


Why are you removing the padding on each plane? Just add align padding
bytes and it should be good.



linesize[i]  is already aligned, why would there be need for additional
align at end of buffer?


FFALIGN(pool->width, align) can be pool->width. If so, then there would 
be no padding at all.






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 

Re: [FFmpeg-devel] [PATCH v2 1/4] lavc/vaapi_encode_h265: Add P frame to GPB frame support for hevc_vaapi

2022-02-21 Thread Mark Thompson

On 21/02/2022 02:13, Fei Wang wrote:

From: Linjie Fu 

Use GPB frames to replace regular P frames if backend driver does not
support it.

- GPB:
 Generalized P and B picture. P frames replaced by B frames with
 forward-predict only, L0 == L1. Normal B frames still have 2
 different ref_lists and allow bi-prediction

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
  libavcodec/vaapi_encode.c  | 33 +++--
  libavcodec/vaapi_encode.h  |  1 +
  libavcodec/vaapi_encode_h265.c | 15 +++
  3 files changed, 47 insertions(+), 2 deletions(-)


This always fails immediately on current iHD 
(7e357b4bea76b2fe2522e6af41ae02ea69cec49e):

$ ./ffmpeg_g -v 44 -y -hwaccel vaapi -hwaccel_output_format vaapi -i in.mp4 -an 
-c:v hevc_vaapi -low_power 1 out.mp4
...
[hevc_vaapi @ 0x560e81d45e80] Using input frames context (format vaapi) with 
hevc_vaapi encoder.
[hevc_vaapi @ 0x560e81d45e80] Input surface format is nv12.
[hevc_vaapi @ 0x560e81d45e80] Using VAAPI profile VAProfileHEVCMain (17).
[hevc_vaapi @ 0x560e81d45e80] Using VAAPI entrypoint VAEntrypointEncSliceLP (8).
[hevc_vaapi @ 0x560e81d45e80] Using VAAPI render target format YUV420 (0x1).
[hevc_vaapi @ 0x560e81d45e80] Using CTU size 64x64, min CB size 8x8.
[hevc_vaapi @ 0x560e81d45e80] No quality level set; using default (25).
[hevc_vaapi @ 0x560e81d45e80] RC mode: CQP.
[hevc_vaapi @ 0x560e81d45e80] RC quality: 25.
[hevc_vaapi @ 0x560e81d45e80] RC framerate: 3/1001 (29.97 fps).
[hevc_vaapi @ 0x560e81d45e80] Use GPB B frames to replace regular P frames.
[hevc_vaapi @ 0x560e81d45e80] Using intra, GPB-B-frames and B-frames (supported 
references: 3 / 3).
[hevc_vaapi @ 0x560e81d45e80] All wanted packed headers available (wanted 0xd, 
found 0x1f).
[hevc_vaapi @ 0x560e81d45e80] Using level 4.
...
[hevc_vaapi @ 0x560e81d45e80] Failed to end picture encode issue: 24 (internal 
encoding error).
[hevc_vaapi @ 0x560e81d45e80] Encode failed: -5.
Video encoding failed
...
$ cat /proc/cpuinfo | grep 'model name' | head -1
model name  : Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
$ uname -v
#1 SMP PREEMPT Debian 5.16.7-2 (2022-02-09)

Do you get this too, or is your setup different somehow?


diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 3bf379b1a0..95eca7c288 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1845,6 +1845,30 @@ static av_cold int 
vaapi_encode_init_gop_structure(AVCodecContext *avctx)
  ref_l1 = attr.value >> 16 & 0x;
  }
  
+ctx->p_to_gpb = 0;

+
+#if VA_CHECK_VERSION(1, 9, 0)
+attr = (VAConfigAttrib) { VAConfigAttribPredictionDirection };
+vas = vaGetConfigAttributes(ctx->hwctx->display,
+ctx->va_profile,
+ctx->va_entrypoint,
+, 1);


This probably shouldn't be done at all if the user has selected a codec without 
B-frames or a configuration which is intra-only, because the log message is 
confusing:

[mjpeg_vaapi @ 0x55b90d72ee00] Driver does not report whether support GPB, use 
regular P frames.
[mjpeg_vaapi @ 0x55b90d72ee00] Using intra frames only.


+if (vas != VA_STATUS_SUCCESS) {
+av_log(avctx, AV_LOG_WARNING, "Failed to query prediction direction "
+   "attribute: %d (%s).\n", vas, vaErrorStr(vas));


And fail?


+} else if (attr.value == VA_ATTRIB_NOT_SUPPORTED) {
+av_log(avctx, AV_LOG_VERBOSE, "Driver does not report whether "
+   "support GPB, use regular P frames.\n");


"support GPB" is a strange thing to say.  It's a constraint - any driver which 
supports B-frames will let you have the same thing in both RefPicLists, but some require 
it because they don't support P-frames.

So maybe something like "Driver does not report any additional prediction 
constraints, using P-frames."?


+} else {
+if (attr.value & VA_PREDICTION_DIRECTION_BI_NOT_EMPTY) {
+ctx->p_to_gpb = 1;
+av_log(avctx, AV_LOG_VERBOSE, "Use GPB B frames to replace "
+   "regular P frames.\n");


Maybe "Driver does not support P-frames, replacing them with B-frames."?


+} else
+av_log(avctx, AV_LOG_VERBOSE, "Use regular P frames.\n");
+}
+#endif
+
  if (ctx->codec->flags & FLAG_INTRA_ONLY ||
  avctx->gop_size <= 1) {
  av_log(avctx, AV_LOG_VERBOSE, "Using intra frames only.\n");
@@ -1861,8 +1885,13 @@ static av_cold int 
vaapi_encode_init_gop_structure(AVCodecContext *avctx)
  ctx->p_per_i  = INT_MAX;
  ctx->b_per_p  = 0;
  } else {
-av_log(avctx, AV_LOG_VERBOSE, "Using intra, P- and B-frames "
-   "(supported references: %d / %d).\n", ref_l0, ref_l1);
+   if (ctx->p_to_gpb)
+   av_log(avctx, AV_LOG_VERBOSE, "Using intra, GPB-B-frames and "
+  "B-frames (supported references: %d / %d).\n",
+  ref_l0, ref_l1);


Seems 

Re: [FFmpeg-devel] M1 Patchwork CI runner

2022-02-21 Thread Michael Niedermayer
On Sun, Feb 20, 2022 at 05:19:41PM -0500, Andriy Gelman wrote:
> Hello,
> 
> I understand we have some spare M1 minis for ffmpeg resources. 
> Do we want to set up a Patchwork CI runner on M1 hardware?

i think thats a good idea

thx


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

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus


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] lavfi/vf_libplacebo: support custom .cube LUTs

2022-02-21 Thread Anton Khirnov
Quoting Niklas Haas (2022-02-21 12:36:23)
> On Mon, 21 Feb 2022 12:33:19 +0100 Anton Khirnov  wrote:
> > Non-overridable IO in random places is evil.
> 
> Can you recommend a better way of accomplishing this?

How large are these? Can they be set directly as binary AVOptions?
We could invent syntax for ffmpeg.c to provide the contents of a file as
an option value.

-- 
Anton Khirnov
___
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] lavfi/vf_libplacebo: support custom .cube LUTs

2022-02-21 Thread Niklas Haas
On Mon, 21 Feb 2022 12:33:19 +0100 Anton Khirnov  wrote:
> Non-overridable IO in random places is evil.

Can you recommend a better way of accomplishing this?
___
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-21 Thread Paul B Mahol
On Mon, Feb 21, 2022 at 12:08 PM Anton Khirnov  wrote:

> Quoting Paul B Mahol (2022-02-20 19:07:47)
> > diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
> > index aab408d355..aaf1642b4f 100644
> > --- a/libavfilter/framepool.c
> > +++ b/libavfilter/framepool.c
> > @@ -76,15 +76,13 @@ 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;
> >  }
> > +if ((pool->linesize[0] & (pool->align - 1)))
>
> Check all of them, not just the first one.
>

Will do, it could overflow (among other things) in theory and result than
would not be wanted one.


>
> Otherwise looks good.
>
> --
> Anton Khirnov
> ___
> 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] lavfi/vf_libplacebo: support custom .cube LUTs

2022-02-21 Thread Anton Khirnov
Quoting Niklas Haas (2022-02-17 19:03:19)
> From: Niklas Haas 
> 
> Option boilerplate. Very soon we shall definitely need to add some sort
> of generic forward-proof option parsing mechanism to libplacebo..
> ---
>  libavfilter/vf_libplacebo.c | 78 +
>  1 file changed, 78 insertions(+)
> 
> diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
> index 31ae28ac38..0ee2db80ed 100644
> --- a/libavfilter/vf_libplacebo.c
> +++ b/libavfilter/vf_libplacebo.c
> @@ -26,6 +26,14 @@
>  #include 
>  #include 
>  
> +struct custom_lut {
> +const struct pl_custom_lut *lut;
> +char *path;
> +void *bin;
> +int bin_len;
> +int type;
> +};
> +
>  typedef struct LibplaceboContext {
>  /* lavfi vulkan*/
>  FFVulkanContext vkctx;
> @@ -115,6 +123,11 @@ typedef struct LibplaceboContext {
>  int shader_bin_len;
>  const struct pl_hook *hooks[2];
>  int num_hooks;
> +
> +/* custom LUTs */
> +struct custom_lut lut;
> +struct custom_lut input_lut;
> +struct custom_lut output_lut;
>  } LibplaceboContext;
>  
>  static inline enum pl_log_level get_log_level(void)
> @@ -202,6 +215,37 @@ static int libplacebo_init(AVFilterContext *avctx)
>  return 0;
>  }
>  
> +static int load_custom_lut(AVFilterContext *avctx, struct custom_lut *lut)
> +{
> +LibplaceboContext *s = avctx->priv;
> +uint8_t *buf = NULL;
> +size_t buf_len;
> +int err;
> +
> +if (lut->bin_len) {
> +// Binary specified
> +buf = lut->bin;
> +buf_len = lut->bin_len;
> +} else if (lut->path) {
> +// File path specified
> +if ((err = av_file_map(lut->path, , _len, 0, s)))

Non-overridable IO in random places is evil.

-- 
Anton Khirnov
___
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-21 Thread Mark Gaiser
On Thu, Feb 17, 2022 at 3:57 PM Mark Gaiser  wrote:

> On Thu, Feb 17, 2022 at 3:50 PM Mark Gaiser  wrote:
>
>> This patch adds support for:
>> - ffplay ipfs://
>> - ffplay ipns://
>>
>> IPFS data can be played from so called "ipfs gateways".
>> A gateway is essentially a webserver that gives access to the
>> distributed IPFS network.
>>
>> This protocol support (ipfs and ipns) therefore translates
>> ipfs:// and ipns:// to a http:// url. This resulting url is
>> then handled by the http protocol. It could also be https
>> depending on the gateway provided.
>>
>> To use this protocol, a gateway must be provided.
>> If you do nothing it will try to find it in your
>> $HOME/.ipfs/gateway file. The ways to set it manually are:
>> 1. Define a -gateway  to the gateway.
>> 2. Define $IPFS_GATEWAY with the full http link to the gateway.
>> 3. Define $IPFS_PATH and point it to the IPFS data path.
>> 4. Have IPFS running in your local user folder (under $HOME/.ipfs).
>>
>> Signed-off-by: Mark Gaiser 
>> ---
>>  configure |   2 +
>>  doc/protocols.texi|  30 
>>  libavformat/Makefile  |   2 +
>>  libavformat/ipfsgateway.c | 309 ++
>>  libavformat/protocols.c   |   2 +
>>  5 files changed, 345 insertions(+)
>>  create mode 100644 libavformat/ipfsgateway.c
>>
>> diff --git a/configure b/configure
>> index 5b19a35f59..6ff09e7974 100755
>> --- a/configure
>> +++ b/configure
>> @@ -3585,6 +3585,8 @@ udp_protocol_select="network"
>>  udplite_protocol_select="network"
>>  unix_protocol_deps="sys_un_h"
>>  unix_protocol_select="network"
>> +ipfs_protocol_select="https_protocol"
>> +ipns_protocol_select="https_protocol"
>>
>>  # external library protocols
>>  libamqp_protocol_deps="librabbitmq"
>> diff --git a/doc/protocols.texi b/doc/protocols.texi
>> index d207df0b52..7c9c0a4808 100644
>> --- a/doc/protocols.texi
>> +++ b/doc/protocols.texi
>> @@ -2025,5 +2025,35 @@ decoding errors.
>>
>>  @end table
>>
>> +@section ipfs
>> +
>> +InterPlanetary File System (IPFS) protocol support. One can access files
>> stored
>> +on the IPFS network through so called gateways. Those are http(s)
>> endpoints.
>> +This protocol wraps the IPFS native protocols (ipfs:// and ipns://) to
>> be send
>> +to such a gateway. Users can (and should) host their own node which
>> means this
>> +protocol will use your local machine gateway to access files on the IPFS
>> network.
>> +
>> +If a user doesn't have a node of their own then the public gateway
>> dweb.link is
>> +used by default.
>> +
>> +You can use this protocol in 2 ways. Using IPFS:
>> +@example
>> +ffplay ipfs://QmbGtJg23skhvFmu9mJiePVByhfzu5rwo74MEkVDYAmF5T
>> +@end example
>> +
>> +Or the IPNS protocol (IPNS is mutable IPFS):
>> +@example
>> +ffplay ipns://QmbGtJg23skhvFmu9mJiePVByhfzu5rwo74MEkVDYAmF5T
>> +@end example
>> +
>> +You can also change the gateway to be used:
>> +
>> +@table @option
>> +
>> +@item gateway
>> +Defines the gateway to use. When nothing is provided the protocol will
>> first try
>> +your local gateway. If that fails dweb.link will be used.
>> +
>> +@end table
>>
>>  @c man end PROTOCOLS
>> diff --git a/libavformat/Makefile b/libavformat/Makefile
>> index 3dc6a479cc..4edce8420f 100644
>> --- a/libavformat/Makefile
>> +++ b/libavformat/Makefile
>> @@ -656,6 +656,8 @@ OBJS-$(CONFIG_SRTP_PROTOCOL) +=
>> srtpproto.o srtp.o
>>  OBJS-$(CONFIG_SUBFILE_PROTOCOL)  += subfile.o
>>  OBJS-$(CONFIG_TEE_PROTOCOL)  += teeproto.o tee_common.o
>>  OBJS-$(CONFIG_TCP_PROTOCOL)  += tcp.o
>> +OBJS-$(CONFIG_IPFS_PROTOCOL) += ipfsgateway.o
>> +OBJS-$(CONFIG_IPNS_PROTOCOL) += ipfsgateway.o
>>  TLS-OBJS-$(CONFIG_GNUTLS)+= tls_gnutls.o
>>  TLS-OBJS-$(CONFIG_LIBTLS)+= tls_libtls.o
>>  TLS-OBJS-$(CONFIG_MBEDTLS)   += tls_mbedtls.o
>> diff --git a/libavformat/ipfsgateway.c b/libavformat/ipfsgateway.c
>> new file mode 100644
>> index 00..7dfa56871d
>> --- /dev/null
>> +++ b/libavformat/ipfsgateway.c
>> @@ -0,0 +1,309 @@
>> +/*
>> + * IPFS and IPNS protocol support through IPFS Gateway.
>> + * Copyright (c) 2022 Mark Gaiser
>> + *
>> + * 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, 

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

2022-02-21 Thread Paul B Mahol
On Mon, Feb 21, 2022 at 2:54 AM James Almer  wrote:

>
>
> On 2/20/2022 7:02 PM, Paul B Mahol wrote:
> > Signed-off-by: Paul B Mahol 
> > ---
> >   libavfilter/audio.c | 11 +--
> >   libavfilter/framepool.c | 16 ++--
> >   libavfilter/video.c | 11 +--
> >   3 files changed, 16 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..ebfd5dc0e0 100644
> > --- a/libavfilter/framepool.c
> > +++ b/libavfilter/framepool.c
> > @@ -76,14 +76,10 @@ 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++) {
> > @@ -92,11 +88,11 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef*
> (*alloc)(size_t size),
> >   }
> >
> >   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,
>
> Why are you removing the padding on each plane? Just add align padding
> bytes and it should be good.
>

linesize[i]  is already aligned, why would there be need for additional
align at end of buffer?


> >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 

[FFmpeg-devel] [PATCH] avformat/mov: stop ignoring subtitle packets durations

2022-02-21 Thread Paul B Mahol
Fixes #7855

Signed-off-by: Paul B Mahol 
---
 libavformat/mov.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 5e26267810..d980996086 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4359,7 +4359,8 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 av_freep(>chunk_offsets);
 av_freep(>sample_sizes);
 av_freep(>keyframes);
-av_freep(>stts_data);
+if (st->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
+av_freep(>stts_data);
 av_freep(>stps_data);
 av_freep(>elst_data);
 av_freep(>rap_group);
@@ -8323,6 +8324,11 @@ static int mov_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0;
 pkt->pos = sample->pos;
 
+if (sc->stts_data && st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+if (sc->current_index <= sc->stts_count && sc->current_index > 0)
+pkt->duration = sc->stts_data[sc->current_index - 1].duration;
+}
+
 /* Multiple stsd handling. */
 if (sc->stsc_data) {
 /* Keep track of the stsc index for the given sample, then check
-- 
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".


Re: [FFmpeg-devel] [PATCH] libavfilter: zscale performance optimization >4x

2022-02-21 Thread Anton Khirnov
> libavfilter: zscale performance optimization >4x

This reads like an advertisement rather than a useful description. It
should say what the patch does, performance improvement numbers should
be mentioned in the commit message body.

Quoting Victoria Zhislina (2022-02-21 09:20:55)
> By ffmpeg threading support implementation via frame slicing and doing
> zimg_filter_graph_build that used to take 30-60% of each frame processig
> only if necessary (some parameters changed)
> the performance increase vs original version
> in video downscale and color conversion  >4x is seen
> on 64 cores Intel Xeon, 3x on i7-6700K (4 cores with HT)

This implies the patch does multiple unrelated things. Then it should be
split in multiple patches, unless some important factor prevents that
(then that factor should be described in the commit message).

-- 
Anton Khirnov
___
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-21 Thread Anton Khirnov
Quoting Paul B Mahol (2022-02-20 19:07:47)
> diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
> index aab408d355..aaf1642b4f 100644
> --- a/libavfilter/framepool.c
> +++ b/libavfilter/framepool.c
> @@ -76,15 +76,13 @@ 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;
>  }
> +if ((pool->linesize[0] & (pool->align - 1)))

Check all of them, not just the first one.

Otherwise looks good.

-- 
Anton Khirnov
___
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 7/7] avformat/concat: refactor to use av_rescale_interval()

2022-02-21 Thread Nicolas George
p...@sandflow.com (12022-02-20):
> From: Pierre-Anthony Lemieux 
> 
> ---
>  libavformat/concatdec.c | 19 +--
>  1 file changed, 5 insertions(+), 14 deletions(-)

LGTM.

Regards,

-- 
  Nicolas George


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".


[FFmpeg-devel] [PATCH v2] libavcodec/qsvenc: add mbbrc to hevc_qsv

2022-02-21 Thread Wenbin Chen
Add mbbrc to hevc_qsv
For detailed description, please see "mbbrc" part in:
https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxextcodingoption2

Signed-off-by: Wenbin Chen 
---
 doc/encoders.texi   | 5 +
 libavcodec/qsvenc.c | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index bfb6c7eef6..4325fdd6b0 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3404,6 +3404,11 @@ Maximum encoded frame size in bytes.
 @item @var{max_slice_size}
 Maximum encoded slice size in bytes.
 
+@item @var{mbbrc}
+Setting this flag enables macroblock level bitrate control that generally
+improves subjective visual quality. Enabling this flag may have negative impact
+on performance and objective visual quality metric.
+
 @item @var{p_strategy}
 Enable P-pyramid: 0-default 1-simple 2-pyramid(bf need to be set to 0).
 
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 07be4287b7..3aed0508a4 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -877,8 +877,6 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 if (avctx->codec_id == AV_CODEC_ID_H264) {
 if (q->bitrate_limit >= 0)
 q->extco2.BitrateLimit = q->bitrate_limit ? 
MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
-if (q->mbbrc >= 0)
-q->extco2.MBBRC = q->mbbrc ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
 
 #if QSV_HAVE_TRELLIS
 if (avctx->trellis >= 0)
@@ -935,6 +933,9 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 q->extco2.MaxQPP = q->extco2.MaxQPB = q->extco2.MaxQPI;
 }
 #endif
+if (q->mbbrc >= 0)
+q->extco2.MBBRC = q->mbbrc ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
+
 q->extco2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2;
 q->extco2.Header.BufferSz = sizeof(q->extco2);
 
-- 
2.32.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] libavfilter: zscale performance optimization >4x

2022-02-21 Thread Victoria Zhislina
By ffmpeg threading support implementation via frame slicing and doing
zimg_filter_graph_build that used to take 30-60% of each frame processig
only if necessary (some parameters changed)
the performance increase vs original version
in video downscale and color conversion  >4x is seen
on 64 cores Intel Xeon, 3x on i7-6700K (4 cores with HT)

Signed-off-by: Victoria Zhislina 
---
 libavfilter/vf_zscale.c | 413 +++-
 1 file changed, 284 insertions(+), 129 deletions(-)

diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index 1288c5efc1..dd0017607e 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2015 Paul B Mahol
- *
+ * 2022 Victoria Zhislina, Intel
+
  * This file is part of FFmpeg.
  *
  * FFmpeg is free software; you can redistribute it and/or
@@ -44,6 +45,8 @@
 #include "libavutil/imgutils.h"
 
 #define ZIMG_ALIGNMENT 32
+#define MIN_TILESIZE 64
+#define MAX_THREADS 64
 
 static const char *const var_names[] = {
 "in_w",   "iw",
@@ -113,13 +116,17 @@ typedef struct ZScaleContext {
 
 int force_original_aspect_ratio;
 
-void *tmp;
-size_t tmp_size;
+void *tmp[MAX_THREADS]; //separate for each thread;
+int nb_threads;
+int slice_h;
 
 zimg_image_format src_format, dst_format;
 zimg_image_format alpha_src_format, alpha_dst_format;
+zimg_image_format src_format_tmp, dst_format_tmp;
+zimg_image_format alpha_src_format_tmp, alpha_dst_format_tmp;
 zimg_graph_builder_params alpha_params, params;
-zimg_filter_graph *alpha_graph, *graph;
+zimg_graph_builder_params alpha_params_tmp, params_tmp;
+zimg_filter_graph *alpha_graph[MAX_THREADS], *graph[MAX_THREADS];
 
 enum AVColorSpace in_colorspace, out_colorspace;
 enum AVColorTransferCharacteristic in_trc, out_trc;
@@ -128,10 +135,35 @@ typedef struct ZScaleContext {
 enum AVChromaLocation in_chromal, out_chromal;
 } ZScaleContext;
 
+typedef struct ThreadData {
+const AVPixFmtDescriptor *desc, *odesc;
+AVFrame *in, *out;
+} ThreadData;
+
 static av_cold int init(AVFilterContext *ctx)
 {
 ZScaleContext *s = ctx->priv;
 int ret;
+int i;
+for (i = 0; i < MAX_THREADS; i++) {
+s->tmp[i] = NULL;
+s->graph[i] = NULL;
+s->alpha_graph[i] = NULL;
+}
+zimg_image_format_default(>src_format, ZIMG_API_VERSION);
+zimg_image_format_default(>dst_format, ZIMG_API_VERSION);
+zimg_image_format_default(>src_format_tmp, ZIMG_API_VERSION);
+zimg_image_format_default(>dst_format_tmp, ZIMG_API_VERSION);
+
+zimg_image_format_default(>alpha_src_format, ZIMG_API_VERSION);
+zimg_image_format_default(>alpha_dst_format, ZIMG_API_VERSION);
+zimg_image_format_default(>alpha_src_format_tmp, ZIMG_API_VERSION);
+zimg_image_format_default(>alpha_dst_format_tmp, ZIMG_API_VERSION);
+
+zimg_graph_builder_params_default(>params, ZIMG_API_VERSION);
+zimg_graph_builder_params_default(>params_tmp, ZIMG_API_VERSION);
+zimg_graph_builder_params_default(>alpha_params, ZIMG_API_VERSION);
+zimg_graph_builder_params_default(>alpha_params_tmp, ZIMG_API_VERSION);
 
 if (s->size_str && (s->w_expr || s->h_expr)) {
 av_log(ctx, AV_LOG_ERROR,
@@ -158,7 +190,6 @@ static av_cold int init(AVFilterContext *ctx)
 av_opt_set(s, "w", "iw", 0);
 if (!s->h_expr)
 av_opt_set(s, "h", "ih", 0);
-
 return 0;
 }
 
@@ -471,6 +502,51 @@ static enum AVColorRange convert_range_from_zimg(enum 
zimg_pixel_range_e color_r
 return AVCOL_RANGE_UNSPECIFIED;
 }
 
+/* returns 0 if image formats are the same and 1 otherwise */
+static int compare_zimg_image_formats(zimg_image_format *img_fmt0, 
zimg_image_format *img_fmt1)
+{
+return ((img_fmt0->chroma_location != img_fmt1->chroma_location) ||
+#if ZIMG_API_VERSION >= 0x204
+(img_fmt0->alpha != img_fmt1->alpha) ||
+#endif
+(img_fmt0->color_family != img_fmt1->color_family) ||
+(img_fmt0->color_primaries != img_fmt1->color_primaries) ||
+(img_fmt0->depth != img_fmt1->depth) ||
+(img_fmt0->field_parity != img_fmt1->field_parity) ||
+(img_fmt0->height != img_fmt1->height) ||
+(img_fmt0->matrix_coefficients != img_fmt1->matrix_coefficients) ||
+(img_fmt0->pixel_range != img_fmt1->pixel_range) ||
+(img_fmt0->pixel_type != img_fmt1->pixel_type) ||
+(img_fmt0->subsample_h != img_fmt1->subsample_h) ||
+(img_fmt0->subsample_w != img_fmt1->subsample_w) ||
+(img_fmt0->transfer_characteristics != 
img_fmt1->transfer_characteristics) ||
+(img_fmt0->width != img_fmt1->width));
+}
+
+/* returns 0 if graph builder parameters are the same and 1 otherwise */
+static int compare_zimg_graph_builder_params(zimg_graph_builder_params *parm0, 
zimg_graph_builder_params *parm1)
+{
+/* the parameters that could be changed inside a single ffmpeg zscale 
invocation  are checked only
+and NaN values