Re: [FFmpeg-devel] [PATCH] avfilter: add afftdn filter

2018-09-24 Thread Moritz Barsnick
On Sat, Sep 22, 2018 at 15:09:19 +0200, Paul B Mahol wrote:
> +@item bn
> +Set custom band noise for every one of 15 bands.

Nit: Probably need to explain the syntax (15, or upto 15(?), '|' separated 
integers?).

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


Re: [FFmpeg-devel] [PATCH v2 1/5] vaapi_encode: Support configurable slices

2018-09-24 Thread Moritz Barsnick
On Sun, Sep 23, 2018 at 22:52:56 +0100, Mark Thompson wrote:
>  const VAEntrypoint *usable_entrypoints;
> -const VAAPIEncodeProfile *profile;
> -const AVPixFmtDescriptor *desc;
> +const VAAPIEncodeProfile *profile;const AVPixFmtDescriptor *desc;

This change doesn't look intentional.

Cheers,
Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avfilter: add afftdn filter

2018-09-24 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 configure|3 +
 doc/filters.texi |   67 ++
 libavfilter/Makefile |1 +
 libavfilter/af_afftdn.c  | 1345 ++
 libavfilter/allfilters.c |1 +
 5 files changed, 1417 insertions(+)
 create mode 100644 libavfilter/af_afftdn.c

diff --git a/configure b/configure
index 1946bcb69c..f3795833b1 100755
--- a/configure
+++ b/configure
@@ -3339,6 +3339,8 @@ libssh_protocol_deps="libssh"
 libtls_conflict="openssl gnutls mbedtls"
 
 # filters
+afftdn_filter_deps="avcodec"
+afftdn_filter_select="fft"
 afftfilt_filter_deps="avcodec"
 afftfilt_filter_select="fft"
 afir_filter_deps="avcodec"
@@ -6857,6 +6859,7 @@ done
 enabled zlib && add_cppflags -DZLIB_CONST
 
 # conditional library dependencies, in any order
+enabled afftdn_filter   && prepend avfilter_deps "avcodec"
 enabled afftfilt_filter && prepend avfilter_deps "avcodec"
 enabled afir_filter && prepend avfilter_deps "avcodec"
 enabled amovie_filter   && prepend avfilter_deps "avformat avcodec"
diff --git a/doc/filters.texi b/doc/filters.texi
index 5ee2bb52ec..db4eaab961 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -974,6 +974,73 @@ afade=t=out:st=875:d=25
 @end example
 @end itemize
 
+@section afftdn
+Denoise audio samples with FFT.
+
+A description of the accepted parameters follows.
+
+@table @option
+@item nr
+Set the noise reduction in dB, allowed range is 0.01 to 97.
+Default value is 12 dB.
+
+@item nf
+Set the noise floor in dB, allowed range is 20 to 80.
+Default value is 50 dB.
+
+@item nt
+Set the noise type.
+
+It accepts the following values:
+@table @option
+@item w
+Select white noise.
+
+@item v
+Select vinyl noise.
+
+@item s
+Select shellac noise.
+
+@item c
+Select custom noise, defined in @code{bn} option.
+
+Default value is white noise.
+@end table
+
+@item bn
+Set custom band noise for every one of 15 bands.
+Bands are separated by ' ' or '|'.
+
+@item rf
+Set the residual floor. Default value is 38 dB.
+
+@item tn
+Enable noise tracking. By default is disabled.
+
+@item tr
+Enable residual tracking. By default is disabled.
+@end table
+
+@subsection Commands
+
+This filter supports the following commands:
+@table @option
+@item sample_noise, sn
+Start or stop measuring noise profile.
+Syntax for the command is : "start" or "stop" string.
+After measuring noise profile is stopped it will be
+automatically applied in filtering.
+
+@item noise_reduction, nr
+Change noise reduction. Argument is single float number.
+Syntax for the command is : "@var{noise_reduction}"
+
+@item noise_floor, nf
+Change noise floor. Argument is single float number.
+Syntax for the command is : "@var{noise_floor}"
+@end table
+
 @section afftfilt
 Apply arbitrary expressions to samples in frequency domain.
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 67e20cc858..62cc2f561f 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -46,6 +46,7 @@ OBJS-$(CONFIG_AECHO_FILTER)  += af_aecho.o
 OBJS-$(CONFIG_AEMPHASIS_FILTER)  += af_aemphasis.o
 OBJS-$(CONFIG_AEVAL_FILTER)  += aeval.o
 OBJS-$(CONFIG_AFADE_FILTER)  += af_afade.o
+OBJS-$(CONFIG_AFFTDN_FILTER) += af_afftdn.o
 OBJS-$(CONFIG_AFFTFILT_FILTER)   += af_afftfilt.o
 OBJS-$(CONFIG_AFIR_FILTER)   += af_afir.o
 OBJS-$(CONFIG_AFORMAT_FILTER)+= af_aformat.o
diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c
new file mode 100644
index 00..2cc9b36d83
--- /dev/null
+++ b/libavfilter/af_afftdn.c
@@ -0,0 +1,1345 @@
+/*
+ * Copyright (c) 2018 The FFmpeg Project
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+
+#include "libavutil/audio_fifo.h"
+#include "libavutil/avstring.h"
+#include "libavutil/channel_layout.h"
+#include "libavutil/opt.h"
+#include "libavcodec/avfft.h"
+#include "avfilter.h"
+#include "audio.h"
+#include "formats.h"
+
+#define C   (M_LN10 * 0.1)
+#define RATIO0.98
+#define RRATIO  (1.0 - RATIO)
+
+enum NoiseType {
+WHITE_NOISE,
+VINYL_NOISE,
+SHELLAC_NOISE,
+CUSTOM_NOISE,
+NB_NOISE
+};
+
+typedef struct DeNoiseChannel {
+int band_noise[15];
+

Re: [FFmpeg-devel] [PATCH] libavformat/segment: strftime date sub-directories

2018-09-24 Thread James Courtier-Dutton

From 6c74670e047bfc9e995c0f968c1688be768d13bd Mon Sep 17 00:00:00 2001
From: James Courtier-Dutton 
Date: Mon, 24 Sep 2018 12:34:54 +0100
Subject: [PATCH] avformat/segment: strftime date sub-directories

Automatically create sub-directories if needed based on date.
E.g.
ffmpeg ... -timelimit 2147483647 -f segment -strftime 1 -segment_time 10 "%Y/%m/%d/%Y-%m-%d_%H-%M-%S.mkv"

Signed-off-by: James Courtier-Dutton 
---
 libavformat/segment.c | 48 
 1 file changed, 48 insertions(+)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index 7fb4dc7..b2300d9 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -186,6 +186,39 @@ static int segment_mux_init(AVFormatContext *s)
 return 0;
 }
 
+static int mkdir_p(const char *path) {
+int ret = 0;
+char *temp = av_strdup(path);
+char *pos = temp;
+char tmp_ch = '\0';
+
+if (!path || !temp) {
+return -1;
+}
+
+if (!strncmp(temp, "/", 1) || !strncmp(temp, "\\", 1)) {
+pos++;
+} else if (!strncmp(temp, "./", 2) || !strncmp(temp, ".\\", 2)) {
+pos += 2;
+}
+
+for ( ; *pos != '\0'; ++pos) {
+if (*pos == '/' || *pos == '\\') {
+tmp_ch = *pos;
+*pos = '\0';
+ret = mkdir(temp, 0755);
+*pos = tmp_ch;
+}
+}
+
+if ((*(pos - 1) != '/') || (*(pos - 1) != '\\')) {
+ret = mkdir(temp, 0755);
+}
+
+av_free(temp);
+return ret;
+}
+
 static int set_segment_filename(AVFormatContext *s)
 {
 SegmentContext *seg = s->priv_data;
@@ -200,12 +233,27 @@ static int set_segment_filename(AVFormatContext *s)
 if (seg->use_strftime) {
 time_t now0;
 struct tm *tm, tmpbuf;
+const char *dir;
+char *fn_copy;
 time(&now0);
 tm = localtime_r(&now0, &tmpbuf);
 if (!strftime(buf, sizeof(buf), s->url, tm)) {
 av_log(oc, AV_LOG_ERROR, "Could not get segment filename with strftime\n");
 return AVERROR(EINVAL);
 }
+/* Automatically create directories if needed */
+/* E.g. %Y/%m/%d/%Y-%m-%d_%H-%M-%S.mkv */
+fn_copy = av_strdup(buf);
+if (!fn_copy) {
+return AVERROR(ENOMEM);
+}
+dir = av_dirname(fn_copy);
+if (mkdir_p(dir) == -1 && errno != EEXIST) {
+av_log(oc, AV_LOG_ERROR, "Could not create directory %s with use_localtime_mkdir\n", dir);
+av_free(fn_copy);
+return AVERROR(errno);
+}
+av_free(fn_copy);
 } else if (av_get_frame_filename(buf, sizeof(buf),
  s->url, seg->segment_idx) < 0) {
 av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", s->url);
-- 
2.7.4

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


[FFmpeg-devel] [PATCH] avdevice/decklink: Add option to align Capture start time

2018-09-24 Thread Karthick J
From: Karthick Jeyapal 

This option is useful for maintaining input synchronization across N
different hardware devices deployed for 'N-way' redundancy.
The system time of different hardware devices should be synchronized
with protocols such as NTP or PTP, before using this option.
---
 doc/indevs.texi | 10 ++
 libavdevice/decklink_common_c.h |  1 +
 libavdevice/decklink_dec.cpp| 20 
 libavdevice/decklink_dec_c.c|  1 +
 4 files changed, 32 insertions(+)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index ed2784b..dfd530a 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -371,6 +371,16 @@ If set to @option{true}, timestamps are forwarded as they 
are without removing
 the initial offset.
 Defaults to @option{false}.
 
+@item timestamp_align
+Capture start time alignment in seconds. If set to nonzero, input frames are
+dropped till the system timestamp aligns with configured value.
+Alignment difference of upto one frame duration is tolerated.
+This is useful for maintaining input synchronization across N different
+hardware devices deployed for 'N-way' redundancy. The system time of different
+hardware devices should be synchronized with protocols such as NTP or PTP,
+before using this option.
+Defaults to @samp{0}.
+
 @end table
 
 @subsection Examples
diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
index 32a5d70..c4a8985 100644
--- a/libavdevice/decklink_common_c.h
+++ b/libavdevice/decklink_common_c.h
@@ -56,6 +56,7 @@ struct decklink_cctx {
 int raw_format;
 int64_t queue_size;
 int copyts;
+int timestamp_align;
 };
 
 #endif /* AVDEVICE_DECKLINK_COMMON_C_H */
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 7fabef2..24f5ca9 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -703,6 +703,26 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 return S_OK;
 }
 
