Re: [FFmpeg-devel] libavformat/tls_mbedtls.c: Accommodating to mbedtls v3.0.0 API changes

2021-10-31 Thread omer yacine
Hello,

Let me ping this patch since I got no response after 4 days.

Thanks,

--Omar

On Thu, Oct 28, 2021 at 8:11 PM meryacine  wrote:

>
> There were breaking API changes in mbedtls from v2.27.0 to v3.0.0.
> This patch accounts for these changes.
>
> Changes:
> - mbedtls/certs.h is no longer imported. See
> https://github.com/ARMmbed/mbedtls/pull/4119.
> - mbedtls/config.h is replaced with mbedtls/build_info.h. See
> https://github.com/ARMmbed/mbedtls/blob/v3.0.0/docs/3.0-migration-guide.md#introduce-a-level-of-indirection-and-versioning-in-the-config-files
> .
> - MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE is replaced with
> MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE. See
> https://github.com/ARMmbed/mbedtls/blob/v3.0.0/docs/3.0-migration-guide.md#changes-in-the-ssl-error-code-space
> .
> - The function mbedtls_pk_parse_keyfile should now be given 2 more
> arguments. See
> https://github.com/ARMmbed/mbedtls/blob/v3.0.0/docs/3.0-migration-guide.md#some-functions-gained-an-rng-parameter
> .
>
> Signed-off-by: meryacine 
> ---
>  libavformat/tls_mbedtls.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
>
___
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 3/3] libavcodec/vaapi_encode: Add async_depth to vaapi_encoder to increase performance

