Re: [FFmpeg-devel] [PATCH] avfilter/[vf_nnedi, vf_estdif]: Check interlaced flag on correct frame

2021-07-16 Thread Paul B Mahol
applied
___
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] lavd/lavfi.c: Set time_base for 608 cc to container time_base.

2021-07-16 Thread Thilo Borgmann
Hi,

>>> when transcoding 608 cc, the cc stream frame pts is set to the same value 
>>> as its container frame's pts. However, the time_base is always set to 
>>> 1/9 (default) in the initialization stage. Which causes timing issues 
>>> when the container time_base is actually not 1/9.
>>
>> identical v2 attached that also includes updates to the FATE references 
>> affected by the patch (and failed with patchwork of course).
>>
>> -Thilo
>>
>> From 41b619e5d5083ca59a41cca9cb515190939d6573 Mon Sep 17 00:00:00 2001
>> From: Yun Zhang 
>> Date: Mon, 28 Jun 2021 15:09:42 +0200
>> Subject: [PATCH] lavd/lavfi.c: Set time_base for 608 cc to container
>>  time_base.
>>
>> Suggested-By: ffm...@fb.com
>> ---
>>  libavdevice/lavfi.c|  3 +++
>>  tests/ref/fate/sub-cc  |  4 ++--
>>  tests/ref/fate/sub-cc-realtime | 38 +++---
>>  3 files changed, 13 insertions(+), 32 deletions(-)
>>
>> diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
>> index 57d977e7ce..e07f20c872 100644
>> --- a/libavdevice/lavfi.c
>> +++ b/libavdevice/lavfi.c
>> @@ -100,6 +100,7 @@ static int create_subcc_streams(AVFormatContext *avctx)
>>  LavfiContext *lavfi = avctx->priv_data;
>>  AVStream *st;
>>  int stream_idx, sink_idx;
>> +AVRational *time_base;
>>  
>>  for (stream_idx = 0; stream_idx < lavfi->nb_sinks; stream_idx++) {
>>  sink_idx = lavfi->stream_sink_map[stream_idx];
>> @@ -109,6 +110,8 @@ static int create_subcc_streams(AVFormatContext *avctx)
>>  return AVERROR(ENOMEM);
>>  st->codecpar->codec_id = AV_CODEC_ID_EIA_608;
>>  st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
>> +time_base = &avctx->streams[stream_idx]->time_base;
>> +avpriv_set_pts_info(st, 64, time_base->num, time_base->den);
> 
> This look like an unnecessariily complicated way to write
> st->time_base.{num,den}

Changed patch attached.

Thanks,
Thilo
From ca110e104f7fa8b18db92ba9c79a5f0093ba9719 Mon Sep 17 00:00:00 2001
From: Yun Zhang 
Date: Fri, 16 Jul 2021 09:43:54 +0200
Subject: [PATCH] lavd/lavfi.c: Set time_base for 608 cc to container
 time_base.

Suggested-By: ffm...@fb.com
---
 libavdevice/lavfi.c|  4 
 tests/ref/fate/sub-cc  |  4 ++--
 tests/ref/fate/sub-cc-realtime | 38 +++---
 3 files changed, 14 insertions(+), 32 deletions(-)

diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index 57d977e7ce..4eb1f56f7d 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -100,6 +100,7 @@ static int create_subcc_streams(AVFormatContext *avctx)
 LavfiContext *lavfi = avctx->priv_data;
 AVStream *st;
 int stream_idx, sink_idx;
+AVRational *time_base;
 
 for (stream_idx = 0; stream_idx < lavfi->nb_sinks; stream_idx++) {
 sink_idx = lavfi->stream_sink_map[stream_idx];
@@ -109,6 +110,9 @@ static int create_subcc_streams(AVFormatContext *avctx)
 return AVERROR(ENOMEM);
 st->codecpar->codec_id = AV_CODEC_ID_EIA_608;
 st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+time_base = &avctx->streams[stream_idx]->time_base;
+st->time_base.num = time_base->num;
+st->time_base.den = time_base->den;
 } else {
 lavfi->sink_stream_subcc_map[sink_idx] = -1;
 }
diff --git a/tests/ref/fate/sub-cc b/tests/ref/fate/sub-cc
index 2b30a35be0..13f393cc86 100644
--- a/tests/ref/fate/sub-cc
+++ b/tests/ref/fate/sub-cc
@@ -11,5 +11,5 @@ Style: 
Default,Monospace,16,&Hff,&Hff,&H0,&H0,0,0,0,0,100,100,0,0,3,1,0,
 
 [Events]
 Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:12.36,0:00:40.83,Default,,0,0,0,,{\an7}{\pos(38,44)}({\i1} 
inaudible radio chatter{\i0} )
-Dialogue: 0,0:00:40.83,0:00:59.07,Default,,0,0,0,,{\an7}{\pos(38,28)}({\i1} 
inaudible radio chatter{\i0} )\N{\an7}{\pos(38,44)}>> Safety remains our number 
one
+Dialogue: 0,0:00:00.83,0:00:02.97,Default,,0,0,0,,{\an7}{\pos(38,44)}({\i1} 
inaudible radio chatter{\i0} )
+Dialogue: 0,0:00:02.97,0:00:04.34,Default,,0,0,0,,{\an7}{\pos(38,28)}({\i1} 
inaudible radio chatter{\i0} )\N{\an7}{\pos(38,44)}>> Safety remains our number 
one
diff --git a/tests/ref/fate/sub-cc-realtime b/tests/ref/fate/sub-cc-realtime
index 5a95ff5cb7..169361f540 100644
--- a/tests/ref/fate/sub-cc-realtime
+++ b/tests/ref/fate/sub-cc-realtime
@@ -11,33 +11,11 @@ Style: 
Default,Monospace,16,&Hff,&Hff,&H0,&H0,0,0,0,0,100,100,0,0,3,1,0,
 
 [Events]
 Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:14.14,9:59:59.99,Default,,0,0,0,,{\an7}{\pos(38,44)}(
-Dialogue: 0,0:00:15.47,9:59:59.99,Default,,0,0,0,,{\an7}{\pos(38,44)}({\i1} in
-Dialogue: 0,0:00:15.92,9:59:59.99,Default,,0,0,0,,{\an7}{\pos(38,44)}({\i1} 
inau
-Dialogue: 0,0:00:16.36,9:59:59.99,Default,,0,0,0,,{\an7}{\pos(38,44)}({\i1} 
inaudi
-Dialogue: 0,0:00:16.81,9:

Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg: Add new variant source_no_drop to the force_key_frames option

2021-07-16 Thread Thilo Borgmann
Am 04.07.21 um 21:23 schrieb Michael Niedermayer:
> On Sun, Jun 20, 2021 at 09:48:29PM +0200, Thilo Borgmann wrote:
>> Hi,
>>
>> adds a new variant to the -force_key_frames option "source_no_drop" to make
>> sure whenever a key frame in the source is dropped, we choose the next frame
>> in the output stream as a key frame.
>>
>> -Thilo
> 
>>  doc/ffmpeg.texi  |7 +++
>>  fftools/ffmpeg.c |6 ++
>>  fftools/ffmpeg.h |1 +
>>  3 files changed, 14 insertions(+)
>> e8ffd04204a6cc243b2f98858ec1f1afe44ff8e8  
>> 0001-fftools-ffmpeg-Add-new-variant-source_no_drop-to-the.patch
>> From b37c854e7d48b538537b2c9c5e9651ba2ead3e52 Mon Sep 17 00:00:00 2001
>> From: Keyun Tong 
>> Date: Sun, 20 Jun 2021 21:42:29 +0200
>> Subject: [PATCH] fftools/ffmpeg: Add new variant source_no_drop to the
>>  force_key_frames option
> 
> LGTM if both variants have a use case 

Pushed.

Thanks,
Thilo
___
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] fftools/cmdutils.c: Add cmd line option to override detection of cpu count

2021-07-16 Thread Thilo Borgmann
Am 04.07.21 um 14:31 schrieb Thilo Borgmann:
> Hi,
> 
 add an option to override auto-detection of cpu count. Defaults to 
 auto-detection, of course.

 -Thilo

>>>

  doc/fftools-common-opts.texi |  7 +++
  fftools/cmdutils.c   | 27 +++
  fftools/cmdutils.h   |  7 +++
  libavutil/cpu.c  | 14 ++
  libavutil/cpu.h  |  6 ++
>>>
>>> The changes to libavutil and cmdutils should be in separate patches; and
>>> of course the commit message should mention that you are changing
>>> libavutil -- I would have nearly missed this patch (given that I don't
>>> pay much attention to fftools in general).
>>>

 diff --git a/libavutil/cpu.c b/libavutil/cpu.c
 index 52f6b9a3bf..ccd5b5adac 100644
 --- a/libavutil/cpu.c
 +++ b/libavutil/cpu.c
>>>
>>> 52f6b9a3bf is the state of cpu.c after
>>> e387fcd01cb84d9493f3b96158addd2a85f086c6. This is completely outdated.
>>
>> Yes, messed up branches for the patch, thx!
>>
>>

 @@ -306,14 +307,27 @@ int av_cpu_count(void)
  nb_cpus = sysinfo.dwNumberOfProcessors;
  #endif
  
 +int count = atomic_load_explicit(&cpu_count, memory_order_relaxed);
 +
  if (!printed) {
  av_log(NULL, AV_LOG_DEBUG, "detected %d logical cores\n", 
 nb_cpus);
 +if (count > 0) {
 +av_log(NULL, AV_LOG_DEBUG, "overriding to %d logical 
 cores\n", count);
 +}
  printed = 1;
  }
  
 +if (count > 0) {
 +nb_cpus = count;
 +}
 +
  return nb_cpus;
  }
  
>>> In particular, this hunk doesn't apply to git master at all any more
>>> (did I already mention that cpu.c only has 245 lines atm, not >300?).
>>> And the declaration of count would lead to a statement-after-declaration
>>> warning.
>>
>> Done locally to apply to today's HEAD. I think I'll wait with sending both 
>> patches once we decided on atomic loads in "[PATCH] Stop using _explicit 
>> atomic operations where not necessary.".
> 
> Discussion on atomic loads appear to have stalled mid-June... If there are no 
> hard feeling, I'll push this version soon as the explicit (or not) loads can 
> then be changed later.

Pushed, thanks!

-Thilo
___
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 v1] avcodec/v4l2_context: don't reinit output queue when dynamic resolution change

2021-07-16 Thread Ming Qian
in the v4l2 stateful video document, we can see the following
description:
During the resolution change sequence, the OUTPUT queue must remain
streaming. Calling VIDIOC_STREAMOFF() on the OUTPUT queue would
abort the sequence and initiate a seek.

In principle, the OUTPUT queue operates separately from the CAPTURE
queue and this remains true for the duration of the entire
resolution change sequence as well.

so don't reinit the output queue when handling the resolution change
event

Signed-off-by: Ming Qian 
---
 libavcodec/v4l2_context.c | 27 ++-
 1 file changed, 2 insertions(+), 25 deletions(-)

diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
index ff1ea8e57b08..dda5157698c3 100644
--- a/libavcodec/v4l2_context.c
+++ b/libavcodec/v4l2_context.c
@@ -162,9 +162,8 @@ static int v4l2_handle_event(V4L2Context *ctx)
 {
 V4L2m2mContext *s = ctx_to_m2mctx(ctx);
 struct v4l2_format cap_fmt = s->capture.format;
-struct v4l2_format out_fmt = s->output.format;
 struct v4l2_event evt = { 0 };
-int full_reinit, reinit, ret;
+int reinit, ret;
 
 ret = ioctl(s->fd, VIDIOC_DQEVENT, &evt);
 if (ret < 0) {
@@ -180,25 +179,12 @@ static int v4l2_handle_event(V4L2Context *ctx)
 if (evt.type != V4L2_EVENT_SOURCE_CHANGE)
 return 0;
 
-ret = ioctl(s->fd, VIDIOC_G_FMT, &out_fmt);
-if (ret) {
-av_log(logger(ctx), AV_LOG_ERROR, "%s VIDIOC_G_FMT\n", s->output.name);
-return 0;
-}
-
 ret = ioctl(s->fd, VIDIOC_G_FMT, &cap_fmt);
 if (ret) {
 av_log(logger(ctx), AV_LOG_ERROR, "%s VIDIOC_G_FMT\n", 
s->capture.name);
 return 0;
 }
 
-full_reinit = v4l2_resolution_changed(&s->output, &out_fmt);
-if (full_reinit) {
-s->output.height = v4l2_get_height(&out_fmt);
-s->output.width = v4l2_get_width(&out_fmt);
-s->output.sample_aspect_ratio = v4l2_get_sar(&s->output);
-}
-
 reinit = v4l2_resolution_changed(&s->capture, &cap_fmt);
 if (reinit) {
 s->capture.height = v4l2_get_height(&cap_fmt);
@@ -206,18 +192,9 @@ static int v4l2_handle_event(V4L2Context *ctx)
 s->capture.sample_aspect_ratio = v4l2_get_sar(&s->capture);
 }
 
-if (full_reinit || reinit)
+if (reinit)
 s->reinit = 1;
 
-if (full_reinit) {
-ret = ff_v4l2_m2m_codec_full_reinit(s);
-if (ret) {
-av_log(logger(ctx), AV_LOG_ERROR, "v4l2_m2m_codec_full_reinit\n");
-return AVERROR(EINVAL);
-}
-goto reinit_run;
-}
-
 if (reinit) {
 if (s->avctx)
 ret = ff_set_dimensions(s->avctx, s->capture.width, 
s->capture.height);
-- 
2.32.0

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

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


[FFmpeg-devel] [PATCH] ffmpeg: add option readrate

2021-07-16 Thread Gyan Doshi
Allows to read inputs at arbitrary rates.
-re is equivalent to -readrate 1

Tested with -copyts {+ start_at_zero}, -ss, streamcopied & decoded streams.
---
 doc/ffmpeg.texi  | 18 +++---
 fftools/ffmpeg.c | 13 ++---
 fftools/ffmpeg.h |  2 ++
 fftools/ffmpeg_opt.c | 19 ++-
 4 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index b27b9fe2c4..d4363f7cc8 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1568,14 +1568,18 @@ Exit after ffmpeg has been running for @var{duration} 
seconds in CPU user time.
 Dump each input packet to stderr.
 @item -hex (@emph{global})
 When dumping packets, also dump the payload.
-@item -re (@emph{input})
-Read input at native frame rate. Mainly used to simulate a grab device,
-or live input stream (e.g. when reading from a file). Should not be used
-with actual grab devices or live input streams (where it can cause packet
-loss).
+@item -readrate @var{speed} (@emph{input})
+Limit input read speed to specified floating-point positive value.
 By default @command{ffmpeg} attempts to read the input(s) as fast as possible.
-This option will slow down the reading of the input(s) to the native frame rate
-of the input(s). It is useful for real-time output (e.g. live streaming).
+This option sets a ceiling which will have an effect when packets are available
+to be read at a faster rate.
+Mainly used to simulate a grab device, or live input stream (e.g. when reading 
from a file).
+Should not be used with actual grab devices or live input streams (where it 
can cause packet
+loss).
+It is useful for output where flow control is important, such as live 
streaming.
+Value @code{1} represents real-time speed. Default is @code{0}, which disables 
any ceiling.
+@item -re (@emph{input})
+Read input at native frame rate. This option is deprecated. Use 
@code{-readrate 1} instead.
 @item -vsync @var{parameter}
 Video sync method.
 For compatibility reasons old values can be specified as numbers.
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index e97d879cb3..efbd513f01 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3759,7 +3759,7 @@ static int transcode_init(void)
 /* init framerate emulation */
 for (i = 0; i < nb_input_files; i++) {
 InputFile *ifile = input_files[i];
-if (ifile->rate_emu)
+if (ifile->readrate || ifile->rate_emu)
 for (j = 0; j < ifile->nb_streams; j++)
 input_streams[j + ifile->ist_index]->start = 
av_gettime_relative();
 }
@@ -4219,12 +4219,19 @@ static int get_input_packet_mt(InputFile *f, AVPacket 
**pkt)
 
 static int get_input_packet(InputFile *f, AVPacket **pkt)
 {
-if (f->rate_emu) {
+if (f->readrate || f->rate_emu) {
 int i;
+int64_t file_start = copy_ts * (
+  (f->ctx->start_time != AV_NOPTS_VALUE ? 
f->ctx->start_time * !start_at_zero : 0) +
+  (f->start_time != AV_NOPTS_VALUE ? f->start_time 
: 0)
+ );
+float scale = f->rate_emu ? 1.0 : f->readrate;
 for (i = 0; i < f->nb_streams; i++) {
 InputStream *ist = input_streams[f->ist_index + i];
+if (!ist->nb_packets) continue;
+int64_t stream_ts_offset = FFMAX(ist->first_dts != AV_NOPTS_VALUE 
? ist->first_dts : 0, file_start);
 int64_t pts = av_rescale(ist->dts, 100, AV_TIME_BASE);
-int64_t now = av_gettime_relative() - ist->start;
+int64_t now = (av_gettime_relative() - ist->start)*scale + 
stream_ts_offset;
 if (pts > now)
 return AVERROR(EAGAIN);
 }
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index e9d30fbd67..eda1c82c43 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -119,6 +119,7 @@ typedef struct OptionsContext {
 int64_t input_ts_offset;
 int loop;
 int rate_emu;
+float readrate;
 int accurate_seek;
 int thread_queue_size;
 
@@ -418,6 +419,7 @@ typedef struct InputFile {
  from ctx.nb_streams if new streams appear during 
av_read_frame() */
 int nb_streams_warn;  /* number of streams that the user was warned of */
 int rate_emu;
+float readrate;
 int accurate_seek;
 
 AVPacket *pkt;
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index cb7d6ceefc..73e265 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1286,6 +1286,20 @@ static int open_input_file(OptionsContext *o, const char 
*filename)
 f->loop = o->loop;
 f->duration = 0;
 f->time_base = (AVRational){ 1, 1 };
+
+f->readrate = o->readrate ? o->readrate : 0.0;
+if (f->readrate < 0.0f) {
+av_log(NULL, AV_LOG_ERROR, "Option -readrate for Input #%d is %0.3f; 
it must be non-negative.\n", nb_input_files, f->readrate);
+exit_program(1);
+}
+if (f->readrate && f->rate_emu) {
+av_log(NULL, AV_LOG_W

Re: [FFmpeg-devel] [PATCH] fftools/cmdutils.c: Add cmd line option to override detection of cpu count

2021-07-16 Thread James Almer

On 6/6/2021 7:44 AM, Thilo Borgmann wrote:

Hi,

Am 05.06.21 um 16:33 schrieb Anton Khirnov:

Quoting Thilo Borgmann (2021-06-05 14:29:05)

Hi,

add an option to override auto-detection of cpu count. Defaults to 
auto-detection, of course.

-Thilo

 From 38612f3e1339354dbaa6be4f36072320ff71c707 Mon Sep 17 00:00:00 2001
From: Thilo Borgmann 
Date: Sat, 5 Jun 2021 14:26:23 +0200
Subject: [PATCH] fftools/cmdutils.c: Add cmd line option to override detection
  of cpu count

Suggested-By: ffm...@fb.com
---
  doc/fftools-common-opts.texi |  7 +++
  fftools/cmdutils.c   | 27 +++
  fftools/cmdutils.h   |  7 +++
  libavutil/cpu.c  | 14 ++
  libavutil/cpu.h  |  6 ++
  5 files changed, 61 insertions(+)

[...]



  /**
   * Fallback for options that are not explicitly handled, these will be
   * parsed through AVOptions.
@@ -239,6 +245,7 @@ void show_help_options(const OptionDef *options, const char 
*msg, int req_flags,
  { "report",  0,{ .func_arg = opt_report },   
"generate a report" }, \
  { "max_alloc",   HAS_ARG,  { .func_arg = opt_max_alloc },"set maximum 
size of a single allocated block", "bytes" }, \
  { "cpuflags",HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags }, "force specific 
cpu flags", "flags" }, \
+{ "cpucount",HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpucount }, "force specific 
cpu count", "count" }, \
  { "hide_banner", OPT_BOOL | OPT_EXPERT, {&hide_banner}, "do not show program 
banner", "hide_banner" },  \
  CMDUTILS_COMMON_OPTIONS_AVDEVICE  
  \
  
diff --git a/libavutil/cpu.c b/libavutil/cpu.c

index 52f6b9a3bf..ccd5b5adac 100644
--- a/libavutil/cpu.c
+++ b/libavutil/cpu.c
@@ -48,6 +48,7 @@
  #endif
  
  static atomic_int cpu_flags = ATOMIC_VAR_INIT(-1);

+static atomic_int cpu_count = ATOMIC_VAR_INIT(-1);
  
  static int get_cpu_flags(void)

  {
@@ -306,14 +307,27 @@ int av_cpu_count(void)
  nb_cpus = sysinfo.dwNumberOfProcessors;
  #endif
  
+int count = atomic_load_explicit(&cpu_count, memory_order_relaxed);


Just use a normal atomic_load().


[...]



+/**
+ * Overrides cpu count detection and forces the specified count.
+ * Count < 1 disables forcing of specific count.
+ */
+void av_force_cpu_count(int count);


I'd prefer if the name was namespaced as av_cpu_


For both of these, I copied the behavior of av_force_cpu_flags(). For function 
names as well as the atomic load.
Let me know which way you prefer. If you prefer your reviewed version, I could 
also send a patch for similar changes to av_force_cpu_flags() if that makes 
sense.

All other remarks changed locally.


Looks like you did not rename it to av_cpu_ namespace.



Thanks,
Thilo
___
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 1/2] libavutil/cpu: Adds fast gather detection.

2021-07-16 Thread Alan Kelly
Broadwell and later and Zen3 and later have fast gather instructions.
---
 Haswell is now excluded from EXTERNAL_AVX2_FAST as discussed in the
 email thread.
 libavutil/cpu.h |  1 +
 libavutil/x86/cpu.c | 11 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavutil/cpu.h b/libavutil/cpu.h
index c069076439..ec3073d021 100644
--- a/libavutil/cpu.h
+++ b/libavutil/cpu.h
@@ -113,6 +113,7 @@ void av_force_cpu_count(int count);
  *  av_set_cpu_flags_mask(), then this function will behave as if AVX is not
  *  present.
  */
+
 size_t av_cpu_max_align(void);
 
 #endif /* AVUTIL_CPU_H */
diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
index bcd41a50a2..158e2170c4 100644
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -146,8 +146,17 @@ int ff_get_cpu_flags_x86(void)
 if (max_std_level >= 7) {
 cpuid(7, eax, ebx, ecx, edx);
 #if HAVE_AVX2
-if ((rval & AV_CPU_FLAG_AVX) && (ebx & 0x0020))
+if ((rval & AV_CPU_FLAG_AVX) && (ebx & 0x0020)){
 rval |= AV_CPU_FLAG_AVX2;
+
+cpuid(1, eax, ebx, ecx, std_caps);
+family = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
+model  = ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0);
+// Haswell and earlier has slow gather
+if(family == 6 && model < 70)
+rval |= AV_CPU_FLAG_AVXSLOW;
+}
+
 #if HAVE_AVX512 /* F, CD, BW, DQ, VL */
 if ((xcr0_lo & 0xe0) == 0xe0) { /* OPMASK/ZMM state */
 if ((rval & AV_CPU_FLAG_AVX2) && (ebx & 0xd003) == 0xd003)
-- 
2.32.0.402.g57bb445576-goog

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

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


[FFmpeg-devel] [PATCH 2/2] libswscale: Adds ff_hscale8to15_4_avx2 and ff_hscale8to15_X4_avx2 for all filter sizes.

2021-07-16 Thread Alan Kelly
These functions replace all ff_hscale8to15_*_ssse3 when avx2 is available.
---
EXTERNAL_AVX2_FAST is now used instead of EXTERNAL_AVX2_FAST_GATHER as
discussed in the email thread for part 1 of this patch.

Benchmark results on Skylake and Haswell:

Skylake Haswell
hscale_8_to_15_width4_ssse3 761.2   760
hscale_8_to_15_width4_avx2  468.7   957
hscale_8_to_15_width8_ssse3 1170.7  1032
hscale_8_to_15_width8_avx2  865.7   1979
hscale_8_to_15_width12_ssse32172.2  2472
hscale_8_to_15_width12_avx2 1245.7  2901
hscale_8_to_15_width16_ssse32244.2  2400
hscale_8_to_15_width16_avx2 1647.2  3681

 libswscale/swscale_internal.h |   2 +
 libswscale/utils.c|  37 +++
 libswscale/x86/Makefile   |   1 +
 libswscale/x86/scale_avx2.asm | 112 ++
 libswscale/x86/swscale.c  |  19 ++
 tests/checkasm/sw_scale.c |  20 --
 6 files changed, 186 insertions(+), 5 deletions(-)
 create mode 100644 libswscale/x86/scale_avx2.asm

diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 673407636a..fba3dabe5b 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -1064,4 +1064,6 @@ void ff_init_vscale_pfn(SwsContext *c, yuv2planar1_fn 
yuv2plane1, yuv2planarX_fn
 //number of extra lines to process
 #define MAX_LINES_AHEAD 4
 
+//shuffle filter and filterPos for hyScale and hcScale filters in avx2
+void ff_shuffle_filter_coefficients(SwsContext *c, int* filterPos, int 
filterSize, int16_t *filter, int dstW);
 #endif /* SWSCALE_SWSCALE_INTERNAL_H */
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 176fc6fd63..0577fd5490 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -268,6 +268,41 @@ static const FormatEntry format_entries[] = {
 [AV_PIX_FMT_X2RGB10LE]   = { 1, 1 },
 };
 
+void ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos, int 
filterSize, int16_t *filter, int dstW){
+#if ARCH_X86_64
+int i, j, k, l;
+int cpu_flags = av_get_cpu_flags();
+if (EXTERNAL_AVX2_FAST(cpu_flags)){
+if ((c->srcBpc == 8) && (c->dstBpc <= 14)){
+if (dstW % 16 == 0){
+if (filter != NULL){
+for (i = 0; i < dstW; i += 8){
+FFSWAP(int, filterPos[i + 2], filterPos[i+4]);
+FFSWAP(int, filterPos[i + 3], filterPos[i+5]);
+}
+if (filterSize > 4){
+int16_t *tmp2 = av_malloc(dstW * filterSize * 2);
+memcpy(tmp2, filter, dstW * filterSize * 2);
+for (i = 0; i < dstW; i += 16){//pixel
+for (k = 0; k < filterSize / 4; ++k){//fcoeff
+for (j = 0; j < 16; ++j){//inner pixel
+for (l = 0; l < 4; ++l){//coeff
+int from = i * filterSize + j * 
filterSize + k * 4 + l;
+int to = (i) * filterSize + j * 4 + l 
+ k * 64;
+filter[to] = tmp2[from];
+}
+}
+}
+}
+av_free(tmp2);
+}
+}
+}
+}
+}
+#endif
+}
+
 int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
 {
 return (unsigned)pix_fmt < FF_ARRAY_ELEMS(format_entries) ?
@@ -1699,6 +1734,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter 
*srcFilter,
get_local_pos(c, 0, 0, 0),
get_local_pos(c, 0, 0, 0))) < 0)
 goto fail;
+ff_shuffle_filter_coefficients(c, c->hLumFilterPos, 
c->hLumFilterSize, c->hLumFilter, dstW);
 if ((ret = initFilter(&c->hChrFilter, &c->hChrFilterPos,
&c->hChrFilterSize, c->chrXInc,
c->chrSrcW, c->chrDstW, filterAlign, 1 << 14,
@@ -1708,6 +1744,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter 
*srcFilter,
get_local_pos(c, c->chrSrcHSubSample, 
c->src_h_chr_pos, 0),
get_local_pos(c, c->chrDstHSubSample, 
c->dst_h_chr_pos, 0))) < 0)
 goto fail;
+ff_shuffle_filter_coefficients(c, c->hChrFilterPos, 
c->hChrFilterSize, c->hChrFilter, c->chrDstW);
 }
 } // initialize horizontal stuff
 
diff --git a/libswscale/x86/Makefile b/libswscale/x86/Makefile
index bfe383364e..68391494be 100644
--- a/libswscale/x86/Makefile
+++ b/libswscale/x86/Makefile
@@ -11,6 +11,7 @@ OBJS-$(CONFIG_XMM_CLOBBER_TEST) += x86/w64xmmtest.o
 X86ASM-OBJS += x86/input.o  \
x86/output.o \
x86/scale.o 

Re: [FFmpeg-devel] [PATCH 1/2] libavutil/cpu: Adds fast gather detection.

2021-07-16 Thread James Almer

On 7/16/2021 10:44 AM, Alan Kelly wrote:

Broadwell and later and Zen3 and later have fast gather instructions.
---
  Haswell is now excluded from EXTERNAL_AVX2_FAST as discussed in the
  email thread.


I was very explicit about this not being ok. We're not disabling all ymm 
usage for Haswell just for one or two swscale functions using gathers.


Lets go with Lynne's latest suggestion and not change the flags at all 
and use gathers on Haswell, same as other arches, by looking at the 
AVX2_FAST flag.



  libavutil/cpu.h |  1 +
  libavutil/x86/cpu.c | 11 ++-
  2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavutil/cpu.h b/libavutil/cpu.h
index c069076439..ec3073d021 100644
--- a/libavutil/cpu.h
+++ b/libavutil/cpu.h
@@ -113,6 +113,7 @@ void av_force_cpu_count(int count);
   *  av_set_cpu_flags_mask(), then this function will behave as if AVX is not
   *  present.
   */
+
  size_t av_cpu_max_align(void);
  
  #endif /* AVUTIL_CPU_H */

diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
index bcd41a50a2..158e2170c4 100644
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -146,8 +146,17 @@ int ff_get_cpu_flags_x86(void)
  if (max_std_level >= 7) {
  cpuid(7, eax, ebx, ecx, edx);
  #if HAVE_AVX2
-if ((rval & AV_CPU_FLAG_AVX) && (ebx & 0x0020))
+if ((rval & AV_CPU_FLAG_AVX) && (ebx & 0x0020)){
  rval |= AV_CPU_FLAG_AVX2;
+
+cpuid(1, eax, ebx, ecx, std_caps);
+family = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
+model  = ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0);
+// Haswell and earlier has slow gather
+if(family == 6 && model < 70)
+rval |= AV_CPU_FLAG_AVXSLOW;
+}
+
  #if HAVE_AVX512 /* F, CD, BW, DQ, VL */
  if ((xcr0_lo & 0xe0) == 0xe0) { /* OPMASK/ZMM state */
  if ((rval & AV_CPU_FLAG_AVX2) && (ebx & 0xd003) == 0xd003)



___
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] lavc/aarch64: add pred functions for 10-bit

2021-07-16 Thread Mikhail Nitenko
Benchmarks:A53 A72
pred8x8_dc_10_c:   64.249.5
pred8x8_dc_10_neon:62.754.5
pred8x8_dc_128_10_c:   26.015.5
pred8x8_dc_128_10_neon:28.216.0
pred8x8_horizontal_10_c:   60.027.7
pred8x8_horizontal_10_neon:34.227.7
pred8x8_left_dc_10_c:  42.527.5
pred8x8_left_dc_10_neon:   50.741.2
pred8x8_mad_cow_dc_0l0_10_c:   55.737.2
pred8x8_mad_cow_dc_0l0_10_neon:46.036.5
pred8x8_mad_cow_dc_0lt_10_c:   89.267.0
pred8x8_mad_cow_dc_0lt_10_neon:50.246.7
pred8x8_mad_cow_dc_l0t_10_c:   75.551.0
pred8x8_mad_cow_dc_l0t_10_neon:49.744.7
pred8x8_mad_cow_dc_l00_10_c:   58.038.0
pred8x8_mad_cow_dc_l00_10_neon:41.037.5
pred8x8_plane_10_c:   347.5   288.7
pred8x8_plane_10_neon:150.2   108.5
pred8x8_top_dc_10_c:   44.530.5
pred8x8_top_dc_10_neon:39.731.5
pred8x8_vertical_10_c: 27.516.0
pred8x8_vertical_10_neon:  27.715.0
pred16x16_plane_10_c:1245.5  1069.7
pred16x16_plane_10_neon:  349.0   208.7

Signed-off-by: Mikhail Nitenko 
---
 libavcodec/aarch64/h264pred_init.c |  40 +++-
 libavcodec/aarch64/h264pred_neon.S | 369 -
 2 files changed, 402 insertions(+), 7 deletions(-)

diff --git a/libavcodec/aarch64/h264pred_init.c 
b/libavcodec/aarch64/h264pred_init.c
index 325a86bfcd..0ae8f70d23 100644
--- a/libavcodec/aarch64/h264pred_init.c
+++ b/libavcodec/aarch64/h264pred_init.c
@@ -45,10 +45,23 @@ void ff_pred8x8_0lt_dc_neon(uint8_t *src, ptrdiff_t stride);
 void ff_pred8x8_l00_dc_neon(uint8_t *src, ptrdiff_t stride);
 void ff_pred8x8_0l0_dc_neon(uint8_t *src, ptrdiff_t stride);
 
-void ff_pred16x16_top_dc_neon_10(uint8_t *src, ptrdiff_t stride);
-void ff_pred16x16_dc_neon_10(uint8_t *src, ptrdiff_t stride);
-void ff_pred16x16_hor_neon_10(uint8_t *src, ptrdiff_t stride);
 void ff_pred16x16_vert_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred16x16_hor_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred16x16_plane_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred16x16_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred16x16_top_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+
+void ff_pred8x8_vert_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_hor_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_plane_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_128_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_left_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_top_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_l0t_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_0lt_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_l00_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_0l0_dc_neon_10(uint8_t *src, ptrdiff_t stride);
 
 static av_cold void h264_pred_init_neon(H264PredContext *h, int codec_id,
 const int bit_depth,
@@ -84,10 +97,31 @@ static av_cold void h264_pred_init_neon(H264PredContext *h, 
int codec_id,
 h->pred16x16[PLANE_PRED8x8  ] = ff_pred16x16_plane_neon;
 }
 if (bit_depth == 10) {
+if (chroma_format_idc <= 1) {
+h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vert_neon_10;
+h->pred8x8[HOR_PRED8x8  ] = ff_pred8x8_hor_neon_10;
+if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8)
+h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_neon_10;
+h->pred8x8[DC_128_PRED8x8   ] = ff_pred8x8_128_dc_neon_10;
+if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 &&
+codec_id != AV_CODEC_ID_VP8) {
+h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_neon_10;
+h->pred8x8[LEFT_DC_PRED8x8] = ff_pred8x8_left_dc_neon_10;
+h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_neon_10;
+h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] = 
ff_pred8x8_l0t_dc_neon_10;
+h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] = 
ff_pred8x8_0lt_dc_neon_10;
+h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] = 
ff_pred8x8_l00_dc_neon_10;
+h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] = 
ff_pred8x8_0l0_dc_neon_10;
+}
+}
+
 h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_neon_10;
 h->pred16x16[VERT_PRED8x8   ] = ff_pred16x16_vert_neon_10;
 h->pred16x16[HOR_PRED8x8] = ff_pred16x16_hor_neon_10;
 h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon_10;
+if (codec_id != AV_CODEC_ID_SVQ3 && codec_id != AV_CODEC_ID_RV40 &&
+codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8)
+h->pred16x16[PLANE_PRED8x8  ] = ff_pred16x16_plane_neon_10;
 }
 }
 

Re: [FFmpeg-devel] [PATCH 1/2] libavutil/cpu: Adds fast gather detection.

2021-07-16 Thread Alan Kelly
On Fri, Jul 16, 2021 at 4:02 PM James Almer  wrote:

> On 7/16/2021 10:44 AM, Alan Kelly wrote:
> > Broadwell and later and Zen3 and later have fast gather instructions.
> > ---
> >   Haswell is now excluded from EXTERNAL_AVX2_FAST as discussed in the
> >   email thread.
>
> I was very explicit about this not being ok. We're not disabling all ymm
> usage for Haswell just for one or two swscale functions using gathers.
>
> Lets go with Lynne's latest suggestion and not change the flags at all
> and use gathers on Haswell, same as other arches, by looking at the
> AVX2_FAST flag.
>
> >   libavutil/cpu.h |  1 +
> >   libavutil/x86/cpu.c | 11 ++-
> >   2 files changed, 11 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavutil/cpu.h b/libavutil/cpu.h
> > index c069076439..ec3073d021 100644
> > --- a/libavutil/cpu.h
> > +++ b/libavutil/cpu.h
> > @@ -113,6 +113,7 @@ void av_force_cpu_count(int count);
> >*  av_set_cpu_flags_mask(), then this function will behave as if AVX
> is not
> >*  present.
> >*/
> > +
> >   size_t av_cpu_max_align(void);
> >
> >   #endif /* AVUTIL_CPU_H */
> > diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
> > index bcd41a50a2..158e2170c4 100644
> > --- a/libavutil/x86/cpu.c
> > +++ b/libavutil/x86/cpu.c
> > @@ -146,8 +146,17 @@ int ff_get_cpu_flags_x86(void)
> >   if (max_std_level >= 7) {
> >   cpuid(7, eax, ebx, ecx, edx);
> >   #if HAVE_AVX2
> > -if ((rval & AV_CPU_FLAG_AVX) && (ebx & 0x0020))
> > +if ((rval & AV_CPU_FLAG_AVX) && (ebx & 0x0020)){
> >   rval |= AV_CPU_FLAG_AVX2;
> > +
> > +cpuid(1, eax, ebx, ecx, std_caps);
> > +family = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
> > +model  = ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0);
> > +// Haswell and earlier has slow gather
> > +if(family == 6 && model < 70)
> > +rval |= AV_CPU_FLAG_AVXSLOW;
> > +}
> > +
> >   #if HAVE_AVX512 /* F, CD, BW, DQ, VL */
> >   if ((xcr0_lo & 0xe0) == 0xe0) { /* OPMASK/ZMM state */
> >   if ((rval & AV_CPU_FLAG_AVX2) && (ebx & 0xd003) ==
> 0xd003)
> >
>
> ___
> 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".
>

OK, apologies for the misunderstanding. In that case part 1 of this patch
is not required. Part two remains valid with the function protected by
EXTERNAL_AVX2_FAST. Should part 2 be re-submitted as a standalone patch or
is it OK as is?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/2] libavutil/cpu: Adds fast gather detection.

2021-07-16 Thread James Almer

On 7/16/2021 11:46 AM, Alan Kelly wrote:

On Fri, Jul 16, 2021 at 4:02 PM James Almer  wrote:


On 7/16/2021 10:44 AM, Alan Kelly wrote:

Broadwell and later and Zen3 and later have fast gather instructions.
---
   Haswell is now excluded from EXTERNAL_AVX2_FAST as discussed in the
   email thread.


I was very explicit about this not being ok. We're not disabling all ymm
usage for Haswell just for one or two swscale functions using gathers.

Lets go with Lynne's latest suggestion and not change the flags at all
and use gathers on Haswell, same as other arches, by looking at the
AVX2_FAST flag.


   libavutil/cpu.h |  1 +
   libavutil/x86/cpu.c | 11 ++-
   2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavutil/cpu.h b/libavutil/cpu.h
index c069076439..ec3073d021 100644
--- a/libavutil/cpu.h
+++ b/libavutil/cpu.h
@@ -113,6 +113,7 @@ void av_force_cpu_count(int count);
*  av_set_cpu_flags_mask(), then this function will behave as if AVX

is not

*  present.
*/
+
   size_t av_cpu_max_align(void);

   #endif /* AVUTIL_CPU_H */
diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
index bcd41a50a2..158e2170c4 100644
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -146,8 +146,17 @@ int ff_get_cpu_flags_x86(void)
   if (max_std_level >= 7) {
   cpuid(7, eax, ebx, ecx, edx);
   #if HAVE_AVX2
-if ((rval & AV_CPU_FLAG_AVX) && (ebx & 0x0020))
+if ((rval & AV_CPU_FLAG_AVX) && (ebx & 0x0020)){
   rval |= AV_CPU_FLAG_AVX2;
+
+cpuid(1, eax, ebx, ecx, std_caps);
+family = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
+model  = ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0);
+// Haswell and earlier has slow gather
+if(family == 6 && model < 70)
+rval |= AV_CPU_FLAG_AVXSLOW;
+}
+
   #if HAVE_AVX512 /* F, CD, BW, DQ, VL */
   if ((xcr0_lo & 0xe0) == 0xe0) { /* OPMASK/ZMM state */
   if ((rval & AV_CPU_FLAG_AVX2) && (ebx & 0xd003) ==

0xd003)




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



OK, apologies for the misunderstanding. In that case part 1 of this patch
is not required. Part two remains valid with the function protected by
EXTERNAL_AVX2_FAST. Should part 2 be re-submitted as a standalone patch or
is it OK as is?


It's ok as is. Thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] avcodec/nvenc: fix flushing for encoder-reuse

2021-07-16 Thread Jai Luthra
Recent encode API restructure (827d6fe73d) removed some state - which broke 
the API for flushing without closing the encoder.

This functionality was originally added in 3ea7057677 and is useful for 
segmented video, where we don't want to do expensive re-init of HW sessions 
for every segment.

---
 libavcodec/nvenc.c | 16 +++-
 libavcodec/nvenc.h |  2 ++
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index dddee8cac1..8eeb955b59 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -2177,6 +2177,11 @@ static int nvenc_send_frame(AVCodecContext *avctx, const 
AVFrame *frame)
 return AVERROR(EINVAL);
 
 if (frame && frame->buf[0]) {
+if (ctx->encoder_flushing) {
+ctx->encoder_flushing = 0;
+av_fifo_reset(ctx->timestamp_list);
+}
+
 in_surf = get_free_frame(ctx);
 if (!in_surf)
 return AVERROR(EAGAIN);
@@ -2256,6 +2261,7 @@ static int nvenc_send_frame(AVCodecContext *avctx, const 
AVFrame *frame)
 nvenc_codec_specific_pic_params(avctx, &pic_params, sei_data, 
sei_count);
 } else {
 pic_params.encodePicFlags = NV_ENC_PIC_FLAG_EOS;
+ctx->encoder_flushing = 1;
 }
 
 res = nvenc_push_context(avctx);
@@ -2305,8 +2311,11 @@ int ff_nvenc_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 
 if (!frame->buf[0]) {
 res = ff_encode_get_frame(avctx, frame);
-if (res < 0 && res != AVERROR_EOF)
+if (res == AVERROR_EOF || (ctx->encoder_flushing && res == 
AVERROR(EAGAIN))) {
+// flushing mode, continue to send packets
+} else if (res < 0) {
 return res;
+}
 }
 
 res = nvenc_send_frame(avctx, frame);
@@ -2316,7 +2325,7 @@ int ff_nvenc_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 } else
 av_frame_unref(frame);
 
-if (output_ready(avctx, avctx->internal->draining)) {
+if (output_ready(avctx, ctx->encoder_flushing)) {
 av_fifo_generic_read(ctx->output_surface_ready_queue, &tmp_out_surf, 
sizeof(tmp_out_surf), NULL);
 
 res = nvenc_push_context(avctx);
@@ -2344,8 +2353,5 @@ int ff_nvenc_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 
 av_cold void ff_nvenc_encode_flush(AVCodecContext *avctx)
 {
-NvencContext *ctx = avctx->priv_data;
-
 nvenc_send_frame(avctx, NULL);
-av_fifo_reset(ctx->timestamp_list);
 }
diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
index fefc5f7f0b..be8194424e 100644
--- a/libavcodec/nvenc.h
+++ b/libavcodec/nvenc.h
@@ -166,6 +166,8 @@ typedef struct NvencContext
 AVFifoBuffer *output_surface_ready_queue;
 AVFifoBuffer *timestamp_list;
 
+int encoder_flushing;
+
 struct {
 void *ptr;
 int ptr_index;
-- 
2.32.0

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

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


[FFmpeg-devel] [PATCH v2] avcodec/nvenc: fix flushing for encoder-reuse

2021-07-16 Thread Jai Luthra
Recent encode API restructure (827d6fe73d) removed some state - which broke
the API for flushing without closing the encoder.

This functionality was originally added in 3ea7057677 and is useful for
segmented video, where we don't want to do expensive re-init of HW sessions
for every segment.
---
v2: Forgot to rebase off master in v1

 libavcodec/nvenc.c | 16 +++-
 libavcodec/nvenc.h |  2 ++
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index ee046b9cef..ee0beb4795 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -2281,6 +2281,11 @@ static int nvenc_send_frame(AVCodecContext *avctx, const 
AVFrame *frame)
 return AVERROR(EINVAL);
 
 if (frame && frame->buf[0]) {
+if (ctx->encoder_flushing) {
+ctx->encoder_flushing = 0;
+av_fifo_reset(ctx->timestamp_list);
+}
+
 in_surf = get_free_frame(ctx);
 if (!in_surf)
 return AVERROR(EAGAIN);
@@ -2335,6 +2340,7 @@ static int nvenc_send_frame(AVCodecContext *avctx, const 
AVFrame *frame)
 nvenc_codec_specific_pic_params(avctx, &pic_params, ctx->sei_data, 
sei_count);
 } else {
 pic_params.encodePicFlags = NV_ENC_PIC_FLAG_EOS;
+ctx->encoder_flushing = 1;
 }
 
 res = nvenc_push_context(avctx);
@@ -2384,8 +2390,11 @@ int ff_nvenc_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 
 if (!frame->buf[0]) {
 res = ff_encode_get_frame(avctx, frame);
-if (res < 0 && res != AVERROR_EOF)
+if (res == AVERROR_EOF || (ctx->encoder_flushing && res == 
AVERROR(EAGAIN))) {
+// flushing mode, continue to send packets
+} else if (res < 0) {
 return res;
+}
 }
 
 res = nvenc_send_frame(avctx, frame);
@@ -2395,7 +2404,7 @@ int ff_nvenc_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 } else
 av_frame_unref(frame);
 
-if (output_ready(avctx, avctx->internal->draining)) {
+if (output_ready(avctx, ctx->encoder_flushing)) {
 av_fifo_generic_read(ctx->output_surface_ready_queue, &tmp_out_surf, 
sizeof(tmp_out_surf), NULL);
 
 res = nvenc_push_context(avctx);
@@ -2423,8 +2432,5 @@ int ff_nvenc_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 
 av_cold void ff_nvenc_encode_flush(AVCodecContext *avctx)
 {
-NvencContext *ctx = avctx->priv_data;
-
 nvenc_send_frame(avctx, NULL);
-av_fifo_reset(ctx->timestamp_list);
 }
diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
index 85d3a33601..6af3aaf0ce 100644
--- a/libavcodec/nvenc.h
+++ b/libavcodec/nvenc.h
@@ -169,6 +169,8 @@ typedef struct NvencContext
 NV_ENC_SEI_PAYLOAD *sei_data;
 int sei_data_size;
 
+int encoder_flushing;
+
 struct {
 void *ptr;
 int ptr_index;
-- 
2.32.0

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

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


Re: [FFmpeg-devel] [PATCH 2/8] FATE: add a test for sliced scaling

2021-07-16 Thread Michael Niedermayer
On Mon, Jul 12, 2021 at 01:07:03PM +0200, Anton Khirnov wrote:
> ---
>  Makefile  |   2 +
>  tests/Makefile|   1 +
>  tests/fate/libswscale.mak |  11 +++
>  tools/Makefile|   3 +-
>  tools/scale_slice_test.c  | 190 ++
>  5 files changed, 206 insertions(+), 1 deletion(-)
>  create mode 100644 tools/scale_slice_test.c

more testing is always good

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Whats the most studid thing your enemy could do ? Blow himself up
Whats the most studid thing you could do ? Give up your rights and
freedom because your enemy blew himself up.



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

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


Re: [FFmpeg-devel] [PATCH v2] avcodec/nvenc: fix flushing for encoder-reuse

2021-07-16 Thread Timo Rothenpieler

On 16.07.2021 18:09, Jai Luthra wrote:

Recent encode API restructure (827d6fe73d) removed some state - which broke
the API for flushing without closing the encoder.

This functionality was originally added in 3ea7057677 and is useful for
segmented video, where we don't want to do expensive re-init of HW sessions
for every segment.
---
v2: Forgot to rebase off master in v1

  libavcodec/nvenc.c | 16 +++-
  libavcodec/nvenc.h |  2 ++
  2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index ee046b9cef..ee0beb4795 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -2281,6 +2281,11 @@ static int nvenc_send_frame(AVCodecContext *avctx, const 
AVFrame *frame)
  return AVERROR(EINVAL);
  
  if (frame && frame->buf[0]) {

+if (ctx->encoder_flushing) {
+ctx->encoder_flushing = 0;
+av_fifo_reset(ctx->timestamp_list);
+}
+
  in_surf = get_free_frame(ctx);
  if (!in_surf)
  return AVERROR(EAGAIN);
@@ -2335,6 +2340,7 @@ static int nvenc_send_frame(AVCodecContext *avctx, const 
AVFrame *frame)
  nvenc_codec_specific_pic_params(avctx, &pic_params, ctx->sei_data, 
sei_count);
  } else {
  pic_params.encodePicFlags = NV_ENC_PIC_FLAG_EOS;
+ctx->encoder_flushing = 1;
  }
  
  res = nvenc_push_context(avctx);

@@ -2384,8 +2390,11 @@ int ff_nvenc_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
  
  if (!frame->buf[0]) {

  res = ff_encode_get_frame(avctx, frame);
-if (res < 0 && res != AVERROR_EOF)
+if (res == AVERROR_EOF || (ctx->encoder_flushing && res == 
AVERROR(EAGAIN))) {
+// flushing mode, continue to send packets
+} else if (res < 0) {
  return res;
+}
  }
  
  res = nvenc_send_frame(avctx, frame);

@@ -2395,7 +2404,7 @@ int ff_nvenc_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
  } else
  av_frame_unref(frame);
  
-if (output_ready(avctx, avctx->internal->draining)) {

+if (output_ready(avctx, ctx->encoder_flushing)) {
  av_fifo_generic_read(ctx->output_surface_ready_queue, &tmp_out_surf, 
sizeof(tmp_out_surf), NULL);
  
  res = nvenc_push_context(avctx);

@@ -2423,8 +2432,5 @@ int ff_nvenc_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
  
  av_cold void ff_nvenc_encode_flush(AVCodecContext *avctx)

  {
-NvencContext *ctx = avctx->priv_data;
-
  nvenc_send_frame(avctx, NULL);
-av_fifo_reset(ctx->timestamp_list);
  }


Is it really correct for this to do absolutely nothing now?


diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
index 85d3a33601..6af3aaf0ce 100644
--- a/libavcodec/nvenc.h
+++ b/libavcodec/nvenc.h
@@ -169,6 +169,8 @@ typedef struct NvencContext
  NV_ENC_SEI_PAYLOAD *sei_data;
  int sei_data_size;
  
+int encoder_flushing;

+
  struct {
  void *ptr;
  int ptr_index;



Can you explain the logic this follows some more? I'm quite confused 
what exactly changed, and how it broke this.

How do you trigger a flush, if calling flush does nothing?



smime.p7s
Description: S/MIME Cryptographic Signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/3] avcodec: add a parser flag to enable keyframe tagging heuristics

2021-07-16 Thread Michael Niedermayer
On Thu, Jul 15, 2021 at 05:55:51PM -0300, James Almer wrote:
> On 7/15/2021 5:23 PM, Michael Niedermayer wrote:
> > On Wed, Jul 14, 2021 at 11:33:59AM -0300, James Almer wrote:
> > > It will be used to allow parsers to be more liberal when tagging packets 
> > > as
> > > keyframes.
> > > 
> > > Signed-off-by: James Almer 
> > > ---
> > >   libavcodec/avcodec.h | 1 +
> > >   1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > > index 8b97895aeb..8e3d888266 100644
> > > --- a/libavcodec/avcodec.h
> > > +++ b/libavcodec/avcodec.h
> > > @@ -2809,6 +2809,7 @@ typedef struct AVCodecParserContext {
> > >   #define PARSER_FLAG_ONCE  0x0002
> > >   /// Set if the parser has a valid file offset
> > >   #define PARSER_FLAG_FETCHED_OFFSET0x0004
> > > +#define PARSER_FLAG_USE_KEYFRAME_HEURISTICS   0x0008
> > >   #define PARSER_FLAG_USE_CODEC_TS  0x1000
> > 
> > This doesnt "feel" like the best solution to me
> > 
> > dont you think it would be better to export all information ?
> 
> The AVParser API is going to be removed at some point for something better
> that works on packets rather than raw buffers, so ideally we should not
> expand it too much, and leave more complex implementations for later.

Iam not sure i follow your logic here

do you suggest to block setting lets call it "advanced keyframe" related work
across the codebase ? (that includes muxers and so on ?
Iam not saying thats a good or bad idea. Just trying to understand

Because to me it seems if the awnser is no to the question above
then this is not just about "Adding a flag is the simplest way to fix this"
but its adding codec specific code in muxers probably to extract the exta
information, and iam not sure that at this point its not easier to have
the parser export this information

And when the parser API is then replaced by "something better" the interface
changes less. If this heuristic flag is added then i assume it needs to be
removed and reimplemented with the API change.

I very likely am missing something
But i certainly do not suggest or ask for more work to be done. Rather the
opposit, i was wondering if its not less work overall to export the
information properly ...

thx

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

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


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

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


[FFmpeg-devel] [PATCH 3/4] libavformat/hls: add support for decryption of HLS media segments encrypted using SAMPLE-AES encryption method

2021-07-16 Thread Nachiket Tarate
Apple HTTP Live Streaming Sample Encryption:

https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption

Signed-off-by: Nachiket Tarate 
---
 libavformat/Makefile|   2 +-
 libavformat/hls.c   | 128 +++--
 libavformat/hls_sample_encryption.c | 389 
 libavformat/hls_sample_encryption.h |  65 +
 libavformat/mpegts.c|  11 +
 5 files changed, 576 insertions(+), 19 deletions(-)
 create mode 100644 libavformat/hls_sample_encryption.c
 create mode 100644 libavformat/hls_sample_encryption.h

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 813ddd3c20..7e3c9c23c6 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -238,7 +238,7 @@ OBJS-$(CONFIG_HCOM_DEMUXER)  += hcom.o pcm.o
 OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o
 OBJS-$(CONFIG_HEVC_DEMUXER)  += hevcdec.o rawdec.o
 OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
-OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o
+OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o hls_sample_encryption.o
 OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o
 OBJS-$(CONFIG_HNM_DEMUXER)   += hnm.o
 OBJS-$(CONFIG_ICO_DEMUXER)   += icodec.o
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 3c1b80f60c..022dae0391 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -2,6 +2,7 @@
  * Apple HTTP Live Streaming demuxer
  * Copyright (c) 2010 Martin Storsjo
  * Copyright (c) 2013 Anssi Hannula
+ * Copyright (c) 2021 Nachiket Tarate
  *
  * This file is part of FFmpeg.
  *
@@ -39,6 +40,8 @@
 #include "avio_internal.h"
 #include "id3v2.h"
 
+#include "hls_sample_encryption.h"
+
 #define INITIAL_BUFFER_SIZE 32768
 
 #define MAX_FIELD_LEN 64
@@ -145,6 +148,8 @@ struct playlist {
 int id3_changed; /* ID3 tag data has changed at some point */
 ID3v2ExtraMeta *id3_deferred_extra; /* stored here until subdemuxer is 
opened */
 
+HLSAudioSetupInfo audio_setup_info;
+
 int64_t seek_timestamp;
 int seek_flags;
 int seek_stream_index; /* into subdemuxer stream array */
@@ -214,6 +219,7 @@ typedef struct HLSContext {
 int http_multiple;
 int http_seekable;
 AVIOContext *playlist_pb;
+HLSCryptoContext  crypto_ctx;
 } HLSContext;
 
 static void free_segment_dynarray(struct segment **segments, int n_segments)
@@ -1006,7 +1012,10 @@ fail:
 
 static struct segment *current_segment(struct playlist *pls)
 {
-return pls->segments[pls->cur_seq_no - pls->start_seq_no];
+int64_t n = pls->cur_seq_no - pls->start_seq_no;
+if (n >= pls->n_segments)
+return NULL;
+return pls->segments[n];
 }
 
 static struct segment *next_segment(struct playlist *pls)
@@ -1035,17 +1044,18 @@ static int read_from_url(struct playlist *pls, struct 
segment *seg,
 
 /* Parse the raw ID3 data and pass contents to caller */
 static void parse_id3(AVFormatContext *s, AVIOContext *pb,
-  AVDictionary **metadata, int64_t *dts,
+  AVDictionary **metadata, int64_t *dts, HLSAudioSetupInfo 
*audio_setup_info,
   ID3v2ExtraMetaAPIC **apic, ID3v2ExtraMeta **extra_meta)
 {
 static const char id3_priv_owner_ts[] = 
"com.apple.streaming.transportStreamTimestamp";
+static const char id3_priv_owner_audio_setup[] = 
"com.apple.streaming.audioDescription";
 ID3v2ExtraMeta *meta;
 
 ff_id3v2_read_dict(pb, metadata, ID3v2_DEFAULT_MAGIC, extra_meta);
 for (meta = *extra_meta; meta; meta = meta->next) {
 if (!strcmp(meta->tag, "PRIV")) {
 ID3v2ExtraMetaPRIV *priv = &meta->data.priv;
-if (priv->datasize == 8 && !strcmp(priv->owner, 
id3_priv_owner_ts)) {
+if (priv->datasize == 8 && !av_strncasecmp(priv->owner, 
id3_priv_owner_ts, 44)) {
 /* 33-bit MPEG timestamp */
 int64_t ts = AV_RB64(priv->data);
 av_log(s, AV_LOG_DEBUG, "HLS ID3 audio timestamp %"PRId64"\n", 
ts);
@@ -1053,6 +1063,8 @@ static void parse_id3(AVFormatContext *s, AVIOContext *pb,
 *dts = ts;
 else
 av_log(s, AV_LOG_ERROR, "Invalid HLS ID3 audio timestamp 
%"PRId64"\n", ts);
+} else if (priv->datasize >= 8 && !av_strncasecmp(priv->owner, 
id3_priv_owner_audio_setup, 36)) {
+ff_hls_senc_read_audio_setup_info(audio_setup_info, 
priv->data, priv->datasize);
 }
 } else if (!strcmp(meta->tag, "APIC") && apic)
 *apic = &meta->data.apic;
@@ -1096,7 +1108,7 @@ static void handle_id3(AVIOContext *pb, struct playlist 
*pls)
 ID3v2ExtraMeta *extra_meta = NULL;
 int64_t timestamp = AV_NOPTS_VALUE;
 
-parse_id3(pls->ctx, pb, &metadata, ×tamp, &apic, &extra_meta);
+parse_id3(pls->ctx, pb, &metadata, ×tamp, &pls->audio_setup_info, 
&apic, &extra_meta);
 
 if (timestamp != AV_NOPTS_VALUE) {
 pls-

Re: [FFmpeg-devel] [PATCH v2] avcodec/nvenc: fix flushing for encoder-reuse

2021-07-16 Thread Jai Luthra
On Fri, Jul 16, 2021, at 10:06 PM, Timo Rothenpieler wrote:

-- snip --

> Can you explain the logic this follows some more? I'm quite confused 
> what exactly changed, and how it broke this.
> How do you trigger a flush, if calling flush does nothing?

Since https://github.com/ffmpeg/ffmpeg/commit/3ea7057677 it was possible to 
flush nvenc buffers without sending a NULL frame like:

// trigger ff_nvenc_encode_flush which will send a NULL frame internally
// this doesn't set avctx->internal->draining
avcodec_flush_buffers(encoder) 

// get remaining packets out of the buffer
while ... {
avcodec_receive_packet(encoder, &pkt)
}

// whenever next segment comes in, reuse encoder without closing & re-opening
avcodec_send_frame(encoder, frame)

But after the recent API changes [1] if someone tries to fetch packets after 
calling avcodec_flush_buffers() they won't receive any and hit EAGAIN.

As the user ran out of frames to encode, no frame is present at 
avctx->internal->buffer_frame - and avctx->internal->draining is unset because 
the user didn't want to send a NULL frame. So ff_encode_get_frame returns 
EAGAIN, which is what the user gets without these changes:

> > @@ -2384,8 +2390,11 @@ int ff_nvenc_receive_packet(AVCodecContext *avctx, 
> > AVPacket *pkt)
> >   
> >   if (!frame->buf[0]) {
> >   res = ff_encode_get_frame(avctx, frame);
> > -if (res < 0 && res != AVERROR_EOF)
> > +if (res == AVERROR_EOF || (ctx->encoder_flushing && res == 
> > AVERROR(EAGAIN))) {
> > +// flushing mode, continue to send packets
> > +} else if (res < 0) {
> >   return res;
> > +}
> >   }



> >   
> >   av_cold void ff_nvenc_encode_flush(AVCodecContext *avctx)
> >   {
> > -NvencContext *ctx = avctx->priv_data;
> > -
> >   nvenc_send_frame(avctx, NULL);
> > -av_fifo_reset(ctx->timestamp_list);
> >   }
> 
> Is it really correct for this to do absolutely nothing now?

It's still sending the NULL frame internally - which will mark encoder_flushing 
as 1 here:

> > @@ -2335,6 +2340,7 @@ static int nvenc_send_frame(AVCodecContext *avctx, 
> > const AVFrame *frame)
> >   nvenc_codec_specific_pic_params(avctx, &pic_params, 
> > ctx->sei_data, sei_count);
> >   } else {
> >   pic_params.encodePicFlags = NV_ENC_PIC_FLAG_EOS;
> > +ctx->encoder_flushing = 1;

We don't wanna cleanup ctx->timestamp_list until the user has retrieved all 
packets from the buffer after triggering a flush.

[1]: 
https://github.com/ffmpeg/ffmpeg/commit/827d6fe73d#diff-ba8b555333cbe9c4d768147d8a7abb152281257770aa314cc057a31f43460fec
 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 1/4] libavcodec/adts_header: add frame_length field and avpriv function to parse AAC ADTS header

2021-07-16 Thread Nachiket Tarate
These will be used by HLS demuxer in case of sample decryption.

Signed-off-by: Nachiket Tarate 
---
 libavcodec/adts_header.c |  1 +
 libavcodec/adts_header.h | 14 ++
 libavcodec/adts_parser.c | 28 
 3 files changed, 43 insertions(+)

diff --git a/libavcodec/adts_header.c b/libavcodec/adts_header.c
index 0889820f8a..e4454529c4 100644
--- a/libavcodec/adts_header.c
+++ b/libavcodec/adts_header.c
@@ -66,6 +66,7 @@ int ff_adts_header_parse(GetBitContext *gbc, 
AACADTSHeaderInfo *hdr)
 hdr->sample_rate= avpriv_mpeg4audio_sample_rates[sr];
 hdr->samples= (rdb + 1) * 1024;
 hdr->bit_rate   = size * 8 * hdr->sample_rate / hdr->samples;
+hdr->frame_length   = size;
 
 return size;
 }
diff --git a/libavcodec/adts_header.h b/libavcodec/adts_header.h
index f615f6a9f9..9ecd67fb5b 100644
--- a/libavcodec/adts_header.h
+++ b/libavcodec/adts_header.h
@@ -34,6 +34,7 @@ typedef struct AACADTSHeaderInfo {
 uint8_t  sampling_index;
 uint8_t  chan_config;
 uint8_t  num_aac_frames;
+uint32_t frame_length;
 } AACADTSHeaderInfo;
 
 /**
@@ -47,4 +48,17 @@ typedef struct AACADTSHeaderInfo {
  */
 int ff_adts_header_parse(GetBitContext *gbc, AACADTSHeaderInfo *hdr);
 
+/**
+ * Parse the ADTS frame header contained in the buffer, which is
+ * the first 54 bits.
+ * @param[in]  buf  Pointer to buffer containing the first 54 bits of the 
frame.
+ * @param[in]  size Size of buffer containing the first 54 bits of the frame.
+ * @param[out] phdr Pointer to pointer to struct AACADTSHeaderInfo for which
+ * memory is allocated and header info is written into it.
+ * @return Returns 0 on success, -1 if there is a sync word mismatch,
+ * -2 if the version element is invalid, -3 if the sample rate
+ * element is invalid, or -4 if the bit rate element is invalid.
+ */
+int avpriv_adts_header_parse(AACADTSHeaderInfo **phdr, const uint8_t *buf, 
size_t size);
+
 #endif /* AVCODEC_ADTS_HEADER_H */
diff --git a/libavcodec/adts_parser.c b/libavcodec/adts_parser.c
index 5c9f8ff6f2..7df714e227 100644
--- a/libavcodec/adts_parser.c
+++ b/libavcodec/adts_parser.c
@@ -42,3 +42,31 @@ int av_adts_header_parse(const uint8_t *buf, uint32_t 
*samples, uint8_t *frames)
 return AVERROR(ENOSYS);
 #endif
 }
+
+int avpriv_adts_header_parse(AACADTSHeaderInfo **phdr, const uint8_t *buf, 
size_t size)
+{
+#if CONFIG_ADTS_HEADER
+int ret = 0;
+GetBitContext gb;
+
+if (size < AV_AAC_ADTS_HEADER_SIZE)
+return AVERROR_INVALIDDATA;
+
+if (!*phdr)
+*phdr = av_mallocz(sizeof(AACADTSHeaderInfo));
+if (!*phdr)
+return AVERROR(ENOMEM);
+
+ret = init_get_bits8(&gb, buf, AV_AAC_ADTS_HEADER_SIZE);
+if (ret < 0)
+return ret;
+
+ret = ff_adts_header_parse(&gb, *phdr);
+if (ret < 0)
+return ret;
+
+return 0;
+#else
+return AVERROR(ENOSYS);
+#endif
+}
-- 
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 4/4] libavformat/hls: correct indentation

2021-07-16 Thread Nachiket Tarate
Signed-off-by: Nachiket Tarate 
---
 libavformat/hls.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 022dae0391..7e457281f4 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -2051,23 +2051,23 @@ static int hls_read_header(AVFormatContext *s)
 if (in_fmt->raw_codec_id == pls->audio_setup_info.codec_id)
 break;
 } else {
-pls->ctx->probesize = s->probesize > 0 ? s->probesize : 1024 * 4;
-pls->ctx->max_analyze_duration = s->max_analyze_duration > 0 ? 
s->max_analyze_duration : 4 * AV_TIME_BASE;
-pls->ctx->interrupt_callback = s->interrupt_callback;
-url = av_strdup(pls->segments[0]->url);
-ret = av_probe_input_buffer(&pls->pb, &in_fmt, url, NULL, 0, 0);
-if (ret < 0) {
-/* Free the ctx - it isn't initialized properly at this point,
- * so avformat_close_input shouldn't be called. If
- * avformat_open_input fails below, it frees and zeros the
- * context, so it doesn't need any special treatment like this. */
-av_log(s, AV_LOG_ERROR, "Error when loading first segment '%s'\n", 
url);
-avformat_free_context(pls->ctx);
-pls->ctx = NULL;
+pls->ctx->probesize = s->probesize > 0 ? s->probesize : 1024 * 4;
+pls->ctx->max_analyze_duration = s->max_analyze_duration > 0 ? 
s->max_analyze_duration : 4 * AV_TIME_BASE;
+pls->ctx->interrupt_callback = s->interrupt_callback;
+url = av_strdup(pls->segments[0]->url);
+ret = av_probe_input_buffer(&pls->pb, &in_fmt, url, NULL, 0, 0);
+if (ret < 0) {
+/* Free the ctx - it isn't initialized properly at this point,
+* so avformat_close_input shouldn't be called. If
+* avformat_open_input fails below, it frees and zeros the
+* context, so it doesn't need any special treatment like this. 
*/
+av_log(s, AV_LOG_ERROR, "Error when loading first segment 
'%s'\n", url);
+avformat_free_context(pls->ctx);
+pls->ctx = NULL;
+av_free(url);
+return ret;
+}
 av_free(url);
-return ret;
-}
-av_free(url);
 }
 
 if (seg && seg->key_type == KEY_SAMPLE_AES) {
@@ -2121,7 +2121,7 @@ static int hls_read_header(AVFormatContext *s)
 pls->ctx->nb_streams == 1)
 ret = ff_hls_senc_parse_audio_setup_info(pls->ctx->streams[0], 
&pls->audio_setup_info);
 else
-ret = avformat_find_stream_info(pls->ctx, NULL);
+ret = avformat_find_stream_info(pls->ctx, NULL);
 
 if (ret < 0)
 return ret;
-- 
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 1/2] lavc/aarch64: move transpose_4x8H to neon.S

2021-07-16 Thread Mikhail Nitenko
transpose_4x8H was declared in vp9lpf_16bpp_neon, however this macro is
not unique to vp9 and could be used elsewhere.

Signed-off-by: Mikhail Nitenko 
---
 libavcodec/aarch64/neon.S  | 13 +
 libavcodec/aarch64/vp9lpf_16bpp_neon.S | 12 
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/libavcodec/aarch64/neon.S b/libavcodec/aarch64/neon.S
index 0fddbecae3..1ad32c359d 100644
--- a/libavcodec/aarch64/neon.S
+++ b/libavcodec/aarch64/neon.S
@@ -109,12 +109,25 @@
 trn2\r5\().4H,  \r0\().4H,  \r1\().4H
 trn1\r6\().4H,  \r2\().4H,  \r3\().4H
 trn2\r7\().4H,  \r2\().4H,  \r3\().4H
+
 trn1\r0\().2S,  \r4\().2S,  \r6\().2S
 trn2\r2\().2S,  \r4\().2S,  \r6\().2S
 trn1\r1\().2S,  \r5\().2S,  \r7\().2S
 trn2\r3\().2S,  \r5\().2S,  \r7\().2S
 .endm
 
+.macro transpose_4x8H r0, r1, r2, r3, t4, t5, t6, t7
+trn1\t4\().8H,  \r0\().8H,  \r1\().8H
+trn2\t5\().8H,  \r0\().8H,  \r1\().8H
+trn1\t6\().8H,  \r2\().8H,  \r3\().8H
+trn2\t7\().8H,  \r2\().8H,  \r3\().8H
+
+trn1\r0\().4S,  \t4\().4S,  \t6\().4S
+trn2\r2\().4S,  \t4\().4S,  \t6\().4S
+trn1\r1\().4S,  \t5\().4S,  \t7\().4S
+trn2\r3\().4S,  \t5\().4S,  \t7\().4S
+.endm
+
 .macro  transpose_8x8H  r0, r1, r2, r3, r4, r5, r6, r7, r8, r9
 trn1\r8\().8H,  \r0\().8H,  \r1\().8H
 trn2\r9\().8H,  \r0\().8H,  \r1\().8H
diff --git a/libavcodec/aarch64/vp9lpf_16bpp_neon.S 
b/libavcodec/aarch64/vp9lpf_16bpp_neon.S
index 9075f3d406..9869614a29 100644
--- a/libavcodec/aarch64/vp9lpf_16bpp_neon.S
+++ b/libavcodec/aarch64/vp9lpf_16bpp_neon.S
@@ -22,18 +22,6 @@
 #include "neon.S"
 
 
-.macro transpose_4x8H r0, r1, r2, r3, t4, t5, t6, t7
-trn1\t4\().8h,  \r0\().8h,  \r1\().8h
-trn2\t5\().8h,  \r0\().8h,  \r1\().8h
-trn1\t6\().8h,  \r2\().8h,  \r3\().8h
-trn2\t7\().8h,  \r2\().8h,  \r3\().8h
-
-trn1\r0\().4s,  \t4\().4s,  \t6\().4s
-trn2\r2\().4s,  \t4\().4s,  \t6\().4s
-trn1\r1\().4s,  \t5\().4s,  \t7\().4s
-trn2\r3\().4s,  \t5\().4s,  \t7\().4s
-.endm
-
 // The input to and output from this macro is in the registers v16-v31,
 // and v0-v7 are used as scratch registers.
 // p7 = v16 .. p3 = v20, p0 = v23, q0 = v24, q3 = v27, q7 = v31
-- 
2.32.0

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

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


[FFmpeg-devel] [PATCH 2/2] lavc/aarch64: h264, add chroma loop filters for 10bit

2021-07-16 Thread Mikhail Nitenko
Benchmarks: A53A72
h264_h_loop_filter_chroma422_10bpp_c:  293.0  116.7
h264_h_loop_filter_chroma422_10bpp_neon:   283.7  126.2
h264_h_loop_filter_chroma_10bpp_c: 165.2   58.5
h264_h_loop_filter_chroma_10bpp_neon:   74.7   87.2
h264_h_loop_filter_chroma_intra422_10bpp_c:246.2  124.5
h264_h_loop_filter_chroma_intra422_10bpp_neon: 178.7   70.0
h264_h_loop_filter_chroma_intra_10bpp_c:   121.0   40.5
h264_h_loop_filter_chroma_intra_10bpp_neon: 73.7   59.2
h264_h_loop_filter_chroma_mbaff422_10bpp_c:145.7   72.7
h264_h_loop_filter_chroma_mbaff422_10bpp_neon: 151.7   87.2
h264_h_loop_filter_chroma_mbaff_intra422_10bpp_c:  117.5   48.0
h264_h_loop_filter_chroma_mbaff_intra422_10bpp_neon:73.7   37.7
h264_h_loop_filter_chroma_mbaff_intra_10bpp_c:  57.0   27.7
h264_h_loop_filter_chroma_mbaff_intra_10bpp_neon:   81.7   50.7
h264_h_loop_filter_luma_intra_8bpp_c:  242.7  134.0
h264_h_loop_filter_luma_intra_8bpp_neon:   100.7   53.5
h264_v_loop_filter_chroma_10bpp_c: 257.2  138.5
h264_v_loop_filter_chroma_10bpp_neon:   98.2   67.5
h264_v_loop_filter_chroma_intra_10bpp_c:   158.0   76.2
h264_v_loop_filter_chroma_intra_10bpp_neon: 62.7   36.5

Signed-off-by: Mikhail Nitenko 
---

this code is a bit slow, particularly the horizontal versions, so any
suggestions are greatly appreciated!

 libavcodec/aarch64/h264dsp_init_aarch64.c |  29 +++
 libavcodec/aarch64/h264dsp_neon.S | 299 ++
 2 files changed, 328 insertions(+)

diff --git a/libavcodec/aarch64/h264dsp_init_aarch64.c 
b/libavcodec/aarch64/h264dsp_init_aarch64.c
index d5baccf235..9ee9c11e15 100644
--- a/libavcodec/aarch64/h264dsp_init_aarch64.c
+++ b/libavcodec/aarch64/h264dsp_init_aarch64.c
@@ -83,6 +83,21 @@ void ff_h264_idct8_add4_neon(uint8_t *dst, const int 
*block_offset,
  int16_t *block, int stride,
  const uint8_t nnzc[6*8]);
 
+void ff_h264_v_loop_filter_chroma_neon_10(uint8_t *pix, ptrdiff_t stride, int 
alpha,
+  int beta, int8_t *tc0);
+void ff_h264_h_loop_filter_chroma_neon_10(uint8_t *pix, ptrdiff_t stride, int 
alpha,
+  int beta, int8_t *tc0);
+void ff_h264_h_loop_filter_chroma422_neon_10(uint8_t *pix, ptrdiff_t stride, 
int alpha,
+ int beta, int8_t *tc0);
+void ff_h264_v_loop_filter_chroma_intra_neon_10(uint8_t *pix, ptrdiff_t stride,
+int alpha, int beta);
+void ff_h264_h_loop_filter_chroma_intra_neon_10(uint8_t *pix, ptrdiff_t stride,
+int alpha, int beta);
+void ff_h264_h_loop_filter_chroma422_intra_neon_10(uint8_t *pix, ptrdiff_t 
stride,
+   int alpha, int beta);
+void ff_h264_h_loop_filter_chroma_mbaff_intra_neon_10(uint8_t *pix, ptrdiff_t 
stride,
+  int alpha, int beta);
+
 av_cold void ff_h264dsp_init_aarch64(H264DSPContext *c, const int bit_depth,
  const int chroma_format_idc)
 {
@@ -125,5 +140,19 @@ av_cold void ff_h264dsp_init_aarch64(H264DSPContext *c, 
const int bit_depth,
 c->h264_idct8_add   = ff_h264_idct8_add_neon;
 c->h264_idct8_dc_add= ff_h264_idct8_dc_add_neon;
 c->h264_idct8_add4  = ff_h264_idct8_add4_neon;
+} else if (have_neon(cpu_flags) && bit_depth == 10) {
+c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon_10;
+c->h264_v_loop_filter_chroma_intra = 
ff_h264_v_loop_filter_chroma_intra_neon_10;
+
+if (chroma_format_idc <= 1) {
+c->h264_h_loop_filter_chroma = 
ff_h264_h_loop_filter_chroma_neon_10;
+c->h264_h_loop_filter_chroma_intra = 
ff_h264_h_loop_filter_chroma_intra_neon_10;
+c->h264_h_loop_filter_chroma_mbaff_intra = 
ff_h264_h_loop_filter_chroma_mbaff_intra_neon_10;
+} else {
+c->h264_h_loop_filter_chroma = 
ff_h264_h_loop_filter_chroma422_neon_10;
+c->h264_h_loop_filter_chroma_mbaff = 
ff_h264_h_loop_filter_chroma_neon_10;
+c->h264_h_loop_filter_chroma_intra = 
ff_h264_h_loop_filter_chroma422_intra_neon_10;
+c->h264_h_loop_filter_chroma_mbaff_intra = 
ff_h264_h_loop_filter_chroma_intra_neon_10;
+}
 }
 }
diff --git a/libavcodec/aarch64/h264dsp_neon.S 
b/libavcodec/aarch64/h264dsp_neon.S
index fbb8ecc463..92e5afa524 100644
--- a/libavcodec/aarch64/h264dsp_neon.S
+++ b/libavcodec/aarch64/h264dsp_neon.S
@@ -827,3 +827,302 @@ endfunc
 weight_func 16
 weight_func 8
 weight_func 4
+
+.macro  h264_loop_fi

[FFmpeg-devel] [PATCH 2/4] libavformat/mov: add support for 'cens', 'cbc1' and 'cbcs' encryption schemes specified in Common Encryption (CENC) standard

2021-07-16 Thread Nachiket Tarate
correct implementation of 'cenc' encryption scheme to support decryption of 
partial cipher blocks at the end of subsamples

https://www.iso.org/standard/68042.html

Signed-off-by: Nachiket Tarate 
---
 libavformat/isom.h |   2 +
 libavformat/mov.c  | 246 +++--
 2 files changed, 242 insertions(+), 6 deletions(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index ac1b3f3d56..705813844f 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -237,6 +237,8 @@ typedef struct MOVStreamContext {
 int has_sidx;  // If there is an sidx entry for this stream.
 struct {
 struct AVAESCTR* aes_ctr;
+struct AVAES *aes_ctx;
+unsigned int frag_index_entry_base;
 unsigned int per_sample_iv_size;  // Either 0, 8, or 16.
 AVEncryptionInfo *default_encrypted_sample;
 MOVEncryptionIndex *encryption_index;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index a37a9cc917..0da1bc606f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -6577,15 +6577,150 @@ static int mov_read_dfla(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 return 0;
 }
 
-static int cenc_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo 
*sample, uint8_t *input, int size)
+static int cenc_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, 
AVEncryptionInfo *sample, uint8_t *input, int size)
 {
 int i, ret;
+int bytes_of_protected_data;
+int partially_encrypted_block_size;
+uint8_t *partially_encrypted_block;
+uint8_t block[16];
 
-if (sample->scheme != MKBETAG('c','e','n','c') || sample->crypt_byte_block 
!= 0 || sample->skip_byte_block != 0) {
-av_log(c->fc, AV_LOG_ERROR, "Only the 'cenc' encryption scheme is 
supported\n");
-return AVERROR_PATCHWELCOME;
+if (!sc->cenc.aes_ctr) {
+/* initialize the cipher */
+sc->cenc.aes_ctr = av_aes_ctr_alloc();
+if (!sc->cenc.aes_ctr) {
+return AVERROR(ENOMEM);
+}
+
+ret = av_aes_ctr_init(sc->cenc.aes_ctr, c->decryption_key);
+if (ret < 0) {
+return ret;
+}
+}
+
+av_aes_ctr_set_full_iv(sc->cenc.aes_ctr, sample->iv);
+
+if (!sample->subsample_count) {
+/* decrypt the whole packet */
+av_aes_ctr_crypt(sc->cenc.aes_ctr, input, input, size);
+return 0;
+}
+
+partially_encrypted_block_size = 0;
+
+for (i = 0; i < sample->subsample_count; i++) {
+if (sample->subsamples[i].bytes_of_clear_data + 
sample->subsamples[i].bytes_of_protected_data > size) {
+av_log(c->fc, AV_LOG_ERROR, "subsample size exceeds the packet 
size left\n");
+return AVERROR_INVALIDDATA;
+}
+
+/* skip the clear bytes */
+input += sample->subsamples[i].bytes_of_clear_data;
+size -= sample->subsamples[i].bytes_of_clear_data;
+
+/* decrypt the encrypted bytes */
+
+if (partially_encrypted_block_size != 0)
+{
+memcpy(block, partially_encrypted_block, 
partially_encrypted_block_size);
+memcpy(block+partially_encrypted_block_size, input, 
16-partially_encrypted_block_size);
+av_aes_ctr_crypt(sc->cenc.aes_ctr, block, block, 16);
+memcpy(partially_encrypted_block, block, 
partially_encrypted_block_size);
+memcpy(input, block+partially_encrypted_block_size, 
16-partially_encrypted_block_size);
+input += 16-partially_encrypted_block_size;
+size -= 16-partially_encrypted_block_size;
+bytes_of_protected_data = 
sample->subsamples[i].bytes_of_protected_data - 
(16-partially_encrypted_block_size);
+} else {
+bytes_of_protected_data = 
sample->subsamples[i].bytes_of_protected_data;
+}
+
+if (i < sample->subsample_count-1) {
+int num_of_encrypted_blocks = bytes_of_protected_data/16;
+partially_encrypted_block_size = bytes_of_protected_data%16;
+if (partially_encrypted_block_size != 0)
+partially_encrypted_block = input + 16*num_of_encrypted_blocks;
+av_aes_ctr_crypt(sc->cenc.aes_ctr, input, input, 
16*num_of_encrypted_blocks);
+} else {
+av_aes_ctr_crypt(sc->cenc.aes_ctr, input, input, 
bytes_of_protected_data);
+}
+
+input += bytes_of_protected_data;
+size -= bytes_of_protected_data;
+}
+
+if (size > 0) {
+av_log(c->fc, AV_LOG_ERROR, "leftover packet bytes after subsample 
processing\n");
+return AVERROR_INVALIDDATA;
+}
+
+return 0;
+}
+
+static int cbc1_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, 
AVEncryptionInfo *sample, uint8_t *input, int size)
+{
+int i, ret;
+int num_of_encrypted_blocks;
+uint8_t iv[16];
+
+if (!sc->cenc.aes_ctx) {
+/* initialize the cipher */
+sc->cenc.aes_ctx = av_aes_alloc();
+if (!sc->cenc.aes_ctx) {
+return AVERROR(ENOMEM);
+ 

Re: [FFmpeg-devel] [PATCH] libavformat/isom_tags.c: add ipcm to list of tags

2021-07-16 Thread Paul B Mahol
On Thu, Jul 15, 2021 at 2:48 AM Stephen Hutchinson  wrote:

> Fixes http://trac.ffmpeg.org/ticket/9219
> ---
>  libavformat/isom_tags.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
> index 1666b9d4a5..e2e589b658 100644
> --- a/libavformat/isom_tags.c
> +++ b/libavformat/isom_tags.c
> @@ -312,6 +312,8 @@ const AVCodecTag ff_codec_movaudio_tags[] = {
>  { AV_CODEC_ID_PCM_S16LE,   MKTAG('s', 'o', 'w', 't') },
>  { AV_CODEC_ID_PCM_S16BE,   MKTAG('l', 'p', 'c', 'm') },
>  { AV_CODEC_ID_PCM_S16LE,   MKTAG('l', 'p', 'c', 'm') },
> +{ AV_CODEC_ID_PCM_S24BE,   MKTAG('i', 'p', 'c', 'm') },
> +{ AV_CODEC_ID_PCM_S24LE,   MKTAG('i', 'p', 'c', 'm') },
>  { AV_CODEC_ID_PCM_S24BE,   MKTAG('i', 'n', '2', '4') },
>  { AV_CODEC_ID_PCM_S24LE,   MKTAG('i', 'n', '2', '4') },
>  { AV_CODEC_ID_PCM_S32BE,   MKTAG('i', 'n', '3', '2') },
> --
> 2.30.2
>
>
Dunno about LE part, but should be fine if tested with sample.


> ___
> 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 2/2] lavc/aarch64: h264, add chroma loop filters for 10bit

2021-07-16 Thread Lynne
16 Jul 2021, 19:56 by mnite...@gmail.com:

> Benchmarks: A53A72
> h264_h_loop_filter_chroma422_10bpp_c:  293.0  116.7
> h264_h_loop_filter_chroma422_10bpp_neon:   283.7  126.2
> h264_h_loop_filter_chroma_10bpp_c: 165.2   58.5
> h264_h_loop_filter_chroma_10bpp_neon:   74.7   87.2
> h264_h_loop_filter_chroma_intra422_10bpp_c:246.2  124.5
> h264_h_loop_filter_chroma_intra422_10bpp_neon: 178.7   70.0
> h264_h_loop_filter_chroma_intra_10bpp_c:   121.0   40.5
> h264_h_loop_filter_chroma_intra_10bpp_neon: 73.7   59.2
> h264_h_loop_filter_chroma_mbaff422_10bpp_c:145.7   72.7
> h264_h_loop_filter_chroma_mbaff422_10bpp_neon: 151.7   87.2
> h264_h_loop_filter_chroma_mbaff_intra422_10bpp_c:  117.5   48.0
> h264_h_loop_filter_chroma_mbaff_intra422_10bpp_neon:73.7   37.7
> h264_h_loop_filter_chroma_mbaff_intra_10bpp_c:  57.0   27.7
> h264_h_loop_filter_chroma_mbaff_intra_10bpp_neon:   81.7   50.7
> h264_h_loop_filter_luma_intra_8bpp_c:  242.7  134.0
> h264_h_loop_filter_luma_intra_8bpp_neon:   100.7   53.5
> h264_v_loop_filter_chroma_10bpp_c: 257.2  138.5
> h264_v_loop_filter_chroma_10bpp_neon:   98.2   67.5
> h264_v_loop_filter_chroma_intra_10bpp_c:   158.0   76.2
> h264_v_loop_filter_chroma_intra_10bpp_neon: 62.7   36.5
>
> Signed-off-by: Mikhail Nitenko 
> ---
>
> this code is a bit slow, particularly the horizontal versions, so any
> suggestions are greatly appreciated!
>
>  libavcodec/aarch64/h264dsp_init_aarch64.c |  29 +++
>  libavcodec/aarch64/h264dsp_neon.S | 299 ++
>  2 files changed, 328 insertions(+)
>
> diff --git a/libavcodec/aarch64/h264dsp_init_aarch64.c 
> b/libavcodec/aarch64/h264dsp_init_aarch64.c
> index d5baccf235..9ee9c11e15 100644
> --- a/libavcodec/aarch64/h264dsp_init_aarch64.c
> +++ b/libavcodec/aarch64/h264dsp_init_aarch64.c
> @@ -83,6 +83,21 @@ void ff_h264_idct8_add4_neon(uint8_t *dst, const int 
> *block_offset,
>  int16_t *block, int stride,
>  const uint8_t nnzc[6*8]);
>  
> +void ff_h264_v_loop_filter_chroma_neon_10(uint8_t *pix, ptrdiff_t stride, 
> int alpha,
> +  int beta, int8_t *tc0);
> +void ff_h264_h_loop_filter_chroma_neon_10(uint8_t *pix, ptrdiff_t stride, 
> int alpha,
> +  int beta, int8_t *tc0);
> +void ff_h264_h_loop_filter_chroma422_neon_10(uint8_t *pix, ptrdiff_t stride, 
> int alpha,
> + int beta, int8_t *tc0);
> +void ff_h264_v_loop_filter_chroma_intra_neon_10(uint8_t *pix, ptrdiff_t 
> stride,
> +int alpha, int beta);
> +void ff_h264_h_loop_filter_chroma_intra_neon_10(uint8_t *pix, ptrdiff_t 
> stride,
> +int alpha, int beta);
> +void ff_h264_h_loop_filter_chroma422_intra_neon_10(uint8_t *pix, ptrdiff_t 
> stride,
> +   int alpha, int beta);
> +void ff_h264_h_loop_filter_chroma_mbaff_intra_neon_10(uint8_t *pix, 
> ptrdiff_t stride,
> +  int alpha, int beta);
> +
>  av_cold void ff_h264dsp_init_aarch64(H264DSPContext *c, const int bit_depth,
>  const int chroma_format_idc)
>  {
> @@ -125,5 +140,19 @@ av_cold void ff_h264dsp_init_aarch64(H264DSPContext *c, 
> const int bit_depth,
>  c->h264_idct8_add   = ff_h264_idct8_add_neon;
>  c->h264_idct8_dc_add= ff_h264_idct8_dc_add_neon;
>  c->h264_idct8_add4  = ff_h264_idct8_add4_neon;
> +} else if (have_neon(cpu_flags) && bit_depth == 10) {
> +c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon_10;
> +c->h264_v_loop_filter_chroma_intra = 
> ff_h264_v_loop_filter_chroma_intra_neon_10;
> +
> +if (chroma_format_idc <= 1) {
> +c->h264_h_loop_filter_chroma = 
> ff_h264_h_loop_filter_chroma_neon_10;
> +c->h264_h_loop_filter_chroma_intra = 
> ff_h264_h_loop_filter_chroma_intra_neon_10;
> +c->h264_h_loop_filter_chroma_mbaff_intra = 
> ff_h264_h_loop_filter_chroma_mbaff_intra_neon_10;
> +} else {
> +c->h264_h_loop_filter_chroma = 
> ff_h264_h_loop_filter_chroma422_neon_10;
> +c->h264_h_loop_filter_chroma_mbaff = 
> ff_h264_h_loop_filter_chroma_neon_10;
> +c->h264_h_loop_filter_chroma_intra = 
> ff_h264_h_loop_filter_chroma422_intra_neon_10;
> +c->h264_h_loop_filter_chroma_mbaff_intra = 
> ff_h264_h_loop_filter_chroma_intra_neon_10;
> +}
>  }
>  }
> diff --git a/libavcodec/aarch64/h264dsp_neon.S 
> b/libavcodec/aarch64/h264dsp_neon.S
> index fbb8ecc463..92e5afa524 100644
> --- a/libavcodec/aarch64/h264dsp_neon.S
> +++ b/libavcodec/aarch64/h264dsp_neon.S
> @@ -827,3 +82

Re: [FFmpeg-devel] [PATCH 1/3] avcodec: add a parser flag to enable keyframe tagging heuristics

2021-07-16 Thread James Almer

On 7/16/2021 1:55 PM, Michael Niedermayer wrote:

On Thu, Jul 15, 2021 at 05:55:51PM -0300, James Almer wrote:

On 7/15/2021 5:23 PM, Michael Niedermayer wrote:

On Wed, Jul 14, 2021 at 11:33:59AM -0300, James Almer wrote:

It will be used to allow parsers to be more liberal when tagging packets as
keyframes.

Signed-off-by: James Almer 
---
   libavcodec/avcodec.h | 1 +
   1 file changed, 1 insertion(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 8b97895aeb..8e3d888266 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2809,6 +2809,7 @@ typedef struct AVCodecParserContext {
   #define PARSER_FLAG_ONCE  0x0002
   /// Set if the parser has a valid file offset
   #define PARSER_FLAG_FETCHED_OFFSET0x0004
+#define PARSER_FLAG_USE_KEYFRAME_HEURISTICS   0x0008
   #define PARSER_FLAG_USE_CODEC_TS  0x1000


This doesnt "feel" like the best solution to me

dont you think it would be better to export all information ?


The AVParser API is going to be removed at some point for something better
that works on packets rather than raw buffers, so ideally we should not
expand it too much, and leave more complex implementations for later.


Iam not sure i follow your logic here

do you suggest to block setting lets call it "advanced keyframe" related work
across the codebase ? (that includes muxers and so on ?
Iam not saying thats a good or bad idea. Just trying to understand


I'm saying to not spend time extending the AVCodecParserContext API to 
export even more information when it's going to be replaced. A single 
flag to stop one parser from tagging more than it needs to is enough to 
work around the problem at hand.




Because to me it seems if the awnser is no to the question above
then this is not just about "Adding a flag is the simplest way to fix this"
but its adding codec specific code in muxers probably to extract the exta
information, and iam not sure that at this point its not easier to have
the parser export this information


Inserting the h264 parser internally in mpegtsenc is needed because it's 
the generic demuxer code that may or may not use one to assemble packets 
or fill missing information. The muxer side has no interaction with it, 
it only receives packets from some source.
So you add a new field to AVCodecParserContext to signal these "advanced 
keyframes". How does that information reach the muxer? You're now having 
to define or expand more stuff for this purpose.


Inserting it in the muxer also has the added benefit of not depending on 
the demuxing side from having inserted one to begin with. For example, 
open an mp4 file for which the demuxer was able to create an 
AVIndexEntry array and therefore will not tell the generic code that it 
needs a parser. If you remux that file to mpegts, only Sync Samples (Of 
which there may be none) will have been tagged as keyframes by the 
demuxer (Which is expected) and not all these other packets with 
recovery points like mpegts apparently wants.
If the muxer internally inserts the parser, all of them can be marked, 
and a flag is enough for that.




And when the parser API is then replaced by "something better" the interface
changes less. If this heuristic flag is added then i assume it needs to be
removed and reimplemented with the API change.


This flag would be removed alongside the rest of AVCodecParserContext 
API, but the replacement would not need something like it since we would 
then look into ensuring it exports more detailed information for a given 
packet in a proper way, and not just setting a generic and poorly 
defined context-wide key_frame field.


This is just a stopgap solution, not something that needs to be 
translated into a new API. I mean, just look how all these flags are not 
even namespaced, or how the main function doesn't even return error 
codes. A replacement hardly requires to be a 1:1 translation.




I very likely am missing something
But i certainly do not suggest or ask for more work to be done. Rather the
opposit, i was wondering if its not less work overall to export the
information properly ...


The replacement for AVCodecParserContext would, if i recall correctly 
when it was suggested, be having the work done by bitstream filters. 
Some muxers and demuxers are already using bsfs in some cases, so it 
would be built on top of that, and maybe automatically inserted by both 
muxers and demuxers, not just the latter.


So considering that muxer specific code is needed right now, I don't 
think adding more fields to AVCodecParserContext will mean less work now 
or even later.




thx

[...]


___
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@ffm

[FFmpeg-devel] [PATCH] avcodec/encode: Avoid building implementation when encoders are disabled

2021-07-16 Thread Michael Niedermayer
This could also be moved into a separate file.

Signed-off-by: Michael Niedermayer 
---
 libavcodec/encode.c | 47 +
 1 file changed, 47 insertions(+)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index a569904f2c..ecf0e6e4bd 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -30,6 +30,8 @@
 #include "frame_thread_encoder.h"
 #include "internal.h"
 
+#if CONFIG_ENCODERS
+
 int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
 {
 if (size < 0 || size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {
@@ -555,3 +557,48 @@ int ff_encode_preinit(AVCodecContext *avctx)
 
 return 0;
 }
+#else // CONFIG_ENCODERS
+
+
+int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
+{
+return AVERROR(ENOSYS);
+}
+
+int avcodec_default_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, 
int flags)
+{
+return AVERROR(ENOSYS);
+}
+
+int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, 
int flags)
+{
+return AVERROR(ENOSYS);
+}
+
+int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
+const AVSubtitle *sub)
+{
+return AVERROR(ENOSYS);
+}
+
+int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame)
+{
+return AVERROR(ENOSYS);
+}
+
+int attribute_align_arg avcodec_send_frame(AVCodecContext *avctx, const 
AVFrame *frame)
+{
+return AVERROR(ENOSYS);
+}
+
+int attribute_align_arg avcodec_receive_packet(AVCodecContext *avctx, AVPacket 
*avpkt)
+{
+return AVERROR(ENOSYS);
+}
+
+int ff_encode_preinit(AVCodecContext *avctx)
+{
+return AVERROR(ENOSYS);
+}
+
+#endif// !CONFIG_ENCODERS
-- 
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] fftools/ffmpeg: Add new variant source_no_drop to the force_key_frames option

2021-07-16 Thread Mattias Wadman
On Fri, Jul 16, 2021 at 9:51 AM Thilo Borgmann 
wrote:

> Am 04.07.21 um 21:23 schrieb Michael Niedermayer:
> > On Sun, Jun 20, 2021 at 09:48:29PM +0200, Thilo Borgmann wrote:
> >> Hi,
> >>
> >> adds a new variant to the -force_key_frames option "source_no_drop" to
> make
> >> sure whenever a key frame in the source is dropped, we choose the next
> frame
> >> in the output stream as a key frame.
> >>
> >> -Thilo
> >
> >>  doc/ffmpeg.texi  |7 +++
> >>  fftools/ffmpeg.c |6 ++
> >>  fftools/ffmpeg.h |1 +
> >>  3 files changed, 14 insertions(+)
> >> e8ffd04204a6cc243b2f98858ec1f1afe44ff8e8
> 0001-fftools-ffmpeg-Add-new-variant-source_no_drop-to-the.patch
> >> From b37c854e7d48b538537b2c9c5e9651ba2ead3e52 Mon Sep 17 00:00:00 2001
> >> From: Keyun Tong 
> >> Date: Sun, 20 Jun 2021 21:42:29 +0200
> >> Subject: [PATCH] fftools/ffmpeg: Add new variant source_no_drop to the
> >>  force_key_frames option
> >
> > LGTM if both variants have a use case
>
> Pushed.


Sorry for late review, i just noticed this line:
"!strncmp(ost->forced_keyframes, "source_no_drop", 6)"
shouldn't it be:
!strncmp(ost->forced_keyframes, "source_no_drop", 14)
?
___
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] cmdutils: simplify opt_cpucount()

2021-07-16 Thread James Almer
Signed-off-by: James Almer 
---
 fftools/cmdutils.c | 27 +++
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 6e875104fd..a3b6b78d50 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -856,28 +856,15 @@ int opt_cpuflags(void *optctx, const char *opt, const 
char *arg)
 
 int opt_cpucount(void *optctx, const char *opt, const char *arg)
 {
-int ret;
-int count;
-
-static const AVOption opts[] = {
-{"count", NULL, 0, AV_OPT_TYPE_INT, { .i64 = -1}, -1, INT_MAX, NULL},
-{NULL},
-};
-static const AVClass class = {
-.class_name = "cpucount",
-.item_name  = av_default_item_name,
-.option = opts,
-.version= LIBAVUTIL_VERSION_INT,
-};
-const AVClass *pclass = &class;
-
-ret = av_opt_eval_int(&pclass, opts, arg, &count);
+char *tail;
+int64_t count;
 
-if (!ret) {
-av_force_cpu_count(count);
-}
+count = strtol(arg, &tail, 10);
+if (*tail || count < -1 || count > INT_MAX)
+return AVERROR(EINVAL);
 
-return ret;
+av_force_cpu_count(count);
+return 0;
 }
 
 int opt_loglevel(void *optctx, const char *opt, const char *arg)
-- 
2.32.0

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

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


Re: [FFmpeg-devel] Mailing List Delay

2021-07-16 Thread ffmpegandmahanstreamer
For what it's worth, I'm moving to e.email. I will see how the delay 
dynamic works over there as well. So far it also seems like a good 
option that I would recommend.


I do know that Yandex has a very long delay (if its even sent at all) 
because I tried that and it didn't even get the confirmation.


I was recommended the lolcow email service I am using by a fellow video 
editor and enthusiast i've known for a while. However, due to it 
constantly being unable to read mails due to an interface bug (the email 
is there, but doesn't show up until I hit "reply to"), I have decided to 
make the switch. I also looked into the person behind the cow service 
and he has been involved in some  less than trustworthy  things 
that's beyond the scope of this mailing list.


On 2021-07-14 14:55, Nicolas George wrote:

ffmpegandmahanstreamer@lolcow.email (12021-07-14):

I'm not against fixing the mailing list. No, not at all. It need to be
fixed. But Google is big company and trying to figure out how to make 
their

mail deliver successfully might be a problem.

I think this was the reasoning behind alot of the major open source 
projects
switching to Nongnu.org and Google Groups along with Github 
discussions.

IIRC even the Alliance of Open Media has their patch mailing list on
Groups.io and Google Groups now. But I'm not saying FFMPEG should. 
Just
saying that other projects have been facing similar issues and fixed 
it by
moving to a large mailing list hub. And libvpx uses Google mail 
servers for

their patches as well.


This discussion would be incomplete without reminding that Google and
these large actors have, under the excuse of fighting spam, 
unilaterally

changed the protocols they implement in ways that makes it harder for
small actors to stay in the game.

Therefore, the terms of the alternative are between choosing a solution
that is seamless even for the clueless but at the same time that 
enables

the monopolists and strengthen their position, or resisting the
monopolists and bearing a few technical hurdles for people who use 
their

services.

Since FFmpeg is a major Libre Software project, and one that is quite
technical at that, I think it should be obvious our side is the one of
freedom and against the monopolists.

Furthermore, FFmpeg has some importance for Google itself, which could
give us weight in asking they fix their shit if they want their users 
to

be able to contribute without hassle. That would benefit all projects
who want to self-host their mailing-lists.

Also, it is worth remembering that if lkml can self-host, so should we.

And, in the wake of the GitHub Copilot scandal, I think it is pretty
obvious we should definitely not choose solutions that are under
singular private control.

Regards,

___
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 v3 1/4] avformat: Introduce AV_DISPOSITION_URGENT disposition flag for emergency alert

2021-07-16 Thread zheng qian
This patchset introduces AV_DISPOSITION_URGENT disposition flag for
marking stuffs which is expected to be shown immediately as received,
and adds recognization/remuxing support for ARIB superimpose stream.

ARIB superimpose is almost same as ARIB caption but is utilized to
transmit emergency alert and newsflash in Japan DTV.

Since superimpose is designed to be displayed immediately as received,
ARIB superimpose utilizes mpegts private_stream_2 rather than the
private_stream_1 that is used by arib_caption, which means superimpose
packet doesn't have PTS/DTS (AV_NOPTS_VALUE).

Purpose of introducing AV_DISPOSITION_URGENT is mainly:

1) To be able to mark stuffs as "show as received", which could be NOPTS

2) Let ffmpeg-based player to be able to recognize these stuffs such as
ARIB superimpose stream, and extract data to render it onto screen

3) Let mpegtsenc to be able to remux ARIB superimpose stream correctly

Signed-off-by: zheng qian 
---
 libavformat/avformat.h | 1 +
 libavformat/dump.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 81d2ac38d0..6c7d3fb3a5 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -831,6 +831,7 @@ typedef struct AVStreamInternal AVStreamInternal;
 #define AV_DISPOSITION_METADATA 0x4
 #define AV_DISPOSITION_DEPENDENT0x8 ///< dependent audio stream 
(mix_type=0 in mpegts)
 #define AV_DISPOSITION_STILL_IMAGE 0x10 ///< still images in video stream 
(still_picture_flag=1 in mpegts)
+#define AV_DISPOSITION_URGENT  0x20 ///< stream which is expected to 
be shown immediately as received (emergency alert)
 
 /**
  * Options for behavior on timestamp wrap detection.
diff --git a/libavformat/dump.c b/libavformat/dump.c
index cf892de107..a987d097dc 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -610,6 +610,8 @@ static void dump_stream_format(const AVFormatContext *ic, 
int i,
 av_log(NULL, AV_LOG_INFO, " (dependent)");
 if (st->disposition & AV_DISPOSITION_STILL_IMAGE)
 av_log(NULL, AV_LOG_INFO, " (still image)");
+if (st->disposition & AV_DISPOSITION_URGENT)
+av_log(NULL, AV_LOG_INFO, " (urgent)");
 av_log(NULL, AV_LOG_INFO, "\n");
 
 dump_metadata(NULL, st->metadata, "");
-- 
2.29.2

___
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 2/4] avformat/mpegts: Recognize ARIB superimpose stream

2021-07-16 Thread zheng qian
Recognize ARIB superimpose stream through ARIB data coding descriptor,
and re-use AV_CODEC_ID_ARIB_CAPTION codec id with an extra disposition
flag AV_DISPOSITION_URGENT.

Signed-off-by: zheng qian 
---
 libavformat/mpegts.c | 23 +++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index a02965bacf..44a1841859 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2106,8 +2106,8 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
 }
 break;
 case 0xfd: /* ARIB data coding type descriptor */
-// STD-B24, fascicle 3, chapter 4 defines private_stream_1
-// for captions
+// STD-B24, fascicle 3, chapter 4 defines
+// private_stream_1 for captions, and private_stream_2 for superimpose
 if (stream_type == STREAM_TYPE_PRIVATE_DATA) {
 // This structure is defined in STD-B10, part 1, listing 5.4 and
 // part 2, 6.2.20).
@@ -2115,6 +2115,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
 // Component tag limits are documented in TR-B14, fascicle 2,
 // Vol. 3, Section 2, 4.2.8.1
 int actual_component_tag = st->internal->stream_identifier - 1;
+int is_superimpose = 0;
 int picked_profile = FF_PROFILE_UNKNOWN;
 int data_component_id = get16(pp, desc_end);
 if (data_component_id < 0)
@@ -2122,17 +2123,28 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
 
 switch (data_component_id) {
 case 0x0008:
-// [0x30..0x37] are component tags utilized for
+// [0x30..0x37] and [0x38..0x3F] are component tags utilized 
for
 // non-mobile captioning service ("profile A").
 if (actual_component_tag >= 0x30 &&
 actual_component_tag <= 0x37) {
+// caption (Profile A)
+picked_profile = FF_PROFILE_ARIB_PROFILE_A;
+} else if (actual_component_tag >= 0x38 &&
+   actual_component_tag <= 0x3F) {
+// superimpose (Profile A)
+is_superimpose = 1;
 picked_profile = FF_PROFILE_ARIB_PROFILE_A;
 }
 break;
 case 0x0012:
-// component tag 0x87 signifies a mobile/partial reception
+// component tag 0x87 and 0x88 signifies a mobile/partial 
reception
 // (1seg) captioning service ("profile C").
 if (actual_component_tag == 0x87) {
+// caption (Profile C)
+picked_profile = FF_PROFILE_ARIB_PROFILE_C;
+} else if (actual_component_tag == 0x88) {
+// superimpose (Profile C)
+is_superimpose = 1;
 picked_profile = FF_PROFILE_ARIB_PROFILE_C;
 }
 break;
@@ -2147,6 +2159,9 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
 st->codecpar->codec_id   = AV_CODEC_ID_ARIB_CAPTION;
 st->codecpar->profile= picked_profile;
 st->internal->request_probe= 0;
+if (is_superimpose) {
+st->disposition |= AV_DISPOSITION_URGENT;
+}
 }
 break;
 case 0xb0: /* DOVI video stream descriptor */
-- 
2.29.2

___
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 3/4] avformat/mpegtsenc: Add muxing support for ARIB superimpose stream

2021-07-16 Thread zheng qian
Signed-off-by: zheng qian 
---
 libavformat/mpegtsenc.c | 40 +++-
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 98dac17994..b5d2938c4a 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -287,26 +287,37 @@ static void putbuf(uint8_t **q_ptr, const uint8_t *buf, 
size_t len)
 *q_ptr += len;
 }
 
-static int put_arib_caption_descriptor(AVFormatContext *s, uint8_t **q_ptr,
-   AVCodecParameters *codecpar)
+static int put_arib_descriptor(AVFormatContext *s, AVStream* st, uint8_t 
**q_ptr)
 {
 uint8_t stream_identifier;
 uint16_t data_component_id;
 uint8_t *q = *q_ptr;
 
-switch (codecpar->profile) {
+switch (st->codecpar->profile) {
 case FF_PROFILE_ARIB_PROFILE_A:
-stream_identifier = 0x30;
+if (st->disposition & AV_DISPOSITION_URGENT) {
+// ARIB superimpose, with AV_DISPOSITION_URGENT flag
+stream_identifier = 0x38;
+} else {
+// ARIB caption
+stream_identifier = 0x30;
+}
 data_component_id = 0x0008;
 break;
 case FF_PROFILE_ARIB_PROFILE_C:
-stream_identifier = 0x87;
+if (st->disposition & AV_DISPOSITION_URGENT) {
+// ARIB superimpose
+stream_identifier = 0x88;
+} else {
+// ARIB caption
+stream_identifier = 0x87;
+}
 data_component_id = 0x0012;
 break;
 default:
 av_log(s, AV_LOG_ERROR,
"Unset/unknown ARIB caption profile %d utilized!\n",
-   codecpar->profile);
+   st->codecpar->profile);
 return AVERROR_INVALIDDATA;
 }
 
@@ -320,11 +331,17 @@ static int put_arib_caption_descriptor(AVFormatContext 
*s, uint8_t **q_ptr,
 *q++ = 3; // descriptor_length
 put16(&q, data_component_id);  // data_component_id
 // additional_arib_caption_info: defined in ARIB STD-B24, fascicle 1, Part 
3, 9.6.1
-// Here we utilize a pre-defined set of values defined in ARIB TR-B14,
+// Here we utilize pre-defined sets of values defined in ARIB TR-B14,
 // Fascicle 2, 4.2.8.5 for PMT usage, with the reserved bits in the middle
 // set to 1 (as that is what every broadcaster seems to be doing in
 // production).
-*q++ = 0x3D; // DMF('0011'), Reserved('11'), Timing('01')
+if (st->disposition & AV_DISPOSITION_URGENT) {
+// ARIB superimpose
+*q++ = 0x3C; // DMF('0011'), Reserved('11'), Timing('00')
+} else {
+// ARIB caption
+*q++ = 0x3D; // DMF('0011'), Reserved('11'), Timing('01')
+}
 
 *q_ptr = q;
 
@@ -772,7 +789,7 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 
*len_ptr = q - len_ptr - 1;
 } else if (codec_id == AV_CODEC_ID_ARIB_CAPTION) {
-if (put_arib_caption_descriptor(s, &q, st->codecpar) < 0)
+if (put_arib_descriptor(s, st, &q) < 0)
 break;
 }
 break;
@@ -1444,6 +1461,11 @@ static int get_pes_stream_id(AVFormatContext *s, 
AVStream *st, int stream_id, in
 if (stream_id == STREAM_ID_PRIVATE_STREAM_1) /* asynchronous KLV */
 *async = 1;
 return stream_id != -1 ? stream_id : STREAM_ID_METADATA_STREAM;
+} else if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE &&
+   st->codecpar->codec_id == AV_CODEC_ID_ARIB_CAPTION &&
+   st->disposition & AV_DISPOSITION_URGENT) {  // ARIB superimpose
+// ARIB TR-B14, Fascicle 1 (2/2), Vol.3, 4.2.3
+return STREAM_ID_PRIVATE_STREAM_2;
 } else {
 return STREAM_ID_PRIVATE_STREAM_1;
 }
-- 
2.29.2

___
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 4/4] fftools/ffmpeg: Ignore dts checking for AV_DISPOSITION_URGENT

2021-07-16 Thread zheng qian
Stream with AV_DISPOSITION_URGENT disposition flag could be NOPTS.

Signed-off-by: zheng qian 
---
 fftools/ffmpeg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 1ac2e48600..a3b720748b 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -824,7 +824,8 @@ static void write_packet(OutputFile *of, AVPacket *pkt, 
OutputStream *ost, int u
 if ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || 
st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == 
AVMEDIA_TYPE_SUBTITLE) &&
 pkt->dts != AV_NOPTS_VALUE &&
 !(st->codecpar->codec_id == AV_CODEC_ID_VP9 && ost->stream_copy) &&
-ost->last_mux_dts != AV_NOPTS_VALUE) {
+ost->last_mux_dts != AV_NOPTS_VALUE &&
+!(st->disposition & AV_DISPOSITION_URGENT)) {
 int64_t max = ost->last_mux_dts + !(s->oformat->flags & 
AVFMT_TS_NONSTRICT);
 if (pkt->dts < max) {
 int loglevel = max - pkt->dts > 2 || st->codecpar->codec_type 
== AVMEDIA_TYPE_VIDEO ? AV_LOG_WARNING : AV_LOG_DEBUG;
-- 
2.29.2

___
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] ffmpeg: add option readrate

2021-07-16 Thread ffmpegandmahanstreamer
Put the fact that -re is equivalent to -readrate 1 in the deprecated message so 
people know what to switch to.

Other than that looks good to me.
___
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] ffmpeg: add option readrate

2021-07-16 Thread Gyan Doshi




On 2021-07-17 04:50, ffmpegandmahanstreamer@e.email wrote:

Put the fact that -re is equivalent to -readrate 1 in the deprecated message so 
people know what to switch to.


It's already in the docs for -re as well as the ffmpeg -h description.

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