+// Drop the frames till system's timestamp aligns with the configured 
value.
+if (0 == ctx->frameCount && cctx->timestamp_align) {
+int64_t current_time_us = av_gettime();
+int64_t align_factor_us = (cctx->timestamp_align * 100);
+int remainder = current_time_us % align_factor_us;
+if (videoFrame) {
+videoFrame->GetStreamTime(&frameTime, &frameDuration, 100);
+} else if (audioFrame) {
+long sample_count = audioFrame->GetSampleFrameCount();
+frameDuration = (long)(sample_count * 100) / 
bmdAudioSampleRate48kHz;
+} else {
+frameDuration = 0;
+}
+// threshold of one frameDuration
+if(remainder > frameDuration) {
+++ctx->dropped;
+return S_OK;
+}
+}
+
 ctx->frameCount++;
 if (ctx->audio_pts_source == PTS_SRC_WALLCLOCK || ctx->video_pts_source == 
PTS_SRC_WALLCLOCK)
 wallclock = av_gettime_relative();
diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c
index 6ab3819..bef9c14 100644
--- a/libavdevice/decklink_dec_c.c
+++ b/libavdevice/decklink_dec_c.c
@@ -84,6 +84,7 @@ static const AVOption options[] = {
 { "queue_size","input queue buffer size",   OFFSET(queue_size),   
AV_OPT_TYPE_INT64, { .i64 = (1024 * 1024 * 1024)}, 0, INT64_MAX, DEC },
 { "audio_depth",   "audio bitdepth (16 or 32)", OFFSET(audio_depth),  
AV_OPT_TYPE_INT,   { .i64 = 16}, 16, 32, DEC },
 { "decklink_copyts", "copy timestamps, do not remove the initial offset", 
OFFSET(copyts), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
+{ "timestamp_align", "Capture start time alignment (in seconds)", 
OFFSET(timestamp_align), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, DEC },
 { NULL },
 };
 
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH] libavformat/segment: strftime date sub-directories

2018-09-24 Thread James Courtier-Dutton
Updated patch is here:
https://patchwork.ffmpeg.org/patch/10469/

Functionalist has not changed. It has been updated to apply to the latest
master branch.


On 22 September 2018 at 17:26, Michael Niedermayer 
wrote:

> On Thu, Nov 30, 2017 at 11:07:03PM +, James Courtier-Dutton wrote:
> >
>
> >  segment.c |   48 
> >  1 file changed, 48 insertions(+)
> > e3e9961df186f73adb24f7a334d398884e894d53  0001-libavformat-segment-
> strftime-date-sub-directories.patch
> > From b6a6f6d577e562c09c7cc1fc0befd2d73a9c0f32 Mon Sep 17 00:00:00 2001
> > From: James Courtier-Dutton 
> > Date: Thu, 30 Nov 2017 22:56:04 +
> > Subject: [PATCH] libavformat/segment: strftime date sub-directories
> >
> > Automatically create sub-directories if needed based on date.
> > E.g.
> > ffmpeg ... -timelimit 2147483647 -f segment -strftime 1 -segment_time 10
> "%Y/%m/%d/%Y-%m-%d_%H-%M-%S.mkv"
> > ---
> >  libavformat/segment.c | 48 ++
> ++
> >  1 file changed, 48 insertions(+)
>
> doesnt apply anymore
>
> Applying: libavformat/segment: strftime date sub-directories
> Using index info to reconstruct a base tree...
> M   libavformat/segment.c
> Falling back to patching base and 3-way merge...
> Auto-merging libavformat/segment.c
> CONFLICT (content): Merge conflict in libavformat/segment.c
> error: Failed to merge in the changes.
> Patch failed at 0001 libavformat/segment: strftime date sub-directories
> hint: Use 'git am --show-current-patch' to see the failed patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".
>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> When you are offended at any man's fault, turn to yourself and study your
> own failings. Then you will forget your anger. -- Epictetus
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/sr: process and output message when load_model is NULL

2018-09-24 Thread Paul B Mahol
On 9/24/18, Steven Liu  wrote:
> fix ticket: 7455
>
> Signed-off-by: Steven Liu 
> ---
>  libavfilter/dnn_interface.c | 4 
>  libavfilter/vf_sr.c | 7 ++-
>  2 files changed, 10 insertions(+), 1 deletion(-)
>

probably ok.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavformat/segment: strftime date sub-directories

2018-09-24 Thread Moritz Barsnick
On Mon, Sep 24, 2018 at 12:39:42 +0100, James Courtier-Dutton wrote:

> Automatically create sub-directories if needed based on date.
> E.g.
> ffmpeg ... -timelimit 2147483647 -f segment -strftime 1 -segment_time 10 
> "%Y/%m/%d/%Y-%m-%d_%H-%M-%S.mkv"
[...]
> +static int mkdir_p(const char *path) {

Is this code duplicated from libavformat/hlsenc.c?

I don't know what the policy is, and how code from hls vs. segment has
been deduplicated previously, but it seems like this is a candidate for
being careful.

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


[FFmpeg-devel] [PATCH] avformat/utils: move mkdir_p to utils

2018-09-24 Thread Steven Liu
Because it will be used by avformat/segment.c or other module which
need to automatically create sub-directories operation.

Signed-off-by: Steven Liu 
---
 libavformat/hlsenc.c   | 37 ++---
 libavformat/internal.h |  8 
 libavformat/utils.c| 34 ++
 3 files changed, 44 insertions(+), 35 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 99a59a231d..28c2dd62fc 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -230,39 +230,6 @@ typedef struct HLSContext {
 int64_t timeout;
 } HLSContext;
 
-static int mkdir_p(const char *path) {
-int ret = 0;
-char *temp = av_strdup(path);
-char *pos = temp;
-char tmp_ch = '\0';
-
-if (!path || !temp) {
-return -1;
-}
-
-if (!strncmp(temp, "/", 1) || !strncmp(temp, "\\", 1)) {
-pos++;
-} else if (!strncmp(temp, "./", 2) || !strncmp(temp, ".\\", 2)) {
-pos += 2;
-}
-
-for ( ; *pos != '\0'; ++pos) {
-if (*pos == '/' || *pos == '\\') {
-tmp_ch = *pos;
-*pos = '\0';
-ret = mkdir(temp, 0755);
-*pos = tmp_ch;
-}
-}
-
-if ((*(pos - 1) != '/') || (*(pos - 1) != '\\')) {
-ret = mkdir(temp, 0755);
-}
-
-av_free(temp);
-return ret;
-}
-
 static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename,
   AVDictionary **options) {
 HLSContext *hls = s->priv_data;
@@ -1545,7 +1512,7 @@ static int hls_start(AVFormatContext *s, VariantStream 
*vs)
 return AVERROR(ENOMEM);
 }
 dir = av_dirname(fn_copy);
