[FFmpeg-devel] [PATCH 1/2] build: Make API documentation depend on config.mak

2016-07-29 Thread Timothy Gu
The Doxygen command is generated from the list of installed headers,
which may change per configuration (e.g. `--enable-gpl` results in
libpostproc to be built and installed).
---
 doc/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/Makefile b/doc/Makefile
index 4a77aac..c90cb1a 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -125,7 +125,7 @@ $(DOC_EXAMPLES:%$(EXESUF)=%.o): | doc/examples
 OBJDIRS += doc/examples
 
 DOXY_INPUT  = $(INSTHEADERS) $(DOC_EXAMPLES:%$(EXESUF)=%.c) 
$(LIB_EXAMPLES:%$(EXESUF)=%.c)
-DOXY_INPUT_DEPS = $(addprefix $(SRC_PATH)/, $(DOXY_INPUT))
+DOXY_INPUT_DEPS = $(addprefix $(SRC_PATH)/, $(DOXY_INPUT)) config.mak
 
 doc/doxy/html: TAG = DOXY
 doc/doxy/html: $(SRC_PATH)/doc/Doxyfile $(SRC_PATH)/doc/doxy-wrapper.sh 
$(DOXY_INPUT_DEPS)
-- 
2.1.4

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


[FFmpeg-devel] [PATCH 2/2] mem: Make function attribute usage consisten

2016-07-29 Thread Timothy Gu
---
 libavutil/mem.h | 42 +++---
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/libavutil/mem.h b/libavutil/mem.h
index 2f53b47..ca936e8 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -80,7 +80,8 @@
  * be allocated.
  * @see av_mallocz()
  */
-void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1);
+av_malloc_attrib
+void *av_malloc(size_t size) av_alloc_size(1);
 
 /**
  * Allocate a block of size * nmemb bytes with av_malloc().
@@ -90,7 +91,8 @@ void *av_malloc(size_t size) av_malloc_attrib 
av_alloc_size(1);
  * be allocated.
  * @see av_malloc()
  */
-av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t 
size)
+av_malloc_attrib
+static inline void *av_malloc_array(size_t nmemb, size_t size) 
av_alloc_size(1, 2)
 {
 if (!size || nmemb >= INT_MAX / size)
 return NULL;
@@ -115,6 +117,7 @@ av_alloc_size(1, 2) static inline void 
*av_malloc_array(size_t nmemb, size_t siz
  *  some libc implementations.
  * @see av_fast_realloc()
  */
+av_malloc_attrib
 void *av_realloc(void *ptr, size_t size) av_alloc_size(2);
 
 /**
@@ -125,7 +128,8 @@ void *av_realloc(void *ptr, size_t size) av_alloc_size(2);
  * - It frees the input block in case of failure, thus avoiding the memory
  *   leak with the classic "buf = realloc(buf); if (!buf) return -1;".
  */
-void *av_realloc_f(void *ptr, size_t nelem, size_t elsize);
+av_malloc_attrib
+void *av_realloc_f(void *ptr, size_t nelem, size_t elsize) av_alloc_size(2, 3);
 
 /**
  * Allocate or reallocate a block of memory.
@@ -145,7 +149,7 @@ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize);
  *  some libc implementations.
  */
 av_warn_unused_result
-int av_reallocp(void *ptr, size_t size);
+int av_reallocp(void *ptr, size_t size) av_alloc_size(2);
 
 /**
  * Allocate or reallocate an array.
@@ -164,7 +168,8 @@ int av_reallocp(void *ptr, size_t size);
  *  The situation is undefined according to POSIX and may crash with
  *  some libc implementations.
  */
-av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t 
size);
+av_malloc_attrib
+void *av_realloc_array(void *ptr, size_t nmemb, size_t size) av_alloc_size(2, 
3);
 
 /**
  * Allocate or reallocate an array through a pointer to a pointer.
@@ -183,7 +188,7 @@ av_alloc_size(2, 3) void *av_realloc_array(void *ptr, 
size_t nmemb, size_t size)
  *  The situation is undefined according to POSIX and may crash with
  *  some libc implementations.
  */
-av_alloc_size(2, 3) int av_reallocp_array(void *ptr, size_t nmemb, size_t 
size);
+int av_reallocp_array(void *ptr, size_t nmemb, size_t size) av_alloc_size(2, 
3);
 
 /**
  * Free a memory block which has been allocated with av_malloc(z)() or
@@ -203,7 +208,8 @@ void av_free(void *ptr);
  * @return Pointer to the allocated block, NULL if it cannot be allocated.
  * @see av_malloc()
  */
-void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1);
+av_malloc_attrib
+void *av_mallocz(size_t size) av_alloc_size(1);
 
 /**
  * Allocate a block of nmemb * size bytes with alignment suitable for all
@@ -215,7 +221,8 @@ void *av_mallocz(size_t size) av_malloc_attrib 
av_alloc_size(1);
  * @param size
  * @return Pointer to the allocated block, NULL if it cannot be allocated.
  */