2021-10-31 Thread Chen, Wenbin
> Add async_depth to increase encoder's performance. Reuse encode_fifo as
> async buffer. Encoder puts all reordered frame to HW and then check
> fifo size. If fifo < async_depth and the top frame is not ready, it will
> return AVERROR(EAGAIN) to require more frames.
> 
> 1080p transcoding (no B frames) with -async_depth=4 can increase 20%
> performance on my environment.
> The async increases performance but also introduces frame delay.
> 
> Signed-off-by: Wenbin Chen 
> ---
>  libavcodec/vaapi_encode.c | 20 +++-
>  libavcodec/vaapi_encode.h | 12 ++--
>  2 files changed, 25 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index db0ae136a1..616fb7c089 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -1158,7 +1158,8 @@ static int
> vaapi_encode_send_frame(AVCodecContext *avctx, AVFrame *frame)
>  if (ctx->input_order == ctx->decode_delay)
>  ctx->dts_pts_diff = pic->pts - ctx->first_pts;
>  if (ctx->output_delay > 0)
> -ctx->ts_ring[ctx->input_order % (3 * ctx->output_delay)] = 
> pic->pts;
> +ctx->ts_ring[ctx->input_order %
> +(3 * ctx->output_delay + ctx->async_depth)] = 
> pic->pts;
> 
>  pic->display_order = ctx->input_order;
>  ++ctx->input_order;
> @@ -1212,7 +1213,8 @@ int
> ff_vaapi_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
>  return AVERROR(EAGAIN);
>  }
> 
> -while (av_fifo_size(ctx->encode_fifo) <= MAX_PICTURE_REFERENCES *
> sizeof(VAAPIEncodePicture *)) {
> +while (av_fifo_size(ctx->encode_fifo) <
> +MAX_ASYNC_DEPTH * sizeof(VAAPIEncodePicture *)) {
>  pic = NULL;
>  err = vaapi_encode_pick_next(avctx, &pic);
>  if (err < 0)
> @@ -1234,6 +1236,14 @@ int
> ff_vaapi_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
>  if (!av_fifo_size(ctx->encode_fifo))
>  return err;
> 
> +if (av_fifo_size(ctx->encode_fifo) < ctx->async_depth *
> sizeof(VAAPIEncodePicture *) &&
> +!ctx->end_of_stream) {
> +av_fifo_generic_peek(ctx->encode_fifo, &pic, sizeof(pic), NULL);
> +err = vaapi_encode_wait(avctx, pic, 0);
> +if (err < 0)
> +return err;
> +}
> +
>  av_fifo_generic_read(ctx->encode_fifo, &pic, sizeof(pic), NULL);
>  ctx->encode_order = pic->encode_order + 1;
> 
> @@ -1252,7 +1262,7 @@ int
> ff_vaapi_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
>  pkt->dts = ctx->ts_ring[pic->encode_order] - ctx->dts_pts_diff;
>  } else {
>  pkt->dts = ctx->ts_ring[(pic->encode_order - ctx->decode_delay) %
> -(3 * ctx->output_delay)];
> +(3 * ctx->output_delay + ctx->async_depth)];
>  }
>  av_log(avctx, AV_LOG_DEBUG, "Output packet: pts %"PRId64"
> dts %"PRId64".\n",
> pkt->pts, pkt->dts);
> @@ -2566,8 +2576,8 @@ av_cold int ff_vaapi_encode_init(AVCodecContext
> *avctx)
>  }
>  }
> 
> -ctx->encode_fifo = av_fifo_alloc((MAX_PICTURE_REFERENCES + 1) *
> -  sizeof(VAAPIEncodePicture *));
> +ctx->encode_fifo = av_fifo_alloc(MAX_ASYNC_DEPTH *
> + sizeof(VAAPIEncodePicture *));
>  if (!ctx->encode_fifo)
>  return AVERROR(ENOMEM);
> 
> diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
> index 89fe8de466..1bf5d7c337 100644
> --- a/libavcodec/vaapi_encode.h
> +++ b/libavcodec/vaapi_encode.h
> @@ -48,6 +48,7 @@ enum {
>  MAX_TILE_ROWS  = 22,
>  // A.4.1: table A.6 allows at most 20 tile columns for any level.
>  MAX_TILE_COLS  = 20,
> +MAX_ASYNC_DEPTH= 64,
>  };
> 
>  extern const AVCodecHWConfigInternal *const
> ff_vaapi_encode_hw_configs[];
> @@ -298,7 +299,8 @@ typedef struct VAAPIEncodeContext {
>  // Timestamp handling.
>  int64_t first_pts;
>  int64_t dts_pts_diff;
> -int64_t ts_ring[MAX_REORDER_DELAY * 3];
> +int64_t ts_ring[MAX_REORDER_DELAY * 3 +
> +MAX_ASYNC_DEPTH];
> 
>  // Slice structure.
>  int slice_block_rows;
> @@ -348,6 +350,8 @@ typedef struct VAAPIEncodeContext {
>  AVFrame *frame;
> 
>  AVFifoBuffer *encode_fifo;
> +
> +int async_depth;
>  } VAAPIEncodeContext;
> 
>  enum {
> @@ -458,7 +462,11 @@ int ff_vaapi_encode_close(AVCodecContext *avctx);
>  { "b_depth", \
>"Maximum B-frame reference depth", \
>OFFSET(common.desired_b_depth), AV_OPT_TYPE_INT, \
> -  { .i64 = 1 }, 1, INT_MAX, FLAGS }
> +  { .i64 = 1 }, 1, INT_MAX, FLAGS }, \
> +{ "async_depth", "Maximum processing parallelism. " \
> +  "Increase this to improve single channel performance", \
> +  OFFSET(common.async_depth), AV_OPT_TYPE_INT, \
> +  { .i64 = 4 }, 0, MAX_ASYNC_DE

Re: [FFmpeg-devel] [PATCH 2/3] libavcodec/vaapi_encode: Add new API adaption to vaapi_encode

2021-10-31 Thread Chen, Wenbin
> Add vaSyncBuffer to VAAPI encoder. Old version API vaSyncSurface wait
> surface to complete. When surface is used for multiple operation, it
> wait all operation to finish. vaSyncBuffer only wait one channel to
> finish.
> 
> Add wait param to vaapi_encode_wait() to prepare for the async_depth
> option. "wait=1" means wait until operation ready. "wait=0" means
> query operation's status. If ready return 0, if still in progress
> return EAGAIN.
> 
> Signed-off-by: Wenbin Chen 
> ---
>  libavcodec/vaapi_encode.c | 47 +--
>  1 file changed, 40 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index 5927849233..db0ae136a1 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -134,7 +134,8 @@ static int
> vaapi_encode_make_misc_param_buffer(AVCodecContext *avctx,
>  }
> 
>  static int vaapi_encode_wait(AVCodecContext *avctx,
> - VAAPIEncodePicture *pic)
> + VAAPIEncodePicture *pic,
> + uint8_t wait)
>  {
>  VAAPIEncodeContext *ctx = avctx->priv_data;
>  VAStatus vas;
> @@ -150,11 +151,43 @@ static int vaapi_encode_wait(AVCodecContext
> *avctx,
> "(input surface %#x).\n", pic->display_order,
> pic->encode_order, pic->input_surface);
> 
> -vas = vaSyncSurface(ctx->hwctx->display, pic->input_surface);
> -if (vas != VA_STATUS_SUCCESS) {
> -av_log(avctx, AV_LOG_ERROR, "Failed to sync to picture completion: "
> -   "%d (%s).\n", vas, vaErrorStr(vas));
> +#if VA_CHECK_VERSION(1, 9, 0)
> +// Try vaSyncBuffer.
> +vas = vaSyncBuffer(ctx->hwctx->display,
> +   pic->output_buffer,
> +   wait ? VA_TIMEOUT_INFINITE : 0);
> +if (vas == VA_STATUS_ERROR_TIMEDOUT) {
> +return AVERROR(EAGAIN);
> +} else if (vas != VA_STATUS_SUCCESS && vas !=
> VA_STATUS_ERROR_UNIMPLEMENTED) {
> +av_log(avctx, AV_LOG_ERROR, "Failed to sync to output buffer
> completion: "
> +"%d (%s).\n", vas, vaErrorStr(vas));
>  return AVERROR(EIO);
> +} else if (vas == VA_STATUS_ERROR_UNIMPLEMENTED)
> +// If vaSyncBuffer is not implemented, try old version API.
> +#endif
> +{
> +if (!wait) {
> +VASurfaceStatus surface_status;
> +vas = vaQuerySurfaceStatus(ctx->hwctx->display,
> +pic->input_surface,
> +&surface_status);
> +if (vas == VA_STATUS_SUCCESS &&
> +surface_status != VASurfaceReady &&
> +surface_status != VASurfaceSkipped) {
> +return AVERROR(EAGAIN);
> +} else if (vas != VA_STATUS_SUCCESS) {
> +av_log(avctx, AV_LOG_ERROR, "Failed to query surface status: 
> "
> +"%d (%s).\n", vas, vaErrorStr(vas));
> +return AVERROR(EIO);
> +}
> +} else {
> +vas = vaSyncSurface(ctx->hwctx->display, pic->input_surface);
> +if (vas != VA_STATUS_SUCCESS) {
> +av_log(avctx, AV_LOG_ERROR, "Failed to sync to picture
> completion: "
> +"%d (%s).\n", vas, vaErrorStr(vas));
> +return AVERROR(EIO);
> +}
> +}
>  }
> 
>  // Input is definitely finished with now.
> @@ -633,7 +666,7 @@ static int vaapi_encode_output(AVCodecContext
> *avctx,
>  uint8_t *ptr;
>  int err;
> 
> -err = vaapi_encode_wait(avctx, pic);
> +err = vaapi_encode_wait(avctx, pic, 1);
>  if (err < 0)
>  return err;
> 
> @@ -695,7 +728,7 @@ fail:
>  static int vaapi_encode_discard(AVCodecContext *avctx,
>  VAAPIEncodePicture *pic)
>  {
> -vaapi_encode_wait(avctx, pic);
> +vaapi_encode_wait(avctx, pic, 1);
> 
>  if (pic->output_buffer_ref) {
>  av_log(avctx, AV_LOG_DEBUG, "Discard output for pic "
> --
> 2.25.1

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

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


Re: [FFmpeg-devel] [PATCH 1/3] libavcodec/vaapi_encode: Change the way to call async to increase performance

2021-10-31 Thread Chen, Wenbin
> Fix: #7706. After commit 5fdcf85bbffe7451c2, vaapi encoder's performance
> decrease. The reason is that vaRenderPicture() and vaSyncSurface() are
> called at the same time (vaRenderPicture() always followed by a
> vaSyncSurface()). When we encode stream with B frames, we need buffer to
> reorder frames, so we can send serveral frames to HW at once to increase
> performance. Now I changed them to be called in a
> asynchronous way, which will make better use of hardware.
> 1080p transcoding increases about 17% fps on my environment.
> 
> Signed-off-by: Wenbin Chen 
> ---
>  libavcodec/vaapi_encode.c | 41 ---
>  libavcodec/vaapi_encode.h |  3 +++
>  2 files changed, 33 insertions(+), 11 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index ec054ae701..5927849233 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -951,8 +951,10 @@ static int vaapi_encode_pick_next(AVCodecContext
> *avctx,
>  if (!pic && ctx->end_of_stream) {
>  --b_counter;
>  pic = ctx->pic_end;
> -if (pic->encode_issued)
> +if (pic->encode_complete)
>  return AVERROR_EOF;
> +else if (pic->encode_issued)
> +return AVERROR(EAGAIN);
>  }
> 
>  if (!pic) {
> @@ -1177,20 +1179,31 @@ int
> ff_vaapi_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
>  return AVERROR(EAGAIN);
>  }
> 
> -pic = NULL;
> -err = vaapi_encode_pick_next(avctx, &pic);
> -if (err < 0)
> -return err;
> -av_assert0(pic);
> +while (av_fifo_size(ctx->encode_fifo) <= MAX_PICTURE_REFERENCES *
> sizeof(VAAPIEncodePicture *)) {
> +pic = NULL;
> +err = vaapi_encode_pick_next(avctx, &pic);
> +if (err < 0)
> +break;
> +av_assert0(pic);
> 
> -pic->encode_order = ctx->encode_order++;
> +pic->encode_order = ctx->encode_order +
> +(av_fifo_size(ctx->encode_fifo) / 
> sizeof(VAAPIEncodePicture
> *));
> 
> -err = vaapi_encode_issue(avctx, pic);
> -if (err < 0) {
> -av_log(avctx, AV_LOG_ERROR, "Encode failed: %d.\n", err);
> -return err;
> +err = vaapi_encode_issue(avctx, pic);
> +if (err < 0) {
> +av_log(avctx, AV_LOG_ERROR, "Encode failed: %d.\n", err);
> +return err;
> +}
> +
> +av_fifo_generic_write(ctx->encode_fifo, &pic, sizeof(pic), NULL);
>  }
> 
> +if (!av_fifo_size(ctx->encode_fifo))
> +return err;
> +
> +av_fifo_generic_read(ctx->encode_fifo, &pic, sizeof(pic), NULL);
> +ctx->encode_order = pic->encode_order + 1;
> +
>  err = vaapi_encode_output(avctx, pic, pkt);
>  if (err < 0) {
>  av_log(avctx, AV_LOG_ERROR, "Output failed: %d.\n", err);
> @@ -2520,6 +2533,11 @@ av_cold int
> ff_vaapi_encode_init(AVCodecContext *avctx)
>  }
>  }
> 
> +ctx->encode_fifo = av_fifo_alloc((MAX_PICTURE_REFERENCES + 1) *
> +  sizeof(VAAPIEncodePicture *));
> +if (!ctx->encode_fifo)
> +return AVERROR(ENOMEM);
> +
>  return 0;
> 
>  fail:
> @@ -2552,6 +2570,7 @@ av_cold int
> ff_vaapi_encode_close(AVCodecContext *avctx)
> 
>  av_freep(&ctx->codec_sequence_params);
>  av_freep(&ctx->codec_picture_params);
> +av_fifo_freep(&ctx->encode_fifo);
> 
>  av_buffer_unref(&ctx->recon_frames_ref);
>  av_buffer_unref(&ctx->input_frames_ref);
> diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
> index b41604a883..89fe8de466 100644
> --- a/libavcodec/vaapi_encode.h
> +++ b/libavcodec/vaapi_encode.h
> @@ -29,6 +29,7 @@
> 
>  #include "libavutil/hwcontext.h"
>  #include "libavutil/hwcontext_vaapi.h"
> +#include "libavutil/fifo.h"
> 
>  #include "avcodec.h"
>  #include "hwconfig.h"
> @@ -345,6 +346,8 @@ typedef struct VAAPIEncodeContext {
>  int roi_warned;
> 
>  AVFrame *frame;
> +
> +AVFifoBuffer *encode_fifo;
>  } VAAPIEncodeContext;
> 
>  enum {
> --
> 2.25.1

ping

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

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


[FFmpeg-devel] [PATCH 2/2] avcodec/dnxhddata: remove invalid trimming of frame size

2021-10-31 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/dnxhddata.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/dnxhddata.c b/libavcodec/dnxhddata.c
index 3a69a0f501..b5c66dfe1d 100644
--- a/libavcodec/dnxhddata.c
+++ b/libavcodec/dnxhddata.c
@@ -1099,8 +1099,7 @@ int avpriv_dnxhd_get_hr_frame_size(int cid, int w, int h)
 if (!entry)
 return -1;
 
-result = ((h + 15) / 16) * ((w + 15) / 16) * 
(int64_t)entry->packet_scale.num / entry->packet_scale.den;
-result = (result + 2048) / 4096 * 4096;
+result = av_rescale(((h + 15) / 16) * ((w + 15) / 16), 
entry->packet_scale.num, entry->packet_scale.den);
 
 return FFMAX(result, 8192);
 }
-- 
2.33.0

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

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


[FFmpeg-devel] [PATCH 1/2] avcodec/dnxhd_parser: make parser more reliable for smaller VBR frame sizes

2021-10-31 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/dnxhd_parser.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libavcodec/dnxhd_parser.c b/libavcodec/dnxhd_parser.c
index 4ba619c9bb..ff80294cca 100644
--- a/libavcodec/dnxhd_parser.c
+++ b/libavcodec/dnxhd_parser.c
@@ -62,7 +62,14 @@ static int dnxhd_find_frame_end(DNXHDParserContext *dctx,
 dctx->cur_byte++;
 state = (state << 8) | buf[i];
 
-if (dctx->cur_byte == 24) {
+if (dctx->cur_byte > 42 && (state & 0x) == 0x600DC0DE) {
+int remaining = i + 1;
+pc->frame_start_found = 0;
+pc->state64 = -1;
+dctx->cur_byte = 0;
+dctx->remaining = 0;
+return remaining;
+} else if (dctx->cur_byte == 24) {
 dctx->h = (state >> 32) & 0x;
 } else if (dctx->cur_byte == 26) {
 dctx->w = (state >> 32) & 0x;
@@ -74,11 +81,8 @@ static int dnxhd_find_frame_end(DNXHDParserContext *dctx,
 continue;
 
 remaining = avpriv_dnxhd_get_frame_size(cid);
-if (remaining <= 0) {
-remaining = avpriv_dnxhd_get_hr_frame_size(cid, dctx->w, 
dctx->h);
-if (remaining <= 0)
-continue;
-}
+if (remaining <= 0)
+continue;
 remaining += i - 47;
 dctx->remaining = remaining;
 if (buf_size >= dctx->remaining) {
-- 
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 3/5] avformat/imf: Demuxer implementation

2021-10-31 Thread Pierre-Anthony Lemieux
On Sun, Oct 31, 2021 at 11:45 AM James Almer  wrote:
>
> On 10/31/2021 3:34 PM, Pierre-Anthony Lemieux wrote:
> >>> The functions are not static and are defined in imf_internal.h. They
> >>> are used in both libavformat/imfdec.c and the tests at
> >>> libavformat/tests/imf.c. Ok?
> >>
> >> If they are used in libavformat only it should be static.
> > AFAIK static functions are only available in the compilation unit
> > where they are defined, so if a static function (e.g.
> > `parse_imf_asset_map_from_xml_dom()`) is defined in
> > libavformat/imf_dec.c, it will not be available in
> > libavformat/tests/imf.c.
> >
> > Functions that can be used by other FFMPEG modules are declared in
> > "imf.h", whereas functions that are intended to be used only by the
> > IMF demuxer are declared in "imf_internal.h".
> >
> > For example, both "libavformat/tests/imf.c" and "libavformat/imfdec.c"
> > include "libavformat/imf_internal.h" so they can access
> > `parse_imf_asset_map_from_xml_dom()`.
> >
> > Does that work? Any alternative?
>
> Tests in the library's test folder can and usually include the actual .c
> file from the module they are testing, so making it static will work fine.

Ok. To summarize:

- functions used only by "imf_.c" should be static in "imf_.c,
and tests should include "imf_.c"
- any function/structure used by both "imf_.c" and "imf_.c"
should be declared in "imf.h", even if the function/structure is not
intended to be used beyond "imf_.c" and "imf_.c"

In other words, splitting imf-related functions into "imf.h"
(functions potentially for use beyond the IMF demuxer) and
"imf_internal.h" (functions not for use beyond the IMF demuxer) is not
desirable.

Ok? Happy either way, just want to make sure I get the next patch
version right :)




> ___
> 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 3/5] avformat/imf: Demuxer implementation

2021-10-31 Thread James Almer

On 10/31/2021 3:34 PM, Pierre-Anthony Lemieux wrote:

The functions are not static and are defined in imf_internal.h. They
are used in both libavformat/imfdec.c and the tests at
libavformat/tests/imf.c. Ok?


If they are used in libavformat only it should be static.

AFAIK static functions are only available in the compilation unit
where they are defined, so if a static function (e.g.
`parse_imf_asset_map_from_xml_dom()`) is defined in
libavformat/imf_dec.c, it will not be available in
libavformat/tests/imf.c.

Functions that can be used by other FFMPEG modules are declared in
"imf.h", whereas functions that are intended to be used only by the
IMF demuxer are declared in "imf_internal.h".

For example, both "libavformat/tests/imf.c" and "libavformat/imfdec.c"
include "libavformat/imf_internal.h" so they can access
`parse_imf_asset_map_from_xml_dom()`.

Does that work? Any alternative?


Tests in the library's test folder can and usually include the actual .c 
file from the module they are testing, so making it static will work fine.

___
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 3/5] avformat/imf: Demuxer implementation

2021-10-31 Thread Paul B Mahol
On Sun, Oct 31, 2021 at 7:34 PM Pierre-Anthony Lemieux 
wrote:

> On Thu, Oct 28, 2021 at 12:58 AM Paul B Mahol  wrote:
> >
> >
> >
> > On Thu, Oct 28, 2021 at 6:32 AM Pierre-Anthony Lemieux 
> wrote:
> >>
> >> On Wed, Oct 27, 2021 at 12:54 AM Paul B Mahol  wrote:
> >> >
> >> >
> >> >
> >> > On Fri, Oct 8, 2021 at 1:42 AM  wrote:
> >> >>
> >> >> From: Pierre-Anthony Lemieux 
> >> >>
> >> >> Signed-off-by: Pierre-Anthony Lemieux 
> >> >> ---
> >> >>
> >> >> Notes:
> >> >> Implements the IMF demuxer.
> >> >>
> >> >>  libavformat/imfdec.c | 660
> +++
> >> >>  1 file changed, 660 insertions(+)
> >> >>  create mode 100644 libavformat/imfdec.c
> >> >>
> >> >> diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
> >> >> new file mode 100644
> >> >> index 00..0c64fe0c03
> >> >> --- /dev/null
> >> >> +++ b/libavformat/imfdec.c
> >> >> @@ -0,0 +1,660 @@
> >> >> +/*
> >> >> + * Copyright (c) Sandflow Consulting LLC
> >> >> + *
> >> >> + * Redistribution and use in source and binary forms, with or
> without
> >> >> + * modification, are permitted provided that the following
> conditions are met:
> >> >> + *
> >> >> + * * Redistributions of source code must retain the above copyright
> notice, this
> >> >> + *   list of conditions and the following disclaimer.
> >> >> + * * Redistributions in binary form must reproduce the above
> copyright notice,
> >> >> + *   this list of conditions and the following disclaimer in the
> documentation
> >> >> + *   and/or other materials provided with the distribution.
> >> >> + *
> >> >> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
> CONTRIBUTORS "AS IS"
> >> >> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> LIMITED TO, THE
> >> >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
> PARTICULAR PURPOSE
> >> >> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
> CONTRIBUTORS BE
> >> >> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
> OR
> >> >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
> PROCUREMENT OF
> >> >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
> BUSINESS
> >> >> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
> WHETHER IN
> >> >> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
> OTHERWISE)
> >> >> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
> ADVISED OF THE
> >> >> + * POSSIBILITY OF SUCH DAMAGE.
> >> >> + *
> >> >> + * This file is part of FFmpeg.
> >> >> + *
> >> >> + * FFmpeg is free software; you can redistribute it and/or
> >> >> + * modify it under the terms of the GNU Lesser General Public
> >> >> + * License as published by the Free Software Foundation; either
> >> >> + * version 2.1 of the License, or (at your option) any later
> version.
> >> >> + *
> >> >> + * FFmpeg is distributed in the hope that it will be useful,
> >> >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >> >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> >> >> + * Lesser General Public License for more details.
> >> >> + *
> >> >> + * You should have received a copy of the GNU Lesser General Public
> >> >> + * License along with FFmpeg; if not, write to the Free Software
> >> >> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> >> >> + */
> >> >> +
> >> >> +/**
> >> >> + * Demuxes an IMF Composition
> >> >> + *
> >> >> + * References
> >> >> + * OV 2067-0:2018 - SMPTE Overview Document - Interoperable Master
> Format
> >> >> + * ST 2067-2:2020 - SMPTE Standard - Interoperable Master Format —
> Core Constraints
> >> >> + * ST 2067-3:2020 - SMPTE Standard - Interoperable Master Format —
> Composition Playlist
> >> >> + * ST 2067-5:2020 - SMPTE Standard - Interoperable Master Format —
> Essence Component
> >> >> + * ST 2067-20:2016 - SMPTE Standard - Interoperable Master Format —
> Application #2
> >> >> + * ST 2067-21:2020 - SMPTE Standard - Interoperable Master Format —
> Application #2 Extended
> >> >> + * ST 2067-102:2017 - SMPTE Standard - Interoperable Master Format
> — Common Image Pixel Color Schemes
> >> >> + * ST 429-9:2007 - SMPTE Standard - D-Cinema Packaging — Asset
> Mapping and File Segmentation
> >> >> + *
> >> >> + * @author Marc-Antoine Arnaud
> >> >> + * @author Valentin Noel
> >> >> + * @file
> >> >> + * @ingroup lavu_imf
> >> >> + */
> >> >> +
> >> >> +#include "imf.h"
> >> >> +#include "imf_internal.h"
> >> >> +#include "internal.h"
> >> >> +#include "libavutil/opt.h"
> >> >> +#include "libavutil/bprint.h"
> >> >> +#include "libavutil/avstring.h"
> >> >> +#include "mxf.h"
> >> >> +#include "url.h"
> >> >> +#include 
> >> >> +#include 
> >> >> +
> >> >> +#define MAX_BPRINT_READ_SIZE (UINT_MAX - 1)
> >> >> +#define DEFAULT_ASSETMAP_SIZE 8 * 1024
> >> >> +
> >> >> +typedef struct IMFVirtualTrackResourcePlaybackCtx {
> >> >> +IMFAssetLocator *locator;
> >> >> +IMFTrackFil

Re: [FFmpeg-devel] [PATCH 2/5] avformat/imf: CPL processor

2021-10-31 Thread Pierre-Anthony Lemieux
On Sun, Oct 31, 2021 at 11:35 AM Paul B Mahol  wrote:
>
>
>
> On Sun, Oct 31, 2021 at 5:48 PM Pierre-Anthony Lemieux  
> wrote:
>>
>> On Thu, Oct 28, 2021 at 12:56 AM Paul B Mahol  wrote:
>> >
>> >
>> >
>> > On Thu, Oct 28, 2021 at 6:34 AM Pierre-Anthony Lemieux  
>> > wrote:
>> >>
>> >> On Wed, Oct 27, 2021 at 12:57 AM Paul B Mahol  wrote:
>> >> >
>> >> >
>> >> >
>> >> > On Wed, Oct 20, 2021 at 4:55 PM  wrote:
>> >> >>
>> >> >> From: Pierre-Anthony Lemieux 
>> >> >>
>> >> >> Signed-off-by: Pierre-Anthony Lemieux 
>> >> >> ---
>> >> >>
>> >> >> Notes:
>> >> >> Implements IMF Composition Playlist (CPL) parsing.
>> >> >>
>> >> >>  libavformat/imf_cpl.c | 666 ++
>> >> >>  1 file changed, 666 insertions(+)
>> >> >>  create mode 100644 libavformat/imf_cpl.c
>> >> >>
>> >> >> diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c
>> >> >> new file mode 100644
>> >> >> index 00..8ef574ad78
>> >> >> --- /dev/null
>> >> >> +++ b/libavformat/imf_cpl.c
>> >> >> @@ -0,0 +1,666 @@
>> >> >> +/*
>> >> >> + * Copyright (c) Sandflow Consulting LLC
>> >> >> + *
>> >> >> + * Redistribution and use in source and binary forms, with or without
>> >> >> + * modification, are permitted provided that the following conditions 
>> >> >> are met:
>> >> >> + *
>> >> >> + * * Redistributions of source code must retain the above copyright 
>> >> >> notice, this
>> >> >> + *   list of conditions and the following disclaimer.
>> >> >> + * * Redistributions in binary form must reproduce the above 
>> >> >> copyright notice,
>> >> >> + *   this list of conditions and the following disclaimer in the 
>> >> >> documentation
>> >> >> + *   and/or other materials provided with the distribution.
>> >> >> + *
>> >> >> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
>> >> >> CONTRIBUTORS "AS IS"
>> >> >> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
>> >> >> TO, THE
>> >> >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
>> >> >> PURPOSE
>> >> >> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
>> >> >> CONTRIBUTORS BE
>> >> >> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
>> >> >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
>> >> >> OF
>> >> >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
>> >> >> BUSINESS
>> >> >> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
>> >> >> WHETHER IN
>> >> >> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
>> >> >> OTHERWISE)
>> >> >> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
>> >> >> ADVISED OF THE
>> >> >> + * POSSIBILITY OF SUCH DAMAGE.
>> >> >> + *
>> >> >> + * This file is part of FFmpeg.
>> >> >> + *
>> >> >> + * FFmpeg is free software; you can redistribute it and/or
>> >> >> + * modify it under the terms of the GNU Lesser General Public
>> >> >> + * License as published by the Free Software Foundation; either
>> >> >> + * version 2.1 of the License, or (at your option) any later version.
>> >> >> + *
>> >> >> + * FFmpeg is distributed in the hope that it will be useful,
>> >> >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> >> >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> >> >> + * Lesser General Public License for more details.
>> >> >> + *
>> >> >> + * You should have received a copy of the GNU Lesser General Public
>> >> >> + * License along with FFmpeg; if not, write to the Free Software
>> >> >> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
>> >> >> 02110-1301 USA
>> >> >> + */
>> >> >> +
>> >> >> +/**
>> >> >> + * Implements IMP CPL processing
>> >> >> + *
>> >> >> + * @author Pierre-Anthony Lemieux
>> >> >> + * @file
>> >> >> + * @ingroup lavu_imf
>> >> >> + */
>> >> >> +
>> >> >> +#include "imf.h"
>> >> >> +#include "imf_internal.h"
>> >> >> +#include "libavformat/mxf.h"
>> >> >> +#include "libavutil/bprint.h"
>> >> >> +#include "libavutil/error.h"
>> >> >> +#include 
>> >> >> +
>> >> >> +xmlNodePtr xml_get_child_element_by_name(xmlNodePtr parent, const 
>> >> >> char *name_utf8) {
>> >> >> +xmlNodePtr cur_element;
>> >> >> +
>> >> >> +cur_element = xmlFirstElementChild(parent);
>> >> >> +while (cur_element) {
>> >> >> +if (xmlStrcmp(cur_element->name, name_utf8) == 0)
>> >> >> +return cur_element;
>> >> >> +cur_element = xmlNextElementSibling(cur_element);
>> >> >> +}
>> >> >> +return NULL;
>> >> >> +}
>> >> >> +
>> >> >> +int xml_read_UUID(xmlNodePtr element, uint8_t uuid[16]) {
>> >> >> +xmlChar *element_text = NULL;
>> >> >> +int scanf_ret;
>> >> >> +int ret = 0;
>> >> >> +
>> >> >> +element_text = xmlNodeListGetString(element->doc, 
>> >> >> element->xmlChildrenNode, 1);
>> >> >> +scanf_ret = sscanf(element_text,
>> >> >> +UUID_FORMAT,
>> >> >> +&uuid[0],
>> >> >> +&u

Re: [FFmpeg-devel] [PATCH 2/5] avformat/imf: CPL processor

2021-10-31 Thread Paul B Mahol
On Sun, Oct 31, 2021 at 5:48 PM Pierre-Anthony Lemieux 
wrote:

> On Thu, Oct 28, 2021 at 12:56 AM Paul B Mahol  wrote:
> >
> >
> >
> > On Thu, Oct 28, 2021 at 6:34 AM Pierre-Anthony Lemieux 
> wrote:
> >>
> >> On Wed, Oct 27, 2021 at 12:57 AM Paul B Mahol  wrote:
> >> >
> >> >
> >> >
> >> > On Wed, Oct 20, 2021 at 4:55 PM  wrote:
> >> >>
> >> >> From: Pierre-Anthony Lemieux 
> >> >>
> >> >> Signed-off-by: Pierre-Anthony Lemieux 
> >> >> ---
> >> >>
> >> >> Notes:
> >> >> Implements IMF Composition Playlist (CPL) parsing.
> >> >>
> >> >>  libavformat/imf_cpl.c | 666
> ++
> >> >>  1 file changed, 666 insertions(+)
> >> >>  create mode 100644 libavformat/imf_cpl.c
> >> >>
> >> >> diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c
> >> >> new file mode 100644
> >> >> index 00..8ef574ad78
> >> >> --- /dev/null
> >> >> +++ b/libavformat/imf_cpl.c
> >> >> @@ -0,0 +1,666 @@
> >> >> +/*
> >> >> + * Copyright (c) Sandflow Consulting LLC
> >> >> + *
> >> >> + * Redistribution and use in source and binary forms, with or
> without
> >> >> + * modification, are permitted provided that the following
> conditions are met:
> >> >> + *
> >> >> + * * Redistributions of source code must retain the above copyright
> notice, this
> >> >> + *   list of conditions and the following disclaimer.
> >> >> + * * Redistributions in binary form must reproduce the above
> copyright notice,
> >> >> + *   this list of conditions and the following disclaimer in the
> documentation
> >> >> + *   and/or other materials provided with the distribution.
> >> >> + *
> >> >> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
> CONTRIBUTORS "AS IS"
> >> >> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> LIMITED TO, THE
> >> >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
> PARTICULAR PURPOSE
> >> >> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
> CONTRIBUTORS BE
> >> >> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
> OR
> >> >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
> PROCUREMENT OF
> >> >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
> BUSINESS
> >> >> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
> WHETHER IN
> >> >> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
> OTHERWISE)
> >> >> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
> ADVISED OF THE
> >> >> + * POSSIBILITY OF SUCH DAMAGE.
> >> >> + *
> >> >> + * This file is part of FFmpeg.
> >> >> + *
> >> >> + * FFmpeg is free software; you can redistribute it and/or
> >> >> + * modify it under the terms of the GNU Lesser General Public
> >> >> + * License as published by the Free Software Foundation; either
> >> >> + * version 2.1 of the License, or (at your option) any later
> version.
> >> >> + *
> >> >> + * FFmpeg is distributed in the hope that it will be useful,
> >> >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >> >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> >> >> + * Lesser General Public License for more details.
> >> >> + *
> >> >> + * You should have received a copy of the GNU Lesser General Public
> >> >> + * License along with FFmpeg; if not, write to the Free Software
> >> >> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> >> >> + */
> >> >> +
> >> >> +/**
> >> >> + * Implements IMP CPL processing
> >> >> + *
> >> >> + * @author Pierre-Anthony Lemieux
> >> >> + * @file
> >> >> + * @ingroup lavu_imf
> >> >> + */
> >> >> +
> >> >> +#include "imf.h"
> >> >> +#include "imf_internal.h"
> >> >> +#include "libavformat/mxf.h"
> >> >> +#include "libavutil/bprint.h"
> >> >> +#include "libavutil/error.h"
> >> >> +#include 
> >> >> +
> >> >> +xmlNodePtr xml_get_child_element_by_name(xmlNodePtr parent, const
> char *name_utf8) {
> >> >> +xmlNodePtr cur_element;
> >> >> +
> >> >> +cur_element = xmlFirstElementChild(parent);
> >> >> +while (cur_element) {
> >> >> +if (xmlStrcmp(cur_element->name, name_utf8) == 0)
> >> >> +return cur_element;
> >> >> +cur_element = xmlNextElementSibling(cur_element);
> >> >> +}
> >> >> +return NULL;
> >> >> +}
> >> >> +
> >> >> +int xml_read_UUID(xmlNodePtr element, uint8_t uuid[16]) {
> >> >> +xmlChar *element_text = NULL;
> >> >> +int scanf_ret;
> >> >> +int ret = 0;
> >> >> +
> >> >> +element_text = xmlNodeListGetString(element->doc,
> element->xmlChildrenNode, 1);
> >> >> +scanf_ret = sscanf(element_text,
> >> >> +UUID_FORMAT,
> >> >> +&uuid[0],
> >> >> +&uuid[1],
> >> >> +&uuid[2],
> >> >> +&uuid[3],
> >> >> +&uuid[4],
> >> >> +&uuid[5],
> >> >> +&uuid[6],
> >> >> +&uuid[7],
> >> >> +&uuid[8],
> >> >> +&uuid[9],
> >> >> +&uuid[10],
> >> >> +&uuid[11],
> >> >> +&u

Re: [FFmpeg-devel] [PATCH 3/5] avformat/imf: Demuxer implementation

2021-10-31 Thread Pierre-Anthony Lemieux
On Thu, Oct 28, 2021 at 12:58 AM Paul B Mahol  wrote:
>
>
>
> On Thu, Oct 28, 2021 at 6:32 AM Pierre-Anthony Lemieux  
> wrote:
>>
>> On Wed, Oct 27, 2021 at 12:54 AM Paul B Mahol  wrote:
>> >
>> >
>> >
>> > On Fri, Oct 8, 2021 at 1:42 AM  wrote:
>> >>
>> >> From: Pierre-Anthony Lemieux 
>> >>
>> >> Signed-off-by: Pierre-Anthony Lemieux 
>> >> ---
>> >>
>> >> Notes:
>> >> Implements the IMF demuxer.
>> >>
>> >>  libavformat/imfdec.c | 660 +++
>> >>  1 file changed, 660 insertions(+)
>> >>  create mode 100644 libavformat/imfdec.c
>> >>
>> >> diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
>> >> new file mode 100644
>> >> index 00..0c64fe0c03
>> >> --- /dev/null
>> >> +++ b/libavformat/imfdec.c
>> >> @@ -0,0 +1,660 @@
>> >> +/*
>> >> + * Copyright (c) Sandflow Consulting LLC
>> >> + *
>> >> + * Redistribution and use in source and binary forms, with or without
>> >> + * modification, are permitted provided that the following conditions 
>> >> are met:
>> >> + *
>> >> + * * Redistributions of source code must retain the above copyright 
>> >> notice, this
>> >> + *   list of conditions and the following disclaimer.
>> >> + * * Redistributions in binary form must reproduce the above copyright 
>> >> notice,
>> >> + *   this list of conditions and the following disclaimer in the 
>> >> documentation
>> >> + *   and/or other materials provided with the distribution.
>> >> + *
>> >> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
>> >> "AS IS"
>> >> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
>> >> THE
>> >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
>> >> PURPOSE
>> >> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
>> >> CONTRIBUTORS BE
>> >> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
>> >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
>> >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
>> >> BUSINESS
>> >> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
>> >> IN
>> >> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
>> >> OTHERWISE)
>> >> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
>> >> OF THE
>> >> + * POSSIBILITY OF SUCH DAMAGE.
>> >> + *
>> >> + * This file is part of FFmpeg.
>> >> + *
>> >> + * FFmpeg is free software; you can redistribute it and/or
>> >> + * modify it under the terms of the GNU Lesser General Public
>> >> + * License as published by the Free Software Foundation; either
>> >> + * version 2.1 of the License, or (at your option) any later version.
>> >> + *
>> >> + * FFmpeg is distributed in the hope that it will be useful,
>> >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> >> + * Lesser General Public License for more details.
>> >> + *
>> >> + * You should have received a copy of the GNU Lesser General Public
>> >> + * License along with FFmpeg; if not, write to the Free Software
>> >> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
>> >> 02110-1301 USA
>> >> + */
>> >> +
>> >> +/**
>> >> + * Demuxes an IMF Composition
>> >> + *
>> >> + * References
>> >> + * OV 2067-0:2018 - SMPTE Overview Document - Interoperable Master Format
>> >> + * ST 2067-2:2020 - SMPTE Standard - Interoperable Master Format — Core 
>> >> Constraints
>> >> + * ST 2067-3:2020 - SMPTE Standard - Interoperable Master Format — 
>> >> Composition Playlist
>> >> + * ST 2067-5:2020 - SMPTE Standard - Interoperable Master Format — 
>> >> Essence Component
>> >> + * ST 2067-20:2016 - SMPTE Standard - Interoperable Master Format — 
>> >> Application #2
>> >> + * ST 2067-21:2020 - SMPTE Standard - Interoperable Master Format — 
>> >> Application #2 Extended
>> >> + * ST 2067-102:2017 - SMPTE Standard - Interoperable Master Format — 
>> >> Common Image Pixel Color Schemes
>> >> + * ST 429-9:2007 - SMPTE Standard - D-Cinema Packaging — Asset Mapping 
>> >> and File Segmentation
>> >> + *
>> >> + * @author Marc-Antoine Arnaud
>> >> + * @author Valentin Noel
>> >> + * @file
>> >> + * @ingroup lavu_imf
>> >> + */
>> >> +
>> >> +#include "imf.h"
>> >> +#include "imf_internal.h"
>> >> +#include "internal.h"
>> >> +#include "libavutil/opt.h"
>> >> +#include "libavutil/bprint.h"
>> >> +#include "libavutil/avstring.h"
>> >> +#include "mxf.h"
>> >> +#include "url.h"
>> >> +#include 
>> >> +#include 
>> >> +
>> >> +#define MAX_BPRINT_READ_SIZE (UINT_MAX - 1)
>> >> +#define DEFAULT_ASSETMAP_SIZE 8 * 1024
>> >> +
>> >> +typedef struct IMFVirtualTrackResourcePlaybackCtx {
>> >> +IMFAssetLocator *locator;
>> >> +IMFTrackFileResource *resource;
>> >> +AVFormatContext *ctx;
>> >> +} IMFVirtualTrackResourcePlaybackCtx;
>> >> +
>> >> +typedef struct IMFVirtualTrackPlaybackCtx {
>> >> +// Track index in pl

Re: [FFmpeg-devel] [PATCH 2/5] avformat/imf: CPL processor

2021-10-31 Thread Pierre-Anthony Lemieux
On Thu, Oct 28, 2021 at 12:56 AM Paul B Mahol  wrote:
>
>
>
> On Thu, Oct 28, 2021 at 6:34 AM Pierre-Anthony Lemieux  
> wrote:
>>
>> On Wed, Oct 27, 2021 at 12:57 AM Paul B Mahol  wrote:
>> >
>> >
>> >
>> > On Wed, Oct 20, 2021 at 4:55 PM  wrote:
>> >>
>> >> From: Pierre-Anthony Lemieux 
>> >>
>> >> Signed-off-by: Pierre-Anthony Lemieux 
>> >> ---
>> >>
>> >> Notes:
>> >> Implements IMF Composition Playlist (CPL) parsing.
>> >>
>> >>  libavformat/imf_cpl.c | 666 ++
>> >>  1 file changed, 666 insertions(+)
>> >>  create mode 100644 libavformat/imf_cpl.c
>> >>
>> >> diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c
>> >> new file mode 100644
>> >> index 00..8ef574ad78
>> >> --- /dev/null
>> >> +++ b/libavformat/imf_cpl.c
>> >> @@ -0,0 +1,666 @@
>> >> +/*
>> >> + * Copyright (c) Sandflow Consulting LLC
>> >> + *
>> >> + * Redistribution and use in source and binary forms, with or without
>> >> + * modification, are permitted provided that the following conditions 
>> >> are met:
>> >> + *
>> >> + * * Redistributions of source code must retain the above copyright 
>> >> notice, this
>> >> + *   list of conditions and the following disclaimer.
>> >> + * * Redistributions in binary form must reproduce the above copyright 
>> >> notice,
>> >> + *   this list of conditions and the following disclaimer in the 
>> >> documentation
>> >> + *   and/or other materials provided with the distribution.
>> >> + *
>> >> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
>> >> "AS IS"
>> >> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
>> >> THE
>> >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
>> >> PURPOSE
>> >> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
>> >> CONTRIBUTORS BE
>> >> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
>> >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
>> >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
>> >> BUSINESS
>> >> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
>> >> IN
>> >> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
>> >> OTHERWISE)
>> >> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
>> >> OF THE
>> >> + * POSSIBILITY OF SUCH DAMAGE.
>> >> + *
>> >> + * This file is part of FFmpeg.
>> >> + *
>> >> + * FFmpeg is free software; you can redistribute it and/or
>> >> + * modify it under the terms of the GNU Lesser General Public
>> >> + * License as published by the Free Software Foundation; either
>> >> + * version 2.1 of the License, or (at your option) any later version.
>> >> + *
>> >> + * FFmpeg is distributed in the hope that it will be useful,
>> >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> >> + * Lesser General Public License for more details.
>> >> + *
>> >> + * You should have received a copy of the GNU Lesser General Public
>> >> + * License along with FFmpeg; if not, write to the Free Software
>> >> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
>> >> 02110-1301 USA
>> >> + */
>> >> +
>> >> +/**
>> >> + * Implements IMP CPL processing
>> >> + *
>> >> + * @author Pierre-Anthony Lemieux
>> >> + * @file
>> >> + * @ingroup lavu_imf
>> >> + */
>> >> +
>> >> +#include "imf.h"
>> >> +#include "imf_internal.h"
>> >> +#include "libavformat/mxf.h"
>> >> +#include "libavutil/bprint.h"
>> >> +#include "libavutil/error.h"
>> >> +#include 
>> >> +
>> >> +xmlNodePtr xml_get_child_element_by_name(xmlNodePtr parent, const char 
>> >> *name_utf8) {
>> >> +xmlNodePtr cur_element;
>> >> +
>> >> +cur_element = xmlFirstElementChild(parent);
>> >> +while (cur_element) {
>> >> +if (xmlStrcmp(cur_element->name, name_utf8) == 0)
>> >> +return cur_element;
>> >> +cur_element = xmlNextElementSibling(cur_element);
>> >> +}
>> >> +return NULL;
>> >> +}
>> >> +
>> >> +int xml_read_UUID(xmlNodePtr element, uint8_t uuid[16]) {
>> >> +xmlChar *element_text = NULL;
>> >> +int scanf_ret;
>> >> +int ret = 0;
>> >> +
>> >> +element_text = xmlNodeListGetString(element->doc, 
>> >> element->xmlChildrenNode, 1);
>> >> +scanf_ret = sscanf(element_text,
>> >> +UUID_FORMAT,
>> >> +&uuid[0],
>> >> +&uuid[1],
>> >> +&uuid[2],
>> >> +&uuid[3],
>> >> +&uuid[4],
>> >> +&uuid[5],
>> >> +&uuid[6],
>> >> +&uuid[7],
>> >> +&uuid[8],
>> >> +&uuid[9],
>> >> +&uuid[10],
>> >> +&uuid[11],
>> >> +&uuid[12],
>> >> +&uuid[13],
>> >> +&uuid[14],
>> >> +&uuid[15]);
>> >> +if (scanf_ret != 16) {
>> >> +av_log(NULL, AV_LOG_ERROR, "Invalid UUID\n");
>> >> +ret = AVERROR_INVALIDDATA;
>> >> +

Re: [FFmpeg-devel] [PATCH] avfilter/scale_npp: add scale2ref_npp filter

2021-10-31 Thread Timo Rothenpieler

On 31.10.2021 14:35, Timo Rothenpieler wrote:

From: Roman Arzumanyan 

Signed-off-by: Timo Rothenpieler 
---
Here's my revised version of the patch.
It brings its order of operation much more in line with normal scale/scale2ref.
Also gets rid of differences in option parsing between the 2ref and non-2ref 
version of the filters.
I also added some more options, like the eval option or size, size it was used 
anyway, just not exposed.

If no further issues or comments arise, I will apply this patch in a few days.
I also plan to come up with a similar patch for scale_cuda.


  doc/filters.texi   | 111 
  libavfilter/allfilters.c   |   1 +
  libavfilter/version.h  |   2 +-
  libavfilter/vf_scale_npp.c | 544 ++---
  4 files changed, 618 insertions(+), 40 deletions(-)


The configure/Makefile line for this got somehow lost in rebase.
Added locally.


smime.p7s
Description: S/MIME Cryptographic 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] avfilter/scale_npp: add scale2ref_npp filter

2021-10-31 Thread Timo Rothenpieler
From: Roman Arzumanyan 

Signed-off-by: Timo Rothenpieler 
---
Here's my revised version of the patch.
It brings its order of operation much more in line with normal scale/scale2ref.
Also gets rid of differences in option parsing between the 2ref and non-2ref 
version of the filters.
I also added some more options, like the eval option or size, size it was used 
anyway, just not exposed.

If no further issues or comments arise, I will apply this patch in a few days.
I also plan to come up with a similar patch for scale_cuda.


 doc/filters.texi   | 111 
 libavfilter/allfilters.c   |   1 +
 libavfilter/version.h  |   2 +-
 libavfilter/vf_scale_npp.c | 544 ++---
 4 files changed, 618 insertions(+), 40 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 177f0774fc..8eae567f01 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -18494,6 +18494,7 @@ scale_cuda=passthrough=0
 @end example
 @end itemize
 
+@anchor{scale_npp}
 @section scale_npp
 
 Use the NVIDIA Performance Primitives (libnpp) to perform scaling and/or pixel
@@ -18570,6 +18571,61 @@ This option can be handy if you need to have a video 
fit within or exceed
 a defined resolution using @option{force_original_aspect_ratio} but also have
 encoder restrictions on width or height divisibility.
 
+@item eval
+Specify when to evaluate @var{width} and @var{height} expression. It accepts 
the following values:
+
+@table @samp
+@item init
+Only evaluate expressions once during the filter initialization or when a 
command is processed.
+
+@item frame
+Evaluate expressions for each incoming frame.
+
+@end table
+
+@end table
+
+The values of the @option{w} and @option{h} options are expressions
+containing the following constants:
+
+@table @var
+@item in_w
+@item in_h
+The input width and height
+
+@item iw
+@item ih
+These are the same as @var{in_w} and @var{in_h}.
+
+@item out_w
+@item out_h
+The output (scaled) width and height
+
+@item ow
+@item oh
+These are the same as @var{out_w} and @var{out_h}
+
+@item a
+The same as @var{iw} / @var{ih}
+
+@item sar
+input sample aspect ratio
+
+@item dar
+The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
+
+@item n
+The (sequential) number of the input frame, starting from 0.
+Only available with @code{eval=frame}.
+
+@item t
+The presentation timestamp of the input frame, expressed as a number of
+seconds. Only available with @code{eval=frame}.
+
+@item pos
+The position (byte offset) of the frame in the input stream, or NaN if
+this information is unavailable and/or meaningless (for example in case of 
synthetic video).
+Only available with @code{eval=frame}.
 @end table
 
 @section scale2ref
@@ -18645,6 +18701,61 @@ If the specified expression is not valid, it is kept 
at its current
 value.
 @end table
 
+@section scale2ref_npp
+
+Use the NVIDIA Performance Primitives (libnpp) to scale (resize) the input
+video, based on a reference video.
+
+See the @ref{scale_npp} filter for available options, scale2ref_npp supports 
the same
+but uses the reference video instead of the main input as basis. scale2ref_npp
+also supports the following additional constants for the @option{w} and
+@option{h} options:
+
+@table @var
+@item main_w
+@item main_h
+The main input video's width and height
+
+@item main_a
+The same as @var{main_w} / @var{main_h}
+
+@item main_sar
+The main input video's sample aspect ratio
+
+@item main_dar, mdar
+The main input video's display aspect ratio. Calculated from
+@code{(main_w / main_h) * main_sar}.
+
+@item main_n
+The (sequential) number of the main input frame, starting from 0.
+Only available with @code{eval=frame}.
+
+@item main_t
+The presentation timestamp of the main input frame, expressed as a number of
+seconds. Only available with @code{eval=frame}.
+
+@item main_pos
+The position (byte offset) of the frame in the main input stream, or NaN if
+this information is unavailable and/or meaningless (for example in case of 
synthetic video).
+Only available with @code{eval=frame}.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Scale a subtitle stream (b) to match the main video (a) in size before 
overlaying
+@example
+'scale2ref_npp[b][a];[a][b]overlay_cuda'
+@end example
+
+@item
+Scale a logo to 1/10th the height of a video, while preserving its display 
aspect ratio.
+@example
+[logo-in][video-in]scale2ref_npp=w=oh*mdar:h=ih/10[logo-out][video-out]
+@end example
+@end itemize
+
 @section scharr
 Apply scharr operator to input video stream.
 
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 409ab5d3c4..667b6fc246 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -396,6 +396,7 @@ extern const AVFilter ff_vf_scale_qsv;
 extern const AVFilter ff_vf_scale_vaapi;
 extern const AVFilter ff_vf_scale_vulkan;
 extern const AVFilter ff_vf_scale2ref;
+extern const AVFilter ff_vf_scale2ref_npp;
 extern const AVFilter ff_vf_scdet;
 extern const AVFilt

Re: [FFmpeg-devel] [PATCH 2/2] avutil/hwcontext_videotoolbox: fix use of unknown builtin '__builtin_available'

2021-10-31 Thread James Almer

On 10/31/2021 10:32 AM, James Almer wrote:

On 10/19/2021 11:52 AM, lance.lmw...@gmail.com wrote:

From: Limin Wang 

OSX version: 10.11.6
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0

Signed-off-by: Limin Wang 
---
  libavutil/hwcontext_videotoolbox.c | 12 
  1 file changed, 12 insertions(+)

diff --git a/libavutil/hwcontext_videotoolbox.c 
b/libavutil/hwcontext_videotoolbox.c

index 58095a1..5794cab 100644
--- a/libavutil/hwcontext_videotoolbox.c
+++ b/libavutil/hwcontext_videotoolbox.c
@@ -375,9 +375,11 @@ static int 
vt_pixbuf_set_colorspace(AVHWFramesContext *hwfc,

  switch (src->colorspace) {
  case AVCOL_SPC_BT2020_CL:
  case AVCOL_SPC_BT2020_NCL:
+#if __has_builtin(__builtin_available)


AV_HAS_BUILTIN(__builtin_available)

I know it's not necessary per se since this is an OSX only file, but it 
will help grepping in the future if there needs to be a change to the 
macro.


Oh, nevermind, i missed the v2.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/2] avutil/hwcontext_videotoolbox: fix use of unknown builtin '__builtin_available'

2021-10-31 Thread James Almer

On 10/19/2021 11:52 AM, lance.lmw...@gmail.com wrote:

From: Limin Wang 

OSX version: 10.11.6
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0

Signed-off-by: Limin Wang 
---
  libavutil/hwcontext_videotoolbox.c | 12 
  1 file changed, 12 insertions(+)

diff --git a/libavutil/hwcontext_videotoolbox.c 
b/libavutil/hwcontext_videotoolbox.c
index 58095a1..5794cab 100644
--- a/libavutil/hwcontext_videotoolbox.c
+++ b/libavutil/hwcontext_videotoolbox.c
@@ -375,9 +375,11 @@ static int vt_pixbuf_set_colorspace(AVHWFramesContext 
*hwfc,
  switch (src->colorspace) {
  case AVCOL_SPC_BT2020_CL:
  case AVCOL_SPC_BT2020_NCL:
+#if __has_builtin(__builtin_available)


AV_HAS_BUILTIN(__builtin_available)

I know it's not necessary per se since this is an OSX only file, but it 
will help grepping in the future if there needs to be a change to the macro.



  if (__builtin_available(macOS 10.11, *))
  colormatrix = kCVImageBufferYCbCrMatrix_ITU_R_2020;
  else
+#endif
  colormatrix = CFSTR("ITU_R_2020");
  break;
  case AVCOL_SPC_BT470BG:
@@ -398,9 +400,11 @@ static int vt_pixbuf_set_colorspace(AVHWFramesContext 
*hwfc,
  
  switch (src->color_primaries) {

  case AVCOL_PRI_BT2020:
+#if __has_builtin(__builtin_available)
  if (__builtin_available(macOS 10.11, *))
  colorpri = kCVImageBufferColorPrimaries_ITU_R_2020;
  else
+#endif
  colorpri = CFSTR("ITU_R_2020");
  break;
  case AVCOL_PRI_BT709:
@@ -420,16 +424,20 @@ static int vt_pixbuf_set_colorspace(AVHWFramesContext 
*hwfc,
  
  switch (src->color_trc) {

  case AVCOL_TRC_SMPTE2084:
+#if __has_builtin(__builtin_available)
  if (__builtin_available(macOS 10.13, *))
  colortrc = kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
  else
+#endif
  colortrc = CFSTR("SMPTE_ST_2084_PQ");
  break;
  case AVCOL_TRC_BT2020_10:
  case AVCOL_TRC_BT2020_12:
+#if __has_builtin(__builtin_available)
  if (__builtin_available(macOS 10.11, *))
  colortrc = kCVImageBufferTransferFunction_ITU_R_2020;
  else
+#endif
  colortrc = CFSTR("ITU_R_2020");
  break;
  case AVCOL_TRC_BT709:
@@ -439,15 +447,19 @@ static int vt_pixbuf_set_colorspace(AVHWFramesContext 
*hwfc,
  colortrc = kCVImageBufferTransferFunction_SMPTE_240M_1995;
  break;
  case AVCOL_TRC_SMPTE428:
+#if __has_builtin(__builtin_available)
  if (__builtin_available(macOS 10.12, *))
  colortrc = kCVImageBufferTransferFunction_SMPTE_ST_428_1;
  else
+#endif
  colortrc = CFSTR("SMPTE_ST_428_1");
  break;
  case AVCOL_TRC_ARIB_STD_B67:
+#if __has_builtin(__builtin_available)
  if (__builtin_available(macOS 10.13, *))
  colortrc = kCVImageBufferTransferFunction_ITU_R_2100_HLG;
  else
+#endif
  colortrc = CFSTR("ITU_R_2100_HLG");
  break;
  case AVCOL_TRC_GAMMA22:



___
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] avutil/hwcontext_videotoolbox: fix use of unknown builtin '__builtin_available'

2021-10-31 Thread lance . lmwang
From: Limin Wang 

OSX version: 10.11.6
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0

Signed-off-by: Limin Wang 
---
 configure  |  8 ++
 libavutil/hwcontext_videotoolbox.c | 54 +-
 2 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/configure b/configure
index ede8f97..c4fb1b7 100755
--- a/configure
+++ b/configure
@@ -2329,6 +2329,10 @@ TYPES_LIST="
 kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
 kCVImageBufferTransferFunction_ITU_R_2100_HLG
 kCVImageBufferTransferFunction_Linear
+kCVImageBufferYCbCrMatrix_ITU_R_2020
+kCVImageBufferColorPrimaries_ITU_R_2020
+kCVImageBufferTransferFunction_ITU_R_2020
+kCVImageBufferTransferFunction_SMPTE_ST_428_1
 socklen_t
 struct_addrinfo
 struct_group_source_req
@@ -6273,6 +6277,10 @@ enabled videotoolbox && {
 check_func_headers CoreVideo/CVImageBuffer.h 
kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ "-framework CoreVideo"
 check_func_headers CoreVideo/CVImageBuffer.h 
kCVImageBufferTransferFunction_ITU_R_2100_HLG "-framework CoreVideo"
 check_func_headers CoreVideo/CVImageBuffer.h 
kCVImageBufferTransferFunction_Linear "-framework CoreVideo"
+check_func_headers CoreVideo/CVImageBuffer.h 
kCVImageBufferYCbCrMatrix_ITU_R_2020 "-framework CoreVideo"
+check_func_headers CoreVideo/CVImageBuffer.h 
kCVImageBufferColorPrimaries_ITU_R_2020 "-framework CoreVideo"
+check_func_headers CoreVideo/CVImageBuffer.h 
kCVImageBufferTransferFunction_ITU_R_2020 "-framework CoreVideo"
+check_func_headers CoreVideo/CVImageBuffer.h 
kCVImageBufferTransferFunction_SMPTE_ST_428_1 "-framework CoreVideo"
 }
 
 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
diff --git a/libavutil/hwcontext_videotoolbox.c 
b/libavutil/hwcontext_videotoolbox.c
index 58095a1..25f4e17 100644
--- a/libavutil/hwcontext_videotoolbox.c
+++ b/libavutil/hwcontext_videotoolbox.c
@@ -375,10 +375,11 @@ static int vt_pixbuf_set_colorspace(AVHWFramesContext 
*hwfc,
 switch (src->colorspace) {
 case AVCOL_SPC_BT2020_CL:
 case AVCOL_SPC_BT2020_NCL:
-if (__builtin_available(macOS 10.11, *))
-colormatrix = kCVImageBufferYCbCrMatrix_ITU_R_2020;
-else
-colormatrix = CFSTR("ITU_R_2020");
+#if HAVE_KCVIMAGEBUFFERYCBCRMATRIX_ITU_R_2020
+colormatrix = kCVImageBufferYCbCrMatrix_ITU_R_2020;
+#else
+colormatrix = CFSTR("ITU_R_2020");
+#endif
 break;
 case AVCOL_SPC_BT470BG:
 case AVCOL_SPC_SMPTE170M:
@@ -398,10 +399,11 @@ static int vt_pixbuf_set_colorspace(AVHWFramesContext 
*hwfc,
 
 switch (src->color_primaries) {
 case AVCOL_PRI_BT2020:
-if (__builtin_available(macOS 10.11, *))
-colorpri = kCVImageBufferColorPrimaries_ITU_R_2020;
-else
-colorpri = CFSTR("ITU_R_2020");
+#if HAVE_KCVIMAGEBUFFERCOLORPRIMARIES_ITU_R_2020
+colorpri = kCVImageBufferColorPrimaries_ITU_R_2020;
+#else
+colorpri = CFSTR("ITU_R_2020");
+#endif
 break;
 case AVCOL_PRI_BT709:
 colorpri = kCVImageBufferColorPrimaries_ITU_R_709_2;
@@ -420,17 +422,19 @@ static int vt_pixbuf_set_colorspace(AVHWFramesContext 
*hwfc,
 
 switch (src->color_trc) {
 case AVCOL_TRC_SMPTE2084:
-if (__builtin_available(macOS 10.13, *))
-colortrc = kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
-else
-colortrc = CFSTR("SMPTE_ST_2084_PQ");
+#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ
+colortrc = kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
+#else
+colortrc = CFSTR("SMPTE_ST_2084_PQ");
+#endif
 break;
 case AVCOL_TRC_BT2020_10:
 case AVCOL_TRC_BT2020_12:
-if (__builtin_available(macOS 10.11, *))
-colortrc = kCVImageBufferTransferFunction_ITU_R_2020;
-else
-colortrc = CFSTR("ITU_R_2020");
+#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2020
+colortrc = kCVImageBufferTransferFunction_ITU_R_2020;
+#else
+colortrc = CFSTR("ITU_R_2020");
+#endif
 break;
 case AVCOL_TRC_BT709:
 colortrc = kCVImageBufferTransferFunction_ITU_R_709_2;
@@ -439,16 +443,18 @@ static int vt_pixbuf_set_colorspace(AVHWFramesContext 
*hwfc,
 colortrc = kCVImageBufferTransferFunction_SMPTE_240M_1995;
 break;
 case AVCOL_TRC_SMPTE428:
-if (__builtin_available(macOS 10.12, *))
-colortrc = kCVImageBufferTransferFunction_SMPTE_ST_428_1;
-else
-colortrc = CFSTR("SMPTE_ST_428_1");
+#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_428_1
+colortrc = kCVImageBufferTransferFunction_SMPTE_ST_428_1;
+#else
+colortrc = CFSTR("SMPTE_ST_428_1");
+#endif
 break;
 case AVCOL_TRC_ARIB_STD_B67:
-if (__builtin_available(macOS 10.13, *))
-colortrc = kCVImageBufferTransferFunction_ITU_R_2100_HLG;
-else

[FFmpeg-devel] [PATCH] avfilter: add option to end filtering on first EOF in filter sink

2021-10-31 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 fftools/ffmpeg.h| 1 +
 fftools/ffmpeg_filter.c | 1 +
 fftools/ffmpeg_opt.c| 3 +++
 libavfilter/avfilter.h  | 1 +
 libavfilter/avfiltergraph.c | 7 +--
 5 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 545ff1c8e7..f3b003cd6a 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -633,6 +633,7 @@ extern char *videotoolbox_pixfmt;
 
 extern char *filter_nbthreads;
 extern int filter_complex_nbthreads;
+extern int filter_shortest;
 extern int vstats_version;
 extern int auto_conversion_filters;
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index b798459946..d67f4d5528 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1028,6 +1028,7 @@ int configure_filtergraph(FilterGraph *fg)
 av_opt_set(fg->graph, "aresample_swr_opts", args, 0);
 } else {
 fg->graph->nb_threads = filter_complex_nbthreads;
+fg->graph->shortest = filter_shortest;
 }
 
 if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, 
&outputs)) < 0)
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 601db2b827..1bc2df37d4 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -171,6 +171,7 @@ int frame_bits_per_raw_sample = 0;
 float max_error_rate  = 2.0/3;
 char *filter_nbthreads;
 int filter_complex_nbthreads = 0;
+int filter_shortest = 0;
 int vstats_version = 2;
 int auto_conversion_filters = 1;
 int64_t stats_period = 50;
@@ -3638,6 +3639,8 @@ const OptionDef options[] = {
 "create a complex filtergraph", "graph_description" },
 { "filter_complex_threads", HAS_ARG | OPT_INT,   { 
&filter_complex_nbthreads },
 "number of threads for -filter_complex" },
+{ "filter_shortest", OPT_BOOL | OPT_INT, { 
&filter_shortest },
+"ends filtering on shortest sink" },
 { "lavfi",  HAS_ARG | OPT_EXPERT,{ 
.func_arg = opt_filter_complex },
 "create a complex filtergraph", "graph_description" },
 { "filter_complex_script", HAS_ARG | OPT_EXPERT, { 
.func_arg = opt_filter_complex_script },
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index f7208754a7..c00e70774e 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -909,6 +909,7 @@ typedef struct AVFilterGraph {
 int sink_links_count;
 
 unsigned disable_auto_convert;
+int shortest;
 } AVFilterGraph;
 
 /**
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index b8b432e98b..3c87d42e49 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -57,6 +57,8 @@ static const AVOption filtergraph_options[] = {
 AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, F|V },
 {"aresample_swr_opts"   , "default aresample filter options", 
OFFSET(aresample_swr_opts),
 AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, F|A },
+{"shortest", "ends filtering with shortest sink", 
OFFSET(shortest)  ,
+AV_OPT_TYPE_BOOL,   {.i64 = 0}, 0, 1, F|V|A },
 { NULL },
 };
 
@@ -77,6 +79,7 @@ int ff_graph_thread_init(AVFilterGraph *graph)
 {
 graph->thread_type = 0;
 graph->nb_threads  = 1;
+graph->shortest= 0;
 return 0;
 }
 #endif
@@ -1298,7 +1301,7 @@ int avfilter_graph_request_oldest(AVFilterGraph *graph)
 } else {
 r = ff_request_frame(oldest);
 }
-if (r != AVERROR_EOF)
+if (r != AVERROR_EOF || graph->shortest)
 break;
 av_log(oldest->dst, AV_LOG_DEBUG, "EOF on sink link %s:%s.\n",
oldest->dst->name,
@@ -1309,7 +1312,7 @@ int avfilter_graph_request_oldest(AVFilterGraph *graph)
  oldest->age_index);
 oldest->age_index = -1;
 }
-if (!graph->sink_links_count)
+if (!graph->sink_links_count || (r == AVERROR_EOF && graph->shortest))
 return AVERROR_EOF;
 av_assert1(!oldest->dst->filter->activate);
 av_assert1(oldest->age_index >= 0);
-- 
2.33.0

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

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


[FFmpeg-devel] [PATCH] avfilter: add positive video filter

2021-10-31 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/vf_positive.c | 337 ++
 3 files changed, 339 insertions(+)
 create mode 100644 libavfilter/vf_positive.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 6ac6e3b764..54fbce7909 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -380,6 +380,7 @@ OBJS-$(CONFIG_PHASE_FILTER)  += vf_phase.o
 OBJS-$(CONFIG_PHOTOSENSITIVITY_FILTER)   += vf_photosensitivity.o
 OBJS-$(CONFIG_PIXDESCTEST_FILTER)+= vf_pixdesctest.o
 OBJS-$(CONFIG_PIXSCOPE_FILTER)   += vf_datascope.o
+OBJS-$(CONFIG_POSITIVE_FILTER)   += vf_positive.o
 OBJS-$(CONFIG_PP_FILTER) += vf_pp.o qp_table.o
 OBJS-$(CONFIG_PP7_FILTER)+= vf_pp7.o qp_table.o
 OBJS-$(CONFIG_PREMULTIPLY_FILTER)+= vf_premultiply.o framesync.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index f5c539199c..c415005ab8 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -364,6 +364,7 @@ extern const AVFilter ff_vf_phase;
 extern const AVFilter ff_vf_photosensitivity;
 extern const AVFilter ff_vf_pixdesctest;
 extern const AVFilter ff_vf_pixscope;
+extern const AVFilter ff_vf_positive;
 extern const AVFilter ff_vf_pp;
 extern const AVFilter ff_vf_pp7;
 extern const AVFilter ff_vf_premultiply;
diff --git a/libavfilter/vf_positive.c b/libavfilter/vf_positive.c
new file mode 100644
index 00..4557aae349
--- /dev/null
+++ b/libavfilter/vf_positive.c
@@ -0,0 +1,337 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+
+#include "libavutil/attributes.h"
+#include "libavutil/common.h"
+#include "libavutil/ffmath.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "avfilter.h"
+#include "drawutils.h"
+#include "formats.h"
+#include "internal.h"
+#include "video.h"
+
+#define AA_DMIN (1 << 0)
+#define AA_DMAX (1 << 1)
+#define AA_OFFSET   (1 << 2)
+#define AA_EXPOSURE (1 << 3)
+#define AA_BLACK(1 << 4)
+#define AA_WBH  (1 << 5)
+#define AA_WBL  (1 << 6)
+
+typedef struct ThreadData {
+AVFrame *in;
+AVFrame *out;
+} ThreadData;
+
+typedef struct PositiveContext {
+const AVClass *class;
+
+float sampler[4];
+float picker_avg[3];
+float picker_min[3];
+float picker_max[3];
+int   autoadjust;
+
+float dmin[3];
+float dmax;
+float owbh[3];
+float owbl[3];
+float ooffset;
+float oblack;
+float wbh[3];
+float offset[3];
+float black;
+float gamma;
+float softclip;
+float exposure;
+
+int max;
+int nb_planes;
+} PositiveContext;
+
+#define OFFSET(x) offsetof(PositiveContext, x)
+#define VF 
AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+
+static const AVOption positive_options[] = {
+{ "dminr","set the red component of film color substrate",
OFFSET(dmin[2]),   AV_OPT_TYPE_FLOAT, {.dbl=1.13},  0, 1.5, VF },
+{ "dming","set the green component of film color substrate",  
OFFSET(dmin[0]),   AV_OPT_TYPE_FLOAT, {.dbl=0.49},  0, 1.5, VF },
+{ "dminb","set the blue component of film color substrate",   
OFFSET(dmin[1]),   AV_OPT_TYPE_FLOAT, {.dbl=0.27},  0, 1.5, VF },
+{ "wbhr", "set the red component highlights offset for whites",   
OFFSET(owbh[2]),   AV_OPT_TYPE_FLOAT, {.dbl=1.00},.25, 2.0, VF },
+{ "wbhg", "set the green component highlights offset for whites", 
OFFSET(owbh[0]),   AV_OPT_TYPE_FLOAT, {.dbl=1.00},.25, 2.0, VF },
+{ "wbhb", "set the blue component higlights offset for whites",   
OFFSET(owbh[1]),   AV_OPT_TYPE_FLOAT, {.dbl=1.00},.25, 2.0, VF },
+{ "wblr", "set the red component shadows offset for blacks",  
OFFSET(owbl[2]),   AV_OPT_TYPE_FLOAT, {.dbl=1.00},.25, 2.0, VF },
+{ "wblg", "set the green component shadows offset for blacks",
OFFSET(owbl[0]),   AV_OPT_TYPE_FLOAT, {.dbl=1.00},.25, 2.0, VF },
+{ "wblb", "set the blue component shadows offset for blacks", 
OFFSET(owbl[1]),   AV_OPT_TYPE_FLOAT, {.dbl=1.00},.25, 2.0, VF },
+{ "dmax", "

Re: [FFmpeg-devel] [PATCH 1/3] avformat/aiffdec: Check sample_rate

2021-10-31 Thread Paul B Mahol
lgtm
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 3/3] avformat/aiffdec: Use av_rescale() for bitrate

2021-10-31 Thread Paul B Mahol
lgtm
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/3] avformat/aiffdec: sanity check block_align

2021-10-31 Thread Paul B Mahol
lgtm, could also change return values  in next commits.
___
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".