-if (mkdir_p(dir) == -1 && errno != EEXIST) {
+if (ff_mkdir_p(dir) == -1 && errno != EEXIST) {
 av_log(oc, AV_LOG_ERROR, "Could not create directory %s 
with use_localtime_mkdir\n", dir);
 av_free(fn_copy);
 return AVERROR(errno);
@@ -1776,7 +1743,7 @@ static int format_name(char *buf, int buf_len, int index)
 }
 
 dir = av_dirname(mod_buf_dup);
-if (mkdir_p(dir) == -1 && errno != EEXIST) {
+if (ff_mkdir_p(dir) == -1 && errno != EEXIST) {
 ret = AVERROR(errno);
 goto fail;
 }
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 0b8120b842..399d0a68be 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -211,6 +211,14 @@ do {\
 
 struct tm *ff_brktimegm(time_t secs, struct tm *tm);
 
+/**
+ * Automatically create sub-directories
+ *
+ * @param path will create sub-directories by path
+ * @return 0, or < 0 on error
+ */
+int ff_mkdir_p(const char *path);
+
 char *ff_data_to_hex(char *buf, const uint8_t *src, int size, int lowercase);
 
 /**
diff --git a/libavformat/utils.c b/libavformat/utils.c
index a72f0a482e..7384f85604 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4797,6 +4797,40 @@ void av_url_split(char *proto, int proto_size,
 }
 }
 
+int ff_mkdir_p(const char *path)
+{
+int ret = 0;
+char *temp = av_strdup(path);
+char *pos = temp;
+char tmp_ch = '\0';
+
+if (!path || !temp) {
+return -1;
+}
+
+if (!av_strncasecmp(temp, "/", 1) || !av_strncasecmp(temp, "\\", 1)) {
+pos++;
+} else if (!av_strncasecmp(temp, "./", 2) || !av_strncasecmp(temp, ".\\", 
2)) {
+pos += 2;
+}
+
+for ( ; *pos != '\0'; ++pos) {
+if (*pos == '/' || *pos == '\\') {
+tmp_ch = *pos;
+*pos = '\0';
+ret = mkdir(temp, 0755);
+*pos = tmp_ch;
+}
+}
+
+if ((*(pos - 1) != '/') || (*(pos - 1) != '\\')) {
+ret = mkdir(temp, 0755);
+}
+
+av_free(temp);
+return ret;
+}
+
 char *ff_data_to_hex(char *buff, const uint8_t *src, int s, int lowercase)
 {
 int i;
-- 
2.15.1



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


Re: [FFmpeg-devel] [PATCHv2 1/7] avformat/ip: factorize some IP filtering and resolving functions to a new file

2018-09-24 Thread Michael Niedermayer
On Mon, Sep 24, 2018 at 08:49:27AM +0200, Marton Balint wrote:
> These are based on the very similar UDP and RTP protocol functions.
> 
> Signed-off-by: Marton Balint 
> ---
>  libavformat/ip.c | 159 
> +++
>  libavformat/ip.h |  72 +
>  2 files changed, 231 insertions(+)
>  create mode 100644 libavformat/ip.c
>  create mode 100644 libavformat/ip.h
> 
> diff --git a/libavformat/ip.c b/libavformat/ip.c
> new file mode 100644
> index 00..70c5529b72
> --- /dev/null
> +++ b/libavformat/ip.c
> @@ -0,0 +1,159 @@
> +/*
> + * IP common code
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public License
> + * as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public License
> + * along with FFmpeg; if not, write to the Free Software * Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#include "ip.h"
> +#include "libavutil/avstring.h"
> +
> +static int compare_addr(const struct sockaddr_storage *a,
> +const struct sockaddr_storage *b)
> +{
> +if (a->ss_family != b->ss_family)
> +return 1;
> +if (a->ss_family == AF_INET) {
> +return (((const struct sockaddr_in *)a)->sin_addr.s_addr !=
> +((const struct sockaddr_in *)b)->sin_addr.s_addr);
> +}
> +
> +#if HAVE_STRUCT_SOCKADDR_IN6
> +if (a->ss_family == AF_INET6) {
> +const uint8_t *s6_addr_a = ((const struct sockaddr_in6 
> *)a)->sin6_addr.s6_addr;
> +const uint8_t *s6_addr_b = ((const struct sockaddr_in6 
> *)b)->sin6_addr.s6_addr;
> +return memcmp(s6_addr_a, s6_addr_b, 16);
> +}
> +#endif
> +return 1;
> +}
> +
> +int ff_ip_check_source_lists(struct sockaddr_storage *source_addr_ptr, 
> IPSourceFilters *s)
> +{
> +int i;
> +if (s->nb_exclude_addrs) {
> +for (i = 0; i < s->nb_exclude_addrs; i++) {
> +if (!compare_addr(source_addr_ptr, &s->exclude_addrs[i]))
> +return 1;
> +}
> +}
> +if (s->nb_include_addrs) {
> +for (i = 0; i < s->nb_include_addrs; i++) {
> +if (!compare_addr(source_addr_ptr, &s->include_addrs[i]))
> +return 0;
> +}
> +return 1;
> +}
> +return 0;
> +}
> +
> +struct addrinfo *ff_ip_resolve_host(void *log_ctx,
> +const char *hostname, int port,
> +int type, int family, int flags)
> +{
> +struct addrinfo hints = { 0 }, *res = 0;
> +int error;
> +char sport[16];
> +const char *node = 0, *service = "0";
> +
> +if (port > 0) {
> +snprintf(sport, sizeof(sport), "%d", port);
> +service = sport;
> +}
> +if ((hostname) && (hostname[0] != '\0') && (hostname[0] != '?')) {
> +node = hostname;
> +}
> +hints.ai_socktype = type;
> +hints.ai_family   = family;
> +hints.ai_flags= flags;
> +if ((error = getaddrinfo(node, service, &hints, &res))) {
> +res = NULL;
> +av_log(log_ctx, AV_LOG_ERROR, "getaddrinfo(%s, %s): %s\n",
> +   node ? node : "unknown",
> +   service,
> +   gai_strerror(error));
> +}
> +
> +return res;
> +}
> +
> +
> +static int ip_parse_addr_list(void *log_ctx, const char *buf,
> +  struct sockaddr_storage **address_list_ptr,
> +  int *address_list_size_ptr)
> +{
> +struct addrinfo *ai = NULL;
> +
> +/* Resolve all of the IPs */
> +
> +while (buf && buf[0]) {
> +char* host = av_get_token(&buf, ",");
> +if (!host)
> +return AVERROR(ENOMEM);
> +
> +ai = ff_ip_resolve_host(log_ctx, host, 0, SOCK_DGRAM, AF_UNSPEC, 0);
> +av_freep(&host);
> +
> +if (ai) {
> +struct sockaddr_storage source_addr = {0};
> +memcpy(&source_addr, ai->ai_addr, ai->ai_addrlen);
> +freeaddrinfo(ai);
> +av_dynarray2_add((void **)address_list_ptr, 
> address_list_size_ptr, sizeof(source_addr), (uint8_t *)&source_addr);
> +if (!*address_list_ptr)
> +return AVERROR(ENOMEM);
> +} else {
> +return AVERROR(EINVAL);
> +}
> +
> +if (*buf)
> +buf++;
> +}
> +
> +return 0;
> +}
> +
> +static int ip_parse_sources_and_blocks(void *log_ctx, const char *buf, 
> IPSourceFilters *fil

Re: [FFmpeg-devel] [PATCH] avfilter/sr: process and output message when load_model is NULL

2018-09-24 Thread Pedro Arthur
2018-09-24 0:35 GMT-03:00 Steven Liu :

> fix ticket: 7455
>
> Signed-off-by: Steven Liu 
> ---
>  libavfilter/dnn_interface.c | 4 
>  libavfilter/vf_sr.c | 7 ++-
>  2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/libavfilter/dnn_interface.c b/libavfilter/dnn_interface.c
> index 78d7c5cf22..792c280c53 100644
> --- a/libavfilter/dnn_interface.c
> +++ b/libavfilter/dnn_interface.c
> @@ -52,6 +52,10 @@ DNNModule *ff_get_dnn_module(DNNBackendType
> backend_type)
>  av_freep(&dnn_module);
>  return NULL;
>  #endif
> +default:
> +av_log(NULL, AV_LOG_ERROR, "Module backend_type is not native or
> tensorflow\n");
> +av_freep(&dnn_module);
> +return NULL;
>  }
>
 It is missing a break in the DNN_TF case, the rest looks good.

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


Re: [FFmpeg-devel] [PATCH] avfilter/sr: process and output message when load_model is NULL

2018-09-24 Thread Steven Liu


> On Sep 24, 2018, at 21:52, Pedro Arthur  wrote:
> 
> 2018-09-24 0:35 GMT-03:00 Steven Liu :
> 
>> fix ticket: 7455
>> 
>> Signed-off-by: Steven Liu 
>> ---
>> libavfilter/dnn_interface.c | 4 
>> libavfilter/vf_sr.c | 7 ++-
>> 2 files changed, 10 insertions(+), 1 deletion(-)
>> 
>> diff --git a/libavfilter/dnn_interface.c b/libavfilter/dnn_interface.c
>> index 78d7c5cf22..792c280c53 100644
>> --- a/libavfilter/dnn_interface.c
>> +++ b/libavfilter/dnn_interface.c
>> @@ -52,6 +52,10 @@ DNNModule *ff_get_dnn_module(DNNBackendType
>> backend_type)
>> av_freep(&dnn_module);
>> return NULL;
>> #endif
>> +default:
>> +av_log(NULL, AV_LOG_ERROR, "Module backend_type is not native or
>> tensorflow\n");
>> +av_freep(&dnn_module);
>> +return NULL;
>> }
>> 
> It is missing a break in the DNN_TF case, the rest looks good.
Fixed locally.
> 
> Thanks.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Thanks
Steven





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


Re: [FFmpeg-devel] [PATCH] avdevice/decklink: Add option to align Capture start time

2018-09-24 Thread Devin Heitmueller
Hello Karthick,


> On Sep 24, 2018, at 7:49 AM, Karthick J  wrote:
> 
> From: Karthick Jeyapal 
> 
> This option is useful for maintaining input synchronization across N
> different hardware devices deployed for 'N-way' redundancy.
> The system time of different hardware devices should be synchronized
> with protocols such as NTP or PTP, before using this option.

I can certainly see the usefulness of such a feature, but is the decklink 
module really the right place for this?  This feels like something that should 
be done through a filter (either as a multimedia filter or a BSF).

Does anyone else have an suggestions as to a better place to do this?

Devin

---
Devin Heitmueller - LTN Global Communications
dheitmuel...@ltnglobal.com

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


[FFmpeg-devel] [PATCH] avfilter/vf_curves: add planar rgb support

2018-09-24 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/vf_curves.c  | 194 +--
 tests/ref/fate/filter-curves |  10 +-
 2 files changed, 146 insertions(+), 58 deletions(-)

diff --git a/libavfilter/vf_curves.c b/libavfilter/vf_curves.c
index 19ab789152..883cc1c90c 100644
--- a/libavfilter/vf_curves.c
+++ b/libavfilter/vf_curves.c
@@ -70,6 +70,9 @@ typedef struct CurvesContext {
 int step;
 char *plot_filename;
 int is_16bit;
+int depth;
+
+int (*filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs);
 } CurvesContext;
 
 typedef struct ThreadData {
@@ -209,7 +212,7 @@ static int get_nb_points(const struct keypoint *d)
  * @see http://people.math.sfu.ca/~stockie/teaching/macm316/notes/splines.pdf
  */
 
-#define CLIP(v) (nbits == 8 ? av_clip_uint8(v) : av_clip_uint16(v))
+#define CLIP(v) (nbits == 8 ? av_clip_uint8(v) : av_clip_uintp2_c(v, nbits))
 
 static inline int interpolate(void *log_ctx, uint16_t *y,
   const struct keypoint *points, int nbits)
@@ -341,6 +344,10 @@ static int interpolate##nbits(void *log_ctx, uint16_t *y,  
 \
 }
 
 DECLARE_INTERPOLATE_FUNC(8)
+DECLARE_INTERPOLATE_FUNC(9)
+DECLARE_INTERPOLATE_FUNC(10)
+DECLARE_INTERPOLATE_FUNC(12)
+DECLARE_INTERPOLATE_FUNC(14)
 DECLARE_INTERPOLATE_FUNC(16)
 
 static int parse_psfile(AVFilterContext *ctx, const char *fname)
@@ -512,6 +519,12 @@ static int query_formats(AVFilterContext *ctx)
 AV_PIX_FMT_RGB0,   AV_PIX_FMT_BGR0,
 AV_PIX_FMT_RGB48,  AV_PIX_FMT_BGR48,
 AV_PIX_FMT_RGBA64, AV_PIX_FMT_BGRA64,
+AV_PIX_FMT_GBRP,   AV_PIX_FMT_GBRAP,
+AV_PIX_FMT_GBRP9,
+AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRAP10,
+AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRAP12,
+AV_PIX_FMT_GBRP14,
+AV_PIX_FMT_GBRP16, AV_PIX_FMT_GBRAP16,
 AV_PIX_FMT_NONE
 };
 AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
@@ -520,6 +533,120 @@ static int query_formats(AVFilterContext *ctx)
 return ff_set_common_formats(ctx, fmts_list);
 }
 
+static int filter_slice_packed(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
+{
+int x, y;
+const CurvesContext *curves = ctx->priv;
+const ThreadData *td = arg;
+const AVFrame *in  = td->in;
+const AVFrame *out = td->out;
+const int direct = out == in;
+const int step = curves->step;
+const uint8_t r = curves->rgba_map[R];
+const uint8_t g = curves->rgba_map[G];
+const uint8_t b = curves->rgba_map[B];
+const uint8_t a = curves->rgba_map[A];
+const int slice_start = (in->height *  jobnr   ) / nb_jobs;
+const int slice_end   = (in->height * (jobnr+1)) / nb_jobs;
+
+if (curves->is_16bit) {
+for (y = slice_start; y < slice_end; y++) {
+uint16_t   *dstp = (  uint16_t *)(out->data[0] + y * 
out->linesize[0]);
+const uint16_t *srcp = (const uint16_t *)(in ->data[0] + y *  
in->linesize[0]);
+
+for (x = 0; x < in->width * step; x += step) {
+dstp[x + r] = curves->graph[R][srcp[x + r]];
+dstp[x + g] = curves->graph[G][srcp[x + g]];
+dstp[x + b] = curves->graph[B][srcp[x + b]];
+if (!direct && step == 4)
+dstp[x + a] = srcp[x + a];
+}
+}
+} else {
+uint8_t   *dst = out->data[0] + slice_start * out->linesize[0];
+const uint8_t *src =  in->data[0] + slice_start *  in->linesize[0];
+
+for (y = slice_start; y < slice_end; y++) {
+for (x = 0; x < in->width * step; x += step) {
+dst[x + r] = curves->graph[R][src[x + r]];
+dst[x + g] = curves->graph[G][src[x + g]];
+dst[x + b] = curves->graph[B][src[x + b]];
+if (!direct && step == 4)
+dst[x + a] = src[x + a];
+}
+dst += out->linesize[0];
+src += in ->linesize[0];
+}
+}
+return 0;
+}
+
+static int filter_slice_planar(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
+{
+int x, y;
+const CurvesContext *curves = ctx->priv;
+const ThreadData *td = arg;
+const AVFrame *in  = td->in;
+const AVFrame *out = td->out;
+const int direct = out == in;
+const int step = curves->step;
+const uint8_t r = curves->rgba_map[R];
+const uint8_t g = curves->rgba_map[G];
+const uint8_t b = curves->rgba_map[B];
+const uint8_t a = curves->rgba_map[A];
+const int slice_start = (in->height *  jobnr   ) / nb_jobs;
+const int slice_end   = (in->height * (jobnr+1)) / nb_jobs;
+
+if (curves->is_16bit) {
+for (y = slice_start; y < slice_end; y++) {
+uint16_t   *dstrp = (  uint16_t *)(out->data[r] + y * 
out->linesize[r]);
+uint16_t   *dstgp = (  uint16_t *)(out->data[g] + y * 
out->linesize[g]);
+uint16_t   *dstbp = (  uint16_t *)(out->

[FFmpeg-devel] h264 decoding question

2018-09-24 Thread Jimmy Bhaktha
Hi

I am working on an application based on FFMPEG version 3.4.2 where the RTSP
packets from the camera are captured and store using python. The decoder
application is run later.  The application receives a  byte array which is
the actual packet. The goal is to decode the received packet and convert it
to RGB from YUV.

When I feed it packets I see the following output

Creating the codec h264
Creating the codec context
[h264 @ 0x557a3846d880] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x557a3846d880] nal_unit_type: 8, nal_ref_idc: 3


[h264 @ 0x557a3846d880] nal_unit_type: 5, nal_ref_idc: 3


[h264 @ 0x557a3846d880] Reinit context to 2688x1520, pix_fmt: yuvj420p


avcodec_send_packet=0


avcodec_receive_frame=0, pCodecCtx->frame_number=1
[swscaler @ 0x557a385fdb20] bad src image pointers
201


[h264 @ 0x557a3846d880] nal_unit_type: 1, nal_ref_idc: 3
[h264 @ 0x557a3846d880] nal_unit_type: 0, nal_ref_idc: 0


[h264 @ 0x557a3846d880] Unknown NAL code: 0 (103 bits)


avcodec_send_packet=0


avcodec_receive_frame=0, pCodecCtx->frame_number=2
[swscaler @ 0x557a385fdb20] bad src image pointers

I was wondering why I am getting the unknown NAL code. Also wondering why
the swscaler is complaining about bad src images.

Here is the sequence of calls in my code

1.  av_packet_alloc() and av_packet_init()
 - copy the encoded image to packet->data (I extend it by
AV_INPUT_BUFFER_PADDING_SIZE and set the memory to zero
2.  av_register_all();
3.  Create the codec and Codec Context for h264 and open it.
- I Copy the extra data from the encoded frame to this context.
4. Allocate the memory for the frames (YUV and RGB)
5. First time using the coded I call decode - I see the codec context now
has the correct values for height and width.
- For decoding I use the avcodec_send_packet and check in a while loop
for avcodec_receive_frame() I see the number of decoded frames in the codec
context goes up (pCodecCtx->frame_number)
6. Use this codec context to set up the sws_context
7. Use the sws_context and the YUV frame decoded to get the RGB frame.


I based the code on the ffmpeg decoding_video,cpp example and the tutorial
at http://dranger.com/ffmpeg/tutorial01.html . I am trying to figure out
why I am getting the errors above.
Thanks for your help in advance.

-- 
Jimmy Bhaktha
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/ivfenc: fix writing codec tag

2018-09-24 Thread Jan Ekström
On Mon, Sep 24, 2018 at 3:57 AM, James Almer  wrote:
> The value in AVCodecParameters->codec_tag may not be correct for IVF,
> as it's the case when remuxing AV1 streams from mp4, so ignore it and
> write the correct value based on codec ID instead.
>
> Signed-off-by: James Almer 
> ---
>  libavformat/ivfenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
> index af803d59ee..66441a2a43 100644
> --- a/libavformat/ivfenc.c
> +++ b/libavformat/ivfenc.c
> @@ -46,7 +46,7 @@ static int ivf_write_header(AVFormatContext *s)
>  avio_write(pb, "DKIF", 4);
>  avio_wl16(pb, 0); // version
>  avio_wl16(pb, 32); // header length
> -avio_wl32(pb, par->codec_tag ? par->codec_tag :
> +avio_wl32(pb,
>par->codec_id == AV_CODEC_ID_VP9 ? AV_RL32("VP90") :
>par->codec_id == AV_CODEC_ID_VP8 ? AV_RL32("VP80") : 
> AV_RL32("AV01"));

In the future we might want to make a mapping array, but for now this
looks a-OK. Unfortunately the tags for AV1 do not match between IVF
and ISOBMFF.

LGTM.

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


Re: [FFmpeg-devel] h264 decoding question

2018-09-24 Thread Lou Logan
On Mon, Sep 24, 2018, at 8:43 AM, Jimmy Bhaktha wrote:
> Hi
> 
> I am working on an application based on FFMPEG version 3.4.2 where the RTSP
> packets from the camera are captured and store using python. The decoder
> application is run later.  The application receives a  byte array which is
> the actual packet. The goal is to decode the received packet and convert it
> to RGB from YUV.
[...]

This mailing list (ffmpeg-devel) is for patch submissions and discussions 
related to the development of FFmpeg. I noticed you also crossposted this to 
ffmpeg-user which is for questions involving the FFmpeg command-line tools 
(ffmpeg, ffplay, ffprobe).

You should ask for help at the libav-user mailing list which is for questions 
involving the FFmpeg libraries.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavformat/segment: strftime date sub-directories

2018-09-24 Thread James Courtier-Dutton
On 24 September 2018 at 13:48, Moritz Barsnick  wrote:

> On Mon, Sep 24, 2018 at 12:39:42 +0100, James Courtier-Dutton wrote:
>
> > Automatically create sub-directories if needed based on date.
> > E.g.
> > ffmpeg ... -timelimit 2147483647 -f segment -strftime 1 -segment_time 10
> "%Y/%m/%d/%Y-%m-%d_%H-%M-%S.mkv"
> [...]
> > +static int mkdir_p(const char *path) {
>
> Is this code duplicated from libavformat/hlsenc.c?
>
> I don't know what the policy is, and how code from hls vs. segment has
> been deduplicated previously, but it seems like this is a candidate for
> being careful.
>
>
It is a duplicate from hisenc.c.  hisenc already has this "create
sub-directories" feature, but I needed it for the segment use case.
I made it static so that it would be treated as local to the .c file.
I don't know ffmpeg well enough to know how best to de-duplicate it.
I am happy to update my patch, if someone can give me a pointer as to what
to do.

Kind Regards

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


Re: [FFmpeg-devel] [PATCH] avformat/ivfenc: fix writing codec tag

2018-09-24 Thread James Almer
On 9/24/2018 2:54 PM, Jan Ekström wrote:
> On Mon, Sep 24, 2018 at 3:57 AM, James Almer  wrote:
>> The value in AVCodecParameters->codec_tag may not be correct for IVF,
>> as it's the case when remuxing AV1 streams from mp4, so ignore it and
>> write the correct value based on codec ID instead.
>>
>> Signed-off-by: James Almer 
>> ---
>>  libavformat/ivfenc.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
>> index af803d59ee..66441a2a43 100644
>> --- a/libavformat/ivfenc.c
>> +++ b/libavformat/ivfenc.c
>> @@ -46,7 +46,7 @@ static int ivf_write_header(AVFormatContext *s)
>>  avio_write(pb, "DKIF", 4);
>>  avio_wl16(pb, 0); // version
>>  avio_wl16(pb, 32); // header length
>> -avio_wl32(pb, par->codec_tag ? par->codec_tag :
>> +avio_wl32(pb,
>>par->codec_id == AV_CODEC_ID_VP9 ? AV_RL32("VP90") :
>>par->codec_id == AV_CODEC_ID_VP8 ? AV_RL32("VP80") : 
>> AV_RL32("AV01"));
> 
> In the future we might want to make a mapping array, but for now this
> looks a-OK. Unfortunately the tags for AV1 do not match between IVF
> and ISOBMFF.

There is a mapping array, codec_ivf_tags[], but since av01 == AV01 when
doing a case insensitive check, par->codec_tag ends up as the former
when remuxing from mp4 to ivf, at least with ffmpeg.c

> 
> LGTM.

Pushed, thanks.

> 
> Jan
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 

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


Re: [FFmpeg-devel] h264 decoding question

2018-09-24 Thread Jimmy Bhaktha
Sorry about that - thanks I will follow up on that mailing list.

--
Jimmy


On Mon, Sep 24, 2018 at 11:46 AM Lou Logan  wrote:

> On Mon, Sep 24, 2018, at 8:43 AM, Jimmy Bhaktha wrote:
> > Hi
> >
> > I am working on an application based on FFMPEG version 3.4.2 where the
> RTSP
> > packets from the camera are captured and store using python. The decoder
> > application is run later.  The application receives a  byte array which
> is
> > the actual packet. The goal is to decode the received packet and convert
> it
> > to RGB from YUV.
> [...]
>
> This mailing list (ffmpeg-devel) is for patch submissions and discussions
> related to the development of FFmpeg. I noticed you also crossposted this
> to ffmpeg-user which is for questions involving the FFmpeg command-line
> tools (ffmpeg, ffplay, ffprobe).
>
> You should ask for help at the libav-user mailing list which is for
> questions involving the FFmpeg libraries.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


-- 
Jimmy Bhaktha
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] cache: read ahead to avoid excessive small requests

2018-09-24 Thread Michael Niedermayer
On Sun, Sep 23, 2018 at 08:52:06PM +0200, Robert Nagy wrote:
> On Sun, Sep 23, 2018 at 1:40 PM Michael Niedermayer
>  wrote:
> >
> > On Sat, Sep 22, 2018 at 07:32:28PM +0200, Robert Nagy wrote:
> > > diff --git a/libavformat/cache.c b/libavformat/cache.c
> > > index 66bbbf54c9..48ff5ab363 100644
> > > --- a/libavformat/cache.c
> > > +++ b/libavformat/cache.c
> > > @@ -153,6 +153,38 @@ fail:
> > >  return ret;
> > >  }
> > >
> > > +static int cache_read_ahead(URLContext *h)
> > > +{
> > > +Context *c= h->priv_data;
> > > +int64_t r, read_ahead, pos;
> > > +uint8_t buf[32768];
> > > +
> > > +pos = c->logical_pos;
> > > +read_ahead = c->read_ahead_limit < 0
> > > +? 512 * 512
> > > +: FFMIN(512 * 512, c->read_ahead_limit);
> > > +
> > > +while (read_ahead > 0) {
> > > +r = ffurl_read(c->inner, buf, FFMIN(read_ahead, sizeof(buf)));
> > > +if (r == AVERROR_EOF) {
> > > +c->is_true_eof = 1;
> > > +av_assert0(c->end >= c->logical_pos);
> > > +}
> > > +if (r<=0)
> > > +break;
> > > +c->inner_pos += r;
> > > +
> > > +add_entry(h, buf, r);
> > > +c->logical_pos += r;
> > > +c->end = FFMAX(c->end, c->logical_pos);
> > > +read_ahead -= r;
> > > +}
> > > +
> > > +c->logical_pos = pos;
> > > +
> > > +return r < 0 ? r : 0;
> > > +}
> > > +
> > >  static int cache_read(URLContext *h, unsigned char *buf, int size)
> > >  {
> > >  Context *c= h->priv_data;
> >
> > > @@ -215,6 +247,10 @@ static int cache_read(URLContext *h, unsigned
> > > char *buf, int size)
> >
> > still not cleanly applying (due to new lines)
> >
> > Applying: cache: read ahead to avoid excessive small requests
> > error: corrupt patch at line 45
> > error: could not build fake ancestor
> > Patch failed at 0001 cache: read ahead to avoid excessive small requests
> > hint: Use 'git am --show-current-patch' to see the failed patch
> > When you have resolved this problem, run "git am --continue".
> > If you prefer to skip this patch, run "git am --skip" instead.
> > To restore the original branch and stop patching, run "git am --abort".
> >
> >
> > [...]
> >
> > --
> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >
> > The greatest way to live with honor in this world is to be what we pretend
> > to be. -- Socrates
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

>  cache.c |  111 
> 
>  1 file changed, 84 insertions(+), 27 deletions(-)
> 5a1f791cd8dd72085fc27c9cdbf2d41a87f24fee  
> 0001-cache-read-ahead-to-avoid-excessive-small-requests.patch
> From 17be70d9ffbfd1f55770e81958b597994abf2c99 Mon Sep 17 00:00:00 2001
> From: Robert Nagy 
> Date: Sat, 22 Sep 2018 19:18:54 +0200
> Subject: [PATCH] cache: read ahead to avoid excessive small requests
> 

> This "fakes" a filler thread for reading ahead.

applies cleanly now, but why fake ?
reading alot more than requested would cause extra latency even if the user
application runs the format code in a seperate thread
It would be better to avoid this and not block a request for "block 1" any
longer than it takes to read "block 1"


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Observe your enemies, for they first find out your faults. -- Antisthenes


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


Re: [FFmpeg-devel] [PATCH v2] lavf/mxfenc: support creating s436m data tracks

2018-09-24 Thread Baptiste Coudurier
On Thu, Jul 19, 2018 at 2:32 PM Michael Niedermayer 
wrote:

> On Wed, Jul 04, 2018 at 03:06:54PM -0700, Baptiste Coudurier wrote:
> > ---
> >  libavformat/mxf.c|  1 +
> >  libavformat/mxfdec.c |  2 ++
> >  libavformat/mxfenc.c | 41 +
> >  libavformat/utils.c  |  6 +-
> >  4 files changed, 45 insertions(+), 5 deletions(-)
> [...]
> > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > index c9cdd2b470..36a32ad9c2 100644
> > --- a/libavformat/utils.c
> > +++ b/libavformat/utils.c
> > @@ -1003,6 +1003,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >  *pnum = frame_size;
> >  *pden = sample_rate;
> >  break;
> > +case AVMEDIA_TYPE_DATA:
> > +*pnum = st->time_base.num;
> > +*pden = st->time_base.den;
> > +break;
> >  default:
> >  break;
> >  }
> > @@ -1405,7 +1409,7 @@ static void compute_pkt_fields(AVFormatContext *s,
> AVStream *st,
> >  presentation_delayed, delay, av_ts2str(pkt->pts),
> av_ts2str(pkt->dts), av_ts2str(st->cur_dts));
> >
> >  /* update flags */
> > -if (is_intra_only(st->codecpar->codec_id))
> > +if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA ||
> is_intra_only(st->codecpar->codec_id))
> >  pkt->flags |= AV_PKT_FLAG_KEY;
> >  #if FF_API_CONVERGENCE_DURATION
> >  FF_DISABLE_DEPRECATION_WARNINGS
>
> This should be a seperate patch.
> Also i think forcing duration=1 is not correct for all AVMEDIA_TYPE_DATA
> for example there are ID3 and fonts. These would i guess if they have a
> timebase set apply to more than 1 "unit"
>

I applied the separate patch.
Will apply this patch shortly, addressing Marton comment.

Thanks!

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


Re: [FFmpeg-devel] [PATCH] avformat/utils: set AV_PKT_FLAG_KEY for data packets

2018-09-24 Thread Baptiste Coudurier
On Tue, Aug 21, 2018 at 12:19 PM Baptiste Coudurier <
baptiste.coudur...@gmail.com> wrote:

> On Mon, Jul 30, 2018 at 11:16 AM, Baptiste Coudurier <
> baptiste.coudur...@gmail.com> wrote:
>
>> ---
>>  libavformat/utils.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavformat/utils.c b/libavformat/utils.c
>> index c9cdd2b470..b15f20dd23 100644
>> --- a/libavformat/utils.c
>> +++ b/libavformat/utils.c
>> @@ -1405,7 +1405,7 @@ static void compute_pkt_fields(AVFormatContext *s,
>> AVStream *st,
>>  presentation_delayed, delay, av_ts2str(pkt->pts),
>> av_ts2str(pkt->dts), av_ts2str(st->cur_dts));
>>
>>  /* update flags */
>> -if (is_intra_only(st->codecpar->codec_id))
>> +if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA ||
>> is_intra_only(st->codecpar->codec_id))
>>  pkt->flags |= AV_PKT_FLAG_KEY;
>>  #if FF_API_CONVERGENCE_DURATION
>>  FF_DISABLE_DEPRECATION_WARNINGS
>>
>
> Will apply.
>

Applied

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


Re: [FFmpeg-devel] [PATCH 2/9] avcodec/gdv: Replace divisions by shifts in rescale()

2018-09-24 Thread Michael Niedermayer
On Mon, Aug 20, 2018 at 12:42:29AM +0200, Michael Niedermayer wrote:
> On Sun, Aug 05, 2018 at 11:55:06PM +0200, Nicolas George wrote:
> > Michael Niedermayer (2018-08-05):
> > > thats done in the next patch
> > 
> > Indeed, except for the part where the variable are turned to unsigned to
> > let the compiler optimize the division. Sorry to have missed that.
> 
> are you ok with leaving the shifts as in the patchset or should i redo the
> patchset with unsigned ?

CC-ing you so you dont miss this (though its not important)

if i hear nothing from anyone i will apply the patchset as is.
IIUC james is ok with that. 
But as said i can redo it with unsigned if people want.
Just dont want to spend time redoing a patchset when maybe everyone is fine
with it after the discussions. (its hard to read peoples preferance from
silence ...)

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

You can kill me, but you cannot change the truth.


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


Re: [FFmpeg-devel] [PATCH] avcodec: add an AV1 parser

2018-09-24 Thread Mark Thompson
On 24/09/18 01:12, James Almer wrote:
> Simple parser to set keyframes, frame type, structure, width, height, and 
> pixel
> format, plus stream profile and level.
> 
> Signed-off-by: James Almer 
> ---
> Missing Changelog entry and version bump.
> 
> This depends on "[PATCH v2 2/3] lavc: Add coded bitstream read/write support
> for AV1" which should be committed in the coming days.
> 
> The AVCodecParser.split() implementation, added for the sake of completeness,
> is very naive and much like the h264 and hevc ones can result in useless OBUs
> being "extracted", but since it's no longer used by libavformat to fill global
> headers when reading raw containers it shouldn't really matter. It's pretty
> much used only by the remove_extradata bsf at this point.
> 
>  configure   |   1 +
>  libavcodec/Makefile |   1 +
>  libavcodec/av1_parser.c | 218 
>  libavcodec/parsers.c|   1 +
>  4 files changed, 221 insertions(+)
>  create mode 100644 libavcodec/av1_parser.c
> 
> diff --git a/configure b/configure
> index ca8b599b63..b46c86ec95 100755
> --- a/configure
> +++ b/configure
> @@ -3020,6 +3020,7 @@ wmv3_crystalhd_decoder_select="crystalhd"
>  
>  # parsers
>  aac_parser_select="adts_header"
> +av1_parser_select="cbs_av1"
>  h264_parser_select="golomb h264dsp h264parse"
>  hevc_parser_select="hevcparse"
>  mpegaudio_parser_select="mpegaudioheader"
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index b2c6995f9a..dc28892e64 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -1006,6 +1006,7 @@ OBJS-$(CONFIG_AAC_PARSER)  += aac_parser.o 
> aac_ac3_parser.o \
>mpeg4audio.o
>  OBJS-$(CONFIG_AC3_PARSER)  += ac3tab.o aac_ac3_parser.o
>  OBJS-$(CONFIG_ADX_PARSER)  += adx_parser.o adx.o
> +OBJS-$(CONFIG_AV1_PARSER)  += av1_parser.o
>  OBJS-$(CONFIG_AVS2_PARSER) += avs2_parser.o
>  OBJS-$(CONFIG_BMP_PARSER)  += bmp_parser.o
>  OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o
> diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c
> new file mode 100644
> index 00..b2e19e2119
> --- /dev/null
> +++ b/libavcodec/av1_parser.c
> @@ -0,0 +1,218 @@
> +/*
> + * AV1 parser
> + *
> + * Copyright (C) 2018 James Almer 
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include "av1_parse.h"
> +#include "cbs.h"
> +#include "cbs_av1.h"
> +#include "parser.h"
> +
> +typedef struct AV1ParseContext {
> +CodedBitstreamContext *cbc;
> +CodedBitstreamFragment temporal_unit;
> +int parsed_extradata;
> +} AV1ParseContext;
> +
> +static int av1_parser_parse(AVCodecParserContext *ctx,
> +AVCodecContext *avctx,
> +const uint8_t **out_data, int *out_size,
> +const uint8_t *data, int size)
> +{
> +AV1ParseContext *s = ctx->priv_data;
> +CodedBitstreamFragment *td = &s->temporal_unit;
> +CodedBitstreamAV1Context *av1 = s->cbc->priv_data;
> +int ret;
> +
> +*out_data = data;
> +*out_size = size;
> +
> +ctx->key_frame = -1;
> +ctx->pict_type = AV_PICTURE_TYPE_NONE;
> +ctx->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
> +
> +if (avctx->extradata_size && !s->parsed_extradata) {
> +ret = ff_cbs_read(s->cbc, td, avctx->extradata, 
> avctx->extradata_size);
> +if (ret < 0) {
> +av_log(avctx, AV_LOG_ERROR, "Failed to parse extradata.\n");
> +return size;
> +}
> +
> +s->parsed_extradata = 1;
> +
> +ff_cbs_fragment_uninit(s->cbc, td);
> +}
> +
> +ret = ff_cbs_read(s->cbc, td, data, size);
> +if (ret < 0) {
> +av_log(avctx, AV_LOG_ERROR, "Failed to parse temporal unit.\n");
> +return size;
> +}
> +
> +if (!av1->sequence_header) {
> +av_log(avctx, AV_LOG_ERROR, "No sequence header available\n");
> +goto end;
> +}
> +
> +for (int i = 0; i < td->nb_units; i++) {
> +CodedBitstreamUnit *unit = &td->units[i];
> +AV1RawOBU *obu = unit->content;
> +AV1RawSequenceHeader *seq = av1->sequ

Re: [FFmpeg-devel] [PATCH] avcodec: add an AV1 parser

2018-09-24 Thread James Almer
On 9/24/2018 8:41 PM, Mark Thompson wrote:
> On 24/09/18 01:12, James Almer wrote:
>> Simple parser to set keyframes, frame type, structure, width, height, and 
>> pixel
>> format, plus stream profile and level.
>>
>> Signed-off-by: James Almer 
>> ---
>> Missing Changelog entry and version bump.
>>
>> This depends on "[PATCH v2 2/3] lavc: Add coded bitstream read/write support
>> for AV1" which should be committed in the coming days.
>>
>> The AVCodecParser.split() implementation, added for the sake of completeness,
>> is very naive and much like the h264 and hevc ones can result in useless OBUs
>> being "extracted", but since it's no longer used by libavformat to fill 
>> global
>> headers when reading raw containers it shouldn't really matter. It's pretty
>> much used only by the remove_extradata bsf at this point.
>>
>>  configure   |   1 +
>>  libavcodec/Makefile |   1 +
>>  libavcodec/av1_parser.c | 218 
>>  libavcodec/parsers.c|   1 +
>>  4 files changed, 221 insertions(+)
>>  create mode 100644 libavcodec/av1_parser.c
>>
>> diff --git a/configure b/configure
>> index ca8b599b63..b46c86ec95 100755
>> --- a/configure
>> +++ b/configure
>> @@ -3020,6 +3020,7 @@ wmv3_crystalhd_decoder_select="crystalhd"
>>  
>>  # parsers
>>  aac_parser_select="adts_header"
>> +av1_parser_select="cbs_av1"
>>  h264_parser_select="golomb h264dsp h264parse"
>>  hevc_parser_select="hevcparse"
>>  mpegaudio_parser_select="mpegaudioheader"
>> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
>> index b2c6995f9a..dc28892e64 100644
>> --- a/libavcodec/Makefile
>> +++ b/libavcodec/Makefile
>> @@ -1006,6 +1006,7 @@ OBJS-$(CONFIG_AAC_PARSER)  += aac_parser.o 
>> aac_ac3_parser.o \
>>mpeg4audio.o
>>  OBJS-$(CONFIG_AC3_PARSER)  += ac3tab.o aac_ac3_parser.o
>>  OBJS-$(CONFIG_ADX_PARSER)  += adx_parser.o adx.o
>> +OBJS-$(CONFIG_AV1_PARSER)  += av1_parser.o
>>  OBJS-$(CONFIG_AVS2_PARSER) += avs2_parser.o
>>  OBJS-$(CONFIG_BMP_PARSER)  += bmp_parser.o
>>  OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o
>> diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c
>> new file mode 100644
>> index 00..b2e19e2119
>> --- /dev/null
>> +++ b/libavcodec/av1_parser.c
>> @@ -0,0 +1,218 @@
>> +/*
>> + * AV1 parser
>> + *
>> + * Copyright (C) 2018 James Almer 
>> + *
>> + * This file is part of FFmpeg.
>> + *
>> + * FFmpeg is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU Lesser General Public
>> + * License as published by the Free Software Foundation; either
>> + * version 2.1 of the License, or (at your option) any later version.
>> + *
>> + * FFmpeg is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with FFmpeg; if not, write to the Free Software
>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
>> USA
>> + */
>> +
>> +#include "av1_parse.h"
>> +#include "cbs.h"
>> +#include "cbs_av1.h"
>> +#include "parser.h"
>> +
>> +typedef struct AV1ParseContext {
>> +CodedBitstreamContext *cbc;
>> +CodedBitstreamFragment temporal_unit;
>> +int parsed_extradata;
>> +} AV1ParseContext;
>> +
>> +static int av1_parser_parse(AVCodecParserContext *ctx,
>> +AVCodecContext *avctx,
>> +const uint8_t **out_data, int *out_size,
>> +const uint8_t *data, int size)
>> +{
>> +AV1ParseContext *s = ctx->priv_data;
>> +CodedBitstreamFragment *td = &s->temporal_unit;
>> +CodedBitstreamAV1Context *av1 = s->cbc->priv_data;
>> +int ret;
>> +
>> +*out_data = data;
>> +*out_size = size;
>> +
>> +ctx->key_frame = -1;
>> +ctx->pict_type = AV_PICTURE_TYPE_NONE;
>> +ctx->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
>> +
>> +if (avctx->extradata_size && !s->parsed_extradata) {
>> +ret = ff_cbs_read(s->cbc, td, avctx->extradata, 
>> avctx->extradata_size);
>> +if (ret < 0) {
>> +av_log(avctx, AV_LOG_ERROR, "Failed to parse extradata.\n");
>> +return size;
>> +}
>> +
>> +s->parsed_extradata = 1;

I'll move this above the ff_cbs_read() call, btw. Otherwise if it fails,
it will keep being called on every av_parser_parse2() call and no packet
will ever be parsed.

>> +
>> +ff_cbs_fragment_uninit(s->cbc, td);
>> +}
>> +
>> +ret = ff_cbs_read(s->cbc, td, data, size);
>> +if (ret < 0) {
>> +av_log(avctx, AV_LOG_ERROR, "Failed to parse temporal unit.\n");
>> +return size;
>> +}
>> 

Re: [FFmpeg-devel] [PATCH v2 1/5] vaapi_encode: Support configurable slices

2018-09-24 Thread myp...@gmail.com
On Mon, Sep 24, 2018 at 5:53 AM Mark Thompson  wrote:
>
> This adds common code to query driver support and set appropriate
> address/size information for each slice.  It only supports rectangular
> slices for now, since that is the most common use-case.
> ---

Tested and verified with media-driver master branch
(https://github.com/intel/media-driver) in SKL.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] avcodec/wcmv: Fix integer overflows

2018-09-24 Thread Michael Niedermayer
Fixes: signed integer overflow: 262140 * 65535 cannot be represented in type 
'int'
Fixes: 
10090/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5691269368512512

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

diff --git a/libavcodec/wcmv.c b/libavcodec/wcmv.c
index 384ceecd32..ebd5ef66f4 100644
--- a/libavcodec/wcmv.c
+++ b/libavcodec/wcmv.c
@@ -113,6 +113,8 @@ static int decode_frame(AVCodecContext *avctx,
 bytestream2_skip(&bgb, 4);
 w = bytestream2_get_le16(&bgb);
 h = bytestream2_get_le16(&bgb);
+if (x + bpp * (int64_t)w * h > INT_MAX)
+return AVERROR_INVALIDDATA;
 x += bpp * w * h;
 }
 
@@ -140,6 +142,8 @@ static int decode_frame(AVCodecContext *avctx,
 bytestream2_skip(&gb, 4);
 w = bytestream2_get_le16(&gb);
 h = bytestream2_get_le16(&gb);
+if (x + bpp * (int64_t)w * h > INT_MAX)
+return AVERROR_INVALIDDATA;
 x += bpp * w * h;
 }
 
-- 
2.19.0

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


[FFmpeg-devel] [PATCH 2/2] avcodec/scpr: Skip frames which change nothing

2018-09-24 Thread Michael Niedermayer
Fixes: Timeout
Fixes: 
10292/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-5687943864254464

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

diff --git a/libavcodec/scpr.c b/libavcodec/scpr.c
index 81597aa4dc..e41fbbec13 100644
--- a/libavcodec/scpr.c
+++ b/libavcodec/scpr.c
@@ -516,7 +516,7 @@ static int decompress_p(AVCodecContext *avctx,
 int backstep = linesize - avctx->width;
 
 if (bytestream2_get_byte(gb) == 0)
-return 0;
+return 1;
 bytestream2_skip(gb, 1);
 init_rangecoder(&s->rc, gb);
 
@@ -813,6 +813,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame,
s->current_frame->linesize[0] / 4,
(uint32_t *)s->last_frame->data[0],
s->last_frame->linesize[0] / 4);
+if (ret == 1)
+return avpkt->size;
 } else {
 return AVERROR_PATCHWELCOME;
 }
-- 
2.19.0

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


Re: [FFmpeg-devel] [PATCH] libavcodec/vp8dec: fix the multi-thread HWAccel decode error

2018-09-24 Thread Xiang, Haihao
On Fri, 2018-09-21 at 16:05 +0800, myp...@gmail.com wrote:
> On Fri, Sep 21, 2018 at 12:08 PM Xiang, Haihao  wrote:
> > 
> > On Thu, 2018-08-09 at 15:09 +0800, Jun Zhao wrote:
> > > the root cause is update_dimentions call get_pixel_format will
> > 
> > Typo? s/dimentions/dimensions. And I see the same typo a few times in this
> > log.
> > 
> 
> Ha, a good catch.
> 
> > > trigger the hwaccel_uninit/hwaccel_init , in current context,
> > 
> > What is the decode error? Could you document the error a little or a link to
> > the
> > issue?
> > 
> 
> In mutil-thread decoding case with media-driver, Vp8 HWaccel decoder
> will carsh in some case.
> 
> > > there are 3 situations in the update_dimentions():
> > > 1. First time calling. No matter single thread or multithread,
> > >get_pixel_format() should be called after dimentions were
> > >set;
> > > 2. Dimention changed at the runtime. Dimention need to be
> > >updated when macroblocks_base is already allocated,
> > 
> > According to the code, ff_set_dimensions is called to overwrite previously
> > setup
> > dimensions when height is changed no matter
> > s->macroblocks_base is allocated or not. I think the HW frames and context
> > should be re-created as well for this case
> > 
> > But I am curious why height and width are treated differently in this
> > condition:
> > 
> > if (width  != s->avctx->width || ((width+15)/16 != s->mb_width ||
> > (height+15)/16 != s->mb_height) && s->macroblocks_base ||
> > height != s->avctx->height) {
> >...
> >ff_set_dimensions(...);
> > }
> > 
> > The condition for updating dimensions is simple in VP9:
> 
> Now I didn't test VP9 decoder in this case

Yes, this patch is for VP8 decoder only. What I mean is that ff_set_dimensions()
is called too when {width, height} are changed without allocated
macroblocks_base. So dim_reset should be 1 instead of (s->macroblocks_base !=
NULL) in the patch.

> > 
> >if (!(s->pix_fmt == s->gf_fmt && w == s->w && h == s->h)) {
> >ff_set_dimensions(...);
> >...
> >}
> > 
> > >get_pixel_format() should be called to recreate new frames
> > >according to updated dimention;
> > > 3. Multithread first time calling. After decoder init, the
> > >other threads will call update_dimentions() at first time
> > >to allocate macroblocks_base and set dimentions.
> > >But get_pixel_format() is shouldn't be called due to low
> > >level frames and context are already created.
> > > In this fix, we only call update_dimentions as need.
> > > 
> > > Signed-off-by: Wang, Shaofei 
> > > Reviewed-by: Jun, Zhao 
> > > ---
> > >  libavcodec/vp8.c |7 +--
> > >  1 files changed, 5 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
> > > index 3adfeac..18d1ada 100644
> > > --- a/libavcodec/vp8.c
> > > +++ b/libavcodec/vp8.c
> > > @@ -187,7 +187,7 @@ static av_always_inline
> > >  int update_dimensions(VP8Context *s, int width, int height, int is_vp7)
> > >  {
> > >  AVCodecContext *avctx = s->avctx;
> > > -int i, ret;
> > > +int i, ret, dim_reset = 0;
> > > 
> > >  if (width  != s->avctx->width || ((width+15)/16 != s->mb_width ||
> > > (height+15)/16 != s->mb_height) && s->macroblocks_base ||
> > >  height != s->avctx->height) {
> > > @@ -196,9 +196,12 @@ int update_dimensions(VP8Context *s, int width, int
> > > height, int is_vp7)
> > >  ret = ff_set_dimensions(s->avctx, width, height);
> > >  if (ret < 0)
> > >  return ret;
> > > +
> > > +dim_reset = (s->macroblocks_base != NULL);
> > 
> > 
> > >  }
> > > 
> > > -if (!s->actually_webp && !is_vp7) {
> > > +if ((s->pix_fmt == AV_PIX_FMT_NONE || dim_reset) &&
> > > + !s->actually_webp && !is_vp7) {
> > >  s->pix_fmt = get_pixel_format(s);
> > >  if (s->pix_fmt < 0)
> > >  return AVERROR(EINVAL);
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel