Re: [FFmpeg-devel] [PATCH v3 0/8] HEVC native support for Screen content coding

2021-01-15 Thread Linjie Fu
On Mon, Dec 7, 2020 at 8:56 PM Linjie Fu  wrote:
>
> Add parsing support and reference management for HEVC SCC, as part of
> the fully decoding support for hardware(vaapi).
>
> v3:
>  - addressed the hang issue in multi-threads
>  - prompted more logs to prompt scc is not fully supported
>  - PPS overread is kind of weird, would reply separately in previous
>mail threads.
>
> Previous comments:
> https://www.mail-archive.com/ffmpeg-devel@ffmpeg.org/msg110151.html
>
> Linjie Fu (8):
>   lavc/avcodec: Add FF_PROFILE_HEVC_SCC for screen content coding
>   lavc/hevc_ps: Add sps parse support for HEVC SCC extension syntax
>   lavc/hevc_ps: Add pps parse support for HEVC SCC extension
>   lavc/hevc_ps: Add slice parse support for HEVC SCC extension
>   lavc/hevcdec: Fix the parsing for use_integer_mv_flag
>   lavc/hevcdec: Set max_num_merge_cand to uint8_t
>   lavc/hevc: Update reference list for SCC
>   lavc/hevcdec: Prompt detailed logs for invalid PPS id
>
>  libavcodec/avcodec.h |   1 +
>  libavcodec/hevc.h|   3 +
>  libavcodec/hevc_parser.c |   2 +-
>  libavcodec/hevc_ps.c | 116 +--
>  libavcodec/hevc_ps.h |  32 +++
>  libavcodec/hevc_refs.c   |  27 -
>  libavcodec/hevcdec.c |  22 +++-
>  libavcodec/hevcdec.h |   7 ++-
>  libavcodec/profiles.c|   1 +
>  9 files changed, 201 insertions(+), 10 deletions(-)
>
> --
Ping for the patch set [1], thx.

[1] https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=2878

- linjie
___
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 6/6] avcodec/qsvdec: refact, remove duplicate code for plugin loading

2021-01-15 Thread Linjie Fu
Guangxin:

On Tue, Jan 5, 2021 at 10:44 AM Xu Guangxin  wrote:
>
> ---
>  libavcodec/qsvdec.c | 29 +++--
>  1 file changed, 11 insertions(+), 18 deletions(-)
>
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index 3ca16dafae..d10f90a0db 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -682,21 +682,12 @@ static av_cold int qsv_decode_init(AVCodecContext 
> *avctx)
>  {
>  QSVDecContext *s = avctx->priv_data;
>  int ret;
> +const char *uid = NULL;
>
>  if (avctx->codec_id == AV_CODEC_ID_VP8) {
> -static const char *uid_vp8dec_hw = 
> "f622394d8d87452f878c51f2fc9b4131";
> -
> -av_freep(&s->qsv.load_plugins);
> -s->qsv.load_plugins = av_strdup(uid_vp8dec_hw);
> -if (!s->qsv.load_plugins)
> -return AVERROR(ENOMEM);
> +uid = "f622394d8d87452f878c51f2fc9b4131";
>  } else if (avctx->codec_id == AV_CODEC_ID_VP9) {
> -static const char *uid_vp9dec_hw = 
> "a922394d8d87452f878c51f2fc9b4131";
> -
> -av_freep(&s->qsv.load_plugins);
> -s->qsv.load_plugins = av_strdup(uid_vp9dec_hw);
> -if (!s->qsv.load_plugins)
> -return AVERROR(ENOMEM);
> +uid = "a922394d8d87452f878c51f2fc9b4131";
>  }
>  else if (avctx->codec_id == AV_CODEC_ID_HEVC && s->load_plugin != 
> LOAD_PLUGIN_NONE) {
>  static const char * const uid_hevcdec_sw = 
> "15dd936825ad475ea34e35f3f54217a6";
> @@ -707,16 +698,18 @@ static av_cold int qsv_decode_init(AVCodecContext 
> *avctx)
> "load_plugins is not empty, but load_plugin is not set to 
> 'none'."
> "The load_plugin value will be ignored.\n");
>  } else {
> -av_freep(&s->qsv.load_plugins);
> -
>  if (s->load_plugin == LOAD_PLUGIN_HEVC_SW)
> -s->qsv.load_plugins = av_strdup(uid_hevcdec_sw);
> +uid = uid_hevcdec_sw;
>  else
> -s->qsv.load_plugins = av_strdup(uid_hevcdec_hw);
> -if (!s->qsv.load_plugins)
> -return AVERROR(ENOMEM);
> +uid = uid_hevcdec_hw;
>  }
>  }
> +if (uid) {
> +av_freep(&s->qsv.load_plugins);
> +s->qsv.load_plugins = av_strdup(uid);
> +if (!s->qsv.load_plugins)
> +return AVERROR(ENOMEM);
> +}
>
>  s->qsv.orig_pix_fmt = AV_PIX_FMT_NV12;
>  s->packet_fifo = av_fifo_alloc(sizeof(AVPacket));
> --
Merging the AVCodec descriptions for all qsv decoders makes the code
cleaner, since
the majority of them are identical. And all checks passed in [1].

One concern is it may be less convenient or more tricky to modify in
the future, if a
specific decoder changes and differs from the rest.

Anyway, lgtm at least for now, and prefer to apply if no more
comments/objections/concerns.

[1] https://github.com/intel-media-ci/ffmpeg/pull/326

- linjie
___
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 v4 1/2] lavf/qsv: Add functions to print mfx iopattern, warning and error

2021-01-15 Thread Linjie Fu
Haihao:

On Tue, Jan 5, 2021 at 3:03 PM Haihao Xiang  wrote:
>
> It is a copy of the relevant part in lavc/qsv but use different function
> names to avoid multiple definition when linking lavc and lavf statically.
>
> Signed-off-by: Haihao Xiang 
> ---
> v4: rename the new functions to avoid multiple definition
>
>  libavfilter/qsvvpp.c | 104 +++
>  libavfilter/qsvvpp.h |   9 
>  2 files changed, 113 insertions(+)
>
> diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
> index 8d5ff2eb65..b31082db03 100644
> --- a/libavfilter/qsvvpp.c
> +++ b/libavfilter/qsvvpp.c
> @@ -76,6 +76,110 @@ static const mfxHandleType handle_types[] = {
>
>  static const AVRational default_tb = { 1, 9 };
>
> +static const struct {
> +int mfx_iopattern;
> +const char *desc;
> +} qsv_iopatterns[] = {
> +{MFX_IOPATTERN_IN_VIDEO_MEMORY, "input is video memory surface"  
>},
> +{MFX_IOPATTERN_IN_SYSTEM_MEMORY,"input is system memory surface" 
>},
> +{MFX_IOPATTERN_IN_OPAQUE_MEMORY,"input is opaque memory surface" 
>},
> +{MFX_IOPATTERN_OUT_VIDEO_MEMORY,"output is video memory surface" 
>},
> +{MFX_IOPATTERN_OUT_SYSTEM_MEMORY,   "output is system memory surface"
>},
> +{MFX_IOPATTERN_OUT_OPAQUE_MEMORY,   "output is opaque memory surface"
>},
> +};
> +
> +int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern,
> +  const char *extra_string)
> +{
> +const char *desc = NULL;
> +
> +for (int i = 0; i < FF_ARRAY_ELEMS(qsv_iopatterns); i++) {
> +if (qsv_iopatterns[i].mfx_iopattern == mfx_iopattern) {
> +desc = qsv_iopatterns[i].desc;
> +}
> +}
> +if (!desc)
> +desc = "unknown iopattern";
> +
> +av_log(log_ctx, AV_LOG_VERBOSE, "%s: %s\n", extra_string, desc);
> +return 0;
> +}
> +
> +static const struct {
> +mfxStatus   mfxerr;
> +int averr;
> +const char *desc;
> +} qsv_errors[] = {
> +{ MFX_ERR_NONE, 0,   "success"   
>},
> +{ MFX_ERR_UNKNOWN,  AVERROR_UNKNOWN, "unknown error" 
>},
> +{ MFX_ERR_NULL_PTR, AVERROR(EINVAL), "NULL pointer"  
>},
> +{ MFX_ERR_UNSUPPORTED,  AVERROR(ENOSYS), "unsupported"   
>},
> +{ MFX_ERR_MEMORY_ALLOC, AVERROR(ENOMEM), "failed to allocate 
> memory"},
> +{ MFX_ERR_NOT_ENOUGH_BUFFER,AVERROR(ENOMEM), "insufficient 
> input/output buffer" },
> +{ MFX_ERR_INVALID_HANDLE,   AVERROR(EINVAL), "invalid handle"
>},
> +{ MFX_ERR_LOCK_MEMORY,  AVERROR(EIO),"failed to lock the 
> memory block"  },
> +{ MFX_ERR_NOT_INITIALIZED,  AVERROR_BUG, "not initialized"   
>},
> +{ MFX_ERR_NOT_FOUND,AVERROR(ENOSYS), "specified object 
> was not found"   },
> +/* the following 3 errors should always be handled explicitly, so those 
> "mappings"
> + * are for completeness only */
> +{ MFX_ERR_MORE_DATA,AVERROR_UNKNOWN, "expect more data 
> at input"},
> +{ MFX_ERR_MORE_SURFACE, AVERROR_UNKNOWN, "expect more 
> surface at output"},
> +{ MFX_ERR_MORE_BITSTREAM,   AVERROR_UNKNOWN, "expect more 
> bitstream at output"  },
> +{ MFX_ERR_ABORTED,  AVERROR_UNKNOWN, "operation aborted" 
>},
> +{ MFX_ERR_DEVICE_LOST,  AVERROR(EIO),"device lost"   
>},
> +{ MFX_ERR_INCOMPATIBLE_VIDEO_PARAM, AVERROR(EINVAL), "incompatible video 
> parameters"},
> +{ MFX_ERR_INVALID_VIDEO_PARAM,  AVERROR(EINVAL), "invalid video 
> parameters" },
> +{ MFX_ERR_UNDEFINED_BEHAVIOR,   AVERROR_BUG, "undefined 
> behavior"   },
> +{ MFX_ERR_DEVICE_FAILED,AVERROR(EIO),"device failed" 
>},
> +{ MFX_ERR_INCOMPATIBLE_AUDIO_PARAM, AVERROR(EINVAL), "incompatible audio 
> parameters"},
> +{ MFX_ERR_INVALID_AUDIO_PARAM,  AVERROR(EINVAL), "invalid audio 
> parameters" },
> +
> +{ MFX_WRN_IN_EXECUTION, 0,   "operation in 
> execution"   },
> +{ MFX_WRN_DEVICE_BUSY,  0,   "device busy"   
>},
> +{ MFX_WRN_VIDEO_PARAM_CHANGED,  0,   "video parameters 
> changed" },
> +{ MFX_WRN_PARTIAL_ACCELERATION, 0,   "partial 
> acceleration" },
> +{ MFX_WRN_INCOMPATIBLE_VIDEO_PARAM, 0,   "incompatible video 
> parameters"},
> +{ MFX_WRN_VALUE_NOT_CHANGED,0,   "value is 
> saturated"   

[FFmpeg-devel] [PATCH] avcodec/bsf: set pctx to NULL when av_bsf_alloc failed

2021-01-15 Thread Steven Liu
av_bsf_free will free invalid pointer when av_bsf_alloc failed.
because av_bsf_list_parse_str called av_bsf_get_null_filter,
av_bsf_get_null_filter called av_bsf_alloc, and av_bsf_alloc
should set a value to the *pctx before return success or failed,
because it dose not initial a null pointer ever, so it will free
invalid pointer in av_bsf_free which is called by ff_decode_bsfs_init.

Found-by: Zu-Ming Jiang 
Signed-off-by: Steven Liu 
---
 libavcodec/bsf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index d71bc32584..5bb3349138 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -141,6 +141,7 @@ int av_bsf_alloc(const AVBitStreamFilter *filter, 
AVBSFContext **pctx)
 return 0;
 fail:
 av_bsf_free(&ctx);
+*pctx = NULL;
 return ret;
 }
 
-- 
2.15.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 v3] avformat/hls: change sequence number type to int64_t

2021-01-15 Thread Zhao Zhili
Fix atoi() overflow for large EXT-X-MEDIA-SEQUENCE.

The spec says the type of sequence number is uint64_t. Use int64_t
here since current implementation requires it to be signed integer,
and hlsenc use int64_t too.
---
v3:
handle MEDIA-SEQUENCE higher than INT64_MAX

v2:
AV_WB32 -> AV_WB64

 libavformat/hls.c | 56 +++
 1 file changed, 32 insertions(+), 24 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 619e4800de..af2468ad9b 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -112,13 +112,13 @@ struct playlist {
 int finished;
 enum PlaylistType type;
 int64_t target_duration;
-int start_seq_no;
+int64_t start_seq_no;
 int n_segments;
 struct segment **segments;
 int needed;
 int broken;
-int cur_seq_no;
-int last_seq_no;
+int64_t cur_seq_no;
+int64_t last_seq_no;
 int m3u8_hold_counters;
 int64_t cur_seg_offset;
 int64_t last_load_time;
@@ -199,7 +199,7 @@ typedef struct HLSContext {
 int n_renditions;
 struct rendition **renditions;
 
-int cur_seq_no;
+int64_t cur_seq_no;
 int m3u8_hold_counters;
 int live_start_index;
 int first_packet;
@@ -722,7 +722,7 @@ static int parse_playlist(HLSContext *c, const char *url,
 int is_http = av_strstart(url, "http", NULL);
 struct segment **prev_segments = NULL;
 int prev_n_segments = 0;
-int prev_start_seq_no = -1;
+int64_t prev_start_seq_no = -1;
 
 if (is_http && !in && c->http_persistent && c->playlist_pb) {
 in = c->playlist_pb;
@@ -808,10 +808,17 @@ static int parse_playlist(HLSContext *c, const char *url,
 goto fail;
 pls->target_duration = strtoll(ptr, NULL, 10) * AV_TIME_BASE;
 } else if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
+uint64_t seq_no;
 ret = ensure_playlist(c, &pls, url);
 if (ret < 0)
 goto fail;
-pls->start_seq_no = atoi(ptr);
+seq_no = strtoull(ptr, NULL, 10);
+if (seq_no > INT64_MAX) {
+av_log(c->ctx, AV_LOG_DEBUG, "MEDIA-SEQUENCE higher than "
+"INT64_MAX, mask out the highest bit\n");
+seq_no &= INT64_MAX;
+}
+pls->start_seq_no = seq_no;
 } else if (av_strstart(line, "#EXT-X-PLAYLIST-TYPE:", &ptr)) {
 ret = ensure_playlist(c, &pls, url);
 if (ret < 0)
@@ -832,9 +839,9 @@ static int parse_playlist(HLSContext *c, const char *url,
 if (has_iv) {
 memcpy(cur_init_section->iv, iv, sizeof(iv));
 } else {
-int seq = pls->start_seq_no + pls->n_segments;
+int64_t seq = pls->start_seq_no + pls->n_segments;
 memset(cur_init_section->iv, 0, sizeof(cur_init_section->iv));
-AV_WB32(cur_init_section->iv + 12, seq);
+AV_WB64(cur_init_section->iv + 8, seq);
 }
 
 if (key_type != KEY_NONE) {
@@ -889,9 +896,9 @@ static int parse_playlist(HLSContext *c, const char *url,
 if (has_iv) {
 memcpy(seg->iv, iv, sizeof(iv));
 } else {
-int seq = pls->start_seq_no + pls->n_segments;
+int64_t seq = pls->start_seq_no + pls->n_segments;
 memset(seg->iv, 0, sizeof(seg->iv));
-AV_WB32(seg->iv + 12, seq);
+AV_WB64(seg->iv + 8, seq);
 }
 
 if (key_type != KEY_NONE) {
@@ -954,16 +961,17 @@ static int parse_playlist(HLSContext *c, const char *url,
 if (prev_segments) {
 if (pls->start_seq_no > prev_start_seq_no && c->first_timestamp != 
AV_NOPTS_VALUE) {
 int64_t prev_timestamp = c->first_timestamp;
-int i, diff = pls->start_seq_no - prev_start_seq_no;
+int i;
+int64_t diff = pls->start_seq_no - prev_start_seq_no;
 for (i = 0; i < prev_n_segments && i < diff; i++) {
 c->first_timestamp += prev_segments[i]->duration;
 }
-av_log(c->ctx, AV_LOG_DEBUG, "Media sequence change (%d -> %d)"
+av_log(c->ctx, AV_LOG_DEBUG, "Media sequence change (%"PRId64" -> 
%"PRId64")"
" reflected in first_timestamp: %"PRId64" -> %"PRId64"\n",
prev_start_seq_no, pls->start_seq_no,
prev_timestamp, c->first_timestamp);
 } else if (pls->start_seq_no < prev_start_seq_no) {
-av_log(c->ctx, AV_LOG_WARNING, "Media sequence changed 
unexpectedly: %d -> %d\n",
+av_log(c->ctx, AV_LOG_WARNING, "Media sequence changed 
unexpectedly: %"PRId64" -> %"PRId64"\n",
prev_start_seq_no, pls->start_seq_no);
 }
 free_segment_dynarray(prev_segments, prev_n_segments);
@@ -991,7 +999,7 @@ static struct segment *current_s

[FFmpeg-devel] [PATCH v2] avformat/async: Use AVERROR macro

2021-01-15 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/async.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/async.c b/libavformat/async.c
index a0bdfa2..cc11ec4 100644
--- a/libavformat/async.c
+++ b/libavformat/async.c
@@ -262,24 +262,28 @@ static int async_open(URLContext *h, const char *arg, int 
flags, AVDictionary **
 
 ret = pthread_mutex_init(&c->mutex, NULL);
 if (ret != 0) {
+ret = AVERROR(ret);
 av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", 
av_err2str(ret));
 goto mutex_fail;
 }
 
 ret = pthread_cond_init(&c->cond_wakeup_main, NULL);
 if (ret != 0) {
+ret = AVERROR(ret);
 av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", 
av_err2str(ret));
 goto cond_wakeup_main_fail;
 }
 
 ret = pthread_cond_init(&c->cond_wakeup_background, NULL);
 if (ret != 0) {
+ret = AVERROR(ret);
 av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", 
av_err2str(ret));
 goto cond_wakeup_background_fail;
 }
 
 ret = pthread_create(&c->async_buffer_thread, NULL, async_buffer_task, h);
 if (ret) {
+ret = AVERROR(ret);
 av_log(h, AV_LOG_ERROR, "pthread_create failed : %s\n", 
av_err2str(ret));
 goto thread_fail;
 }
-- 
1.8.3.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] libavcodec/hevcdsp: port SIMD idct functions from 32-bit.

2021-01-15 Thread Reimar Döffinger


> On 15 Jan 2021, at 23:55, Martin Storsjö  wrote:
> 
> On Tue, 12 Jan 2021, reimar.doeffin...@gmx.de wrote:
> 
>> create mode 100644 libavcodec/aarch64/hevcdsp_idct_neon.S
>> create mode 100644 libavcodec/aarch64/hevcdsp_init_aarch64.c
> 
> This patch fails checkasm

Fixed, one mis-translated coefficient index...

>> 
>> +.macro fixsqrshrn d, dt, n, m
>> +  .ifc \dt, .8H
>> +sqrshrn2\d\dt, \n\().4S, \m
>> +  .else
>> +sqrshrn \n\().4H, \n\().4S, \m
>> +mov \d\().D[0], \n\().D[0]
>> +  .endif
>> +.endm
> 
> Is this to set the lower half of the dest register, without wiping the upper 
> part? It looks a bit clumsy (and stall-prone on in-order cores), but I guess 
> it's not easy to do things differently without rewriting the higher level 
> structure?

Did not have a good idea, but I was also aiming for keeping the structure of 
the 32-bit and 64-bit code similar.
In particular since I did not know about checkasm and expected some further 
painful debug.

> 
>> +.macro transpose_8x8 r0, r1, r2, r3, r4, r5, r6, r7
>> +transpose8_4x4  \r0, \r1, \r2, \r3
>> +transpose8_4x4  \r4, \r5, \r6, \r7
>> +.endm
>> +
> 
> There's a bunch of existing transposes in libavcodec/aarch64/neon.S - can 
> they be used? Not that they're rocket science, though... And I see that the 
> existing arm version also has got its own transpose macros.
> 
> If it's inconvenient to use shared macros, this is fine.

They are different and seem to not be documented, so it would take some
time to figure out how to replace them.
There’s also a bit of a question if I’d want to give up alignment
with the 32-bit code just yet.


> 
>> +// Transpose each 4x4 block, and swap how d4-d7 and d8-d11 are used.
>> +// Layout before:
>> +// d0  d1
>> +// d2  d3
>> +// d4  d5
>> +// d6  d7
>> +// d8  d9
>> +// d10 d11
>> +// d12 d13
>> +// d14 d15
> 
> These layouts don't look like they're up to date for the aarch64 version?

Removed in new version as it seems not that useful.

>> 
>> +vst1.s32{\in7}, [r3, :128]
>> +.endm
> 
> This is left behind untranslated (and thus unused)

Removed. I am not sure if that means it’s also unused in the 32-bit version.

>> +
>> +movrel  x1, trans + 16
> 
> The movrel macro has got a separate third optional argument for the offset, 
> so write this "movrel x1, trans, 16". (Older versions of llvm are picky with 
> the symbol offset syntax and break with this, as the macro right now adds its 
> own implicit +(0) here. If you pass the offset in the macro parameter, all 
> the offsets get passed within the parentheses.

Changed.

>> +.macro idct_16x16 bitdepth
>> +function ff_hevc_idct_16x16_\bitdepth\()_neon, export=1
>> +//r0 - coeffs
>> +mov x15, lr
>> +
> 
> Binutils doesn't recognize "lr" as alias for x30

It didn’t have an issue in the Debian unstable VM?
That seems like the kind of workaround where it would be
better to leave a comment with more info, if you know
what exactly is affected.

___
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] libavcodec/hevcdsp: port SIMD idct functions from 32-bit.

2021-01-15 Thread Reimar . Doeffinger
From: Reimar Döffinger 

Makes SIMD-optimized 8x8 and 16x16 idcts for 8 and 10 bit depth
available on aarch64.
For a UHD HDR (10 bit) sample video these were consuming the most time
and this optimization reduced overall decode time from 19.4s to 16.4s,
approximately 15% speedup.
Test sample was the first 300 frames of "LG 4K HDR Demo - New York.ts",
running on Apple M1.
---
 libavcodec/aarch64/Makefile   |   2 +
 libavcodec/aarch64/hevcdsp_idct_neon.S| 380 ++
 libavcodec/aarch64/hevcdsp_init_aarch64.c |  45 +++
 libavcodec/hevcdsp.c  |   2 +
 libavcodec/hevcdsp.h  |   1 +
 5 files changed, 430 insertions(+)
 create mode 100644 libavcodec/aarch64/hevcdsp_idct_neon.S
 create mode 100644 libavcodec/aarch64/hevcdsp_init_aarch64.c

diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
index f6434e40da..2ea1d74a38 100644
--- a/libavcodec/aarch64/Makefile
+++ b/libavcodec/aarch64/Makefile
@@ -61,3 +61,5 @@ NEON-OBJS-$(CONFIG_VP9_DECODER) += 
aarch64/vp9itxfm_16bpp_neon.o   \
aarch64/vp9lpf_neon.o   
\
aarch64/vp9mc_16bpp_neon.o  
\
aarch64/vp9mc_neon.o
+NEON-OBJS-$(CONFIG_HEVC_DECODER)+= aarch64/hevcdsp_idct_neon.o 
\
+   aarch64/hevcdsp_init_aarch64.o
diff --git a/libavcodec/aarch64/hevcdsp_idct_neon.S 
b/libavcodec/aarch64/hevcdsp_idct_neon.S
new file mode 100644
index 00..4aac205e22
--- /dev/null
+++ b/libavcodec/aarch64/hevcdsp_idct_neon.S
@@ -0,0 +1,380 @@
+/*
+ * ARM NEON optimised IDCT functions for HEVC decoding
+ * Copyright (c) 2014 Seppo Tomperi 
+ * Copyright (c) 2017 Alexandra Hájková
+ *
+ * Ported from arm/hevcdsp_idct_neon.S by
+ * Copyright (c) 2020 Reimar Döffinger
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+
+const trans, align=4
+.short 64, 83, 64, 36
+.short 89, 75, 50, 18
+.short 90, 87, 80, 70
+.short 57, 43, 25, 9
+.short 90, 90, 88, 85
+.short 82, 78, 73, 67
+.short 61, 54, 46, 38
+.short 31, 22, 13, 4
+endconst
+
+.macro sum_sub out, in, c, op, p
+  .ifc \op, +
+smlal\p \out, \in, \c
+  .else
+smlsl\p \out, \in, \c
+  .endif
+.endm
+
+.macro fixsqrshrn d, dt, n, m
+  .ifc \dt, .8H
+sqrshrn2\d\dt, \n\().4S, \m
+  .else
+sqrshrn \n\().4H, \n\().4S, \m
+mov \d\().D[0], \n\().D[0]
+  .endif
+.endm
+
+// uses and clobbers v28-v31 as temp registers
+.macro tr_4x4_8 in0, in1, in2, in3, out0, out1, out2, out3, p1, p2
+ sshll\p1   v28.4S, \in0, #6
+ movv29.16B, v28.16B
+ smull\p1   v30.4S, \in1, v0.H[1]
+ smull\p1   v31.4S, \in1, v0.H[3]
+ smlal\p2   v28.4S, \in2, v0.H[0] //e0
+ smlsl\p2   v29.4S, \in2, v0.H[0] //e1
+ smlal\p2   v30.4S, \in3, v0.H[3] //o0
+ smlsl\p2   v31.4S, \in3, v0.H[1] //o1
+
+ add\out0, v28.4S, v30.4S
+ add\out1, v29.4S, v31.4S
+ sub\out2, v29.4S, v31.4S
+ sub\out3, v28.4S, v30.4S
+.endm
+
+.macro transpose8_4x4 r0, r1, r2, r3
+trn1v2.8H, \r0\().8H, \r1\().8H
+trn2v3.8H, \r0\().8H, \r1\().8H
+trn1v4.8H, \r2\().8H, \r3\().8H
+trn2v5.8H, \r2\().8H, \r3\().8H
+trn1\r0\().4S, v2.4S, v4.4S
+trn2\r2\().4S, v2.4S, v4.4S
+trn1\r1\().4S, v3.4S, v5.4S
+trn2\r3\().4S, v3.4S, v5.4S
+.endm
+
+.macro transpose_8x8 r0, r1, r2, r3, r4, r5, r6, r7
+transpose8_4x4  \r0, \r1, \r2, \r3
+transpose8_4x4  \r4, \r5, \r6, \r7
+.endm
+
+.macro tr_8x4 shift, in0,in0t, in1,in1t, in2,in2t, in3,in3t, in4,in4t, 
in5,in5t, in6,in6t, in7,in7t, p1, p2
+tr_4x4_8\in0\in0t, \in2\in2t, \in4\in4t, \in6\in6t, v24.4S, 
v25.4S, v26.4S, v27.4S, \p1, \p2
+
+smull\p1v30.4S, \in1\in1t, v0.H[6]
+smull\p1 

Re: [FFmpeg-devel] [PATCH 5/5] avformat/hlsenc: use AV_OPT_TYPE_DURATION

2021-01-15 Thread lance . lmwang
On Fri, Jan 15, 2021 at 02:27:44PM +0100, Moritz Barsnick wrote:
> On Wed, Jan 06, 2021 at 23:35:31 +0800, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> >
> > Signed-off-by: Limin Wang 
> > ---
> >  doc/muxers.texi  |  4 ++--
> >  libavformat/hlsenc.c | 18 +-
> >  2 files changed, 11 insertions(+), 11 deletions(-)
> >
> > diff --git a/doc/muxers.texi b/doc/muxers.texi
> > index 8e12aca..044c16b 100644
> > --- a/doc/muxers.texi
> > +++ b/doc/muxers.texi
> > @@ -609,13 +609,13 @@ segmentation.
> >  This muxer supports the following options:
> >
> >  @table @option
> > -@item hls_init_time @var{seconds}
> > +@item hls_init_time @var{duration}
> >  Set the initial target segment length in seconds. Default value is @var{0}.
> >  Segment will be cut on the next key frame after this time has passed on 
> > the first m3u8 list.
> >  After the initial playlist is filled @command{ffmpeg} will cut segments
> >  at duration equal to @code{hls_time}
> 
> AV_OPT_TYPE_DURATION is not strictly seconds. It can use other
> syntaxes. You could refer to the appropriate section:
> 
> > see @ref{time duration syntax,,the Time duration section in the 
> > ffmpeg-utils(1) manual,ffmpeg-utils}.

OK, will add the section for reference if have update.

> 
> 
> >  Set the target segment length in seconds. Default value is 2.
> 
> Ditto.

will fix it.

> 
> > -{"hls_time",  "set segment length in seconds",   
> > OFFSET(time),AV_OPT_TYPE_FLOAT,  {.dbl = 2}, 0, FLT_MAX, E},
> > -{"hls_init_time", "set segment length in seconds at init list",
> >OFFSET(init_time),AV_OPT_TYPE_FLOAT,  {.dbl = 0}, 0, FLT_MAX, E},
> > +{"hls_time",  "set segment length in seconds",   
> > OFFSET(time),AV_OPT_TYPE_DURATION,  {.i64 = 200}, 0, INT64_MAX, 
> > E},
> > +{"hls_init_time", "set segment length in seconds at init list",
> >OFFSET(init_time),AV_OPT_TYPE_DURATION,  {.i64 = 0}, 0, 
> > INT64_MAX, E},
> 
> Ditto, just "set segment length".

will fix it.


> 
> Cheers,
> Moritz
> ___
> 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".

-- 
Thanks,
Limin Wang
___
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 v4 3/3] avformat/mxfenc: prefer to use the configured metadta

2021-01-15 Thread lance . lmwang
On Fri, Jan 15, 2021 at 09:43:58PM +0100, Marton Balint wrote:
> 
> 
> On Fri, 15 Jan 2021, Tomas Härdin wrote:
> 
> > lör 2021-01-09 klockan 13:07 +0800 skrev lance.lmw...@gmail.com:
> > > From: Limin Wang 
> > > 
> > > The metadata company_name, product_name, product_version from input
> > > file will be deleted to avoid overwriting information
> > > Please to test with below command:
> > > ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf
> > > and
> > > ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy \
> > > -metadata company_name="xxx" \
> > > -metadata product_name="xxx" \
> > > -metadata product_version="xxx" \
> > > out.mxf
> > > 
> > > Signed-off-by: Limin Wang 
> > > ---
> > >  fftools/ffmpeg_opt.c |  3 +++
> > >  libavformat/mxfenc.c | 12 
> > >  2 files changed, 11 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> > > index c295514..493763b 100644
> > > --- a/fftools/ffmpeg_opt.c
> > > +++ b/fftools/ffmpeg_opt.c
> > > @@ -2650,6 +2650,9 @@ loop_end:
> > >  if(o->recording_time != INT64_MAX)
> > >  av_dict_set(&oc->metadata, "duration", NULL, 0);
> > >  av_dict_set(&oc->metadata, "creation_time", NULL, 0);
> > > +av_dict_set(&oc->metadata, "company_name", NULL, 0);
> > > +av_dict_set(&oc->metadata, "product_name", NULL, 0);
> > > +av_dict_set(&oc->metadata, "product_version", NULL, 0);
> > >  }
> > >  if (!o->metadata_streams_manual)
> > >  for (i = of->ost_index; i < nb_output_streams; i++) {
> > > diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> > > index d8678c9..5244211 100644
> > > --- a/libavformat/mxfenc.c
> > > +++ b/libavformat/mxfenc.c
> > > @@ -722,16 +722,20 @@ static void 
> > > mxf_write_identification(AVFormatContext *s)
> > >  {
> > >  MXFContext *mxf = s->priv_data;
> > >  AVIOContext *pb = s->pb;
> > > -const char *company = "FFmpeg";
> > > -const char *product = s->oformat != &ff_mxf_opatom_muxer ? "OP1a 
> > > Muxer" : "OPAtom Muxer";
> > > -const char *version;
> > > +AVDictionaryEntry *com_entry =  av_dict_get(s->metadata, 
> > > "company_name", NULL, 0);
> > > +AVDictionaryEntry *product_entry =  av_dict_get(s->metadata, 
> > > "product_name", NULL, 0);
> > > +AVDictionaryEntry *version_entry =  av_dict_get(s->metadata, 
> > > "product_version", NULL, 0);
> > > +const char *company = com_entry ? com_entry->value : "FFmpeg";
> > > +const char *product = product_entry ? product_entry->value : 
> > > s->oformat != &ff_mxf_opatom_muxer ? "OP1a Muxer" : "OPAtom Muxer";
> > > +const char *version = NULL;
> > > +const char *product_version = version_entry ? version_entry->value : 
> > > AV_STRINGIFY(LIBAVFORMAT_VERSION);
> > >  int length;
> > > 
> > >  mxf_write_metadata_key(pb, 0x013000);
> > >  PRINT_KEY(s, "identification key", pb->buf_ptr - 16);
> > > 
> > >  version = s->flags & AVFMT_FLAG_BITEXACT ?
> > > -"0.0.0" : AV_STRINGIFY(LIBAVFORMAT_VERSION);
> > > +"0.0.0" : product_version;
> > 
> > Again, why? If you have a company that maintains a fork of FFmpeg then
> > compile that info in here instead. Compare with FFmbc which always puts
> > "FFmbc" as CompanyName.
> 
> And how can a product based on libavformat set the company name, product
> name and product version? It seems a valid use case for me that these are
> overridable. Also note that this product version is only the "user friendly"
> version string, for the numeric version still LIBAVFORMAT_VERSION values are
> used.

Yes, my use case is the product is using libavformat as library, so it's
prefer to have way to override these information as requirements.

> 
> Regards,
> Marton
> ___
> 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".

-- 
Thanks,
Limin Wang
___
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] avformat/async: Use the correct return values

2021-01-15 Thread lance . lmwang
On Sat, Jan 16, 2021 at 12:30:04AM +0100, Michael Niedermayer wrote:
> On Thu, Jan 14, 2021 at 11:29:18PM +0800, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavformat/async.c | 4 
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/libavformat/async.c b/libavformat/async.c
> > index a0bdfa2..801b20e 100644
> > --- a/libavformat/async.c
> > +++ b/libavformat/async.c
> > @@ -263,24 +263,28 @@ static int async_open(URLContext *h, const char *arg, 
> > int flags, AVDictionary **
> >  ret = pthread_mutex_init(&c->mutex, NULL);
> >  if (ret != 0) {
> >  av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", 
> > av_err2str(ret));
> > +ret = AVERROR(ret);
> >  goto mutex_fail;
> >  }
> >  
> >  ret = pthread_cond_init(&c->cond_wakeup_main, NULL);
> >  if (ret != 0) {
> >  av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", 
> > av_err2str(ret));
> > +ret = AVERROR(ret);
> >  goto cond_wakeup_main_fail;
> >  }
> >  
> >  ret = pthread_cond_init(&c->cond_wakeup_background, NULL);
> >  if (ret != 0) {
> >  av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", 
> > av_err2str(ret));
> > +ret = AVERROR(ret);
> >  goto cond_wakeup_background_fail;
> >  }
> >  
> >  ret = pthread_create(&c->async_buffer_thread, NULL, async_buffer_task, 
> > h);
> >  if (ret) {
> >  av_log(h, AV_LOG_ERROR, "pthread_create failed : %s\n", 
> > av_err2str(ret));
> > +ret = AVERROR(ret);
> 
> the av_err2str() calls should probably be after AVERROR

Yes, will move the AVERROR before av_log.

> 
> thx
> 
> [...]
> 
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> In fact, the RIAA has been known to suggest that students drop out
> of college or go to community college in order to be able to afford
> settlements. -- The RIAA



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


-- 
Thanks,
Limin Wang
___
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] configure: Set MSVC as_default later.

2021-01-15 Thread Reimar Döffinger


> On 15 Jan 2021, at 23:25, Martin Storsjö  wrote:
> 
> On Fri, 15 Jan 2021, reimar.doeffin...@gmx.de wrote:
> 
>> From: Reimar Döffinger 
>> 
>> It would get immediately overridden to $cc, which in case
>> of gas-preprocessor missing would result in it trying
>> to use cl.exe for asm files instead of erroring out.
>> This is because cl.exe does not fail but just print a warning
>> when it is given a file it does not know what to do with it...
> 
> As this setup seems to work fine in the setups I've tried, can you think of 
> why it's overwritten with $cc in your cases?
> 
> With the line
>: ${as_default:=$cc}
> it only sets as_default to $cc if $as_default is empty.

Actually after a few debug prints it’s clear what actually happens:
$arch is not set at that point unless specified on command-line.
Not sure if it’s reasonable to just check arch_default as fallback or such?

> You can't really do that here. Probe_cc only should set the existing set of 
> _type/_ident/_ldflags/_cflags* etc variables, which are picked up by the 
> caller of probe_cc. probe_cc is called separately for both host and target 
> compilers, so if e.g. cross compiling, with MSVC as host compiler, with a 
> different compiler for the target, this wouldn't do the right thing.

Then the armcc logic in there is broken I guess?

___
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] avformat/async: Use the correct return values

2021-01-15 Thread Michael Niedermayer
On Thu, Jan 14, 2021 at 11:29:18PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavformat/async.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavformat/async.c b/libavformat/async.c
> index a0bdfa2..801b20e 100644
> --- a/libavformat/async.c
> +++ b/libavformat/async.c
> @@ -263,24 +263,28 @@ static int async_open(URLContext *h, const char *arg, 
> int flags, AVDictionary **
>  ret = pthread_mutex_init(&c->mutex, NULL);
>  if (ret != 0) {
>  av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", 
> av_err2str(ret));
> +ret = AVERROR(ret);
>  goto mutex_fail;
>  }
>  
>  ret = pthread_cond_init(&c->cond_wakeup_main, NULL);
>  if (ret != 0) {
>  av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", 
> av_err2str(ret));
> +ret = AVERROR(ret);
>  goto cond_wakeup_main_fail;
>  }
>  
>  ret = pthread_cond_init(&c->cond_wakeup_background, NULL);
>  if (ret != 0) {
>  av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", 
> av_err2str(ret));
> +ret = AVERROR(ret);
>  goto cond_wakeup_background_fail;
>  }
>  
>  ret = pthread_create(&c->async_buffer_thread, NULL, async_buffer_task, 
> h);
>  if (ret) {
>  av_log(h, AV_LOG_ERROR, "pthread_create failed : %s\n", 
> av_err2str(ret));
> +ret = AVERROR(ret);

the av_err2str() calls should probably be after AVERROR

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA


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] avutil/parseutils: Check sign in av_parse_time()

2021-01-15 Thread Michael Niedermayer
Fixes: signed integer overflow: -9223372053736 * 100 cannot be represented 
in type 'long'
Fixes: 
26910/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-6607924558430208

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavutil/parseutils.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index 167e822648..7f678cd85a 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -736,12 +736,14 @@ int av_parse_time(int64_t *timeval, const char *timestr, 
int duration)
 if (*q)
 return AVERROR(EINVAL);
 
-if (INT64_MAX / suffix < t)
+if (INT64_MAX / suffix < t || t < INT64_MIN / suffix)
 return AVERROR(ERANGE);
 t *= suffix;
 if (INT64_MAX - microseconds < t)
 return AVERROR(ERANGE);
 t += microseconds;
+if (t == INT64_MIN && negative)
+return AVERROR(ERANGE);
 *timeval = negative ? -t : t;
 return 0;
 }
-- 
2.17.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 6/7] avformat/lxfdec: Fix multiple integer overflows related to track_size

2021-01-15 Thread Michael Niedermayer
On Fri, Jan 15, 2021 at 09:48:38AM +0100, Tomas Härdin wrote:
> tor 2021-01-14 klockan 23:51 +0100 skrev Michael Niedermayer:
> > Fixes: signed integer overflow: 538976288 * 8 cannot be represented in type 
> > 'int'
> > Fixes: 
> > 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_LXF_fuzzer-6634030636335104
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/lxfdec.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/lxfdec.c b/libavformat/lxfdec.c
> > index fa84ceea78..509d19fe7f 100644
> > --- a/libavformat/lxfdec.c
> > +++ b/libavformat/lxfdec.c
> > @@ -195,7 +195,7 @@ static int get_packet_header(AVFormatContext *s)
> >  return AVERROR_PATCHWELCOME;
> >  }
> >  
> > -samples = track_size * 8 / st->codecpar->bits_per_coded_sample;
> > +samples = track_size * 8LL / st->codecpar->bits_per_coded_sample;
> >  
> >  //use audio packet size to determine video standard
> >  //for NTSC we have one 8008-sample audio frame per five video 
> > frames
> > @@ -210,6 +210,8 @@ static int get_packet_header(AVFormatContext *s)
> >  avpriv_set_pts_info(s->streams[0], 64, 1, 25);
> >  }
> >  
> > +if (av_popcount(channels) * (uint64_t)track_size > INT_MAX)
> > +return AVERROR_INVALIDDATA;
> >  //TODO: warning if track mask != (1 << channels) - 1?
> >  ret = av_popcount(channels) * track_size;
> 
> What happens if channels == 0 ? Probably gets caught in
> av_new_packet(), just making sure

Probably would produce a 0 sized packet.
That could be checked for too but seems unrelated to the integer overflow
are there any other constraints i should check for ?
The code suggests  mask != (1 << channels) - 1
what level of warning vs. error do you prefer for the different odd
possibilities?

thx


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates


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 3/7] avutil/parseutils: Check sign in av_parse_time()

2021-01-15 Thread Michael Niedermayer
On Fri, Jan 15, 2021 at 09:36:26PM +0100, Marton Balint wrote:
> 
> 
> On Thu, 14 Jan 2021, Michael Niedermayer wrote:
> 
> > Fixes: signed integer overflow: -9223372053736 * 100 cannot be 
> > represented in type 'long'
> > Fixes: 
> > 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-6607924558430208
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> > libavutil/parseutils.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
> > index 167e822648..6161f4ac95 100644
> > --- a/libavutil/parseutils.c
> > +++ b/libavutil/parseutils.c
> > @@ -736,7 +736,7 @@ int av_parse_time(int64_t *timeval, const char 
> > *timestr, int duration)
> > if (*q)
> > return AVERROR(EINVAL);
> > 
> > -if (INT64_MAX / suffix < t)
> > +if (t < 0 || INT64_MAX / suffix < t)
> 
> This does not look right, because a negative t can mean a date before 1970.

indeed ive somehow mixed something up between the negative duration handling
and the documentation of the error code.
Will post a better patch

thx

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

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope


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

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

Re: [FFmpeg-devel] [PATCH] libavcodec/aarch64/hevcdsp_idct_neon.S: Also port add_residual functions.

2021-01-15 Thread Martin Storsjö

On Sun, 10 Jan 2021, reimar.doeffin...@gmx.de wrote:


From: Reimar Döffinger 

Speedup is fairly small, around 1.5%, but these are fairly simple.
---
libavcodec/aarch64/hevcdsp_idct_neon.S| 190 ++
libavcodec/aarch64/hevcdsp_init_aarch64.c |  24 +++
2 files changed, 214 insertions(+)

diff --git a/libavcodec/aarch64/hevcdsp_idct_neon.S 
b/libavcodec/aarch64/hevcdsp_idct_neon.S
index 9f67e45..edd03a0 100644
--- a/libavcodec/aarch64/hevcdsp_idct_neon.S
+++ b/libavcodec/aarch64/hevcdsp_idct_neon.S
@@ -36,6 +36,196 @@ const trans, align=4
.short 31, 22, 13, 4
endconst

+.macro clip10 in1, in2, c1, c2
+smax\in1, \in1, \c1
+smax\in2, \in2, \c1
+smin\in1, \in1, \c2
+smin\in2, \in2, \c2
+.endm
+
+function ff_hevc_add_residual_4x4_8_neon, export=1
+ld1 {v0.8H-v1.8H}, [x1]
+ld1 {v2.S}[0], [x0], x2
+ld1 {v2.S}[1], [x0], x2
+ld1 {v2.S}[2], [x0], x2
+ld1 {v2.S}[3], [x0], x2
+sub x0, x0, x2, lsl #2
+uxtlv8.8H, v2.8B
+uxtl2   v9.8H, v2.16B
+sqadd   v0.8H, v0.8H, v8.8H


FWIW, as a matter of taste, I dislike the shouty uppercase version of e.g. 
element specifiers, like .8H here. The code base contains both styles, but 
I'd say the lowercase form is more prevalent.


Overall, this patch looks good, nothing much to comment on I think. Not 
tested fully though, as it depends on the other patch, which still has a 
few issues (and fails checkasm).


// Martin
___
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] libavcodec/hevcdsp: port SIMD idct functions from 32-bit.

2021-01-15 Thread Martin Storsjö

On Tue, 12 Jan 2021, reimar.doeffin...@gmx.de wrote:


From: Reimar Döffinger 

Makes SIMD-optimized 8x8 and 16x16 idcts for 8 and 10 bit depth
available on aarch64.
For a UHD HDR (10 bit) sample video these were consuming the most time
and this optimization reduced overall decode time from 19.4s to 16.4s,
approximately 15% speedup.
Test sample was the first 300 frames of "LG 4K HDR Demo - New York.ts",
running on Apple M1.
---
libavcodec/aarch64/Makefile   |   2 +
libavcodec/aarch64/hevcdsp_idct_neon.S| 423 ++
libavcodec/aarch64/hevcdsp_init_aarch64.c |  45 +++
libavcodec/hevcdsp.c  |   2 +
libavcodec/hevcdsp.h  |   1 +
5 files changed, 473 insertions(+)
create mode 100644 libavcodec/aarch64/hevcdsp_idct_neon.S
create mode 100644 libavcodec/aarch64/hevcdsp_init_aarch64.c


This patch fails checkasm



diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
index f6434e40da..2ea1d74a38 100644
--- a/libavcodec/aarch64/Makefile
+++ b/libavcodec/aarch64/Makefile
@@ -61,3 +61,5 @@ NEON-OBJS-$(CONFIG_VP9_DECODER) += 
aarch64/vp9itxfm_16bpp_neon.o   \
   aarch64/vp9lpf_neon.o   \
   aarch64/vp9mc_16bpp_neon.o  \
   aarch64/vp9mc_neon.o
+NEON-OBJS-$(CONFIG_HEVC_DECODER)+= aarch64/hevcdsp_idct_neon.o 
\
+   aarch64/hevcdsp_init_aarch64.o
diff --git a/libavcodec/aarch64/hevcdsp_idct_neon.S 
b/libavcodec/aarch64/hevcdsp_idct_neon.S
new file mode 100644
index 00..6b42f6ca3a
--- /dev/null
+++ b/libavcodec/aarch64/hevcdsp_idct_neon.S
@@ -0,0 +1,423 @@
+/*
+ * ARM NEON optimised IDCT functions for HEVC decoding
+ * Copyright (c) 2014 Seppo Tomperi 
+ * Copyright (c) 2017 Alexandra Hájková
+ *
+ * Ported from arm/hevcdsp_idct_neon.S by
+ * Copyright (c) 2020 Reimar Döffinger
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+
+const trans, align=4
+.short 64, 83, 64, 36
+.short 89, 75, 50, 18
+.short 90, 87, 80, 70
+.short 57, 43, 25, 9
+.short 90, 90, 88, 85
+.short 82, 78, 73, 67
+.short 61, 54, 46, 38
+.short 31, 22, 13, 4
+endconst
+
+.macro sum_sub out, in, c, op, p
+  .ifc \op, +
+smlal\p \out, \in, \c
+  .else
+smlsl\p \out, \in, \c
+  .endif
+.endm
+
+.macro fixsqrshrn d, dt, n, m
+  .ifc \dt, .8H
+sqrshrn2\d\dt, \n\().4S, \m
+  .else
+sqrshrn \n\().4H, \n\().4S, \m
+mov \d\().D[0], \n\().D[0]
+  .endif
+.endm


Is this to set the lower half of the dest register, without wiping the 
upper part? It looks a bit clumsy (and stall-prone on in-order cores), but 
I guess it's not easy to do things differently without rewriting the 
higher level structure?




+
+// uses and clobbers v28-v31 as temp registers
+.macro tr_4x4_8 in0, in1, in2, in3, out0, out1, out2, out3, p1, p2
+ sshll\p1   v28.4S, \in0, #6
+ movv29.16B, v28.16B
+ smull\p1   v30.4S, \in1, v0.H[1]
+ smull\p1   v31.4S, \in1, v0.H[3]
+ smlal\p2   v28.4S, \in2, v0.H[0] //e0
+ smlsl\p2   v29.4S, \in2, v0.H[0] //e1
+ smlal\p2   v30.4S, \in3, v0.H[3] //o0
+ smlsl\p2   v31.4S, \in3, v0.H[1] //o1
+
+ add\out0, v28.4S, v30.4S
+ add\out1, v29.4S, v31.4S
+ sub\out2, v29.4S, v31.4S
+ sub\out3, v28.4S, v30.4S
+.endm
+
+.macro transpose8_4x4 r0, r1, r2, r3
+trn1v2.8H, \r0\().8H, \r1\().8H
+trn2v3.8H, \r0\().8H, \r1\().8H
+trn1v4.8H, \r2\().8H, \r3\().8H
+trn2v5.8H, \r2\().8H, \r3\().8H
+trn1\r0\().4S, v2.4S, v4.4S
+trn2\r2\().4S, v2.4S, v4.4S
+trn1\r1\().4S, v3.4S, v5.4S
+trn2\r3\().4S, v3.4S, v5.4S
+.endm
+
+.macro transpose_8x8 r0, r1, r2, r3, r4, r5, r6, r7
+transpose8_4x4  \r0, \r1, \r2, \r3
+transpose8_4x4  \r4,

Re: [FFmpeg-devel] [PATCH] configure: Set MSVC as_default later.

2021-01-15 Thread Martin Storsjö

On Fri, 15 Jan 2021, reimar.doeffin...@gmx.de wrote:


From: Reimar Döffinger 

It would get immediately overridden to $cc, which in case
of gas-preprocessor missing would result in it trying
to use cl.exe for asm files instead of erroring out.
This is because cl.exe does not fail but just print a warning
when it is given a file it does not know what to do with it...


As this setup seems to work fine in the setups I've tried, can you think 
of why it's overwritten with $cc in your cases?


With the line
: ${as_default:=$cc}
it only sets as_default to $cc if $as_default is empty.



---
configure | 16 
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index 12b41cde1c..d3b665f6f9 100755
--- a/configure
+++ b/configure
@@ -4271,14 +4271,6 @@ case "$toolchain" in
ld_default="$source_path/compat/windows/mslink"
nm_default="dumpbin.exe -symbols"
ar_default="lib.exe"
-case "$arch" in
-aarch64|arm64)
-as_default="armasm64.exe"
-;;
-arm*)
-as_default="armasm.exe"
-;;
-esac
target_os_default="win32"
# Use a relative path for TMPDIR. This makes sure all the
# ffconf temp files are written with a relative path, avoiding
@@ -4720,6 +4712,14 @@ probe_cc(){
_ld_path='-libpath:'
elif $_cc -nologo- 2>&1 | grep -q Microsoft || { $_cc -v 2>&1 | grep -q clang && $_cc 
-? > /dev/null 2>&1; }; then
_type=msvc
+case "$arch" in
+aarch64|arm64)
+as_default="armasm64.exe"
+;;
+arm*)
+as_default="armasm.exe"
+;;
+esac
if $_cc -nologo- 2>&1 | grep -q Microsoft; then


You can't really do that here. Probe_cc only should set the existing set 
of _type/_ident/_ldflags/_cflags* etc variables, which are picked up by 
the caller of probe_cc. probe_cc is called separately for both host and 
target compilers, so if e.g. cross compiling, with MSVC as host compiler, 
with a different compiler for the target, this wouldn't do the right 
thing.


// Martin
___
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] configure: Set MSVC as_default later.

2021-01-15 Thread Reimar . Doeffinger
From: Reimar Döffinger 

It would get immediately overridden to $cc, which in case
of gas-preprocessor missing would result in it trying
to use cl.exe for asm files instead of erroring out.
This is because cl.exe does not fail but just print a warning
when it is given a file it does not know what to do with it...
---
 configure | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index 12b41cde1c..d3b665f6f9 100755
--- a/configure
+++ b/configure
@@ -4271,14 +4271,6 @@ case "$toolchain" in
 ld_default="$source_path/compat/windows/mslink"
 nm_default="dumpbin.exe -symbols"
 ar_default="lib.exe"
-case "$arch" in
-aarch64|arm64)
-as_default="armasm64.exe"
-;;
-arm*)
-as_default="armasm.exe"
-;;
-esac
 target_os_default="win32"
 # Use a relative path for TMPDIR. This makes sure all the
 # ffconf temp files are written with a relative path, avoiding
@@ -4720,6 +4712,14 @@ probe_cc(){
 _ld_path='-libpath:'
 elif $_cc -nologo- 2>&1 | grep -q Microsoft || { $_cc -v 2>&1 | grep -q 
clang && $_cc -? > /dev/null 2>&1; }; then
 _type=msvc
+case "$arch" in
+aarch64|arm64)
+as_default="armasm64.exe"
+;;
+arm*)
+as_default="armasm.exe"
+;;
+esac
 if $_cc -nologo- 2>&1 | grep -q Microsoft; then
 _ident=$($_cc 2>&1 | head -n1 | tr -d '\r')
 else
-- 
2.24.3 (Apple Git-128)

___
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] libswscale/aarch64/hscale.S: Support more bit-depth variants.

2021-01-15 Thread Reimar Döffinger


> On 15 Jan 2021, at 22:10, Martin Storsjö  wrote:
> 
> On Mon, 11 Jan 2021, reimar.doeffin...@gmx.de wrote:
> 
>> From: Reimar Döffinger 
>> 
>> Trivially expand hscale assembler to support > 8 bit formats
>> both for input and output.
>> 16-bit input is not supported as I am not certain how to
>> get sufficient test coverage.
>> ---
>> libswscale/aarch64/hscale.S  | 53 ++--
>> libswscale/aarch64/swscale.c | 49 +++--
>> 2 files changed, 85 insertions(+), 17 deletions(-)
>> 
>> diff --git a/libswscale/aarch64/hscale.S b/libswscale/aarch64/hscale.S
>> index af55ffe2b7..3b42d39dac 100644
>> --- a/libswscale/aarch64/hscale.S
>> +++ b/libswscale/aarch64/hscale.S
>> @@ -20,7 +20,11 @@
>> #include "libavutil/aarch64/asm.S"
>> -function ff_hscale_8_to_15_neon, export=1
>> +.macro hscale srcbits, dstbits, ldt, lds, c
>> +function ff_hscale_\srcbits\()_to_\dstbits\()_neon, export=1
>> +.if \dstbits >= 16
>> +moviv20.4S, #(0x1 << (\dstbits - 16)), msl #16
>> +.endif
>>sbfiz   x7, x6, #1, #32   // filterSize*2 (*2 
>> because int16)
>> 1:  ldr w8, [x5], #4 // filterPos[idx]
>>ldr w0, [x5], #4  // filterPos[idx + 1]
>> @@ -34,30 +38,30 @@ function ff_hscale_8_to_15_neon, export=1
>>moviv1.2D, #0 // val sum part 2 (for 
>> dst[1])
>>moviv2.2D, #0 // val sum part 3 (for 
>> dst[2])
>>moviv3.2D, #0 // val sum part 4 (for 
>> dst[3])
>> -add x17, x3, w8, UXTW   // srcp + filterPos[0]
>> -add x8,  x3, w0, UXTW   // srcp + filterPos[1]
>> -add x0, x3, w11, UXTW   // srcp + filterPos[2]
>> -add x11, x3, w9, UXTW   // srcp + filterPos[3]
>> +add x17, x3, w8, UXTW #!!(\srcbits > 8) // srcp + 
>> filterPos[0]
>> +add x8,  x3, w0, UXTW #!!(\srcbits > 8) // srcp + 
>> filterPos[1]
>> +add x0, x3, w11, UXTW #!!(\srcbits > 8) // srcp + 
>> filterPos[2]
>> +add x11, x3, w9, UXTW #!!(\srcbits > 8) // srcp + 
>> filterPos[3]
> 
> This construct breaks with llvm's assembler and armasm64 - they don't 
> evaluate !! here, ending up with errors like these:
> 
> :19:31: error: expected integer shift amount
>add x8, x3, w0, UXTW #!!(8 > 8)
> 
> libswscale\aarch64\hscale.o.asm(3093) : error A2007: wrong operand type for 
> :LNOT:
>add x17, x3, w8, UXTW #!!0
> 
> While less elegant, I guess this can be handled easily by adding a macro 
> parameter that represents the evaluated value of \srcbits > 8.

It’s actually easier. I just need 0 or 1 here, the thing I was missing
that caused me to add the !! is that a true condition does not evaluate
to 1 but to -1, so (\srcbits <= 8) + 1 works with both.


>>mov w15, w6   // filterSize counter
>> -2:  ld1 {v4.8B}, [x17], #8  // srcp[filterPos[0] + 
>> {0..7}]
>> +2:  ld1 {v4.\ldt}, [x17], \lds // srcp[filterPos[0] + 
>> {0..7}]
>>ld1 {v5.8H}, [x16], #16   // load 8x16-bit filter 
>> values, part 1
>> -ld1 {v6.8B}, [x8], #8   // srcp[filterPos[1] + 
>> {0..7}]
>> +ld1 {v6.\ldt}, [x8], \lds   // srcp[filterPos[1] + 
>> {0..7}]
>>ld1 {v7.8H}, [x12], #16   // load 8x16-bit at 
>> filter+filterSize
>> -uxtlv4.8H, v4.8B// unpack part 1 to 
>> 16-bit
>> +\c\cuxtlv4.8H, v4.8B// unpack part 1 to 
>> 16-bit
> 
> With gas-preprocessor and armasm64, // isn't considered a comment char by 
> armasm64, only by the C preprocessor invoked by gas-preprocessor, so it 
> doesn't strip out these lines properly. I guess one could add more code to 
> gas-preprocessor to handle that, but that's probably a bit overkill...

That is a whole another fun topic, I’ll be sending patches related to 
gas-preprocessor.
Admittedly might consider some of the issues my fault for not cross-compiling 
and also preferring WSL over msys2 or such...
And then I might get around to addressing the rest.
___
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] libswscale/aarch64/hscale.S: Support more bit-depth variants.

2021-01-15 Thread Martin Storsjö

On Mon, 11 Jan 2021, reimar.doeffin...@gmx.de wrote:


From: Reimar Döffinger 

Trivially expand hscale assembler to support > 8 bit formats
both for input and output.
16-bit input is not supported as I am not certain how to
get sufficient test coverage.
---
libswscale/aarch64/hscale.S  | 53 ++--
libswscale/aarch64/swscale.c | 49 +++--
2 files changed, 85 insertions(+), 17 deletions(-)

diff --git a/libswscale/aarch64/hscale.S b/libswscale/aarch64/hscale.S
index af55ffe2b7..3b42d39dac 100644
--- a/libswscale/aarch64/hscale.S
+++ b/libswscale/aarch64/hscale.S
@@ -20,7 +20,11 @@

#include "libavutil/aarch64/asm.S"

-function ff_hscale_8_to_15_neon, export=1
+.macro hscale srcbits, dstbits, ldt, lds, c
+function ff_hscale_\srcbits\()_to_\dstbits\()_neon, export=1
+.if \dstbits >= 16
+moviv20.4S, #(0x1 << (\dstbits - 16)), msl #16
+.endif
sbfiz   x7, x6, #1, #32 // filterSize*2 (*2 
because int16)
1:  ldr w8, [x5], #4// filterPos[idx]
ldr w0, [x5], #4// filterPos[idx + 1]
@@ -34,30 +38,30 @@ function ff_hscale_8_to_15_neon, export=1
moviv1.2D, #0   // val sum part 2 (for 
dst[1])
moviv2.2D, #0   // val sum part 3 (for 
dst[2])
moviv3.2D, #0   // val sum part 4 (for 
dst[3])
-add x17, x3, w8, UXTW   // srcp + filterPos[0]
-add x8,  x3, w0, UXTW   // srcp + filterPos[1]
-add x0, x3, w11, UXTW   // srcp + filterPos[2]
-add x11, x3, w9, UXTW   // srcp + filterPos[3]
+add x17, x3, w8, UXTW #!!(\srcbits > 8) // srcp + 
filterPos[0]
+add x8,  x3, w0, UXTW #!!(\srcbits > 8) // srcp + 
filterPos[1]
+add x0, x3, w11, UXTW #!!(\srcbits > 8) // srcp + 
filterPos[2]
+add x11, x3, w9, UXTW #!!(\srcbits > 8) // srcp + 
filterPos[3]


This construct breaks with llvm's assembler and armasm64 - they don't 
evaluate !! here, ending up with errors like these:


:19:31: error: expected integer shift amount
add x8, x3, w0, UXTW #!!(8 > 8)

libswscale\aarch64\hscale.o.asm(3093) 
: error A2007: wrong operand type for :LNOT:

add x17, x3, w8, UXTW #!!0

While less elegant, I guess this can be handled easily by adding a macro 
parameter that represents the evaluated value of \srcbits > 8.




mov w15, w6 // filterSize counter
-2:  ld1 {v4.8B}, [x17], #8  // srcp[filterPos[0] + 
{0..7}]
+2:  ld1 {v4.\ldt}, [x17], \lds  // srcp[filterPos[0] + 
{0..7}]
ld1 {v5.8H}, [x16], #16 // load 8x16-bit filter 
values, part 1
-ld1 {v6.8B}, [x8], #8   // srcp[filterPos[1] + 
{0..7}]
+ld1 {v6.\ldt}, [x8], \lds   // srcp[filterPos[1] + 
{0..7}]
ld1 {v7.8H}, [x12], #16 // load 8x16-bit at 
filter+filterSize
-uxtlv4.8H, v4.8B// unpack part 1 to 
16-bit
+\c\cuxtlv4.8H, v4.8B// unpack part 1 to 
16-bit


With gas-preprocessor and armasm64, // isn't considered a comment char by 
armasm64, only by the C preprocessor invoked by gas-preprocessor, so it 
doesn't strip out these lines properly. I guess one could add more code to 
gas-preprocessor to handle that, but that's probably a bit overkill...


Adding .if .endif around these instances isn't entirely elegant, but you 
can also make e.g. a macro uxtl_if, which takes a third parameter which is 
a predicate for whether the instruction should be included or not.



smlal   v0.4S, v4.4H, v5.4H // v0 accumulates 
srcp[filterPos[0] + {0..3}] * filter[{0..3}]
smlal2  v0.4S, v4.8H, v5.8H // v0 accumulates 
srcp[filterPos[0] + {4..7}] * filter[{4..7}]
-ld1 {v16.8B}, [x0], #8  // srcp[filterPos[2] + 
{0..7}]
+ld1 {v16.\ldt}, [x0], \lds  // srcp[filterPos[2] + 
{0..7}]


LLVM's assembler had a bug regarding passing parameters like "8h" as a 
parameter to a macro, which was only fixed in LLVM 8, see 
https://bugs.llvm.org/show_bug.cgi?id=32973.


That bug is easy to avoid by moving the dot into the macro argument, i.e. 
making this "ld1 {v16\ldt}, ..." and passing ".8h" as macro argument.


Additionally - we do have a checkasm test for this function, but not for 
these bitdepth combinations. It'd be great to extend the test to test 
these combinations as well - I'd prefer to not add much more assembly 
without a corresponding checkasm test.


// Martin

Re: [FFmpeg-devel] [PATCH v4 3/3] avformat/mxfenc: prefer to use the configured metadta

2021-01-15 Thread Marton Balint



On Fri, 15 Jan 2021, Tomas Härdin wrote:


lör 2021-01-09 klockan 13:07 +0800 skrev lance.lmw...@gmail.com:

From: Limin Wang 

The metadata company_name, product_name, product_version from input
file will be deleted to avoid overwriting information
Please to test with below command:
./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf
and
./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy \
-metadata company_name="xxx" \
-metadata product_name="xxx" \
-metadata product_version="xxx" \
out.mxf

Signed-off-by: Limin Wang 
---
 fftools/ffmpeg_opt.c |  3 +++
 libavformat/mxfenc.c | 12 
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index c295514..493763b 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -2650,6 +2650,9 @@ loop_end:
 if(o->recording_time != INT64_MAX)
 av_dict_set(&oc->metadata, "duration", NULL, 0);
 av_dict_set(&oc->metadata, "creation_time", NULL, 0);
+av_dict_set(&oc->metadata, "company_name", NULL, 0);
+av_dict_set(&oc->metadata, "product_name", NULL, 0);
+av_dict_set(&oc->metadata, "product_version", NULL, 0);
 }
 if (!o->metadata_streams_manual)
 for (i = of->ost_index; i < nb_output_streams; i++) {
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index d8678c9..5244211 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -722,16 +722,20 @@ static void mxf_write_identification(AVFormatContext *s)
 {
 MXFContext *mxf = s->priv_data;
 AVIOContext *pb = s->pb;
-const char *company = "FFmpeg";
-const char *product = s->oformat != &ff_mxf_opatom_muxer ? "OP1a Muxer" : 
"OPAtom Muxer";
-const char *version;
+AVDictionaryEntry *com_entry =  av_dict_get(s->metadata, "company_name", 
NULL, 0);
+AVDictionaryEntry *product_entry =  av_dict_get(s->metadata, 
"product_name", NULL, 0);
+AVDictionaryEntry *version_entry =  av_dict_get(s->metadata, 
"product_version", NULL, 0);
+const char *company = com_entry ? com_entry->value : "FFmpeg";
+const char *product = product_entry ? product_entry->value : s->oformat != 
&ff_mxf_opatom_muxer ? "OP1a Muxer" : "OPAtom Muxer";
+const char *version = NULL;
+const char *product_version = version_entry ? version_entry->value : 
AV_STRINGIFY(LIBAVFORMAT_VERSION);
 int length;

 mxf_write_metadata_key(pb, 0x013000);
 PRINT_KEY(s, "identification key", pb->buf_ptr - 16);

 version = s->flags & AVFMT_FLAG_BITEXACT ?
-"0.0.0" : AV_STRINGIFY(LIBAVFORMAT_VERSION);
+"0.0.0" : product_version;


Again, why? If you have a company that maintains a fork of FFmpeg then
compile that info in here instead. Compare with FFmbc which always puts
"FFmbc" as CompanyName.


And how can a product based on libavformat set the company name, product 
name and product version? It seems a valid use case for me that these are 
overridable. Also note that this product version is only the "user 
friendly" version string, for the numeric version still 
LIBAVFORMAT_VERSION values are used.


Regards,
Marton
___
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/7] avutil/parseutils: Check sign in av_parse_time()

2021-01-15 Thread Marton Balint



On Thu, 14 Jan 2021, Michael Niedermayer wrote:


Fixes: signed integer overflow: -9223372053736 * 100 cannot be represented 
in type 'long'
Fixes: 
26910/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-6607924558430208

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
libavutil/parseutils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index 167e822648..6161f4ac95 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -736,7 +736,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, 
int duration)
if (*q)
return AVERROR(EINVAL);

-if (INT64_MAX / suffix < t)
+if (t < 0 || INT64_MAX / suffix < t)


This does not look right, because a negative t can mean a date before 
1970.


Regards,
Marton


return AVERROR(ERANGE);
t *= suffix;
if (INT64_MAX - microseconds < t)
--
2.17.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 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] avformat/hls: change sequence number type to int64_t

2021-01-15 Thread Chad Fraleigh


On 1/15/2021 3:41 AM, Zhao Zhili wrote:

Fix atoi() overflow for large EXT-X-MEDIA-SEQUENCE.

The spec says the type of sequence number is uint64_t. Use int64_t
here since current implementation requires it to be signed integer,
and hlsenc use int64_t too.
---
  libavformat/hls.c | 49 ---
  1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 619e4800de..56f1103a11 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -112,13 +112,13 @@ struct playlist {


...


  if (is_http && !in && c->http_persistent && c->playlist_pb) {
  in = c->playlist_pb;
@@ -811,7 +811,7 @@ static int parse_playlist(HLSContext *c, const char *url,
  ret = ensure_playlist(c, &pls, url);
  if (ret < 0)
  goto fail;
-pls->start_seq_no = atoi(ptr);
+pls->start_seq_no = strtoll(ptr, NULL, 10);


Would it be better it use strtoull() to correctly parse the spec'd 
value, then check if it is in int64_t range before assigning the 
implementation's sequence number (and handling out of range values 
appropriately)?




  } else if (av_strstart(line, "#EXT-X-PLAYLIST-TYPE:", &ptr)) {


...
___
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: add estdif video filter

2021-01-15 Thread Paul B Mahol
Will apply soon!
___
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] avformat/hlsenc: EXT-X-I-FRAMES-ONLY requires version 4 or higher

2021-01-15 Thread Zhao Zhili


> On Jan 16, 2021, at 12:47 AM, Zhao Zhili  wrote:
> 
> ---
> libavformat/hlsenc.c | 4 
> 1 file changed, 4 insertions(+)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index cafe0e8c69..d376fc6f08 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1564,6 +1564,10 @@ static int hls_window(AVFormatContext *s, int last, 
> VariantStream *vs)
> sequence = 0;
> }
> 
> +if (hls->flags & HLS_I_FRAMES_ONLY) {
> +hls->version = 4;
> +}
> +
> if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
> hls->version = 6;
> }

Current implementation only takes HLS_SINGLE_FILE mode into consideration.
I_FRMAMES_ONLY should works without SINGLE_FILE mode by dropping non-key
frame packets. This patch doesn't consider that issue.

> -- 
> 2.27.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 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/hlsenc: EXT-X-I-FRAMES-ONLY requires version 4 or higher

2021-01-15 Thread Zhao Zhili
---
 libavformat/hlsenc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index cafe0e8c69..d376fc6f08 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1564,6 +1564,10 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 sequence = 0;
 }
 
+if (hls->flags & HLS_I_FRAMES_ONLY) {
+hls->version = 4;
+}
+
 if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
 hls->version = 6;
 }
-- 
2.27.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] avformat/webvttdec: Fix WebVTT decoder truncating files at first STYLE block

2021-01-15 Thread Moritz Barsnick
On Tue, Jan 12, 2021 at 17:40:06 +, Dave Evans wrote:
> Hijacking with related, similar patch from a few months ago:
> https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=2538

... which even includes a fate test, which is what I was about to
request from the newly submitted patch.

Cheers,
Moritz
___
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 5/5] avformat/hlsenc: use AV_OPT_TYPE_DURATION

2021-01-15 Thread Moritz Barsnick
On Wed, Jan 06, 2021 at 23:35:31 +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
>
> Signed-off-by: Limin Wang 
> ---
>  doc/muxers.texi  |  4 ++--
>  libavformat/hlsenc.c | 18 +-
>  2 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 8e12aca..044c16b 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -609,13 +609,13 @@ segmentation.
>  This muxer supports the following options:
>
>  @table @option
> -@item hls_init_time @var{seconds}
> +@item hls_init_time @var{duration}
>  Set the initial target segment length in seconds. Default value is @var{0}.
>  Segment will be cut on the next key frame after this time has passed on the 
> first m3u8 list.
>  After the initial playlist is filled @command{ffmpeg} will cut segments
>  at duration equal to @code{hls_time}

AV_OPT_TYPE_DURATION is not strictly seconds. It can use other
syntaxes. You could refer to the appropriate section:

> see @ref{time duration syntax,,the Time duration section in the 
> ffmpeg-utils(1) manual,ffmpeg-utils}.


>  Set the target segment length in seconds. Default value is 2.

Ditto.

> -{"hls_time",  "set segment length in seconds",   
> OFFSET(time),AV_OPT_TYPE_FLOAT,  {.dbl = 2}, 0, FLT_MAX, E},
> -{"hls_init_time", "set segment length in seconds at init list",  
>  OFFSET(init_time),AV_OPT_TYPE_FLOAT,  {.dbl = 0}, 0, FLT_MAX, E},
> +{"hls_time",  "set segment length in seconds",   
> OFFSET(time),AV_OPT_TYPE_DURATION,  {.i64 = 200}, 0, INT64_MAX, 
> E},
> +{"hls_init_time", "set segment length in seconds at init list",  
>  OFFSET(init_time),AV_OPT_TYPE_DURATION,  {.i64 = 0}, 0, INT64_MAX, 
> E},

Ditto, just "set segment length".

Cheers,
Moritz
___
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] avformat/movenc: Remove dts delay from duration.

2021-01-15 Thread Martin Storsjö

Hi Josh,

On Tue, 22 Dec 2020, Josh Allmann wrote:


Thank you for taking the time to look into this! Tested with your
alternative patch and it does seem to be an improvement. I was able to
find a case where it didn't seem to do the correct thing (described
below), but this is not a regression; master doesn't do the correct
thing, and neither does my patch. I haven't looked much at what the
code is doing beyond running these tests, but could find some time to
dig in early 2021 if it's not fixed by then.

First, a working sample with pts > 0 . This has a 600-frame GOP (20s @
30fps) to show that cutting mid-GOP works correctly.

https://trac.ffmpeg.org/raw-attachment/ticket/9028/gop-600.mp4

Command to generate a clipped sample with edit list. This spans two GOPs.

ffmpeg -ss 17.319 -i gop-600.mp4 -t 5 -c copy -movflags
+faststart -y cut-mp4-600.mp4

Things look good with ffprobe, and playback works well with ffplay; it
starts right around the 17-second mark. The sample is a timecode
pattern so it is easy to verify.

If the sample is a mpegts (rather than a mp4, all other things
identical), then things are a bit odd:

https://trac.ffmpeg.org/raw-attachment/ticket/9028/gop-600.ts

Cut the sample with:

ffmpeg -ss 17.319 -i gop-600.ts -t 5 -c copy -movflags
+faststart -y cut-ts-600.mp4

Probing gives the correct duration with a start time of 2.683.
However, playback starts at the 20 second mark. (Same timecode
pattern, so easy to visually verify.) Incidentally, it seems that 20 -
2.683 = 17.316, which is the original cut position.

ffprobe cut-ts-600.mp4 gives "Duration: 00:00:05.12, start: 2.683000"

The trac ticket has a bit more info (including commands for how to
generate the samples) but this is the gist of it.


I think this issue isn't related to the mov muxer at least, but is more 
related to how stream copy works at the ffmpeg.c level, and/or how the 
seeking is done.


As that's unrelated, and I haven't heard any objections to my version of 
the patch, I think I'll go ahead and land it soon then.


// Martin

___
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] avformat/hls: change sequence number type to int64_t

2021-01-15 Thread zhilizhao(赵志立)


> On Jan 15, 2021, at 7:43 PM, Nicolas George  wrote:
> 
> Zhao Zhili (12021-01-15):
>> -AV_WB32(seg->iv + 12, seq);
>> +AV_WB32(seg->iv + 8, seq);
> 
> AV_WB64?

Good catch, thanks!

Version two: http://ffmpeg.org/pipermail/ffmpeg-devel/2021-January/274693.html

> 
> Regards,
> 
> -- 
>  Nicolas George
> ___
> 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 v2] avformat/hls: change sequence number type to int64_t

2021-01-15 Thread Zhao Zhili
Fix atoi() overflow for large EXT-X-MEDIA-SEQUENCE.

The spec says the type of sequence number is uint64_t. Use int64_t
here since current implementation requires it to be signed integer,
and hlsenc use int64_t too.
---
v2:
AV_WB32 -> AV_WB64

 libavformat/hls.c | 49 ---
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 619e4800de..ddf914621f 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -112,13 +112,13 @@ struct playlist {
 int finished;
 enum PlaylistType type;
 int64_t target_duration;
-int start_seq_no;
+int64_t start_seq_no;
 int n_segments;
 struct segment **segments;
 int needed;
 int broken;
-int cur_seq_no;
-int last_seq_no;
+int64_t cur_seq_no;
+int64_t last_seq_no;
 int m3u8_hold_counters;
 int64_t cur_seg_offset;
 int64_t last_load_time;
@@ -199,7 +199,7 @@ typedef struct HLSContext {
 int n_renditions;
 struct rendition **renditions;
 
-int cur_seq_no;
+int64_t cur_seq_no;
 int m3u8_hold_counters;
 int live_start_index;
 int first_packet;
@@ -722,7 +722,7 @@ static int parse_playlist(HLSContext *c, const char *url,
 int is_http = av_strstart(url, "http", NULL);
 struct segment **prev_segments = NULL;
 int prev_n_segments = 0;
-int prev_start_seq_no = -1;
+int64_t prev_start_seq_no = -1;
 
 if (is_http && !in && c->http_persistent && c->playlist_pb) {
 in = c->playlist_pb;
@@ -811,7 +811,7 @@ static int parse_playlist(HLSContext *c, const char *url,
 ret = ensure_playlist(c, &pls, url);
 if (ret < 0)
 goto fail;
-pls->start_seq_no = atoi(ptr);
+pls->start_seq_no = strtoll(ptr, NULL, 10);
 } else if (av_strstart(line, "#EXT-X-PLAYLIST-TYPE:", &ptr)) {
 ret = ensure_playlist(c, &pls, url);
 if (ret < 0)
@@ -832,9 +832,9 @@ static int parse_playlist(HLSContext *c, const char *url,
 if (has_iv) {
 memcpy(cur_init_section->iv, iv, sizeof(iv));
 } else {
-int seq = pls->start_seq_no + pls->n_segments;
+int64_t seq = pls->start_seq_no + pls->n_segments;
 memset(cur_init_section->iv, 0, sizeof(cur_init_section->iv));
-AV_WB32(cur_init_section->iv + 12, seq);
+AV_WB64(cur_init_section->iv + 8, seq);
 }
 
 if (key_type != KEY_NONE) {
@@ -889,9 +889,9 @@ static int parse_playlist(HLSContext *c, const char *url,
 if (has_iv) {
 memcpy(seg->iv, iv, sizeof(iv));
 } else {
-int seq = pls->start_seq_no + pls->n_segments;
+int64_t seq = pls->start_seq_no + pls->n_segments;
 memset(seg->iv, 0, sizeof(seg->iv));
-AV_WB32(seg->iv + 12, seq);
+AV_WB64(seg->iv + 8, seq);
 }
 
 if (key_type != KEY_NONE) {
@@ -954,16 +954,17 @@ static int parse_playlist(HLSContext *c, const char *url,
 if (prev_segments) {
 if (pls->start_seq_no > prev_start_seq_no && c->first_timestamp != 
AV_NOPTS_VALUE) {
 int64_t prev_timestamp = c->first_timestamp;
-int i, diff = pls->start_seq_no - prev_start_seq_no;
+int i;
+int64_t diff = pls->start_seq_no - prev_start_seq_no;
 for (i = 0; i < prev_n_segments && i < diff; i++) {
 c->first_timestamp += prev_segments[i]->duration;
 }
-av_log(c->ctx, AV_LOG_DEBUG, "Media sequence change (%d -> %d)"
+av_log(c->ctx, AV_LOG_DEBUG, "Media sequence change (%"PRId64" -> 
%"PRId64")"
" reflected in first_timestamp: %"PRId64" -> %"PRId64"\n",
prev_start_seq_no, pls->start_seq_no,
prev_timestamp, c->first_timestamp);
 } else if (pls->start_seq_no < prev_start_seq_no) {
-av_log(c->ctx, AV_LOG_WARNING, "Media sequence changed 
unexpectedly: %d -> %d\n",
+av_log(c->ctx, AV_LOG_WARNING, "Media sequence changed 
unexpectedly: %"PRId64" -> %"PRId64"\n",
prev_start_seq_no, pls->start_seq_no);
 }
 free_segment_dynarray(prev_segments, prev_n_segments);
@@ -991,7 +992,7 @@ static struct segment *current_segment(struct playlist *pls)
 
 static struct segment *next_segment(struct playlist *pls)
 {
-int n = pls->cur_seq_no - pls->start_seq_no + 1;
+int64_t n = pls->cur_seq_no - pls->start_seq_no + 1;
 if (n >= pls->n_segments)
 return NULL;
 return pls->segments[n];
@@ -1457,7 +1458,7 @@ reload:
 }
 if (v->cur_seq_no < v->start_seq_no) {
 av_log(v->parent, AV_LOG_WARNING,
-   "skipping %d segments ahead, expired from playlists\n",
+   "sk

Re: [FFmpeg-devel] [PATCH 2/3] avformat/dashdec: fix code style in is_common_init_section_exist

2021-01-15 Thread Steven Liu


> 2021年1月15日 下午8:02,Moritz Barsnick  写道:
> 
> On Tue, Jan 12, 2021 at 21:20:03 +0800, liuqi05 wrote:
>> -if (av_strcasecmp(pls[i]->init_section->url, url) || 
>> pls[i]->init_section->url_offset != url_offset || pls[i]->init_section->size 
>> != size) {
>> +if (av_strcasecmp(pls[i]->init_section->url, url) ||
>> +  pls[i]->init_section->url_offset != url_offset ||
>> +  pls[i]->init_section->size != size) {
> 
> Good idea, but the indentation is incorrect. The subsequent lines are
> not arguments to av_strcasecmp(), but further clauses for if().
> 
> Also, you should make this change the first commit of your series which
Hi Moritz,

Do you mean this modify should be merged into the first patch?

> would make what is now your first commit, including another cosmetic
> change (added space), much more compact and easier to read.
> 
> Cheers,
> Moritz
> ___
> 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".

Thanks

Steven Liu



___
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/dashdec: fix code style in is_common_init_section_exist

2021-01-15 Thread Moritz Barsnick
On Tue, Jan 12, 2021 at 21:20:03 +0800, liuqi05 wrote:
> -if (av_strcasecmp(pls[i]->init_section->url, url) || 
> pls[i]->init_section->url_offset != url_offset || pls[i]->init_section->size 
> != size) {
> +if (av_strcasecmp(pls[i]->init_section->url, url) ||
> +  pls[i]->init_section->url_offset != url_offset ||
> +  pls[i]->init_section->size != size) {

Good idea, but the indentation is incorrect. The subsequent lines are
not arguments to av_strcasecmp(), but further clauses for if().

Also, you should make this change the first commit of your series which
would make what is now your first commit, including another cosmetic
change (added space), much more compact and easier to read.

Cheers,
Moritz
___
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] avformat/hls: change sequence number type to int64_t

2021-01-15 Thread Nicolas George
Zhao Zhili (12021-01-15):
> -AV_WB32(seg->iv + 12, seq);
> +AV_WB32(seg->iv + 8, seq);

AV_WB64?

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] avformat/hls: change sequence number type to int64_t

2021-01-15 Thread Zhao Zhili
Fix atoi() overflow for large EXT-X-MEDIA-SEQUENCE.

The spec says the type of sequence number is uint64_t. Use int64_t
here since current implementation requires it to be signed integer,
and hlsenc use int64_t too.
---
 libavformat/hls.c | 49 ---
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 619e4800de..56f1103a11 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -112,13 +112,13 @@ struct playlist {
 int finished;
 enum PlaylistType type;
 int64_t target_duration;
-int start_seq_no;
+int64_t start_seq_no;
 int n_segments;
 struct segment **segments;
 int needed;
 int broken;
-int cur_seq_no;
-int last_seq_no;
+int64_t cur_seq_no;
+int64_t last_seq_no;
 int m3u8_hold_counters;
 int64_t cur_seg_offset;
 int64_t last_load_time;
@@ -199,7 +199,7 @@ typedef struct HLSContext {
 int n_renditions;
 struct rendition **renditions;
 
-int cur_seq_no;
+int64_t cur_seq_no;
 int m3u8_hold_counters;
 int live_start_index;
 int first_packet;
@@ -722,7 +722,7 @@ static int parse_playlist(HLSContext *c, const char *url,
 int is_http = av_strstart(url, "http", NULL);
 struct segment **prev_segments = NULL;
 int prev_n_segments = 0;
-int prev_start_seq_no = -1;
+int64_t prev_start_seq_no = -1;
 
 if (is_http && !in && c->http_persistent && c->playlist_pb) {
 in = c->playlist_pb;
@@ -811,7 +811,7 @@ static int parse_playlist(HLSContext *c, const char *url,
 ret = ensure_playlist(c, &pls, url);
 if (ret < 0)
 goto fail;
-pls->start_seq_no = atoi(ptr);
+pls->start_seq_no = strtoll(ptr, NULL, 10);
 } else if (av_strstart(line, "#EXT-X-PLAYLIST-TYPE:", &ptr)) {
 ret = ensure_playlist(c, &pls, url);
 if (ret < 0)
@@ -832,9 +832,9 @@ static int parse_playlist(HLSContext *c, const char *url,
 if (has_iv) {
 memcpy(cur_init_section->iv, iv, sizeof(iv));
 } else {
-int seq = pls->start_seq_no + pls->n_segments;
+int64_t seq = pls->start_seq_no + pls->n_segments;
 memset(cur_init_section->iv, 0, sizeof(cur_init_section->iv));
-AV_WB32(cur_init_section->iv + 12, seq);
+AV_WB64(cur_init_section->iv + 8, seq);
 }
 
 if (key_type != KEY_NONE) {
@@ -889,9 +889,9 @@ static int parse_playlist(HLSContext *c, const char *url,
 if (has_iv) {
 memcpy(seg->iv, iv, sizeof(iv));
 } else {
-int seq = pls->start_seq_no + pls->n_segments;
+int64_t seq = pls->start_seq_no + pls->n_segments;
 memset(seg->iv, 0, sizeof(seg->iv));
-AV_WB32(seg->iv + 12, seq);
+AV_WB32(seg->iv + 8, seq);
 }
 
 if (key_type != KEY_NONE) {
@@ -954,16 +954,17 @@ static int parse_playlist(HLSContext *c, const char *url,
 if (prev_segments) {
 if (pls->start_seq_no > prev_start_seq_no && c->first_timestamp != 
AV_NOPTS_VALUE) {
 int64_t prev_timestamp = c->first_timestamp;
-int i, diff = pls->start_seq_no - prev_start_seq_no;
+int i;
+int64_t diff = pls->start_seq_no - prev_start_seq_no;
 for (i = 0; i < prev_n_segments && i < diff; i++) {
 c->first_timestamp += prev_segments[i]->duration;
 }
-av_log(c->ctx, AV_LOG_DEBUG, "Media sequence change (%d -> %d)"
+av_log(c->ctx, AV_LOG_DEBUG, "Media sequence change (%"PRId64" -> 
%"PRId64")"
" reflected in first_timestamp: %"PRId64" -> %"PRId64"\n",
prev_start_seq_no, pls->start_seq_no,
prev_timestamp, c->first_timestamp);
 } else if (pls->start_seq_no < prev_start_seq_no) {
-av_log(c->ctx, AV_LOG_WARNING, "Media sequence changed 
unexpectedly: %d -> %d\n",
+av_log(c->ctx, AV_LOG_WARNING, "Media sequence changed 
unexpectedly: %"PRId64" -> %"PRId64"\n",
prev_start_seq_no, pls->start_seq_no);
 }
 free_segment_dynarray(prev_segments, prev_n_segments);
@@ -991,7 +992,7 @@ static struct segment *current_segment(struct playlist *pls)
 
 static struct segment *next_segment(struct playlist *pls)
 {
-int n = pls->cur_seq_no - pls->start_seq_no + 1;
+int64_t n = pls->cur_seq_no - pls->start_seq_no + 1;
 if (n >= pls->n_segments)
 return NULL;
 return pls->segments[n];
@@ -1457,7 +1458,7 @@ reload:
 }
 if (v->cur_seq_no < v->start_seq_no) {
 av_log(v->parent, AV_LOG_WARNING,
-   "skipping %d segments ahead, expired from playlists\n",
+   "skipping %"PRId64" segment

Re: [FFmpeg-devel] [PATCH V2] libavfilter/dnn: add batch mode for async execution

2021-01-15 Thread Guo, Yejun


> -Original Message-
> From: Steven Liu 
> Sent: 2021年1月15日 11:34
> To: FFmpeg development discussions and patches 
> Cc: Steven Liu ; Guo, Yejun 
> Subject: Re: [FFmpeg-devel] [PATCH V2] libavfilter/dnn: add batch mode for
> async execution
> 
> 
> 
> > 2021年1月10日 下午9:16,Guo, Yejun  写道:
> >
> > the default number of batch_size is 1
> >
> > Signed-off-by: Xie, Lin 
> > Signed-off-by: Wu Zhiwen 
> > Signed-off-by: Guo, Yejun 
> > ---
> > libavfilter/dnn/dnn_backend_openvino.c | 187 -
> > libavfilter/dnn/dnn_backend_openvino.h |   1 +
> > libavfilter/dnn/dnn_interface.c|   1 +
> > libavfilter/dnn_interface.h|   2 +
> > libavfilter/vf_dnn_processing.c|  36 -
> > 5 files changed, 194 insertions(+), 33 deletions(-)
> >
> > diff --git a/libavfilter/dnn/dnn_backend_openvino.c
> > b/libavfilter/dnn/dnn_backend_openvino.c
> > index d27e451eea..5271d1caa5 100644
> > --- a/libavfilter/dnn/dnn_backend_openvino.c
> > +++ b/libavfilter/dnn/dnn_backend_openvino.c
> > @@ -37,6 +37,7 @@
> > typedef struct OVOptions{
> > char *device_type;
> > int nireq;
> > +int batch_size;
> > } OVOptions;
> >
> > typedef struct OVContext {
> > @@ -70,7 +71,8 @@ typedef struct TaskItem {
> >
> > typedef struct RequestItem {
> > ie_infer_request_t *infer_request;
> > -TaskItem *task;
> > +TaskItem **tasks;
> > +int task_count;
> > ie_complete_call_back_t callback;
> > } RequestItem;
> >
> > @@ -83,6 +85,7 @@ typedef struct RequestItem { static const AVOption
> > dnn_openvino_options[] = {
> > { "device", "device to run model", OFFSET(options.device_type),
> AV_OPT_TYPE_STRING, { .str = "CPU" }, 0, 0, FLAGS },
> > { "nireq",  "number of request",   OFFSET(options.nireq),
> AV_OPT_TYPE_INT,{ .i64 = 0 }, 0, INT_MAX, FLAGS },
> > +{ "batch_size",  "batch size per request", OFFSET(options.batch_size),
> AV_OPT_TYPE_INT,{ .i64 = 1 }, 1, 1000, FLAGS},
> > { NULL }
> > };
> >
> > @@ -100,7 +103,19 @@ static DNNDataType
> precision_to_datatype(precision_e precision)
> > }
> > }
> >
> > -static DNNReturnType fill_model_input_ov(OVModel *ov_model, TaskItem
> > *task, RequestItem *request)
> > +static int get_datatype_size(DNNDataType dt) {
> > +switch (dt)
> > +{
> > +case DNN_FLOAT:
> > +return sizeof(float);
> > +default:
> > +av_assert0(!"not supported yet.");
> > +return 1;
> Why don’t try about this way ? :D
> avpriv_request_sample()
> AVERROR_PATCHWELCOME;
thanks, good point, will do it this way.

___
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: Added siti filter

2021-01-15 Thread Boris Baracaldo

Calculate Spatial Info (SI) and Temporal Info (TI) scores for a video, as 
defined
in ITU-T P.910: Subjective video quality assessment methods for multimedia
applications.
---
 Changelog|   1 +
 doc/filters.texi |  25 
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/version.h|   2 +-
 libavfilter/vf_siti.c| 359 +++
 6 files changed, 388 insertions(+), 1 deletion(-)
 create mode 100644 libavfilter/vf_siti.c

diff --git a/Changelog b/Changelog
index dcb80e0ed9..9ca79a12aa 100644
--- a/Changelog
+++ b/Changelog
@@ -55,6 +55,7 @@ version :
 - asuperpass and asuperstop filter
 - shufflepixels filter
 - tmidequalizer filter
+- siti filter


 version 4.3:
diff --git a/doc/filters.texi b/doc/filters.texi
index 813e35c2f9..eb1f23128c 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -18158,6 +18158,31 @@ ffmpeg -i input1.mkv -i input2.mkv -filter_complex 
"[0:v][1:v] signature=nb_inpu

 @end itemize

+@anchor{siti}
+@section siti
+
+Calculate Spatial Info (SI) and Temporal Info (TI) scores for a video, as 
defined
+in ITU-T P.910: Subjective video quality assessment methods for multimedia
+applications. Available PDF at 
@url{https://www.itu.int/rec/T-REC-P.910-199909-S/en }.
+Per frame metrics can be written into a file in csv format.
+
+It accepts the following option:
+
+@table @option
+@item stats_file
+Set the path to the file where per frame SI and TI metrics will be written. If 
no file
+is specified, only summary statistics will be printed to the console.
+@end table
+
+@subsection Examples
+@itemize
+@item
+To calculate SI/TI metrics and store per frame data to stats.csv:
+@example
+ffmpeg -i input.mp4 -vf siti=stats_file='siti.csv' -f null -
+@end example
+@end itemize
+
 @anchor{smartblur}
 @section smartblur

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index ad1046d526..5514536463 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -413,6 +413,7 @@ OBJS-$(CONFIG_SMARTBLUR_FILTER)  += 
vf_smartblur.o
 OBJS-$(CONFIG_SOBEL_FILTER)  += vf_convolution.o
 OBJS-$(CONFIG_SOBEL_OPENCL_FILTER)   += vf_convolution_opencl.o 
opencl.o \
 opencl/convolution.o
+OBJS-$(CONFIG_SITI_FILTER)   += vf_siti.o
 OBJS-$(CONFIG_SPLIT_FILTER)  += split.o
 OBJS-$(CONFIG_SPP_FILTER)+= vf_spp.o qp_table.o
 OBJS-$(CONFIG_SR_FILTER) += vf_sr.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index ce317dfa1c..0aef9fdcef 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -393,6 +393,7 @@ extern AVFilter ff_vf_signature;
 extern AVFilter ff_vf_smartblur;
 extern AVFilter ff_vf_sobel;
 extern AVFilter ff_vf_sobel_opencl;
+extern AVFilter ff_vf_siti;
 extern AVFilter ff_vf_split;
 extern AVFilter ff_vf_spp;
 extern AVFilter ff_vf_sr;
diff --git a/libavfilter/version.h b/libavfilter/version.h
index fbe2ed62b2..2136235e54 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,7 +30,7 @@
 #include "libavutil/version.h"

 #define LIBAVFILTER_VERSION_MAJOR   7
-#define LIBAVFILTER_VERSION_MINOR  95
+#define LIBAVFILTER_VERSION_MINOR  96
 #define LIBAVFILTER_VERSION_MICRO 100


diff --git a/libavfilter/vf_siti.c b/libavfilter/vf_siti.c
new file mode 100644
index 00..e8b6142ae7
--- /dev/null
+++ b/libavfilter/vf_siti.c
@@ -0,0 +1,359 @@
+/*
+ * Copyright (c) 2002 A'rpi
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/**
+ * @file
+ * Calculate Spatial Info (SI) and Temporal Info (TI) scores
+ */
+
+#include 
+
+#include "libavutil/imgutils.h"
+#include "libavutil/internal.h"
+#include "libavutil/opt.h"
+
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "video.h"
+
+static const int X_FILTER[9] = {
+1, 0, -1,
+2, 0, -2,
+1, 0, -1
+};
+
+static const int Y_FILTER[9] = {
+1, 2, 1,
+0, 0, 0,
+-1, -2, -1
+};
+
+typedef struct SiTiContext {
+const AVClass *class;
+int pixel_depth;
+int width, height;
+int nb_frames;
+unsigned char *prev_frame;
+double max_si;
+double max_ti;
+double min_si;
+double min_ti;
+dou

Re: [FFmpeg-devel] [PATCH v4 3/3] avformat/mxfenc: prefer to use the configured metadta

2021-01-15 Thread Tomas Härdin
lör 2021-01-09 klockan 13:07 +0800 skrev lance.lmw...@gmail.com:
> From: Limin Wang 
> 
> The metadata company_name, product_name, product_version from input
> file will be deleted to avoid overwriting information
> Please to test with below command:
> ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf
> and
> ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy \
> -metadata company_name="xxx" \
> -metadata product_name="xxx" \
> -metadata product_version="xxx" \
> out.mxf
> 
> Signed-off-by: Limin Wang 
> ---
>  fftools/ffmpeg_opt.c |  3 +++
>  libavformat/mxfenc.c | 12 
>  2 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> index c295514..493763b 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -2650,6 +2650,9 @@ loop_end:
>  if(o->recording_time != INT64_MAX)
>  av_dict_set(&oc->metadata, "duration", NULL, 0);
>  av_dict_set(&oc->metadata, "creation_time", NULL, 0);
> +av_dict_set(&oc->metadata, "company_name", NULL, 0);
> +av_dict_set(&oc->metadata, "product_name", NULL, 0);
> +av_dict_set(&oc->metadata, "product_version", NULL, 0);
>  }
>  if (!o->metadata_streams_manual)
>  for (i = of->ost_index; i < nb_output_streams; i++) {
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index d8678c9..5244211 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -722,16 +722,20 @@ static void mxf_write_identification(AVFormatContext *s)
>  {
>  MXFContext *mxf = s->priv_data;
>  AVIOContext *pb = s->pb;
> -const char *company = "FFmpeg";
> -const char *product = s->oformat != &ff_mxf_opatom_muxer ? "OP1a Muxer" 
> : "OPAtom Muxer";
> -const char *version;
> +AVDictionaryEntry *com_entry =  av_dict_get(s->metadata, "company_name", 
> NULL, 0);
> +AVDictionaryEntry *product_entry =  av_dict_get(s->metadata, 
> "product_name", NULL, 0);
> +AVDictionaryEntry *version_entry =  av_dict_get(s->metadata, 
> "product_version", NULL, 0);
> +const char *company = com_entry ? com_entry->value : "FFmpeg";
> +const char *product = product_entry ? product_entry->value : s->oformat 
> != &ff_mxf_opatom_muxer ? "OP1a Muxer" : "OPAtom Muxer";
> +const char *version = NULL;
> +const char *product_version = version_entry ? version_entry->value : 
> AV_STRINGIFY(LIBAVFORMAT_VERSION);
>  int length;
>  
>  mxf_write_metadata_key(pb, 0x013000);
>  PRINT_KEY(s, "identification key", pb->buf_ptr - 16);
>  
>  version = s->flags & AVFMT_FLAG_BITEXACT ?
> -"0.0.0" : AV_STRINGIFY(LIBAVFORMAT_VERSION);
> +"0.0.0" : product_version;

Again, why? If you have a company that maintains a fork of FFmpeg then
compile that info in here instead. Compare with FFmbc which always puts
"FFmbc" as CompanyName.

/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 V2 2/3] dnn/openvino: refine code for better model initialization

2021-01-15 Thread Ting Fu
Move openvino model/inference request creation and initialization steps
from ff_dnn_load_model_ov to new function init_model_ov, for later input
resize support.

Signed-off-by: Ting Fu 
---
 libavfilter/dnn/dnn_backend_openvino.c | 196 ++---
 1 file changed, 111 insertions(+), 85 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index 8476f4fb38..0b125eef65 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -248,6 +248,96 @@ static void infer_completion_callback(void *args)
 }
 }
 
+static DNNReturnType init_model_ov(OVModel *ov_model)
+{
+OVContext *ctx = &ov_model->ctx;
+IEStatusCode status;
+ie_available_devices_t a_dev;
+ie_config_t config = {NULL, NULL, NULL};
+char *all_dev_names = NULL;
+
+// batch size
+if (ctx->options.batch_size <= 0) {
+ctx->options.batch_size = 1;
+}
+
+if (ctx->options.batch_size > 1) {
+input_shapes_t input_shapes;
+status = ie_network_get_input_shapes(ov_model->network, &input_shapes);
+if (status != OK)
+goto err;
+for (int i = 0; i < input_shapes.shape_num; i++)
+input_shapes.shapes[i].shape.dims[0] = ctx->options.batch_size;
+status = ie_network_reshape(ov_model->network, input_shapes);
+ie_network_input_shapes_free(&input_shapes);
+if (status != OK)
+goto err;
+}
+
+status = ie_core_load_network(ov_model->core, ov_model->network, 
ctx->options.device_type, &config, &ov_model->exe_network);
+if (status != OK) {
+av_log(ctx, AV_LOG_ERROR, "Failed to load OpenVINO model network\n");
+status = ie_core_get_available_devices(ov_model->core, &a_dev);
+if (status != OK) {
+av_log(ctx, AV_LOG_ERROR, "Failed to get available devices\n");
+goto err;
+}
+for (int i = 0; i < a_dev.num_devices; i++) {
+APPEND_STRING(all_dev_names, a_dev.devices[i])
+}
+av_log(ctx, AV_LOG_ERROR,"device %s may not be supported, all 
available devices are: \"%s\"\n",
+   ctx->options.device_type, all_dev_names);
+goto err;
+}
+
+// create infer_request for sync execution
+status = ie_exec_network_create_infer_request(ov_model->exe_network, 
&ov_model->infer_request);
+if (status != OK)
+goto err;
+
+// create infer_requests for async execution
+if (ctx->options.nireq <= 0) {
+// the default value is a rough estimation
+ctx->options.nireq = av_cpu_count() / 2 + 1;
+}
+
+ov_model->request_queue = ff_safe_queue_create();
+if (!ov_model->request_queue) {
+goto err;
+}
+
+for (int i = 0; i < ctx->options.nireq; i++) {
+ie_infer_request_t *request;
+RequestItem *item = av_mallocz(sizeof(*item));
+if (!item) {
+goto err;
+}
+status = ie_exec_network_create_infer_request(ov_model->exe_network, 
&request);
+if (status != OK) {
+av_freep(&item);
+goto err;
+}
+item->infer_request = request;
+item->callback.completeCallBackFunc = infer_completion_callback;
+item->callback.args = item;
+if (ff_safe_queue_push_back(ov_model->request_queue, item) < 0) {
+av_freep(&item);
+goto err;
+}
+}
+
+ov_model->task_queue = ff_queue_create();
+if (!ov_model->task_queue) {
+goto err;
+}
+
+return DNN_SUCCESS;
+
+err:
+ff_dnn_free_model_ov(&ov_model->model);
+return DNN_ERROR;
+}
+
 static DNNReturnType execute_model_ov(RequestItem *request)
 {
 IEStatusCode status;
@@ -367,6 +457,13 @@ static DNNReturnType get_output_ov(void *model, const char 
*input_name, int inpu
 in_frame->width = input_width;
 in_frame->height = input_height;
 
+if (!ov_model->exe_network) {
+if (init_model_ov(ov_model) != DNN_SUCCESS) {
+av_log(ctx, AV_LOG_ERROR, "Failed init OpenVINO exectuable network 
or inference request\n");
+return DNN_ERROR;
+};
+}
+
 task.done = 0;
 task.do_ioproc = 0;
 task.async = 0;
@@ -391,13 +488,10 @@ static DNNReturnType get_output_ov(void *model, const 
char *input_name, int inpu
 
 DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char 
*options, AVFilterContext *filter_ctx)
 {
-char *all_dev_names = NULL;
 DNNModel *model = NULL;
 OVModel *ov_model = NULL;
 OVContext *ctx = NULL;
 IEStatusCode status;
-ie_config_t config = {NULL, NULL, NULL};
-ie_available_devices_t a_dev;
 
 model = av_mallocz(sizeof(DNNModel));
 if (!model){
@@ -429,88 +523,6 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, 
const char *options,
 if (status != OK)
 goto err;
 
-// batch size
-if (ctx->options.batch_size <= 0) {
-ctx->options.batch

[FFmpeg-devel] [PATCH V2 1/3] dnn/openvino: remove unnecessary code

2021-01-15 Thread Ting Fu
Signed-off-by: Ting Fu 
---
 libavfilter/dnn/dnn_backend_openvino.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index 5271d1caa5..8476f4fb38 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -325,14 +325,6 @@ static DNNReturnType get_input_ov(void *model, DNNData 
*input, const char *input
 return DNN_ERROR;
 }
 
-// The order of dims in the openvino is fixed and it is always 
NCHW for 4-D data.
-// while we pass NHWC data from FFmpeg to openvino
-status = ie_network_set_input_layout(ov_model->network, 
input_name, NHWC);
-if (status != OK) {
-av_log(ctx, AV_LOG_ERROR, "Input \"%s\" does not match layout 
NHWC\n", input_name);
-return DNN_ERROR;
-}
-
 input->channels = dims.dims[1];
 input->height   = dims.dims[2];
 input->width= dims.dims[3];
-- 
2.17.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 V2 3/3] dnn/openvino: support model input resize

2021-01-15 Thread Ting Fu
OpenVINO APIs require specify input size to run the model, while some
OpenVINO model does accept different input size. To enable this feature
adding input_resizable option here for easier use.
Setting bool variable input_resizable to specify if the input can be resizable 
or not.
input_resizable = 1 means support input resize, aka accept different input size.
input_resizable = 0 (default) means do not support input resize.
Please make sure the inference model does accept different input size
before use this option, otherwise the inference engine may report error(s).
eg: ./ffmpeg -i video_name.mp4 -vf dnn_processing=dnn_backend=openvino:\
  model=model_name.xml:input=input_name:output=output_name:\
  options=device=CPU\&input_resizable=1 -y output_video_name.mp4

Signed-off-by: Ting Fu 
---
V2:
rebase to latest code

 libavfilter/dnn/dnn_backend_openvino.c | 21 +++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index 0b125eef65..1664ff5268 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -38,6 +38,7 @@ typedef struct OVOptions{
 char *device_type;
 int nireq;
 int batch_size;
+int input_resizable;
 } OVOptions;
 
 typedef struct OVContext {
@@ -86,6 +87,7 @@ static const AVOption dnn_openvino_options[] = {
 { "device", "device to run model", OFFSET(options.device_type), 
AV_OPT_TYPE_STRING, { .str = "CPU" }, 0, 0, FLAGS },
 { "nireq",  "number of request",   OFFSET(options.nireq),   
AV_OPT_TYPE_INT,{ .i64 = 0 }, 0, INT_MAX, FLAGS },
 { "batch_size",  "batch size per request", OFFSET(options.batch_size),  
AV_OPT_TYPE_INT,{ .i64 = 1 }, 1, 1000, FLAGS},
+{ "input_resizable", "can input be resizable or not", 
OFFSET(options.input_resizable), AV_OPT_TYPE_BOOL,   { .i64 = 0 }, 0, 1, 
FLAGS },
 { NULL }
 };
 
@@ -393,6 +395,7 @@ static DNNReturnType get_input_ov(void *model, DNNData 
*input, const char *input
 size_t model_input_count = 0;
 dimensions_t dims;
 precision_e precision;
+int input_resizable = ctx->options.input_resizable;
 
 status = ie_network_get_inputs_number(ov_model->network, 
&model_input_count);
 if (status != OK) {
@@ -416,8 +419,8 @@ static DNNReturnType get_input_ov(void *model, DNNData 
*input, const char *input
 }
 
 input->channels = dims.dims[1];
-input->height   = dims.dims[2];
-input->width= dims.dims[3];
+input->height   = input_resizable ? -1 : dims.dims[2];
+input->width= input_resizable ? -1 : dims.dims[3];
 input->dt   = precision_to_datatype(precision);
 return DNN_SUCCESS;
 } else {
@@ -443,6 +446,8 @@ static DNNReturnType get_output_ov(void *model, const char 
*input_name, int inpu
 AVFrame *in_frame = av_frame_alloc();
 AVFrame *out_frame = NULL;
 TaskItem *ptask = &task;
+IEStatusCode status;
+input_shapes_t input_shapes;
 
 if (!in_frame) {
 av_log(ctx, AV_LOG_ERROR, "Failed to allocate memory for input 
frame\n");
@@ -457,6 +462,18 @@ static DNNReturnType get_output_ov(void *model, const char 
*input_name, int inpu
 in_frame->width = input_width;
 in_frame->height = input_height;
 
+if (ctx->options.input_resizable) {
+status = ie_network_get_input_shapes(ov_model->network, &input_shapes);
+input_shapes.shapes->shape.dims[2] = input_height;
+input_shapes.shapes->shape.dims[3] = input_width;
+status |= ie_network_reshape(ov_model->network, input_shapes);
+ie_network_input_shapes_free(&input_shapes);
+if (status != OK) {
+av_log(ctx, AV_LOG_ERROR, "Failed to reshape input size for %s\n", 
input_name);
+return DNN_ERROR;
+}
+}
+
 if (!ov_model->exe_network) {
 if (init_model_ov(ov_model) != DNN_SUCCESS) {
 av_log(ctx, AV_LOG_ERROR, "Failed init OpenVINO exectuable network 
or inference request\n");
-- 
2.17.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 6/7] avformat/lxfdec: Fix multiple integer overflows related to track_size

2021-01-15 Thread Tomas Härdin
tor 2021-01-14 klockan 23:51 +0100 skrev Michael Niedermayer:
> Fixes: signed integer overflow: 538976288 * 8 cannot be represented in type 
> 'int'
> Fixes: 
> 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_LXF_fuzzer-6634030636335104
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/lxfdec.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/lxfdec.c b/libavformat/lxfdec.c
> index fa84ceea78..509d19fe7f 100644
> --- a/libavformat/lxfdec.c
> +++ b/libavformat/lxfdec.c
> @@ -195,7 +195,7 @@ static int get_packet_header(AVFormatContext *s)
>  return AVERROR_PATCHWELCOME;
>  }
>  
> -samples = track_size * 8 / st->codecpar->bits_per_coded_sample;
> +samples = track_size * 8LL / st->codecpar->bits_per_coded_sample;
>  
>  //use audio packet size to determine video standard
>  //for NTSC we have one 8008-sample audio frame per five video frames
> @@ -210,6 +210,8 @@ static int get_packet_header(AVFormatContext *s)
>  avpriv_set_pts_info(s->streams[0], 64, 1, 25);
>  }
>  
> +if (av_popcount(channels) * (uint64_t)track_size > INT_MAX)
> +return AVERROR_INVALIDDATA;
>  //TODO: warning if track mask != (1 << channels) - 1?
>  ret = av_popcount(channels) * track_size;

What happens if channels == 0 ? Probably gets caught in
av_new_packet(), just making sure

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