-void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib;
+av_malloc_attrib
+void *av_calloc(size_t nmemb, size_t size) av_alloc_size(1, 2);
 
 /**
  * Allocate a block of size * nmemb bytes with av_mallocz().
@@ -226,7 +233,8 @@ void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib;
  * @see av_mallocz()
  * @see av_malloc_array()
  */
-av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t 
size)
+av_malloc_attrib
+static inline void *av_mallocz_array(size_t nmemb, size_t size) 
av_alloc_size(1, 2)
 {
 if (!size || nmemb >= INT_MAX / size)
 return NULL;
@@ -239,7 +247,8 @@ av_alloc_size(1, 2) static inline void 
*av_mallocz_array(size_t nmemb, size_t si
  * @return Pointer to a newly-allocated string containing a
  * copy of s or NULL if the string cannot be allocated.
  */
-char *av_strdup(const char *s) av_malloc_attrib;
+av_malloc_attrib
+char *av_strdup(const char *s);
 
 /**
  * Duplicate a substring of the string s.
@@ -249,7 +258,8 @@ char *av_strdup(const char *s) av_malloc_attrib;
  * @return Pointer to a newly-allocated string containing a
  * copy of s or NULL if the string cannot be allocated.
  */
-char *av_strndup(const char *s, size_t len) av_malloc_attrib;
+av_malloc_attrib
+char *av_strndup(const char *s, size_t len) av_alloc_size(2);
 
 /**
  * Duplicate the buffer p.
@@ -257,7 +267,8 @@ char *av_strndup(const char *s, size_t len) 
av_malloc_attrib;
  * @return Pointer to a newly allocated buffer containing a
  * copy of p or NULL if the buffer cannot be allocated.
  */
-void *av_memdup(const void *p, size_t size);
+av_malloc_attrib
+void *av_memdup(const void 

[FFmpeg-devel] [PATCH] dynarray: Change AV_ to FF_ for AV_DYNARRAY_ADD

2016-07-29 Thread Timothy Gu
The header is not installed and the macro isn't used outside libavutil,
so it is obviously privat to libavutil. Make the name reflect that.
---
 libavutil/dynarray.h | 2 +-
 libavutil/mem.c  | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavutil/dynarray.h b/libavutil/dynarray.h
index 4947d93..034a9fe 100644
--- a/libavutil/dynarray.h
+++ b/libavutil/dynarray.h
@@ -42,7 +42,7 @@
  * array and size are not changed; the statement can end
  * with a return or a goto
  */
-#define AV_DYNARRAY_ADD(av_size_max, av_elt_size, av_array, av_size, \
+#define FF_DYNARRAY_ADD(av_size_max, av_elt_size, av_array, av_size, \
 av_success, av_failure) \
 do { \
 size_t av_size_new = (av_size); \
diff --git a/libavutil/mem.c b/libavutil/mem.c
index 809ec01..1a8fc21 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -312,7 +312,7 @@ int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void 
*elem)
 void **tab;
 memcpy(, tab_ptr, sizeof(tab));
 
-AV_DYNARRAY_ADD(INT_MAX, sizeof(*tab), tab, *nb_ptr, {
+FF_DYNARRAY_ADD(INT_MAX, sizeof(*tab), tab, *nb_ptr, {
 tab[*nb_ptr] = elem;
 memcpy(tab_ptr, , sizeof(tab));
 }, {
@@ -326,7 +326,7 @@ void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem)
 void **tab;
 memcpy(, tab_ptr, sizeof(tab));
 
-AV_DYNARRAY_ADD(INT_MAX, sizeof(*tab), tab, *nb_ptr, {
+FF_DYNARRAY_ADD(INT_MAX, sizeof(*tab), tab, *nb_ptr, {
 tab[*nb_ptr] = elem;
 memcpy(tab_ptr, , sizeof(tab));
 }, {
@@ -340,7 +340,7 @@ void *av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t 
elem_size,
 {
 uint8_t *tab_elem_data = NULL;
 
-AV_DYNARRAY_ADD(INT_MAX, elem_size, *tab_ptr, *nb_ptr, {
+FF_DYNARRAY_ADD(INT_MAX, elem_size, *tab_ptr, *nb_ptr, {
 tab_elem_data = (uint8_t *)*tab_ptr + (*nb_ptr) * elem_size;
 if (elem_data)
 memcpy(tab_elem_data, elem_data, elem_size);
-- 
2.1.4

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


Re: [FFmpeg-devel] [PATCH] libavformat/matroskadec: Add test for seeking with codec delay.

2016-07-29 Thread Michael Niedermayer
On Fri, Jul 29, 2016 at 12:54:13AM +0200, Michael Niedermayer wrote:
> On Wed, Jul 27, 2016 at 06:33:30PM -0700, chcunning...@chromium.org wrote:
> > From: Chris Cunningham 
> > 
> > Also cleanup parens for the skip_to_timecode check.
> > ---
> >  libavformat/matroskadec.c  |  2 +-
> >  tests/fate/seek.mak|  3 +++
> >  tests/ref/seek/mkv-codec-delay | 48 
> > ++
> >  3 files changed, 52 insertions(+), 1 deletion(-)
> >  create mode 100644 tests/ref/seek/mkv-codec-delay
> 
> LGTM
> ill apply tomorrow unless i forget in which case ill apply when someone
> reminds me

applied

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates


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 audio clipping problem in dynaudnorm

2016-07-29 Thread andyndeanna
Paul,

I didn't, but that makes sense.

Thanks,
Andy

On Friday, July 29, 2016, Paul B Mahol  wrote:

> On 7/27/16, andyndeanna > wrote:
> > Hello,
> >
> > See attached patch to fix a clipping problem with dynaudnorm when the
> first
> > frame contains silence.  I implemented the fix by adding a boundary mode.
> > It could also be done by changing how b=1 works.
> >
> > Thanks,
> > Andy
> >
>
> Have you considered sending this directly to creator of this code?
> ___
> 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 3/7] af_hdcd: Improve error detection logging

2016-07-29 Thread Burt P
* Moves the filter context member out of state and into HDCDContext
* More useful information when an error is detected
* Gives a location near where the error was detected

Signed-off-by: Burt P 
---
 libavfilter/af_hdcd.c | 34 +++---
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c
index 8498b35..6040400 100644
--- a/libavfilter/af_hdcd.c
+++ b/libavfilter/af_hdcd.c
@@ -849,8 +849,6 @@ typedef struct {
 /* occurences of code detect timer expiring without detecting
  * a code. -1 for timer never set. */
 int count_sustain_expired;
-
-AVFilterContext *fctx; /* filter context for logging errors */
 } hdcd_state_t;
 
 typedef enum {
@@ -869,6 +867,9 @@ typedef struct HDCDContext {
 const AVClass *class;
 hdcd_state_t state[2];
 
+AVFilterContext *fctx; /* filter context for logging errors */
+int sample_count;  /* used in error logging */
+
 /* User information/stats */
 int hdcd_detected;
 int det_errors;/* detectable errors */
@@ -923,7 +924,7 @@ static void hdcd_update_info(hdcd_state_t *state)
 state->max_gain = FFMAX(state->max_gain, (state->control & 15));
 }
 
-static int hdcd_integrate(hdcd_state_t *state, int *flag, const int32_t 
*samples, int count, int stride)
+static int hdcd_integrate(HDCDContext *ctx, hdcd_state_t *state, int *flag, 
const int32_t *samples, int count, int stride)
 {
 uint32_t bits = 0;
 int result = FFMIN(state->readahead, count);
@@ -954,8 +955,8 @@ static int hdcd_integrate(hdcd_state_t *state, int *flag, 
const int32_t *samples
 } else {
 /* one of bits 3, 6, or 7 was not 0 */
 state->code_counterA_almost++;
-av_log(state->fctx, AV_LOG_VERBOSE,
-"hdcd error: Control A almost: 0x%08x\n", bits);
+av_log(ctx->fctx, AV_LOG_VERBOSE,
+"hdcd error: Control A almost: 0x%02x near %d\n", bits & 
0xff, ctx->sample_count);
 }
 } else if ((bits & 0xa006) == 0xa006) {
 /* B: 8-bit code, 8-bit XOR check */
@@ -968,14 +969,14 @@ static int hdcd_integrate(hdcd_state_t *state, int *flag, 
const int32_t *samples
 } else {
 /* XOR check failed */
 state->code_counterB_checkfails++;
-av_log(state->fctx, AV_LOG_VERBOSE,
-"hdcd error: Control B check failed: 0x%08x\n", bits);
+av_log(ctx->fctx, AV_LOG_VERBOSE,
+   "hdcd error: Control B check failed: 0x%04x (0x%02x vs 
0x%02x) near %d\n", bits & 0x, (bits & 0xff00) >> 8, ~bits & 0xff, 
ctx->sample_count);
 }
 } else {
 /* told to look for a code, but didn't match one */
 state->code_counterC_unmatched++;
-av_log(state->fctx, AV_LOG_VERBOSE,
-"hdcd error: Unmatched code: 0x%08x\n", bits);
+av_log(ctx->fctx, AV_LOG_VERBOSE,
+   "hdcd error: Unmatched code: 0x%08x near %d\n", bits, 
ctx->sample_count);
 }
 if (*flag) hdcd_update_info(state);
 state->arg = 0;
@@ -1002,7 +1003,7 @@ static void hdcd_sustain_reset(hdcd_state_t *state)
 state->count_sustain_expired = 0;
 }
 
-static int hdcd_scan(hdcd_state_t *state, const int32_t *samples, int max, int 
stride)
+static int hdcd_scan(HDCDContext *ctx, hdcd_state_t *state, const int32_t 
*samples, int max, int stride)
 {
 int cdt_active = 0;
 /* code detect timer */
@@ -1018,7 +1019,7 @@ static int hdcd_scan(hdcd_state_t *state, const int32_t 
*samples, int max, int s
 result = 0;
 while (result < max) {
 int flag;
-int consumed = hdcd_integrate(state, , samples, max - result, 
stride);
+int consumed = hdcd_integrate(ctx, state, , samples, max - 
result, stride);
 result += consumed;
 if (flag > 0) {
 /* reset timer if code detected in channel */
@@ -1092,7 +1093,7 @@ static int hdcd_envelope(int32_t *samples, int count, int 
stride, int gain, int
 return gain;
 }
 
-static void hdcd_process(hdcd_state_t *state, int32_t *samples, int count, int 
stride)
+static void hdcd_process(HDCDContext *ctx, hdcd_state_t *state, int32_t 
*samples, int count, int stride)
 {
 int32_t *samples_end = samples + count * stride;
 int gain = state->running_gain;
@@ -1105,7 +1106,7 @@ static void hdcd_process(hdcd_state_t *state, int32_t 
*samples, int count, int s
 int run;
 
 av_assert0(samples + lead * stride + stride * (count - lead) <= 
samples_end);
-run = hdcd_scan(state, samples + lead * stride, count - lead, stride) 
+ lead;
+run = hdcd_scan(ctx, state, samples + lead * stride, count - lead, 
stride) + lead;
 envelope_run = run - 1;
 
 av_assert0(samples + envelope_run * stride <= samples_end);
@@ -1160,7 +1161,7 

[FFmpeg-devel] [PATCH 4/7] af_hdcd: add force_pe filter option

2016-07-29 Thread Burt P
Used to attempt replication of some results from
http://www.audiomisc.co.uk/HFN/HDCD/Examined.html
May not be generally useful, defaults to off.

Signed-off-by: Burt P 
---
 libavfilter/af_hdcd.c | 26 ++
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c
index 6040400..aeb65eb 100644
--- a/libavfilter/af_hdcd.c
+++ b/libavfilter/af_hdcd.c
@@ -867,6 +867,12 @@ typedef struct HDCDContext {
 const AVClass *class;
 hdcd_state_t state[2];
 
+/* always extend peaks above -3dBFS even if PE isn't signaled
+ * -af hdcd=force_pe=0 for off
+ * -af hdcd=force_pe=1 for on
+ * default is off */
+int force_pe;
+
 AVFilterContext *fctx; /* filter context for logging errors */
 int sample_count;  /* used in error logging */
 
@@ -878,7 +884,10 @@ typedef struct HDCDContext {
 float max_gain_adjustment; /* in dB, expected in the range -6.0 to 0.0 */
 } HDCDContext;
 
+#define OFFSET(x) offsetof(HDCDContext, x)
 static const AVOption hdcd_options[] = {
+{ "force_pe", "Always extend peaks above -3dBFS even when PE is not 
signaled.",
+OFFSET(force_pe), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, 0 },
  {NULL}
 };
 
@@ -1093,14 +1102,21 @@ static int hdcd_envelope(int32_t *samples, int count, 
int stride, int gain, int
 return gain;
 }
 
+/* extract fields from control code */
+static void hdcd_control(HDCDContext *ctx, hdcd_state_t *state, int 
*peak_extend, int *target_gain)
+{
+*peak_extend = (ctx->force_pe || state->control & 16);
+*target_gain = (state->control & 15) << 7;
+}
+
 static void hdcd_process(HDCDContext *ctx, hdcd_state_t *state, int32_t 
*samples, int count, int stride)
 {
 int32_t *samples_end = samples + count * stride;
 int gain = state->running_gain;
-int peak_extend = (state->control & 16);
-int target_gain = (state->control & 15) << 7;
+int peak_extend, target_gain;
 int lead = 0;
 
+hdcd_control(ctx, state, _extend, _gain);
 while (count > lead) {
 int envelope_run;
 int run;
@@ -1115,8 +1131,7 @@ static void hdcd_process(HDCDContext *ctx, hdcd_state_t 
*state, int32_t *samples
 samples += envelope_run * stride;
 count -= envelope_run;
 lead = run - envelope_run;
-peak_extend = (state->control & 16);
-target_gain = (state->control & 15) << 7;
+hdcd_control(ctx, state, _extend, _gain);
 }
 if (lead > 0) {
 av_assert0(samples + lead * stride <= samples_end);
@@ -1283,6 +1298,9 @@ static av_cold int init(AVFilterContext *ctx)
 hdcd_reset(>state[c], 44100);
 }
 
+av_log(ctx, AV_LOG_VERBOSE, "Force PE: %s\n",
+(s->force_pe) ? "on" : "off");
+
 return 0;
 }
 
-- 
2.7.4

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


[FFmpeg-devel] [PATCH 2/7] af_hdcd: give cdt expired counter a value for never set

2016-07-29 Thread Burt P
The counter is now -1 if the code detect timer was never set,
and 0 if it was set but never expired.

Signed-off-by: Burt P 
---
 libavfilter/af_hdcd.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c
index b860077..8498b35 100644
--- a/libavfilter/af_hdcd.c
+++ b/libavfilter/af_hdcd.c
@@ -846,7 +846,9 @@ typedef struct {
  * steps of 0.5, but no value below -6.0 dB should appear. */
 int gain_counts[16]; /* for cursiosity, mostly */
 int max_gain;
-int count_sustain_expired;/* occurences of code detect timer expiring 
without detecting a code */
+/* occurences of code detect timer expiring without detecting
+ * a code. -1 for timer never set. */
+int count_sustain_expired;
 
 AVFilterContext *fctx; /* filter context for logging errors */
 } hdcd_state_t;
@@ -909,7 +911,7 @@ static void hdcd_reset(hdcd_state_t *state, unsigned rate)
 for(i = 0; i < 16; i++) state->gain_counts[i] = 0;
 state->max_gain = 0;
 
-state->count_sustain_expired = 0;
+state->count_sustain_expired = -1;
 }
 
 /* update the user info/counters */
@@ -991,6 +993,15 @@ static int hdcd_integrate(hdcd_state_t *state, int *flag, 
const int32_t *samples
 return result;
 }
 
+static void hdcd_sustain_reset(hdcd_state_t *state)
+{
+state->sustain = state->sustain_reset;
+/* if this is the first reset then change
+ * from never set, to never expired */
+if (state->count_sustain_expired == -1)
+state->count_sustain_expired = 0;
+}
+
 static int hdcd_scan(hdcd_state_t *state, const int32_t *samples, int max, int 
stride)
 {
 int cdt_active = 0;
@@ -1011,7 +1022,7 @@ static int hdcd_scan(hdcd_state_t *state, const int32_t 
*samples, int max, int s
 result += consumed;
 if (flag > 0) {
 /* reset timer if code detected in channel */
-state->sustain = state->sustain_reset;
+hdcd_sustain_reset(state);
 break;
 }
 samples += consumed * stride;
-- 
2.7.4

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


[FFmpeg-devel] [PATCH 1/7] af_hdcd: fix a minor annoyance

2016-07-29 Thread Burt P
Signed-off-by: Burt P 
---
 libavfilter/af_hdcd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c
index 6f3eb1e..b860077 100644
--- a/libavfilter/af_hdcd.c
+++ b/libavfilter/af_hdcd.c
@@ -23,12 +23,12 @@
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ */
 
 /*
   Original code reverse engineered from HDCD decoder library by Christopher 
Key,
   which was likely reverse engineered from Windows Media Player.
-*/
+ */
 
 /*
   HDCD is High Definition Compatible Digital
-- 
2.7.4

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


[FFmpeg-devel] [PATCH 6/7] af_hdcd: Process stereo channels together, fix #5727

2016-07-29 Thread Burt P
Issue #5727: gain adjustment should only be applied if matching
gain value from a valid packet in both channels. The existing functions process
each channel separately, so it was not possible.

* New versions of hdcd_process(), hdcd_scan(), hdcd_integrate() named
  hdcd_*_stereo() that process both channels together.
* target_gain applied will be the last matching target_gain.
* The old single channel functions remain as an option. They can be
  used by: -af hdcd=process_stereo=0.

Signed-off-by: Burt P 
---
 libavfilter/af_hdcd.c | 287 +++---
 1 file changed, 250 insertions(+), 37 deletions(-)

diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c
index 902827e..d46c7bc 100644
--- a/libavfilter/af_hdcd.c
+++ b/libavfilter/af_hdcd.c
@@ -863,10 +863,22 @@ const char* pe_str[] = {
 "enabled permanently"
 };
 
+#define HDCD_PROCESS_STEREO_DEFAULT 1
+#define HDCD_MAX_CHANNELS 2
+
+/* convert to float from 4-bit (3.1) fixed-point
+ * the always-negative value is stored positive, so make it negative */
+#define GAINTOFLOAT(g) (g) ? -(float)(g>>1) - ((g & 1) ? 0.5 : 0.0) : 0.0
+
 typedef struct HDCDContext {
 const AVClass *class;
-hdcd_state_t state[2];
+hdcd_state_t state[HDCD_MAX_CHANNELS];
 
+/* use hdcd_*_stereo() functions to process both channels together.
+ * -af hdcd=process_stereo=0 for off
+ * -af hdcd=process_stereo=1 for on
+ * default is HDCD_PROCESS_STEREO_DEFAULT */
+int process_stereo;
 /* always extend peaks above -3dBFS even if PE isn't signaled
  * -af hdcd=force_pe=0 for off
  * -af hdcd=force_pe=1 for on
@@ -875,6 +887,7 @@ typedef struct HDCDContext {
 
 AVFilterContext *fctx; /* filter context for logging errors */
 int sample_count;  /* used in error logging */
+int val_target_gain;   /* last matching target_gain in both channels */
 
 /* User information/stats */
 int hdcd_detected;
@@ -886,9 +899,11 @@ typedef struct HDCDContext {
 
 #define OFFSET(x) offsetof(HDCDContext, x)
 static const AVOption hdcd_options[] = {
+{ "process_stereo", "Process stereo channels together. Only apply 
target_gain when both channels match.",
+OFFSET(process_stereo), AV_OPT_TYPE_INT, { .i64 = 
HDCD_PROCESS_STEREO_DEFAULT }, 0, 1, 0 },
 { "force_pe", "Always extend peaks above -3dBFS even when PE is not 
signaled.",
 OFFSET(force_pe), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, 0 },
- {NULL}
+{NULL}
 };
 
 AVFILTER_DEFINE_CLASS(hdcd);
@@ -915,12 +930,10 @@ static void hdcd_reset(hdcd_state_t *state, unsigned rate)
 state->code_counterB_checkfails = 0;
 state->code_counterC = 0;
 state->code_counterC_unmatched = 0;
-
 state->count_peak_extend = 0;
 state->count_transient_filter = 0;
 for(i = 0; i < 16; i++) state->gain_counts[i] = 0;
 state->max_gain = 0;
-
 state->count_sustain_expired = -1;
 }
 
@@ -1037,6 +1050,76 @@ static int hdcd_integrate(HDCDContext *ctx, hdcd_state_t 
*state, int *flag, cons
 return result;
 }
 
+static int hdcd_integrate_stereo(HDCDContext *ctx, int *flag, const int32_t 
*samples, int count)
+{
+uint32_t bits[2] = {0, 0};
+int result;
+int i;
+*flag = 0;
+
+/* result = min(count, s0ra, s1ra) */
+result = FFMIN(ctx->state[0].readahead, count);
+result = FFMIN(ctx->state[1].readahead, result);
+
+for (i = result - 1; i >= 0; i--) {
+bits[0] |= (*(samples++) & 1) << i;
+bits[1] |= (*(samples++) & 1) << i;
+}
+
+for (i = 0; i < 2; i++) {
+ctx->state[i].window = (ctx->state[i].window << result) | bits[i];
+ctx->state[i].readahead -= result;
+
+if (ctx->state[i].readahead == 0) {
+uint32_t wbits = (ctx->state[i].window ^ ctx->state[i].window >> 5 
^ ctx->state[i].window >> 23);
+if (ctx->state[i].arg) {
+switch (hdcd_code(wbits, >state[i].control)) {
+case HDCD_CODE_A:
+*flag |= i+1;
+ctx->state[i].code_counterA++;
+break;
+case HDCD_CODE_B:
+*flag |= i+1;
+ctx->state[i].code_counterB++;
+break;
+case HDCD_CODE_A_ALMOST:
+ctx->state[i].code_counterA_almost++;
+av_log(ctx->fctx, AV_LOG_VERBOSE,
+"hdcd error: Control A almost: 0x%02x near %d\n", 
wbits & 0xff, ctx->sample_count);
+break;
+case HDCD_CODE_B_CHECKFAIL:
+ctx->state[i].code_counterB_checkfails++;
+av_log(ctx->fctx, AV_LOG_VERBOSE,
+"hdcd error: Control B check failed: 0x%04x 
(0x%02x vs 0x%02x) near %d\n", wbits & 0x, (wbits & 0xff00) >> 8, ~wbits & 
0xff, ctx->sample_count);
+break;
+ 

[FFmpeg-devel] [PATCH 0/7] fix(v2) for #5727 split up, plus other things

2016-07-29 Thread Burt P
Here is a set with the earlier patch split into smaller patches.
Added to the old version is hdcd_control_stereo() that logs 
information about the mismatched target_gain so that problem samples
can be found more easily.

Also, a patch for warning about problems in the AVFilterLink chain.

Thanks for comments.

--
Burt

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


[FFmpeg-devel] [PATCH] Fix null dereferences in the qsv decoder

2016-07-29 Thread Yuli Khodorkovskiy
This patch fixes the h264_qsv decoder issues mentioned
in https://ffmpeg.zeranoe.com/forum/viewtopic.php?t=2962.

The patch may be tested by specifying h264_qsv as the decoder to ffplay
for an h264 encoded file.

ffplay -vcodec h264_qsv foo.mts

Signed-off-by: Yuli Khodorkovskiy 
---
 libavcodec/qsvdec.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 9125700..98585e3 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -555,16 +555,18 @@ void ff_qsv_decode_reset(AVCodecContext *avctx, 
QSVContext *q)
 }
 
 /* Reset output surfaces */
-av_fifo_reset(q->async_fifo);
+if (q->async_fifo)
+av_fifo_reset(q->async_fifo);
 
 /* Reset input packets fifo */
-while (av_fifo_size(q->pkt_fifo)) {
+while (q->pkt_fifo && av_fifo_size(q->pkt_fifo)) {
 av_fifo_generic_read(q->pkt_fifo, , sizeof(pkt), NULL);
 av_packet_unref();
 }
 
 /* Reset input bitstream fifo */
-av_fifo_reset(q->input_fifo);
+if (q->input_fifo)
+av_fifo_reset(q->input_fifo);
 }
 
 int ff_qsv_decode_close(QSVContext *q)
-- 
1.8.3.1

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


Re: [FFmpeg-devel] [PATCH] avcodec/alsdec: implement floating point decoding

2016-07-29 Thread Umair Khan
On Thu, Jul 28, 2016 at 7:12 PM, Umair Khan  wrote:
> On Thu, Jul 28, 2016 at 2:25 PM, Thilo Borgmann  
> wrote:
>> Am 28.07.16 um 08:28 schrieb Umair Khan:
>>> On Thu, Jul 28, 2016 at 12:22 AM, Clément Bœsch  wrote:
 On Wed, Jul 27, 2016 at 07:48:56PM +0200, Thilo Borgmann wrote:
>> @@ -1803,6 +2057,34 @@ static av_cold int decode_init(AVCodecContext 
>> *avctx)
>>  ctx->raw_buffer   = av_mallocz_array(avctx->channels * 
>> channel_size, sizeof(*ctx->raw_buffer));
>>  ctx->raw_samples  = av_malloc_array(avctx->channels, 
>> sizeof(*ctx->raw_samples));
>>
>> +if (sconf->floating) {
>> +ctx->acf   = av_malloc_array(avctx->channels, 
>> sizeof(*ctx->acf));
>> +ctx->shift_value   = av_malloc_array(avctx->channels, 
>> sizeof(*ctx->shift_value));
>> +ctx->last_shift_value  = av_malloc_array(avctx->channels, 
>> sizeof(*ctx->last_shift_value));
>> +ctx->last_acf_mantissa = av_malloc_array(avctx->channels, 
>> sizeof(*ctx->last_acf_mantissa));
>> +ctx->raw_mantissa  = av_malloc_array(avctx->channels, 
>> sizeof(*ctx->raw_mantissa));
>> +
>> +ctx->larray = av_malloc_array(ctx->cur_frame_length * 4, 
>> sizeof(*ctx->larray));
>> +ctx->nbits  = av_malloc_array(ctx->cur_frame_length, 
>> sizeof(*ctx->nbits));
>>
>> +ctx->mlz= av_malloc(sizeof(*ctx->mlz));
>> +ff_mlz_init_dict(avctx, ctx->mlz);
>> +ff_mlz_flush_dict(ctx->mlz);
>>
>> ctx->mlz is also used without allocation check. Are the _dict functions safe 
>> for
>> ctx->mlz == NULL?

I had sent the old patch file by mistake. This is the correct one.

- Umair


0001-avcodec-alsdec-implement-floating-point-decoding.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avcodec/alacenc: allocate bigger packets

2016-07-29 Thread Paul B Mahol
Hi,

patch attached.


0001-avcodec-alacenc-allocate-bigger-packets.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Fix audio clipping problem in dynaudnorm

2016-07-29 Thread Paul B Mahol
On 7/27/16, andyndeanna  wrote:
> Hello,
>
> See attached patch to fix a clipping problem with dynaudnorm when the first
> frame contains silence.  I implemented the fix by adding a boundary mode.
> It could also be done by changing how b=1 works.
>
> Thanks,
> Andy
>

Have you considered sending this directly to creator of this code?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Fix double free and null dereferences in the qsv decoder

2016-07-29 Thread Ivan Uskov

Hello Yuli,

Wednesday, July 27, 2016, 6:21:41 PM, you wrote:

> This patch fixes the h264_qsv decoder issues mentioned
> in https://ffmpeg.zeranoe.com/forum/viewtopic.php?t=2962.

> The patch may be tested by specifying h264_qsv as the decoder to ffplay
> for an h264 encoded file.

> ffplay -vcodec h264_qsv foo.mts

> Signed-off-by: Yuli Khodorkovskiy 
> ---
>  libavcodec/qsvdec.c | 10 ++
>  1 file changed, 6 insertions(+), 4 deletions(-)

> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index 9125700..b462887 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -408,7 +408,7 @@ static int do_qsv_decode(AVCodecContext *avctx, 
> QSVContext *q,
>  return ff_qsv_error(ret);
>  }
>  n_out_frames = av_fifo_size(q->async_fifo) / 
> (sizeof(out_frame)+sizeof(sync));
> -
> +av_freep();
I'm sorry but it is not actual more. There was the roll-back for
sync allocations on heap at July 24, now there is old good way uses again.

>  if (n_out_frames > q->async_depth || (flush && n_out_frames) ) {
>  AVFrame *src_frame;
>  
> @@ -555,16 +555,18 @@ void ff_qsv_decode_reset(AVCodecContext *avctx, 
> QSVContext *q)
>  }
>  
>  /* Reset output surfaces */
> -av_fifo_reset(q->async_fifo);
+if (q->>async_fifo)
> +av_fifo_reset(q->async_fifo);
>  
>  /* Reset input packets fifo */
> -while (av_fifo_size(q->pkt_fifo)) {
+while (q->>pkt_fifo && av_fifo_size(q->pkt_fifo)) {
>  av_fifo_generic_read(q->pkt_fifo, , sizeof(pkt), NULL);
>  av_packet_unref();
>  }
>  
>  /* Reset input bitstream fifo */
> -av_fifo_reset(q->input_fifo);
+if (q->>input_fifo)
> +av_fifo_reset(q->input_fifo);
>  }
>  
>  int ff_qsv_decode_close(QSVContext *q)


-- 
Best regards,
 Ivanmailto:ivan.us...@nablet.com

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


Re: [FFmpeg-devel] [PATCH] hapdec: remove unused memory.h include

2016-07-29 Thread Josh de Kock
On Fri, Jul 29, 2016, at 03:49 AM, Timothy Gu wrote:
> Looks good to me. For what it's worth, the include was added in
> commit 3ee217853a6741b829a2683f49c590618891b1ab, and looks like a stray
> change.
> 
> Timothy

Thanks, applied.

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


Re: [FFmpeg-devel] [PATCH] lavf/mpegtsenc: add special case for handling timed ID3 packets

2016-07-29 Thread Stefano Sabatini
On date Thursday 2016-05-19 22:20:41 +0200, Michael Niedermayer encoded:
> On Thu, May 19, 2016 at 06:45:41PM +0200, Stefano Sabatini wrote:
> > Set the stream_id to 0xbd (private_stream_id_1). Tools seem to assume
> > that value, and this is consistent with MPEG TS (ITU-T H.222.0) section
> > 2.12.3.
> > ---
> >  libavformat/mpegtsenc.c | 3 +++
> >  1 file changed, 3 insertions(+)
> 
> should be ok

Finally applied, thanks.
-- 
FFmpeg = Friendly Fostering Majestic Powered Ecumenical Governor
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel