Re: [FFmpeg-devel] [PATCH v1 1/2] lavf/vf_transpose: add exif orientation support

2019-05-25 Thread Jun Li
On Sat, May 25, 2019 at 2:46 AM Nicolas George  wrote:

> Jun Li (12019-05-24):
> > Add exif orientation support and expose an option.
> > ---
> >  libavfilter/vf_transpose.c | 258 +
> >  1 file changed, 207 insertions(+), 51 deletions(-)
>
> If I read the code correctly, when orientation=1 (unchanged), this code
> will copy the frame instead of just passing it unchanged. Did I miss
> something?
>

return 0;
@@ -334,7 +485,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
*in)
 ThreadData td;
 AVFrame *out;

-if (s->passthrough)
+if (s->passthrough || s->orientation == 1)

I believe this line skip the frame copy ?

 return ff_filter_frame(outlink, in);


>
> --
>   Nicolas George
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v1 2/2] fftools/ffmpeg: add exif orientation support per frame's metadata

2019-05-25 Thread Jun Li
On Sat, May 25, 2019 at 2:53 AM Nicolas George  wrote:

> Jun Li (12019-05-24):
> > Fix #6945
> > Rotate or/and flip frame according to frame's metadata orientation
>
> Since ffmpeg does not handle resolution changes very well, do we want
> this enabled by default?


Thanks Nicolas for review.
I believe it has been enabled by default, the 'autorotate' value is true by
default.

> ---
> >  fftools/ffmpeg.c|  3 ++-
> >  fftools/ffmpeg.h|  3 ++-
> >  fftools/ffmpeg_filter.c | 19 ++-
> >  3 files changed, 22 insertions(+), 3 deletions(-)
> >
> > diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> > index 01f04103cf..da4c19c782 100644
> > --- a/fftools/ffmpeg.c
> > +++ b/fftools/ffmpeg.c
> > @@ -2142,7 +2142,8 @@ static int ifilter_send_frame(InputFilter
> *ifilter, AVFrame *frame)
> >  break;
> >  case AVMEDIA_TYPE_VIDEO:
> >  need_reinit |= ifilter->width  != frame->width ||
> > -   ifilter->height != frame->height;
> > +   ifilter->height != frame->height ||
>
> > +   ifilter->orientation !=
> get_frame_orientation(frame);
>
> I the filter chain does not really need reinit if the orientation change
> does not change the output resolution.
>
> It can happen for photos who were all taken in portrait mode, but
> sometimes by leaning on the left and sometimes leaning on the right. I
> am sorry if these questions I raise seem to complicate matters, but it
> is not on purpose: automatic transformation is an issue that has many
> direct consequences on the usability of the tools, they need to be at
> least considered in the solution.
>

Do you mean the orientation case 1, 2, 3, 4 have the same resolution and 5,
6, 7, 8 are rotated, so the reinit is only necessary when switch between
these two cases?
I think it is doable. That transpose filter can do partially dynamic
processing based on frame's orientation, but the filter args still need to
set resolution info.

Correct me if I wrongly understand you question. Thanks.



> >  break;
> >  }
> >
> > diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
> > index eb1eaf6363..54532ef0eb 100644
> > --- a/fftools/ffmpeg.h
> > +++ b/fftools/ffmpeg.h
> > @@ -244,7 +244,7 @@ typedef struct InputFilter {
> >  // parameters configured for this input
> >  int format;
> >
> > -int width, height;
> > +int width, height, orientation;
> >  AVRational sample_aspect_ratio;
> >
> >  int sample_rate;
> > @@ -649,6 +649,7 @@ int init_complex_filtergraph(FilterGraph *fg);
> >  void sub2video_update(InputStream *ist, AVSubtitle *sub);
> >
> >  int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame
> *frame);
> > +int get_frame_orientation(const AVFrame* frame);
> >
> >  int ffmpeg_parse_options(int argc, char **argv);
> >
> > diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
> > index 72838de1e2..b230dafdc9 100644
> > --- a/fftools/ffmpeg_filter.c
> > +++ b/fftools/ffmpeg_filter.c
> > @@ -743,6 +743,18 @@ static int sub2video_prepare(InputStream *ist,
> InputFilter *ifilter)
> >  return 0;
> >  }
> >
> > +int get_frame_orientation(const AVFrame *frame)
> > +{
> > +AVDictionaryEntry *entry = NULL;
> > +int orientation = 1; // orientation indicates 'Normal'
> > +
> > +// read exif orientation data
> > +entry = av_dict_get(frame->metadata, "Orientation", NULL, 0);
>
> > +if (entry)
> > +orientation = atoi(entry->value);
> > +return orientation > 8 ? 1 : orientation;
>
> I do not like the defensive programming here. If orientation is invalid,
> then it should not be invented, even a same default value.
>
Addressed in the new version.

> +}
> > +
> >  static int configure_input_video_filter(FilterGraph *fg, InputFilter
> *ifilter,
> >  AVFilterInOut *in)
> >  {
> > @@ -809,7 +821,11 @@ static int configure_input_video_filter(FilterGraph
> *fg, InputFilter *ifilter,
> >  if (ist->autorotate) {
> >  double theta = get_rotation(ist->st);
> >
>
> > -if (fabs(theta - 90) < 1.0) {
> > +if (fabs(theta) < 1.0) { // no rotation info in stream meta
> > +char transpose_args[32];
> > +snprintf(transpose_args, sizeof(transpose_args),
> "orientation=%i", ifilter->orientation);
> > +ret = insert_filter(_filter, _idx, "transpose",
> transpose_args);
>
> If the frame does not contain orientation metadata, I think the filter
> should not be inserted.
>
Addressed in the new version.


> > +} else if (fabs(theta - 90) < 1.0) {
> >  ret = insert_filter(_filter, _idx, "transpose",
> "clock");
> >  } else if (fabs(theta - 180) < 1.0) {
> >  ret = insert_filter(_filter, _idx, "hflip", NULL);
>
> If transpose can take care of all cases, then the other cases need to be
> removed, or am I missing something?
>
Fixed in the new version.

Thanks for the review !

Best Regards,

Re: [FFmpeg-devel] [PATCH v1 2/2] fftools/ffmpeg: add exif orientation support per frame's metadata

2019-05-25 Thread Jun Li
On Sat, May 25, 2019 at 6:16 AM Michael Niedermayer 
wrote:

> On Fri, May 24, 2019 at 05:04:27PM -0700, Jun Li wrote:
> > Fix #6945
> > Rotate or/and flip frame according to frame's metadata orientation
> > ---
> >  fftools/ffmpeg.c|  3 ++-
> >  fftools/ffmpeg.h|  3 ++-
> >  fftools/ffmpeg_filter.c | 19 ++-
> >  3 files changed, 22 insertions(+), 3 deletions(-)
>
> This breaks 227 fate tests here
>
> My bad, forgot to run test. Sorry about that.
New patch is sent out, should be fine now.
Thanks.

Best Regards
-Jun

> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Take away the freedom of one citizen and you will be jailed, take away
> the freedom of all citizens and you will be congratulated by your peers
> in Parliament.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v2 2/2] fftools/ffmpeg: add exif orientation support per frame's metadata

2019-05-25 Thread Jun Li
Fix #6945
Rotate or/and flip frame according to frame's metadata orientation
---
 fftools/ffmpeg.c|  3 ++-
 fftools/ffmpeg.h|  3 ++-
 fftools/ffmpeg_filter.c | 35 ++-
 3 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 01f04103cf..da4c19c782 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2142,7 +2142,8 @@ static int ifilter_send_frame(InputFilter *ifilter, 
AVFrame *frame)
 break;
 case AVMEDIA_TYPE_VIDEO:
 need_reinit |= ifilter->width  != frame->width ||
-   ifilter->height != frame->height;
+   ifilter->height != frame->height ||
+   ifilter->orientation != get_frame_orientation(frame);
 break;
 }
 
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index eb1eaf6363..54532ef0eb 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -244,7 +244,7 @@ typedef struct InputFilter {
 // parameters configured for this input
 int format;
 
-int width, height;
+int width, height, orientation;
 AVRational sample_aspect_ratio;
 
 int sample_rate;
@@ -649,6 +649,7 @@ int init_complex_filtergraph(FilterGraph *fg);
 void sub2video_update(InputStream *ist, AVSubtitle *sub);
 
 int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame);
+int get_frame_orientation(const AVFrame* frame);
 
 int ffmpeg_parse_options(int argc, char **argv);
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 72838de1e2..41dcf89692 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -743,6 +743,18 @@ static int sub2video_prepare(InputStream *ist, InputFilter 
*ifilter)
 return 0;
 }
 
+int get_frame_orientation(const AVFrame *frame)
+{
+AVDictionaryEntry *entry = NULL;
+int orientation = 0;
+
+// read exif orientation data
+entry = av_dict_get(frame->metadata, "Orientation", NULL, 0);
+if (entry)
+orientation = atoi(entry->value);
+return orientation;
+}
+
 static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
 AVFilterInOut *in)
 {
@@ -808,20 +820,24 @@ static int configure_input_video_filter(FilterGraph *fg, 
InputFilter *ifilter,
 
 if (ist->autorotate) {
 double theta = get_rotation(ist->st);
-
-if (fabs(theta - 90) < 1.0) {
+char filter_args[64];
+
+if (fabs(theta) < 1.0) { // no rotation info in stream meta
+if (ifilter->orientation < 0 || ifilter->orientation > 8) {
+av_log(NULL, AV_LOG_ERROR, "Invalid frame orientation: %i\n", 
ifilter->orientation);
+} else if (ifilter->orientation > 1) { // skip 0 (not set) and 1 
(orientaion 'Normal') 
+snprintf(filter_args, sizeof(filter_args), "orientation=%i", 
ifilter->orientation);
+ret = insert_filter(_filter, _idx, "transpose", 
filter_args);
+}
+} else if (fabs(theta - 90) < 1.0) {
 ret = insert_filter(_filter, _idx, "transpose", "clock");
 } else if (fabs(theta - 180) < 1.0) {
-ret = insert_filter(_filter, _idx, "hflip", NULL);
-if (ret < 0)
-return ret;
-ret = insert_filter(_filter, _idx, "vflip", NULL);
+ret = insert_filter(_filter, _idx, "transpose", 
"orientation=3");
 } else if (fabs(theta - 270) < 1.0) {
 ret = insert_filter(_filter, _idx, "transpose", "cclock");
 } else if (fabs(theta) > 1.0) {
-char rotate_buf[64];
-snprintf(rotate_buf, sizeof(rotate_buf), "%f*PI/180", theta);
-ret = insert_filter(_filter, _idx, "rotate", rotate_buf);
+snprintf(filter_args, sizeof(filter_args), "%f*PI/180", theta);
+ret = insert_filter(_filter, _idx, "rotate", filter_args);
 }
 if (ret < 0)
 return ret;
@@ -1191,6 +1207,7 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, 
const AVFrame *frame)
 ifilter->width   = frame->width;
 ifilter->height  = frame->height;
 ifilter->sample_aspect_ratio = frame->sample_aspect_ratio;
+ifilter->orientation = get_frame_orientation(frame);
 
 ifilter->sample_rate = frame->sample_rate;
 ifilter->channels= frame->channels;
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH v2 1/2] lavf/vf_transpose: add exif orientation support

2019-05-25 Thread Jun Li
Add exif orientation support and expose an option.
---
 libavfilter/vf_transpose.c | 258 +
 1 file changed, 207 insertions(+), 51 deletions(-)

diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
index dd54947bd9..4aebfb9ee4 100644
--- a/libavfilter/vf_transpose.c
+++ b/libavfilter/vf_transpose.c
@@ -46,6 +46,9 @@ typedef struct TransVtable {
 void (*transpose_block)(uint8_t *src, ptrdiff_t src_linesize,
 uint8_t *dst, ptrdiff_t dst_linesize,
 int w, int h);
+void (*copyline_block)(uint8_t *src, ptrdiff_t src_linesize,
+   uint8_t *dst, ptrdiff_t dst_linesize,
+   int line_dir, int w, int h);
 } TransVtable;
 
 typedef struct TransContext {
@@ -56,7 +59,7 @@ typedef struct TransContext {
 
 int passthrough;///< PassthroughType, landscape passthrough mode 
enabled
 int dir;///< TransposeDir
-
+int orientation;///< Orientation
 TransVtable vtables[4];
 } TransContext;
 
@@ -182,6 +185,105 @@ static void transpose_8x8_64_c(uint8_t *src, ptrdiff_t 
src_linesize,
 transpose_block_64_c(src, src_linesize, dst, dst_linesize, 8, 8);
 }
 
+
+static void copyline_block_8(uint8_t *src, ptrdiff_t src_linesize,
+ uint8_t *dst, ptrdiff_t dst_linesize,
+ int line_dir, int w, int h)
+{
+int x, y, i;
+for (y = 0; y < h; y++, dst += dst_linesize, src += src_linesize) {
+for (x = 0; x < w; x ++) {
+i = line_dir < 0 ? w-x-1 : x;
+dst[i] = src[x];
+}
+}
+}
+
+static void copyline_block_16(uint8_t *src, ptrdiff_t src_linesize,
+  uint8_t *dst, ptrdiff_t dst_linesize,
+  int line_dir, int w, int h)
+{
+int x, y, i;
+for (y = 0; y < h; y++, dst += dst_linesize, src += src_linesize) {
+for (x = 0; x < w; x ++) {
+i = line_dir < 0 ? w-x-1 : x;
+*((uint16_t *)(dst + 2*i)) = *((uint16_t *)(src + 2*x));
+}
+}
+}
+
+static void copyline_block_24(uint8_t *src, ptrdiff_t src_linesize,
+  uint8_t *dst, ptrdiff_t dst_linesize,
+  int line_dir, int w, int h)
+{
+int x, y, i;
+for (y = 0; y < h; y++, dst += dst_linesize, src += src_linesize) {
+for (x = 0; x < w; x++) {
+int32_t v = AV_RB24(src + 3*x);
+i = line_dir < 0 ? w-x-1 : x;
+AV_WB24(dst + 3*i, v);
+}
+}
+}
+
+static void copyline_block_32(uint8_t *src, ptrdiff_t src_linesize,
+  uint8_t *dst, ptrdiff_t dst_linesize,
+  int line_dir, int w, int h)
+{
+int x, y, i;
+for (y = 0; y < h; y++, dst += dst_linesize, src += src_linesize) {
+for (x = 0; x < w; x ++) {
+i = line_dir < 0 ? w-x-1 : x;
+*((uint32_t *)(dst + 4*i)) = *((uint32_t *)(src + 4*x));
+}
+}
+}
+
+static void copyline_block_48(uint8_t *src, ptrdiff_t src_linesize,
+  uint8_t *dst, ptrdiff_t dst_linesize,
+  int line_dir, int w, int h)
+{
+int x, y, i;
+for (y = 0; y < h; y++, dst += dst_linesize, src += src_linesize) {
+for (x = 0; x < w; x++) {
+int64_t v = AV_RB48(src + 6*x);
+i = line_dir < 0 ? w-x-1 : x;
+AV_WB48(dst + 6*i, v);
+}
+}
+}
+
+static void copyline_block_64(uint8_t *src, ptrdiff_t src_linesize,
+  uint8_t *dst, ptrdiff_t dst_linesize,
+  int line_dir, int w, int h)
+{
+int x, y, i;
+for (y = 0; y < h; y++, dst += dst_linesize, src += src_linesize) {
+for (x = 0; x < w; x ++) {
+i = line_dir < 0 ? w-x-1 : x;
+*((uint64_t *)(dst + 8*i)) = *((uint64_t *)(src + 8*x));
+}
+}
+}
+
+static void set_outlink_width_height(AVFilterLink *inlink, AVFilterLink 
*outlink, int transpose)
+{
+if (transpose) {
+outlink->w = inlink->h;
+outlink->h = inlink->w;
+
+if (inlink->sample_aspect_ratio.num)
+outlink->sample_aspect_ratio = av_div_q((AVRational) { 1, 1 },
+
inlink->sample_aspect_ratio);
+else
+outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
+} else {
+outlink->w = inlink->w;
+outlink->h = inlink->h;
+outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
+}
+}
+
 static int config_props_output(AVFilterLink *outlink)
 {
 AVFilterContext *ctx = outlink->src;
@@ -213,33 +315,44 @@ static int config_props_output(AVFilterLink *outlink)
 
 av_assert0(desc_in->nb_components == desc_out->nb_components);
 
-
 av_image_fill_max_pixsteps(s->pixsteps, NULL, desc_out);
+
+if (s->orientation && 

[FFmpeg-devel] [PATCH 4/5] libavfilter/vf_overlay.c: using the nbits and depth for 8bits and 10bit support Have fix the build issue for other platform by Michael Niedermayer comments: https://patchwor

2019-05-25 Thread lance . lmwang
From: Limin Wang 

---
 libavfilter/vf_overlay.c | 79 
 1 file changed, 47 insertions(+), 32 deletions(-)

diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index ee51a54659..2d06074f15 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -464,22 +464,26 @@ static av_always_inline void 
blend_plane_##depth##_##nbits##bits(AVFilterContext
 int dst_hp = AV_CEIL_RSHIFT(dst_h, vsub);  
\
 int yp = y>>vsub;  
\
 int xp = x>>hsub;  
\
-uint8_t *s, *sp, *d, *dp, *dap, *a, *da, *ap;  
\
+uint##depth##_t *s, *sp, *d, *dp, *dap, *a, *da, *ap;  
\
 int jmax, j, k, kmax;  
\
 int slice_start, slice_end;
\
+const uint##depth##_t max = (1 << nbits) - 1;  
\
+const uint##depth##_t mid = (1 << (nbits -1)) ;
\
+int bytes = depth / 8; 
\

\
+dst_step /= bytes; 
\
 j = FFMAX(-yp, 0); 
\
 jmax = FFMIN3(-yp + dst_hp, FFMIN(src_hp, dst_hp), yp + src_hp);   
\

\
 slice_start = j + (jmax * jobnr) / nb_jobs;
\
 slice_end = j + (jmax * (jobnr+1)) / nb_jobs;  
\

\
-sp = src->data[i] + (slice_start) * src->linesize[i];  
\
-dp = dst->data[dst_plane]  
\
+sp = (uint##depth##_t *)(src->data[i] + (slice_start) * src->linesize[i]); 
\
+dp = (uint##depth##_t *)(dst->data[dst_plane]  
\
   + (yp + slice_start) * dst->linesize[dst_plane]  
\
-  + dst_offset;
\
-ap = src->data[3] + (slice_start << vsub) * src->linesize[3];  
\
-dap = dst->data[3] + ((yp + slice_start) << vsub) * dst->linesize[3];  
\
+  + dst_offset);   
\
+ap = (uint##depth##_t *)(src->data[3] + (slice_start << vsub) * 
src->linesize[3]); \
+dap = (uint##depth##_t *)(dst->data[3] + ((yp + slice_start) << vsub) * 
dst->linesize[3]); \

\
 for (j = slice_start; j < slice_end; j++) {
\
 k = FFMAX(-xp, 0); 
\
@@ -489,8 +493,8 @@ static av_always_inline void 
blend_plane_##depth##_##nbits##bits(AVFilterContext
 da = dap + ((xp+k) << hsub);   
\
 kmax = FFMIN(-xp + dst_wp, src_wp);
\

\
-if (((vsub && j+1 < src_hp) || !vsub) && octx->blend_row[i]) { 
\
-int c = octx->blend_row[i](d, da, s, a, 

[FFmpeg-devel] [PATCH 1/5] libavfilter/vf_overlay.c: change the comment style for the following macro defined function

2019-05-25 Thread lance . lmwang
From: Limin Wang 

---
 libavfilter/vf_overlay.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 0a8f089c0d..b468cedf2e 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -500,7 +500,7 @@ static av_always_inline void blend_plane(AVFilterContext 
*ctx,
 for (; k < kmax; k++) {
 int alpha_v, alpha_h, alpha;
 
-// average alpha for color components, improve quality
+/* average alpha for color components, improve quality */
 if (hsub && vsub && j+1 < src_hp && k+1 < src_wp) {
 alpha = (a[0] + a[src->linesize[3]] +
  a[1] + a[src->linesize[3]+1]) >> 2;
@@ -512,10 +512,10 @@ static av_always_inline void blend_plane(AVFilterContext 
*ctx,
 alpha = (alpha_v + alpha_h) >> 1;
 } else
 alpha = a[0];
-// if the main channel has an alpha channel, alpha has to be 
calculated
-// to create an un-premultiplied (straight) alpha value
+/* if the main channel has an alpha channel, alpha has to be 
calculated */
+/* to create an un-premultiplied (straight) alpha value */
 if (main_has_alpha && alpha != 0 && alpha != 255) {
-// average alpha for color components, improve quality
+/* average alpha for color components, improve quality */
 uint8_t alpha_d;
 if (hsub && vsub && j+1 < src_hp && k+1 < src_wp) {
 alpha_d = (da[0] + da[dst->linesize[3]] +
@@ -556,7 +556,7 @@ static inline void alpha_composite(const AVFrame *src, 
const AVFrame *dst,
int x, int y,
int jobnr, int nb_jobs)
 {
-uint8_t alpha;  ///< the amount of overlay to blend on to main
+uint8_t alpha;  /* the amount of overlay to blend on to main */
 uint8_t *s, *sa, *d, *da;
 int i, imax, j, jmax;
 int slice_start, slice_end;
@@ -587,7 +587,7 @@ static inline void alpha_composite(const AVFrame *src, 
const AVFrame *dst,
 *d = *s;
 break;
 default:
-// apply alpha compositing: main_alpha += (1-main_alpha) * 
overlay_alpha
+/* apply alpha compositing: main_alpha += (1-main_alpha) * 
overlay_alpha */
 *d += FAST_DIV255((255 - *d) * *s);
 }
 d += 1;
-- 
2.21.0

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

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

[FFmpeg-devel] [PATCH 3/5] libavfilter/vf_overlay.c: define the macro-style function to support 8bit and 10bit blend, keep the 8bit function same now

2019-05-25 Thread lance . lmwang
From: Limin Wang 

---
 libavfilter/vf_overlay.c | 52 ++--
 1 file changed, 29 insertions(+), 23 deletions(-)

diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index ba8147f579..ee51a54659 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -441,7 +441,8 @@ static av_always_inline void 
blend_slice_packed_rgb(AVFilterContext *ctx,
 }
 }
 
-static av_always_inline void blend_plane(AVFilterContext *ctx, 
\
+#define DEFINE_BLEND_PLANE(depth, nbits)   
\
+static av_always_inline void 
blend_plane_##depth##_##nbits##bits(AVFilterContext *ctx,   
  \
  AVFrame *dst, const AVFrame *src, 
\
  int src_w, int src_h, 
\
  int dst_w, int dst_h, 
\
@@ -549,8 +550,10 @@ static av_always_inline void blend_plane(AVFilterContext 
*ctx,
 dap += (1 << vsub) * dst->linesize[3]; 
\
 }  
\
 }
+DEFINE_BLEND_PLANE(8, 8);
 
-static inline void alpha_composite(const AVFrame *src, const AVFrame *dst, 
\
+#define DEFINE_ALPHA_COMPOSITE(depth, nbits)   
\
+static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, 
const AVFrame *dst, \
int src_w, int src_h,   
\
int dst_w, int dst_h,   
\
int x, int y,   
\
@@ -597,8 +600,10 @@ static inline void alpha_composite(const AVFrame *src, 
const AVFrame *dst,
 sa += src->linesize[3];
\
 }  
\
 }
+DEFINE_ALPHA_COMPOSITE(8, 8);
 
-static av_always_inline void blend_slice_yuv(AVFilterContext *ctx, 
\
+#define DEFINE_BLEND_SLICE_YUV(depth, nbits)   
\
+static av_always_inline void 
blend_slice_yuv_##depth##_##nbits##bits(AVFilterContext *ctx,   
  \
  AVFrame *dst, const AVFrame *src, 
\
  int hsub, int vsub,   
\
  int main_has_alpha,   
\
@@ -612,19 +617,20 @@ static av_always_inline void 
blend_slice_yuv(AVFilterContext *ctx,
 const int dst_w = dst->width;  
\
 const int dst_h = dst->height; 
\

\
-blend_plane(ctx, dst, src, src_w, src_h, dst_w, dst_h, 0, 0,   0, x, 
y, main_has_alpha,\
+blend_plane_##depth##_##nbits##bits(ctx, dst, src, src_w, src_h, dst_w, 
dst_h, 0, 0,   0, x, y, main_has_alpha,\
 s->main_desc->comp[0].plane, s->main_desc->comp[0].offset, 
s->main_desc->comp[0].step, is_straight, 1, \
 jobnr, nb_jobs);   
\
-blend_plane(ctx, dst, src, src_w, src_h, dst_w, dst_h, 1, hsub, vsub, x, 
y, main_has_alpha,\
+blend_plane_##depth##_##nbits##bits(ctx, dst, src, src_w, src_h, dst_w, 
dst_h, 1, hsub, vsub, x, y, main_has_alpha,\
 s->main_desc->comp[1].plane, s->main_desc->comp[1].offset, 
s->main_desc->comp[1].step, is_straight, 1, \
 jobnr, nb_jobs);   
\
-blend_plane(ctx, dst, src, src_w, src_h, dst_w, dst_h, 2, hsub, vsub, x, 
y, main_has_alpha,\
+blend_plane_##depth##_##nbits##bits(ctx, dst, src, 

[FFmpeg-devel] [PATCH 2/5] libavfilter/vf_overlay.c: Add "\" for the following macro style function

2019-05-25 Thread lance . lmwang
From: Limin Wang 

Merge the old patch 2/3/4 into one by Carl Eugen comments:
https://patchwork.ffmpeg.org/patch/13270/
---
 libavfilter/vf_overlay.c | 358 +++
 1 file changed, 179 insertions(+), 179 deletions(-)

diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index b468cedf2e..ba8147f579 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -441,189 +441,189 @@ static av_always_inline void 
blend_slice_packed_rgb(AVFilterContext *ctx,
 }
 }
 
-static av_always_inline void blend_plane(AVFilterContext *ctx,
- AVFrame *dst, const AVFrame *src,
- int src_w, int src_h,
- int dst_w, int dst_h,
- int i, int hsub, int vsub,
- int x, int y,
- int main_has_alpha,
- int dst_plane,
- int dst_offset,
- int dst_step,
- int straight,
- int yuv,
- int jobnr,
- int nb_jobs)
-{
-OverlayContext *octx = ctx->priv;
-int src_wp = AV_CEIL_RSHIFT(src_w, hsub);
-int src_hp = AV_CEIL_RSHIFT(src_h, vsub);
-int dst_wp = AV_CEIL_RSHIFT(dst_w, hsub);
-int dst_hp = AV_CEIL_RSHIFT(dst_h, vsub);
-int yp = y>>vsub;
-int xp = x>>hsub;
-uint8_t *s, *sp, *d, *dp, *dap, *a, *da, *ap;
-int jmax, j, k, kmax;
-int slice_start, slice_end;
-
-j = FFMAX(-yp, 0);
-jmax = FFMIN3(-yp + dst_hp, FFMIN(src_hp, dst_hp), yp + src_hp);
-
-slice_start = j + (jmax * jobnr) / nb_jobs;
-slice_end = j + (jmax * (jobnr+1)) / nb_jobs;
-
-sp = src->data[i] + (slice_start) * src->linesize[i];
-dp = dst->data[dst_plane]
-  + (yp + slice_start) * dst->linesize[dst_plane]
-  + dst_offset;
-ap = src->data[3] + (slice_start << vsub) * src->linesize[3];
-dap = dst->data[3] + ((yp + slice_start) << vsub) * dst->linesize[3];
-
-for (j = slice_start; j < slice_end; j++) {
-k = FFMAX(-xp, 0);
-d = dp + (xp+k) * dst_step;
-s = sp + k;
-a = ap + (kblend_row[i](d, da, s, a, kmax - k, 
src->linesize[3]);
-
-s += c;
-d += dst_step * c;
-da += (1 << hsub) * c;
-a += (1 << hsub) * c;
-k += c;
-}
-for (; k < kmax; k++) {
-int alpha_v, alpha_h, alpha;
-
-/* average alpha for color components, improve quality */
-if (hsub && vsub && j+1 < src_hp && k+1 < src_wp) {
-alpha = (a[0] + a[src->linesize[3]] +
- a[1] + a[src->linesize[3]+1]) >> 2;
-} else if (hsub || vsub) {
-alpha_h = hsub && k+1 < src_wp ?
-(a[0] + a[1]) >> 1 : a[0];
-alpha_v = vsub && j+1 < src_hp ?
-(a[0] + a[src->linesize[3]]) >> 1 : a[0];
-alpha = (alpha_v + alpha_h) >> 1;
-} else
-alpha = a[0];
-/* if the main channel has an alpha channel, alpha has to be 
calculated */
-/* to create an un-premultiplied (straight) alpha value */
-if (main_has_alpha && alpha != 0 && alpha != 255) {
-/* average alpha for color components, improve quality */
-uint8_t alpha_d;
-if (hsub && vsub && j+1 < src_hp && k+1 < src_wp) {
-alpha_d = (da[0] + da[dst->linesize[3]] +
-   da[1] + da[dst->linesize[3]+1]) >> 2;
-} else if (hsub || vsub) {
-alpha_h = hsub && k+1 < src_wp ?
-(da[0] + da[1]) >> 1 : da[0];
-alpha_v = vsub && j+1 < src_hp ?
-(da[0] + da[dst->linesize[3]]) >> 1 : da[0];
-alpha_d = (alpha_v + alpha_h) >> 1;
-} else
-alpha_d = da[0];
-alpha = UNPREMULTIPLY_ALPHA(alpha, alpha_d);
-}
-if (straight) {
-*d = FAST_DIV255(*d * (255 - alpha) + *s * alpha);
-} else {
-if (i && yuv)
-*d = av_clip(FAST_DIV255((*d - 128) * (255 - alpha)) + *s 
- 128, -128, 128) + 128;
-else
-*d = FFMIN(FAST_DIV255(*d * (255 - alpha)) + *s, 255);
-}
-s++;
-d += dst_step;
-da += 1 << hsub;
-a += 1 << hsub;
-}
-dp += dst->linesize[dst_plane];
-sp += src->linesize[i];
-ap += (1 << vsub) * 

[FFmpeg-devel] [PATCH 5/5] libavfilter/vf_overlay.c: add the yuv420p10 10bit support

2019-05-25 Thread lance . lmwang
From: Limin Wang 

The test ffmpeg command in iMAC system:
./ffmpeg -y  -i input.ts -i ./logo.png -filter_complex 
overlay=50:50:format=yuv420p10  -c:v hevc_videotoolbox ./test.ts
Now I have tested with yuv420p10 overlay and check the result is OK, please 
help to test with your condition.
---
 libavfilter/vf_overlay.c | 42 +++-
 libavfilter/vf_overlay.h |  1 +
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 2d06074f15..e708d525e5 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -153,7 +153,7 @@ static int process_command(AVFilterContext *ctx, const char 
*cmd, const char *ar
 }
 
 static const enum AVPixelFormat alpha_pix_fmts[] = {
-AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
+AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P, 
AV_PIX_FMT_YUVA444P,
 AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR, AV_PIX_FMT_RGBA,
 AV_PIX_FMT_BGRA, AV_PIX_FMT_GBRAP, AV_PIX_FMT_NONE
 };
@@ -172,6 +172,14 @@ static int query_formats(AVFilterContext *ctx)
 AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE
 };
 
+static const enum AVPixelFormat main_pix_fmts_yuv420p10[] = {
+AV_PIX_FMT_YUV420P10LE, AV_PIX_FMT_YUVA420P10LE,
+AV_PIX_FMT_NONE
+};
+static const enum AVPixelFormat overlay_pix_fmts_yuv420p10[] = {
+AV_PIX_FMT_YUVA420P10LE, AV_PIX_FMT_NONE
+};
+
 static const enum AVPixelFormat main_pix_fmts_yuv422[] = {
 AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVA422P, 
AV_PIX_FMT_NONE
 };
@@ -217,6 +225,13 @@ static int query_formats(AVFilterContext *ctx)
 goto fail;
 }
 break;
+case OVERLAY_FORMAT_YUV420P10:
+if (!(main_formats= ff_make_format_list(main_pix_fmts_yuv420p10)) 
||
+!(overlay_formats = 
ff_make_format_list(overlay_pix_fmts_yuv420p10))) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+break;
 case OVERLAY_FORMAT_YUV422:
 if (!(main_formats= ff_make_format_list(main_pix_fmts_yuv422)) ||
 !(overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv422))) 
{
@@ -565,6 +580,7 @@ static av_always_inline void 
blend_plane_##depth##_##nbits##bits(AVFilterContext
 }  
\
 }
 DEFINE_BLEND_PLANE(8, 8);
+DEFINE_BLEND_PLANE(16, 10);
 
 #define DEFINE_ALPHA_COMPOSITE(depth, nbits)   
\
 static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, 
const AVFrame *dst, \
@@ -616,6 +632,7 @@ static inline void 
alpha_composite_##depth##_##nbits##bits(const AVFrame *src, c
 }  
\
 }
 DEFINE_ALPHA_COMPOSITE(8, 8);
+DEFINE_ALPHA_COMPOSITE(16, 10);
 
 #define DEFINE_BLEND_SLICE_YUV(depth, nbits)   
\
 static av_always_inline void 
blend_slice_yuv_##depth##_##nbits##bits(AVFilterContext *ctx,   
  \
@@ -646,6 +663,7 @@ static av_always_inline void 
blend_slice_yuv_##depth##_##nbits##bits(AVFilterCon
 alpha_composite_##depth##_##nbits##bits(src, dst, src_w, src_h, dst_w, 
dst_h, x, y, jobnr, nb_jobs);   \
 }
 DEFINE_BLEND_SLICE_YUV(8, 8);
+DEFINE_BLEND_SLICE_YUV(16, 10);
 
 static av_always_inline void blend_slice_planar_rgb(AVFilterContext *ctx,
 AVFrame *dst, const 
AVFrame *src,
@@ -692,6 +710,21 @@ static int blend_slice_yuva420(AVFilterContext *ctx, void 
*arg, int jobnr, int n
 return 0;
 }
 
+static int blend_slice_yuv420p10(AVFilterContext *ctx, void *arg, int jobnr, 
int nb_jobs)
+{
+OverlayContext *s = ctx->priv;
+ThreadData *td = arg;
+blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 0, s->x, s->y, 1, 
jobnr, nb_jobs);
+return 0;
+}
+
+static int blend_slice_yuva420p10(AVFilterContext *ctx, void *arg, int jobnr, 
int nb_jobs)
+{
+OverlayContext *s = ctx->priv;
+ThreadData *td = arg;
+blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 1, s->x, s->y, 1, 
jobnr, nb_jobs);
+return 0;
+}
 static int blend_slice_yuv422(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
 {
 OverlayContext *s = ctx->priv;
@@ -855,6 +888,9 @@ static int config_input_main(AVFilterLink *inlink)
 case OVERLAY_FORMAT_YUV420:
 s->blend_slice = s->main_has_alpha ? blend_slice_yuva420 : 
blend_slice_yuv420;
 break;
+case OVERLAY_FORMAT_YUV420P10:
+s->blend_slice = s->main_has_alpha ? blend_slice_yuva420p10 : 
blend_slice_yuv420p10;
+break;
 case OVERLAY_FORMAT_YUV422:
 s->blend_slice = 

Re: [FFmpeg-devel] [PATCH 6/7] libavfilter/vf_overlay.c: using the nbits and depth for 8bits and 10bit support

2019-05-25 Thread Lance Wang
On Sat, May 25, 2019 at 7:52 PM Michael Niedermayer 
wrote:

> On Fri, May 24, 2019 at 05:36:15PM +0800, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> >
> > ---
> >  libavfilter/vf_overlay.c | 69 +---
> >  1 file changed, 44 insertions(+), 25 deletions(-)
>
> breaks build
>
> CC  libavfilter/vf_overlay.o
> libavfilter/vf_overlay.c: In function ‘blend_plane_8_8bits’:
> libavfilter/vf_overlay.c:567:972: warning: unused variable ‘mid’
> [-Wunused-variable]
>  DEFINE_BLEND_PLANE(8, 8);
>
>
>
>
>
>
>
>
>
>
>
>
>   ^
> libavfilter/vf_overlay.c: In function ‘alpha_composite_8_8bits’:
> libavfilter/vf_overlay.c:622:1: error: case label does not reduce to an
> integer constant
>  DEFINE_ALPHA_COMPOSITE(8, 8);
>  ^
> make: *** [libavfilter/vf_overlay.o] Error 1
> make: Target `all' not remade because of errors.
>
>
>
Sorry, I have tested with other system and fix the build issue now. Please
help to check the new version patch. It's OK with Mac and CentOS linux
system.



> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> If a bugfix only changes things apparently unrelated to the bug with no
> further explanation, that is a good sign that the bugfix is wrong.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/libx265: Support full range videos

2019-05-25 Thread Derek Buitenhuis
On 25/05/2019 22:31, James Almer wrote:
> Ah hell, whatever, just push it. Jeeb pointed out the reason you wrote
> this patch. Reverting this patch in the future should be trivial anyway.

This patch also adds support for checking the AVCOL range. If you object that
strongly to it, I'm sure they don't mind switching to -color_range jpeg. That
works with x264, etc. too.

> Anyone wants to write libavscale and solve this mess?

I've been happily using zimg and libplacebo ;).

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

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

Re: [FFmpeg-devel] [PATCH] avcodec/libx265: Support full range videos

2019-05-25 Thread James Almer
On 5/25/2019 6:03 PM, James Almer wrote:
> On 5/25/2019 12:50 PM, Derek Buitenhuis wrote:
>> On 25/05/2019 04:25, James Almer wrote:
 +
>>>
>>> Unnecessary empty line.
>>
>> Fixed.
>>
>>> Could we not? The idea is to eventually kill these, so we should at
>>> least try to not make them even more widespread...
>>
>> As far as I know, they can't be removed, as there isn't a simple replacement
>> for some of their functionality. Has this changed?
> 
> Paul tried to remove them, but as usual a billion obscure use cases and
> command lines started to behave differently and he gave up. I don't
> recall if the issue was in swscale or lavfi, but one of those seems to
> have some code deeply tied to these pseudo formats and no easy solution
> for it.
> 
>>
>> Either we finally act on their """deprecation""", or we at least have
>> consistent behavior. e.g. libx264.c has almost this exact bit of code, and
>> users would expect libx265.c to behave the same.
> 
> libx264 is a very old encoder. New encoders, including this one, vpx and
> aom, accept only yuv4xxp + color_range value. Is this change really
> necessary? Why did nobody request it before?

Ah hell, whatever, just push it. Jeeb pointed out the reason you wrote
this patch. Reverting this patch in the future should be trivial anyway.

Anyone wants to write libavscale and solve this mess?

> 
>>
>> As far as I'm concerned, until the YUVJ stuff is /actually/ behind 
>> deprecation
>> guards, it's deprecated in name only... for years.
>>
>> - Derek
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>>
> 

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

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

Re: [FFmpeg-devel] [PATCH] avcodec/libx265: Support full range videos

2019-05-25 Thread James Almer
On 5/25/2019 12:50 PM, Derek Buitenhuis wrote:
> On 25/05/2019 04:25, James Almer wrote:
>>> +
>>
>> Unnecessary empty line.
> 
> Fixed.
> 
>> Could we not? The idea is to eventually kill these, so we should at
>> least try to not make them even more widespread...
> 
> As far as I know, they can't be removed, as there isn't a simple replacement
> for some of their functionality. Has this changed?

Paul tried to remove them, but as usual a billion obscure use cases and
command lines started to behave differently and he gave up. I don't
recall if the issue was in swscale or lavfi, but one of those seems to
have some code deeply tied to these pseudo formats and no easy solution
for it.

> 
> Either we finally act on their """deprecation""", or we at least have
> consistent behavior. e.g. libx264.c has almost this exact bit of code, and
> users would expect libx265.c to behave the same.

libx264 is a very old encoder. New encoders, including this one, vpx and
aom, accept only yuv4xxp + color_range value. Is this change really
necessary? Why did nobody request it before?

> 
> As far as I'm concerned, until the YUVJ stuff is /actually/ behind deprecation
> guards, it's deprecated in name only... for years.
> 
> - Derek
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 

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

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

[FFmpeg-devel] [PATCH v5] avformat/ifv: added support for ifv cctv files

2019-05-25 Thread Swaraj Hota
Fixes ticket #2956.

Signed-off-by: Swaraj Hota 
---
Minor changes based on previous discussions.
Seeking is fixed.
---
 Changelog|   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/ifv.c| 304 +++
 libavformat/version.h|   4 +-
 5 files changed, 309 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/ifv.c

diff --git a/Changelog b/Changelog
index e6b209ae0a..e0b27657d7 100644
--- a/Changelog
+++ b/Changelog
@@ -30,6 +30,7 @@ version :
 - colorhold filter
 - xmedian filter
 - asr filter
+- IFV demuxer
 
 
 version 4.1:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index df87c54a58..a434b005a4 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -231,6 +231,7 @@ OBJS-$(CONFIG_ICO_MUXER) += icoenc.o
 OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o
 OBJS-$(CONFIG_IDF_DEMUXER)   += bintext.o sauce.o
 OBJS-$(CONFIG_IFF_DEMUXER)   += iff.o
+OBJS-$(CONFIG_IFV_DEMUXER)   += ifv.o
 OBJS-$(CONFIG_ILBC_DEMUXER)  += ilbc.o
 OBJS-$(CONFIG_ILBC_MUXER)+= ilbc.o
 OBJS-$(CONFIG_IMAGE2_DEMUXER)+= img2dec.o img2.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d316a0529a..cd00834807 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -188,6 +188,7 @@ extern AVOutputFormat ff_ico_muxer;
 extern AVInputFormat  ff_idcin_demuxer;
 extern AVInputFormat  ff_idf_demuxer;
 extern AVInputFormat  ff_iff_demuxer;
+extern AVInputFormat  ff_ifv_demuxer;
 extern AVInputFormat  ff_ilbc_demuxer;
 extern AVOutputFormat ff_ilbc_muxer;
 extern AVInputFormat  ff_image2_demuxer;
diff --git a/libavformat/ifv.c b/libavformat/ifv.c
new file mode 100644
index 00..03c682bb9d
--- /dev/null
+++ b/libavformat/ifv.c
@@ -0,0 +1,304 @@
+/*
+ * IFV demuxer
+ *
+ * Copyright (c) 2019 Swaraj Hota
+ *
+ * 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 "avformat.h"
+#include "internal.h"
+#include "avio_internal.h"
+
+typedef struct IFVContext {
+uint32_t next_video_index;
+uint32_t next_audio_index;
+uint32_t total_vframes;
+uint32_t total_aframes;
+
+int width, height;
+int is_audio_present;
+int sample_rate;
+
+int video_stream_index;
+int audio_stream_index;
+} IFVContext;
+
+static int ifv_probe(const AVProbeData *p)
+{
+static const uint8_t ifv_magic[] = {0x11, 0xd2, 0xd3, 0xab, 0xba, 0xa9,
+0xcf, 0x11, 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65, 0x44};
+
+if (!memcmp(p->buf, ifv_magic, sizeof(ifv_magic)))
+return AVPROBE_SCORE_MAX;
+
+return 0;
+}
+
+static int read_index(AVFormatContext *s,
+  enum AVMediaType frame_type,
+  uint32_t start_index)
+{
+IFVContext *ifv = s->priv_data;
+AVStream *st;
+int64_t pos, size, timestamp;
+uint32_t end_index, i;
+int ret;
+
+if (frame_type == AVMEDIA_TYPE_VIDEO) {
+end_index = ifv->total_vframes;
+st = s->streams[ifv->video_stream_index];
+} else {
+end_index = ifv->total_aframes;
+st = s->streams[ifv->audio_stream_index];
+}
+
+for (i = start_index; i < end_index; i++) {
+pos = avio_rl32(s->pb);
+size = avio_rl32(s->pb);
+
+avio_skip(s->pb, 8);
+timestamp = avio_rl32(s->pb);
+
+ret = av_add_index_entry(st, pos, timestamp, size, 0, 0);
+if (ret < 0)
+return ret;
+
+avio_skip(s->pb, frame_type == AVMEDIA_TYPE_VIDEO ? 8: 4);
+}
+
+return 0;
+}
+
+static int parse_header(AVFormatContext *s)
+{
+IFVContext *ifv = s->priv_data;
+uint32_t aud_magic;
+uint32_t vid_magic;
+
+avio_skip(s->pb, 0x5c);
+ifv->width = avio_rl16(s->pb);
+ifv->height = avio_rl16(s->pb);
+
+avio_skip(s->pb, 0x8);
+vid_magic = avio_rl32(s->pb);
+
+if (vid_magic != MKTAG('H','2','6','4'))
+avpriv_request_sample(s, "Unknown video codec %x", vid_magic);
+
+avio_skip(s->pb, 0x2c);
+ifv->sample_rate = avio_rl32(s->pb);
+aud_magic = avio_rl32(s->pb);
+
+if (aud_magic == MKTAG('G','R','A','W')) {
+ifv->is_audio_present = 1;
+} else if 

Re: [FFmpeg-devel] [FFMPEG DEVEL] [PATCH v6] fftools/ffprobe: Add S12M Timecode output as side data (such as SEI TC)

2019-05-25 Thread Antonin Gouzer
Hello,
Shame on me, I didn't test the patch with the json format, only xml and flat.
It's ok now.
ok for XML too.

Thanks!


Le sam. 25 mai 2019 à 00:27, Marton Balint  a écrit :
>
>
>
> On Fri, 24 May 2019, Antonin Gouzer wrote:
>
> > ---
> > Add S12M Timecode output with the show_frame option
> > Multiple timecodes (3) for one frame support
> > Control side date Size to 16
> > Correct ffrpobe.xsd to allow multiple timecodes in side_data element
> > ---
> > doc/ffprobe.xsd   |  8 
> > fftools/ffprobe.c | 14 +-
> > 2 files changed, 21 insertions(+), 1 deletion(-)
>
> I almost committed this, but found another issue: the JSON output
> contained the "timecode" key multiple times. Apparently in order for the
> JSON output to work, we need a separate section for arrays.
>
> I managed to make those changes (see the attached patch), it affected the
> XML output slightly as well. Please let me know if this is satisfactory to
> you.
>
> Thanks,
> Marton___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] swresample/swresample: check for invalid sample rates

2019-05-25 Thread Paul B Mahol
On 5/25/19, Michael Niedermayer  wrote:
> On Fri, May 24, 2019 at 06:05:42PM +0200, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libswresample/swresample.c | 8 
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/libswresample/swresample.c b/libswresample/swresample.c
>> index 6d28e6a798..1ac5ef9a30 100644
>> --- a/libswresample/swresample.c
>> +++ b/libswresample/swresample.c
>> @@ -164,6 +164,14 @@ av_cold int swr_init(struct SwrContext *s){
>>  return AVERROR(EINVAL);
>>  }
>>
>> +if(s-> in_sample_rate <= 0){
>> +av_log(s, AV_LOG_ERROR, "Requested input sample rate %d is
>> invalid\n", s->in_sample_rate);
>> +return AVERROR(EINVAL);
>> +}
>> +if(s->out_sample_rate <= 0){
>> +av_log(s, AV_LOG_ERROR, "Requested output sample rate %d is
>> invalid\n", s->out_sample_rate);
>> +return AVERROR(EINVAL);
>> +}
>
> probably ok
>
> Only hypothetical issue i could see is convering sample types or channel
> layout with unspecified sample rate, that is both 0.
> dont know if that works currently but it at least semantically would make
> sense

It does not work, it reach floating-point exception and crashes.
(outlink sample rate set to 0 and input sample rate set to 48000)

>
> Thanks
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> I know you won't believe me, but the highest form of Human Excellence is
> to question oneself and others. -- Socrates
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] swresample/swresample: check for invalid sample rates

2019-05-25 Thread Michael Niedermayer
On Sat, May 25, 2019 at 06:45:01PM +0200, Hendrik Leppkes wrote:
> On Sat, May 25, 2019 at 5:58 PM Michael Niedermayer
>  wrote:
> >
> > On Fri, May 24, 2019 at 06:05:42PM +0200, Paul B Mahol wrote:
> > > Signed-off-by: Paul B Mahol 
> > > ---
> > >  libswresample/swresample.c | 8 
> > >  1 file changed, 8 insertions(+)
> > >
> > > diff --git a/libswresample/swresample.c b/libswresample/swresample.c
> > > index 6d28e6a798..1ac5ef9a30 100644
> > > --- a/libswresample/swresample.c
> > > +++ b/libswresample/swresample.c
> > > @@ -164,6 +164,14 @@ av_cold int swr_init(struct SwrContext *s){
> > >  return AVERROR(EINVAL);
> > >  }
> > >
> > > +if(s-> in_sample_rate <= 0){
> > > +av_log(s, AV_LOG_ERROR, "Requested input sample rate %d is 
> > > invalid\n", s->in_sample_rate);
> > > +return AVERROR(EINVAL);
> > > +}
> > > +if(s->out_sample_rate <= 0){
> > > +av_log(s, AV_LOG_ERROR, "Requested output sample rate %d is 
> > > invalid\n", s->out_sample_rate);
> > > +return AVERROR(EINVAL);
> > > +}
> >
> > probably ok
> >
> > Only hypothetical issue i could see is convering sample types or channel
> > layout with unspecified sample rate, that is both 0.
> > dont know if that works currently but it at least semantically would make
> > sense
> >
> 
> Unspecified channel layout can at least make some sense, since you
> still have the channel count to properly handle the audio data, but
> unspecified sample rate? How would that ever work?

you sure can convert 0.5 0.0 1.0 to 128 0 255 you do not need to know
the sample rate.
For a real life example, that would be a raw pcm file, to convert it
from 32bit float to 16bit signed int only that needs to be known
neither the number of channels nor the sample rate is needed

or said differently, for this example, you could set the sample rate
to anything it would not affect the output. So it is basically not
needed for the process

not saying this is worth supporting. Just that it could be supported
and the case at least to me makes sense ...

thanks

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

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus


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

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

[FFmpeg-devel] HLS-decoding question

2019-05-25 Thread Thomas Schmiedl

Hello,

I read the note on the mailing-lists page "It is not for development of
software that use the FFmpeg libraries...", but I hope someone could
help me (I have only few development knowledge in scripting languages).

I use the xupnpd2-mediaserver (https://github.com/clark15b/xupnpd2) to
display some HLS-streams on the TV. The software would have to be
extended by HTTPS and the HLS processing adapted (eg for HLS streams
from https://www.mall.tv/zive). Unfortunately, the original author does
not answer anymore.

My idea is to use the ffmpeg libs for the correct HLS-processing for
https://www.mall.tv/zive in xupnpd2. I hope someone could help me to
integrate this.

Thanks and regards,
Thomas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] swresample/swresample: check for invalid sample rates

2019-05-25 Thread Hendrik Leppkes
On Sat, May 25, 2019 at 5:58 PM Michael Niedermayer
 wrote:
>
> On Fri, May 24, 2019 at 06:05:42PM +0200, Paul B Mahol wrote:
> > Signed-off-by: Paul B Mahol 
> > ---
> >  libswresample/swresample.c | 8 
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/libswresample/swresample.c b/libswresample/swresample.c
> > index 6d28e6a798..1ac5ef9a30 100644
> > --- a/libswresample/swresample.c
> > +++ b/libswresample/swresample.c
> > @@ -164,6 +164,14 @@ av_cold int swr_init(struct SwrContext *s){
> >  return AVERROR(EINVAL);
> >  }
> >
> > +if(s-> in_sample_rate <= 0){
> > +av_log(s, AV_LOG_ERROR, "Requested input sample rate %d is 
> > invalid\n", s->in_sample_rate);
> > +return AVERROR(EINVAL);
> > +}
> > +if(s->out_sample_rate <= 0){
> > +av_log(s, AV_LOG_ERROR, "Requested output sample rate %d is 
> > invalid\n", s->out_sample_rate);
> > +return AVERROR(EINVAL);
> > +}
>
> probably ok
>
> Only hypothetical issue i could see is convering sample types or channel
> layout with unspecified sample rate, that is both 0.
> dont know if that works currently but it at least semantically would make
> sense
>

Unspecified channel layout can at least make some sense, since you
still have the channel count to properly handle the audio data, but
unspecified sample rate? How would that ever work?

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

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

Re: [FFmpeg-devel] [PATCH] swresample/swresample: check for invalid sample rates

2019-05-25 Thread Michael Niedermayer
On Fri, May 24, 2019 at 06:05:42PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libswresample/swresample.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/libswresample/swresample.c b/libswresample/swresample.c
> index 6d28e6a798..1ac5ef9a30 100644
> --- a/libswresample/swresample.c
> +++ b/libswresample/swresample.c
> @@ -164,6 +164,14 @@ av_cold int swr_init(struct SwrContext *s){
>  return AVERROR(EINVAL);
>  }
>  
> +if(s-> in_sample_rate <= 0){
> +av_log(s, AV_LOG_ERROR, "Requested input sample rate %d is 
> invalid\n", s->in_sample_rate);
> +return AVERROR(EINVAL);
> +}
> +if(s->out_sample_rate <= 0){
> +av_log(s, AV_LOG_ERROR, "Requested output sample rate %d is 
> invalid\n", s->out_sample_rate);
> +return AVERROR(EINVAL);
> +}

probably ok

Only hypothetical issue i could see is convering sample types or channel
layout with unspecified sample rate, that is both 0.
dont know if that works currently but it at least semantically would make
sense

Thanks

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

I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates


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

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

Re: [FFmpeg-devel] [PATCH] avcodec/libx265: Support full range videos

2019-05-25 Thread Derek Buitenhuis
On 25/05/2019 04:25, James Almer wrote:
>> +
> 
> Unnecessary empty line.

Fixed.

> Could we not? The idea is to eventually kill these, so we should at
> least try to not make them even more widespread...

As far as I know, they can't be removed, as there isn't a simple replacement
for some of their functionality. Has this changed?

Either we finally act on their """deprecation""", or we at least have
consistent behavior. e.g. libx264.c has almost this exact bit of code, and
users would expect libx265.c to behave the same.

As far as I'm concerned, until the YUVJ stuff is /actually/ behind deprecation
guards, it's deprecated in name only... for years.

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

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

Re: [FFmpeg-devel] [PATCH 2/3] avcodec/nvenc: add master display and light level sei for HDR10

2019-05-25 Thread James Almer
On 5/22/2019 3:59 AM, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> The testing command for the HDR10 output with nvenc:
> $ ./ffmpeg_g -y -i 4K.mp4 -c:v hevc_nvenc -g 7 -color_primaries bt2020 
> -colorspace bt2020_ncl -color_trc smpte2084 -sei hdr10 \
> -master_display 
> "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(1000,50)" 
> -max_cll "0, 0" test.ts
> 
> Please notice it is preferable to use the frame sei side data than 
> master_display and max_cll paramters config
> ---
>  libavcodec/nvenc.c  | 129 
>  libavcodec/nvenc.h  |  18 ++
>  libavcodec/nvenc_hevc.c |  11 
>  3 files changed, 158 insertions(+)
> 
> diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
> index 75dda6d689..3fd0eca4a5 100644
> --- a/libavcodec/nvenc.c
> +++ b/libavcodec/nvenc.c
> @@ -22,6 +22,9 @@
>  #include "config.h"
>  
>  #include "nvenc.h"
> +#include "cbs_h265.h"

This doesn't seem right. The encoder isn't using this framework at all.

You're apparently including this only to get the
H265RawSEIMasteringDisplayColourVolume and
H265RawSEIContentLightLevelInfo structs, which you don't really need to
fill sei_data[i].payload

> +#include "hevc_sei.h"
> +#include "put_bits.h"
>  
>  #include "libavutil/hwcontext_cuda.h"
>  #include "libavutil/hwcontext.h"
> @@ -30,6 +33,7 @@
>  #include "libavutil/avassert.h"
>  #include "libavutil/mem.h"
>  #include "libavutil/pixdesc.h"
> +#include "libavutil/mastering_display_metadata.h"
>  #include "internal.h"
>  
>  #define CHECK_CU(x) FF_CUDA_CHECK_DL(avctx, dl_fn->cuda_dl, x)
> @@ -1491,6 +1495,46 @@ av_cold int ff_nvenc_encode_init(AVCodecContext *avctx)
>  ctx->data_pix_fmt = avctx->pix_fmt;
>  }
>  
> +ctx->display_primaries_x[0] = 13250;
> +ctx->display_primaries_y[0] = 34500;
> +ctx->display_primaries_x[1] = 7500;
> +ctx->display_primaries_y[1] = 3000;
> +ctx->display_primaries_x[2] = 34000;
> +ctx->display_primaries_y[2] = 16000;
> +ctx->white_point_x  = 15635;
> +ctx->white_point_y  = 16450;
> +ctx->max_display_mastering_luminance = 1000;
> +ctx->min_display_mastering_luminance = 500;
> +ctx->max_content_light_level = 0;
> +ctx->max_pic_average_light_level = 0;
> +if (ctx->master_display) {
> +ret = sscanf(ctx->master_display, 
> "G(%hu,%hu)B(%hu,%hu)R(%hu,%hu)WP(%hu,%hu)L(%u,%u)",
> +>display_primaries_x[0], >display_primaries_y[0],
> +>display_primaries_x[1], >display_primaries_y[1],
> +>display_primaries_x[2], >display_primaries_y[2],
> +>white_point_x, >white_point_y,
> +>max_display_mastering_luminance, 
> >min_display_mastering_luminance);
> +if (ret != 10) {
> +ret = sscanf(ctx->master_display, 
> "G[%hu,%hu]B[%hu,%hu]R[%hu,%hu]WP[%hu,%hu]L[%u,%u]",
> +>display_primaries_x[0], >display_primaries_y[0],
> +>display_primaries_x[1], >display_primaries_y[1],
> +>display_primaries_x[2], >display_primaries_y[2],
> +>white_point_x, >white_point_y,
> +>max_display_mastering_luminance, 
> >min_display_mastering_luminance);
> +}
> +
> +if (ret != 10) {
> +av_log(avctx, AV_LOG_INFO, "Failed to parse master 
> display(%s)\n", ctx->master_display);
> +}
> +}
> +
> +if (ctx->max_cll) {
> +ret = sscanf(ctx->max_cll, "%hu,%hu", >max_content_light_level, 
> >max_pic_average_light_level);
> +if (ret != 2) {
> +av_log(avctx, AV_LOG_INFO, "Failed to parse max cll(%s)\n", 
> ctx->max_cll);
> +}
> +}
> +
>  if ((ret = nvenc_load_libraries(avctx)) < 0)
>  return ret;
>  
> @@ -2110,6 +2154,91 @@ int ff_nvenc_send_frame(AVCodecContext *avctx, const 
> AVFrame *frame)
>  }
>  }
>  
> +if (ctx->sei  & SEI_MASTERING_DISPLAY) {
> +AVFrameSideData *sd = av_frame_get_side_data(frame, 
> AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
> +H265RawSEIMasteringDisplayColourVolume smd;
> +
> +if (sd) {
> +AVMasteringDisplayMetadata *mdm = 
> (AVMasteringDisplayMetadata *)sd->data;
> +// HEVC uses a g,b,r ordering, which we convert from a more 
> natural r,g,b
> +const int mapping[3] = {2, 0, 1};
> +const int chroma_den = 5;
> +const int luma_den = 1;
> +
> +if (mdm->has_primaries && mdm->has_luminance) {
> +
> +for (i = 0; i < 3; i++) {
> +const int j = mapping[i];
> +smd.display_primaries_x[i] = chroma_den * 
> av_q2d(mdm->display_primaries[j][0]);
> +smd.display_primaries_y[i] = chroma_den * av_q2d( 
> mdm->display_primaries[j][1]);
> +}
> +
> +smd.white_point_x = 

Re: [FFmpeg-devel] [PATCH] avformat/segment: populate empty outer stream extradata from packet

2019-05-25 Thread Gyan



On 23-05-2019 06:40 PM, Gyan wrote:



On 21-05-2019 06:59 PM, Gyan wrote:

Fixes playback in QT for me.

Gyan



Ping.


Pong.

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

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

Re: [FFmpeg-devel] [PATCH V1 2/2] lavfi/sr: Remove slice thread flag

2019-05-25 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Jun Zhao
> Sent: Saturday, May 25, 2019 8:17 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Jun Zhao 
> Subject: [FFmpeg-devel] [PATCH V1 2/2] lavfi/sr: Remove slice thread flag
> 
> From: Jun Zhao 
> 
> sr didn't enable the slice threading, so remove the flag
> 
> Signed-off-by: Jun Zhao 
> ---
>  libavfilter/vf_sr.c |3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> diff --git a/libavfilter/vf_sr.c b/libavfilter/vf_sr.c index 95bd3b7..86dc551
> 100644
> --- a/libavfilter/vf_sr.c
> +++ b/libavfilter/vf_sr.c
> @@ -317,6 +317,5 @@ AVFilter ff_vf_sr = {
>  .inputs= sr_inputs,
>  .outputs   = sr_outputs,
>  .priv_class= _class,
> -.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC |
> AVFILTER_FLAG_SLICE_THREADS,
> +.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
>  };
> -
> --
> 1.7.1

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

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

Re: [FFmpeg-devel] [PATCH v1 2/2] fftools/ffmpeg: add exif orientation support per frame's metadata

2019-05-25 Thread Michael Niedermayer
On Fri, May 24, 2019 at 05:04:27PM -0700, Jun Li wrote:
> Fix #6945
> Rotate or/and flip frame according to frame's metadata orientation
> ---
>  fftools/ffmpeg.c|  3 ++-
>  fftools/ffmpeg.h|  3 ++-
>  fftools/ffmpeg_filter.c | 19 ++-
>  3 files changed, 22 insertions(+), 3 deletions(-)

This breaks 227 fate tests here


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

Take away the freedom of one citizen and you will be jailed, take away
the freedom of all citizens and you will be congratulated by your peers
in Parliament.


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

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

Re: [FFmpeg-devel] [PATCH v4] avformat/ifv: added support for ifv cctv files

2019-05-25 Thread Peter Ross
On Sat, May 25, 2019 at 01:59:44PM +0200, Paul B Mahol wrote:
> On 5/25/19, Swaraj Hota  wrote:
> > Fixes ticket #2956.
> >
> > Signed-off-by: Swaraj Hota 
> > ---
> > Changes made based on previous discussions.
> >
> > Now the demuxer is working pretty much as the original dvr player does.
> > Framerate is based on timestamps (hence correct). Seeking is working for
> > all files without any issue.

more comments below.

> > ---
> >  Changelog|   1 +
> >  libavformat/Makefile |   1 +
> >  libavformat/allformats.c |   1 +
> >  libavformat/ifv.c| 318 +++
> >  libavformat/version.h|   4 +-
> >  5 files changed, 323 insertions(+), 2 deletions(-)
> >  create mode 100644 libavformat/ifv.c
> >
> > diff --git a/Changelog b/Changelog
> > index e6b209ae0a..e0b27657d7 100644
> > --- a/Changelog
> > +++ b/Changelog
> > @@ -30,6 +30,7 @@ version :
> >  - colorhold filter
> >  - xmedian filter
> >  - asr filter
> > +- IFV demuxer
> >
> >
> >  version 4.1:
> > diff --git a/libavformat/Makefile b/libavformat/Makefile
> > index df87c54a58..a434b005a4 100644
> > --- a/libavformat/Makefile
> > +++ b/libavformat/Makefile
> > @@ -231,6 +231,7 @@ OBJS-$(CONFIG_ICO_MUXER) += icoenc.o
> >  OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o
> >  OBJS-$(CONFIG_IDF_DEMUXER)   += bintext.o sauce.o
> >  OBJS-$(CONFIG_IFF_DEMUXER)   += iff.o
> > +OBJS-$(CONFIG_IFV_DEMUXER)   += ifv.o
> >  OBJS-$(CONFIG_ILBC_DEMUXER)  += ilbc.o
> >  OBJS-$(CONFIG_ILBC_MUXER)+= ilbc.o
> >  OBJS-$(CONFIG_IMAGE2_DEMUXER)+= img2dec.o img2.o
> > diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> > index d316a0529a..cd00834807 100644
> > --- a/libavformat/allformats.c
> > +++ b/libavformat/allformats.c
> > @@ -188,6 +188,7 @@ extern AVOutputFormat ff_ico_muxer;
> >  extern AVInputFormat  ff_idcin_demuxer;
> >  extern AVInputFormat  ff_idf_demuxer;
> >  extern AVInputFormat  ff_iff_demuxer;
> > +extern AVInputFormat  ff_ifv_demuxer;
> >  extern AVInputFormat  ff_ilbc_demuxer;
> >  extern AVOutputFormat ff_ilbc_muxer;
> >  extern AVInputFormat  ff_image2_demuxer;
> > diff --git a/libavformat/ifv.c b/libavformat/ifv.c
> > new file mode 100644
> > index 00..517f0252f5
> > --- /dev/null
> > +++ b/libavformat/ifv.c
> > @@ -0,0 +1,318 @@
> > +/*
> > + * IFV demuxer
> > + *
> > + * Copyright (c) 2019 Swaraj Hota
> > + *
> > + * 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 "avformat.h"
> > +#include "internal.h"
> > +#include "avio_internal.h"
> > +
> > +
> > +typedef struct IFVContext {
> > +uint32_t next_video_index;
> > +uint32_t next_audio_index;
> > +uint32_t total_vframes;
> > +uint32_t total_aframes;
> > +
> > +int width, height;
> > +int is_audio_present;
> > +int sample_rate;
> > +
> > +int video_stream_index;
> > +int audio_stream_index;
> > +} IFVContext;
> > +
> > +static int ifv_probe(const AVProbeData *p)
> > +{
> > +static const uint8_t ifv_magic[] = {0x11, 0xd2, 0xd3, 0xab, 0xba, 0xa9,
> > +0xcf, 0x11, 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65, 0x44};
> > +
> > +if (!memcmp(p->buf, ifv_magic, sizeof(ifv_magic)))
> > +return AVPROBE_SCORE_MAX;
> > +
> > +return 0;
> > +}
> > +
> > +static int read_index(AVFormatContext *s,
> > +  enum AVMediaType frame_type,
> > +  uint32_t start_index)
> > +{
> > +IFVContext *ifv = s->priv_data;
> > +AVStream *st;
> > +int64_t pos, size, timestamp;
> > +uint32_t end_index, i;
> > +int ret;
> > +
> > +if (frame_type == AVMEDIA_TYPE_VIDEO) {
> > +end_index = ifv->total_vframes;
> > +st = s->streams[ifv->video_stream_index];
> > +} else {
> > +end_index = ifv->total_aframes;
> > +st = s->streams[ifv->audio_stream_index];
> > +}
> > +
> > +for (i = start_index; i < end_index; i++) {
> > +pos = avio_rl32(s->pb);
> > +size = avio_rl32(s->pb);
> > +
> > +avio_skip(s->pb, 8);
> > +timestamp = avio_rl32(s->pb);
> > +
> > +ret = 

[FFmpeg-devel] [PATCH V1 1/2] lavfi/sr: Change the backend type from flags to int

2019-05-25 Thread Jun Zhao
From: Jun Zhao 

native and tensorflow is exclusive, so change the type from
flags to int.

Signed-off-by: Jun Zhao 
---
 libavfilter/vf_sr.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavfilter/vf_sr.c b/libavfilter/vf_sr.c
index 65baf5f..95bd3b7 100644
--- a/libavfilter/vf_sr.c
+++ b/libavfilter/vf_sr.c
@@ -50,7 +50,7 @@ typedef struct SRContext {
 #define OFFSET(x) offsetof(SRContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
 static const AVOption sr_options[] = {
-{ "dnn_backend", "DNN backend used for model execution", 
OFFSET(backend_type), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, 1, FLAGS, "backend" },
+{ "dnn_backend", "DNN backend used for model execution", 
OFFSET(backend_type), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS, "backend" },
 { "native", "native backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 
0, FLAGS, "backend" },
 #if (CONFIG_LIBTENSORFLOW == 1)
 { "tensorflow", "tensorflow backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = 
1 }, 0, 0, FLAGS, "backend" },
-- 
1.7.1

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

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

[FFmpeg-devel] [PATCH V1 2/2] lavfi/sr: Remove slice thread flag

2019-05-25 Thread Jun Zhao
From: Jun Zhao 

sr didn't enable the slice threading, so remove the flag

Signed-off-by: Jun Zhao 
---
 libavfilter/vf_sr.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_sr.c b/libavfilter/vf_sr.c
index 95bd3b7..86dc551 100644
--- a/libavfilter/vf_sr.c
+++ b/libavfilter/vf_sr.c
@@ -317,6 +317,5 @@ AVFilter ff_vf_sr = {
 .inputs= sr_inputs,
 .outputs   = sr_outputs,
 .priv_class= _class,
-.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | 
AVFILTER_FLAG_SLICE_THREADS,
+.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 };
-
-- 
1.7.1

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

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

Re: [FFmpeg-devel] [PATCH v4] avformat/ifv: added support for ifv cctv files

2019-05-25 Thread Paul B Mahol
On 5/25/19, Swaraj Hota  wrote:
> Fixes ticket #2956.
>
> Signed-off-by: Swaraj Hota 
> ---
> Changes made based on previous discussions.
>
> Now the demuxer is working pretty much as the original dvr player does.
> Framerate is based on timestamps (hence correct). Seeking is working for
> all files without any issue.
> ---
>  Changelog|   1 +
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/ifv.c| 318 +++
>  libavformat/version.h|   4 +-
>  5 files changed, 323 insertions(+), 2 deletions(-)
>  create mode 100644 libavformat/ifv.c
>
> diff --git a/Changelog b/Changelog
> index e6b209ae0a..e0b27657d7 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -30,6 +30,7 @@ version :
>  - colorhold filter
>  - xmedian filter
>  - asr filter
> +- IFV demuxer
>
>
>  version 4.1:
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index df87c54a58..a434b005a4 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -231,6 +231,7 @@ OBJS-$(CONFIG_ICO_MUXER) += icoenc.o
>  OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o
>  OBJS-$(CONFIG_IDF_DEMUXER)   += bintext.o sauce.o
>  OBJS-$(CONFIG_IFF_DEMUXER)   += iff.o
> +OBJS-$(CONFIG_IFV_DEMUXER)   += ifv.o
>  OBJS-$(CONFIG_ILBC_DEMUXER)  += ilbc.o
>  OBJS-$(CONFIG_ILBC_MUXER)+= ilbc.o
>  OBJS-$(CONFIG_IMAGE2_DEMUXER)+= img2dec.o img2.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index d316a0529a..cd00834807 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -188,6 +188,7 @@ extern AVOutputFormat ff_ico_muxer;
>  extern AVInputFormat  ff_idcin_demuxer;
>  extern AVInputFormat  ff_idf_demuxer;
>  extern AVInputFormat  ff_iff_demuxer;
> +extern AVInputFormat  ff_ifv_demuxer;
>  extern AVInputFormat  ff_ilbc_demuxer;
>  extern AVOutputFormat ff_ilbc_muxer;
>  extern AVInputFormat  ff_image2_demuxer;
> diff --git a/libavformat/ifv.c b/libavformat/ifv.c
> new file mode 100644
> index 00..517f0252f5
> --- /dev/null
> +++ b/libavformat/ifv.c
> @@ -0,0 +1,318 @@
> +/*
> + * IFV demuxer
> + *
> + * Copyright (c) 2019 Swaraj Hota
> + *
> + * 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 "avformat.h"
> +#include "internal.h"
> +#include "avio_internal.h"
> +
> +
> +typedef struct IFVContext {
> +uint32_t next_video_index;
> +uint32_t next_audio_index;
> +uint32_t total_vframes;
> +uint32_t total_aframes;
> +
> +int width, height;
> +int is_audio_present;
> +int sample_rate;
> +
> +int video_stream_index;
> +int audio_stream_index;
> +} IFVContext;
> +
> +static int ifv_probe(const AVProbeData *p)
> +{
> +static const uint8_t ifv_magic[] = {0x11, 0xd2, 0xd3, 0xab, 0xba, 0xa9,
> +0xcf, 0x11, 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65, 0x44};
> +
> +if (!memcmp(p->buf, ifv_magic, sizeof(ifv_magic)))
> +return AVPROBE_SCORE_MAX;
> +
> +return 0;
> +}
> +
> +static int read_index(AVFormatContext *s,
> +  enum AVMediaType frame_type,
> +  uint32_t start_index)
> +{
> +IFVContext *ifv = s->priv_data;
> +AVStream *st;
> +int64_t pos, size, timestamp;
> +uint32_t end_index, i;
> +int ret;
> +
> +if (frame_type == AVMEDIA_TYPE_VIDEO) {
> +end_index = ifv->total_vframes;
> +st = s->streams[ifv->video_stream_index];
> +} else {
> +end_index = ifv->total_aframes;
> +st = s->streams[ifv->audio_stream_index];
> +}
> +
> +for (i = start_index; i < end_index; i++) {
> +pos = avio_rl32(s->pb);
> +size = avio_rl32(s->pb);
> +
> +avio_skip(s->pb, 8);
> +timestamp = avio_rl32(s->pb);
> +
> +ret = av_add_index_entry(st, pos, timestamp, size, 0, 0);
> +if (ret < 0)
> +return ret;
> +
> +avio_skip(s->pb, frame_type == AVMEDIA_TYPE_VIDEO? 8: 4);
> +}
> +
> +return 0;
> +}
> +
> +static int parse_header(AVFormatContext *s)
> +{
> +IFVContext *ifv = s->priv_data;
> +uint32_t aud_magic;
> +uint32_t vid_magic;
> +
> +

[FFmpeg-devel] [PATCH] avfilter: add showspatial multimedia filter

2019-05-25 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi  |  52 +
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/avf_showspatial.c | 384 ++
 4 files changed, 438 insertions(+)
 create mode 100644 libavfilter/avf_showspatial.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 4fdcfe919e..60df5bf35b 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -22248,6 +22248,58 @@ Set minimum amplitude used in @code{log} amplitude 
scaler.
 
 @end table
 
+@section showspatial
+
+Convert stereo input audio to a video output, representing the spatial 
relationship
+between two channels.
+
+The filter accepts the following options:
+
+@table @option
+@item size, s
+Specify the video size for the output. For the syntax of this option, check the
+@ref{video size syntax,,"Video size" section in the ffmpeg-utils 
manual,ffmpeg-utils}.
+Default value is @code{512x512}.
+
+@item win_size
+Set window size. Allowed range is from @var{1024} to @var{65536}. Default size 
is @var{4096}.
+
+@item win_func
+Set window function.
+
+It accepts the following values:
+@table @samp
+@item rect
+@item bartlett
+@item hann
+@item hanning
+@item hamming
+@item blackman
+@item welch
+@item flattop
+@item bharris
+@item bnuttall
+@item bhann
+@item sine
+@item nuttall
+@item lanczos
+@item gauss
+@item tukey
+@item dolph
+@item cauchy
+@item parzen
+@item poisson
+@item bohman
+@end table
+
+Default value is @code{hann}.
+
+@item overlap
+Set ratio of overlap window. Default value is @code{0.5}.
+When value is @code{1} overlap is set to recommended size for specific
+window function currently used.
+@end table
+
 @anchor{showspectrum}
 @section showspectrum
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 9a61c25b05..a99362b3ee 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -465,6 +465,7 @@ OBJS-$(CONFIG_AVECTORSCOPE_FILTER)   += 
avf_avectorscope.o
 OBJS-$(CONFIG_CONCAT_FILTER) += avf_concat.o
 OBJS-$(CONFIG_SHOWCQT_FILTER)+= avf_showcqt.o lswsutils.o 
lavfutils.o
 OBJS-$(CONFIG_SHOWFREQS_FILTER)  += avf_showfreqs.o
+OBJS-$(CONFIG_SHOWSPATIAL_FILTER)+= avf_showspatial.o
 OBJS-$(CONFIG_SHOWSPECTRUM_FILTER)   += avf_showspectrum.o
 OBJS-$(CONFIG_SHOWSPECTRUMPIC_FILTER)+= avf_showspectrum.o
 OBJS-$(CONFIG_SHOWVOLUME_FILTER) += avf_showvolume.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 40534738ee..858ed1cf78 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -443,6 +443,7 @@ extern AVFilter ff_avf_avectorscope;
 extern AVFilter ff_avf_concat;
 extern AVFilter ff_avf_showcqt;
 extern AVFilter ff_avf_showfreqs;
+extern AVFilter ff_avf_showspatial;
 extern AVFilter ff_avf_showspectrum;
 extern AVFilter ff_avf_showspectrumpic;
 extern AVFilter ff_avf_showvolume;
diff --git a/libavfilter/avf_showspatial.c b/libavfilter/avf_showspatial.c
new file mode 100644
index 00..974c9154b3
--- /dev/null
+++ b/libavfilter/avf_showspatial.c
@@ -0,0 +1,384 @@
+/*
+ * Copyright (c) 2019 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 
+
+#include "libavcodec/avfft.h"
+#include "libavutil/audio_fifo.h"
+#include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
+#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
+#include "audio.h"
+#include "video.h"
+#include "avfilter.h"
+#include "filters.h"
+#include "internal.h"
+#include "window_func.h"
+
+typedef struct ShowSpatialContext {
+const AVClass *class;
+int w, h;
+AVRational frame_rate;
+FFTContext *fft[2];   ///< Fast Fourier Transform context
+FFTContext *ifft[2];  ///< Inverse Fast Fourier Transform context
+int fft_bits; ///< number of bits (FFT window size = 
1fft[i]);
+for (i = 0; i < 2; i++)
+av_fft_end(s->ifft[i]);
+for (i = 0; i < 2; i++)
+av_freep(>fft_data[i]);
+av_freep(>window_func_lut);
+av_audio_fifo_free(s->fifo);
+}
+
+static int query_formats(AVFilterContext *ctx)
+{
+AVFilterFormats *formats = 

Re: [FFmpeg-devel] [PATCH 6/7] libavfilter/vf_overlay.c: using the nbits and depth for 8bits and 10bit support

2019-05-25 Thread Michael Niedermayer
On Fri, May 24, 2019 at 05:36:15PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> ---
>  libavfilter/vf_overlay.c | 69 +---
>  1 file changed, 44 insertions(+), 25 deletions(-)

breaks build

CC  libavfilter/vf_overlay.o
libavfilter/vf_overlay.c: In function ‘blend_plane_8_8bits’:
libavfilter/vf_overlay.c:567:972: warning: unused variable ‘mid’ 
[-Wunused-variable]
 DEFINE_BLEND_PLANE(8, 8);












^
libavfilter/vf_overlay.c: In function ‘alpha_composite_8_8bits’:
libavfilter/vf_overlay.c:622:1: error: case label does not reduce to an integer 
constant
 DEFINE_ALPHA_COMPOSITE(8, 8);
 ^
make: *** [libavfilter/vf_overlay.o] Error 1
make: Target `all' not remade because of errors.


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

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.


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

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

[FFmpeg-devel] [PATCH v4] avformat/ifv: added support for ifv cctv files

2019-05-25 Thread Swaraj Hota
Fixes ticket #2956.

Signed-off-by: Swaraj Hota 
---
Changes made based on previous discussions.

Now the demuxer is working pretty much as the original dvr player does.
Framerate is based on timestamps (hence correct). Seeking is working for
all files without any issue.
---
 Changelog|   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/ifv.c| 318 +++
 libavformat/version.h|   4 +-
 5 files changed, 323 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/ifv.c

diff --git a/Changelog b/Changelog
index e6b209ae0a..e0b27657d7 100644
--- a/Changelog
+++ b/Changelog
@@ -30,6 +30,7 @@ version :
 - colorhold filter
 - xmedian filter
 - asr filter
+- IFV demuxer
 
 
 version 4.1:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index df87c54a58..a434b005a4 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -231,6 +231,7 @@ OBJS-$(CONFIG_ICO_MUXER) += icoenc.o
 OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o
 OBJS-$(CONFIG_IDF_DEMUXER)   += bintext.o sauce.o
 OBJS-$(CONFIG_IFF_DEMUXER)   += iff.o
+OBJS-$(CONFIG_IFV_DEMUXER)   += ifv.o
 OBJS-$(CONFIG_ILBC_DEMUXER)  += ilbc.o
 OBJS-$(CONFIG_ILBC_MUXER)+= ilbc.o
 OBJS-$(CONFIG_IMAGE2_DEMUXER)+= img2dec.o img2.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d316a0529a..cd00834807 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -188,6 +188,7 @@ extern AVOutputFormat ff_ico_muxer;
 extern AVInputFormat  ff_idcin_demuxer;
 extern AVInputFormat  ff_idf_demuxer;
 extern AVInputFormat  ff_iff_demuxer;
+extern AVInputFormat  ff_ifv_demuxer;
 extern AVInputFormat  ff_ilbc_demuxer;
 extern AVOutputFormat ff_ilbc_muxer;
 extern AVInputFormat  ff_image2_demuxer;
diff --git a/libavformat/ifv.c b/libavformat/ifv.c
new file mode 100644
index 00..517f0252f5
--- /dev/null
+++ b/libavformat/ifv.c
@@ -0,0 +1,318 @@
+/*
+ * IFV demuxer
+ *
+ * Copyright (c) 2019 Swaraj Hota
+ *
+ * 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 "avformat.h"
+#include "internal.h"
+#include "avio_internal.h"
+
+
+typedef struct IFVContext {
+uint32_t next_video_index;
+uint32_t next_audio_index;
+uint32_t total_vframes;
+uint32_t total_aframes;
+
+int width, height;
+int is_audio_present;
+int sample_rate;
+
+int video_stream_index;
+int audio_stream_index;
+} IFVContext;
+
+static int ifv_probe(const AVProbeData *p)
+{
+static const uint8_t ifv_magic[] = {0x11, 0xd2, 0xd3, 0xab, 0xba, 0xa9,
+0xcf, 0x11, 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65, 0x44};
+
+if (!memcmp(p->buf, ifv_magic, sizeof(ifv_magic)))
+return AVPROBE_SCORE_MAX;
+
+return 0;
+}
+
+static int read_index(AVFormatContext *s,
+  enum AVMediaType frame_type,
+  uint32_t start_index)
+{
+IFVContext *ifv = s->priv_data;
+AVStream *st;
+int64_t pos, size, timestamp;
+uint32_t end_index, i;
+int ret;
+
+if (frame_type == AVMEDIA_TYPE_VIDEO) {
+end_index = ifv->total_vframes;
+st = s->streams[ifv->video_stream_index];
+} else {
+end_index = ifv->total_aframes;
+st = s->streams[ifv->audio_stream_index];
+}
+
+for (i = start_index; i < end_index; i++) {
+pos = avio_rl32(s->pb);
+size = avio_rl32(s->pb);
+
+avio_skip(s->pb, 8);
+timestamp = avio_rl32(s->pb);
+
+ret = av_add_index_entry(st, pos, timestamp, size, 0, 0);
+if (ret < 0)
+return ret;
+
+avio_skip(s->pb, frame_type == AVMEDIA_TYPE_VIDEO? 8: 4);
+}
+
+return 0;
+}
+
+static int parse_header(AVFormatContext *s)
+{
+IFVContext *ifv = s->priv_data;
+uint32_t aud_magic;
+uint32_t vid_magic;
+
+avio_skip(s->pb, 0x5c);
+ifv->width = avio_rl16(s->pb);
+ifv->height = avio_rl16(s->pb);
+
+avio_skip(s->pb, 0x8);
+vid_magic = avio_rl32(s->pb);
+
+if (vid_magic != MKTAG('H','2','6','4'))
+avpriv_request_sample(s, "Unknown video codec %x\n", vid_magic);
+
+avio_skip(s->pb, 0x2c);
+ifv->sample_rate = 

Re: [FFmpeg-devel] [PATCH v1 2/2] fftools/ffmpeg: add exif orientation support per frame's metadata

2019-05-25 Thread Nicolas George
Jun Li (12019-05-24):
> Fix #6945
> Rotate or/and flip frame according to frame's metadata orientation

Since ffmpeg does not handle resolution changes very well, do we want
this enabled by default?

> ---
>  fftools/ffmpeg.c|  3 ++-
>  fftools/ffmpeg.h|  3 ++-
>  fftools/ffmpeg_filter.c | 19 ++-
>  3 files changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 01f04103cf..da4c19c782 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -2142,7 +2142,8 @@ static int ifilter_send_frame(InputFilter *ifilter, 
> AVFrame *frame)
>  break;
>  case AVMEDIA_TYPE_VIDEO:
>  need_reinit |= ifilter->width  != frame->width ||
> -   ifilter->height != frame->height;
> +   ifilter->height != frame->height ||

> +   ifilter->orientation != get_frame_orientation(frame);

I the filter chain does not really need reinit if the orientation change
does not change the output resolution.

It can happen for photos who were all taken in portrait mode, but
sometimes by leaning on the left and sometimes leaning on the right. I
am sorry if these questions I raise seem to complicate matters, but it
is not on purpose: automatic transformation is an issue that has many
direct consequences on the usability of the tools, they need to be at
least considered in the solution.

>  break;
>  }
>  
> diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
> index eb1eaf6363..54532ef0eb 100644
> --- a/fftools/ffmpeg.h
> +++ b/fftools/ffmpeg.h
> @@ -244,7 +244,7 @@ typedef struct InputFilter {
>  // parameters configured for this input
>  int format;
>  
> -int width, height;
> +int width, height, orientation;
>  AVRational sample_aspect_ratio;
>  
>  int sample_rate;
> @@ -649,6 +649,7 @@ int init_complex_filtergraph(FilterGraph *fg);
>  void sub2video_update(InputStream *ist, AVSubtitle *sub);
>  
>  int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame 
> *frame);
> +int get_frame_orientation(const AVFrame* frame);
>  
>  int ffmpeg_parse_options(int argc, char **argv);
>  
> diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
> index 72838de1e2..b230dafdc9 100644
> --- a/fftools/ffmpeg_filter.c
> +++ b/fftools/ffmpeg_filter.c
> @@ -743,6 +743,18 @@ static int sub2video_prepare(InputStream *ist, 
> InputFilter *ifilter)
>  return 0;
>  }
>  
> +int get_frame_orientation(const AVFrame *frame)
> +{
> +AVDictionaryEntry *entry = NULL;
> +int orientation = 1; // orientation indicates 'Normal' 
> +
> +// read exif orientation data
> +entry = av_dict_get(frame->metadata, "Orientation", NULL, 0);

> +if (entry)
> +orientation = atoi(entry->value);
> +return orientation > 8 ? 1 : orientation;

I do not like the defensive programming here. If orientation is invalid,
then it should not be invented, even a same default value.

> +}
> +
>  static int configure_input_video_filter(FilterGraph *fg, InputFilter 
> *ifilter,
>  AVFilterInOut *in)
>  {
> @@ -809,7 +821,11 @@ static int configure_input_video_filter(FilterGraph *fg, 
> InputFilter *ifilter,
>  if (ist->autorotate) {
>  double theta = get_rotation(ist->st);
>  

> -if (fabs(theta - 90) < 1.0) {
> +if (fabs(theta) < 1.0) { // no rotation info in stream meta
> +char transpose_args[32];
> +snprintf(transpose_args, sizeof(transpose_args), 
> "orientation=%i", ifilter->orientation);
> +ret = insert_filter(_filter, _idx, "transpose", 
> transpose_args);

If the frame does not contain orientation metadata, I think the filter
should not be inserted.

> +} else if (fabs(theta - 90) < 1.0) {
>  ret = insert_filter(_filter, _idx, "transpose", 
> "clock");
>  } else if (fabs(theta - 180) < 1.0) {
>  ret = insert_filter(_filter, _idx, "hflip", NULL);

If transpose can take care of all cases, then the other cases need to be
removed, or am I missing something?

> @@ -1191,6 +1207,7 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, 
> const AVFrame *frame)
>  ifilter->width   = frame->width;
>  ifilter->height  = frame->height;
>  ifilter->sample_aspect_ratio = frame->sample_aspect_ratio;
> +ifilter->orientation = get_frame_orientation(frame);
>  
>  ifilter->sample_rate = frame->sample_rate;
>  ifilter->channels= frame->channels;

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH v1 1/2] lavf/vf_transpose: add exif orientation support

2019-05-25 Thread Nicolas George
Jun Li (12019-05-24):
> Add exif orientation support and expose an option.
> ---
>  libavfilter/vf_transpose.c | 258 +
>  1 file changed, 207 insertions(+), 51 deletions(-)

If I read the code correctly, when orientation=1 (unchanged), this code
will copy the frame instead of just passing it unchanged. Did I miss
something?

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] native mode in FFmpeg DNN module

2019-05-25 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of
> Steven Liu
> Sent: Friday, May 24, 2019 11:35 PM
> To: FFmpeg development discussions and patches 
> Cc: Steven Liu 
> Subject: Re: [FFmpeg-devel] native mode in FFmpeg DNN module
> 
> 
> 
> > 在 2019年5月24日,20:34,Pedro Arthur  写
> 道:
> >
> > Em qui, 23 de mai de 2019 às 00:06, Guo, Yejun 
> escreveu:
> >>
> >>
> >>
>  Option 2)
>  Write c code in FFmpeg to convert tensorflow file format (format 1)
>  directly
> >>> into memory representation (format 3), and so we controls everything
> in
> >>> ffmpeg community. And the conversion can be extended to import
> more
>  file
> >>> formats such as torch, darknet, etc. One example is that OpenCV uses
>  this
> >>> method.
> 
>  The in memory representation (format 3) can still be current.
> 
> >>>
> >>> Option 2 would be ideal, as it does not introduce any dependency for
> >>> using the native backend.
> >>> Yet I'm not sure  how complex implementing the tf model reader can
> >>> be,
> >>> If I remember correctly the student said it was not trivial at the
> >>> time.
> >>
> >> yes, it is not easy, but I think it is worthy to do it. Here is a 
> >> reference
>  example
> >> for the complexity, see
> >>
> 
> >>>
> https://github.com/opencv/opencv/blob/master/modules/dnn/src/tensorflow/
> >> tf_importer.cpp.
> >>
> >>>
> >>> Is the tf model file stable? if not it will be a maintenance burden to
> >>> keep it working whenever tf releases a new version. This point makes
> >>> me think having control over our file format is good.
> >>
> >> imho, this issue is always there, no matter which method used, unless
> our
> >> format could be exported by tensorflow (it has little possibility).
> >>
> >> Whenever tf releases a new version with a new file format, we still
> have
> >>> to
> >> change the python script in phase 1 (convert tf file model to our 
> >> format)
>  which
> >> is even an external dependency at
> >> https://github.com/HighVoltageRocknRoll/sr,
> >>
> >> As from effort perspective, the current implementation is better since
>  python
> >> script is simpler. But I think we are still worth implementing option 
> >> 2 as
> >>> the
> >> ideal technical direction.
> >
> > I checked a bit more about https://github.com/HighVoltageRocknRoll/sr,
> it
> >>> is
>  actually
> > not an converter (from tf model to native model), but hard code for 
> > given
>  models.
> > And the native model is not exactly the same as tf model, it even
> changes
> >>> the
>  behavior
> > of pad parameter of conv layer.
> >
> > If community is open to option 2, I'll try it.
> >
>  Option 2 is fine for me.
> >>>
> >>> that's great, :)
> >>
> >> looks that option 2 is a bit complex, TF model file is in protocol buffers
> (protobuf) format and not easy to parse it with simple c code.
> >>
> >> Since there is no official c support for protobuf, let's first image how 
> >> the
> work can be done via official c++ support.
> >>
> >> 1. get protobuf compiler protoc, .h header files and .so library files
> (download or build from
> https://github.com/protocolbuffers/protobuf/tree/master/src).
> >> 2. get tensorflow model's .proto files from
> https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/fram
> ework.
> >> 3. generate .cc/.h files from .proto files (see step 2) via protoc (see 
> >> step 1).
> >> 4. let the generated .cc/.h files be part of ffmpeg source tree, and build 
> >> with
> protobuf header/library files.
> >> 5. at run time, the protobuf libraries are invoked. It means that the 
> >> system
> should have installed protobuf dev package.
> >>
> >> furthermore, there is a compatible problem between the protobuf compiler,
> header files and library files.
> >> So, as a practice to fix it, the method is to make the protobuf source 
> >> code be
> part of ffmpeg source tree. (it is a common practice, so we can many other
> projects contain the protobuf source code).
> >>
> >> I guess the above method is not acceptable in ffmpeg. I would be glad to
> continue if the community embrace this change. :)
> > Indeed I think it is not acceptable.
> >
> >>
> >> While the current implementation has external dependency, my new
> suggestion is:
> >> -  add a python script under .../libavfilter/dnn/  (all other dnn source 
> >> files
> will be also moved here later), so ffmpeg has the full control on it.
> > I'm not sure about the policy on putting secondary scripts with the
> > main code, but another option is to create a repo controlled by ffmpeg
> > maybe?
> > I think this option would also help GSoC students that work with dnn,
> > so they don't have to depend on previous students maintaining
> > independent