Re: [FFmpeg-devel] [PATCH 2/4] opus: Fix arithmetic overflows (per RFC8251)

2017-12-03 Thread Rostislav Pehlivanov
On 2 December 2017 at 17:36, Andrew D'Addesio  wrote:

> The relevant sections from the RFC are:
>
> Sec.6. Integer Wrap-Around in Inverse Gain Computation
> 32-bit integer overflow in Levinson recursion. Affects
> silk_is_lpc_stable().
>
> Sec.8. Cap on Band Energy
> NaN due to large log-energy value. Affects celt_denormalize().
>
> Signed-off-by: Andrew D'Addesio 
> ---
>  libavcodec/opus_celt.c |  3 ++-
>  libavcodec/opus_silk.c | 11 +--
>  2 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/opus_celt.c b/libavcodec/opus_celt.c
> index 84d4847..ff56041 100644
> --- a/libavcodec/opus_celt.c
> +++ b/libavcodec/opus_celt.c
> @@ -481,7 +481,8 @@ static void celt_denormalize(CeltFrame *f, CeltBlock
> *block, float *data)
>
>  for (i = f->start_band; i < f->end_band; i++) {
>  float *dst = data + (ff_celt_freq_bands[i] << f->size);
> -float norm = exp2f(block->energy[i] + ff_celt_mean_energy[i]);
> +float log_norm = block->energy[i] + ff_celt_mean_energy[i];
> +float norm = exp2f(FFMIN(log_norm, 32.0f));
>
>  for (j = 0; j < ff_celt_freq_range[i] << f->size; j++)
>  dst[j] *= norm;
> diff --git a/libavcodec/opus_silk.c b/libavcodec/opus_silk.c
> index 3c9c849..344333c 100644
> --- a/libavcodec/opus_silk.c
> +++ b/libavcodec/opus_silk.c
> @@ -185,8 +185,15 @@ static inline int silk_is_lpc_stable(const int16_t
> lpc[16], int order)
>  row = lpc32[k & 1];
>
>  for (j = 0; j < k; j++) {
> -int x = prevrow[j] - ROUND_MULL(prevrow[k - j - 1], rc, 31);
> -row[j] = ROUND_MULL(x, gain, fbits);
> +int x = av_sat_sub32(prevrow[j], ROUND_MULL(prevrow[k - j -
> 1], rc, 31));
> +int64_t tmp = ROUND_MULL(x, gain, fbits);
> +
> +/* per RFC 8251 section 6, if this calculation overflows, the
> filter
> +   is considered unstable. */
> +if (tmp < INT32_MIN || tmp > INT32_MAX)
> +return 0;
> +
> +row[j] = (int32_t)tmp;
>  }
>  }
>  }
> --
> 2.15.1.windows.2
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Pushed (split in 2 commits, not that it matters).
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 4/4] opus: Don't invert phase when downmixing to mono (per RFC8251)

2017-12-03 Thread Rostislav Pehlivanov
On 2 December 2017 at 17:46, Andrew D'Addesio  wrote:

> When decoding to downmixed mono, don't put the channels out of phase,
> as they will cancel out and create audible artifacts. (See
> RFC 8251 sec. 10.)
>
> Signed-off-by: Andrew D'Addesio 
> ---
>  libavcodec/opus_pvq.c | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/libavcodec/opus_pvq.c b/libavcodec/opus_pvq.c
> index 2f7aa74..f18c010 100644
> --- a/libavcodec/opus_pvq.c
> +++ b/libavcodec/opus_pvq.c
> @@ -643,7 +643,13 @@ static av_always_inline uint32_t
> quant_band_template(CeltPVQ *pvq, CeltFrame *f,
>  }
>  } else {
>  inv = (b > 2 << 3 && f->remaining2 > 2 << 3) ?
> ff_opus_rc_dec_log(rc, 2) : 0;
> +
> +/* Don't put the channels out of phase if we are decoding
> to downmixed
> + * mono as this subjectively sounds bad (RFC 8251 section
> 10). */
> +if (f->channels == 1)
> +inv = 0;
>  }
> +
>  itheta = 0;
>  }
>  qalloc = opus_rc_tell_frac(rc) - tell;
> --
> 2.15.1.windows.2
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

RFC8251 made this optional, pushed a new version which added an option to
toggle this.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/4] opus: Add Special Hybrid Folding (per RFC8251)

2017-12-03 Thread Rostislav Pehlivanov
On 2 December 2017 at 17:46, Andrew D'Addesio  wrote:

> This decoder-side change, introduced in RFC 8251 (section 9), slightly
> improves the decoded quality of 16kbps speech in Hybrid Mode.
>
> Differences can be seen/heard in testvector05.bit, testvector06.bit,
> and testvector12.bit in the RFC 6716/8251 testvectors found here:
> https://people.xiph.org/~greg/opus_testvectors/
>
> Signed-off-by: Andrew D'Addesio 
> ---
>  libavcodec/opus_celt.c | 18 +++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/opus_celt.c b/libavcodec/opus_celt.c
> index ff56041..2bbb96b 100644
> --- a/libavcodec/opus_celt.c
> +++ b/libavcodec/opus_celt.c
> @@ -712,10 +712,22 @@ static void celt_decode_bands(CeltFrame *f,
> OpusRangeCoder *rc)
>  b = av_clip_uintp2(FFMIN(f->remaining2 + 1, f->pulses[i] +
> curr_balance), 14);
>  }
>
> -if (ff_celt_freq_bands[i] - ff_celt_freq_range[i] >=
> ff_celt_freq_bands[f->start_band] &&
> -(update_lowband || lowband_offset == 0))
> +if ((ff_celt_freq_bands[i] - ff_celt_freq_range[i] >=
> ff_celt_freq_bands[f->start_band] ||
> +i == f->start_band + 1) && (update_lowband || lowband_offset
> == 0))
>  lowband_offset = i;
>
> +if (i == f->start_band + 1) {
> +/* Special Hybrid Folding (RFC 8251 section 9). Copy the
> first band into
> +the second to ensure the second band never has to use the
> LCG. */
> +int offset = 8 * ff_celt_freq_bands[i];
> +int count = 8 * (ff_celt_freq_range[i] -
> ff_celt_freq_range[i-1]);
> +
> +memcpy([offset], [offset - count], count *
> sizeof(float));
> +
> +if (f->channels == 2)
> +memcpy([offset], [offset - count], count *
> sizeof(float));
> +}
> +
>  /* Get a conservative estimate of the collapse_mask's for the
> bands we're
> going to be folding from. */
>  if (lowband_offset != 0 && (f->spread != CELT_SPREAD_AGGRESSIVE ||
> @@ -728,7 +740,7 @@ static void celt_decode_bands(CeltFrame *f,
> OpusRangeCoder *rc)
>  foldstart = lowband_offset;
>  while (ff_celt_freq_bands[--foldstart] > effective_lowband);
>  foldend = lowband_offset - 1;
> -while (ff_celt_freq_bands[++foldend] < effective_lowband +
> ff_celt_freq_range[i]);
> +while (++foldend < i && ff_celt_freq_bands[foldend] <
> effective_lowband + ff_celt_freq_range[i]);
>
>  cm[0] = cm[1] = 0;
>  for (j = foldstart; j < foldend; j++) {
> --
> 2.15.1.windows.2
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Pushed, updated fate stddev scores, new decoded samples should be uploaded
to fate soon too.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/4] libavutil: Add saturating subtraction functions

2017-12-03 Thread Rostislav Pehlivanov
On 2 December 2017 at 17:36, Andrew D'Addesio  wrote:

> Add av_sat_sub32 and av_sat_dsub32 as the subtraction analogues to
> av_sat_add32/av_sat_dadd32.
>
> Also clarify the formulas for dadd32/dsub32.
>
> Signed-off-by: Andrew D'Addesio 
> ---
>  libavutil/arm/intmath.h | 16 
>  libavutil/common.h  | 32 +++-
>  2 files changed, 47 insertions(+), 1 deletion(-)
>
> diff --git a/libavutil/arm/intmath.h b/libavutil/arm/intmath.h
> index 65e42c5..5311a7d 100644
> --- a/libavutil/arm/intmath.h
> +++ b/libavutil/arm/intmath.h
> @@ -94,6 +94,22 @@ static av_always_inline int av_sat_dadd32_arm(int a,
> int b)
>  return r;
>  }
>
> +#define av_sat_sub32 av_sat_sub32_arm
> +static av_always_inline int av_sat_sub32_arm(int a, int b)
> +{
> +int r;
> +__asm__ ("qsub %0, %1, %2" : "=r"(r) : "r"(a), "r"(b));
> +return r;
> +}
> +
> +#define av_sat_dsub32 av_sat_dsub32_arm
> +static av_always_inline int av_sat_dsub32_arm(int a, int b)
> +{
> +int r;
> +__asm__ ("qdsub %0, %1, %2" : "=r"(r) : "r"(a), "r"(b));
> +return r;
> +}
> +
>  #endif /* HAVE_ARMV6_INLINE */
>
>  #if HAVE_ASM_MOD_Q
> diff --git a/libavutil/common.h b/libavutil/common.h
> index 8142b31..5e03828 100644
> --- a/libavutil/common.h
> +++ b/libavutil/common.h
> @@ -260,13 +260,37 @@ static av_always_inline int av_sat_add32_c(int a,
> int b)
>   *
>   * @param  a first value
>   * @param  b value doubled and added to a
> - * @return sum with signed saturation
> + * @return sum sat(a + sat(2*b)) with signed saturation
>   */
>  static av_always_inline int av_sat_dadd32_c(int a, int b)
>  {
>  return av_sat_add32(a, av_sat_add32(b, b));
>  }
>
> +/**
> + * Subtract two signed 32-bit values with saturation.
> + *
> + * @param  a one value
> + * @param  b another value
> + * @return difference with signed saturation
> + */
> +static av_always_inline int av_sat_sub32_c(int a, int b)
> +{
> +return av_clipl_int32((int64_t)a - b);
> +}
> +
> +/**
> + * Subtract a doubled value from another value with saturation at both
> stages.
> + *
> + * @param  a first value
> + * @param  b value doubled and subtracted from a
> + * @return difference sat(a - sat(2*b)) with signed saturation
> + */
> +static av_always_inline int av_sat_dsub32_c(int a, int b)
> +{
> +return av_sat_sub32(a, av_sat_add32(b, b));
> +}
> +
>  /**
>   * Clip a float value into the amin-amax range.
>   * @param a value to clip
> @@ -513,6 +537,12 @@ static av_always_inline av_const int
> av_parity_c(uint32_t v)
>  #ifndef av_sat_dadd32
>  #   define av_sat_dadd32av_sat_dadd32_c
>  #endif
> +#ifndef av_sat_sub32
> +#   define av_sat_sub32 av_sat_sub32_c
> +#endif
> +#ifndef av_sat_dsub32
> +#   define av_sat_dsub32av_sat_dsub32_c
> +#endif
>  #ifndef av_clipf
>  #   define av_clipf av_clipf_c
>  #endif
> --
> 2.15.1.windows.2
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Pushed with a minor bump, these will be useful for some entropy coding
systems which rely on saturated adds.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] Add doc on ffmpeg-devel, update on -cvslog list (v3)

2017-12-03 Thread Jim DeLaHunt
The Developer Documentation had instructions to
subscribe to the ffmpeg-cvslog email list. But that is
no longer accurate. For the purposes in this section --
review of patches, discussion of development issues --
ffmpeg_devel is the appropriate email list. Some developers
may want to monitor ffmpeg-cvslog, but it is not mandatory.

This is v3 of this doc, based on discussion in thread

and in response to docs Maintainer comments in
.

1. In doc/developer.texi, add a new section about
ffmpeg-devel, based on existing text from ffmpeg-cvslog
section regarding discussion of patches and of
development issues. Reflect wording from discussion at

but with copy-editing to make wording more concise.

2. In doc/developer.texi, rewrite the ffmpeg-cvslog section
to match the current usage of ffmpeg-cvslog. Some
developers choose to follow this list, but it is not
mandatory.

There are a lot of improvements possible to the
Developer Documentation page, beyond this refactoring.
However, making those improvements is a much bigger
and more difficult task.  This change is "low hanging
fruit".

Signed-off-by: Jim DeLaHunt 
---
 doc/developer.texi | 26 ++
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/doc/developer.texi b/doc/developer.texi
index 89124a295c..65f2630e69 100644
--- a/doc/developer.texi
+++ b/doc/developer.texi
@@ -380,12 +380,30 @@ always check values read from some untrusted source 
before using them
 as array index or other risky things.
 
 @section Documentation/Other
+@subheading Subscribe to the ffmpeg-devel mailing list.
+It is important to be subscribed to the
+@uref{https://lists.ffmpeg.org/mailman/listinfo/ffmpeg-devel, ffmpeg-devel}
+mailing list. Almost any non-trivial patch is to be sent there
+for review. Other developers may have comments about your contribution.
+We expect you see those comments, and to improve it if requested.
+(N.B. Experienced committers have other channels,
+and may sometimes skip review for trivial fixes.)
+Also, discussion here about bug fixes and ffmpeg improvements by
+other developers may be helpful information for you.
+Finally, by being a list subscriber, your contribution will be posted
+immediately to the list, without the moderation hold 
+which messages from non-subscribers experience.
+
+However, it is more important to the project that we receive your
+patch than that you be subscribed to the ffmpeg-devel list. If you
+have a patch, and don't want to subscribe and discuss the patch,
+then please do send it to the list.
 
 @subheading Subscribe to the ffmpeg-cvslog mailing list.
-It is important to do this as the diffs of all commits are sent there and
-reviewed by all the other developers. Bugs and possible improvements or
-general questions regarding commits are discussed there. We expect you to
-react if problems with your code are uncovered.
+Diffs of all commits are sent to the
+@uref{https://lists.ffmpeg.org/mailman/listinfo/ffmpeg-cvslog, ffmpeg-cvslog}
+mailing list. Some developers read this list to review all code base changes
+from all sources. Subscribing to this list is not mandatory.
 
 @subheading Keep the documentation up to date.
 Update the documentation if you change behavior or add features. If you are
-- 
2.12.2

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


Re: [FFmpeg-devel] [PATCH 1/2] vaapi_h264: Add named options for setting profile and level

2017-12-03 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Saturday, December 2, 2017 11:36 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 1/2] vaapi_h264: Add named options for
> setting profile and level
> 
> On 01/12/17 05:24, Li, Zhong wrote:
> >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> >> Of Moritz Barsnick
> >> Sent: Thursday, November 30, 2017 10:33 PM
> >> To: FFmpeg development discussions and patches
> >> 
> >> Subject: Re: [FFmpeg-devel] [PATCH 1/2] vaapi_h264: Add named options
> >> for setting profile and level
> >>
> >> On Thu, Nov 30, 2017 at 08:52:21 +, Li, Zhong wrote:
>  +{ LEVEL("6",   60) },
>  +{ LEVEL("6.1", 61) },
>  +{ LEVEL("6.2", 62) },
> >>>
> >>> IIRC, level 5.2 is the maximum level of H264?
> >>
> >> Higher levels were introduced in 2016. Edition V12 of H.264 lists 6,
> >> 6.1 and 6.2 in Annex A, Table A-1. It basically lists the same thing
> >> as
> >> Wikipedia:
> >> https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels
> >
> > Exactly.
> To clarify, are you happy with this patch and the matching one for H.265
> now?

Yeah, LGTM. 
For h265, level_idc is not set by avctx->level in libx265, so we can just make 
it consistent with nvenc instead of libx264. 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avfilter/formats: fix wrong function name in error message

2017-12-03 Thread Jun Zhao

From 336be81bef86244a28b378b4c143ad8924c9e2d9 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Mon, 4 Dec 2017 12:50:34 +0800
Subject: [PATCH] avfilter/formats: fix wrong function name in error message

Use perdefined micro __FUNCTION__ rather than hard coding function name
to fix wrong function name in error message.

Signed-off-by: Jun Zhao 
---
 libavfilter/formats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index d4de862237..20a2c89719 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -72,7 +72,7 @@ do {
 for (j = 0; j < b->nb; j++)
 \
 if (a->fmts[i] == b->fmts[j]) {
 \
 if(k >= FFMIN(a->nb, b->nb)){  
 \
-av_log(NULL, AV_LOG_ERROR, "Duplicate formats in 
avfilter_merge_formats() detected\n"); \
+av_log(NULL, AV_LOG_ERROR, "Duplicate formats in %s 
detected\n", __FUNCTION__); \
 av_free(ret->fmts);
 \
 av_free(ret);  
 \
 return NULL;   
 \
-- 
2.14.1

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


[FFmpeg-devel] [PATCH] libavformat/dashdec: Fix for ticket 6658 (Dash demuxer segfault)

2017-12-03 Thread Colin NG
---
 libavformat/dashdec.c | 112 --
 1 file changed, 99 insertions(+), 13 deletions(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 3798649..d04bec0 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -148,6 +148,11 @@ static uint64_t get_current_time_in_sec(void)
 return  av_gettime() / 100;
 }
 
+static char * ishttp(char *url) {
+char *proto_name = avio_find_protocol_name(url);
+return av_strstart(proto_name, "http", NULL);
+}
+
 static uint64_t get_utc_date_time_insec(AVFormatContext *s, const char 
*datetime)
 {
 struct tm timeinfo;
@@ -392,7 +397,9 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
const char *url,
 else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5))
 return AVERROR_INVALIDDATA;
 
-ret = s->io_open(s, pb, url, AVIO_FLAG_READ, );
+av_freep(pb);
+ret = avio_open2(pb, url, AVIO_FLAG_READ, c->interrupt_callback, );
+
 if (ret >= 0) {
 // update cookies on http response with setcookies.
 char *new_cookies = NULL;
@@ -639,6 +646,87 @@ static int parse_manifest_segmenttimeline(AVFormatContext 
*s, struct representat
 return 0;
 }
 
+static int resolve_content_path(AVFormatContext *s, const char *url,  
xmlNodePtr *baseurl_nodes,  int n_baseurl_nodes) {
+
+int i;
+char *text;
+char *tmp_str = av_mallocz(MAX_URL_SIZE);
+char *tmp_str_2= av_mallocz(MAX_URL_SIZE);
+
+char *path = av_mallocz(MAX_URL_SIZE);
+int nameSize = 0;
+int updated = 0;
+
+if (!tmp_str || !tmp_str_2 || !path) {
+updated = AVERROR(ENOMEM);
+goto end;
+}
+
+av_strlcpy(tmp_str, url, strlen(url)+1);
+char *mpdName = strtok (tmp_str," /");
+
+while ((mpdName =strtok (NULL, "/"))) {
+nameSize = strlen(mpdName);
+}
+
+av_strlcpy (path, url, strlen(url)-nameSize+1);
+
+int rootId = 0;
+xmlNodePtr  *node = NULL;
+for (rootId = n_baseurl_nodes-1; rootId >0; rootId--) {
+if (!(node = baseurl_nodes[rootId])) {
+continue;
+}
+if (ishttp(xmlNodeGetContent(node))) {
+break;
+}
+}
+
+node = baseurl_nodes[rootId];
+char *baseurl = xmlNodeGetContent(node);
+char *root_url = (!av_strcasecmp(baseurl, ""))? path: baseurl;
+
+if (node) {
+xmlNodeSetContent(node, root_url);
+}
+
+int size = strlen(root_url);
+char *isRootHttp= ishttp(root_url);
+
+char token ='/';
+//if (root_url[size-1]==token) {
+if (av_strncasecmp(_url[size-1],, 1) != 0) {
+av_strlcat(root_url, "/", size+2);
+size+=2;
+}
+
+for (i = 0; i < n_baseurl_nodes; ++i) {
+if (i==rootId) {
+continue;
+}
+text = xmlNodeGetContent(baseurl_nodes[i]);
+if (text) {
+memset(tmp_str, 0, strlen(tmp_str));
+
+if (!ishttp(text) && isRootHttp) {
+av_strlcpy(tmp_str, root_url, size+1);
+}
+int start = (text[0]==token) ? 1: 0;
+memset(tmp_str_2, 0, strlen(tmp_str_2));
+av_strlcat(tmp_str, text+start, MAX_URL_SIZE);
+xmlFree(text);
+xmlNodeSetContent(baseurl_nodes[i], tmp_str);
+updated = 1;
+}
+}
+
+end:
+av_free(path);
+av_free(tmp_str);
+av_free(tmp_str_2);
+return updated;
+
+}
 static int parse_manifest_representation(AVFormatContext *s, const char *url,
  xmlNodePtr node,
  xmlNodePtr adaptionset_node,
@@ -698,6 +786,12 @@ static int parse_manifest_representation(AVFormatContext 
*s, const char *url,
 baseurl_nodes[2] = adaptionset_baseurl_node;
 baseurl_nodes[3] = representation_baseurl_node;
 
+ret = resolve_content_path(s, url, baseurl_nodes, 4);
+
+if (ret == AVERROR(ENOMEM)) {
+goto end;
+}
+
 if (representation_segmenttemplate_node || fragment_template_node) {
 fragment_timeline_node = NULL;
 fragment_templates_tab[0] = representation_segmenttemplate_node;
@@ -993,6 +1087,9 @@ static int parse_manifest(AVFormatContext *s, const char 
*url, AVIOContext *in)
 }
 
 mpd_baseurl_node = find_child_node_by_name(node, "BaseURL");
+if (!mpd_baseurl_node) {
+mpd_baseurl_node = xmlNewNode(node, "BaseURL");
+}
 
 // at now we can handle only one period, with the longest duration
 node = xmlFirstElementChild(node);
@@ -1315,6 +1412,7 @@ static int read_from_url(struct representation *pls, 
struct fragment *seg,
 } else {
 ret = avio_read(pls->input, buf, buf_size);
 }
+
 if (ret > 0)
 pls->cur_seg_offset += ret;
 
@@ -1343,18 +1441,6 @@ static int open_input(DASHContext *c, struct 
representation *pls, struct fragmen
 goto cleanup;
 }
 
-/* Seek to 

Re: [FFmpeg-devel] [PATCH] configure: Allow users to disable all hwaccel libraries

2017-12-03 Thread Gyan Doshi


On 11/30/2017 3:58 PM, Gyan Doshi wrote:
I added --disable-hwaccels during configure and noticed that all 
autodetected hwaccel libs were still being linked - 6 in my case, which 
makes for a more bloated binary than warranted.


Turns out the option only disables native components which make use of 
the hwaccel libs. The reporter of ticket #3906 had a similar concern.


Added option to disable all autodetected hwaccel libs.

Regards,
Gyan


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


Re: [FFmpeg-devel] [PATCH] hls: fix baseurl missing last char

2017-12-03 Thread Steven Liu
2017-12-02 10:03 GMT+08:00 Steven Liu :
> 2017-12-02 8:59 GMT+08:00 Michael Niedermayer :
>> On Fri, Dec 01, 2017 at 11:06:07AM +0100, Robert Nagy wrote:
>>> ---
>>>  libavformat/hlsenc.c | 5 +
>>>  1 file changed, 1 insertion(+), 4 deletions(-)
>>>
>>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>>> index cdfbf45823..dc8bf48791 100644
>>> --- a/libavformat/hlsenc.c
>>> +++ b/libavformat/hlsenc.c
>>> @@ -1921,14 +1921,11 @@ static int hls_write_header(AVFormatContext *s)
>>>  }
>>>
>>>  if (hls->baseurl) {
>>> -int baseurl_len;
>>> -baseurl_len = strlen(hls->baseurl);
>>> -vs->baseurl = av_malloc(baseurl_len);
>>> +vs->baseurl = av_strdup(hls->baseurl);
>>>  if (!vs->baseurl) {
>>>  ret = AVERROR(ENOMEM);
>>>  goto fail;
>>>  }
>>> -av_strlcpy(vs->baseurl, hls->baseurl, baseurl_len);
>>>  }
>>>
>>>  if ((hls->flags & HLS_SINGLE_FILE) && (hls->segment_type ==
>>> SEGMENT_TYPE_FMP4)) {
>>
>> this looks like a stray linebreak
>> this wont apply automatically
>
> Ok, let me apply it manually.
Pushed


Thanks


Steven
>
>
> Thanks
>>
>>
>> [...]
>> --
>> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>>
>> In a rich man's house there is no place to spit but his face.
>> -- Diogenes of Sinope
>>
>> ___
>> 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


[FFmpeg-devel] [PATCH] libavcodec/dvbsubdec: Fix for ticket 6796 (ffprobe show_frames ts dvbsubs infinite loop)

2017-12-03 Thread Colin NG
---
 libavcodec/dvbsubdec.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index a657b1d..29997a2 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -1596,7 +1596,7 @@ static int dvbsub_display_end_segment(AVCodecContext 
*avctx, const uint8_t *buf,
 }
 
 static int dvbsub_decode(AVCodecContext *avctx,
- void *data, int *data_size,
+ void *data, int *got_output,
  AVPacket *avpkt)
 {
 const uint8_t *buf = avpkt->data;
@@ -1654,7 +1654,7 @@ static int dvbsub_decode(AVCodecContext *avctx,
 int ret = 0;
 switch (segment_type) {
 case DVBSUB_PAGE_SEGMENT:
-ret = dvbsub_parse_page_segment(avctx, p, segment_length, sub, 
data_size);
+ret = dvbsub_parse_page_segment(avctx, p, segment_length, sub, 
got_output);
 got_segment |= 1;
 break;
 case DVBSUB_REGION_SEGMENT:
@@ -1676,7 +1676,7 @@ static int dvbsub_decode(AVCodecContext *avctx,
 got_dds = 1;
 break;
 case DVBSUB_DISPLAY_SEGMENT:
-ret = dvbsub_display_end_segment(avctx, p, segment_length, 
sub, data_size);
+ret = dvbsub_display_end_segment(avctx, p, segment_length, 
sub, got_output);
 if (got_segment == 15 && !got_dds && !avctx->width && 
!avctx->height) {
 // Default from ETSI EN 300 743 V1.3.1 (7.2.1)
 avctx->width  = 720;
@@ -1699,12 +1699,12 @@ static int dvbsub_decode(AVCodecContext *avctx,
 // segments then we need no further data.
 if (got_segment == 15) {
 av_log(avctx, AV_LOG_DEBUG, "Missing display_end_segment, 
emulating\n");
-dvbsub_display_end_segment(avctx, p, 0, sub, data_size);
+dvbsub_display_end_segment(avctx, p, 0, sub, got_output);
 }
 
 end:
 if(ret < 0) {
-*data_size = 0;
+*got_output = 0;
 avsubtitle_free(sub);
 return ret;
 } else {
-- 
2.7.4

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


[FFmpeg-devel] [PATCH] fftools/ffprobe: Fix for ticket 6796 (ffprobe show_frames ts dvbsubs infinite loop)

2017-12-03 Thread Colin NG
---
 fftools/ffprobe.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 0e7a771..6ddd81e 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2280,6 +2280,7 @@ static av_always_inline int process_frame(WriterContext 
*w,
 break;
 default:
 *packet_new = 0;
+break;
 }
 } else {
 *packet_new = 0;
@@ -2290,6 +2291,7 @@ static av_always_inline int process_frame(WriterContext 
*w,
 if (got_frame) {
 int is_sub = (par->codec_type == AVMEDIA_TYPE_SUBTITLE);
 nb_streams_frames[pkt->stream_index]++;
+got_frame = (par->codec_type == AVMEDIA_TYPE_SUBTITLE) ? 0: got_frame;
 if (do_show_frames)
 if (is_sub)
 show_subtitle(w, , ifile->streams[pkt->stream_index].st, 
fmt_ctx);
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH 1/2] v3 - SCTE extraction from mpegts

2017-12-03 Thread Steven Liu
2017-12-02 20:15 GMT+08:00 Sandeep Reddy :
> Hi,
>
> I applied the SCTE patch on hlsenc. But I am unable to find a way to
> intialize scte_interface of HLSContext .
>
> Please let me know ,how to intialize it

hlsenc initialize in hls_mux_init API, it is called by
hls_write_header, you can insert it into the API.

I will refine the hls_mux_init to ff_hls_muxer->init, that's no matter
you do the SCTE work.



Thanks

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


Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Fix parsing of edit list atoms with invalid elst entry count.

2017-12-03 Thread Carl Eugen Hoyos
2017-12-04 1:22 GMT+01:00 Michael Niedermayer :
> On Sun, Oct 29, 2017 at 01:39:06PM +0100, Michael Niedermayer wrote:
>> On Sat, Oct 28, 2017 at 08:26:16PM +0200, Michael Niedermayer wrote:
>> > On Thu, Oct 26, 2017 at 08:51:50PM -0700, Sasi Inguva wrote:
>> > > On Tue, Oct 24, 2017 at 2:48 PM, Michael Niedermayer 
>> > > > > > > wrote:
>> > >
>> > > > On Mon, Oct 23, 2017 at 04:18:28PM -0700, Sasi Inguva wrote:
>> > > > > Signed-off-by: Sasi Inguva 
>> > > > > ---
>> > > > >  libavformat/mov.c   | 15 +++-
>> > > > >  tests/fate/mov.mak  |  4 ++
>> > > > >  tests/ref/fate/mov-invalid-elst-entry-count | 57
>> > > > +
>> > > > >  3 files changed, 75 insertions(+), 1 deletion(-)
>> > > > >  create mode 100644 tests/ref/fate/mov-invalid-elst-entry-count
>> > > > >
>> > > > > diff --git a/libavformat/mov.c b/libavformat/mov.c
>> > > > > index b22a116140..424293ad93 100644
>> > > > > --- a/libavformat/mov.c
>> > > > > +++ b/libavformat/mov.c
>> > > > > @@ -4597,6 +4597,7 @@ static int mov_read_elst(MOVContext *c,
>> > > > AVIOContext *pb, MOVAtom atom)
>> > > > >  {
>> > > > >  MOVStreamContext *sc;
>> > > > >  int i, edit_count, version;
>> > > > > +int64_t elst_entry_size;
>> > > > >
>> > > > >  if (c->fc->nb_streams < 1 || c->ignore_editlist)
>> > > > >  return 0;
>> > > > > @@ -4605,6 +4606,15 @@ static int mov_read_elst(MOVContext *c,
>> > > > AVIOContext *pb, MOVAtom atom)
>> > > > >  version = avio_r8(pb); /* version */
>> > > > >  avio_rb24(pb); /* flags */
>> > > > >  edit_count = avio_rb32(pb); /* entries */
>> > > > > +atom.size -= 8;
>> > > > > +
>> > > > > +elst_entry_size = version == 1 ? 20 : 12;
>> > > > > +if (atom.size != edit_count * elst_entry_size &&
>> > > > > +c->fc->strict_std_compliance >= FF_COMPLIANCE_STRICT) {
>> > > > > +av_log(c->fc, AV_LOG_ERROR, "Invalid edit list entry_count: 
>> > > > > %d
>> > > > for elst atom of size: %"PRId64" bytes.\n",
>> > > > > +   edit_count, atom.size + 8);
>> > > > > +return AVERROR_INVALIDDATA;
>> > > > > +}
>> > > > >
>> > > > >  if (!edit_count)
>> > > > >  return 0;
>> > > > > @@ -4617,17 +4627,20 @@ static int mov_read_elst(MOVContext *c,
>> > > > AVIOContext *pb, MOVAtom atom)
>> > > > >  return AVERROR(ENOMEM);
>> > > > >
>> > > > >  av_log(c->fc, AV_LOG_TRACE, "track[%u].edit_count = %i\n",
>> > > > c->fc->nb_streams - 1, edit_count);
>> > > > > -for (i = 0; i < edit_count && !pb->eof_reached; i++) {
>> > > > > +for (i = 0; i < edit_count && atom.size > 0 && !pb->eof_reached;
>> > > > i++) {
>> > > > >  MOVElst *e = >elst_data[i];
>> > > > >
>> > > > >  if (version == 1) {
>> > > > >  e->duration = avio_rb64(pb);
>> > > > >  e->time = avio_rb64(pb);
>> > > > > +atom.size -= 16;
>> > > > >  } else {
>> > > > >  e->duration = avio_rb32(pb); /* segment duration */
>> > > > >  e->time = (int32_t)avio_rb32(pb); /* media time */
>> > > > > +atom.size -= 8;
>> > > > >  }
>> > > > >  e->rate = avio_rb32(pb) / 65536.0;
>> > > > > +atom.size -= 4;
>> > > > >  av_log(c->fc, AV_LOG_TRACE, "duration=%"PRId64" 
>> > > > > time=%"PRId64"
>> > > > rate=%f\n",
>> > > > > e->duration, e->time, e->rate);
>> > > >
>> > > > it would be simpler to adjust edit_count in case of ineqality.
>> > > > you already compute the elst_entry_size
>> > > > this would also avoid allocating a larger than needed array
>> > > >
>> > > > Done. Attaching the corrected patch.
>> > >
>> > > >
>> > > > [...]
>> > > >
>> > > > --
>> > > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>> > > >
>> > > > Many things microsoft did are stupid, but not doing something just 
>> > > > because
>> > > > microsoft did it is even more stupid. If everything ms did were stupid 
>> > > > they
>> > > > would be bankrupt already.
>> > > >
>> > > > ___
>> > > > ffmpeg-devel mailing list
>> > > > ffmpeg-devel@ffmpeg.org
>> > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> > > >
>> > > >
>> >
>> > >  libavformat/mov.c   |   21 +-
>> > >  tests/fate/mov.mak  |4 +
>> > >  tests/ref/fate/mov-invalid-elst-entry-count |   57 
>> > > 
>> > >  3 files changed, 81 insertions(+), 1 deletion(-)
>> > > c553340f66797876d039f408f83574a40c54d17b  
>> > > 0001-lavf-mov.c-Fix-parsing-of-edit-list-atoms-with-inval.patch
>> > > From 188602e662868a79c7f85e9193e9aedc9ba1a170 Mon Sep 17 00:00:00 2001
>> > > From: Sasi Inguva 
>> > > Date: Wed, 18 Oct 2017 20:11:16 -0700
>> > > Subject: [PATCH] lavf/mov.c: Fix parsing of edit list atoms 

Re: [FFmpeg-devel] [PATCH]lavc: Allow forcing work-around for x264 cabac 8x8 4:4:4 bug

2017-12-03 Thread Carl Eugen Hoyos
2017-12-04 1:56 GMT+01:00 Mark Thompson :
> On 04/12/17 00:09, Carl Eugen Hoyos wrote:

>> Attached patch fixes ticket #6717, files without sei can be produced
>> with remuxing and seeking, even if this is a (separate) bug, such
>> files exist in the wild.

> File are currently fixable by remuxing with:
>
> -bsf:v 'h264_metadata=sei_user_data=dc45e9bde6d948b7962cd820d923eeef+x264 - 
> core 150'

Thank you!

> Unfortunately that can't be applied directly when decoding,
> because -bsf isn't available as an input option.

> I don't really like the idea of adding the option because it does
> break correct files, but I guess it probably ends up being the
> pragmatic option for decoding.

Sorry, I don't understand: Do you mean if the user specifies
the work-around, it will break files encoded with current
x264? Isn't that the whole point of this (and every other)
work-around?

> Still, I think it might be sensible to at least add a big warning
> telling the user they're doing something stupid if this option
> is set and it finds x264_build is >= 151?

I believe you know that I am a big fan of warnings but printing
a warning when a user explicitely specifies an option? We
don't warn when an experimental encoder is used (not even
when we know it will segfault) and I don't think it is necessary.

Thank you, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 2/2] libavcodec/mediacodec: use AVMediaCodecDeviceContext hw_device_ctx if set

2017-12-03 Thread Aman Gupta
From: Aman Gupta 

---
 libavcodec/mediacodecdec.c|  2 +-
 libavcodec/mediacodecdec_common.c | 14 +-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index 39f5cbc045..eabf6d0648 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -520,7 +520,7 @@ static const AVCodecHWConfigInternal 
*mediacodec_hw_configs[] = {
 &(const AVCodecHWConfigInternal) {
 .public  = {
 .pix_fmt = AV_PIX_FMT_MEDIACODEC,
-.methods = AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
+.methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX,
 .device_type = AV_HWDEVICE_TYPE_NONE,
 },
 .hwaccel = NULL,
diff --git a/libavcodec/mediacodecdec_common.c 
b/libavcodec/mediacodecdec_common.c
index cb2f6ae5e5..a9147f3a08 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -24,6 +24,7 @@
 #include 
 
 #include "libavutil/common.h"
+#include "libavutil/hwcontext_mediacodec.h"
 #include "libavutil/mem.h"
 #include "libavutil/log.h"
 #include "libavutil/pixfmt.h"
@@ -476,7 +477,18 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx, 
MediaCodecDecContext *s,
 if (pix_fmt == AV_PIX_FMT_MEDIACODEC) {
 AVMediaCodecContext *user_ctx = avctx->hwaccel_context;
 
-if (user_ctx && user_ctx->surface) {
+if (avctx->hw_device_ctx) {
+AVHWDeviceContext *device_ctx = 
(AVHWDeviceContext*)(avctx->hw_device_ctx->data);
+if (device_ctx->type == AV_HWDEVICE_TYPE_MEDIACODEC) {
+if (device_ctx->hwctx) {
+AVMediaCodecDeviceContext *mediacodec_ctx = 
(AVMediaCodecDeviceContext *)device_ctx->hwctx;
+s->surface = 
ff_mediacodec_surface_ref(mediacodec_ctx->surface, avctx);
+av_log(avctx, AV_LOG_INFO, "Using surface %p\n", 
s->surface);
+}
+}
+}
+
+if (!s->surface && user_ctx && user_ctx->surface) {
 s->surface = ff_mediacodec_surface_ref(user_ctx->surface, avctx);
 av_log(avctx, AV_LOG_INFO, "Using surface %p\n", s->surface);
 }
-- 
2.13.6 (Apple Git-96)

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


[FFmpeg-devel] [PATCH v2 1/2] libavutil/hwcontext: add AV_HWDEVICE_TYPE_MEDIACODEC

2017-12-03 Thread Aman Gupta
From: Aman Gupta 

---
 libavutil/Makefile   |  1 +
 libavutil/hwcontext.c|  4 
 libavutil/hwcontext.h|  1 +
 libavutil/hwcontext_mediacodec.c | 50 
 libavutil/hwcontext_mediacodec.h | 36 +
 5 files changed, 92 insertions(+)
 create mode 100644 libavutil/hwcontext_mediacodec.c
 create mode 100644 libavutil/hwcontext_mediacodec.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 721784086c..0b73a14f0b 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -166,6 +166,7 @@ OBJS-$(CONFIG_OPENCL)   += 
hwcontext_opencl.o
 OBJS-$(CONFIG_VAAPI)+= hwcontext_vaapi.o
 OBJS-$(CONFIG_VIDEOTOOLBOX) += hwcontext_videotoolbox.o
 OBJS-$(CONFIG_VDPAU)+= hwcontext_vdpau.o
+OBJS-$(CONFIG_MEDIACODEC)   += hwcontext_mediacodec.o
 
 OBJS += $(COMPAT_OBJS:%=../compat/%)
 
diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index f47158f811..31ac12807b 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -56,6 +56,9 @@ static const HWContextType * const hw_table[] = {
 #if CONFIG_VIDEOTOOLBOX
 _hwcontext_type_videotoolbox,
 #endif
+#if CONFIG_MEDIACODEC
+_hwcontext_type_mediacodec,
+#endif
 NULL,
 };
 
@@ -69,6 +72,7 @@ static const char *const hw_type_names[] = {
 [AV_HWDEVICE_TYPE_VAAPI]  = "vaapi",
 [AV_HWDEVICE_TYPE_VDPAU]  = "vdpau",
 [AV_HWDEVICE_TYPE_VIDEOTOOLBOX] = "videotoolbox",
+[AV_HWDEVICE_TYPE_MEDIACODEC] = "mediacodec",
 };
 
 enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name)
diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
index 8d27b987df..f5a4b62387 100644
--- a/libavutil/hwcontext.h
+++ b/libavutil/hwcontext.h
@@ -35,6 +35,7 @@ enum AVHWDeviceType {
 AV_HWDEVICE_TYPE_D3D11VA,
 AV_HWDEVICE_TYPE_DRM,
 AV_HWDEVICE_TYPE_OPENCL,
+AV_HWDEVICE_TYPE_MEDIACODEC,
 };
 
 typedef struct AVHWDeviceInternal AVHWDeviceInternal;
diff --git a/libavutil/hwcontext_mediacodec.c b/libavutil/hwcontext_mediacodec.c
new file mode 100644
index 00..b0d8993e15
--- /dev/null
+++ b/libavutil/hwcontext_mediacodec.c
@@ -0,0 +1,50 @@
+/*
+ * 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 "config.h"
+
+#include "buffer.h"
+#include "common.h"
+#include "hwcontext.h"
+#include "hwcontext_internal.h"
+#include "hwcontext_mediacodec.h"
+
+static int mc_device_create(AVHWDeviceContext *ctx, const char *device,
+AVDictionary *opts, int flags)
+{
+if (device && device[0]) {
+av_log(ctx, AV_LOG_ERROR, "Device selection unsupported.\n");
+return AVERROR_UNKNOWN;
+}
+
+return 0;
+}
+
+const HWContextType ff_hwcontext_type_mediacodec = {
+.type = AV_HWDEVICE_TYPE_MEDIACODEC,
+.name = "mediacodec",
+
+.device_hwctx_size= sizeof(AVMediaCodecDeviceContext),
+
+.device_create= mc_device_create,
+
+.pix_fmts = (const enum AVPixelFormat[]){
+AV_PIX_FMT_MEDIACODEC,
+AV_PIX_FMT_NONE
+},
+};
diff --git a/libavutil/hwcontext_mediacodec.h b/libavutil/hwcontext_mediacodec.h
new file mode 100644
index 00..101a9806d5
--- /dev/null
+++ b/libavutil/hwcontext_mediacodec.h
@@ -0,0 +1,36 @@
+/*
+ * 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
+ */
+
+#ifndef AVUTIL_HWCONTEXT_MEDIACODEC_H
+#define AVUTIL_HWCONTEXT_MEDIACODEC_H
+
+/**
+ * MediaCodec details.
+ *
+ * Allocated as 

Re: [FFmpeg-devel] [PATCH]lavc: Allow forcing work-around for x264 cabac 8x8 4:4:4 bug

2017-12-03 Thread Mark Thompson
On 04/12/17 00:09, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes ticket #6717, files without sei can be produced
> with remuxing and seeking, even if this is a (separate) bug, such
> files exist in the wild.
> 
> Please comment, Carl Eugen

File are currently fixable by remuxing with:

-bsf:v 'h264_metadata=sei_user_data=dc45e9bde6d948b7962cd820d923eeef+x264 - 
core 150'

Unfortunately that can't be applied directly when decoding, because -bsf isn't 
available as an input option.

I don't really like the idea of adding the option because it does break correct 
files, but I guess it probably ends up being the pragmatic option for decoding.

Still, I think it might be sensible to at least add a big warning telling the 
user they're doing something stupid if this option is set and it finds 
x264_build is >= 151?

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


Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Fix parsing of edit list atoms with invalid elst entry count.

2017-12-03 Thread Michael Niedermayer
On Sun, Oct 29, 2017 at 01:39:06PM +0100, Michael Niedermayer wrote:
> On Sat, Oct 28, 2017 at 08:26:16PM +0200, Michael Niedermayer wrote:
> > On Thu, Oct 26, 2017 at 08:51:50PM -0700, Sasi Inguva wrote:
> > > On Tue, Oct 24, 2017 at 2:48 PM, Michael Niedermayer 
> > >  > > > wrote:
> > > 
> > > > On Mon, Oct 23, 2017 at 04:18:28PM -0700, Sasi Inguva wrote:
> > > > > Signed-off-by: Sasi Inguva 
> > > > > ---
> > > > >  libavformat/mov.c   | 15 +++-
> > > > >  tests/fate/mov.mak  |  4 ++
> > > > >  tests/ref/fate/mov-invalid-elst-entry-count | 57
> > > > +
> > > > >  3 files changed, 75 insertions(+), 1 deletion(-)
> > > > >  create mode 100644 tests/ref/fate/mov-invalid-elst-entry-count
> > > > >
> > > > > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > > > > index b22a116140..424293ad93 100644
> > > > > --- a/libavformat/mov.c
> > > > > +++ b/libavformat/mov.c
> > > > > @@ -4597,6 +4597,7 @@ static int mov_read_elst(MOVContext *c,
> > > > AVIOContext *pb, MOVAtom atom)
> > > > >  {
> > > > >  MOVStreamContext *sc;
> > > > >  int i, edit_count, version;
> > > > > +int64_t elst_entry_size;
> > > > >
> > > > >  if (c->fc->nb_streams < 1 || c->ignore_editlist)
> > > > >  return 0;
> > > > > @@ -4605,6 +4606,15 @@ static int mov_read_elst(MOVContext *c,
> > > > AVIOContext *pb, MOVAtom atom)
> > > > >  version = avio_r8(pb); /* version */
> > > > >  avio_rb24(pb); /* flags */
> > > > >  edit_count = avio_rb32(pb); /* entries */
> > > > > +atom.size -= 8;
> > > > > +
> > > > > +elst_entry_size = version == 1 ? 20 : 12;
> > > > > +if (atom.size != edit_count * elst_entry_size &&
> > > > > +c->fc->strict_std_compliance >= FF_COMPLIANCE_STRICT) {
> > > > > +av_log(c->fc, AV_LOG_ERROR, "Invalid edit list entry_count: 
> > > > > %d
> > > > for elst atom of size: %"PRId64" bytes.\n",
> > > > > +   edit_count, atom.size + 8);
> > > > > +return AVERROR_INVALIDDATA;
> > > > > +}
> > > > >
> > > > >  if (!edit_count)
> > > > >  return 0;
> > > > > @@ -4617,17 +4627,20 @@ static int mov_read_elst(MOVContext *c,
> > > > AVIOContext *pb, MOVAtom atom)
> > > > >  return AVERROR(ENOMEM);
> > > > >
> > > > >  av_log(c->fc, AV_LOG_TRACE, "track[%u].edit_count = %i\n",
> > > > c->fc->nb_streams - 1, edit_count);
> > > > > -for (i = 0; i < edit_count && !pb->eof_reached; i++) {
> > > > > +for (i = 0; i < edit_count && atom.size > 0 && !pb->eof_reached;
> > > > i++) {
> > > > >  MOVElst *e = >elst_data[i];
> > > > >
> > > > >  if (version == 1) {
> > > > >  e->duration = avio_rb64(pb);
> > > > >  e->time = avio_rb64(pb);
> > > > > +atom.size -= 16;
> > > > >  } else {
> > > > >  e->duration = avio_rb32(pb); /* segment duration */
> > > > >  e->time = (int32_t)avio_rb32(pb); /* media time */
> > > > > +atom.size -= 8;
> > > > >  }
> > > > >  e->rate = avio_rb32(pb) / 65536.0;
> > > > > +atom.size -= 4;
> > > > >  av_log(c->fc, AV_LOG_TRACE, "duration=%"PRId64" 
> > > > > time=%"PRId64"
> > > > rate=%f\n",
> > > > > e->duration, e->time, e->rate);
> > > >
> > > > it would be simpler to adjust edit_count in case of ineqality.
> > > > you already compute the elst_entry_size
> > > > this would also avoid allocating a larger than needed array
> > > >
> > > > Done. Attaching the corrected patch.
> > > 
> > > >
> > > > [...]
> > > >
> > > > --
> > > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> > > >
> > > > Many things microsoft did are stupid, but not doing something just 
> > > > because
> > > > microsoft did it is even more stupid. If everything ms did were stupid 
> > > > they
> > > > would be bankrupt already.
> > > >
> > > > ___
> > > > ffmpeg-devel mailing list
> > > > ffmpeg-devel@ffmpeg.org
> > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > > >
> > > >
> > 
> > >  libavformat/mov.c   |   21 +-
> > >  tests/fate/mov.mak  |4 +
> > >  tests/ref/fate/mov-invalid-elst-entry-count |   57 
> > > 
> > >  3 files changed, 81 insertions(+), 1 deletion(-)
> > > c553340f66797876d039f408f83574a40c54d17b  
> > > 0001-lavf-mov.c-Fix-parsing-of-edit-list-atoms-with-inval.patch
> > > From 188602e662868a79c7f85e9193e9aedc9ba1a170 Mon Sep 17 00:00:00 2001
> > > From: Sasi Inguva 
> > > Date: Wed, 18 Oct 2017 20:11:16 -0700
> > > Subject: [PATCH] lavf/mov.c: Fix parsing of edit list atoms with invalid 
> > > elst
> > >  entry count.
> > 
> > applied
> 
> It seems this fails on ARM qemu
> 
> TESTmov-invalid-elst-entry-count
> --- 

[FFmpeg-devel] [PATCH]lavc: Allow forcing work-around for x264 cabac 8x8 4:4:4 bug

2017-12-03 Thread Carl Eugen Hoyos
Hi!

Attached patch fixes ticket #6717, files without sei can be produced
with remuxing and seeking, even if this is a (separate) bug, such
files exist in the wild.

Please comment, Carl Eugen
From c3ce0a75f13663958034a70fb4a982671532d269 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Mon, 4 Dec 2017 01:05:57 +0100
Subject: [PATCH] lavc: Allow forcing work-around for old x264 cabac 8x8 4:4:4
 bug.

Fixes ticket #6717.
---
 libavcodec/avcodec.h   |1 +
 libavcodec/h264_cabac.c|5 -
 libavcodec/options_table.h |1 +
 libavcodec/version.h   |2 +-
 4 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 5db6a81..bae8812 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2516,6 +2516,7 @@ typedef struct AVCodecContext {
  */
 int workaround_bugs;
 #define FF_BUG_AUTODETECT   1  ///< autodetection
+#define FF_BUG_X264_CAB_8x8_444 2
 #define FF_BUG_XVID_ILACE   4
 #define FF_BUG_UMP4 8
 #define FF_BUG_NO_PADDING   16
diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
index ec5fc74..8b2973a 100644
--- a/libavcodec/h264_cabac.c
+++ b/libavcodec/h264_cabac.c
@@ -1919,6 +1919,9 @@ int ff_h264_decode_mb_cabac(const H264Context *h, H264SliceContext *sl)
 int dct8x8_allowed = h->ps.pps->transform_8x8_mode;
 const int decode_chroma = sps->chroma_format_idc == 1 || sps->chroma_format_idc == 2;
 const int pixel_shift = h->pixel_shift;
+AVCodecContext *avctx = h->avctx;
+if (h->x264_build < 151U)
+avctx->workaround_bugs |= FF_BUG_X264_CAB_8x8_444;
 
 mb_xy = sl->mb_xy = sl->mb_x + sl->mb_y*h->mb_stride;
 
@@ -2347,7 +2350,7 @@ decode_intra_mb:
 if (CHROMA444(h) && IS_8x8DCT(mb_type)){
 int i;
 uint8_t *nnz_cache = sl->non_zero_count_cache;
-if (h->x264_build < 151U) {
+if (avctx->workaround_bugs & FF_BUG_X264_CAB_8x8_444) {
 for (i = 0; i < 2; i++){
 if (sl->left_type[LEFT(i)] && !IS_8x8DCT(sl->left_type[LEFT(i)])) {
 nnz_cache[3+8* 1 + 2*8*i]=
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index d89f58d..ed35bec 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -112,6 +112,7 @@ static const AVOption avcodec_options[] = {
 {"bug", "work around not autodetected encoder bugs", OFFSET(workaround_bugs), AV_OPT_TYPE_FLAGS, {.i64 = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"},
 {"autodetect", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"},
 {"xvid_ilace", "Xvid interlacing bug (autodetected if FOURCC == XVIX)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_XVID_ILACE }, INT_MIN, INT_MAX, V|D, "bug"},
+{"x264_cab_8x8_444", "x264 cabac 8x8 4:4:4 encoding bug (autodetected if possible)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_X264_CAB_8x8_444 }, INT_MIN, INT_MAX, V|D, "bug"},
 {"ump4", "(autodetected if FOURCC == UMP4)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_UMP4 }, INT_MIN, INT_MAX, V|D, "bug"},
 {"no_padding", "padding bug (autodetected)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_NO_PADDING }, INT_MIN, INT_MAX, V|D, "bug"},
 {"amv", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_AMV }, INT_MIN, INT_MAX, V|D, "bug"},
diff --git a/libavcodec/version.h b/libavcodec/version.h
index d67b689..3b5c300 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR  58
 #define LIBAVCODEC_VERSION_MINOR   6
-#define LIBAVCODEC_VERSION_MICRO 102
+#define LIBAVCODEC_VERSION_MICRO 103
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH] fix MSVC compilation errors

2017-12-03 Thread Mateusz
W dniu 03.12.2017 o 22:26, Michael Niedermayer pisze:
> On Sat, Dec 02, 2017 at 09:50:26PM +0100, Mateusz wrote:
>> After commit 3701d49 'error_resilience: remove avpriv_atomic usage'
>> we have included windows.h in much more files and we should
>> avoid conflicts with defines/function declarations.
>>
>> Signed-off-by: Mateusz Brzostek 
>> ---
>>  libavcodec/jpegls.h  | 4 
>>  libavcodec/mss2.c| 6 +++---
>>  libavformat/mxfenc.c | 2 +-
>>  3 files changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavcodec/jpegls.h b/libavcodec/jpegls.h
>> index c8997c7861..69a57b9538 100644
>> --- a/libavcodec/jpegls.h
>> +++ b/libavcodec/jpegls.h
>> @@ -32,6 +32,10 @@
>>  #include "avcodec.h"
>>  #include "internal.h"
>>  
>> +#ifdef near
>> +#undef near
>> +#endif
>> +
>>  typedef struct JpeglsContext {
>>  AVCodecContext *avctx;
>>  } JpeglsContext;
>> diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
>> index 9e7cc466de..f850349a0a 100644
>> --- a/libavcodec/mss2.c
>> +++ b/libavcodec/mss2.c
>> @@ -464,9 +464,9 @@ static int decode_wmv9(AVCodecContext *avctx, const 
>> uint8_t *buf, int buf_size,
>>  return 0;
>>  }
>>  
>> -typedef struct Rectangle {
>> +typedef struct ff_Rectangle {
> 
> Does Rect instead of ff_Rectangle work too ?
> 
> The ff_ is a bit confusng as its outside how we name structs
> (struct identifers are capitalized)

Yes, Rect works. I've checked also MSS2Rectangle -- works too and in mss2.c 
there is for example
typedef struct MSS2Context

Should I resent this patch with Rect or MSS2Rectangle?

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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_stereo3d: implement auto detection by using frame side data

2017-12-03 Thread Michael Niedermayer
On Sun, Dec 03, 2017 at 08:21:50PM +0100, Nicolas George wrote:
> Michael Niedermayer (2017-12-01):
> > Do you think this comment will fix any issue or improve anything ?
> 
> This comment had one goal: prevent somebody from pushing incorrect
> changes before I had time to make my point.
> 
> > First i do not even know what you speak of exactly and as this is
> 
> I posted the exact reference in my previous mail in this thread, which
> is not very long:
> 
> https://ffmpeg.org/pipermail/ffmpeg-devel/2017-December/221480.html
> 
> > supposedly about code i wrote, i doubt others will have a better idea.
> > 
> > And there is possibly a difference in goals. Reinitializing filters
> > would loose filter state, so avoiding reinit unless really needed was
> > a big goal. Last but not least what i had envissioned is just in my head,
> > i never implemeted it. (the bikeshedding made me loose
> > interrest back then as i already mentioned) what is in git is a small
> > part of it, that alone certainly is not that great.
> > and "too simple" yes my vission of this was and is simple
> 
> I agree that avoiding resets is a worthy goal. I do not know if what you
> had in your head was correct or not. But what you committed in
> 9225513242 (and related commits 5d2b885074, 6c702c3c63, 5d859e5980) was
> just wrong. And one of the reason we can be sure it was wrong is that it
> caused assert failures, that you did not fix but just hid with more of
> the same.

I think i may be missing something here

The way i remember this, is that all the changes do never get
triggered unless the user application passes frames with changing
parameters into the filter graph.
That is something not supported before these commits. So an application
first has to introduce changes to get changes out or to get any of
these failure modes. While before all this should have failed 


[...]
> 
> You are overly optimistic when saying it is simple. It will involve
> quite a bit of work: checking filters to see if their code is safe to
> call several times; probably use some kind of flag to see which one are
> safe; inserting scale if necessary; providing an API to enable/disable
> parameters changes on buffersink; providing an API to detect parameters
> changes conveniently.
> 
> Not overwhelmingly difficult, but not an easy task either.

I think our difference here is entirely linguistic

its a lot of work, and indeed as there are more filters now its
more work than what it would have been in the past.
But it is simple work (as in alot but it does not seem to be complicated work)


> 
> And this is only speaking of changes in resolution and other shallow
> parameters. If you want to allow changes in pixel format (which your
> commits do), you need to adapt the whole format negotiation.

iam not sure
naively the same approuch (flag & insert scale or reinit or do nothing)
should work too.
I do not think we need to rebuild parts of the filter graph totally
reoptimizing for changed pixel formats but we could of course if thats
something someone wants to implement


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes


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


Re: [FFmpeg-devel] [PATCH 3/6] lavc/libx265: mark disposable frames

2017-12-03 Thread Hendrik Leppkes
On Sun, Dec 3, 2017 at 10:42 PM, Michael Niedermayer
 wrote:
> On Sat, Dec 02, 2017 at 11:32:16PM -0300, James Almer wrote:
>> On 12/2/2017 10:48 PM, Michael Niedermayer wrote:
>> > On Sat, Dec 02, 2017 at 03:26:34PM -0300, James Almer wrote:
> [...]
>
>> I'm surprised for that matter that the libvpx wrappers in old FFMpeg
>> versions don't work with >= 1.4.0. I don't recall any kind of API break
>> that we had to work around in them.
>
> i dont know about exact versions, i just know some release branches
> stoped building with configure settings that worked previously after i
> updated libvpx
>
> i needed to backport this:
>

That change is kind of the opposite of what we're really talking about
here, isn't it. It provides support for newer versions, didn't remove
support for older ones.

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


Re: [FFmpeg-devel] [PATCH] avformat: add NSP demuxer

2017-12-03 Thread Carl Eugen Hoyos
2017-12-01 17:26 GMT+01:00 Paul B Mahol :

> +static int nsp_read_header(AVFormatContext *s)
> +{
> +int rate = 0, channels = 0;
> +uint32_t chunk, size;
> +AVStream *st;
> +int64_t pos;
> +
> +avio_skip(s->pb, 12);

I believe you could set the duration here for the
supported interleaved stereo files.

> +st = avformat_new_stream(s, NULL);
> +if (!st)
> +return AVERROR(ENOMEM);
> +
> +while (!avio_feof(s->pb)) {
> +chunk = avio_rb32(s->pb);
> +size  = avio_rl32(s->pb);
> +pos   = avio_tell(s->pb);
> +
> +if (chunk == MKBETAG('H', 'D', 'R', '8') ||
> +chunk == MKBETAG('H', 'E', 'D', 'R')) {
> +if (size < 32)
> +return AVERROR_INVALIDDATA;
> +avio_skip(s->pb, 20);
> +rate = avio_rl32(s->pb);

> +avio_skip(s->pb, size - (avio_tell(s->pb) - pos));

Why is this not "skip(pb, size - 32)" (or whatever the correct
constant is)?

> +} else if (chunk == MKBETAG('N', 'O', 'T', 'E')) {
> +char value[1024];
> +
> +avio_get_str(s->pb, size, value, sizeof(value));
> +av_dict_set(>metadata, "Note", value, 0);

Shouldn't this be "comment"?

> +avio_skip(s->pb, 1);

Should be something like "avio_skip(pb, size & 1);" according
to the description I found.

> +} else if (chunk == MKBETAG('S', 'D', 'A', 'B')) {
> +channels = 2;

If I read correctly, you can set STEREO here.

> +break;

> +} else if (chunk == MKBETAG('S', 'D', 'A', '_') ||
> +   chunk == MKBETAG('S', 'D', '_', 'A') ||
> +   chunk == MKBETAG('S', 'D', '_', '2') ||
> +   chunk == MKBETAG('S', 'D', '_', '3') ||
> +   chunk == MKBETAG('S', 'D', '_', '4') ||
> +   chunk == MKBETAG('S', 'D', '_', '5') ||
> +   chunk == MKBETAG('S', 'D', '_', '6') ||
> +   chunk == MKBETAG('S', 'D', '_', '7') ||
> +   chunk == MKBETAG('S', 'D', '_', '8')) {

Iiuc, in these cases the file is not read correctly.
If this cannot be implemented easily, a warning should
be shown.

Thank you, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] adding bluetooth SBC codec

2017-12-03 Thread Aurelien Jacobs
On Sun, Dec 03, 2017 at 10:57:59AM +, Rostislav Pehlivanov wrote:
> On 5 November 2017 at 23:35, Aurelien Jacobs  wrote:
> 
> > Hello everyone,
> >
> > Long time no see !
> >
> > I'm glad to see ffmpeg still strong.
> >
> > I'm curently playing with bluetooth audio (A2DP) and I wanted to
> > use lavc to do the encoding/decoding, so I added some codecs that
> > I need to ffmpeg.
> >
> > Here is the result for the SBC codec.
> >
> > [PATCH 1/3] sbc: implement SBC codec (low-complexity subband codec)
> > [PATCH 2/3] sbc: add parser for SBC
> > [PATCH 3/3] sbc: add raw muxer and demuxer for SBC
> >
> > Note that this is based on libsbc, and that I have a repository with full
> > history of the modifications I applied on top of libsbc:
> >   https://gitlab.com/aurelj/ffmpeg/commits/bluetooth_sbc
> > If anyone would prefer me to submit all the patches with full history
> > on this mailing list, just say so. (I just think the squashed
> > version makes more sense to review)
> >
> > Thanks everyone for all your efforts to keep ffmpeg going.
> >
> 
> 
> Ping, there isn't much to do to this patch, just what was mentioned plus
> some of the stuff you did for the aptx patchset.

Yes, I'm just very busy lately. But I will clean this up it eventually.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/6] lavc/libx265: mark disposable frames

2017-12-03 Thread Michael Niedermayer
On Sat, Dec 02, 2017 at 11:32:16PM -0300, James Almer wrote:
> On 12/2/2017 10:48 PM, Michael Niedermayer wrote:
> > On Sat, Dec 02, 2017 at 03:26:34PM -0300, James Almer wrote:
[...]

> I'm surprised for that matter that the libvpx wrappers in old FFMpeg
> versions don't work with >= 1.4.0. I don't recall any kind of API break
> that we had to work around in them.

i dont know about exact versions, i just know some release branches
stoped building with configure settings that worked previously after i
updated libvpx

i needed to backport this:

commit 6540fe04a3f9a11ba7084a49b3ee5fa2fc5b32ab
Author: James Zern 
Date:   Mon Oct 19 22:44:11 2015 -0700

libvpxenc: remove some unused ctrl id mappings

VP8E_UPD_ENTROPY, VP8E_UPD_REFERENCE, VP8E_USE_REFERENCE were removed
from libvpx and the remaining values were never used here

Reviewed-by: Michael Niedermayer 
Signed-off-by: James Zern 

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

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


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


Re: [FFmpeg-devel] [PATCH 1/4] libavutil: Add saturating subtraction functions

2017-12-03 Thread Michael Niedermayer
On Sat, Dec 02, 2017 at 11:46:56AM -0600, Andrew D'Addesio wrote:
> Add av_sat_sub32 and av_sat_dsub32 as the subtraction analogues to
> av_sat_add32/av_sat_dadd32.
> 
> Also clarify the formulas for dadd32/dsub32.
> 
> Signed-off-by: Andrew D'Addesio 
> ---
>  libavutil/arm/intmath.h | 16 
>  libavutil/common.h  | 32 +++-
>  2 files changed, 47 insertions(+), 1 deletion(-)

this should bump something in version.h

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

The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"


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


Re: [FFmpeg-devel] [PATCH 2/4] opus: Fix arithmetic overflows (per RFC8251)

2017-12-03 Thread Michael Niedermayer
On Sat, Dec 02, 2017 at 11:46:57AM -0600, Andrew D'Addesio wrote:
> The relevant sections from the RFC are:
> 
> Sec.6. Integer Wrap-Around in Inverse Gain Computation
> 32-bit integer overflow in Levinson recursion. Affects
> silk_is_lpc_stable().
> 
> Sec.8. Cap on Band Energy
> NaN due to large log-energy value. Affects celt_denormalize().
> 
> Signed-off-by: Andrew D'Addesio 
> ---
>  libavcodec/opus_celt.c |  3 ++-
>  libavcodec/opus_silk.c | 11 +--
>  2 files changed, 11 insertions(+), 3 deletions(-)

This should be 2 patches

thanks

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

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope


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


Re: [FFmpeg-devel] [PATCH] fix MSVC compilation errors

2017-12-03 Thread Michael Niedermayer
On Sat, Dec 02, 2017 at 09:50:26PM +0100, Mateusz wrote:
> After commit 3701d49 'error_resilience: remove avpriv_atomic usage'
> we have included windows.h in much more files and we should
> avoid conflicts with defines/function declarations.
> 
> Signed-off-by: Mateusz Brzostek 
> ---
>  libavcodec/jpegls.h  | 4 
>  libavcodec/mss2.c| 6 +++---
>  libavformat/mxfenc.c | 2 +-
>  3 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/jpegls.h b/libavcodec/jpegls.h
> index c8997c7861..69a57b9538 100644
> --- a/libavcodec/jpegls.h
> +++ b/libavcodec/jpegls.h
> @@ -32,6 +32,10 @@
>  #include "avcodec.h"
>  #include "internal.h"
>  
> +#ifdef near
> +#undef near
> +#endif
> +
>  typedef struct JpeglsContext {
>  AVCodecContext *avctx;
>  } JpeglsContext;
> diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
> index 9e7cc466de..f850349a0a 100644
> --- a/libavcodec/mss2.c
> +++ b/libavcodec/mss2.c
> @@ -464,9 +464,9 @@ static int decode_wmv9(AVCodecContext *avctx, const 
> uint8_t *buf, int buf_size,
>  return 0;
>  }
>  
> -typedef struct Rectangle {
> +typedef struct ff_Rectangle {

Does Rect instead of ff_Rectangle work too ?

The ff_ is a bit confusng as its outside how we name structs
(struct identifers are capitalized)

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

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato


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


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Martin Vignali
Checkasm result (osx) for your last patch :
hflip_byte_c: 28.5
hflip_byte_ssse3: 29.0
hflip_short_c: 277.7
hflip_short_ssse3: 65.0

if you add a "cmp xq, wq" after the simd loop
you can be faster than c (clang), if width is multiple of mmsize*2

hflip_byte_c: 28.5
hflip_byte_ssse3: 27.5

see below


otherwise looks ok (i will send later a much cleaner patch for the checkasm,
and a patch to use one macro for both func)

+
> +pb_flip_byte:  db 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
> +pb_flip_short: db 14,15,12,13,10,11,8,9,6,7,4,5,2,3,0,1
> +
> +SECTION .text
> +
> +INIT_XMM ssse3
> +cglobal hflip_byte, 3, 6, 3, src, dst, w, x, v, r
>
+movam0, [pb_flip_byte]
> +mov xq, 0
> +mov wd, dword wm
> +mov rq, wq
> +and rq, 2 * mmsize - 1
> +cmp wq, 2 * mmsize
> +jl .loop1
> +sub wq, rq
> +
> +.loop0:
> +neg xq
> +movum1, [srcq + xq - mmsize + 1]
> +movum2, [srcq + xq - 2 * mmsize + 1]
> +pshufb  m1, m0
> +pshufb  m2, m0
> +neg xq
> +movu[dstq + xq ], m1
> +movu[dstq + xq + mmsize], m2
> +add xq, mmsize * 2
> +cmp xq, wq
> +jl .loop0
>

cmp xq, wq
je .end


> +
> +addwq, rq
> +
> +.loop1:
> +negxq
> +movvb, [srcq + xq]
> +negxq
> +mov[dstq + xq], vb
> +addxq, 1
> +cmpxq, wq
> +jl .loop1
>

.end:


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


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread James Almer
On 12/3/2017 5:50 PM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/hflip.h |  38 
>  libavfilter/vf_hflip.c  | 133 
> ++--
>  libavfilter/x86/Makefile|   2 +
>  libavfilter/x86/vf_hflip.asm| 102 ++
>  libavfilter/x86/vf_hflip_init.c |  41 +
>  5 files changed, 269 insertions(+), 47 deletions(-)
>  create mode 100644 libavfilter/hflip.h
>  create mode 100644 libavfilter/x86/vf_hflip.asm
>  create mode 100644 libavfilter/x86/vf_hflip_init.c

[...]

> @@ -80,6 +139,24 @@ static int config_props(AVFilterLink *inlink)
>  s->planeheight[0] = s->planeheight[3] = inlink->h;
>  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, vsub);
>  
> +nb_planes = av_pix_fmt_count_planes(inlink->format);
> +
> +for (i = 0; i < nb_planes; i++) {
> +switch (s->max_step[i]) {
> +case 1: s->flip_line[i] = hflip_byte_c;  break;
> +case 2: s->flip_line[i] = hflip_short_c; break;
> +case 3: s->flip_line[i] = hflip_b24_c;   break;
> +case 4: s->flip_line[i] = hflip_dword_c; break;
> +case 6: s->flip_line[i] = hflip_b48_c;   break;
> +case 8: s->flip_line[i] = hflip_qword_c; break;
> +default:
> +return AVERROR_BUG;
> +}
> +}
> +
> +if (ARCH_X86)
> +ff_hflip_init_x86(s, s->max_step);

Pass nb_planes here and use it instead of the hardcoded 4.

Should be good aside from that.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 6/6] ffplay: use AV_PKT_FLAG_DISPOSABLE in frame drop logic

2017-12-03 Thread Marton Balint


On Thu, 30 Nov 2017, John Stebbins wrote:


---
fftools/ffplay.c | 21 -
1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 10a917194d..152d220cdb 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -198,6 +198,8 @@ typedef struct Decoder {
int64_t next_pts;
AVRational next_pts_tb;
SDL_Thread *decoder_tid;
+int drop_disposable;
+int frame_drops_disposable;
} Decoder;

typedef struct VideoState {
@@ -660,10 +662,16 @@ static int decoder_decode_frame(Decoder *d, AVFrame 
*frame, AVSubtitle *sub) {
ret = got_frame ? 0 : (pkt.data ? AVERROR(EAGAIN) : 
AVERROR_EOF);
}
} else {
-if (avcodec_send_packet(d->avctx, ) == AVERROR(EAGAIN)) {
-av_log(d->avctx, AV_LOG_ERROR, "Receive_frame and send_packet 
both returned EAGAIN, which is an API violation.\n");
-d->packet_pending = 1;
-av_packet_move_ref(>pkt, );
+if (d->avctx->codec_type == AVMEDIA_TYPE_VIDEO &&
+d->drop_disposable &&
+(pkt.flags & AV_PKT_FLAG_DISPOSABLE)) {
+d->frame_drops_disposable++;
+} else {
+if (avcodec_send_packet(d->avctx, ) == 
AVERROR(EAGAIN)) {
+av_log(d->avctx, AV_LOG_ERROR, "Receive_frame and 
send_packet both returned EAGAIN, which is an API violation.\n");
+d->packet_pending = 1;
+av_packet_move_ref(>pkt, );
+}
}
}
av_packet_unref();
@@ -1622,6 +1630,7 @@ retry:
frame_queue_next(>pictq);
goto retry;
}
+is->viddec.drop_disposable = 0;
}

if (is->subtitle_st) {
@@ -1699,7 +1708,8 @@ display:
   get_master_clock(is),
   (is->audio_st && is->video_st) ? "A-V" : (is->video_st ? "M-V" : (is->audio_st ? 
"M-A" : "   ")),
   av_diff,
-   is->frame_drops_early + is->frame_drops_late,
+   is->frame_drops_early + is->frame_drops_late +
+   is->viddec.frame_drops_disposable,
   aqsize / 1024,
   vqsize / 1024,
   sqsize,
@@ -1767,6 +1777,7 @@ static int get_video_frame(VideoState *is, AVFrame *frame)
is->frame_drops_early++;
av_frame_unref(frame);
got_picture = 0;
+is->viddec.drop_disposable = 1;
}
}
}


The patch looks OK now, but as I mentioned earlier, please do not enable 
this kind of frame dropping by default, either introduce a separate option 
"hardframedrop", or make -framedrop an integer and use "2" for this kind 
of hard dropping.


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


Re: [FFmpeg-devel] [PATCHv2] avformat/mxfdec: fix last packet timestamps

2017-12-03 Thread Marton Balint



On Sat, 2 Dec 2017, Marton Balint wrote:



On Fri, 24 Nov 2017, Marton Balint wrote:

The current edit unit cannot be reliably determined for the last packet of 

a

video stream, because we can't query the start offset of the next edit unit
from the index. This caused missing timestamps for the last video packet.

Therefore from now on, we allow setting the PTS even if we are not sure of 

the
current edit unit if mxf_set_current_edit_unit returned a specific failure, 

and

the assumed current edit unit is the last.

Fixes last packet timestamp of:
ffprobe -fflags nofillin -show_packets tests/data/lavf/lavf.mxf 

-select_streams v




Ping, will apply soon.


Applied.

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


[FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/hflip.h |  38 
 libavfilter/vf_hflip.c  | 133 ++--
 libavfilter/x86/Makefile|   2 +
 libavfilter/x86/vf_hflip.asm| 102 ++
 libavfilter/x86/vf_hflip_init.c |  41 +
 5 files changed, 269 insertions(+), 47 deletions(-)
 create mode 100644 libavfilter/hflip.h
 create mode 100644 libavfilter/x86/vf_hflip.asm
 create mode 100644 libavfilter/x86/vf_hflip_init.c

diff --git a/libavfilter/hflip.h b/libavfilter/hflip.h
new file mode 100644
index 00..138380427c
--- /dev/null
+++ b/libavfilter/hflip.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2007 Benoit Fouet
+ * Copyright (c) 2010 Stefano Sabatini
+ *
+ * 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
+ */
+
+#ifndef AVFILTER_HFLIP_H
+#define AVFILTER_HFLIP_H
+
+#include "avfilter.h"
+
+typedef struct FlipContext {
+const AVClass *class;
+int max_step[4];///< max pixel step for each plane, expressed as a 
number of bytes
+int planewidth[4];  ///< width of each plane
+int planeheight[4]; ///< height of each plane
+
+void (*flip_line[4])(const uint8_t *src, uint8_t *dst, int w);
+} FlipContext;
+
+void ff_hflip_init_x86(FlipContext *s, int step[4]);
+
+#endif /* AVFILTER_HFLIP_H */
diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c
index cf20c193f7..030015df0a 100644
--- a/libavfilter/vf_hflip.c
+++ b/libavfilter/vf_hflip.c
@@ -29,6 +29,7 @@
 #include "libavutil/opt.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "hflip.h"
 #include "internal.h"
 #include "video.h"
 #include "libavutil/pixdesc.h"
@@ -36,13 +37,6 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/imgutils.h"
 
-typedef struct FlipContext {
-const AVClass *class;
-int max_step[4];///< max pixel step for each plane, expressed as a 
number of bytes
-int planewidth[4];  ///< width of each plane
-int planeheight[4]; ///< height of each plane
-} FlipContext;
-
 static const AVOption hflip_options[] = {
 { NULL }
 };
@@ -67,12 +61,77 @@ static int query_formats(AVFilterContext *ctx)
 return ff_set_common_formats(ctx, pix_fmts);
 }
 
+static void hflip_byte_c(const uint8_t *src, uint8_t *dst, int w)
+{
+int j;
+
+for (j = 0; j < w; j++)
+dst[j] = src[-j];
+}
+
+static void hflip_short_c(const uint8_t *ssrc, uint8_t *ddst, int w)
+{
+const uint16_t *src = (const uint16_t *)ssrc;
+uint16_t *dst = (uint16_t *)ddst;
+int j;
+
+for (j = 0; j < w; j++)
+dst[j] = src[-j];
+}
+
+static void hflip_dword_c(const uint8_t *ssrc, uint8_t *ddst, int w)
+{
+const uint32_t *src = (const uint32_t *)ssrc;
+uint32_t *dst = (uint32_t *)ddst;
+int j;
+
+for (j = 0; j < w; j++)
+dst[j] = src[-j];
+}
+
+static void hflip_b24_c(const uint8_t *src, uint8_t *dst, int w)
+{
+const uint8_t *in  = src;
+uint8_t *out = dst;
+int j;
+
+for (j = 0; j < w; j++, out += 3, in -= 3) {
+int32_t v = AV_RB24(in);
+
+AV_WB24(out, v);
+}
+}
+
+static void hflip_b48_c(const uint8_t *src, uint8_t *dst, int w)
+{
+const uint8_t *in  = src;
+uint8_t *out = dst;
+int j;
+
+for (j = 0; j < w; j++, out += 6, in -= 6) {
+int64_t v = AV_RB48(in);
+
+AV_WB48(out, v);
+}
+}
+
+static void hflip_qword_c(const uint8_t *ssrc, uint8_t *ddst, int w)
+{
+const uint64_t *src = (const uint64_t *)ssrc;
+uint64_t *dst = (uint64_t *)ddst;
+int j;
+
+for (j = 0; j < w; j++)
+dst[j] = src[-j];
+}
+
 static int config_props(AVFilterLink *inlink)
 {
 FlipContext *s = inlink->dst->priv;
 const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
 const int hsub = pix_desc->log2_chroma_w;
 const int vsub = pix_desc->log2_chroma_h;
+int nb_planes, i;
 
 av_image_fill_max_pixsteps(s->max_step, NULL, pix_desc);
 s->planewidth[0]  = s->planewidth[3]  = inlink->w;
@@ -80,6 +139,24 @@ static int config_props(AVFilterLink *inlink)
 s->planeheight[0] = s->planeheight[3] = inlink->h;
 s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, vsub);
 
+nb_planes = 

Re: [FFmpeg-devel] avfilter/x86/vf_threshold : add SSE4 and AVX2 for threshold 16

2017-12-03 Thread Martin Vignali
2017-12-03 21:15 GMT+01:00 James Darnley :

> On 2017-12-03 19:30, Martin Vignali wrote:
> >  libavfilter/x86/vf_threshold.asm| 19 ++-
> >  libavfilter/x86/vf_threshold_init.c | 34 --
> 
> >  2 files changed, 34 insertions(+), 19 deletions(-)
> >
> > diff --git a/libavfilter/x86/vf_threshold.asm b/libavfilter/x86/vf_
> threshold.asm
> > index fb008c376a..7b929c6bd2 100644
> > --- a/libavfilter/x86/vf_threshold.asm
> > +++ b/libavfilter/x86/vf_threshold.asm
> > @@ -27,14 +27,21 @@
> >  SECTION_RODATA
> >
> >  pb_128: times 16 db 128
> > +pb_128_0 : times 16 dw 32768
>
> No.  Please use db and the values you want.
>
> I assume this is supposed to be "times 8 db 0, 128".  If these are
> supposed to be word values then the constant should be named "packed
> word".  If one were to reuse an existing constant for different word
> sizes then it would be acceptable.
>
>
> Thanks for pointing this,
I will replace it by
pb_128_0 : times 8 db 128, 0
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] avfilter/x86/vf_threshold : add SSE4 and AVX2 for threshold 16

2017-12-03 Thread James Darnley
On 2017-12-03 19:30, Martin Vignali wrote:
>  libavfilter/x86/vf_threshold.asm| 19 ++-
>  libavfilter/x86/vf_threshold_init.c | 34 --
>  2 files changed, 34 insertions(+), 19 deletions(-)
> 
> diff --git a/libavfilter/x86/vf_threshold.asm 
> b/libavfilter/x86/vf_threshold.asm
> index fb008c376a..7b929c6bd2 100644
> --- a/libavfilter/x86/vf_threshold.asm
> +++ b/libavfilter/x86/vf_threshold.asm
> @@ -27,14 +27,21 @@
>  SECTION_RODATA
>  
>  pb_128: times 16 db 128
> +pb_128_0 : times 16 dw 32768

No.  Please use db and the values you want.

I assume this is supposed to be "times 8 db 0, 128".  If these are
supposed to be word values then the constant should be named "packed
word".  If one were to reuse an existing constant for different word
sizes then it would be acceptable.




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


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Martin Vignali
I modify the checkasm test, to test various width

if (check_func(s.flip_line[0], "hflip_%s", report_name)) {
for (i = 1; i < w; i++) {
call_ref(src, dst_ref, i);
call_new(src, dst_new, i);
if (memcmp(dst_ref, dst_new, WIDTH)) {
printf("FAIL : W = %d\n", i);
fail();
}
}
bench_new(src, dst_new, WIDTH);
}


This asm seems to be ok (same idea for the hflip_short version)
hflip_byte_c: 28.4
hflip_byte_ssse3: 23.7
hflip_short_c: 275.9
hflip_short_ssse3: 65.2


INIT_XMM ssse3
cglobal hflip_byte, 3, 5, 3, src, dst, w, x, v
movam0, [pb_flip_byte]
mov xq, 0
mov wd, dword wm
sub wq, 2 * mmsize
;cmp wq, mmsize ; < Doesn't seems to be need
jl .skip

.loop0:
neg xq
movum1, [srcq + xq - mmsize + 1]
movum2, [srcq + xq - 2 * mmsize + 1]
pshufb  m1, m0
pshufb  m2, m0
neg xq
movu[dstq + xq ], m1
movu[dstq + xq + mmsize], m2
add xq, mmsize * 2
cmp xq, wq
jl .loop0

cmp xq, wq ;<
je .end ;<


   sub xq, mmsize *2 ;<
   jmp .loop1 ;<




.skip:
add wq, 2 * mmsize
.loop1:
negxq
movvb, [srcq + xq]
negxq
mov[dstq + xq], vb
addxq, 1
cmpxq, wq
jl .loop1
.end:
RET
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Paul B Mahol
On 12/3/17, Paul B Mahol  wrote:
> On 12/3/17, Martin Vignali  wrote:
>> Maybe the problem come from the skip part :
>>
>> +INIT_XMM ssse3
>>> +cglobal hflip_byte, 3, 5, 3, src, dst, w, x, v
>>> +movam0, [pb_flip_byte]
>>> +mov xq, 0
>>> +mov wd, dword wm
>>> +sub wq, 2 * mmsize
>>> +cmp wq, mmsize
>>> +jl .skip
>>> +
>>> +.loop0:
>>> +neg xq
>>> +movum1, [srcq + xq - mmsize + 1]
>>> +movum2, [srcq + xq - 2 * mmsize + 1]
>>> +pshufb  m1, m0
>>> +pshufb  m2, m0
>>> +neg xq
>>> +movu[dstq + xq ], m1
>>> +movu[dstq + xq + mmsize], m2
>>> +add xq, mmsize * 2
>>> +cmp xq, wq
>>> +jl .loop0
>>> +
>>> +.skip:
>>> +add wq, 2 * mmsize
>>>
>>
>> ==> use xq instead of wq ?
>
> Nope.
>
>>
>>
>>> +.loop1:
>>> +negxq
>>> +movvb, [srcq + xq]
>>> +negxq
>>> +mov[dstq + xq], vb
>>> +addxq, 1
>>> +cmpxq, wq
>>> +jl .loop1
>>> +RET
>>> +
>>> +cglobal hflip_short, 3, 5, 3, src, dst, w, x, v
>>> +movam0, [pb_flip_short]
>>> +mov xq, 0
>>> +mov wd, dword wm
>>> +add wq, wq
>>> +sub wq, 2 * mmsize
>>> +cmp wq, mmsize
>>> +jl .skip
>>> +
>>> +.loop0:
>>> +neg xq
>>> +movum1, [srcq + xq - mmsize + 2]
>>> +movum2, [srcq + xq - 2 * mmsize + 2]
>>> +pshufb  m1, m0
>>> +pshufb  m2, m0
>>> +neg xq
>>> +movu[dstq + xq ], m1
>>> +movu[dstq + xq + mmsize], m2
>>> +add xq, mmsize
>>> +cmp xq, wq
>>> +jl .loop0
>>> +
>>> +.skip:
>>> +add wq, 2 * mmsize
>>>
>>
>>
>> ==> same here ?
>
> Nope, This is for case when width is not multiple of mmsize.
>

Can I get final verdict? I would like to move to other things.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2] libavcodec/hevc_filter: support for all skip_loop_filter levels

2017-12-03 Thread Stefan _
On 01.12.2017 at 17:45 Michael Niedermayer wrote:
> AVDISCARD_NONREF is about frames which are not referenced by any other
> doesnt ff_hevc_frame_nb_refs() produce the number of references curently
> aka the other end of the reference arrows ?

Yes, that sounds right.

I've revised the patch to check for *_N NAL unit types instead (which 
should be equivalent to H.264's nal_idc == 0) and to skip not only 
deblock, but also SAO.

From a3ebeb4ca0849cfc3846de79b38ae5ca6c001718 Mon Sep 17 00:00:00 2001
From: sfan5 
Date: Thu, 30 Nov 2017 23:58:02 +0100
Subject: [PATCH] libavcodec/hevc_filter: support for all skip_loop_filter
 levels.

Continues where commit 52c75d486ed5f75cbb79e5dbd07b7aef24f3071f left off.
---
 doc/decoders.texi|  7 ---
 libavcodec/hevc_filter.c | 29 +++--
 2 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/doc/decoders.texi b/doc/decoders.texi
index d149d2bea5..a9510bdf02 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -25,13 +25,6 @@ enabled decoders.
 A description of some of the currently available video decoders
 follows.
 
-@section hevc
-
-HEVC / H.265 decoder.
-
-Note: the @option{skip_loop_filter} option has effect only at level
-@code{all}.
-
 @section rawvideo
 
 Raw video decoder.
diff --git a/libavcodec/hevc_filter.c b/libavcodec/hevc_filter.c
index b53f4cc721..94fb7cd3d1 100644
--- a/libavcodec/hevc_filter.c
+++ b/libavcodec/hevc_filter.c
@@ -842,9 +842,34 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
 void ff_hevc_hls_filter(HEVCContext *s, int x, int y, int ctb_size)
 {
 int x_end = x >= s->ps.sps->width  - ctb_size;
-if (s->avctx->skip_loop_filter < AVDISCARD_ALL)
+int skip = 0, is_n = 0;
+switch (s->nal_unit_type) {
+case HEVC_NAL_TRAIL_N:
+case HEVC_NAL_TSA_N:
+case HEVC_NAL_STSA_N:
+case HEVC_NAL_RADL_N:
+case HEVC_NAL_RASL_N:
+case HEVC_NAL_VCL_N10:
+case HEVC_NAL_VCL_N12:
+case HEVC_NAL_VCL_N14:
+case HEVC_NAL_BLA_N_LP:
+case HEVC_NAL_IDR_N_LP:
+is_n = 1;
+break;
+default: break;
+}
+if (s->avctx->skip_loop_filter >= AVDISCARD_ALL ||
+(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && !IS_IDR(s)) ||
+(s->avctx->skip_loop_filter >= AVDISCARD_NONINTRA &&
+ s->sh.slice_type != HEVC_SLICE_I) ||
+(s->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
+ s->sh.slice_type == HEVC_SLICE_B) ||
+(s->avctx->skip_loop_filter >= AVDISCARD_NONREF && is_n))
+skip = 1;
+
+if (!skip)
 deblocking_filter_CTB(s, x, y);
-if (s->ps.sps->sao_enabled) {
+if (s->ps.sps->sao_enabled && !skip) {
 int y_end = y >= s->ps.sps->height - ctb_size;
 if (y && x)
 sao_filter_CTB(s, x - ctb_size, y - ctb_size);
-- 
2.15.1

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


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Paul B Mahol
On 12/3/17, Martin Vignali  wrote:
> Maybe the problem come from the skip part :
>
> +INIT_XMM ssse3
>> +cglobal hflip_byte, 3, 5, 3, src, dst, w, x, v
>> +movam0, [pb_flip_byte]
>> +mov xq, 0
>> +mov wd, dword wm
>> +sub wq, 2 * mmsize
>> +cmp wq, mmsize
>> +jl .skip
>> +
>> +.loop0:
>> +neg xq
>> +movum1, [srcq + xq - mmsize + 1]
>> +movum2, [srcq + xq - 2 * mmsize + 1]
>> +pshufb  m1, m0
>> +pshufb  m2, m0
>> +neg xq
>> +movu[dstq + xq ], m1
>> +movu[dstq + xq + mmsize], m2
>> +add xq, mmsize * 2
>> +cmp xq, wq
>> +jl .loop0
>> +
>> +.skip:
>> +add wq, 2 * mmsize
>>
>
> ==> use xq instead of wq ?

Nope.

>
>
>> +.loop1:
>> +negxq
>> +movvb, [srcq + xq]
>> +negxq
>> +mov[dstq + xq], vb
>> +addxq, 1
>> +cmpxq, wq
>> +jl .loop1
>> +RET
>> +
>> +cglobal hflip_short, 3, 5, 3, src, dst, w, x, v
>> +movam0, [pb_flip_short]
>> +mov xq, 0
>> +mov wd, dword wm
>> +add wq, wq
>> +sub wq, 2 * mmsize
>> +cmp wq, mmsize
>> +jl .skip
>> +
>> +.loop0:
>> +neg xq
>> +movum1, [srcq + xq - mmsize + 2]
>> +movum2, [srcq + xq - 2 * mmsize + 2]
>> +pshufb  m1, m0
>> +pshufb  m2, m0
>> +neg xq
>> +movu[dstq + xq ], m1
>> +movu[dstq + xq + mmsize], m2
>> +add xq, mmsize
>> +cmp xq, wq
>> +jl .loop0
>> +
>> +.skip:
>> +add wq, 2 * mmsize
>>
>
>
> ==> same here ?

Nope, This is for case when width is not multiple of mmsize.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Paul B Mahol
On 12/3/17, Martin Vignali  wrote:
> 2017-12-03 20:36 GMT+01:00 Paul B Mahol :
>
>> On 12/3/17, Martin Vignali  wrote:
>> >>
>> >> In any case, if clang or gcc can generate better code, then the hand
>> >> written version needs to be optimized to be as fast or faster.
>> >>
>> >>
>> >>
>> > Quick test : pass checkasm (but probably only because width = 256)
>> > hflip_byte_c: 26.4
>> > hflip_byte_ssse3: 20.4
>> >
>> >
>> > INIT_XMM ssse3
>> > cglobal hflip_byte, 3, 5, 2, src, dst, w, x, v, src2
>> > movam0, [pb_flip_byte]
>> > xor xq, xq ; <==
>> > mov wd, dword wm
>> > sub wq, mmsize * 2
>> > ;remove the cmp here <==
>> > jl .skip
>> >
>> > .loop0: ; process two xmm in the loop
>> > neg xq
>> > movum1, [srcq + xq - mmsize + 1]
>> > movum2, [srcq + xq - mmsize * 2 + 1] <==
>> > pshufb  m1, m0
>> > pshufb  m2, m0 <==
>> > neg xq
>> > movu[dstq + xq], m1
>> > movu[dstq + xq + mmsize], m2 <==
>> > add xq, mmsize * 2 <==
>> > cmp xq, wq
>> > jl .loop0
>> >  RET ; add RET here
>> >
>> > ; MISSING one xmm process if need
>> >
>> > .skip:
>> > add wq, mmsize
>> > .loop1:
>> > negxq
>> > movvb, [srcq + xq]
>> > negxq
>> > mov[dstq + xq], vb
>> > addxq, 1
>> > cmpxq, wq
>> > jl .loop1
>> > RET
>>
>> So what is wrong now?
>>
>
> Doesn't see your email, when i send mine.
>
> Check asm result with your last patch (and modify for the short version
> "add xq, mmsize" to "add xq, mmsize * 2")
> hflip_byte_c: 28.0
> hflip_byte_ssse3: 127.5
> hflip_short_c: 276.5
> hflip_short_ssse3: 100.2
>

Ops, fixed.

>
> Do you think if you add RET after the end of loop0 , it can work in all
> cases ?

No, it would try to read before src, and crash.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Martin Vignali
Maybe the problem come from the skip part :

+INIT_XMM ssse3
> +cglobal hflip_byte, 3, 5, 3, src, dst, w, x, v
> +movam0, [pb_flip_byte]
> +mov xq, 0
> +mov wd, dword wm
> +sub wq, 2 * mmsize
> +cmp wq, mmsize
> +jl .skip
> +
> +.loop0:
> +neg xq
> +movum1, [srcq + xq - mmsize + 1]
> +movum2, [srcq + xq - 2 * mmsize + 1]
> +pshufb  m1, m0
> +pshufb  m2, m0
> +neg xq
> +movu[dstq + xq ], m1
> +movu[dstq + xq + mmsize], m2
> +add xq, mmsize * 2
> +cmp xq, wq
> +jl .loop0
> +
> +.skip:
> +add wq, 2 * mmsize
>

==> use xq instead of wq ?


> +.loop1:
> +negxq
> +movvb, [srcq + xq]
> +negxq
> +mov[dstq + xq], vb
> +addxq, 1
> +cmpxq, wq
> +jl .loop1
> +RET
> +
> +cglobal hflip_short, 3, 5, 3, src, dst, w, x, v
> +movam0, [pb_flip_short]
> +mov xq, 0
> +mov wd, dword wm
> +add wq, wq
> +sub wq, 2 * mmsize
> +cmp wq, mmsize
> +jl .skip
> +
> +.loop0:
> +neg xq
> +movum1, [srcq + xq - mmsize + 2]
> +movum2, [srcq + xq - 2 * mmsize + 2]
> +pshufb  m1, m0
> +pshufb  m2, m0
> +neg xq
> +movu[dstq + xq ], m1
> +movu[dstq + xq + mmsize], m2
> +add xq, mmsize
> +cmp xq, wq
> +jl .loop0
> +
> +.skip:
> +add wq, 2 * mmsize
>


==> same here ?


+.loop1:
> +negxq
> +movvw, [srcq + xq]
> +negxq
> +mov[dstq + xq], vw
> +addxq, 2
> +cmpxq, wq
> +jl .loop1
> +RET
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Martin Vignali
2017-12-03 20:36 GMT+01:00 Paul B Mahol :

> On 12/3/17, Martin Vignali  wrote:
> >>
> >> In any case, if clang or gcc can generate better code, then the hand
> >> written version needs to be optimized to be as fast or faster.
> >>
> >>
> >>
> > Quick test : pass checkasm (but probably only because width = 256)
> > hflip_byte_c: 26.4
> > hflip_byte_ssse3: 20.4
> >
> >
> > INIT_XMM ssse3
> > cglobal hflip_byte, 3, 5, 2, src, dst, w, x, v, src2
> > movam0, [pb_flip_byte]
> > xor xq, xq ; <==
> > mov wd, dword wm
> > sub wq, mmsize * 2
> > ;remove the cmp here <==
> > jl .skip
> >
> > .loop0: ; process two xmm in the loop
> > neg xq
> > movum1, [srcq + xq - mmsize + 1]
> > movum2, [srcq + xq - mmsize * 2 + 1] <==
> > pshufb  m1, m0
> > pshufb  m2, m0 <==
> > neg xq
> > movu[dstq + xq], m1
> > movu[dstq + xq + mmsize], m2 <==
> > add xq, mmsize * 2 <==
> > cmp xq, wq
> > jl .loop0
> >  RET ; add RET here
> >
> > ; MISSING one xmm process if need
> >
> > .skip:
> > add wq, mmsize
> > .loop1:
> > negxq
> > movvb, [srcq + xq]
> > negxq
> > mov[dstq + xq], vb
> > addxq, 1
> > cmpxq, wq
> > jl .loop1
> > RET
>
> So what is wrong now?
>

Doesn't see your email, when i send mine.

Check asm result with your last patch (and modify for the short version
"add xq, mmsize" to "add xq, mmsize * 2")
hflip_byte_c: 28.0
hflip_byte_ssse3: 127.5
hflip_short_c: 276.5
hflip_short_ssse3: 100.2


Do you think if you add RET after the end of loop0 , it can work in all
cases ?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Paul B Mahol
On 12/3/17, Martin Vignali  wrote:
>>
>> In any case, if clang or gcc can generate better code, then the hand
>> written version needs to be optimized to be as fast or faster.
>>
>>
>>
> Quick test : pass checkasm (but probably only because width = 256)
> hflip_byte_c: 26.4
> hflip_byte_ssse3: 20.4
>
>
> INIT_XMM ssse3
> cglobal hflip_byte, 3, 5, 2, src, dst, w, x, v, src2
> movam0, [pb_flip_byte]
> xor xq, xq ; <==
> mov wd, dword wm
> sub wq, mmsize * 2
> ;remove the cmp here <==
> jl .skip
>
> .loop0: ; process two xmm in the loop
> neg xq
> movum1, [srcq + xq - mmsize + 1]
> movum2, [srcq + xq - mmsize * 2 + 1] <==
> pshufb  m1, m0
> pshufb  m2, m0 <==
> neg xq
> movu[dstq + xq], m1
> movu[dstq + xq + mmsize], m2 <==
> add xq, mmsize * 2 <==
> cmp xq, wq
> jl .loop0
>  RET ; add RET here
>
> ; MISSING one xmm process if need
>
> .skip:
> add wq, mmsize
> .loop1:
> negxq
> movvb, [srcq + xq]
> negxq
> mov[dstq + xq], vb
> addxq, 1
> cmpxq, wq
> jl .loop1
> RET

So what is wrong now?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Martin Vignali
>
> In any case, if clang or gcc can generate better code, then the hand
> written version needs to be optimized to be as fast or faster.
>
>
>
Quick test : pass checkasm (but probably only because width = 256)
hflip_byte_c: 26.4
hflip_byte_ssse3: 20.4


INIT_XMM ssse3
cglobal hflip_byte, 3, 5, 2, src, dst, w, x, v, src2
movam0, [pb_flip_byte]
xor xq, xq ; <==
mov wd, dword wm
sub wq, mmsize * 2
;remove the cmp here <==
jl .skip

.loop0: ; process two xmm in the loop
neg xq
movum1, [srcq + xq - mmsize + 1]
movum2, [srcq + xq - mmsize * 2 + 1] <==
pshufb  m1, m0
pshufb  m2, m0 <==
neg xq
movu[dstq + xq], m1
movu[dstq + xq + mmsize], m2 <==
add xq, mmsize * 2 <==
cmp xq, wq
jl .loop0
 RET ; add RET here

; MISSING one xmm process if need

.skip:
add wq, mmsize
.loop1:
negxq
movvb, [srcq + xq]
negxq
mov[dstq + xq], vb
addxq, 1
cmpxq, wq
jl .loop1
RET


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


[FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/hflip.h |  38 
 libavfilter/vf_hflip.c  | 133 ++--
 libavfilter/x86/Makefile|   2 +
 libavfilter/x86/vf_hflip.asm|  98 +
 libavfilter/x86/vf_hflip_init.c |  41 +
 5 files changed, 265 insertions(+), 47 deletions(-)
 create mode 100644 libavfilter/hflip.h
 create mode 100644 libavfilter/x86/vf_hflip.asm
 create mode 100644 libavfilter/x86/vf_hflip_init.c

diff --git a/libavfilter/hflip.h b/libavfilter/hflip.h
new file mode 100644
index 00..138380427c
--- /dev/null
+++ b/libavfilter/hflip.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2007 Benoit Fouet
+ * Copyright (c) 2010 Stefano Sabatini
+ *
+ * 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
+ */
+
+#ifndef AVFILTER_HFLIP_H
+#define AVFILTER_HFLIP_H
+
+#include "avfilter.h"
+
+typedef struct FlipContext {
+const AVClass *class;
+int max_step[4];///< max pixel step for each plane, expressed as a 
number of bytes
+int planewidth[4];  ///< width of each plane
+int planeheight[4]; ///< height of each plane
+
+void (*flip_line[4])(const uint8_t *src, uint8_t *dst, int w);
+} FlipContext;
+
+void ff_hflip_init_x86(FlipContext *s, int step[4]);
+
+#endif /* AVFILTER_HFLIP_H */
diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c
index cf20c193f7..030015df0a 100644
--- a/libavfilter/vf_hflip.c
+++ b/libavfilter/vf_hflip.c
@@ -29,6 +29,7 @@
 #include "libavutil/opt.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "hflip.h"
 #include "internal.h"
 #include "video.h"
 #include "libavutil/pixdesc.h"
@@ -36,13 +37,6 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/imgutils.h"
 
-typedef struct FlipContext {
-const AVClass *class;
-int max_step[4];///< max pixel step for each plane, expressed as a 
number of bytes
-int planewidth[4];  ///< width of each plane
-int planeheight[4]; ///< height of each plane
-} FlipContext;
-
 static const AVOption hflip_options[] = {
 { NULL }
 };
@@ -67,12 +61,77 @@ static int query_formats(AVFilterContext *ctx)
 return ff_set_common_formats(ctx, pix_fmts);
 }
 
+static void hflip_byte_c(const uint8_t *src, uint8_t *dst, int w)
+{
+int j;
+
+for (j = 0; j < w; j++)
+dst[j] = src[-j];
+}
+
+static void hflip_short_c(const uint8_t *ssrc, uint8_t *ddst, int w)
+{
+const uint16_t *src = (const uint16_t *)ssrc;
+uint16_t *dst = (uint16_t *)ddst;
+int j;
+
+for (j = 0; j < w; j++)
+dst[j] = src[-j];
+}
+
+static void hflip_dword_c(const uint8_t *ssrc, uint8_t *ddst, int w)
+{
+const uint32_t *src = (const uint32_t *)ssrc;
+uint32_t *dst = (uint32_t *)ddst;
+int j;
+
+for (j = 0; j < w; j++)
+dst[j] = src[-j];
+}
+
+static void hflip_b24_c(const uint8_t *src, uint8_t *dst, int w)
+{
+const uint8_t *in  = src;
+uint8_t *out = dst;
+int j;
+
+for (j = 0; j < w; j++, out += 3, in -= 3) {
+int32_t v = AV_RB24(in);
+
+AV_WB24(out, v);
+}
+}
+
+static void hflip_b48_c(const uint8_t *src, uint8_t *dst, int w)
+{
+const uint8_t *in  = src;
+uint8_t *out = dst;
+int j;
+
+for (j = 0; j < w; j++, out += 6, in -= 6) {
+int64_t v = AV_RB48(in);
+
+AV_WB48(out, v);
+}
+}
+
+static void hflip_qword_c(const uint8_t *ssrc, uint8_t *ddst, int w)
+{
+const uint64_t *src = (const uint64_t *)ssrc;
+uint64_t *dst = (uint64_t *)ddst;
+int j;
+
+for (j = 0; j < w; j++)
+dst[j] = src[-j];
+}
+
 static int config_props(AVFilterLink *inlink)
 {
 FlipContext *s = inlink->dst->priv;
 const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
 const int hsub = pix_desc->log2_chroma_w;
 const int vsub = pix_desc->log2_chroma_h;
+int nb_planes, i;
 
 av_image_fill_max_pixsteps(s->max_step, NULL, pix_desc);
 s->planewidth[0]  = s->planewidth[3]  = inlink->w;
@@ -80,6 +139,24 @@ static int config_props(AVFilterLink *inlink)
 s->planeheight[0] = s->planeheight[3] = inlink->h;
 s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, vsub);
 
+nb_planes = 

Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Paul B Mahol
On 12/3/17, Paul B Mahol  wrote:
> On 12/3/17, Paul B Mahol  wrote:
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavfilter/hflip.h |  38 
>>  libavfilter/vf_hflip.c  | 133
>> ++--
>>  libavfilter/x86/Makefile|   2 +
>>  libavfilter/x86/vf_hflip.asm|  98 +
>>  libavfilter/x86/vf_hflip_init.c |  41 +
>>  5 files changed, 265 insertions(+), 47 deletions(-)
>>  create mode 100644 libavfilter/hflip.h
>>  create mode 100644 libavfilter/x86/vf_hflip.asm
>>  create mode 100644 libavfilter/x86/vf_hflip_init.c
>>
>
> This is overall ~50% faster than pure C that gcc 6.3.0 gives with
> vanilla options.
>

By overall I mean this simple bench test:

ffmpeg -f lavfi -i smptehdbars=hd1080 -vf hflip=threads=1 -f null -
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Paul B Mahol
On 12/3/17, Paul B Mahol  wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/hflip.h |  38 
>  libavfilter/vf_hflip.c  | 133
> ++--
>  libavfilter/x86/Makefile|   2 +
>  libavfilter/x86/vf_hflip.asm|  98 +
>  libavfilter/x86/vf_hflip_init.c |  41 +
>  5 files changed, 265 insertions(+), 47 deletions(-)
>  create mode 100644 libavfilter/hflip.h
>  create mode 100644 libavfilter/x86/vf_hflip.asm
>  create mode 100644 libavfilter/x86/vf_hflip_init.c
>

This is overall ~50% faster than pure C that gcc 6.3.0 gives with
vanilla options.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/vf_stereo3d: implement auto detection by using frame side data

2017-12-03 Thread Nicolas George
Michael Niedermayer (2017-12-01):
> Do you think this comment will fix any issue or improve anything ?

This comment had one goal: prevent somebody from pushing incorrect
changes before I had time to make my point.

> First i do not even know what you speak of exactly and as this is

I posted the exact reference in my previous mail in this thread, which
is not very long:

https://ffmpeg.org/pipermail/ffmpeg-devel/2017-December/221480.html

> supposedly about code i wrote, i doubt others will have a better idea.
> 
> And there is possibly a difference in goals. Reinitializing filters
> would loose filter state, so avoiding reinit unless really needed was
> a big goal. Last but not least what i had envissioned is just in my head,
> i never implemeted it. (the bikeshedding made me loose
> interrest back then as i already mentioned) what is in git is a small
> part of it, that alone certainly is not that great.
> and "too simple" yes my vission of this was and is simple

I agree that avoiding resets is a worthy goal. I do not know if what you
had in your head was correct or not. But what you committed in
9225513242 (and related commits 5d2b885074, 6c702c3c63, 5d859e5980) was
just wrong. And one of the reason we can be sure it was wrong is that it
caused assert failures, that you did not fix but just hid with more of
the same.

But it is even worse than that: with the last of these commits, the
change can reach buffersink, and therefore the application. The
application will therefore get from buffersink frames with parameters
that do not match the parameters obtained from buffersink itself, it can
be considered a severe bug all by itself. It could even open security
issues for some applications.

What Paul proposes does not have that problem, since it changes the
parameters in buffersink, but it has never been documented that they
could change, and indeed our own source code is written as if they do
not. Therefore, it is not acceptable as is.

You are overly optimistic when saying it is simple. It will involve
quite a bit of work: checking filters to see if their code is safe to
call several times; probably use some kind of flag to see which one are
safe; inserting scale if necessary; providing an API to enable/disable
parameters changes on buffersink; providing an API to detect parameters
changes conveniently.

Not overwhelmingly difficult, but not an easy task either.

And this is only speaking of changes in resolution and other shallow
parameters. If you want to allow changes in pixel format (which your
commits do), you need to adapt the whole format negotiation.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread James Almer
On 12/3/2017 3:55 PM, Martin Vignali wrote:
> in O2 or O3 : clang -S -O3 test_asm_gen.c
> 
> If i correctly understand, same idea than paul's patch
> but processing two xmm in the main loop
> 
> .section__TEXT,__text,regular,pure_instructions
> .macosx_version_min 10, 12
> .section__TEXT,__literal16,16byte_literals
> .p2align4
> LCPI0_0:
> .byte15  ## 0xf
> .byte14  ## 0xe
> .byte13  ## 0xd
> .byte12  ## 0xc
> .byte11  ## 0xb
> .byte10  ## 0xa
> .byte9   ## 0x9
> .byte8   ## 0x8
> .byte7   ## 0x7
> .byte6   ## 0x6
> .byte5   ## 0x5
> .byte4   ## 0x4
> .byte3   ## 0x3
> .byte2   ## 0x2
> .byte1   ## 0x1
> .byte0   ## 0x0
> .section__TEXT,__text,regular,pure_instructions
> .globl_hflip_byte_c
> .p2align4, 0x90
> _hflip_byte_c:  ## @hflip_byte_c
> .cfi_startproc
> ## BB#0:
> pushq%rbp
> Ltmp0:
> .cfi_def_cfa_offset 16
> Ltmp1:
> .cfi_offset %rbp, -16
> movq%rsp, %rbp
> Ltmp2:
> .cfi_def_cfa_register %rbp
> ## kill: %EDX %EDX
> %RDX
> testl%edx, %edx
> jleLBB0_17
> ## BB#1:
> movl%edx, %r8d
> cmpl$32, %edx
> jaeLBB0_3
> ## BB#2:
> xorl%r11d, %r11d
> jmpLBB0_11
> LBB0_3:
> andl$31, %edx
> movq%r8, %r11
> subq%rdx, %r11
> jeLBB0_7
> ## BB#4:
> leaq1(%rdi), %rax
> cmpq%rsi, %rax
> jbeLBB0_8
> ## BB#5:
> leaq(%rsi,%r8), %r9
> movl$1, %eax
> subq%r8, %rax
> addq%rdi, %rax
> cmpq%r9, %rax
> jaeLBB0_8
> LBB0_7:
> xorl%r11d, %r11d
> jmpLBB0_11
> LBB0_8:
> leaq-15(%rdi), %r9
> leaq16(%rsi), %rax
> movdqaLCPI0_0(%rip), %xmm0## xmm0 =
> [15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0]
> movq%r11, %r10
> .p2align4, 0x90
> LBB0_9: ## =>This Inner Loop Header: Depth=1
> movdqu-16(%r9), %xmm1
> movdqu(%r9), %xmm2
> pshufb%xmm0, %xmm2
> pshufb%xmm0, %xmm1
> movdqu%xmm2, -16(%rax)
> movdqu%xmm1, (%rax)
> addq$-32, %r9
> addq$32, %rax
> addq$-32, %r10
> jneLBB0_9

Huh, so we're not disabling tree vectorization with clang, only with
GCC. Guess it hasn't generated broken code before to justify disabling it.

In any case, if clang or gcc can generate better code, then the hand
written version needs to be optimized to be as fast or faster.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Martin Vignali
> Can you post a disassembly of hflip_byte_c?
>
>
> in O1 : clang -S -O1 test_asm_gen.c

.section__TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 12
.globl_hflip_byte_c
.p2align4, 0x90
_hflip_byte_c:  ## @hflip_byte_c
.cfi_startproc
## BB#0:
pushq%rbp
Ltmp0:
.cfi_def_cfa_offset 16
Ltmp1:
.cfi_offset %rbp, -16
movq%rsp, %rbp
Ltmp2:
.cfi_def_cfa_register %rbp
testl%edx, %edx
jleLBB0_3
## BB#1:
movl%edx, %eax
.p2align4, 0x90
LBB0_2: ## =>This Inner Loop Header: Depth=1
movzbl(%rdi), %ecx
movb%cl, (%rsi)
decq%rdi
incq%rsi
decq%rax
jneLBB0_2
LBB0_3:
popq%rbp
retq
.cfi_endproc


.subsections_via_symbols






in O2 or O3 : clang -S -O3 test_asm_gen.c

If i correctly understand, same idea than paul's patch
but processing two xmm in the main loop

.section__TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 12
.section__TEXT,__literal16,16byte_literals
.p2align4
LCPI0_0:
.byte15  ## 0xf
.byte14  ## 0xe
.byte13  ## 0xd
.byte12  ## 0xc
.byte11  ## 0xb
.byte10  ## 0xa
.byte9   ## 0x9
.byte8   ## 0x8
.byte7   ## 0x7
.byte6   ## 0x6
.byte5   ## 0x5
.byte4   ## 0x4
.byte3   ## 0x3
.byte2   ## 0x2
.byte1   ## 0x1
.byte0   ## 0x0
.section__TEXT,__text,regular,pure_instructions
.globl_hflip_byte_c
.p2align4, 0x90
_hflip_byte_c:  ## @hflip_byte_c
.cfi_startproc
## BB#0:
pushq%rbp
Ltmp0:
.cfi_def_cfa_offset 16
Ltmp1:
.cfi_offset %rbp, -16
movq%rsp, %rbp
Ltmp2:
.cfi_def_cfa_register %rbp
## kill: %EDX %EDX
%RDX
testl%edx, %edx
jleLBB0_17
## BB#1:
movl%edx, %r8d
cmpl$32, %edx
jaeLBB0_3
## BB#2:
xorl%r11d, %r11d
jmpLBB0_11
LBB0_3:
andl$31, %edx
movq%r8, %r11
subq%rdx, %r11
jeLBB0_7
## BB#4:
leaq1(%rdi), %rax
cmpq%rsi, %rax
jbeLBB0_8
## BB#5:
leaq(%rsi,%r8), %r9
movl$1, %eax
subq%r8, %rax
addq%rdi, %rax
cmpq%r9, %rax
jaeLBB0_8
LBB0_7:
xorl%r11d, %r11d
jmpLBB0_11
LBB0_8:
leaq-15(%rdi), %r9
leaq16(%rsi), %rax
movdqaLCPI0_0(%rip), %xmm0## xmm0 =
[15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0]
movq%r11, %r10
.p2align4, 0x90
LBB0_9: ## =>This Inner Loop Header: Depth=1
movdqu-16(%r9), %xmm1
movdqu(%r9), %xmm2
pshufb%xmm0, %xmm2
pshufb%xmm0, %xmm1
movdqu%xmm2, -16(%rax)
movdqu%xmm1, (%rax)
addq$-32, %r9
addq$32, %rax
addq$-32, %r10
jneLBB0_9
## BB#10:
testl%edx, %edx
jeLBB0_17
LBB0_11:
movl%r8d, %eax
subl%r11d, %eax
leaq-1(%r8), %r9
subq%r11, %r9
andq$3, %rax
jeLBB0_14
## BB#12:
movq%rdi, %rdx
subq%r11, %rdx
negq%rax
.p2align4, 0x90
LBB0_13:## =>This Inner Loop Header: Depth=1
movzbl(%rdx), %ecx
movb%cl, (%rsi,%r11)
incq%r11
decq%rdx
incq%rax
jneLBB0_13
LBB0_14:
cmpq$3, %r9
jbLBB0_17
## BB#15:
subq%r11, %r8
subq%r11, %rdi
leaq3(%rsi,%r11), %rax
.p2align4, 0x90
LBB0_16:## =>This Inner Loop Header: Depth=1
movzbl(%rdi), %ecx
movb%cl, -3(%rax)
movzbl-1(%rdi), %ecx
movb%cl, -2(%rax)
movzbl-2(%rdi), %ecx
movb%cl, -1(%rax)
movzbl-3(%rdi), %ecx
movb%cl, (%rax)
addq$-4, %rdi
addq$4, %rax
addq$-4, %r8
jneLBB0_16
LBB0_17:
popq%rbp
retq
.cfi_endproc


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


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread James Almer
On 12/3/2017 3:09 PM, Martin Vignali wrote:
>> 2017-12-03 17:46 GMT+01:00 Paul B Mahol :
>>
>>> On 12/3/17, Martin Vignali  wrote:
 Hello,

 Maybe you can use a macro for byte and short version,
 only few lines are different in each version
>>>
>>> Sure, feel free to send patches.
>>>
>>> I'm not very macro proficient.
>>>
>>
>> Ok, i will take a look.
>>
>> Martin
>>
> 
> I write a basic checkasm test. Seems like the byte version is slower than c
> 
> hflip_byte_c: 31.8
> hflip_byte_ssse3: 108.1
> hflip_short_c: 300.1
> hflip_short_ssse3: 139.8
> 
> (checkasm patch in attach if you want to test)
> 
> Martin

$ tests/checkasm/checkasm.exe --test=vf_hflip --bench
benchmarking with native FFmpeg timers
nop: 32.0
hflip_byte_c: 362.0
hflip_byte_ssse3: 96.0
hflip_short_c: 374.0
hflip_short_ssse3: 121.0

Guess your compiler is really good at optimizing this code, or something
funny is going on.
Can you post a disassembly of hflip_byte_c?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] avfilter/x86/vf_threshold : add SSE4 and AVX2 for threshold 16

2017-12-03 Thread Martin Vignali
Hello,

Patch in attach add SIMD for threshold16

Checkasm result :
threshold16_c: 304.5
threshold16_sse4: 60.5
threshold16_avx2: 45.0


001 : modify threshold macro, and add threshold 16

002 : add checkasm test for threshold16


Martin


0001-avfilter-x86-vf_threshold-add-threshold16-SIMD-SSE4-.patch
Description: Binary data


0002-checkasm-vf_threshold-add-test-for-threshold16.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] avfilter/vf_threshold : add checkasm and avx2 version for threshold8

2017-12-03 Thread Martin Vignali
2017-12-03 18:01 GMT+01:00 Paul B Mahol :

> On 12/3/17, Martin Vignali  wrote:
> >> >
> >>> > 002 : Add checkasm test for vf_threshold
> >>>
> >>> Why is this GPL?
> >>>
> >>> Because i copy paste the header of vf_blend checkasm
> >> Will change to LGPL.
> >>
> >> in fact most(all ?) checkasm test are under GPL licence.
> > and the checkasm exe, is under GPL too.
> >
> > So i will let the current GPL licence
>
> Funny, ok then, feel to apply whenever you wish.
>
>
> Pushed, thanks

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


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Martin Vignali
> 2017-12-03 17:46 GMT+01:00 Paul B Mahol :
>
>> On 12/3/17, Martin Vignali  wrote:
>> > Hello,
>> >
>> > Maybe you can use a macro for byte and short version,
>> > only few lines are different in each version
>>
>> Sure, feel free to send patches.
>>
>> I'm not very macro proficient.
>>
>
> Ok, i will take a look.
>
> Martin
>

I write a basic checkasm test. Seems like the byte version is slower than c

hflip_byte_c: 31.8
hflip_byte_ssse3: 108.1
hflip_short_c: 300.1
hflip_short_ssse3: 139.8

(checkasm patch in attach if you want to test)

Martin


0002-checkasm-vf_hflip-add-test-for-hflip-SIMD.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/6] lavc/libx265: mark disposable frames

2017-12-03 Thread John Stebbins
On 12/02/2017 06:32 PM, James Almer wrote:
> On 12/2/2017 10:48 PM, Michael Niedermayer wrote:
>> On Sat, Dec 02, 2017 at 03:26:34PM -0300, James Almer wrote:
>>> On 12/2/2017 3:00 PM, Carl Eugen Hoyos wrote:
 2017-12-02 18:51 GMT+01:00 James Almer :
> On 12/2/2017 2:40 PM, Carl Eugen Hoyos wrote:
>> 2017-12-02 18:37 GMT+01:00 John Stebbins :
>>> That should be done, or I should add back support for earlier versions.
>>> Is there any desire by anyone to keep support for earlier versions?
>> How old is 2.5, is 2.4 used by current versions of distributions?
>> (How ugly is the support for earlier versions?)
> It's four months old, and rolling release distros are using it and will
> move on to 2.6 soon.
>
> By the time non rolling release distros switch to ffmpeg > 3.4, they
> will also switch to whatever is newest for x265 at the time.
 I was mostly thinking about users who build FFmpeg by themselves
 on current distributions. (And about developers who like to test on
 vanilla systems.)
>>> Those on rolling release ditros are covered, and those compiling ffmpeg
>>> git head on non rolling release distros are most likely also compiling
>>> any required libraries for it.
>>> Hell, 2.5 is even in Debian testing right now.
>>>
>>> I very much rather avoid ifdeffery to support old releases from projects
>>> with a rapid update schedule like x265.
>> I understand why you prefer this but i think its nicer to our users
>> also the stricter version  deps are the more one runs into issues
>>
>> for example the "recent" libvpx min version bump required me to
>> update my libvpx
> How? 1.4.0 is two years and a half old. Even Debian ships 1.6.x in
> stable by now.
>
>> and it promptly broke many older FFmpeg versions
>> ive patched my release branches locally and that would be in the next
>> point releases of course but versions released previously require
>> a libvpx that master doesnt build with and what master builds with
>> they dont.
>>
>> If we accumulate too many of these things bisect will become
>> increasingly painfull
> We can't keep external libraries hostage of bisect attempts for
> unrelated modules... You don't need libvpx or libx265 compiled in when
> hunting down a bug in mpeg2/h264/snow code. We'd never be able to update
> anything that way.
>
> I'm surprised for that matter that the libvpx wrappers in old FFMpeg
> versions don't work with >= 1.4.0. I don't recall any kind of API break
> that we had to work around in them.
>
>> short version, my "vote" is for keeping support for the older version
>> by #if or any other solution
> I'm fine keeping libx265 as is for now. Unlike libvpx 1.4.0, which is
> two years and a half old, libx265 2.5 is admittedly somewhat recent.
> But bisecting bugs in unrelated modules is definitely not a reason to
> maintain ugly support for old and potentially buggy/unstable/insecure
> versions of optional, non system external libraries.
>

I'll add back the support for libx265 <= 2.4 then.  There's technically no 
ifdef'ery required.  But it requires using a
field in a struct (x265_frame_stats) that is really meant for logging.  My 
concern with using it is that logging could
change in the future and break this. So I'll ifdef it anyway so that it's more 
future proof.

-- 
John  GnuPG fingerprint: D0EC B3DB C372 D1F1 0B01  83F0 49F1 D7B2 60D4 D0F7




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


Re: [FFmpeg-devel] avfilter/vf_threshold : add checkasm and avx2 version for threshold8

2017-12-03 Thread Paul B Mahol
On 12/3/17, Martin Vignali  wrote:
>> >
>>> > 002 : Add checkasm test for vf_threshold
>>>
>>> Why is this GPL?
>>>
>>> Because i copy paste the header of vf_blend checkasm
>> Will change to LGPL.
>>
>> in fact most(all ?) checkasm test are under GPL licence.
> and the checkasm exe, is under GPL too.
>
> So i will let the current GPL licence

Funny, ok then, feel to apply whenever you wish.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] avfilter/vf_threshold : add checkasm and avx2 version for threshold8

2017-12-03 Thread Martin Vignali
> >
>> > 002 : Add checkasm test for vf_threshold
>>
>> Why is this GPL?
>>
>> Because i copy paste the header of vf_blend checkasm
> Will change to LGPL.
>
> in fact most(all ?) checkasm test are under GPL licence.
and the checkasm exe, is under GPL too.

So i will let the current GPL licence

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


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Martin Vignali
2017-12-03 17:46 GMT+01:00 Paul B Mahol :

> On 12/3/17, Martin Vignali  wrote:
> > Hello,
> >
> > Maybe you can use a macro for byte and short version,
> > only few lines are different in each version
>
> Sure, feel free to send patches.
>
> I'm not very macro proficient.
>

Ok, i will take a look.

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


Re: [FFmpeg-devel] avfilter/vf_threshold : add checkasm and avx2 version for threshold8

2017-12-03 Thread Martin Vignali
>
> > 002 : Add checkasm test for vf_threshold
>
> Why is this GPL?
>
> Because i copy paste the header of vf_blend checkasm
Will change to LGPL.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Paul B Mahol
On 12/3/17, Martin Vignali  wrote:
> Hello,
>
> Maybe you can use a macro for byte and short version,
> only few lines are different in each version

Sure, feel free to send patches.

I'm not very macro proficient.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] avfilter/vf_threshold : add checkasm and avx2 version for threshold8

2017-12-03 Thread Paul B Mahol
On 12/3/17, Martin Vignali  wrote:
> Hello,
>
> In attach patch to add a checkasm test for the recently added threshold8
> SIMD
>
> also add AVX2 version
>
> Checkasm result :
> threshold8_c: 584.8
> threshold8_sse4: 65.0
> threshold8_avx2: 43.5
>
>
> 001 : create ff_threshold_init_func in order to simplify checkasm write
> (more like previous checkasm test for filter)
>
> 002 : Add checkasm test for vf_threshold

Why is this GPL?


>
> 003 : make macro for existing asm, in order to add avx2 version
>
> 004 : add avx2 version for threshold 8
>
> 005 : cosmetic indent asm
>
> Martin
>

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


Re: [FFmpeg-devel] [PATCH] avfilter: add hflip x86 SIMD

2017-12-03 Thread Martin Vignali
Hello,

Maybe you can use a macro for byte and short version,
only few lines are different in each version

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


[FFmpeg-devel] avfilter/vf_threshold : add checkasm and avx2 version for threshold8

2017-12-03 Thread Martin Vignali
Hello,

In attach patch to add a checkasm test for the recently added threshold8
SIMD

also add AVX2 version

Checkasm result :
threshold8_c: 584.8
threshold8_sse4: 65.0
threshold8_avx2: 43.5


001 : create ff_threshold_init_func in order to simplify checkasm write
(more like previous checkasm test for filter)

002 : Add checkasm test for vf_threshold

003 : make macro for existing asm, in order to add avx2 version

004 : add avx2 version for threshold 8

005 : cosmetic indent asm

Martin


0001-avfilter-vf_threshold-move-context-func-init-in-ff_t.patch
Description: Binary data


0002-checkasm-vf_threshold-add-checkasm-test-for-threshol.patch
Description: Binary data


0003-avfilter-x86-vf_threshold-make-macro-for-threshold8.patch
Description: Binary data


0004-avfilter-x86-vf_threshold-add-avx2-version-for-thres.patch
Description: Binary data


0005-avfilter-x86-vf_threshold-cosmetic-indent.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] rtsp: only break on parse_rtsp_message on error

2017-12-03 Thread Tristan Matthews
On Sat, Dec 2, 2017 at 11:01 AM, Michael Niedermayer
 wrote:
> On Fri, Dec 01, 2017 at 04:09:15PM -0500, Tristan Matthews wrote:
>> Fix suggested by Luca Barbato.
>>
>> This was causing spurious EOFs when using -rtsp_transport udp, as
>> reported in https://bugzilla.libav.org/show_bug.cgi?id=1103
>> ---
>>  libavformat/rtsp.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> where is the code which interprets 0 as EOF ?

udp_read_packet is called here:
http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/rtsp.c;h=b6da61b95e6c0ecce63d1d86e2b8fe7066ee2f96;hb=HEAD#l2082

which in turn, calls rtsp_parse_message here:
http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/rtsp.c;h=b6da61b95e6c0ecce63d1d86e2b8fe7066ee2f96;hb=HEAD#l2010

which returns 0 in the non-error case here:
http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/rtsp.c;h=b6da61b95e6c0ecce63d1d86e2b8fe7066ee2f96;hb=HEAD#l1945

this is then interpreted as an EOF here
http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/rtsp.c;h=b6da61b95e6c0ecce63d1d86e2b8fe7066ee2f96;hb=HEAD#l2098

Best,
Tristan

> also nicolas may want to look at this, he was working on EOF vs 0 issues
> (thus ccing nicolas)
>
> thanks
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> it is not once nor twice but times without number that the same ideas make
> their appearance in the world. -- Aristotle
>
> ___
> 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


[FFmpeg-devel] [PATCH v4 1/2] lavf/hls: refactoring of read_header

2017-12-03 Thread Rainer Hochecker
---
 libavformat/hls.c | 208 +++---
 1 file changed, 119 insertions(+), 89 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index ab6ff187a6..3c2c720abe 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -314,6 +314,8 @@ static struct playlist *new_playlist(HLSContext *c, const 
char *url,
 pls->is_id3_timestamped = -1;
 pls->id3_mpegts_timestamp = AV_NOPTS_VALUE;
 
+pls->index = c->n_playlists;
+pls->needed = 0;
 dynarray_add(>playlists, >n_playlists, pls);
 return pls;
 }
@@ -1670,6 +1672,121 @@ static int hls_close(AVFormatContext *s)
 return 0;
 }
 
+static int init_playlist(HLSContext *c, struct playlist *pls)
+{
+AVInputFormat *in_fmt = NULL;
+int highest_cur_seq_no = 0;
+int ret;
+int i;
+
+if (!(pls->ctx = avformat_alloc_context())) {
+return AVERROR(ENOMEM);
+}
+
+if (pls->n_segments == 0)
+return 0;
+
+pls->needed = 1;
+pls->parent = c->ctx;
+
+/*
+ * If this is a live stream and this playlist looks like it is one segment
+ * behind, try to sync it up so that every substream starts at the same
+ * time position (so e.g. avformat_find_stream_info() will see packets from
+ * all active streams within the first few seconds). This is not very 
generic,
+ * though, as the sequence numbers are technically independent.
+ */
+highest_cur_seq_no = 0;
+for (i = 0; i < c->n_playlists; i++) {
+struct playlist *pls = c->playlists[i];
+if (pls->cur_seq_no > highest_cur_seq_no)
+highest_cur_seq_no = pls->cur_seq_no;
+}
+if (!pls->finished && pls->cur_seq_no == highest_cur_seq_no - 1 &&
+highest_cur_seq_no < pls->start_seq_no + pls->n_segments) {
+pls->cur_seq_no = highest_cur_seq_no;
+}
+
+pls->read_buffer = av_malloc(INITIAL_BUFFER_SIZE);
+if (!pls->read_buffer){
+ret = AVERROR(ENOMEM);
+avformat_free_context(pls->ctx);
+pls->ctx = NULL;
+return ret;
+}
+ffio_init_context(>pb, pls->read_buffer, INITIAL_BUFFER_SIZE, 0, pls,
+  read_data, NULL, NULL);
+pls->pb.seekable = 0;
+ret = av_probe_input_buffer(>pb, _fmt, pls->segments[0]->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(c->ctx, AV_LOG_ERROR, "Error when loading first segment 
'%s'\n", pls->segments[0]->url);
+avio_closep(>pb);
+avformat_free_context(pls->ctx);
+pls->ctx = NULL;
+return ret;
+}
+pls->ctx->pb   = >pb;
+pls->ctx->io_open  = nested_io_open;
+pls->ctx->flags   |= c->ctx->flags & ~AVFMT_FLAG_CUSTOM_IO;
+
+if ((ret = ff_copy_whiteblacklists(pls->ctx, c->ctx)) < 0)
+return ret;
+
+ret = avformat_open_input(>ctx, pls->segments[0]->url, in_fmt, NULL);
+if (ret < 0) {
+av_log(c->ctx, AV_LOG_ERROR, "Error opening playlist %s", 
pls->segments[0]->url);
+avformat_free_context(pls->ctx);
+pls->ctx = NULL;
+return ret;
+}
+
+if (pls->id3_deferred_extra && pls->ctx->nb_streams == 1) {
+ff_id3v2_parse_apic(pls->ctx, >id3_deferred_extra);
+avformat_queue_attached_pictures(pls->ctx);
+ff_id3v2_free_extra_meta(>id3_deferred_extra);
+pls->id3_deferred_extra = NULL;
+}
+
+if (pls->is_id3_timestamped == -1)
+av_log(c->ctx, AV_LOG_WARNING, "No expected HTTP requests have been 
made\n");
+
+/*
+ * For ID3 timestamped raw audio streams we need to detect the packet
+ * durations to calculate timestamps in 
fill_timing_for_id3_timestamped_stream(),
+ * but for other streams we can rely on our user calling 
avformat_find_stream_info()
+ * on us if they want to.
+ */
+if (pls->is_id3_timestamped) {
+ret = avformat_find_stream_info(pls->ctx, NULL);
+if (ret < 0) {
+avformat_free_context(pls->ctx);
+pls->ctx = NULL;
+return ret;
+}
+}
+
+pls->has_noheader_flag = !!(pls->ctx->ctx_flags & AVFMTCTX_NOHEADER);
+
+/* Create new AVStreams for each stream in this playlist */
+ret = update_streams_from_subdemuxer(c->ctx, pls);
+if (ret < 0) {
+avformat_free_context(pls->ctx);
+pls->ctx = NULL;
+return ret;
+}
+
+add_metadata_from_renditions(c->ctx, pls, AVMEDIA_TYPE_AUDIO);
+add_metadata_from_renditions(c->ctx, pls, AVMEDIA_TYPE_VIDEO);
+add_metadata_from_renditions(c->ctx, pls, AVMEDIA_TYPE_SUBTITLE);
+
+return 0;
+}
+
 static int hls_read_header(AVFormatContext *s)
 {
 void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb;
@@ -1775,97 

[FFmpeg-devel] [PATCH v4 2/2] lavf/hls: add option to defer parsing of variants

2017-12-03 Thread Rainer Hochecker
---
 doc/demuxers.texi |   6 
 libavformat/hls.c | 106 ++
 2 files changed, 98 insertions(+), 14 deletions(-)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 73dc0feec1..33643f966a 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -316,6 +316,12 @@ segment index to start live streams at (negative values 
are from the end).
 @item max_reload
 Maximum number of times a insufficient list is attempted to be reloaded.
 Default value is 1000.
+
+@item load_all_variants
+If 0, only the first variant/playlist is loaded on open. All other variants
+get disabled and can be enabled by setting discard option in program.
+Default value is 1.
+
 @end table
 
 @section image2
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 3c2c720abe..500e3c15de 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -112,6 +112,7 @@ struct playlist {
 int n_segments;
 struct segment **segments;
 int needed;
+int parsed;
 int cur_seq_no;
 int64_t cur_seg_offset;
 int64_t last_load_time;
@@ -206,6 +207,7 @@ typedef struct HLSContext {
 int strict_std_compliance;
 char *allowed_extensions;
 int max_reload;
+int load_all_variants;
 } HLSContext;
 
 static int read_chomp_line(AVIOContext *s, char *buf, int maxlen)
@@ -315,6 +317,7 @@ static struct playlist *new_playlist(HLSContext *c, const 
char *url,
 pls->id3_mpegts_timestamp = AV_NOPTS_VALUE;
 
 pls->index = c->n_playlists;
+pls->parsed = 0;
 pls->needed = 0;
 dynarray_add(>playlists, >n_playlists, pls);
 return pls;
@@ -867,6 +870,10 @@ fail:
 av_free(new_url);
 if (close_in)
 ff_format_io_close(c->ctx, );
+
+if (pls)
+pls->parsed = 1;
+
 return ret;
 }
 
@@ -1260,17 +1267,30 @@ static int64_t default_reload_interval(struct playlist 
*pls)
   pls->target_duration;
 }
 
-static int playlist_needed(struct playlist *pls)
+static int playlist_needed(AVFormatContext *s, struct playlist *pls, int 
check_parsed)
 {
-AVFormatContext *s = pls->parent;
+HLSContext *c = s->priv_data;
 int i, j;
 int stream_needed = 0;
 int first_st;
 
 /* If there is no context or streams yet, the playlist is needed */
-if (!pls->ctx || !pls->n_main_streams)
+if (check_parsed && (!pls->ctx || !pls->n_main_streams))
 return 1;
 
+/* If the playlist belongs to a non discarded variant and is not parsed,
+ * we need to parse and activate it later */
+for (i = 0; i < s->nb_programs; i++) {
+AVProgram *program = s->programs[i];
+struct variant *var = c->variants[i];
+if (program->discard < AVDISCARD_ALL) {
+for (j = 0; j < var->n_playlists; j++) {
+if (var->playlists[j] == pls && !var->playlists[j]->parsed)
+return  1;
+}
+}
+}
+
 /* check if any of the streams in the playlist are needed */
 for (i = 0; i < pls->n_main_streams; i++) {
 if (pls->main_streams[i]->discard < AVDISCARD_ALL) {
@@ -1324,7 +1344,7 @@ restart:
 
 /* Check that the playlist is still needed before opening a new
  * segment. */
-v->needed = playlist_needed(v);
+v->needed = playlist_needed(v->parent, v, 1);
 
 if (!v->needed) {
 av_log(v->parent, AV_LOG_INFO, "No longer receiving playlist %d\n",
@@ -1418,23 +1438,41 @@ reload:
 static void add_renditions_to_variant(HLSContext *c, struct variant *var,
   enum AVMediaType type, const char 
*group_id)
 {
-int i;
+int i, j;
+int found;
 
 for (i = 0; i < c->n_renditions; i++) {
 struct rendition *rend = c->renditions[i];
 
 if (rend->type == type && !strcmp(rend->group_id, group_id)) {
 
-if (rend->playlist)
+if (rend->playlist) {
 /* rendition is an external playlist
  * => add the playlist to the variant */
-dynarray_add(>playlists, >n_playlists, 
rend->playlist);
-else
+found = 0;
+for (j = 0; j < var->n_playlists; j++) {
+if (var->playlists[j] == rend->playlist) {
+found = 1;
+break;
+}
+}
+if (!found)
+dynarray_add(>playlists, >n_playlists, 
rend->playlist);
+} else {
 /* rendition is part of the variant main Media Playlist
  * => add the rendition to the main Media Playlist */
-dynarray_add(>playlists[0]->renditions,
- >playlists[0]->n_renditions,
- rend);
+found = 0;
+for (j = 0; j < var->playlists[0]->n_renditions; j++) {
+if (var->playlists[0]->renditions[j] == rend) {
+

[FFmpeg-devel] [PATCH] hls demuxer: add option to defer parsing of variants

2017-12-03 Thread Rainer Hochecker
v4: fixed the memleak properly
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v3 2/2] lavf/hls: add option to defer parsing of variants

2017-12-03 Thread Rainer Hochecker
---
 doc/demuxers.texi |   6 
 libavformat/hls.c | 106 ++
 2 files changed, 98 insertions(+), 14 deletions(-)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 73dc0feec1..33643f966a 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -316,6 +316,12 @@ segment index to start live streams at (negative values 
are from the end).
 @item max_reload
 Maximum number of times a insufficient list is attempted to be reloaded.
 Default value is 1000.
+
+@item load_all_variants
+If 0, only the first variant/playlist is loaded on open. All other variants
+get disabled and can be enabled by setting discard option in program.
+Default value is 1.
+
 @end table
 
 @section image2
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 3f83707c1f..731e8a569c 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -112,6 +112,7 @@ struct playlist {
 int n_segments;
 struct segment **segments;
 int needed;
+int parsed;
 int cur_seq_no;
 int64_t cur_seg_offset;
 int64_t last_load_time;
@@ -206,6 +207,7 @@ typedef struct HLSContext {
 int strict_std_compliance;
 char *allowed_extensions;
 int max_reload;
+int load_all_variants;
 } HLSContext;
 
 static int read_chomp_line(AVIOContext *s, char *buf, int maxlen)
@@ -315,6 +317,7 @@ static struct playlist *new_playlist(HLSContext *c, const 
char *url,
 pls->id3_mpegts_timestamp = AV_NOPTS_VALUE;
 
 pls->index = c->n_playlists;
+pls->parsed = 0;
 pls->needed = 0;
 dynarray_add(>playlists, >n_playlists, pls);
 return pls;
@@ -867,6 +870,10 @@ fail:
 av_free(new_url);
 if (close_in)
 ff_format_io_close(c->ctx, );
+
+if (pls)
+pls->parsed = 1;
+
 return ret;
 }
 
@@ -1260,17 +1267,30 @@ static int64_t default_reload_interval(struct playlist 
*pls)
   pls->target_duration;
 }
 
-static int playlist_needed(struct playlist *pls)
+static int playlist_needed(AVFormatContext *s, struct playlist *pls, int 
check_parsed)
 {
-AVFormatContext *s = pls->parent;
+HLSContext *c = s->priv_data;
 int i, j;
 int stream_needed = 0;
 int first_st;
 
 /* If there is no context or streams yet, the playlist is needed */
-if (!pls->ctx || !pls->n_main_streams)
+if (check_parsed && (!pls->ctx || !pls->n_main_streams))
 return 1;
 
+/* If the playlist belongs to a non discarded variant and is not parsed,
+ * we need to parse and activate it later */
+for (i = 0; i < s->nb_programs; i++) {
+AVProgram *program = s->programs[i];
+struct variant *var = c->variants[i];
+if (program->discard < AVDISCARD_ALL) {
+for (j = 0; j < var->n_playlists; j++) {
+if (var->playlists[j] == pls && !var->playlists[j]->parsed)
+return  1;
+}
+}
+}
+
 /* check if any of the streams in the playlist are needed */
 for (i = 0; i < pls->n_main_streams; i++) {
 if (pls->main_streams[i]->discard < AVDISCARD_ALL) {
@@ -1324,7 +1344,7 @@ restart:
 
 /* Check that the playlist is still needed before opening a new
  * segment. */
-v->needed = playlist_needed(v);
+v->needed = playlist_needed(v->parent, v, 1);
 
 if (!v->needed) {
 av_log(v->parent, AV_LOG_INFO, "No longer receiving playlist %d\n",
@@ -1418,23 +1438,41 @@ reload:
 static void add_renditions_to_variant(HLSContext *c, struct variant *var,
   enum AVMediaType type, const char 
*group_id)
 {
-int i;
+int i, j;
+int found;
 
 for (i = 0; i < c->n_renditions; i++) {
 struct rendition *rend = c->renditions[i];
 
 if (rend->type == type && !strcmp(rend->group_id, group_id)) {
 
-if (rend->playlist)
+if (rend->playlist) {
 /* rendition is an external playlist
  * => add the playlist to the variant */
-dynarray_add(>playlists, >n_playlists, 
rend->playlist);
-else
+found = 0;
+for (j = 0; j < var->n_playlists; j++) {
+if (var->playlists[j] == rend->playlist) {
+found = 1;
+break;
+}
+}
+if (!found)
+dynarray_add(>playlists, >n_playlists, 
rend->playlist);
+} else {
 /* rendition is part of the variant main Media Playlist
  * => add the rendition to the main Media Playlist */
-dynarray_add(>playlists[0]->renditions,
- >playlists[0]->n_renditions,
- rend);
+found = 0;
+for (j = 0; j < var->playlists[0]->n_renditions; j++) {
+if (var->playlists[0]->renditions[j] == rend) {
+

[FFmpeg-devel] [PATCH] hls demuxer: add option to defer parsing of variants

2017-12-03 Thread Rainer Hochecker
fixed mem leak poined out by Steven
 
---
 doc/demuxers.texi |   5 +
 libavformat/hls.c | 304 --
 2 files changed, 209 insertions(+), 100 deletions(-)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 73dc0feec1..634b122e10 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -316,6 +316,11 @@ segment index to start live streams at (negative values 
are from the end).
 @item max_reload
 Maximum number of times a insufficient list is attempted to be reloaded.
 Default value is 1000.
+
+@item load_all_variants
+If 0, only the first variant/playlist is loaded on open. All other variants
+get disabled and can be enabled by setting discard option in program.
+Default value is 1.
 @end table
 
 @section image2
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 786934af03..c42e0b0f95 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -112,6 +112,7 @@ struct playlist {
 int n_segments;
 struct segment **segments;
 int needed, cur_needed;
+int parsed;
 int cur_seq_no;
 int64_t cur_seg_offset;
 int64_t last_load_time;
@@ -206,6 +207,7 @@ typedef struct HLSContext {
 int strict_std_compliance;
 char *allowed_extensions;
 int max_reload;
+int load_all_variants;
 } HLSContext;
 
 static int read_chomp_line(AVIOContext *s, char *buf, int maxlen)
@@ -314,6 +316,9 @@ static struct playlist *new_playlist(HLSContext *c, const 
char *url,
 pls->is_id3_timestamped = -1;
 pls->id3_mpegts_timestamp = AV_NOPTS_VALUE;
 
+pls->index = c->n_playlists;
+pls->parsed = 0;
+pls->needed = 0;
 dynarray_add(>playlists, >n_playlists, pls);
 return pls;
 }
@@ -721,6 +726,7 @@ static int parse_playlist(HLSContext *c, const char *url,
 free_segment_list(pls);
 pls->finished = 0;
 pls->type = PLS_TYPE_UNSPECIFIED;
+pls->parsed = 1;
 }
 while (!avio_feof(in)) {
 read_chomp_line(in, line, sizeof(line));
@@ -1377,23 +1383,41 @@ reload:
 static void add_renditions_to_variant(HLSContext *c, struct variant *var,
   enum AVMediaType type, const char 
*group_id)
 {
-int i;
+int i, j;
+int found;
 
 for (i = 0; i < c->n_renditions; i++) {
 struct rendition *rend = c->renditions[i];
 
 if (rend->type == type && !strcmp(rend->group_id, group_id)) {
 
-if (rend->playlist)
+if (rend->playlist) {
 /* rendition is an external playlist
  * => add the playlist to the variant */
-dynarray_add(>playlists, >n_playlists, 
rend->playlist);
-else
+found = 0;
+for (j = 0; j < var->n_playlists; j++) {
+if (var->playlists[j] == rend->playlist) {
+found = 1;
+break;
+}
+}
+if (!found)
+dynarray_add(>playlists, >n_playlists, 
rend->playlist);
+} else {
 /* rendition is part of the variant main Media Playlist
  * => add the rendition to the main Media Playlist */
-dynarray_add(>playlists[0]->renditions,
- >playlists[0]->n_renditions,
- rend);
+found = 0;
+for (j = 0; j < var->playlists[0]->n_renditions; j++) {
+if (var->playlists[0]->renditions[j] == rend) {
+found = 1;
+break;
+}
+}
+if (!found)
+dynarray_add(>playlists[0]->renditions,
+ >playlists[0]->n_renditions,
+ rend);
+}
 }
 }
 }
@@ -1631,6 +1655,124 @@ static int hls_close(AVFormatContext *s)
 return 0;
 }
 
+static int init_playlist(HLSContext *c, struct playlist *pls)
+{
+AVInputFormat *in_fmt = NULL;
+int highest_cur_seq_no = 0;
+int ret;
+int i;
+
+if (!(pls->ctx = avformat_alloc_context())) {
+return AVERROR(ENOMEM);
+}
+
+if (pls->n_segments == 0)
+return 0;
+
+pls->needed = 1;
+pls->parent = c->ctx;
+
+/*
+ * If this is a live stream and this playlist looks like it is one segment
+ * behind, try to sync it up so that every substream starts at the same
+ * time position (so e.g. avformat_find_stream_info() will see packets from
+ * all active streams within the first few seconds). This is not very 
generic,
+ * though, as the sequence numbers are technically independent.
+ */
+highest_cur_seq_no = 0;
+for (i = 0; i < c->n_playlists; i++) {
+struct playlist *pls = c->playlists[i];
+if (!pls->parsed)
+continue;
+if (pls->cur_seq_no > highest_cur_seq_no)
+highest_cur_seq_no = 

[FFmpeg-devel] [PATCH v3 1/2] lavf/hls: refactoring of read_header

2017-12-03 Thread Rainer Hochecker
---
 libavformat/hls.c | 209 +++---
 1 file changed, 120 insertions(+), 89 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index ab6ff187a6..3f83707c1f 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -314,6 +314,8 @@ static struct playlist *new_playlist(HLSContext *c, const 
char *url,
 pls->is_id3_timestamped = -1;
 pls->id3_mpegts_timestamp = AV_NOPTS_VALUE;
 
+pls->index = c->n_playlists;
+pls->needed = 0;
 dynarray_add(>playlists, >n_playlists, pls);
 return pls;
 }
@@ -1670,6 +1672,122 @@ static int hls_close(AVFormatContext *s)
 return 0;
 }
 
+static int init_playlist(HLSContext *c, struct playlist *pls)
+{
+AVInputFormat *in_fmt = NULL;
+int highest_cur_seq_no = 0;
+int ret;
+int i;
+
+if (!(pls->ctx = avformat_alloc_context())) {
+return AVERROR(ENOMEM);
+}
+
+if (pls->n_segments == 0)
+return 0;
+
+pls->needed = 1;
+pls->parent = c->ctx;
+
+/*
+ * If this is a live stream and this playlist looks like it is one segment
+ * behind, try to sync it up so that every substream starts at the same
+ * time position (so e.g. avformat_find_stream_info() will see packets from
+ * all active streams within the first few seconds). This is not very 
generic,
+ * though, as the sequence numbers are technically independent.
+ */
+highest_cur_seq_no = 0;
+for (i = 0; i < c->n_playlists; i++) {
+struct playlist *pls = c->playlists[i];
+if (pls->cur_seq_no > highest_cur_seq_no)
+highest_cur_seq_no = pls->cur_seq_no;
+}
+if (!pls->finished && pls->cur_seq_no == highest_cur_seq_no - 1 &&
+highest_cur_seq_no < pls->start_seq_no + pls->n_segments) {
+pls->cur_seq_no = highest_cur_seq_no;
+}
+
+pls->read_buffer = av_malloc(INITIAL_BUFFER_SIZE);
+if (!pls->read_buffer){
+ret = AVERROR(ENOMEM);
+avformat_free_context(pls->ctx);
+pls->ctx = NULL;
+return ret;
+}
+ffio_init_context(>pb, pls->read_buffer, INITIAL_BUFFER_SIZE, 0, pls,
+  read_data, NULL, NULL);
+pls->pb.seekable = 0;
+ret = av_probe_input_buffer(>pb, _fmt, pls->segments[0]->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(c->ctx, AV_LOG_ERROR, "Error when loading first segment 
'%s'\n", pls->segments[0]->url);
+av_free(pls->read_buffer);
+pls->read_buffer = NULL;
+avformat_free_context(pls->ctx);
+pls->ctx = NULL;
+return ret;
+}
+pls->ctx->pb   = >pb;
+pls->ctx->io_open  = nested_io_open;
+pls->ctx->flags   |= c->ctx->flags & ~AVFMT_FLAG_CUSTOM_IO;
+
+if ((ret = ff_copy_whiteblacklists(pls->ctx, c->ctx)) < 0)
+return ret;
+
+ret = avformat_open_input(>ctx, pls->segments[0]->url, in_fmt, NULL);
+if (ret < 0) {
+av_log(c->ctx, AV_LOG_ERROR, "Error opening playlist %s", 
pls->segments[0]->url);
+avformat_free_context(pls->ctx);
+pls->ctx = NULL;
+return ret;
+}
+
+if (pls->id3_deferred_extra && pls->ctx->nb_streams == 1) {
+ff_id3v2_parse_apic(pls->ctx, >id3_deferred_extra);
+avformat_queue_attached_pictures(pls->ctx);
+ff_id3v2_free_extra_meta(>id3_deferred_extra);
+pls->id3_deferred_extra = NULL;
+}
+
+if (pls->is_id3_timestamped == -1)
+av_log(c->ctx, AV_LOG_WARNING, "No expected HTTP requests have been 
made\n");
+
+/*
+ * For ID3 timestamped raw audio streams we need to detect the packet
+ * durations to calculate timestamps in 
fill_timing_for_id3_timestamped_stream(),
+ * but for other streams we can rely on our user calling 
avformat_find_stream_info()
+ * on us if they want to.
+ */
+if (pls->is_id3_timestamped) {
+ret = avformat_find_stream_info(pls->ctx, NULL);
+if (ret < 0) {
+avformat_free_context(pls->ctx);
+pls->ctx = NULL;
+return ret;
+}
+}
+
+pls->has_noheader_flag = !!(pls->ctx->ctx_flags & AVFMTCTX_NOHEADER);
+
+/* Create new AVStreams for each stream in this playlist */
+ret = update_streams_from_subdemuxer(c->ctx, pls);
+if (ret < 0) {
+avformat_free_context(pls->ctx);
+pls->ctx = NULL;
+return ret;
+}
+
+add_metadata_from_renditions(c->ctx, pls, AVMEDIA_TYPE_AUDIO);
+add_metadata_from_renditions(c->ctx, pls, AVMEDIA_TYPE_VIDEO);
+add_metadata_from_renditions(c->ctx, pls, AVMEDIA_TYPE_SUBTITLE);
+
+return 0;
+}
+
 static int hls_read_header(AVFormatContext *s)
 {
 void *u = (s->flags & 

[FFmpeg-devel] [PATCH] hls demuxer: add option to defer parsing of variants

2017-12-03 Thread Rainer Hochecker
I tried to implement what you requested
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] libavcodec/mediacodec: use AVMediaCodecDeviceContext hw_device_ctx if set

2017-12-03 Thread Mark Thompson
On 02/12/17 23:14, Aman Gupta wrote:
> From: Aman Gupta 
> 
> ---
>  libavcodec/mediacodecdec_common.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mediacodecdec_common.c 
> b/libavcodec/mediacodecdec_common.c
> index cb2f6ae5e5..e524ffe0e4 100644
> --- a/libavcodec/mediacodecdec_common.c
> +++ b/libavcodec/mediacodecdec_common.c
> @@ -24,6 +24,7 @@
>  #include 
>  
>  #include "libavutil/common.h"
> +#include "libavutil/hwcontext_mediacodec.h"
>  #include "libavutil/mem.h"
>  #include "libavutil/log.h"
>  #include "libavutil/pixfmt.h"
> @@ -475,8 +476,12 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx, 
> MediaCodecDecContext *s,
>  pix_fmt = ff_get_format(avctx, pix_fmts);
>  if (pix_fmt == AV_PIX_FMT_MEDIACODEC) {
>  AVMediaCodecContext *user_ctx = avctx->hwaccel_context;
> +AVMediaCodecDeviceContext *device_ctx = avctx->hw_device_ctx;

Er, no.  AVCodecContext.hw_device_ctx is an AVBufferRef containing an 
AVHWDeviceContext - you need to dereference through it to get the 
AVMediaCodecDeviceContext.

>  
> -if (user_ctx && user_ctx->surface) {
> +if (device_ctx && device_ctx->surface) {
> +s->surface = ff_mediacodec_surface_ref(device_ctx->surface, 
> avctx);
> +av_log(avctx, AV_LOG_INFO, "Using surface %p\n", s->surface);
> +} else if (user_ctx && user_ctx->surface) {
>  s->surface = ff_mediacodec_surface_ref(user_ctx->surface, avctx);
>  av_log(avctx, AV_LOG_INFO, "Using surface %p\n", s->surface);
>  }
> 

You want to add the hw-config metadata as well, I think.

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


Re: [FFmpeg-devel] [PATCH 1/2] libavutil/hwcontext: add AV_HWDEVICE_TYPE_MEDIACODEC

2017-12-03 Thread Mark Thompson
On 02/12/17 23:14, Aman Gupta wrote:
> From: Aman Gupta 
> 
> ---
>  libavutil/Makefile   |  2 ++
>  libavutil/hwcontext.c|  4 
>  libavutil/hwcontext.h|  1 +
>  libavutil/hwcontext_mediacodec.c | 50 
> 
>  libavutil/hwcontext_mediacodec.h | 34 +++
>  5 files changed, 91 insertions(+)
>  create mode 100644 libavutil/hwcontext_mediacodec.c
>  create mode 100644 libavutil/hwcontext_mediacodec.h
> 
> diff --git a/libavutil/Makefile b/libavutil/Makefile
> index 721784086c..6b12acea68 100644
> --- a/libavutil/Makefile
> +++ b/libavutil/Makefile
> @@ -166,6 +166,7 @@ OBJS-$(CONFIG_OPENCL)   += 
> hwcontext_opencl.o
>  OBJS-$(CONFIG_VAAPI)+= hwcontext_vaapi.o
>  OBJS-$(CONFIG_VIDEOTOOLBOX) += hwcontext_videotoolbox.o
>  OBJS-$(CONFIG_VDPAU)+= hwcontext_vdpau.o
> +OBJS-$(CONFIG_MEDIACODEC)   += hwcontext_mediacodec.o
>  
>  OBJS += $(COMPAT_OBJS:%=../compat/%)
>  
> @@ -181,6 +182,7 @@ SKIPHEADERS-$(CONFIG_OPENCL)   += 
> hwcontext_opencl.h
>  SKIPHEADERS-$(CONFIG_VAAPI)+= hwcontext_vaapi.h
>  SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += hwcontext_videotoolbox.h
>  SKIPHEADERS-$(CONFIG_VDPAU)+= hwcontext_vdpau.h
> +SKIPHEADERS-$(CONFIG_MEDIACODEC)   += hwcontext_mediacodec.h

Unnecessary, the header doesn't depend on anything.

>  SKIPHEADERS-$(HAVE_ATOMICS_GCC)+= atomic_gcc.h
>  SKIPHEADERS-$(HAVE_ATOMICS_SUNCC)  += atomic_suncc.h
>  SKIPHEADERS-$(HAVE_ATOMICS_WIN32)  += atomic_win32.h
> diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
> index f47158f811..31ac12807b 100644
> --- a/libavutil/hwcontext.c
> +++ b/libavutil/hwcontext.c
> @@ -56,6 +56,9 @@ static const HWContextType * const hw_table[] = {
>  #if CONFIG_VIDEOTOOLBOX
>  _hwcontext_type_videotoolbox,
>  #endif
> +#if CONFIG_MEDIACODEC
> +_hwcontext_type_mediacodec,
> +#endif
>  NULL,
>  };
>  
> @@ -69,6 +72,7 @@ static const char *const hw_type_names[] = {
>  [AV_HWDEVICE_TYPE_VAAPI]  = "vaapi",
>  [AV_HWDEVICE_TYPE_VDPAU]  = "vdpau",
>  [AV_HWDEVICE_TYPE_VIDEOTOOLBOX] = "videotoolbox",
> +[AV_HWDEVICE_TYPE_MEDIACODEC] = "mediacodec",
>  };
>  
>  enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name)
> diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
> index 8d27b987df..f5a4b62387 100644
> --- a/libavutil/hwcontext.h
> +++ b/libavutil/hwcontext.h
> @@ -35,6 +35,7 @@ enum AVHWDeviceType {
>  AV_HWDEVICE_TYPE_D3D11VA,
>  AV_HWDEVICE_TYPE_DRM,
>  AV_HWDEVICE_TYPE_OPENCL,
> +AV_HWDEVICE_TYPE_MEDIACODEC,
>  };
>  
>  typedef struct AVHWDeviceInternal AVHWDeviceInternal;
> diff --git a/libavutil/hwcontext_mediacodec.c 
> b/libavutil/hwcontext_mediacodec.c
> new file mode 100644
> index 00..b0d8993e15
> --- /dev/null
> +++ b/libavutil/hwcontext_mediacodec.c
> @@ -0,0 +1,50 @@
> +/*
> + * 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 "config.h"
> +
> +#include "buffer.h"
> +#include "common.h"
> +#include "hwcontext.h"
> +#include "hwcontext_internal.h"
> +#include "hwcontext_mediacodec.h"
> +
> +static int mc_device_create(AVHWDeviceContext *ctx, const char *device,
> +AVDictionary *opts, int flags)
> +{
> +if (device && device[0]) {
> +av_log(ctx, AV_LOG_ERROR, "Device selection unsupported.\n");
> +return AVERROR_UNKNOWN;
> +}
> +
> +return 0;
> +}
> +
> +const HWContextType ff_hwcontext_type_mediacodec = {
> +.type = AV_HWDEVICE_TYPE_MEDIACODEC,
> +.name = "mediacodec",
> +
> +.device_hwctx_size= sizeof(AVMediaCodecDeviceContext),
> +
> +.device_create= mc_device_create,
> +
> +.pix_fmts = (const enum AVPixelFormat[]){
> +AV_PIX_FMT_MEDIACODEC,
> +AV_PIX_FMT_NONE
> +},
> +};
> diff --git a/libavutil/hwcontext_mediacodec.h 
> b/libavutil/hwcontext_mediacodec.h
> new file mode 100644
> index 00..3d2c91d2f2
> --- /dev/null
> +++ b/libavutil/hwcontext_mediacodec.h
> @@ -0,0 +1,34 @@
> +/*
> + * This file is part of FFmpeg.
> + 

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

2017-12-03 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi   | 31 ++
 libavfilter/Makefile   |  1 +
 libavfilter/allfilters.c   |  1 +
 libavfilter/vf_setparams.c | 82 ++
 4 files changed, 115 insertions(+)
 create mode 100644 libavfilter/vf_setparams.c

diff --git a/doc/filters.texi b/doc/filters.texi
index f7c371592f..718263a608 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -18496,6 +18496,37 @@ asetpts=N/SR/TB
 
 @end itemize
 
+@section setrange
+
+Force color range for the output video frame.
+
+The @code{setrange} filter marks the color range property for the
+output frames. It does not change the input frame, but only sets the
+corresponding property, which affects how the frame is treated by
+following filters.
+
+The filter accepts the following options:
+
+@table @option
+
+@item range
+Available values are:
+
+@table @samp
+@item auto
+Keep the same color range property.
+
+@item unspecified, unknown
+Set the color range as unspecified.
+
+@item limited, tv, mpeg
+Set the color range as limited.
+
+@item full, pc, jpeg
+Set the color range as full.
+@end table
+@end table
+
 @section settb, asettb
 
 Set the timebase to use for the output frames timestamps.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 1c0cc1da80..6b06d57234 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -300,6 +300,7 @@ OBJS-$(CONFIG_SEPARATEFIELDS_FILTER) += 
vf_separatefields.o
 OBJS-$(CONFIG_SETDAR_FILTER) += vf_aspect.o
 OBJS-$(CONFIG_SETFIELD_FILTER)   += vf_setfield.o
 OBJS-$(CONFIG_SETPTS_FILTER) += setpts.o
+OBJS-$(CONFIG_SETRANGE_FILTER)   += vf_setparams.o
 OBJS-$(CONFIG_SETSAR_FILTER) += vf_aspect.o
 OBJS-$(CONFIG_SETTB_FILTER)  += settb.o
 OBJS-$(CONFIG_SHOWINFO_FILTER)   += vf_showinfo.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index fc212e58db..707faad777 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -309,6 +309,7 @@ static void register_all(void)
 REGISTER_FILTER(SETDAR, setdar, vf);
 REGISTER_FILTER(SETFIELD,   setfield,   vf);
 REGISTER_FILTER(SETPTS, setpts, vf);
+REGISTER_FILTER(SETRANGE,   setrange,   vf);
 REGISTER_FILTER(SETSAR, setsar, vf);
 REGISTER_FILTER(SETTB,  settb,  vf);
 REGISTER_FILTER(SHOWINFO,   showinfo,   vf);
diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c
new file mode 100644
index 00..7668bd4cdf
--- /dev/null
+++ b/libavfilter/vf_setparams.c
@@ -0,0 +1,82 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/pixfmt.h"
+#include "libavutil/opt.h"
+#include "avfilter.h"
+#include "internal.h"
+#include "video.h"
+
+typedef struct SetParamsContext {
+const AVClass *class;
+int color_range;
+} SetParamsContext;
+
+#define OFFSET(x) offsetof(SetParamsContext, x)
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
+
+static const AVOption setrange_options[] = {
+{"range", "select color range", OFFSET(color_range), AV_OPT_TYPE_INT, 
{.i64=-1},-1, AVCOL_RANGE_NB-1, FLAGS, "range"},
+{"auto",  "keep the same color range",   0, AV_OPT_TYPE_CONST, {.i64=-1},  
 0, 0, FLAGS, "range"},
+{"unspecified",  NULL,   0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_RANGE_UNSPECIFIED},  0, 0, FLAGS, "range"},
+{"unknown",  NULL,   0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_RANGE_UNSPECIFIED},  0, 0, FLAGS, "range"},
+{"limited",  NULL,   0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_RANGE_MPEG}, 0, 0, FLAGS, "range"},
+{"tv",   NULL,   0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_RANGE_MPEG}, 0, 0, FLAGS, "range"},
+{"mpeg", NULL,   0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_RANGE_MPEG}, 0, 0, FLAGS, "range"},
+{"full", NULL,   0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_RANGE_JPEG}, 0, 0, FLAGS, "range"},
+{"pc",   NULL,   0, AV_OPT_TYPE_CONST, 

Re: [FFmpeg-devel] adding bluetooth SBC codec

2017-12-03 Thread Rostislav Pehlivanov
On 5 November 2017 at 23:35, Aurelien Jacobs  wrote:

> Hello everyone,
>
> Long time no see !
>
> I'm glad to see ffmpeg still strong.
>
> I'm curently playing with bluetooth audio (A2DP) and I wanted to
> use lavc to do the encoding/decoding, so I added some codecs that
> I need to ffmpeg.
>
> Here is the result for the SBC codec.
>
> [PATCH 1/3] sbc: implement SBC codec (low-complexity subband codec)
> [PATCH 2/3] sbc: add parser for SBC
> [PATCH 3/3] sbc: add raw muxer and demuxer for SBC
>
> Note that this is based on libsbc, and that I have a repository with full
> history of the modifications I applied on top of libsbc:
>   https://gitlab.com/aurelj/ffmpeg/commits/bluetooth_sbc
> If anyone would prefer me to submit all the patches with full history
> on this mailing list, just say so. (I just think the squashed
> version makes more sense to review)
>
> Thanks everyone for all your efforts to keep ffmpeg going.
> --
> Aurel
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


Ping, there isn't much to do to this patch, just what was mentioned plus
some of the stuff you did for the aptx patchset.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat: add NSP demuxer

2017-12-03 Thread Paul B Mahol
On 12/3/17, Carl Eugen Hoyos  wrote:
> 2017-12-01 17:26 GMT+01:00 Paul B Mahol :
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavformat/Makefile |   1 +
>>  libavformat/allformats.c |   1 +
>>  libavformat/nspdec.c | 101
>> +++
>>  3 files changed, 103 insertions(+)
>>  create mode 100644 libavformat/nspdec.c
>>
>> diff --git a/libavformat/Makefile b/libavformat/Makefile
>> index 4bffdf2205..734b703862 100644
>> --- a/libavformat/Makefile
>> +++ b/libavformat/Makefile
>> @@ -331,6 +331,7 @@ OBJS-$(CONFIG_MXF_MUXER) += mxfenc.o
>> mxf.o audiointerleave.o
>>  OBJS-$(CONFIG_MXG_DEMUXER)   += mxg.o
>>  OBJS-$(CONFIG_NC_DEMUXER)+= ncdec.o
>>  OBJS-$(CONFIG_NISTSPHERE_DEMUXER)+= nistspheredec.o pcm.o
>> +OBJS-$(CONFIG_NSP_DEMUXER)   += nspdec.o
>>  OBJS-$(CONFIG_NSV_DEMUXER)   += nsvdec.o
>>  OBJS-$(CONFIG_NULL_MUXER)+= nullenc.o
>>  OBJS-$(CONFIG_NUT_DEMUXER)   += nutdec.o nut.o isom.o
>> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
>> index 9213af9301..6a9b9883c9 100644
>> --- a/libavformat/allformats.c
>> +++ b/libavformat/allformats.c
>> @@ -224,6 +224,7 @@ static void register_all(void)
>>  REGISTER_DEMUXER (MXG,  mxg);
>>  REGISTER_DEMUXER (NC,   nc);
>>  REGISTER_DEMUXER (NISTSPHERE,   nistsphere);
>> +REGISTER_DEMUXER (NSP,  nsp);
>>  REGISTER_DEMUXER (NSV,  nsv);
>>  REGISTER_MUXER   (NULL, null);
>>  REGISTER_MUXDEMUX(NUT,  nut);
>> diff --git a/libavformat/nspdec.c b/libavformat/nspdec.c
>> new file mode 100644
>> index 00..d2ff779732
>> --- /dev/null
>> +++ b/libavformat/nspdec.c
>> @@ -0,0 +1,101 @@
>> +/*
>> + * NSP demuxer
>> + * Copyright (c) 2017 Paul B Mahol
>> + *
>> + * This file is part of FFmpeg.
>> + *
>> + * FFmpeg is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU Lesser General Public
>> + * License as published by the Free Software Foundation; either
>> + * version 2.1 of the License, or (at your option) any later version.
>> + *
>> + * FFmpeg is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with FFmpeg; if not, write to the Free Software
>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
>> 02110-1301 USA
>> + */
>> +
>> +#include "libavutil/avstring.h"
>> +#include "libavutil/intreadwrite.h"
>> +#include "avformat.h"
>> +#include "internal.h"
>> +#include "pcm.h"
>> +
>> +static int nsp_probe(AVProbeData *p)
>> +{
>> +if (AV_RB32(p->buf) == AV_RB32("FORM") &&
>> +AV_RB32(p->buf + 4) == AV_RB32("DS16"))
>> +return AVPROBE_SCORE_MAX;
>> +return 0;
>> +}
>> +
>> +static int nsp_read_header(AVFormatContext *s)
>> +{
>> +int rate = 0, channels = 0;
>> +uint32_t chunk, size;
>> +AVStream *st;
>> +int64_t pos;
>> +
>> +avio_skip(s->pb, 12);
>> +st = avformat_new_stream(s, NULL);
>> +if (!st)
>> +return AVERROR(ENOMEM);
>> +
>> +while (!avio_feof(s->pb)) {
>> +chunk = avio_rb32(s->pb);
>
> Not codec_tag?

No.

>
>> +size  = avio_rl32(s->pb);
>> +pos   = avio_tell(s->pb);
>> +
>> +if (chunk == MKBETAG('H', 'D', 'R', '8') ||
>> +chunk == MKBETAG('H', 'E', 'D', 'R')) {
>
> It's your code but I suspect a switch() makes this
> more readable.

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