Re: [FFmpeg-devel] [PATCH v1] avfilter/showinfo: support Content Light Level information

2019-08-08 Thread Limin Wang
On Fri, Aug 09, 2019 at 10:50:10AM +0800, myp...@gmail.com wrote:
> On Fri, Aug 9, 2019 at 10:36 AM  wrote:
> >
> > From: Limin Wang 
> >
> > show real information instead of the unknown side data type message for 
> > HDR10 stream
> >
> > Signed-off-by: Limin Wang 
> > ---
> >  libavfilter/vf_showinfo.c | 12 
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
> > index 9fa322e404..3c13f11524 100644
> > --- a/libavfilter/vf_showinfo.c
> > +++ b/libavfilter/vf_showinfo.c
> > @@ -160,6 +160,15 @@ static void dump_mastering_display(AVFilterContext 
> > *ctx, AVFrameSideData *sd)
> > av_q2d(mastering_display->min_luminance), 
> > av_q2d(mastering_display->max_luminance));
> >  }
> >
> > +static void dump_content_light_metadata(AVFilterContext *ctx, 
> > AVFrameSideData *sd)
> > +{
> > +AVContentLightMetadata* metadata = (AVContentLightMetadata*)sd->data;
> > +
> Add invaild data check? other part is Ok for me

IMO, the medata memory is allocate by 
av_content_light_metadata_create_side_data() api, it's valid already,
there is no need to check the size.

> > +av_log(ctx, AV_LOG_INFO, "Content Light Level information: "
> > +   "MaxCLL=%d, MaxFALL=%d",
> > +   metadata->MaxCLL, metadata->MaxFALL);
> > +}
> > +
> >  static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
> >  {
> >  const char *color_range_str = 
> > av_color_range_name(frame->color_range);
> > @@ -301,6 +310,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> > *frame)
> >  case AV_FRAME_DATA_MASTERING_DISPLAY_METADATA:
> >  dump_mastering_display(ctx, sd);
> >  break;
> > +case AV_FRAME_DATA_CONTENT_LIGHT_LEVEL:
> > +dump_content_light_metadata(ctx, sd);
> > +break;
> >  default:
> >  av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d 
> > bytes)",
> > sd->type, sd->size);
> > --
> > 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".

Re: [FFmpeg-devel] [PATCH v1] avfilter/showinfo: support Content Light Level information

2019-08-08 Thread myp...@gmail.com
On Fri, Aug 9, 2019 at 10:36 AM  wrote:
>
> From: Limin Wang 
>
> show real information instead of the unknown side data type message for HDR10 
> stream
>
> Signed-off-by: Limin Wang 
> ---
>  libavfilter/vf_showinfo.c | 12 
>  1 file changed, 12 insertions(+)
>
> diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
> index 9fa322e404..3c13f11524 100644
> --- a/libavfilter/vf_showinfo.c
> +++ b/libavfilter/vf_showinfo.c
> @@ -160,6 +160,15 @@ static void dump_mastering_display(AVFilterContext *ctx, 
> AVFrameSideData *sd)
> av_q2d(mastering_display->min_luminance), 
> av_q2d(mastering_display->max_luminance));
>  }
>
> +static void dump_content_light_metadata(AVFilterContext *ctx, 
> AVFrameSideData *sd)
> +{
> +AVContentLightMetadata* metadata = (AVContentLightMetadata*)sd->data;
> +
Add invaild data check? other part is Ok for me
> +av_log(ctx, AV_LOG_INFO, "Content Light Level information: "
> +   "MaxCLL=%d, MaxFALL=%d",
> +   metadata->MaxCLL, metadata->MaxFALL);
> +}
> +
>  static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
>  {
>  const char *color_range_str = 
> av_color_range_name(frame->color_range);
> @@ -301,6 +310,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> *frame)
>  case AV_FRAME_DATA_MASTERING_DISPLAY_METADATA:
>  dump_mastering_display(ctx, sd);
>  break;
> +case AV_FRAME_DATA_CONTENT_LIGHT_LEVEL:
> +dump_content_light_metadata(ctx, sd);
> +break;
>  default:
>  av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d 
> bytes)",
> sd->type, sd->size);
> --
> 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 v1] avfilter/showinfo: support Content Light Level information

2019-08-08 Thread lance . lmwang
From: Limin Wang 

show real information instead of the unknown side data type message for HDR10 
stream

Signed-off-by: Limin Wang 
---
 libavfilter/vf_showinfo.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 9fa322e404..3c13f11524 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -160,6 +160,15 @@ static void dump_mastering_display(AVFilterContext *ctx, 
AVFrameSideData *sd)
av_q2d(mastering_display->min_luminance), 
av_q2d(mastering_display->max_luminance));
 }
 
+static void dump_content_light_metadata(AVFilterContext *ctx, AVFrameSideData 
*sd)
+{
+AVContentLightMetadata* metadata = (AVContentLightMetadata*)sd->data;
+
+av_log(ctx, AV_LOG_INFO, "Content Light Level information: "
+   "MaxCLL=%d, MaxFALL=%d",
+   metadata->MaxCLL, metadata->MaxFALL);
+}
+
 static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
 {
 const char *color_range_str = av_color_range_name(frame->color_range);
@@ -301,6 +310,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 case AV_FRAME_DATA_MASTERING_DISPLAY_METADATA:
 dump_mastering_display(ctx, sd);
 break;
+case AV_FRAME_DATA_CONTENT_LIGHT_LEVEL:
+dump_content_light_metadata(ctx, sd);
+break;
 default:
 av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)",
sd->type, sd->size);
-- 
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/3] avcodec: Rename jedec-p22 to ebu3213

2019-08-08 Thread rzumer
From: Raphaël Zumer 

This matches a name change in avutil/pixdesc.

Signed-off-by: Raphaël Zumer 
---
 libavcodec/options_table.h | 2 +-
 libavcodec/version.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 4a266eca16..9d82188171 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -365,7 +365,7 @@ static const AVOption avcodec_options[] = {
 {"smpte428_1",  "SMPTE 428-1",0, AV_OPT_TYPE_CONST, {.i64 = 
AVCOL_PRI_SMPTE428 }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
 {"smpte431","SMPTE 431-2",0, AV_OPT_TYPE_CONST, {.i64 = 
AVCOL_PRI_SMPTE431 }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
 {"smpte432","SMPTE 422-1",0, AV_OPT_TYPE_CONST, {.i64 = 
AVCOL_PRI_SMPTE432 }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
-{"jedec-p22",   "JEDEC P22",  0, AV_OPT_TYPE_CONST, {.i64 = 
AVCOL_PRI_JEDEC_P22 },INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
+{"ebu3213", "EBU 3213-E", 0, AV_OPT_TYPE_CONST, {.i64 = 
AVCOL_PRI_JEDEC_P22 },INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
 {"unspecified", "Unspecified",0, AV_OPT_TYPE_CONST, {.i64 = 
AVCOL_PRI_UNSPECIFIED },  INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
 {"color_trc", "color transfer characteristics", OFFSET(color_trc), 
AV_OPT_TYPE_INT, {.i64 = AVCOL_TRC_UNSPECIFIED }, 1, INT_MAX, V|E|D, 
"color_trc_type"},
 {"bt709","BT.709",   0, AV_OPT_TYPE_CONST, {.i64 = 
AVCOL_TRC_BT709 },INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 43c8cdb59f..e70ebc0c70 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR  58
 #define LIBAVCODEC_VERSION_MINOR  55
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
-- 
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 2/3] avfilter: Rename jedec-p22 to ebu3213

2019-08-08 Thread rzumer
From: Raphaël Zumer 

This matches a name change in avutil/pixdesc.

Signed-off-by: Raphaël Zumer 
---
 libavfilter/version.h   | 2 +-
 libavfilter/vf_colorspace.c | 2 +-
 libavfilter/vf_setparams.c  | 2 +-
 libavfilter/vf_zscale.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavfilter/version.h b/libavfilter/version.h
index dd829160fc..58a0221f43 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR   7
 #define LIBAVFILTER_VERSION_MINOR  58
-#define LIBAVFILTER_VERSION_MICRO 100
+#define LIBAVFILTER_VERSION_MICRO 101
 
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index df6efffb3d..5f22f92507 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -968,7 +968,7 @@ static const AVOption colorspace_options[] = {
 ENUM("smpte431", AVCOL_PRI_SMPTE431,   "prm"),
 ENUM("smpte432", AVCOL_PRI_SMPTE432,   "prm"),
 ENUM("bt2020",   AVCOL_PRI_BT2020, "prm"),
-ENUM("jedec-p22",AVCOL_PRI_JEDEC_P22,  "prm"),
+ENUM("ebu3213",  AVCOL_PRI_JEDEC_P22,  "prm"),
 
 { "trc","Output transfer characteristics",
   OFFSET(user_trc),   AV_OPT_TYPE_INT, { .i64 = AVCOL_TRC_UNSPECIFIED },
diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c
index fe298e5a06..80e61f851e 100644
--- a/libavfilter/vf_setparams.c
+++ b/libavfilter/vf_setparams.c
@@ -74,7 +74,7 @@ static const AVOption setparams_options[] = {
 {"smpte428",NULL,  0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_PRI_SMPTE428}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
 {"smpte431",NULL,  0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_PRI_SMPTE431}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
 {"smpte432",NULL,  0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_PRI_SMPTE432}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
-{"jedec-p22",   NULL,  0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_PRI_JEDEC_P22},INT_MIN, INT_MAX, FLAGS, "color_primaries"},
+{"ebu3213", NULL,  0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_PRI_JEDEC_P22},INT_MIN, INT_MAX, FLAGS, "color_primaries"},
 
 {"color_trc", "select color transfer", OFFSET(color_trc), AV_OPT_TYPE_INT, 
{.i64=-1}, -1, AVCOL_TRC_NB-1, FLAGS, "color_trc"},
 {"auto", "keep the same color transfer",  0, AV_OPT_TYPE_CONST, {.i64=-1}, 
INT_MIN, INT_MAX, FLAGS, "color_trc"},
diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index f0309272fa..e53d7c1ae0 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -788,7 +788,7 @@ static const AVOption zscale_options[] = {
 { "smpte428", 0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_ST428},   0, 0, FLAGS, "primaries" },
 { "smpte431", 0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_ST431_2}, 0, 0, FLAGS, "primaries" },
 { "smpte432", 0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_ST432_1}, 0, 0, FLAGS, "primaries" },
-{ "jedec-p22",0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_EBU3213_E},   0, 0, FLAGS, "primaries" },
+{ "ebu3213",  0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_EBU3213_E},   0, 0, FLAGS, "primaries" },
 { "transfer", "set transfer characteristic", OFFSET(trc), AV_OPT_TYPE_INT, 
{.i64 = -1}, -1, INT_MAX, FLAGS, "transfer" },
 { "t","set transfer characteristic", OFFSET(trc), AV_OPT_TYPE_INT, 
{.i64 = -1}, -1, INT_MAX, FLAGS, "transfer" },
 { "input",0,   0, AV_OPT_TYPE_CONST, 
{.i64 = -1}, 0, 0, FLAGS, "transfer" },
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 1/3] avutil/pixfmt: Add EBU Tech. 3213-E AVColorPrimaries value

2019-08-08 Thread rzumer
From: Raphaël Zumer 

This is an alias for JEDEC P22.

The name associated with the value is also changed
from "jedec-p22" to "ebu3213" to match ITU-T H.273.

Signed-off-by: Raphaël Zumer 
---
 doc/APIchanges  | 3 +++
 libavutil/pixdesc.c | 2 +-
 libavutil/pixfmt.h  | 1 +
 libavutil/version.h | 2 +-
 4 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 6603a8229e..f71b0c4a75 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2019-08-08 - xx - lavu 56.34.100 - pixfmt.h
+  Add EBU Tech. 3213-E AVColorPrimaries value
+
 2019-07-27 - xx - lavu 56.33.100 - tx.h
   Add AV_TX_DOUBLE_FFT and AV_TX_DOUBLE_MDCT
 
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index b97b0665b0..3b2d3b3123 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -2369,7 +2369,7 @@ static const char * const 
color_primaries_names[AVCOL_PRI_NB] = {
 [AVCOL_PRI_SMPTE428] = "smpte428",
 [AVCOL_PRI_SMPTE431] = "smpte431",
 [AVCOL_PRI_SMPTE432] = "smpte432",
-[AVCOL_PRI_JEDEC_P22] = "jedec-p22",
+[AVCOL_PRI_JEDEC_P22] = "ebu3213",
 };
 
 static const char * const color_transfer_names[] = {
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 8b54c9415b..7f7b537721 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -457,6 +457,7 @@ enum AVColorPrimaries {
 AVCOL_PRI_SMPTE431= 11, ///< SMPTE ST 431-2 (2011) / DCI P3
 AVCOL_PRI_SMPTE432= 12, ///< SMPTE ST 432-1 (2010) / P3 D65 / Display 
P3
 AVCOL_PRI_JEDEC_P22   = 22, ///< JEDEC P22 phosphors
+AVCOL_PRI_EBU3213 = AVCOL_PRI_JEDEC_P22,
 AVCOL_PRI_NB///< Not part of ABI
 };
 
diff --git a/libavutil/version.h b/libavutil/version.h
index ecc6a7c9e2..658a508284 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  33
+#define LIBAVUTIL_VERSION_MINOR  34
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.17.1

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

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

Re: [FFmpeg-devel] libavcodec: add timeshift bitstream filter [v3]

2019-08-08 Thread Alexander Strasser
Hi Nicolas!

On 2019-08-08 11:43 +0200, Nicolas George wrote:
> Andreas Håkon (12019-08-08):
> > > setpts or setts, similar to lavfi.
>
> > Then I proposse these two alternatives:
> >
> > 1) "editpts_bsf"
> > 2) "setpts_bsf"
> >
> > The "_bsf" is not real, only to differenciate (here) from other filters.
> > Which one do you prefer?
>
> editpts has no similarity with lavfi. Users would need to remember if it
> is filters <-> set and bsf <-> edit or filters <-> edit and bsf <-> set.
> Better have a single name.

Right, I thought about that too. It could get confusing. Still my initial
suggestions were on purpose not setpts. More on that below.


> Bitstream filters and lavfi are not in the same namespace, therefore the
> suffix is unneeded.
>
>
> Gyan (12019-08-08):
> > This BSF only allows to apply a fixed offset whereas the setpts filter
> > allows arbitrary expressions. Unless someone is planning to extend this
> > BSF,  the current candidate is more apt.

Like Gyan mentioned here, that was my reason to refrain from proposing
setpts as a name for this bsf. I too think, that one would expect being
able to use free expressions for the timestamp specification. And that
would cause similar confusions like the one you described above, where
users would think

"ah, it's setpts I can just give it the offset I want"

vs

"ah, it's setpts I can give it an expressions that evaluates
to the time stamp I want to set"

Also if I'm not mistaken for the lavfi filter the name setpts is on
spot whereas for the bsf we would also deal with dts, which was not
a consideration when implementing the setpts filter and defining its
arguments, which is just a single argument named "expr".


> At some point, somebody will implement generic expression eval.

That might happen, but it's IMHO too vague to rely on for making
name decisions right in this moment.


> When
> that happens, it will be better if they can just add an option to the
> existing filter rather than creating a whole new filter, deprecating the
> existing one, etc.

That sounds a bit exaggerating to me:

1. Building a whole new bsf would not be that different from changing the
   existing one, except from having to copy and modify the boiler plate
   related to implementing bsfs in general. Maybe a couple of lines in
   the existing implementation of the bsf could be reused, maybe not.
2. The existing one wouldn't have to be deprecating, as it's so simple
   that it could stay there providing an alternative filter with a
   different interface and implementation. Or the code could be shared,
   which at the moment doesn't seem to have any benefits, but would also
   share the flaws for which there will be more opportunities in the bsf
   with expression evaluation.
3. If one would decide, one doesn't want to have the two achieving the
   same thing. One could replace the documentation of this bsf with
   "Only for backward compatibility. Use bsf setpts."

So yes it might be better if, but even then probably not much.

Also if it happens that all set filters of lavfi really get merged into
a single filter, we would have chosen the wrong name now.


> Key idea: long term planning.

I agree that long term planning is important, though I disagree with
your conclusion in this specific discussion.

The whole bsf framework is probably a nice long-term move. It's
flexibility of allowing bsfs as individual filters that are handled in
a generic fashion, provides a good ground for implementing a diverse,
useful and partially redundant set of bsfs.

Seeing it this way it eases long-term planning by removing the need for
detailed planning and allowing experimentation and evolution without
having to sacrifice compatibility.


> Therefore, I am for setpts (dts is just secondary), with a mention in
> the documentation:
>
> # Unlike the setpts filter in libavfilter, this filter currently can
> # only apply a constant offset.

Another name idea

* ts_offset

loosely in reference to -itsoffset and output_ts_offset (AVFormatContext).

And from the initial discussion there was:

* add_delay


Regarding setpts and other filters like addroi and so on, I find it a bit
unfortunate that they don't have an underscore. "set_" and "add_" is much
better for doing full text searches on the docs or the complete codebase.


If you still think setpts is the best name for that bsf, it's fine for
me; my main concern was to not name it "timer".


  Alexander
___
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] colorspace: Rename jedec-p22 to ebu3213

2019-08-08 Thread James Almer
On 8/8/2019 9:01 PM, rzu...@tebako.net wrote:
> From: Raphaël Zumer 
> 
> Internally, this adds an EBU3213 alias to JEDEC_P22,
> and changes the name string to match ITU-T H.273.
> ---
>  libavcodec/options_table.h  | 2 +-
>  libavfilter/vf_colorspace.c | 2 +-
>  libavfilter/vf_setparams.c  | 2 +-
>  libavfilter/vf_zscale.c | 2 +-
>  libavutil/pixdesc.c | 2 +-
>  libavutil/pixfmt.h  | 1 +
>  6 files changed, 6 insertions(+), 5 deletions(-)

This should be split into three patches. The first one adding the enum
value to pixfmt.h, changing the string in pixdesc.c, bumping libavutil
minor version, and adding an entry to doc/APIChanges. The subject should
be something like "avutil/pixfmt: Add EBU Tech. 3213-E AVColorPrimaries
value" plus the explanation that it's an alias for Jedec P22 (Or that
one becoming an alias for the new one) after it.
Then another patch changing the libavfilter option values and bumping
libavfilter micro version, and another doing the same with libavcodec.

> 
> diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
> index 4a266eca16..9d82188171 100644
> --- a/libavcodec/options_table.h
> +++ b/libavcodec/options_table.h
> @@ -365,7 +365,7 @@ static const AVOption avcodec_options[] = {
>  {"smpte428_1",  "SMPTE 428-1",0, AV_OPT_TYPE_CONST, {.i64 = 
> AVCOL_PRI_SMPTE428 }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
>  {"smpte431","SMPTE 431-2",0, AV_OPT_TYPE_CONST, {.i64 = 
> AVCOL_PRI_SMPTE431 }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
>  {"smpte432","SMPTE 422-1",0, AV_OPT_TYPE_CONST, {.i64 = 
> AVCOL_PRI_SMPTE432 }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
> -{"jedec-p22",   "JEDEC P22",  0, AV_OPT_TYPE_CONST, {.i64 = 
> AVCOL_PRI_JEDEC_P22 },INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
> +{"ebu3213", "EBU 3213-E", 0, AV_OPT_TYPE_CONST, {.i64 = 
> AVCOL_PRI_JEDEC_P22 },INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
>  {"unspecified", "Unspecified",0, AV_OPT_TYPE_CONST, {.i64 = 
> AVCOL_PRI_UNSPECIFIED },  INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
>  {"color_trc", "color transfer characteristics", OFFSET(color_trc), 
> AV_OPT_TYPE_INT, {.i64 = AVCOL_TRC_UNSPECIFIED }, 1, INT_MAX, V|E|D, 
> "color_trc_type"},
>  {"bt709","BT.709",   0, AV_OPT_TYPE_CONST, {.i64 = 
> AVCOL_TRC_BT709 },INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
> diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
> index df6efffb3d..5f22f92507 100644
> --- a/libavfilter/vf_colorspace.c
> +++ b/libavfilter/vf_colorspace.c
> @@ -968,7 +968,7 @@ static const AVOption colorspace_options[] = {
>  ENUM("smpte431", AVCOL_PRI_SMPTE431,   "prm"),
>  ENUM("smpte432", AVCOL_PRI_SMPTE432,   "prm"),
>  ENUM("bt2020",   AVCOL_PRI_BT2020, "prm"),
> -ENUM("jedec-p22",AVCOL_PRI_JEDEC_P22,  "prm"),
> +ENUM("ebu3213",  AVCOL_PRI_JEDEC_P22,  "prm"),
>  
>  { "trc","Output transfer characteristics",
>OFFSET(user_trc),   AV_OPT_TYPE_INT, { .i64 = AVCOL_TRC_UNSPECIFIED },
> diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c
> index fe298e5a06..80e61f851e 100644
> --- a/libavfilter/vf_setparams.c
> +++ b/libavfilter/vf_setparams.c
> @@ -74,7 +74,7 @@ static const AVOption setparams_options[] = {
>  {"smpte428",NULL,  0, AV_OPT_TYPE_CONST, 
> {.i64=AVCOL_PRI_SMPTE428}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
>  {"smpte431",NULL,  0, AV_OPT_TYPE_CONST, 
> {.i64=AVCOL_PRI_SMPTE431}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
>  {"smpte432",NULL,  0, AV_OPT_TYPE_CONST, 
> {.i64=AVCOL_PRI_SMPTE432}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
> -{"jedec-p22",   NULL,  0, AV_OPT_TYPE_CONST, 
> {.i64=AVCOL_PRI_JEDEC_P22},INT_MIN, INT_MAX, FLAGS, "color_primaries"},
> +{"ebu3213", NULL,  0, AV_OPT_TYPE_CONST, 
> {.i64=AVCOL_PRI_JEDEC_P22},INT_MIN, INT_MAX, FLAGS, "color_primaries"},
>  
>  {"color_trc", "select color transfer", OFFSET(color_trc), 
> AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_TRC_NB-1, FLAGS, "color_trc"},
>  {"auto", "keep the same color transfer",  0, AV_OPT_TYPE_CONST, 
> {.i64=-1}, INT_MIN, INT_MAX, FLAGS, "color_trc"},
> diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
> index f0309272fa..e53d7c1ae0 100644
> --- a/libavfilter/vf_zscale.c
> +++ b/libavfilter/vf_zscale.c
> @@ -788,7 +788,7 @@ static const AVOption zscale_options[] = {
>  { "smpte428", 0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_PRIMARIES_ST428},   0, 0, FLAGS, "primaries" },
>  { "smpte431", 0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_PRIMARIES_ST431_2}, 0, 0, FLAGS, "primaries" },
>  { "smpte432", 0,   0,  

Re: [FFmpeg-devel] [PATCH 1/2] avutil: Add Simple loop detector

2019-08-08 Thread Michael Niedermayer
On Thu, Aug 08, 2019 at 03:38:58PM +0100, Kieran Kunhya wrote:
> >
> > You argue that it does not NEED to be in lavu, but not that it SHOULD
> > note.
> >
> > > Plus, its not really common av code, and don't let its name mislead
> > > you, its more of a hack.
> >
> > I will disregard the insulting subtext of this sentence.
> >
> 
> There is nothing insulting about this sentence. IMO this is a hack, how
> come we have not needed such a thing for years?

we didnt "need" the bugfixes because the code was buggy.

The "building block" of a offset or pointer pointing anywhere in a file
is common, that can lead to cycles. Maybe the fuzzers are not good at
creating such constructs out of thin air but i wouldnt use this as
argument that the code isnt containing such bugs

PS: the reason why fuzzers fail to find such loops is likely because 
its not locally convergent. A pointer closing a loop will not run more
iterations as it become closer in value to closing the loop. It doesnt
loop and only in maybe 1 out of 4 billion values will infinite loop and
that only if all surrounding data structures also are valid enough.

Thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin


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] colorspace: Rename jedec-p22 to ebu3213

2019-08-08 Thread rzumer
From: Raphaël Zumer 

Internally, this adds an EBU3213 alias to JEDEC_P22,
and changes the name string to match ITU-T H.273.
---
 libavcodec/options_table.h  | 2 +-
 libavfilter/vf_colorspace.c | 2 +-
 libavfilter/vf_setparams.c  | 2 +-
 libavfilter/vf_zscale.c | 2 +-
 libavutil/pixdesc.c | 2 +-
 libavutil/pixfmt.h  | 1 +
 6 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 4a266eca16..9d82188171 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -365,7 +365,7 @@ static const AVOption avcodec_options[] = {
 {"smpte428_1",  "SMPTE 428-1",0, AV_OPT_TYPE_CONST, {.i64 = 
AVCOL_PRI_SMPTE428 }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
 {"smpte431","SMPTE 431-2",0, AV_OPT_TYPE_CONST, {.i64 = 
AVCOL_PRI_SMPTE431 }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
 {"smpte432","SMPTE 422-1",0, AV_OPT_TYPE_CONST, {.i64 = 
AVCOL_PRI_SMPTE432 }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
-{"jedec-p22",   "JEDEC P22",  0, AV_OPT_TYPE_CONST, {.i64 = 
AVCOL_PRI_JEDEC_P22 },INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
+{"ebu3213", "EBU 3213-E", 0, AV_OPT_TYPE_CONST, {.i64 = 
AVCOL_PRI_JEDEC_P22 },INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
 {"unspecified", "Unspecified",0, AV_OPT_TYPE_CONST, {.i64 = 
AVCOL_PRI_UNSPECIFIED },  INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
 {"color_trc", "color transfer characteristics", OFFSET(color_trc), 
AV_OPT_TYPE_INT, {.i64 = AVCOL_TRC_UNSPECIFIED }, 1, INT_MAX, V|E|D, 
"color_trc_type"},
 {"bt709","BT.709",   0, AV_OPT_TYPE_CONST, {.i64 = 
AVCOL_TRC_BT709 },INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index df6efffb3d..5f22f92507 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -968,7 +968,7 @@ static const AVOption colorspace_options[] = {
 ENUM("smpte431", AVCOL_PRI_SMPTE431,   "prm"),
 ENUM("smpte432", AVCOL_PRI_SMPTE432,   "prm"),
 ENUM("bt2020",   AVCOL_PRI_BT2020, "prm"),
-ENUM("jedec-p22",AVCOL_PRI_JEDEC_P22,  "prm"),
+ENUM("ebu3213",  AVCOL_PRI_JEDEC_P22,  "prm"),
 
 { "trc","Output transfer characteristics",
   OFFSET(user_trc),   AV_OPT_TYPE_INT, { .i64 = AVCOL_TRC_UNSPECIFIED },
diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c
index fe298e5a06..80e61f851e 100644
--- a/libavfilter/vf_setparams.c
+++ b/libavfilter/vf_setparams.c
@@ -74,7 +74,7 @@ static const AVOption setparams_options[] = {
 {"smpte428",NULL,  0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_PRI_SMPTE428}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
 {"smpte431",NULL,  0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_PRI_SMPTE431}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
 {"smpte432",NULL,  0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_PRI_SMPTE432}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
-{"jedec-p22",   NULL,  0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_PRI_JEDEC_P22},INT_MIN, INT_MAX, FLAGS, "color_primaries"},
+{"ebu3213", NULL,  0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_PRI_JEDEC_P22},INT_MIN, INT_MAX, FLAGS, "color_primaries"},
 
 {"color_trc", "select color transfer", OFFSET(color_trc), AV_OPT_TYPE_INT, 
{.i64=-1}, -1, AVCOL_TRC_NB-1, FLAGS, "color_trc"},
 {"auto", "keep the same color transfer",  0, AV_OPT_TYPE_CONST, {.i64=-1}, 
INT_MIN, INT_MAX, FLAGS, "color_trc"},
diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index f0309272fa..e53d7c1ae0 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -788,7 +788,7 @@ static const AVOption zscale_options[] = {
 { "smpte428", 0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_ST428},   0, 0, FLAGS, "primaries" },
 { "smpte431", 0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_ST431_2}, 0, 0, FLAGS, "primaries" },
 { "smpte432", 0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_ST432_1}, 0, 0, FLAGS, "primaries" },
-{ "jedec-p22",0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_EBU3213_E},   0, 0, FLAGS, "primaries" },
+{ "ebu3213",  0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_EBU3213_E},   0, 0, FLAGS, "primaries" },
 { "transfer", "set transfer characteristic", OFFSET(trc), AV_OPT_TYPE_INT, 
{.i64 = -1}, -1, INT_MAX, FLAGS, "transfer" },
 { "t","set transfer characteristic", OFFSET(trc), AV_OPT_TYPE_INT, 
{.i64 = -1}, -1, INT_MAX, FLAGS, "transfer" },
 { "input",0,   0, AV_OPT_TYPE_CONST, 
{.i64 = -1}, 0, 

Re: [FFmpeg-devel] [PATCH] doc/fate: Document how to request samples upload access

2019-08-08 Thread Michael Niedermayer
On Wed, Aug 07, 2019 at 09:25:07PM +0200, Thilo Borgmann wrote:
> Am 07.08.19 um 21:18 schrieb Michael Niedermayer:
> > The awnser which most people will seek is put first
> > 
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  doc/fate.texi | 4 
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/doc/fate.texi b/doc/fate.texi
> > index 2be61d639c..c3550785a1 100644
> > --- a/doc/fate.texi
> > +++ b/doc/fate.texi
> > @@ -149,6 +149,8 @@ the synchronisation of the samples directory.
> >  
> >  @chapter Uploading new samples to the fate suite
> >  
> > +If you need a sample uploaded send a mail to samples-request.
> > +
> >  This is for developers who have an account on the fate suite server.
> >  If you upload new samples, please make sure they are as small as possible,
> >  space on each client, network bandwidth and so on benefit from smaller 
> > test cases.
> > @@ -157,6 +159,8 @@ practice generally do not replace, remove or overwrite 
> > files as it likely would
> >  break older checkouts or releases.
> >  Also all needed samples for a commit should be uploaded, ideally 24
> >  hours, before the push.
> > +If you need an account for frequently uploading samples or you wish to help
> > +others by doing that send a mail to ffmpeg-devel.
> 
> LGTM

will apply

thx

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

Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato


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 5/5] avcodec/smacker: Check that not all tables are skiped

2019-08-08 Thread Michael Niedermayer
If all tables are skipped it would be impossible to encode any
"non black" video.

Fixes: Timeout (78sec -> 1ms)
Fixes: 
15821/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKER_fuzzer-5652598838788096

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

diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index 61e316916b..70e0dfd5df 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -319,6 +319,7 @@ error:
 static int decode_header_trees(SmackVContext *smk) {
 GetBitContext gb;
 int mmap_size, mclr_size, full_size, type_size, ret;
+int skip = 0;
 
 mmap_size = AV_RL32(smk->avctx->extradata);
 mclr_size = AV_RL32(smk->avctx->extradata + 4);
@@ -330,6 +331,7 @@ static int decode_header_trees(SmackVContext *smk) {
 return ret;
 
 if(!get_bits1()) {
+skip ++;
 av_log(smk->avctx, AV_LOG_INFO, "Skipping MMAP tree\n");
 smk->mmap_tbl = av_malloc(sizeof(int) * 2);
 if (!smk->mmap_tbl)
@@ -342,6 +344,7 @@ static int decode_header_trees(SmackVContext *smk) {
 return ret;
 }
 if(!get_bits1()) {
+skip ++;
 av_log(smk->avctx, AV_LOG_INFO, "Skipping MCLR tree\n");
 smk->mclr_tbl = av_malloc(sizeof(int) * 2);
 if (!smk->mclr_tbl)
@@ -354,6 +357,7 @@ static int decode_header_trees(SmackVContext *smk) {
 return ret;
 }
 if(!get_bits1()) {
+skip ++;
 av_log(smk->avctx, AV_LOG_INFO, "Skipping FULL tree\n");
 smk->full_tbl = av_malloc(sizeof(int) * 2);
 if (!smk->full_tbl)
@@ -366,6 +370,7 @@ static int decode_header_trees(SmackVContext *smk) {
 return ret;
 }
 if(!get_bits1()) {
+skip ++;
 av_log(smk->avctx, AV_LOG_INFO, "Skipping TYPE tree\n");
 smk->type_tbl = av_malloc(sizeof(int) * 2);
 if (!smk->type_tbl)
@@ -377,6 +382,8 @@ static int decode_header_trees(SmackVContext *smk) {
 if (ret < 0)
 return ret;
 }
+if (skip == 4)
+return AVERROR_INVALIDDATA;
 
 return 0;
 }
-- 
2.22.0

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

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

[FFmpeg-devel] [PATCH 2/5] avcodec/vc1: Fix overflow in aspect ratio calculation

2019-08-08 Thread Michael Niedermayer
Fixes: signed integer overflow: 393215 * 14594 cannot be represented in type 
'int'
Fixes: 
15728/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3IMAGE_fuzzer-5661588893204480

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

diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index e102b931d8..0790eb160e 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -453,8 +453,8 @@ static int decode_sequence_header_adv(VC1Context *v, 
GetBitContext *gb)
 } else {
 av_reduce(>s.avctx->sample_aspect_ratio.num,
   >s.avctx->sample_aspect_ratio.den,
-  v->s.avctx->height * w,
-  v->s.avctx->width * h,
+  v->s.avctx->height * (int64_t)w,
+  v->s.avctx->width * (int64_t)h,
   1 << 30);
 }
 ff_set_sar(v->s.avctx, v->s.avctx->sample_aspect_ratio);
-- 
2.22.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 4/5] avcodec/alac: Check for bps of 0

2019-08-08 Thread Michael Niedermayer
Fixes: shift exponent 32 is too large for 32-bit type 'unsigned int'
Fixes: 
15764/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-5102101203517440

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

diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index 6086e2caa8..1196925aa7 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -250,7 +250,7 @@ static int decode_element(AVCodecContext *avctx, AVFrame 
*frame, int ch_index,
 
 alac->extra_bits = get_bits(>gb, 2) << 3;
 bps = alac->sample_size - alac->extra_bits + channels - 1;
-if (bps > 32U) {
+if (bps > 32 || bps < 1) {
 avpriv_report_missing_feature(avctx, "bps %d", bps);
 return AVERROR_PATCHWELCOME;
 }
-- 
2.22.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] avcodec/alac: Fix multiple integer overflows in lpc_prediction()

2019-08-08 Thread Michael Niedermayer
Fixes: signed integer overflow: 2088795537 + 2147254401 cannot be represented 
in type 'int'
Fixes: signed integer overflow: -1500363496 + -1295351808 cannot be represented 
in type 'int'
Fixes: signed integer overflow: -79560 * 32640 cannot be represented in type 
'int'
Fixes: signed integer overflow: 2088910005 + 2088796058 cannot be represented 
in type 'int'
Fixes: signed integer overflow: -117258064 - 2088725225 cannot be represented 
in type 'int'
Fixes: signed integer overflow: 2088725225 - -117258064 cannot be represented 
in type 'int'
Fixes: 
15739/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-5630664122040320

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

diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index c234d7153b..6086e2caa8 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -171,12 +171,12 @@ static inline int sign_only(int v)
 return v ? FFSIGN(v) : 0;
 }
 
-static void lpc_prediction(int32_t *error_buffer, int32_t *buffer_out,
+static void lpc_prediction(int32_t *error_buffer, uint32_t *buffer_out,
int nb_samples, int bps, int16_t *lpc_coefs,
int lpc_order, int lpc_quant)
 {
 int i;
-int32_t *pred = buffer_out;
+uint32_t *pred = buffer_out;
 
 /* first sample always copies */
 *buffer_out = *error_buffer;
@@ -208,7 +208,7 @@ static void lpc_prediction(int32_t *error_buffer, int32_t 
*buffer_out,
 for (; i < nb_samples; i++) {
 int j;
 int val = 0;
-int error_val = error_buffer[i];
+unsigned error_val = error_buffer[i];
 int error_sign;
 int d = *pred++;
 
@@ -222,7 +222,7 @@ static void lpc_prediction(int32_t *error_buffer, int32_t 
*buffer_out,
 /* adapt LPC coefficients */
 error_sign = sign_only(error_val);
 if (error_sign) {
-for (j = 0; j < lpc_order && error_val * error_sign > 0; j++) {
+for (j = 0; j < lpc_order && (int)error_val * error_sign > 0; j++) 
{
 int sign;
 val  = d - pred[j];
 sign = sign_only(val) * error_sign;
-- 
2.22.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 1/5] avcodec/tiff: Enforce increasing offsets

2019-08-08 Thread Michael Niedermayer
This may break some valid tiff files, it appears the specification does not 
require
the offsets to be increasing. They increase in the 2 test files i have though 
except
the last offset which is 0 (an end marker) and for which a special case is 
added to
avoid asking for a sample for that end marker.

See: [FFmpeg-devel] [PATCH 2/2] avcodec/tiff: Detect infinite retry loop
for an alternative implementation

Fixes: Timeout (Infinite -> Finite)
Fixes: 
15706/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5114674904825856

This variant was requested by paul on IRC
Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/tiff.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index c520d7df83..1f1a1a3698 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1399,7 +1399,7 @@ static int decode_frame(AVCodecContext *avctx,
 TiffContext *const s = avctx->priv_data;
 AVFrame *const p = data;
 ThreadFrame frame = { .f = data };
-unsigned off;
+unsigned off, last_off;
 int le, ret, plane, planes;
 int i, j, entries, stride;
 unsigned soff, ssize;
@@ -1454,6 +1454,7 @@ again:
 /** whether we should process this multi-page IFD's next page */
 retry_for_page = s->get_page && s->cur_page + 1 < s->get_page;  // 
get_page is 1-indexed
 
+last_off = off;
 if (retry_for_page) {
 // set offset to the next IFD
 off = ff_tget_long(>gb, le);
@@ -1463,6 +1464,14 @@ again:
 }
 
 if (retry_for_subifd || retry_for_page) {
+if (!off) {
+av_log(avctx, AV_LOG_ERROR, "Requested entry not found\n");
+return AVERROR_INVALIDDATA;
+}
+if (off <= last_off) {
+avpriv_request_sample(s->avctx, "non increasing IFD offset\n");
+return AVERROR_INVALIDDATA;
+}
 if (off >= UINT_MAX - 14 || avpkt->size < off + 14) {
 av_log(avctx, AV_LOG_ERROR, "IFD offset is greater than image 
size\n");
 return AVERROR_INVALIDDATA;
-- 
2.22.0

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

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

Re: [FFmpeg-devel] [PATCH] libavformat/subfile: Fix SEEK_CUR and SEEK_END seeking

2019-08-08 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Up until now, when performing a SEEK_END seek, the subfile protocol
> ignored the desired position (relative to EOF) and used the current
> absolute offset in the input file instead.
> 
> And when performing a SEEK_CUR seek, the current position has been
> ignored.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
Ping.

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

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

[FFmpeg-devel] [PATCH 2/6] avformat/mpegtsenc: factorize setting up services

2019-08-08 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 66 +++--
 1 file changed, 25 insertions(+), 41 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 661aa4066d..13fdb6ff97 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -717,12 +717,24 @@ invalid:
 return 0;
 }
 
+static void section_write_packet(MpegTSSection *s, const uint8_t *packet);
+
 static MpegTSService *mpegts_add_service(AVFormatContext *s, int sid,
- const char *provider_name,
- const char *name)
+ const AVDictionary *metadata,
+ AVProgram *program)
 {
 MpegTSWrite *ts = s->priv_data;
 MpegTSService *service;
+AVDictionaryEntry *title, *provider;
+const char *service_name;
+const char *provider_name;
+
+title = av_dict_get(metadata, "service_name", NULL, 0);
+if (!title)
+title = av_dict_get(metadata, "title", NULL, 0);
+service_name  = title ? title->value : DEFAULT_SERVICE_NAME;
+provider  = av_dict_get(metadata, "service_provider", NULL, 0);
+provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
 
 service = av_mallocz(sizeof(MpegTSService));
 if (!service)
@@ -731,13 +743,19 @@ static MpegTSService *mpegts_add_service(AVFormatContext 
*s, int sid,
 service->sid   = sid;
 service->pcr_pid   = 0x1fff;
 if (encode_str8(service->provider_name, provider_name) < 0 ||
-encode_str8(service->name, name) < 0) {
+encode_str8(service->name, service_name) < 0) {
 av_log(s, AV_LOG_ERROR, "Too long service or provider name\n");
 goto fail;
 }
 if (av_dynarray_add_nofree(>services, >nb_services, service) < 0)
 goto fail;
 
+service->pmt.write_packet = section_write_packet;
+service->pmt.opaque   = s;
+service->pmt.cc   = 15;
+service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
+service->program  = program;
+
 return service;
 fail:
 av_free(service);
@@ -833,13 +851,7 @@ static void select_pcr_streams(AVFormatContext *s)
 static int mpegts_init(AVFormatContext *s)
 {
 MpegTSWrite *ts = s->priv_data;
-MpegTSWriteStream *ts_st;
-MpegTSService *service;
-AVStream *st;
-AVDictionaryEntry *title, *provider;
 int i, j;
-const char *service_name;
-const char *provider_name;
 int *pids;
 int ret;
 
@@ -853,42 +865,13 @@ static int mpegts_init(AVFormatContext *s)
 ts->onid = ts->original_network_id;
 if (!s->nb_programs) {
 /* allocate a single DVB service */
-title = av_dict_get(s->metadata, "service_name", NULL, 0);
-if (!title)
-title = av_dict_get(s->metadata, "title", NULL, 0);
-service_name  = title ? title->value : DEFAULT_SERVICE_NAME;
-provider  = av_dict_get(s->metadata, "service_provider", NULL, 0);
-provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
-service   = mpegts_add_service(s, ts->service_id,
-   provider_name, service_name);
-
-if (!service)
+if (!mpegts_add_service(s, ts->service_id, s->metadata, NULL))
 return AVERROR(ENOMEM);
-
-service->pmt.write_packet = section_write_packet;
-service->pmt.opaque   = s;
-service->pmt.cc   = 15;
-service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
 } else {
 for (i = 0; i < s->nb_programs; i++) {
 AVProgram *program = s->programs[i];
-title = av_dict_get(program->metadata, "service_name", NULL, 0);
-if (!title)
-title = av_dict_get(program->metadata, "title", NULL, 0);
-service_name  = title ? title->value : DEFAULT_SERVICE_NAME;
-provider  = av_dict_get(program->metadata, "service_provider", 
NULL, 0);
-provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
-service   = mpegts_add_service(s, program->id,
-   provider_name, service_name);
-
-if (!service)
+if (!mpegts_add_service(s, program->id, program->metadata, 
program))
 return AVERROR(ENOMEM);
-
-service->pmt.write_packet = section_write_packet;
-service->pmt.opaque   = s;
-service->pmt.cc   = 15;
-service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
-service->program  = program;
 }
 }
 
@@ -914,7 +897,8 @@ static int mpegts_init(AVFormatContext *s)
 
 /* assign pids to each stream */
 for (i = 0; i < s->nb_streams; i++) {
-st = s->streams[i];
+AVStream *st = s->streams[i];
+

[FFmpeg-devel] [PATCH 6/6] avformat/mpegtsenc: remove deprecated resend_headers option

2019-08-08 Thread Marton Balint
Deprecated since 2014.

Signed-off-by: Marton Balint 
---
 doc/muxers.texi |  4 
 libavformat/mpegtsenc.c | 13 -
 2 files changed, 17 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index f9e8b60517..846b5f41db 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1611,10 +1611,6 @@ Conform to System B (DVB) instead of System A (ATSC).
 Mark the initial packet of each stream as discontinuity.
 @end table
 
-@item resend_headers @var{integer}
-Reemit PAT/PMT before writing the next packet. This option is deprecated:
-use @option{mpegts_flags} instead.
-
 @item mpegts_copyts @var{boolean}
 Preserve original timestamps, if value is set to @code{1}. Default value
 is @code{-1}, which results in shifting timestamps so that they start from 0.
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index aec2559b14..32f562ecac 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -97,8 +97,6 @@ typedef struct MpegTSWrite {
 int start_pid;
 int m2ts_mode;
 
-int reemit_pat_pmt; // backward compatibility
-
 int pcr_period;
 #define MPEGTS_FLAG_REEMIT_PAT_PMT  0x01
 #define MPEGTS_FLAG_AAC_LATM0x02
@@ -1530,13 +1528,6 @@ static int mpegts_write_packet_internal(AVFormatContext 
*s, AVPacket *pkt)
 if (side_data)
 stream_id = side_data[0];
 
-if (ts->reemit_pat_pmt) {
-av_log(s, AV_LOG_WARNING,
-   "resend_headers option is deprecated, use -mpegts_flags 
resend_headers\n");
-ts->reemit_pat_pmt = 0;
-ts->flags |= MPEGTS_FLAG_REEMIT_PAT_PMT;
-}
-
 if (ts->flags & MPEGTS_FLAG_REEMIT_PAT_PMT) {
 ts->pat_packet_count = ts->pat_packet_period - 1;
 ts->sdt_packet_count = ts->sdt_packet_period - 1;
@@ -1934,10 +1925,6 @@ static const AVOption options[] = {
 { "initial_discontinuity", "Mark initial packets as discontinuous",
   0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_DISCONT }, 0, INT_MAX,
   AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" },
-// backward compatibility
-{ "resend_headers", "Reemit PAT/PMT before writing the next packet",
-  offsetof(MpegTSWrite, reemit_pat_pmt), AV_OPT_TYPE_INT,
-  { .i64 = 0 }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
 { "mpegts_copyts", "don't offset dts/pts",
   offsetof(MpegTSWrite, copyts), AV_OPT_TYPE_BOOL,
   { .i64 = -1 }, -1, 1, AV_OPT_FLAG_ENCODING_PARAM },
-- 
2.16.4

___
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 5/6] avformat/mpegtsenc: fix PCR generation intervals

2019-08-08 Thread Marton Balint
PCR generation was based on counting packets for both CBR and VBR streams.
Couting packets might have worked for CBR streams (when muxrate was specified)
but it only took into account the packets of a service (or the packets of the
PCR stream lately), so even that was problematic for multi program streams.

The new code works on actual PCR for CBR and packet DTS values for VBR streams,
so the default 20ms PCR retransmission time is now respected for both CBR and
VBR.

The accuracy of PCR packets for CBR streams was greatly improved by preemtively
sending them at PCR intervals even if sending the payload of another stream
is in progress.

Signed-off-by: Marton Balint 
---
 doc/muxers.texi |  4 +--
 libavformat/mpegtsenc.c | 92 ++---
 tests/ref/lavf/ts   |  2 +-
 3 files changed, 44 insertions(+), 54 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index bc38cf6029..f9e8b60517 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1623,8 +1623,8 @@ is @code{-1}, which results in shifting timestamps so 
that they start from 0.
 Omit the PES packet length for video packets. Default is @code{1} (true).
 
 @item pcr_period @var{integer}
-Override the default PCR retransmission time in milliseconds. Ignored if
-variable muxrate is selected. Default is @code{20}.
+Override the default PCR retransmission time in milliseconds. Default is
+@code{20}.
 
 @item pat_period @var{double}
 Maximum time in seconds between PAT/PMT tables.
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index f4c1bb4717..aec2559b14 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -84,6 +84,7 @@ typedef struct MpegTSWrite {
 int onid;
 int tsid;
 int64_t first_pcr;
+int64_t next_pcr;
 int mux_rate; ///< set to 1 when VBR
 int pes_payload_size;
 
@@ -237,10 +238,9 @@ typedef struct MpegTSWriteStream {
 int payload_flags;
 uint8_t *payload;
 AVFormatContext *amux;
-AVRational user_tb;
 
-int pcr_packet_count;
-int pcr_packet_period;
+int64_t pcr_period; /* PCR period in PCR time base */
+int64_t last_pcr;
 
 /* For Opus */
 int opus_queued_samples;
@@ -787,39 +787,6 @@ fail:
 return NULL;
 }
 
-static void enable_pcr_generation_for_stream(AVFormatContext *s, AVStream 
*pcr_st)
-{
-MpegTSWrite *ts = s->priv_data;
-MpegTSWriteStream *ts_st = pcr_st->priv_data;
-
-if (ts->mux_rate > 1) {
-ts_st->pcr_packet_period   = (int64_t)ts->mux_rate * ts->pcr_period /
- (TS_PACKET_SIZE * 8 * 1000);
-} else {
-if (pcr_st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
-int frame_size = av_get_audio_frame_duration2(pcr_st->codecpar, 0);
-if (!frame_size) {
-av_log(s, AV_LOG_WARNING, "frame size not set\n");
-ts_st->pcr_packet_period =
-pcr_st->codecpar->sample_rate / (10 * 512);
-} else {
-ts_st->pcr_packet_period =
-pcr_st->codecpar->sample_rate / (10 * frame_size);
-}
-} else {
-// max delta PCR 0.1s
-// TODO: should be avg_frame_rate
-ts_st->pcr_packet_period =
-ts_st->user_tb.den / (10 * ts_st->user_tb.num);
-}
-if (!ts_st->pcr_packet_period)
-ts_st->pcr_packet_period = 1;
-}
-
-// output a PCR as soon as possible
-ts_st->pcr_packet_count = ts_st->pcr_packet_period;
-}
-
 static void select_pcr_streams(AVFormatContext *s)
 {
 MpegTSWrite *ts = s->priv_data;
@@ -842,8 +809,11 @@ static void select_pcr_streams(AVFormatContext *s)
 if (pcr_st) {
 MpegTSWriteStream *ts_st = pcr_st->priv_data;
 service->pcr_pid = ts_st->pid;
-enable_pcr_generation_for_stream(s, pcr_st);
-av_log(s, AV_LOG_VERBOSE, "service %i using PCR in pid=%i\n", 
service->sid, service->pcr_pid);
+ts_st->pcr_period = av_rescale(ts->pcr_period, PCR_TIME_BASE, 
1000);
+// output a PCR as soon as possible
+ts_st->last_pcr   = ts->first_pcr - ts_st->pcr_period;
+av_log(s, AV_LOG_VERBOSE, "service %i using PCR in pid=%i, 
pcr_period=%"PRId64"ms\n",
+service->sid, service->pcr_pid, av_rescale(ts_st->pcr_period, 
1000, PCR_TIME_BASE));
 }
 }
 }
@@ -907,7 +877,6 @@ static int mpegts_init(AVFormatContext *s)
 }
 st->priv_data = ts_st;
 
-ts_st->user_tb = st->time_base;
 avpriv_set_pts_info(st, 33, 1, 9);
 
 ts_st->payload = av_mallocz(ts->pes_payload_size);
@@ -1183,7 +1152,6 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
 uint8_t *q;
 int val, is_start, len, header_len, write_pcr, is_dvb_subtitle, 
is_dvb_teletext, flags;
 int afc_len, stuffing_len;
-int64_t pcr = -1; /* avoid warning */
 int64_t delay = 

[FFmpeg-devel] [PATCH 4/6] avformat/mpegtsenc: use increasing numbers in default service names

2019-08-08 Thread Marton Balint
Maybe we should use service ID instead of increasing numbers?

Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 68af45d8b5..f4c1bb4717 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -218,7 +218,7 @@ static int mpegts_write_section1(MpegTSSection *s, int tid, 
int id,
 /* mpegts writer */
 
 #define DEFAULT_PROVIDER_NAME   "FFmpeg"
-#define DEFAULT_SERVICE_NAME"Service01"
+#define DEFAULT_SERVICE_NAME"Service"
 
 /* we retransmit the SI info at this rate */
 #define SDT_RETRANS_TIME 500
@@ -749,13 +749,15 @@ static MpegTSService *mpegts_add_service(AVFormatContext 
*s, int sid,
 MpegTSWrite *ts = s->priv_data;
 MpegTSService *service;
 AVDictionaryEntry *title, *provider;
+char default_service_name[32];
 const char *service_name;
 const char *provider_name;
 
 title = av_dict_get(metadata, "service_name", NULL, 0);
 if (!title)
 title = av_dict_get(metadata, "title", NULL, 0);
-service_name  = title ? title->value : DEFAULT_SERVICE_NAME;
+snprintf(default_service_name, sizeof(default_service_name), "%s%02d", 
DEFAULT_SERVICE_NAME, ts->nb_services + 1);
+service_name  = title ? title->value : default_service_name;
 provider  = av_dict_get(metadata, "service_provider", NULL, 0);
 provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
 
-- 
2.16.4

___
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/6] avformat/mpegtsenc: remove section_write_packet forward declaration

2019-08-08 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 50 -
 1 file changed, 24 insertions(+), 26 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 13fdb6ff97..68af45d8b5 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -717,7 +717,30 @@ invalid:
 return 0;
 }
 
-static void section_write_packet(MpegTSSection *s, const uint8_t *packet);
+static int64_t get_pcr(const MpegTSWrite *ts, AVIOContext *pb)
+{
+return av_rescale(avio_tell(pb) + 11, 8 * PCR_TIME_BASE, ts->mux_rate) +
+   ts->first_pcr;
+}
+
+static void mpegts_prefix_m2ts_header(AVFormatContext *s)
+{
+MpegTSWrite *ts = s->priv_data;
+if (ts->m2ts_mode) {
+int64_t pcr = get_pcr(s->priv_data, s->pb);
+uint32_t tp_extra_header = pcr % 0x3fff;
+tp_extra_header = AV_RB32(_extra_header);
+avio_write(s->pb, (unsigned char *) _extra_header,
+   sizeof(tp_extra_header));
+}
+}
+
+static void section_write_packet(MpegTSSection *s, const uint8_t *packet)
+{
+AVFormatContext *ctx = s->opaque;
+mpegts_prefix_m2ts_header(ctx);
+avio_write(ctx->pb, packet, TS_PACKET_SIZE);
+}
 
 static MpegTSService *mpegts_add_service(AVFormatContext *s, int sid,
  const AVDictionary *metadata,
@@ -762,31 +785,6 @@ fail:
 return NULL;
 }
 
-static int64_t get_pcr(const MpegTSWrite *ts, AVIOContext *pb)
-{
-return av_rescale(avio_tell(pb) + 11, 8 * PCR_TIME_BASE, ts->mux_rate) +
-   ts->first_pcr;
-}
-
-static void mpegts_prefix_m2ts_header(AVFormatContext *s)
-{
-MpegTSWrite *ts = s->priv_data;
-if (ts->m2ts_mode) {
-int64_t pcr = get_pcr(s->priv_data, s->pb);
-uint32_t tp_extra_header = pcr % 0x3fff;
-tp_extra_header = AV_RB32(_extra_header);
-avio_write(s->pb, (unsigned char *) _extra_header,
-   sizeof(tp_extra_header));
-}
-}
-
-static void section_write_packet(MpegTSSection *s, const uint8_t *packet)
-{
-AVFormatContext *ctx = s->opaque;
-mpegts_prefix_m2ts_header(ctx);
-avio_write(ctx->pb, packet, TS_PACKET_SIZE);
-}
-
 static void enable_pcr_generation_for_stream(AVFormatContext *s, AVStream 
*pcr_st)
 {
 MpegTSWrite *ts = s->priv_data;
-- 
2.16.4

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

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

[FFmpeg-devel] [PATCH 1/6] avformat/mpegtsenc: fix incorrect PCR selection with multiple programs

2019-08-08 Thread Marton Balint
The MPEG-TS muxer had a serious bug related to the use of multiple programs:
in that case, the PCR pid selection was incomplete for all services except one.
This patch solves this problem and selects a stream to become PCR for each
service, preferably the video stream.

This patch also moves pcr calculation attributes to MpegTSWriteStream from
MpegTSService. PCR is a per-stream and not per-service thing, so it was
misleading to refer to it as something that is per-service.

Also remove *service from MpegTSWriteStream because a stream can belong to
multiple services so it was misleading to select one for each stream.

You can check the result with this example command:

./ffmpeg -loglevel verbose -y -f lavfi -i \
  
"testsrc=s=64x64:d=10,split=2[out0][tmp1];[tmp1]vflip[out1];sine=d=10,asetnsamples=1152[out2]"
 \
  -flags +bitexact -fflags +bitexact -sws_flags +accurate_rnd+bitexact  \
  -codec:v libx264 -codec:a mp2 -pix_fmt yuv420p \
  -map '0:v:0' \
  -map '0:v:1' \
  -map '0:a:0'  \
  -program st=0:st=2 -program st=1:st=2 -program st=2 -program st=0 -f mpegts 
out.ts

You should now see this:

[mpegts @ 0x37505c0] service 1 using PCR in pid=256
[mpegts @ 0x37505c0] service 2 using PCR in pid=257
[mpegts @ 0x37505c0] service 3 using PCR in pid=258
[mpegts @ 0x37505c0] service 4 using PCR in pid=256

Fixes ticket #8039.

v2: a video is stream is preferred if there are no programs, just like before
the patch.

Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 144 +++-
 1 file changed, 80 insertions(+), 64 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fc0ea225c6..661aa4066d 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -57,8 +57,6 @@ typedef struct MpegTSService {
 uint8_t name[256];
 uint8_t provider_name[256];
 int pcr_pid;
-int pcr_packet_count;
-int pcr_packet_period;
 AVProgram *program;
 } MpegTSService;
 
@@ -228,7 +226,6 @@ static int mpegts_write_section1(MpegTSSection *s, int tid, 
int id,
 #define PCR_RETRANS_TIME 20
 
 typedef struct MpegTSWriteStream {
-struct MpegTSService *service;
 int pid; /* stream associated pid */
 int cc;
 int discontinuity;
@@ -242,6 +239,9 @@ typedef struct MpegTSWriteStream {
 AVFormatContext *amux;
 AVRational user_tb;
 
+int pcr_packet_count;
+int pcr_packet_period;
+
 /* For Opus */
 int opus_queued_samples;
 int opus_pending_trim_start;
@@ -769,12 +769,73 @@ static void section_write_packet(MpegTSSection *s, const 
uint8_t *packet)
 avio_write(ctx->pb, packet, TS_PACKET_SIZE);
 }
 
+static void enable_pcr_generation_for_stream(AVFormatContext *s, AVStream 
*pcr_st)
+{
+MpegTSWrite *ts = s->priv_data;
+MpegTSWriteStream *ts_st = pcr_st->priv_data;
+
+if (ts->mux_rate > 1) {
+ts_st->pcr_packet_period   = (int64_t)ts->mux_rate * ts->pcr_period /
+ (TS_PACKET_SIZE * 8 * 1000);
+} else {
+if (pcr_st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+int frame_size = av_get_audio_frame_duration2(pcr_st->codecpar, 0);
+if (!frame_size) {
+av_log(s, AV_LOG_WARNING, "frame size not set\n");
+ts_st->pcr_packet_period =
+pcr_st->codecpar->sample_rate / (10 * 512);
+} else {
+ts_st->pcr_packet_period =
+pcr_st->codecpar->sample_rate / (10 * frame_size);
+}
+} else {
+// max delta PCR 0.1s
+// TODO: should be avg_frame_rate
+ts_st->pcr_packet_period =
+ts_st->user_tb.den / (10 * ts_st->user_tb.num);
+}
+if (!ts_st->pcr_packet_period)
+ts_st->pcr_packet_period = 1;
+}
+
+// output a PCR as soon as possible
+ts_st->pcr_packet_count = ts_st->pcr_packet_period;
+}
+
+static void select_pcr_streams(AVFormatContext *s)
+{
+MpegTSWrite *ts = s->priv_data;
+
+for (int i = 0; i < ts->nb_services; i++) {
+MpegTSService *service = ts->services[i];
+AVStream *pcr_st = NULL;
+AVProgram *program = service->program;
+int nb_streams = program ? program->nb_stream_indexes : s->nb_streams;
+
+for (int j = 0; j < nb_streams; j++) {
+AVStream *st = s->streams[program ? program->stream_index[j] : j];
+if (!pcr_st ||
+pcr_st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO && 
st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+{
+pcr_st = st;
+}
+}
+
+if (pcr_st) {
+MpegTSWriteStream *ts_st = pcr_st->priv_data;
+service->pcr_pid = ts_st->pid;
+enable_pcr_generation_for_stream(s, pcr_st);
+av_log(s, AV_LOG_VERBOSE, "service %i using PCR in pid=%i\n", 
service->sid, service->pcr_pid);
+}
+}
+}
+
 static int 

[FFmpeg-devel] [PATCH 2/2] avformat/rpl: Support files containing Replay IMA ADPCM audio

2019-08-08 Thread Cameron Cawley
---
 libavformat/rpl.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index 6afd373810..d31c7f09ad 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -121,6 +121,7 @@ static int rpl_read_header(AVFormatContext *s)
 int error = 0;
 const char *endptr;
 char audio_type[RPL_LINE_LENGTH];
+char audio_codec[RPL_LINE_LENGTH];
 
 uint32_t i;
 
@@ -189,7 +190,9 @@ static int rpl_read_header(AVFormatContext *s)
 
 // ARMovie supports multiple audio tracks; I don't have any
 // samples, though. This code will ignore additional tracks.
-audio_format = read_line_and_int(pb, );  // audio format ID
+error |= read_line(pb, line, sizeof(line));
+audio_format = read_int(line, , );  // audio format ID
+av_strlcpy(audio_codec, endptr, RPL_LINE_LENGTH);
 if (audio_format) {
 ast = avformat_new_stream(s, NULL);
 if (!ast)
@@ -229,6 +232,14 @@ static int rpl_read_header(AVFormatContext *s)
 break;
 }
 }
+break;
+case 2:
+if (av_strcasecmp(audio_codec," adpcm") == 0) {
+ast->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_ACORN;
+} else {
+avpriv_report_missing_feature(s, "Audio format %"PRId32" 
(%s)",
+  audio_format, audio_codec);
+}
 // There are some other formats listed as legal per the spec;
 // samples needed.
 break;
-- 
2.11.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 1/2] avcodec: Implement Acorn Replay IMA ADPCM decoder

2019-08-08 Thread Cameron Cawley
Signed-off-by: Cameron Cawley 
---
 doc/general.texi|  1 +
 libavcodec/Makefile |  1 +
 libavcodec/adpcm.c  | 14 ++
 libavcodec/allcodecs.c  |  1 +
 libavcodec/avcodec.h|  1 +
 libavcodec/codec_desc.c |  7 +++
 libavcodec/utils.c  |  1 +
 7 files changed, 26 insertions(+)

diff --git a/doc/general.texi b/doc/general.texi
index 3c0c803449..db30738716 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -1072,6 +1072,7 @@ following image formats are supported:
 @item ADPCM Electronic Arts XAS @tab @tab  X
 @item ADPCM G.722@tab  X  @tab  X
 @item ADPCM G.726@tab  X  @tab  X
+@item ADPCM IMA Acorn Replay @tab @tab  X
 @item ADPCM IMA AMV  @tab @tab  X
 @tab Used in AMV files
 @item ADPCM IMA Electronic Arts EACS  @tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3cd73fbcc6..c0a038495f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -825,6 +825,7 @@ OBJS-$(CONFIG_ADPCM_G726_DECODER) += g726.o
 OBJS-$(CONFIG_ADPCM_G726_ENCODER) += g726.o
 OBJS-$(CONFIG_ADPCM_G726LE_DECODER)   += g726.o
 OBJS-$(CONFIG_ADPCM_G726LE_ENCODER)   += g726.o
+OBJS-$(CONFIG_ADPCM_IMA_ACORN_DECODER)+= adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_DAT4_DECODER) += adpcm.o adpcm_data.o
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index fb126503d6..70503fc0b1 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -599,6 +599,7 @@ static int get_nb_samples(AVCodecContext *avctx, 
GetByteContext *gb,
 switch (avctx->codec->id) {
 case AV_CODEC_ID_ADPCM_4XM:
 case AV_CODEC_ID_ADPCM_AGM:
+case AV_CODEC_ID_ADPCM_IMA_ACORN:
 case AV_CODEC_ID_ADPCM_IMA_DAT4:
 case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch;  break;
 case AV_CODEC_ID_ADPCM_IMA_AMV: header_size = 8;   break;
@@ -1441,6 +1442,18 @@ static int adpcm_decode_frame(AVCodecContext *avctx, 
void *data,
 }
 }
 break;
+case AV_CODEC_ID_ADPCM_IMA_ACORN:
+for (i=0; i<=st; i++) {
+bytestream2_skip(, 2); // TODO: What does this do?
+c->status[i].step_index = bytestream2_get_le16u();
+}
+
+for (n = nb_samples >> (1 - st); n > 0; n--) {
+int byte = bytestream2_get_byteu();
+*samples++ = adpcm_ima_expand_nibble(>status[0],  byte & 0x0F, 
6);
+*samples++ = adpcm_ima_expand_nibble(>status[st], byte >> 4,   
6);
+}
+break;
 case AV_CODEC_ID_ADPCM_IMA_AMV:
 c->status[0].predictor = sign_extend(bytestream2_get_le16u(), 16);
 c->status[0].step_index = bytestream2_get_byteu();
@@ -1825,6 +1838,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R1,   
sample_fmts_s16p, adpcm_ea_r1,
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R2,   sample_fmts_s16p, adpcm_ea_r2,
   "ADPCM Electronic Arts R2");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R3,   sample_fmts_s16p, adpcm_ea_r3,
   "ADPCM Electronic Arts R3");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_XAS,  sample_fmts_s16p, adpcm_ea_xas,   
   "ADPCM Electronic Arts XAS");
+ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ACORN,   sample_fmts_s16,  
adpcm_ima_acorn,   "ADPCM IMA Acorn Replay");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_AMV, sample_fmts_s16,  adpcm_ima_amv,  
   "ADPCM IMA AMV");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APC, sample_fmts_s16,  adpcm_ima_apc,  
   "ADPCM IMA CRYO APC");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DAT4,sample_fmts_s16,  adpcm_ima_dat4, 
   "ADPCM IMA Eurocom DAT4");
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index d2f9a39ce5..78177a1255 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -592,6 +592,7 @@ extern AVCodec ff_adpcm_g726_encoder;
 extern AVCodec ff_adpcm_g726_decoder;
 extern AVCodec ff_adpcm_g726le_encoder;
 extern AVCodec ff_adpcm_g726le_decoder;
+extern AVCodec ff_adpcm_ima_acorn_decoder;
 extern AVCodec ff_adpcm_ima_amv_decoder;
 extern AVCodec ff_adpcm_ima_apc_decoder;
 extern AVCodec ff_adpcm_ima_dat4_decoder;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index d234271c5b..c8b6ec7f3c 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -542,6 +542,7 @@ enum AVCodecID {
 AV_CODEC_ID_ADPCM_IMA_DAT4,
 AV_CODEC_ID_ADPCM_MTAF,
 AV_CODEC_ID_ADPCM_AGM,
+AV_CODEC_ID_ADPCM_IMA_ACORN,
 
 /* AMR */
 AV_CODEC_ID_AMR_NB = 0x12000,
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 4d033c20ff..dc39b50e33 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2276,6 +2276,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("ADPCM AmuseGraphics Movie AGM"),
 .props = AV_CODEC_PROP_LOSSY,
 },
+{
+.id= 

Re: [FFmpeg-devel] [PATCH v10 04/13] lavc/tiff: Apply color scaling to uncompressed DNGs

2019-08-08 Thread Nick Renieris
Thanks for the review Michael, pushing fixes and a commit that makes
some more images compatible.

Στις Πέμ, 8 Αυγ 2019 στις 1:22 π.μ., ο/η Michael Niedermayer
 έγραψε:
>
> On Wed, Aug 07, 2019 at 06:27:14PM +0300, velocit...@gmail.com wrote:
> > From: Nick Renieris 
> >
> > Signed-off-by: Nick Renieris 
> > ---
> >  libavcodec/tiff.c | 22 +-
> >  1 file changed, 21 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
> > index c7e2adb3ae..b6f626daca 100644
> > --- a/libavcodec/tiff.c
> > +++ b/libavcodec/tiff.c
> > @@ -679,6 +679,25 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame 
> > *p, uint8_t *dst, int strid
> >  for (i = 0; i < width; i++)
> >  dst[i] = ff_reverse[src[i]];
> >  }
> > +
> > +/* Color processing for DNG images with uncompressed strips 
> > (non-tiled) */
> > +if (is_dng) {
>
> This variable is only added in a later patch
> so this does not build
>
> also some change in this patchset breaks:
> ./ffplay tickets/2826/pred6disc7.jpg
> file should be here:
> https://trac.ffmpeg.org/raw-attachment/ticket/2826/pred6disc7.jpg
>
> Thanks
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Does the universe only have a finite lifespan? No, its going to go on
> forever, its just that you wont like living in it. -- Hiranya Peiri
> ___
> 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 v11 10/14] lavc/tiff: Support decoding of DNGs with single-component JPEGs

2019-08-08 Thread velocityra
From: Nick Renieris 

This enables decoding of DNG images generated by the 'DJI Zenmuse X7'
digital camera
Samples: https://www.dji.com/gr/zenmuse-x7/info#downloads

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 61 +++
 1 file changed, 51 insertions(+), 10 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 9d20763186..52c49e1bcf 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -274,7 +274,8 @@ static int add_metadata(int count, int type,
 }
 
 static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
-  const uint8_t *src, int src_stride, int 
width, int height, int is_u16);
+  const uint8_t *src, int src_stride, int 
width, int height,
+  int is_single_comp, int is_u16);
 
 static void av_always_inline horizontal_fill(TiffContext *s,
  unsigned int bpp, uint8_t* dst,
@@ -698,6 +699,7 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
  0, // no stride, only 1 line
  width / pixel_size_bytes * pixel_size_bits / s->bpp, 
// need to account for [1, 16] bpp
  1,
+ 0, // single-component variation is only preset in 
JPEG-encoded DNGs
  is_u16);
 }
 
@@ -795,18 +797,32 @@ static uint16_t av_always_inline 
dng_process_color8(uint16_t value,
 
 static void dng_blit(TiffContext *s, uint8_t *dst, int dst_stride,
  const uint8_t *src, int src_stride,
- int width, int height, int is_u16)
+ int width, int height, int is_single_comp, int is_u16)
 {
 int line, col;
 float scale_factor;
 
 scale_factor = 1.0f / (s->white_level - s->black_level);
 
-if (is_u16) {
-for (line = 0; line < height; line++) {
+if (is_single_comp) {
+if (!is_u16)
+return; /* <= 8bpp unsupported */
+
+/* Image is double the width and half the height we need, each row 
comprises 2 rows of the output
+   (split vertically in the middle). */
+for (line = 0; line < height / 2; line++) {
 uint16_t *dst_u16 = (uint16_t *)dst;
 uint16_t *src_u16 = (uint16_t *)src;
 
+/* Blit first half of input row row to initial row of output */
+for (col = 0; col < width; col++)
+*dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, 
s->black_level, scale_factor);
+
+/* Advance the destination pointer by a row (source pointer 
remains in the same place) */
+dst += dst_stride * sizeof(uint16_t);
+dst_u16 = (uint16_t *)dst;
+
+/* Blit second half of input row row to next row of output */
 for (col = 0; col < width; col++)
 *dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, 
s->black_level, scale_factor);
 
@@ -814,12 +830,27 @@ static void dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
 src += src_stride * sizeof(uint16_t);
 }
 } else {
-for (line = 0; line < height; line++) {
-for (col = 0; col < width; col++)
-*dst++ = dng_process_color8(*src++, s->dng_lut, 
s->black_level, scale_factor);
+/* Input and output image are the same size and the MJpeg decoder has 
done per-component
+   deinterleaving, so blitting here is straightforward. */
+if (is_u16) {
+for (line = 0; line < height; line++) {
+uint16_t *dst_u16 = (uint16_t *)dst;
+uint16_t *src_u16 = (uint16_t *)src;
+
+for (col = 0; col < width; col++)
+*dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, 
s->black_level, scale_factor);
+
+dst += dst_stride * sizeof(uint16_t);
+src += src_stride * sizeof(uint16_t);
+}
+} else {
+for (line = 0; line < height; line++) {
+for (col = 0; col < width; col++)
+*dst++ = dng_process_color8(*src++, s->dng_lut, 
s->black_level, scale_factor);
 
-dst += dst_stride;
-src += src_stride;
+dst += dst_stride;
+src += src_stride;
+}
 }
 }
 }
@@ -831,7 +862,7 @@ static int dng_decode_jpeg_tile(AVCodecContext *avctx, 
AVFrame *frame,
 AVPacket jpkt;
 uint8_t *dst_data, *src_data;
 uint32_t dst_offset; /* offset from dst buffer in pixels */
-int is_u16, pixel_size;
+int is_single_comp, is_u16, pixel_size;
 int ret;
 
 /* Prepare a packet and send to the MJPEG decoder */
@@ -858,9 +889,18 @@ static int dng_decode_jpeg_tile(AVCodecContext *avctx, 
AVFrame *frame,
 
 /* Copy the outputted tile's pixels from 

[FFmpeg-devel] [PATCH v11 12/14] lavc/mjpegdec: Skip useless APPx marker on bayer images

2019-08-08 Thread velocityra
From: Nick Renieris 

Samples:
- Embedded JPEG images in the DNG images here:
  https://www.photographyblog.com/previews/pentax_k1_photos

Signed-off-by: Nick Renieris 
---
 libavcodec/mjpegdec.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 94cf73549d..b3d6279853 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1810,8 +1810,15 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
 int len, id, i;
 
 len = get_bits(>gb, 16);
-if (len < 6)
-return AVERROR_INVALIDDATA;
+if (len < 6) {
+if (s->bayer) {
+// Pentax K-1 (digital camera) JPEG images embedded in DNG images 
contain useless APP0 markers
+av_log(s->avctx, AV_LOG_WARNING, "skipping APPx (len=%"PRId32") 
for bayer-encoded image\n", len);
+skip_bits(>gb, len);
+return 0;
+} else
+return AVERROR_INVALIDDATA;
+}
 if (8 * len > get_bits_left(>gb))
 return AVERROR_INVALIDDATA;
 
-- 
2.21.0.windows.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 v11 14/14] lavc/tiff: Initialize WhiteLevel DNG tag value

2019-08-08 Thread velocityra
From: Nick Renieris 

Inited to (2^BitsPerSample)-1 as per the DNG Specification

This fixes decoding for "X7 CinemaDNG" samples here:
- https://www.dji.com/gr/zenmuse-x7/info#downloads

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 47140cddbc..47f2a5a441 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1787,7 +1787,7 @@ again:
 s->photometric = TIFF_PHOTOMETRIC_NONE;
 s->compr   = TIFF_RAW;
 s->fill_order  = 0;
-s->white_level = 0;
+s->white_level = (1 << s->bpp) - 1; /* Default value as per the spec */
 s->is_bayer= 0;
 s->is_tiled= 0;
 s->is_jpeg = 0;
@@ -2044,7 +2044,7 @@ again:
 FFSWAP(int,  p->linesize[0], p->linesize[1]);
 }
 
-if (s->is_bayer && s->white_level && s->bpp == 16 &&
+if (s->is_bayer && (s->white_level != (1 << s->bpp) - 1) && s->bpp == 16 &&
 !(s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG)) {
 uint16_t *dst = (uint16_t *)p->data[0];
 for (i = 0; i < s->height; i++) {
-- 
2.21.0.windows.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 v11 09/14] lavc/mjpegdec: Enable decoding of single-component bayer images

2019-08-08 Thread velocityra
From: Nick Renieris 

Signed-off-by: Nick Renieris 
---
 libavcodec/mjpegdec.c | 35 ---
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 6391107f78..94cf73549d 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -412,13 +412,21 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 return AVERROR_PATCHWELCOME;
 }
 
-/* Lossless JPEGs encoded in DNGs are commonly bayer-encoded. They contain 
2
-   interleaved components and the width stored in their SOF3 markers is the
-   width of each one.  We only output a single component, therefore we need
-   to adjust the output image width. */
-if (s->lossless == 1 && nb_components == 2) {
-s->bayer = 1;
-width *= 2;
+/* Lossless JPEGs encoded in DNGs are commonly bayer-encoded. */
+if (s->lossless) {
+if (nb_components == 1) {
+/* They can contain 1 component, which is double the width and 
half the height
+   of the final image (rows are interleaved).  We don't handle the 
decoding in
+   this file, but leave that to the DNG decoder. */
+s->bayer = 1;
+} else if (nb_components == 2) {
+/* Or they can contain 2 interleaved components and the width 
stored in their
+   SOF3 markers is the width of each one.  We only output a single 
component,
+   therefore we need to adjust the output image width.  We handle 
the
+   deinterleaving (but not the debayering) in this file. */
+s->bayer = 1;
+width *= 2;
+}
 }
 
 /* if different size, realloc/alloc picture */
@@ -1184,10 +1192,15 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
 ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
 }
-} else if (s->bayer && nb_components == 2) {
-for (mb_x = 0; mb_x < width; mb_x++) {
-((uint16_t*)ptr)[2*mb_x + 0] = buffer[mb_x][0];
-((uint16_t*)ptr)[2*mb_x + 1] = buffer[mb_x][1];
+} else if (s->bayer) {
+if (nb_components == 1) {
+for (mb_x = 0; mb_x < width; mb_x++)
+((uint16_t*)ptr)[mb_x] = buffer[mb_x][0];
+} else if (nb_components == 2) {
+for (mb_x = 0; mb_x < width; mb_x++) {
+((uint16_t*)ptr)[2*mb_x + 0] = buffer[mb_x][0];
+((uint16_t*)ptr)[2*mb_x + 1] = buffer[mb_x][1];
+}
 }
 } else {
 for(i=0; ihttps://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v11 13/14] lavc/tiff: Support DNGs with striped (non-tiled) JPEGs images

2019-08-08 Thread velocityra
From: Nick Renieris 

DNG samples here can now be decoded:
- https://www.photographyblog.com/previews/pentax_k1_photos

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 73 +++
 1 file changed, 42 insertions(+), 31 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 7855c36aa7..47140cddbc 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -550,6 +550,8 @@ static int tiff_unpack_fax(TiffContext *s, uint8_t *dst, 
int stride,
 return ret;
 }
 
+static int dng_decode_strip(AVCodecContext *avctx, AVFrame *frame);
+
 static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int 
stride,
  const uint8_t *src, int size, int strip_start, 
int lines)
 {
@@ -665,6 +667,17 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 
 is_dng = (s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG);
 
+/* Decode JPEG-encoded DNGs with strips */
+if (s->compr == TIFF_NEWJPEG && is_dng) {
+if (s->strips > 1) {
+av_log(s->avctx, AV_LOG_ERROR, "More than one DNG JPEG strips 
unsupported\n");
+return AVERROR_PATCHWELCOME;
+}
+if ((ret = dng_decode_strip(s->avctx, p)) < 0)
+return ret;
+return 0;
+}
+
 for (line = 0; line < lines; line++) {
 if (src - ssrc > size) {
 av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n");
@@ -859,8 +872,8 @@ static void dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
 }
 }
 
-static int dng_decode_jpeg_tile(AVCodecContext *avctx, AVFrame *frame,
-int tile_byte_count, int x, int y, int w, int 
h)
+static int dng_decode_jpeg(AVCodecContext *avctx, AVFrame *frame,
+   int tile_byte_count, int dst_x, int dst_y, int w, 
int h)
 {
 TiffContext *s = avctx->priv_data;
 AVPacket jpkt;
@@ -905,7 +918,7 @@ static int dng_decode_jpeg_tile(AVCodecContext *avctx, 
AVFrame *frame,
 return AVERROR_PATCHWELCOME;
 }
 
-dst_offset = x + frame->linesize[0] * y / pixel_size;
+dst_offset = dst_x + frame->linesize[0] * dst_y / pixel_size;
 dst_data = frame->data[0] + dst_offset * pixel_size;
 src_data = s->jpgframe->data[0];
 
@@ -924,7 +937,7 @@ static int dng_decode_jpeg_tile(AVCodecContext *avctx, 
AVFrame *frame,
 return 0;
 }
 
-static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame)
+static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame, AVPacket 
*avpkt)
 {
 TiffContext *s = avctx->priv_data;
 int tile_idx;
@@ -937,6 +950,12 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame 
*frame)
 int pos_x = 0, pos_y = 0;
 int ret;
 
+s->jpgframe->width  = s->tile_width;
+s->jpgframe->height = s->tile_length;
+
+s->avctx_mjpeg->width = s->tile_width;
+s->avctx_mjpeg->height = s->tile_length;
+
 has_width_leftover = (s->width % s->tile_width != 0);
 has_height_leftover = (s->height % s->tile_length != 0);
 
@@ -973,7 +992,7 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame 
*frame)
 bytestream2_seek(>gb, tile_offset, SEEK_SET);
 
 /* Decode JPEG tile and copy it in the reference frame */
-ret = dng_decode_jpeg_tile(avctx, frame, tile_byte_count, pos_x, 
pos_y, tile_width, tile_length);
+ret = dng_decode_jpeg(avctx, frame, tile_byte_count, pos_x, pos_y, 
tile_width, tile_length);
 
 if (ret < 0)
 return ret;
@@ -986,30 +1005,24 @@ static int dng_decode_tiles(AVCodecContext *avctx, 
AVFrame *frame)
 }
 }
 
-return 0;
-}
+/* Frame is ready to be output */
+frame->pict_type = AV_PICTURE_TYPE_I;
+frame->key_frame = 1;
 
-static int dng_decode(AVCodecContext *avctx, AVFrame *frame, AVPacket *avpkt) {
-int ret;
+return avpkt->size;
+}
 
+static int dng_decode_strip(AVCodecContext *avctx, AVFrame *frame)
+{
 TiffContext *s = avctx->priv_data;
 
-s->jpgframe->width  = s->tile_width;
-s->jpgframe->height = s->tile_length;
-
-s->avctx_mjpeg->width = s->tile_width;
-s->avctx_mjpeg->height = s->tile_length;
-
-/* Decode all tiles in a frame */
-ret = dng_decode_tiles(avctx, frame);
-if (ret < 0)
-return ret;
+s->jpgframe->width  = s->width;
+s->jpgframe->height = s->height;
 
-/* Frame is ready to be output */
-frame->pict_type = AV_PICTURE_TYPE_I;
-frame->key_frame = 1;
+s->avctx_mjpeg->width = s->width;
+s->avctx_mjpeg->height = s->height;
 
-return avpkt->size;
+return dng_decode_jpeg(avctx, frame, s->stripsize, 0, 0, s->width, 
s->height);
 }
 
 static int init_image(TiffContext *s, ThreadFrame *frame)
@@ -1873,17 +1886,15 @@ again:
 
 /* Handle DNG images with JPEG-compressed tiles */
 
-if (s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == TIFF_TYPE_CINEMADNG) {
-if (!s->is_jpeg && 

[FFmpeg-devel] [PATCH v11 07/14] lavc/tiff: Don't apply strips-related logic to tiled images

2019-08-08 Thread velocityra
From: Nick Renieris 

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 42 ++
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 37fda15162..174ca168c6 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1780,7 +1780,7 @@ again:
 }
 }
 
-if (!s->strippos && !s->stripoff) {
+if (!s->is_tiled && !s->strippos && !s->stripoff) {
 av_log(avctx, AV_LOG_ERROR, "Image data is missing\n");
 return AVERROR_INVALIDDATA;
 }
@@ -1788,27 +1788,29 @@ again:
 if ((ret = init_image(s, )) < 0)
 return ret;
 
-if (s->strips == 1 && !s->stripsize) {
-av_log(avctx, AV_LOG_WARNING, "Image data size missing\n");
-s->stripsize = avpkt->size - s->stripoff;
-}
+if (!s->is_tiled) {
+if (s->strips == 1 && !s->stripsize) {
+av_log(avctx, AV_LOG_WARNING, "Image data size missing\n");
+s->stripsize = avpkt->size - s->stripoff;
+}
 
-if (s->stripsizesoff) {
-if (s->stripsizesoff >= (unsigned)avpkt->size)
-return AVERROR_INVALIDDATA;
-bytestream2_init(, avpkt->data + s->stripsizesoff,
- avpkt->size - s->stripsizesoff);
-}
-if (s->strippos) {
-if (s->strippos >= (unsigned)avpkt->size)
-return AVERROR_INVALIDDATA;
-bytestream2_init(, avpkt->data + s->strippos,
- avpkt->size - s->strippos);
-}
+if (s->stripsizesoff) {
+if (s->stripsizesoff >= (unsigned)avpkt->size)
+return AVERROR_INVALIDDATA;
+bytestream2_init(, avpkt->data + s->stripsizesoff,
+avpkt->size - s->stripsizesoff);
+}
+if (s->strippos) {
+if (s->strippos >= (unsigned)avpkt->size)
+return AVERROR_INVALIDDATA;
+bytestream2_init(, avpkt->data + s->strippos,
+avpkt->size - s->strippos);
+}
 
-if (s->rps <= 0 || s->rps % s->subsampling[1]) {
-av_log(avctx, AV_LOG_ERROR, "rps %d invalid\n", s->rps);
-return AVERROR_INVALIDDATA;
+if (s->rps <= 0 || s->rps % s->subsampling[1]) {
+av_log(avctx, AV_LOG_ERROR, "rps %d invalid\n", s->rps);
+return AVERROR_INVALIDDATA;
+}
 }
 
 /* Handle DNG images with JPEG-compressed tiles */
-- 
2.21.0.windows.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 v11 08/14] lavc/tiff: Force DNG pixel data endianness on an edge case

2019-08-08 Thread velocityra
From: Nick Renieris 

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 174ca168c6..9d20763186 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1038,6 +1038,18 @@ static int init_image(TiffContext *s, ThreadFrame *frame)
AV_RL32(s->pattern));
 return AVERROR_PATCHWELCOME;
 }
+/* Force endianness as mentioned in 'DNG Specification: Chapter 3: 
BitsPerSample'
+NOTE: The spec actually specifies big-endian, not sure why we need 
little-endian,
+  but such images don't work otherwise. */
+if ((s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG)
+&& (s->bpp != 8 && s->bpp != 16 && s->bpp != 32)) {
+switch (s->avctx->pix_fmt) {
+case AV_PIX_FMT_BAYER_RGGB16BE: s->avctx->pix_fmt = 
AV_PIX_FMT_BAYER_RGGB16LE; break;
+case AV_PIX_FMT_BAYER_BGGR16BE: s->avctx->pix_fmt = 
AV_PIX_FMT_BAYER_BGGR16LE; break;
+case AV_PIX_FMT_BAYER_GBRG16BE: s->avctx->pix_fmt = 
AV_PIX_FMT_BAYER_GBRG16LE; break;
+case AV_PIX_FMT_BAYER_GRBG16BE: s->avctx->pix_fmt = 
AV_PIX_FMT_BAYER_GRBG16LE; break;
+}
+}
 break;
 case 10161:
 switch (AV_RL32(s->pattern)) {
-- 
2.21.0.windows.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 v11 06/14] lavc/tiff: Fix edge case with full-length/width tiles

2019-08-08 Thread velocityra
From: Nick Renieris 

In an image [1], the height was equal to the tile length (full-height
tile) and after `height % tile_length` was applied to them with the
current code, it resulted in the operating tile_length to be 0.  This
commit makes this leftover logic only applies if it's necessary.

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 4620508d53..37fda15162 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -887,10 +887,14 @@ static int dng_decode_tiles(AVCodecContext *avctx, 
AVFrame *frame)
 int tile_byte_count_offset, tile_byte_count;
 int tile_count_x, tile_count_y;
 int tile_width, tile_length;
+int has_width_leftover, has_height_leftover;
 int tile_x = 0, tile_y = 0;
 int pos_x = 0, pos_y = 0;
 int ret;
 
+has_width_leftover = (s->width % s->tile_width != 0);
+has_height_leftover = (s->height % s->tile_length != 0);
+
 /* Calculate tile counts (round up) */
 tile_count_x = (s->width + s->tile_width - 1) / s->tile_width;
 tile_count_y = (s->height + s->tile_length - 1) / s->tile_length;
@@ -900,12 +904,12 @@ static int dng_decode_tiles(AVCodecContext *avctx, 
AVFrame *frame)
 tile_x = tile_idx % tile_count_x;
 tile_y = tile_idx / tile_count_x;
 
-if (tile_x == tile_count_x - 1) // If on the right edge
+if (has_width_leftover && tile_x == tile_count_x - 1) // If on the 
right-most tile
 tile_width = s->width % s->tile_width;
 else
 tile_width = s->tile_width;
 
-if (tile_y == tile_count_y - 1) // If on the bottom edge
+if (has_height_leftover && tile_y == tile_count_y - 1) // If on the 
bottom-most tile
 tile_length = s->height % s->tile_length;
 else
 tile_length = s->tile_length;
-- 
2.21.0.windows.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 v11 05/14] lavc/jpegtables: Handle multiple mappings to the same value

2019-08-08 Thread velocityra
From: Nick Renieris 

Some JPEGs [1] have incorrect DHT entries that map 2 codes to
the same value.

The second (last) mapping does not ever actually appear in the
code stream, therefore ignoring any mappings after the first one
fixes this.

Without this, an "mjpeg_decode_dc: bad vlc: 0:0" error is thrown.

---

[1]: Embedded JPEGs in "X7 RAW" and "X7 CinemaDNG" samples here:
 https://www.dji.com/gr/zenmuse-x7/info#downloads

Signed-off-by: Nick Renieris 
---
 libavcodec/jpegtables.c | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/libavcodec/jpegtables.c b/libavcodec/jpegtables.c
index cbe5523cb4..6f596cfc92 100644
--- a/libavcodec/jpegtables.c
+++ b/libavcodec/jpegtables.c
@@ -130,14 +130,27 @@ void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, 
uint16_t *huff_code,
 {
 int i, j, k,nb, code, sym;
 
-code = 0;
+/* Zero-initialize huff_size (needed for multiple mappings check below) */
+k = 0;
+for(i=1;i<=16;i++) {
+nb = bits_table[i];
+for(j=0;jhttps://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v11 11/14] lavc/tiff: Decode 14-bit DNG images

2019-08-08 Thread velocityra
From: Nick Renieris 

Sample file: 
https://drive.google.com/open?id=0B4JyRT3Lth5HVndyOTVOdWktM3J4TFEydTk1MnY3RWlpSzVB

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 52c49e1bcf..7855c36aa7 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -309,14 +309,18 @@ static void av_always_inline horizontal_fill(TiffContext 
*s,
 dst[(width+offset)*2+0] = (usePtr ? src[width] : c) >> 4;
 }
 break;
-case 12: {
- uint16_t *dst16 = (uint16_t *)dst;
- GetBitContext gb;
- init_get_bits8(, src, width);
- for (int i = 0; i < s->width; i++) {
- dst16[i] = get_bits(, 12) << 4;
- }
- }
+case 12:
+case 14: {
+uint16_t *dst16 = (uint16_t *)dst;
+int is_dng = (s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG);
+uint8_t shift = is_dng ? 0 : 16 - bpp;
+GetBitContext gb;
+
+init_get_bits8(, src, width);
+for (int i = 0; i < s->width; i++) {
+dst16[i] = get_bits(, bpp) << shift;
+}
+}
 break;
 default:
 if (usePtr) {
@@ -1061,6 +1065,7 @@ static int init_image(TiffContext *s, ThreadFrame *frame)
 }
 break;
 case 10121:
+case 10141:
 switch (AV_RL32(s->pattern)) {
 case 0x02010100:
 s->avctx->pix_fmt = s->le ? AV_PIX_FMT_BAYER_RGGB16LE : 
AV_PIX_FMT_BAYER_RGGB16BE;
-- 
2.21.0.windows.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 v11 04/14] lavc/tiff: Apply color scaling to uncompressed DNGs

2019-08-08 Thread velocityra
From: Nick Renieris 

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index a118c37c41..4620508d53 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -556,6 +556,7 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 int is_yuv = !(desc->flags & AV_PIX_FMT_FLAG_RGB) &&
  (desc->flags & AV_PIX_FMT_FLAG_PLANAR) &&
  desc->nb_components >= 3;
+int is_dng;
 
 if (s->planar)
 width /= s->bppcount;
@@ -657,6 +658,8 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 bytestream2_init(>gb, src, size);
 bytestream2_init_writer(, dst, is_yuv ? s->yuv_line_size : (stride * 
lines));
 
+is_dng = (s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG);
+
 for (line = 0; line < lines; line++) {
 if (src - ssrc > size) {
 av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n");
@@ -679,6 +682,25 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 for (i = 0; i < width; i++)
 dst[i] = ff_reverse[src[i]];
 }
+
+/* Color processing for DNG images with uncompressed strips 
(non-tiled) */
+if (is_dng) {
+int is_u16, pixel_size_bytes, pixel_size_bits;
+
+is_u16 = (s->bpp > 8);
+pixel_size_bits = (is_u16 ? 16 : 8);
+pixel_size_bytes = (is_u16 ? sizeof(uint16_t) : 
sizeof(uint8_t));
+
+dng_blit(s,
+ dst,
+ 0, // no stride, only 1 line
+ dst,
+ 0, // no stride, only 1 line
+ width / pixel_size_bytes * pixel_size_bits / s->bpp, 
// need to account for [1, 16] bpp
+ 1,
+ is_u16);
+}
+
 src += width;
 break;
 case TIFF_PACKBITS:
@@ -1947,7 +1969,8 @@ again:
 FFSWAP(int,  p->linesize[0], p->linesize[1]);
 }
 
-if (s->is_bayer && s->white_level && s->bpp == 16) {
+if (s->is_bayer && s->white_level && s->bpp == 16 &&
+!(s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG)) {
 uint16_t *dst = (uint16_t *)p->data[0];
 for (i = 0; i < s->height; i++) {
 for (j = 0; j < s->width; j++)
-- 
2.21.0.windows.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 v11 03/14] lavc/tiff: Convert DNGs to sRGB color space

2019-08-08 Thread velocityra
From: Nick Renieris 

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 34 +++---
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index d5673abb19..a118c37c41 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -731,14 +731,23 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 return 0;
 }
 
+static float av_always_inline linear_to_srgb(float value) {
+if (value <= 0.0031308)
+return value * 12.92;
+else
+return pow(value * 1.055, 1.0 / 2.4) - 0.055;
+}
+
 /**
- * Map stored raw sensor values into linear reference values.
- * See: DNG Specification - Chapter 5
+ * Map stored raw sensor values into linear reference values (see: DNG 
Specification - Chapter 5)
+ * Then convert to sRGB color space.
  */
-static uint16_t av_always_inline dng_raw_to_linear16(uint16_t value,
-const uint16_t *lut,
-uint16_t black_level,
-float scale_factor) {
+static uint16_t av_always_inline dng_process_color16(uint16_t value,
+ const uint16_t *lut,
+ uint16_t black_level,
+ float scale_factor) {
+float value_norm;
+
 // Lookup table lookup
 if (lut)
 value = lut[value];
@@ -747,16 +756,19 @@ static uint16_t av_always_inline 
dng_raw_to_linear16(uint16_t value,
 value = av_clip_uint16_c((unsigned)value - black_level);
 
 // Color scaling
-value = av_clip_uint16_c((unsigned)(((float)value * scale_factor) * 
0x));
+value_norm = (float)value * scale_factor;
+
+// Color space conversion (sRGB)
+value = av_clip_uint16_c((uint16_t)(linear_to_srgb(value_norm) * 0x));
 
 return value;
 }
 
-static uint16_t av_always_inline dng_raw_to_linear8(uint16_t value,
+static uint16_t av_always_inline dng_process_color8(uint16_t value,
 const uint16_t *lut,
 uint16_t black_level,
 float scale_factor) {
-return dng_raw_to_linear16(value, lut, black_level, scale_factor) >> 8;
+return dng_process_color16(value, lut, black_level, scale_factor) >> 8;
 }
 
 static void dng_blit(TiffContext *s, uint8_t *dst, int dst_stride,
@@ -774,7 +786,7 @@ static void dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
 uint16_t *src_u16 = (uint16_t *)src;
 
 for (col = 0; col < width; col++)
-*dst_u16++ = dng_raw_to_linear16(*src_u16++, s->dng_lut, 
s->black_level, scale_factor);
+*dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, 
s->black_level, scale_factor);
 
 dst += dst_stride * sizeof(uint16_t);
 src += src_stride * sizeof(uint16_t);
@@ -782,7 +794,7 @@ static void dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
 } else {
 for (line = 0; line < height; line++) {
 for (col = 0; col < width; col++)
-*dst++ = dng_raw_to_linear8(*src++, s->dng_lut, 
s->black_level, scale_factor);
+*dst++ = dng_process_color8(*src++, s->dng_lut, 
s->black_level, scale_factor);
 
 dst += dst_stride;
 src += src_stride;
-- 
2.21.0.windows.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 v11 02/14] lavc/tiff: Decode embedded JPEGs in DNG images

2019-08-08 Thread velocityra
From: Nick Renieris 

Used a technique similar to lavc/tdsc.c for invoking the MJPEG decoder.

This commit adds support for:
- DNG tiles
- DNG tile huffman lossless JPEG decoding
- DNG 8-bpp ("packed" as dcraw calls it) decoding
- DNG color scaling [1]
  - LinearizationTable tag
  - BlackLevel tag

[1]: As specified in the DNG Specification - Chapter 5

Signed-off-by: Nick Renieris 
---
 configure   |   1 +
 libavcodec/Makefile |   2 +-
 libavcodec/tiff.c   | 315 +++-
 libavcodec/tiff.h   |   2 +
 4 files changed, 312 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index 34c2adb4a4..112b84f0ba 100755
--- a/configure
+++ b/configure
@@ -2817,6 +2817,7 @@ tdsc_decoder_deps="zlib"
 tdsc_decoder_select="mjpeg_decoder"
 theora_decoder_select="vp3_decoder"
 thp_decoder_select="mjpeg_decoder"
+tiff_decoder_select="mjpeg_decoder"
 tiff_decoder_suggest="zlib lzma"
 tiff_encoder_suggest="zlib"
 truehd_decoder_select="mlp_parser"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3cd73fbcc6..f814c69996 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -616,7 +616,7 @@ OBJS-$(CONFIG_TARGA_ENCODER)   += targaenc.o rle.o
 OBJS-$(CONFIG_TARGA_Y216_DECODER)  += targa_y216dec.o
 OBJS-$(CONFIG_TDSC_DECODER)+= tdsc.o
 OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o
-OBJS-$(CONFIG_TIFF_DECODER)+= tiff.o lzw.o faxcompr.o tiff_data.o 
tiff_common.o
+OBJS-$(CONFIG_TIFF_DECODER)+= tiff.o lzw.o faxcompr.o tiff_data.o 
tiff_common.o mjpegdec.o
 OBJS-$(CONFIG_TIFF_ENCODER)+= tiffenc.o rle.o lzwenc.o tiff_data.o
 OBJS-$(CONFIG_TMV_DECODER) += tmv.o cga_data.o
 OBJS-$(CONFIG_TRUEHD_DECODER)  += mlpdec.o mlpdsp.o
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index c520d7df83..d5673abb19 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -35,6 +35,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/avstring.h"
+#include "libavutil/error.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
@@ -46,6 +47,7 @@
 #include "mathops.h"
 #include "tiff.h"
 #include "tiff_data.h"
+#include "mjpegdec.h"
 #include "thread.h"
 #include "get_bits.h"
 
@@ -54,6 +56,10 @@ typedef struct TiffContext {
 AVCodecContext *avctx;
 GetByteContext gb;
 
+/* JPEG decoding for DNG */
+AVCodecContext *avctx_mjpeg; // wrapper context for MJPEG
+AVFrame *jpgframe;   // decoded JPEG tile
+
 int get_subimage;
 uint16_t get_page;
 int get_thumbnail;
@@ -76,7 +82,9 @@ typedef struct TiffContext {
 
 int is_bayer;
 uint8_t pattern[4];
+unsigned black_level;
 unsigned white_level;
+const uint16_t *dng_lut; // Pointer to DNG linearization table
 
 uint32_t sub_ifd;
 uint16_t cur_page;
@@ -86,6 +94,14 @@ typedef struct TiffContext {
 int stripsizesoff, stripsize, stripoff, strippos;
 LZWState *lzw;
 
+/* Tile support */
+int is_tiled;
+int tile_byte_counts_offset, tile_offsets_offset;
+int tile_width, tile_length;
+int tile_count;
+
+int is_jpeg;
+
 uint8_t *deinvert_buf;
 int deinvert_buf_size;
 uint8_t *yuv_line;
@@ -257,6 +273,9 @@ static int add_metadata(int count, int type,
 };
 }
 
+static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
+  const uint8_t *src, int src_stride, int 
width, int height, int is_u16);
+
 static void av_always_inline horizontal_fill(TiffContext *s,
  unsigned int bpp, uint8_t* dst,
  int usePtr, const uint8_t *src,
@@ -712,6 +731,204 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 return 0;
 }
 
+/**
+ * Map stored raw sensor values into linear reference values.
+ * See: DNG Specification - Chapter 5
+ */
+static uint16_t av_always_inline dng_raw_to_linear16(uint16_t value,
+const uint16_t *lut,
+uint16_t black_level,
+float scale_factor) {
+// Lookup table lookup
+if (lut)
+value = lut[value];
+
+// Black level subtraction
+value = av_clip_uint16_c((unsigned)value - black_level);
+
+// Color scaling
+value = av_clip_uint16_c((unsigned)(((float)value * scale_factor) * 
0x));
+
+return value;
+}
+
+static uint16_t av_always_inline dng_raw_to_linear8(uint16_t value,
+const uint16_t *lut,
+uint16_t black_level,
+float scale_factor) {
+return dng_raw_to_linear16(value, lut, black_level, scale_factor) >> 8;
+}
+
+static void dng_blit(TiffContext 

[FFmpeg-devel] [PATCH v11 01/14] lavc/mjpegdec: Decode Huffman-coded lossless JPEGs embedded in DNGs

2019-08-08 Thread velocityra
From: Nick Renieris 

Main image data in DNGs is usually comprised of tiles, each of which is a 
Huffman-encoded lossless JPEG.

Tested for ljpeg regressions with:
`ffmpeg -f lavfi -i testsrc=d=1 -vcodec ljpeg test.avi`
`ffmpeg test.avi out.avi`
The modified code in ljpeg_decode_rgb_scan runs without issues.

Signed-off-by: Nick Renieris 
---
 libavcodec/mjpegdec.c | 52 +--
 libavcodec/mjpegdec.h |  1 +
 2 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index a65bc8df15..6391107f78 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -412,6 +412,14 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 return AVERROR_PATCHWELCOME;
 }
 
+/* Lossless JPEGs encoded in DNGs are commonly bayer-encoded. They contain 
2
+   interleaved components and the width stored in their SOF3 markers is the
+   width of each one.  We only output a single component, therefore we need
+   to adjust the output image width. */
+if (s->lossless == 1 && nb_components == 2) {
+s->bayer = 1;
+width *= 2;
+}
 
 /* if different size, realloc/alloc picture */
 if (width != s->width || height != s->height || bits != s->bits ||
@@ -488,6 +496,9 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 }
 
 switch (pix_fmt_id) {
+case 0x: /* for bayer-encoded huffman lossless JPEGs embedded 
in DNGs */
+s->avctx->pix_fmt = AV_PIX_FMT_GRAY16LE;
+break;
 case 0x1100:
 if (s->rgb)
 s->avctx->pix_fmt = s->bits <= 9 ? AV_PIX_FMT_BGR24 : 
AV_PIX_FMT_BGR48;
@@ -1041,17 +1052,20 @@ static int handle_rstn(MJpegDecodeContext *s, int 
nb_components)
 return reset;
 }
 
+/* Handles 1 to 4 components */
 static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int 
predictor, int point_transform)
 {
 int i, mb_x, mb_y;
+unsigned width;
 uint16_t (*buffer)[4];
 int left[4], top[4], topleft[4];
 const int linesize = s->linesize[0];
 const int mask = ((1 << s->bits) - 1) << point_transform;
 int resync_mb_y = 0;
 int resync_mb_x = 0;
+int vpred[6];
 
-if (s->nb_components != 3 && s->nb_components != 4)
+if (s->nb_components <= 0 || s->nb_components > 4)
 return AVERROR_INVALIDDATA;
 if (s->v_max != 1 || s->h_max != 1 || !s->lossless)
 return AVERROR_INVALIDDATA;
@@ -1059,8 +1073,15 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 
 s->restart_count = s->restart_interval;
 
-av_fast_malloc(>ljpeg_buffer, >ljpeg_buffer_size,
-   (unsigned)s->mb_width * 4 * sizeof(s->ljpeg_buffer[0][0]));
+if (s->restart_interval == 0)
+s->restart_interval = INT_MAX;
+
+if (s->bayer)
+width = s->mb_width / nb_components; /* Interleaved, width stored is 
the total so need to divide */
+else
+width = s->mb_width;
+
+av_fast_malloc(>ljpeg_buffer, >ljpeg_buffer_size, width * 4 * 
sizeof(s->ljpeg_buffer[0][0]));
 if (!s->ljpeg_buffer)
 return AVERROR(ENOMEM);
 
@@ -1078,7 +1099,12 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 for (i = 0; i < 4; i++)
 top[i] = left[i] = topleft[i] = buffer[0][i];
 
-for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
+if ((mb_y * s->width) % s->restart_interval == 0) {
+for (i = 0; i < 6; i++)
+vpred[i] = 1 << (s->bits-1);
+}
+
+for (mb_x = 0; mb_x < width; mb_x++) {
 int modified_predictor = predictor;
 
 if (get_bits_left(>gb) < 1) {
@@ -1102,12 +1128,19 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 topleft[i] = top[i];
 top[i] = buffer[mb_x][i];
 
-PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
-
 dc = mjpeg_decode_dc(s, s->dc_index[i]);
 if(dc == 0xF)
 return -1;
 
+if (!s->bayer || mb_x) {
+pred = left[i];
+} else { /* This path runs only for the first line in bayer 
images */
+vpred[i] += dc;
+pred = vpred[i] - dc;
+}
+
+PREDICT(pred, topleft[i], top[i], pred, modified_predictor);
+
 left[i] = buffer[mb_x][i] =
 mask & (pred + (unsigned)(dc * (1 << point_transform)));
 }
@@ -1151,6 +1184,11 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
 ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
 }
+} else if (s->bayer && nb_components == 2) {
+for (mb_x = 0; mb_x < width; 

[FFmpeg-devel] [PATCH] mov: Support fake moov boxes disguised as hoov

2019-08-08 Thread Vittorio Giovara
Some broken apps generate files that have a fake box named 'hoov'
instead of a proper 'moov' one. This is speculation but it seems like
this box contains data to be modified later (eg as file grows in size,
data gets re-written) and its name is supposed to be changed to 'moov'
once it can be used as a 'moov', but for some reason this step is skipped.

Since this is not the first time this happens ('moov' boxes can be found
in 'free' ones) extend the existing hacks to search for the moov in such
boxes and skip the moov_retry since it needs to be found right away.
---
 libavformat/mov.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

This code is ugly, tips for improving it are welcome, or a full
rejection is ok too. Unfortunately I cannot share the sample, but VLC
is able to play it.
Vittorio

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 24de5429d1..0c2986b72e 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -6800,10 +6800,10 @@ static int mov_read_default(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 if (atom.size >= 8) {
 a.size = avio_rb32(pb);
 a.type = avio_rl32(pb);
-if (a.type == MKTAG('f','r','e','e') &&
+if (((a.type == MKTAG('f','r','e','e') && c->moov_retry) ||
+  a.type == MKTAG('h','o','o','v')) &&
 a.size >= 8 &&
-c->fc->strict_std_compliance < FF_COMPLIANCE_STRICT &&
-c->moov_retry) {
+c->fc->strict_std_compliance < FF_COMPLIANCE_STRICT) {
 uint8_t buf[8];
 uint32_t *type = (uint32_t *)buf + 1;
 if (avio_read(pb, buf, 8) != 8)
@@ -6811,7 +6811,7 @@ static int mov_read_default(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 avio_seek(pb, -8, SEEK_CUR);
 if (*type == MKTAG('m','v','h','d') ||
 *type == MKTAG('c','m','o','v')) {
-av_log(c->fc, AV_LOG_ERROR, "Detected moov in a free 
atom.\n");
+av_log(c->fc, AV_LOG_ERROR, "Detected moov in a free or 
hoov atom.\n");
 a.type = MKTAG('m','o','o','v');
 }
 }
-- 
2.22.0

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

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

Re: [FFmpeg-devel] [PATCH] libavformat/rtspdec: Don't send teardown if rtsp_hd_out is null

2019-08-08 Thread Ross Nicholson
Any feedback on this patch?

On Mon, 5 Aug 2019 at 00:18, Ross Nicholson  wrote:

> Example stream that does not work: rtsp://
> 184.72.239.149/vod/mp4:BigBuckBunny_115k.mov
>
> Extending the condition allows the stream to be processed correctly.
>
> On Mon, 5 Aug 2019 at 08:17, Ross Nicholson  wrote:
>
>> From: phunkyfish 
>>
>> ---
>>  libavformat/rtspdec.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
>> index 32dff2319c..3a79d1b175 100644
>> --- a/libavformat/rtspdec.c
>> +++ b/libavformat/rtspdec.c
>> @@ -57,7 +57,7 @@ static int rtsp_read_close(AVFormatContext *s)
>>  {
>>  RTSPState *rt = s->priv_data;
>>
>> -if (!(rt->rtsp_flags & RTSP_FLAG_LISTEN))
>> +if (!(rt->rtsp_flags & RTSP_FLAG_LISTEN) && rt->rtsp_hd_out)
>>  ff_rtsp_send_cmd_async(s, "TEARDOWN", rt->control_uri, NULL);
>>
>>  ff_rtsp_close_streams(s);
>> --
>> 2.20.1 (Apple Git-117)
>>
>>
___
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] libavcodec/amfenc: Vulkan initialization support for encoder.

2019-08-08 Thread OvchinnikovDmitrii
Added linux support for amf encoder through vulkan.

To use h.264(AMD VCE) encoder on linux amdgru-pro version 19.20+ and 
amf-amdgpu-pro package(amdgru-pro contains, but does not install automatically) 
are required.
This driver can be installed using amdgpu-pro-install script in official amd 
driver archive.

Initialization of amf encoder occurs in this order:
1) trying to initialize through dx11(only windows)
2) trying to initialize through dx9(only windows)
3) trying to initialize through vulkan

Only Vulkan initialization available on linux.


---
 doc/general.texi| 16 +---
 libavcodec/amfenc.c | 17 +++--
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/doc/general.texi b/doc/general.texi
index 3c0c803449..056f88fba3 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -27,16 +27,26 @@ enable it.
 
 @section AMD AMF/VCE
 
-FFmpeg can use the AMD Advanced Media Framework library under Windows
-for accelerated H.264 and HEVC encoding on hardware with Video Coding Engine 
(VCE).
+FFmpeg can use the AMD Advanced Media Framework library 
+for accelerated H.264 and HEVC(only windows) encoding on hardware with Video 
Coding Engine (VCE).
 
-To enable support you must obtain the AMF framework header files from
+To enable support you must obtain the AMF framework header files(version 
1.4.9+) from
 @url{https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git}.
 
 Create an @code{AMF/} directory in the system include path.
 Copy the contents of @code{AMF/amf/public/include/} into that directory.
 Then configure FFmpeg with @code{--enable-amf}.
 
+Initialization of amf encoder occurs in this order:
+1) trying to initialize through dx11(only windows)
+2) trying to initialize through dx9(only windows)
+3) trying to initialize through vulkan
+
+To use h.264(AMD VCE) encoder on linux amdgru-pro version 19.20+ and 
amf-amdgpu-pro 
+package(amdgru-pro contains, but does not install automatically) are required.
+
+This driver can be installed using amdgpu-pro-install script in official amd 
driver archive.
+
 @section AviSynth
 
 FFmpeg can read AviSynth scripts as input. To enable support, pass
diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c
index 384d8efc92..f66b95645e 100644
--- a/libavcodec/amfenc.c
+++ b/libavcodec/amfenc.c
@@ -213,6 +213,7 @@ static int amf_init_from_dxva2_device(AVCodecContext 
*avctx, AVDXVA2DeviceContex
 static int amf_init_context(AVCodecContext *avctx)
 {
 AmfContext *ctx = avctx->priv_data;
+AMFContext1 *context1 = NULL;
 AMF_RESULT  res;
 av_unused int ret;
 
@@ -311,8 +312,20 @@ static int amf_init_context(AVCodecContext *avctx)
 if (res == AMF_OK) {
 av_log(avctx, AV_LOG_VERBOSE, "AMF initialisation succeeded 
via D3D9.\n");
 } else {
-av_log(avctx, AV_LOG_ERROR, "AMF initialisation failed via 
D3D9: error %d.\n", res);
-return AVERROR(ENOSYS);
+AMFGuid guid = IID_AMFContext1();
+res = ctx->context->pVtbl->QueryInterface(ctx->context, , 
(void**));
+AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN, 
"CreateContext1() failed with error %d\n", res);
+
+res = context1->pVtbl->InitVulkan(context1, NULL);
+context1->pVtbl->Release(context1);
+if (res != AMF_OK) {
+if (res == AMF_NOT_SUPPORTED)
+av_log(avctx, AV_LOG_ERROR, "AMF via Vulkan is not 
supported on the given device.\n");
+else
+av_log(avctx, AV_LOG_ERROR, "AMF failed to initialise 
on the given Vulkan device: %d.\n", res);
+return AVERROR(ENOSYS);
+}
+av_log(avctx, AV_LOG_VERBOSE, "AMF initialisation succeeded 
via Vulkan.\n");
 }
 }
 }
-- 
2.19.1.windows.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 v3 3/6] avformat/s337m: Make available as subdemuxer

2019-08-08 Thread Gaullier Nicolas
>Look at spdif in wav.
Indeed, I missed that, spdif and s337m are very similar technically, and it 
means I have to rework my patch for the integration of s337m in wavdec, but I 
still do not catch why another demuxer should be created : spdifdec.c is 
actually quite similar to the existing s337m.c
Perhaps you find unacceptable only the use of the avpriv_ prefix instead of ff_ 
? I understand, but in a previous cover letter, I mentioned that the idea was 
to make this available to build a filter that would decode s337m in a filter 
graph; but yes, maybe I should stay with ff_ for now and migrate to avpriv_ 
later when submitting the new filter, that would make sense, moreover the 
prototype may be changed too depending on how the implementation of the filter 
turns to be (and I have no experience in writing a filter for ffmpeg for now, 
so...).

In my opinion, here are the most relevant differences between spdif and s337m, 
it is a matter of use cases :
- s337m may be split in two mono streams and may require an "audio merge" to be 
decodable, which suggests the use of a filter graph and a dedicated filter to 
decode s337/dolby_e (so the use of public methods for a dedicated format, 
indeed)
- dolby E is a codec one either don't want to see (ie. pass through) or one 
want to get rid off/decode to uncompressed/pcm, whereas ac3 for example is a 
very popular codec one usually wants to stream copy: so an audio filter to 
decode s337/dolbyE seems interesting whereas an audio filter to decode 
spdif/ac3 would be absolutely useless
- s337m may be frame wrapped (ex: mxf) (probing method differs)

At the end, in my current understanding, here is what I should correct :
- make the integration of s337m in wavdec similar to that of spdif
- replace the avpriv_* by ff_* ... for now

Anyway, I will wait your feedback and until we completely agree before going 
anywhere further.

Nicolas
___
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 v4] avutil/mips: refine msa macros CLIP_*.

2019-08-08 Thread Michael Niedermayer
On Thu, Aug 08, 2019 at 09:49:35AM +0800, 顾希伟 wrote:
> > 发件人: "Michael Niedermayer" 
> > 发送时间: 2019-08-08 07:05:13 (星期四)
> > 收件人: "FFmpeg development discussions and patches" 
> > 抄送: 
> > 主题: Re: [FFmpeg-devel] [PATCH v4] avutil/mips: refine msa macros CLIP_*.
> > 
> > On Wed, Aug 07, 2019 at 05:52:00PM +0800, gxw wrote:
> > > Changing details as following:
> > > 1. Remove the local variable 'out_m' in 'CLIP_SH' and store the result in
> > >source vector.
> > > 2. Refine the implementation of macro 'CLIP_SH_0_255' and 'CLIP_SW_0_255'.
> > >Performance of VP8 decoding has speed up about 1.1%(from 7.03x to 
> > > 7.11x).
> > >Performance of H264 decoding has speed up about 0.5%(from 4.35x to 
> > > 4.37x).
> > >Performance of Theora decoding has speed up about 0.7%(from 5.79x to 
> > > 5.83x).
> > > 3. Remove redundant macro 'CLIP_SH/Wn_0_255_MAX_SATU' and use 
> > > 'CLIP_SH/Wn_0_255'
> > >instead, because there are no difference in the effect of this two 
> > > macros.
> > 
> > can these 3 things be split into 3 patches ?
> > It would be clearer if each change would be in its own patch
> > 
> > thanks
> > 
> > [...]
> > -- 
> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> > 
> > Whats the most studid thing your enemy could do ? Blow himself up
> > Whats the most studid thing you could do ? Give up your rights and
> > freedom because your enemy blew himself up.
> 
> It can be split into 3 patches. But there some benefits as 1 patch, these 
> macros belong to the same class and are highly relevant. It is more intuitive 
> to put them in a patch.

hmm
does anyone else has any oppinion about this ?

if not ill apply it

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] MpegTS contribution question

2019-08-08 Thread Phil Burr
Hello Anthony,

I'm not really the best to answer your questions, as I'm also a fairly new
contributor (my patches seem to be languishing due to a lack of feedback
and a lack of time on my part pushing the issue).  I've been working on
getting support into mpegts for ATSC compliant descriptors of which EIT
tables are a glaring omission in large part due to the amount of work
needed to support them.  So to say the least, I'm excited about your
patches!  I'll take a look at your patches but one thing I would like to
know if you've considered, is whether or not your code supports modifying
the EIT tables, ie updating tables_version when the tables are modified?

Thanks,
Phil

On Thu, Aug 8, 2019 at 4:13 AM Anthony Delannoy 
wrote:

> Hi,
>
> I'm currently doing my first contribution to ffmpeg by adding EPG support
> in the mpegts format.
> For now, i succeeded to add support for EIT table and majority of its
> descriptors and can read/export EPG
> events in a .csv file.
> But I don't know on how to organize it now. Do I make a new codec for epg
> and a data stream? Do I keep those
> information « hidden » and present them only in metadatas plus functions
> api to export them?
>
> For those who wants to see where I am at:
> https://github.com/spnngl/FFmpeg/tree/epg2
>
> Some remarks:
>   * For now I use linked list to store EPG events but I may change for
> something simpler.
>   * I made separate descriptors code to be able to use it on others tables
> later. I want to add NIT table
>   support and maybe others if i succeed to finish EPG.
>   * EPG/descriptors files are all in libavformat for now, they need to be
> moved
>
> Thanks
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel 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 3/3] avformat/avio: remove 4k limit from avio_printf

2019-08-08 Thread Paul B Mahol
On Thu, Aug 8, 2019 at 10:43 AM Nicolas George  wrote:

> Marton Balint (12019-08-07):
> > The function returns an int so it can't signal writing longer strings
> that
> > that.
>
> Yet, replacing an arbitrary limit by another arbitrary limit, however
> high, seems very wrong.
>
>
But function returns int and not int64_t.


> Regards,
>
> --
>   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 3/3] avformat/avio: remove 4k limit from avio_printf

2019-08-08 Thread Marton Balint



On Thu, 8 Aug 2019, Nicolas George wrote:


Marton Balint (12019-08-07):

The function returns an int so it can't signal writing longer strings that
that.


Yet, replacing an arbitrary limit by another arbitrary limit, however
high, seems very wrong.


Current 4k limit is definitely causing errors, the users are not aware of 
it, because it is not intuitive.


I don't see why increasing the limit to 2 GB which is something that we 
will hardly ever hit is worse than current status which causes actual 
issues.


Are you against increasing the limit?

Do you want to increase the limit to UINT_MAX (the AVBprint 
implementation limit) instead of INT_MAX?


Or do you have some other suggestion?

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

Re: [FFmpeg-devel] [PATCH] tools/zmqsend: Avoid mem copy past the end of input buffer

2019-08-08 Thread Paul B Mahol
On Thu, Aug 8, 2019 at 4:44 PM Andriy Gelman 
wrote:

> From: Andriy Gelman 
>
> This patch avoids a read past the end of the input buffer in memcpy since
> the size
> of the received zmq message is recv_buf_size - 1.
> ---
>  tools/zmqsend.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/zmqsend.c b/tools/zmqsend.c
> index 7bd7fe4199..f26fa9c1c2 100644
> --- a/tools/zmqsend.c
> +++ b/tools/zmqsend.c
> @@ -155,7 +155,7 @@ int main(int argc, char **argv)
>  ret = 1;
>  goto end;
>  }
> -memcpy(recv_buf, zmq_msg_data(), recv_buf_size);
> +memcpy(recv_buf, zmq_msg_data(), recv_buf_size - 1);
>  recv_buf[recv_buf_size-1] = 0;
>  printf("%s\n", recv_buf);
>  zmq_msg_close();
> --
> 2.22.0
>
>
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".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/2] avutil: Add Simple loop detector

2019-08-08 Thread Kieran Kunhya
>
> You argue that it does not NEED to be in lavu, but not that it SHOULD
> note.
>
> > Plus, its not really common av code, and don't let its name mislead
> > you, its more of a hack.
>
> I will disregard the insulting subtext of this sentence.
>

There is nothing insulting about this sentence. IMO this is a hack, how
come we have not needed such a thing for years?

Kieran
___
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] tools/zmqsend: Avoid mem copy past the end of input buffer

2019-08-08 Thread Andriy Gelman
From: Andriy Gelman 

This patch avoids a read past the end of the input buffer in memcpy since the 
size
of the received zmq message is recv_buf_size - 1.
---
 tools/zmqsend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/zmqsend.c b/tools/zmqsend.c
index 7bd7fe4199..f26fa9c1c2 100644
--- a/tools/zmqsend.c
+++ b/tools/zmqsend.c
@@ -155,7 +155,7 @@ int main(int argc, char **argv)
 ret = 1;
 goto end;
 }
-memcpy(recv_buf, zmq_msg_data(), recv_buf_size);
+memcpy(recv_buf, zmq_msg_data(), recv_buf_size - 1);
 recv_buf[recv_buf_size-1] = 0;
 printf("%s\n", recv_buf);
 zmq_msg_close();
-- 
2.22.0

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

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

Re: [FFmpeg-devel] [PATCH v8] Fix integer parameters size check in SDP fmtp line

2019-08-08 Thread Olivier MAIGNIAL
Hello here,

Just a mail to ping this patch

Have a nice day,

Olivier

On Thu, Jul 25, 2019 at 11:34 PM Michael Niedermayer 
wrote:

> On Wed, Jul 24, 2019 at 10:20:14AM +0200, Olivier Maignial wrote:
> > === PROBLEM ===
> >
> > I was trying to record h264 + aac streams from an RTSP server to mp4
> file. using this command line:
> > ffmpeg -v verbose -y -i "rtsp:///my_resources" -codec copy
> -bsf:a aac_adtstoasc test.mp4
> >
> > FFmpeg then fail to record audio and output this logs:
> > [rtsp @ 0xcda1f0] The profile-level-id field size is invalid (40)
> > [rtsp @ 0xcda1f0] Error parsing AU headers
> > ...
> > [rtsp @ 0xcda1f0] Could not find codec parameters for stream 1
> (Audio: aac, 48000 Hz, 1 channels): unspecified sample format
> >
> > In SDP provided by my RTSP server I had this fmtp line:
> > a=fmtp:98 streamType=5; profile-level-id=40; mode=AAC-hbr;
> config=1188; sizeLength=13; indexLength=3; indexDeltaLength=3;
> >
> > In FFmpeg code, I found a check introduced by commit
> 24130234cd9dd733116d17b724ea4c8e12ce097a. It disallows values greater than
> 32 for fmtp line parameters.
> > RFC-4566 (SDP: Session Description Protocol) do not give any limit of
> size on interger parameters given in an fmtp line.
> >
> > However, In RFC-6416 (RTP Payload Format for MPEG-4 Audio/Visual
> Streams) give examples of "profile-level-id" values for AAC, up to 55.
> >
> > === FIX ===
> >
> > As each parameter may have its own min and max values
> > I propose to introduce a range for each parameter.
> > For this patch I used RFC-3640 and ISO/IEC 14496-1 as reference for
> validity ranges.
> >
> > This patch fix my problem and I now can record my RTSP AAC stream to mp4.
> > It has passed the full fate tests suite sucessfully.
> >
> > Signed-off-by: Olivier Maignial 
> > ---
> > Changes v7 --> v8:
> > Indroduced a per parameter validity range
>
> thanks, yes this should resolve the issue
>
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Complexity theory is the science of finding the exact solution to an
> approximation. Benchmarking OTOH is finding an approximation of the exact
> ___
> 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 v3 3/3] lavc/libdavs2.c: use decoder data directly instead of memcpy

2019-08-08 Thread hwren
I'm sorry I almost missed this email. Thanks for your review.

At 2019-07-23 03:42:20, "Marton Balint"  wrote:
>
>
>On Sat, 13 Jul 2019, hwren wrote:
>
>>
>> At 2019-07-13 01:38:55, "Marton Balint"  wrote:
>>>
>>>
>>> On Fri, 12 Jul 2019, hwrenx wrote:
>>>
 Can effectivly improved decoding speed when memcpy becomes a limitation
 for proccessing high resolution source.
 Tested under i7-8700k with `ffmpeg -i 7680x4320.avs2 -vsync 0 -f null -`
 got performance 23fps => 42fps

 Signed-off-by: hwrenx 
 ---
 libavcodec/libdavs2.c | 54 
 +--
 1 file changed, 31 insertions(+), 23 deletions(-)

 diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
 index 1b274a3..af0778f 100644
 --- a/libavcodec/libdavs2.c
 +++ b/libavcodec/libdavs2.c
 @@ -60,13 +60,24 @@ static av_cold int davs2_init(AVCodecContext *avctx)
 return 0;
 }
 
 +static void davs2_frame_unref(void *opaque, uint8_t *data) {
 +DAVS2Context*cad = (DAVS2Context *)opaque;
 +davs2_picture_t  pic;
 +
 +pic.magic = (davs2_picture_t *)data;
 +
 +if (cad->decoder) {
 +davs2_decoder_frame_unref(cad->decoder, );
 +} else {
 +av_log(NULL, AV_LOG_WARNING, "Decoder not found, frame 
 unreference failed.\n");
>>>
>>> Whoa, this should not happen, and you have to be prepared that the user 
>>> might close the decoder before freeing the last frame.
>>
>> I hope so, actually it's harmless if we failed to unref some frames outside 
>> davs2 when decoder
>> was closed through davs2_decoder_close(). The decoder will free the memory 
>> which contains
>> all recycle data itself.
>
>And that is the problem, because the data should survive closing the 
>(avcodec) decoder.

Do you mean after decoder closing, there may still some data left which should 
be unref by decoder ...
The davs2_decoder_frame_unref() can only notice the decoder that it could reuse 
this part of memory,
but the decoder won't free or realloc any memory. All these memory will be free 
together when decoder
was closing. So the "survived data" in ffmpeg should just be some unuseful 
pointers.

Or you mean even decoder is closed, there are still some data needed by ffmpeg?

>
>>
>>>
>>> Maybe you should use some refcounting and create references to the 
>>> decoder, others may have a better idea.
>>>
>>> Regards,
>>> Marton
>>
>> Of course, anyway, it would be better if there are any ways to make sure we 
>> correctly freed all
>> frames even decoder was not found or exited without a davs2_decoder_close(). 
>>  But force to
>> free the memory immediately in the call back function can cause troubles to 
>> decoder and I'm
>> not very clearly understand how to use reference to deal with this problem 
>> inside a codec.
>>
>>
>> Maybe that means I could reference the buffer and waiting ffmpeg to free 
>> them once they were
>> not handled by davs2?
>
>I am not sure I understand your concern here.
>
>Here is what I propose in more detail, I think it works for all cases:
>
>In davs_init allocate a small struct which contains the decoder and a 
>reference counter for the decoder itself:
>DAVS2Reference {
>   atomic_int refcount;
>   void *decoder;
>}
>set the refs to 1.
>
>In davs2_dump_frames you should pass the allocated DAVS2Reference to 
>av_buffer_create instead of the DAVS2Context. After each successful 
>av_buffer_create you should increase refcount.
>
>In davs2_frame_unref after freeing the frame you should decrease the 
>reference counter and if you reach 0 then you can destroy the davs2 
>decoder (and free DAVS2Reference struct as well)
>
>You can do the same in davs2_end: decrease the refcount and if you reach 0 
>then you can close the davs2 decoder and free the DAVS2Reference struct.
>

In my understanding, once closing decoder, ffmpeg should finish or stop 
outputing (not so sure,
if not please correct me). So I think normally the refcount should always be 
zero when using
decoder_close(), if not zero, maybe decoder can do nothing but wait (and never 
stop).

If after closing decoder there are still some data needed by ffmpeg, a 
refcounter is necessary indeed.

Regards,
Huiwen REN

>Regards,
>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 v2 1/2] swscale: Replace illegal vector keyword usage in altivec code

2019-08-08 Thread Daniel Kolesa
On Thu, Aug 8, 2019, at 15:23, Daniel Kolesa wrote:
> On Thu, Aug 8, 2019, at 14:32, Carl Eugen Hoyos wrote:
> > Am Mi., 7. Aug. 2019 um 19:39 Uhr schrieb Daniel Kolesa 
> > :
> > >
> > > While this technically compiles in current ffmpeg, this is only
> > > because ffmpeg is compiled in strict ISO C mode, which disables
> > > the builtin 'vector' keyword for AltiVec/VSX. Instead this gets
> > > replaced with a macro inside altivec.h, which defines vector to
> > > be actually __vector, which accepts random types.
> > >
> > > Normally, the vector keyword should be used only with plain
> > > scalar non-typedef types, such as unsigned int. But we have the
> > > vec_(s|u)(8|16|32) macros, which can be used in a portable manner,
> > > in util_altivec.h in libavutil.
> > >
> > > This is also consistent with other AltiVec/VSX code elsewhere in
> > > the tree.
> > >
> > > Fixes #7861.
> > 
> > Since I cannot reproduce any issue with current FFmpeg on Power8
> > using gcc-8.3.1, at least the commit message has to be changed,
> > same for the other patch.
> 
> I don't see why that would need changing. For one, the commit message 
> for the first patch describes exactly what is wrong and also the reason 
> you can't reproduce it by default (which I also mentioned in the 
> ticket). I believe the second patch's reproducibility is limited to 
> more recent gcc (probably only 9.x series), it was reproduced by me, 
> the other person in the ticket, as well as the Fedora project (see 
> http://koji.rpmfusion.org/koji/taskinfo?taskID=341163).

For further reference, see the docs: 
https://gcc.gnu.org/onlinedocs/gcc-8.3.0/gcc/PowerPC-AltiVec_002fVSX-Built-in-Functions.html

---
GCC allows using a typedef name as the type specifier for a vector type, but 
only under the following circumstances:

When using __vector instead of vector; for example,

typedef signed short int16;
__vector int16 data;

When using vector in keyword-and-predefine mode; for example,

typedef signed short int16;
vector int16 data;

Note that keyword-and-predefine mode is enabled by disabling GNU extensions 
(e.g., by using -std=c11) and including .
---

That means you can easily reproduce the first patch by replacing -std=c11 with 
-std=gnu11 (or no -std). By default, ffmpeg compiles with -std=c11.

> 
> Regards
> 
> > 
> > Carl Eugen
> > ___
> > 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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v3 2/3] lavfi: modify avfilter_get_matrix to support separate scale factors

2019-08-08 Thread Jarek Samic
---
 libavfilter/transform.c  | 13 ++---
 libavfilter/transform.h  | 30 +++---
 libavfilter/vf_deshake.c |  7 +--
 3 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/libavfilter/transform.c b/libavfilter/transform.c
index f92fc4d42f..f4f9e0a47d 100644
--- a/libavfilter/transform.c
+++ b/libavfilter/transform.c
@@ -103,12 +103,19 @@ INTERPOLATE_METHOD(interpolate_biquadratic)
 }
 }
 
-void avfilter_get_matrix(float x_shift, float y_shift, float angle, float 
zoom, float *matrix) {
-matrix[0] = zoom * cos(angle);
+void ff_get_matrix(
+float x_shift,
+float y_shift,
+float angle,
+float scale_x,
+float scale_y,
+float *matrix
+) {
+matrix[0] = scale_x * cos(angle);
 matrix[1] = -sin(angle);
 matrix[2] = x_shift;
 matrix[3] = -matrix[1];
-matrix[4] = matrix[0];
+matrix[4] = scale_y * cos(angle);
 matrix[5] = y_shift;
 matrix[6] = 0;
 matrix[7] = 0;
diff --git a/libavfilter/transform.h b/libavfilter/transform.h
index 07436bfccb..9b0c19ceca 100644
--- a/libavfilter/transform.h
+++ b/libavfilter/transform.h
@@ -60,20 +60,28 @@ enum FillMethod {
 #define FILL_DEFAULT FILL_ORIGINAL
 
 /**
- * Get an affine transformation matrix from a given translation, rotation, and
- * zoom factor. The matrix will look like:
+ * Get an affine transformation matrix from given translation, rotation, and
+ * zoom factors. The matrix will look like:
  *
- * [ zoom * cos(angle),   -sin(angle), x_shift,
- *  sin(angle), zoom * cos(angle), y_shift,
- *   0, 0,   1 ]
+ * [ scale_x * cos(angle),   -sin(angle), x_shift,
+ * sin(angle),  scale_y * cos(angle), y_shift,
+ *  0, 0,   1 ]
  *
- * @param x_shift horizontal translation
- * @param y_shift vertical translation
- * @param angle   rotation in radians
- * @param zoomscale percent (1.0 = 100%)
- * @param matrix  9-item affine transformation matrix
+ * @param x_shift   horizontal translation
+ * @param y_shift   vertical translation
+ * @param angle rotation in radians
+ * @param scale_x   x scale percent (1.0 = 100%)
+ * @param scale_y   y scale percent (1.0 = 100%)
+ * @param matrix9-item affine transformation matrix
  */
-void avfilter_get_matrix(float x_shift, float y_shift, float angle, float 
zoom, float *matrix);
+void ff_get_matrix(
+float x_shift,
+float y_shift,
+float angle,
+float scale_x,
+float scale_y,
+float *matrix
+);
 
 /**
  * Add two matrices together. result = m1 + m2.
diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
index c8480e74dd..b516ea2d59 100644
--- a/libavfilter/vf_deshake.c
+++ b/libavfilter/vf_deshake.c
@@ -421,6 +421,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 const int chroma_width  = AV_CEIL_RSHIFT(link->w, desc->log2_chroma_w);
 const int chroma_height = AV_CEIL_RSHIFT(link->h, desc->log2_chroma_h);
 int aligned;
+float transform_zoom;
 
 out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
 if (!out) {
@@ -505,10 +506,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 deshake->last.angle = t.angle;
 deshake->last.zoom = t.zoom;
 
+transform_zoom = 1.0 + t.zoom / 100.0;
+
 // Generate a luma transformation matrix
-avfilter_get_matrix(t.vec.x, t.vec.y, t.angle, 1.0 + t.zoom / 100.0, 
matrix_y);
+ff_get_matrix(t.vec.x, t.vec.y, t.angle, transform_zoom, transform_zoom, 
matrix_y);
 // Generate a chroma transformation matrix
-avfilter_get_matrix(t.vec.x / (link->w / chroma_width), t.vec.y / (link->h 
/ chroma_height), t.angle, 1.0 + t.zoom / 100.0, matrix_uv);
+ff_get_matrix(t.vec.x / (link->w / chroma_width), t.vec.y / (link->h / 
chroma_height), t.angle, transform_zoom, transform_zoom, matrix_uv);
 // Transform the luma and chroma planes
 ret = deshake->transform(link->dst, link->w, link->h, chroma_width, 
chroma_height,
  matrix_y, matrix_uv, INTERPOLATE_BILINEAR, 
deshake->edge, in, out);
-- 
2.22.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 v3 1/3] lavfi: add utilities to reduce OpenCL boilerplate code

2019-08-08 Thread Jarek Samic
---
 libavfilter/opencl.c |  10 +++
 libavfilter/opencl.h | 142 +--
 2 files changed, 146 insertions(+), 6 deletions(-)

diff --git a/libavfilter/opencl.c b/libavfilter/opencl.c
index 95f0bfc604..8e96543467 100644
--- a/libavfilter/opencl.c
+++ b/libavfilter/opencl.c
@@ -350,3 +350,13 @@ void ff_opencl_print_const_matrix_3x3(AVBPrint *buf, const 
char *name_str,
 }
 av_bprintf(buf, "};\n");
 }
+
+cl_ulong ff_opencl_get_event_time(cl_event event) {
+cl_ulong time_start;
+cl_ulong time_end;
+
+clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_START, 
sizeof(time_start), _start, NULL);
+clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END, sizeof(time_end), 
_end, NULL);
+
+return time_end - time_start;
+}
diff --git a/libavfilter/opencl.h b/libavfilter/opencl.h
index 973b6d82dd..7487e60241 100644
--- a/libavfilter/opencl.h
+++ b/libavfilter/opencl.h
@@ -47,6 +47,11 @@ typedef struct OpenCLFilterContext {
 intoutput_height;
 } OpenCLFilterContext;
 
+// Groups together information about a kernel argument
+typedef struct OpenCLKernelArg {
+size_t arg_size;
+const void *arg_val;
+} OpenCLKernelArg;
 
 /**
  * set argument to specific Kernel.
@@ -73,9 +78,26 @@ typedef struct OpenCLFilterContext {
 goto fail; \
 }  \
 } while(0)
+
+/**
+ * Create a kernel with the given name.
+ *
+ * The kernel variable in the context structure must have a name of the form
+ * kernel_.
+ *
+ * The OpenCLFilterContext variable in the context structure must be named ocf.
+ *
+ * Requires the presence of a local cl_int variable named cle and a fail label 
for error
+ * handling.
+ */
+#define CL_CREATE_KERNEL(ctx, kernel_name) do {
 \
+ctx->kernel_ ## kernel_name = clCreateKernel(ctx->ocf.program, 
#kernel_name, ); \
+CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to create %s kernel: %d.\n", 
#kernel_name, cle); \
+} while(0)
+
 /**
-  * release an OpenCL Kernel
-  */
+ * release an OpenCL Kernel
+ */
 #define CL_RELEASE_KERNEL(k)  \
 do {  \
 if (k) {  \
@@ -87,8 +109,8 @@ do { 
 \
 } while(0)
 
 /**
-  * release an OpenCL Memory Object
-  */
+ * release an OpenCL Memory Object
+ */
 #define CL_RELEASE_MEMORY(m)  \
 do {  \
 if (m) {  \
@@ -100,8 +122,8 @@ do {
  \
 } while(0)
 
 /**
-  * release an OpenCL Command Queue
-  */
+ * release an OpenCL Command Queue
+ */
 #define CL_RELEASE_QUEUE(q)   \
 do {  \
 if (q) {  \
@@ -112,6 +134,108 @@ do {  
\
 } \
 } while(0)
 
+/**
+ * Enqueue a kernel with the given information.
+ *
+ * Kernel arguments are provided as KernelArg structures and are set in the 
order
+ * that they are passed.
+ *
+ * Requires the presence of a local cl_int variable named cle and a fail label 
for error
+ * handling.
+ */
+#define CL_ENQUEUE_KERNEL_WITH_ARGS(queue, kernel, global_work_size, 
local_work_size, event, ...)   \
+do {   
 \
+OpenCLKernelArg args[] = {__VA_ARGS__};
 \
+for (int i = 0; i < FF_ARRAY_ELEMS(args); i++) {   
 \
+cle = clSetKernelArg(kernel, i, args[i].arg_size, args[i].arg_val);
 \
+if (cle != CL_SUCCESS) {   
 \
+av_log(avctx, AV_LOG_ERROR, "Failed to set kernel "
 \
+"argument %d: error %d.\n", i, cle);   
 \
+err = AVERROR(EIO);
 \
+goto fail; 
 \
+}  
 \
+}  
 \
+   
 \
+cle = clEnqueueNDRangeKernel(  

[FFmpeg-devel] [PATCH v3 3/3] lavfi: add deshake_opencl filter

2019-08-08 Thread Jarek Samic
---

This filter is the subject of my GSoC project.

This is a video stabilization / deshake filter (name undetermined, feel free to 
discuss) that uses feature
point matching and RANSAC to determine a camera path, smooths the camera path 
with a gaussian filter, and
then applies the new path to the video.

There are a number of debug features that can be turned on (viewing point 
matches, viewing transform
details, viewing average kernel execution times). See the bottom of the file.

Since the last version of the patch, I have:

* Greatly improved the performance of the match_descriptors kernel
* Also improved the performance of various other kernels / buffer reads 
with the same change
* Tested the filter on the Intel OpenCL drivers
* For some reason OpenCL compilation warnings get displayed to the user on 
this platform; if anyone knows how to fix that, please let me know

Performance of the harris_response kernel still leaves something to be desired, 
but I am out of ideas currently to improve it. I am fairly certain
it is simply caused by poor memory access patterns, but I haven't been able to 
find any functioning OpenCL profiling tools so I don't have any way
of confirming that. In any case, even in its current state, the filter is 
faster than the existing deshake filter on both my NVIDIA GPU and my
Intel iGPU with improved output quality.

At this point the filter is ready to be merged (as the end of GSoC is drawing 
near). If anyone has a few minutes to spare, please take the time
to give this filter a try and report any bugs / issues (there is only time left 
to fix major, blocking bugs at this point, such as crashes and
malformed output, but other issues are always great for future work).

 configure   |1 +
 doc/filters.texi|   69 +
 libavfilter/Makefile|2 +
 libavfilter/allfilters.c|1 +
 libavfilter/opencl/deshake.cl   |  647 +
 libavfilter/opencl_source.h |1 +
 libavfilter/vf_deshake_opencl.c | 2202 +++
 7 files changed, 2923 insertions(+)
 create mode 100644 libavfilter/opencl/deshake.cl
 create mode 100644 libavfilter/vf_deshake_opencl.c

diff --git a/configure b/configure
index 5a4f507246..6516b91845 100755
--- a/configure
+++ b/configure
@@ -3441,6 +3441,7 @@ delogo_filter_deps="gpl"
 denoise_vaapi_filter_deps="vaapi"
 derain_filter_select="dnn"
 deshake_filter_select="pixelutils"
+deshake_opencl_filter_deps="opencl"
 dilation_opencl_filter_deps="opencl"
 drawtext_filter_deps="libfreetype"
 drawtext_filter_suggest="libfontconfig libfribidi"
diff --git a/doc/filters.texi b/doc/filters.texi
index 604e44d569..d4d2c0911f 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -19530,6 +19530,75 @@ Make every semi-green pixel in the input transparent 
with some slight blending:
 @end example
 @end itemize
 
+@section deshake_opencl
+Feature-point based video stabilization filter.
+
+The filter accepts the following options:
+
+@table @option
+@item tripod
+Simulates a tripod by preventing any camera movement whatsoever from the 
original frame. Defaults to @code{0}.
+
+@item debug
+Whether or not additional debug info should be displayed, both in the 
processed output and in the console.
+
+Note that in order to see console debug output you will also need to pass 
@code{-v verbose} to ffmpeg.
+
+Viewing point matches in the output video is only supported for RGB input.
+
+Defaults to @code{0}.
+
+@item adaptive_crop
+Whether or not to do a tiny bit of cropping at the borders to cut down on the 
amount of mirrored pixels.
+
+Defaults to @code{1}.
+
+@item refine_features
+Whether or not feature points should be refined at a sub-pixel level.
+
+This can be turned off for a slight performance gain at the cost of precision.
+
+Defaults to @code{1}.
+
+@item smooth_strength
+The strength of the smoothing applied to the camera path from @code{0.0} to 
@code{1.0}.
+
+@code{1.0} is the maximum smoothing strength while values less than that 
result in less smoothing.
+
+@code{0.0} causes the filter to adaptively choose a smoothing strength on a 
per-frame basis.
+
+Defaults to @code{0.0}.
+
+@item smooth_window_multiplier
+Controls the size of the smoothing window (the number of frames buffered to 
determine motion information from).
+
+The size of the smoothing window is determined by multiplying the framerate of 
the video by this number.
+
+Acceptable values range from @code{0.1} to @code{10.0}.
+
+Larger values increase the amount of motion data available for determining how 
to smooth the camera path,
+potentially improving smoothness, but also increase latency and memory usage.
+
+Defaults to @code{2.0}.
+
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Stabilize a video with a fixed, medium smoothing strength:
+@example
+-i INPUT -vf "hwupload, deshake_opencl=smooth_strength=0.5, hwdownload" OUTPUT
+@end example
+
+@item
+Stabilize a video with debugging (both in 

Re: [FFmpeg-devel] [PATCH v2 1/2] swscale: Replace illegal vector keyword usage in altivec code

2019-08-08 Thread Daniel Kolesa
On Thu, Aug 8, 2019, at 14:32, Carl Eugen Hoyos wrote:
> Am Mi., 7. Aug. 2019 um 19:39 Uhr schrieb Daniel Kolesa 
> :
> >
> > While this technically compiles in current ffmpeg, this is only
> > because ffmpeg is compiled in strict ISO C mode, which disables
> > the builtin 'vector' keyword for AltiVec/VSX. Instead this gets
> > replaced with a macro inside altivec.h, which defines vector to
> > be actually __vector, which accepts random types.
> >
> > Normally, the vector keyword should be used only with plain
> > scalar non-typedef types, such as unsigned int. But we have the
> > vec_(s|u)(8|16|32) macros, which can be used in a portable manner,
> > in util_altivec.h in libavutil.
> >
> > This is also consistent with other AltiVec/VSX code elsewhere in
> > the tree.
> >
> > Fixes #7861.
> 
> Since I cannot reproduce any issue with current FFmpeg on Power8
> using gcc-8.3.1, at least the commit message has to be changed,
> same for the other patch.

I don't see why that would need changing. For one, the commit message for the 
first patch describes exactly what is wrong and also the reason you can't 
reproduce it by default (which I also mentioned in the ticket). I believe the 
second patch's reproducibility is limited to more recent gcc (probably only 9.x 
series), it was reproduced by me, the other person in the ticket, as well as 
the Fedora project (see http://koji.rpmfusion.org/koji/taskinfo?taskID=341163).

Regards

> 
> Carl Eugen
> ___
> 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 v3 4/6] avformat/wavdec: s337m support

2019-08-08 Thread Gaullier Nicolas
>.. this won't compile if S377m is disabled. Just go with the old #if
>solution, sorry for causing confusion
My mistake but I think it is a good idea to get rid of some bulky #if... Do you 
think a mixed usage of if and #if would be acceptable ? I think the following 
would be the best :
if (!CONFIG_S337M_DEMUXER || st->codecpar->codec_id != AV_CODEC_ID_DOLBY_E) 
{
(...)
#if CONFIG_S337M_DEMUXER
} else {
(... using s337m_get_packet method ... )
#endif
}

NB: I have to rework all the patchset with carl's feedback, but this point will 
still remain, so better to have it solved now.

Thank you
Nicolas
___
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 v3 3/6] avformat/s337m: Make available as subdemuxer

2019-08-08 Thread Carl Eugen Hoyos
Am Do., 8. Aug. 2019 um 14:18 Uhr schrieb Gaullier Nicolas
:
>
> >> +int avpriv_s337m_probe_stream(void *avc, AVIOContext *pb, AVStream **st, 
> >> int size);

> > This is to the best of my knowledge not acceptable (to have a public 
> > function for a particular
> > format), instead create a new demuxer that supports this raw format.
>
> S337m is a very particular format though:

Yes (like others)

> potentially, it may be probed within any pcm stream, I don't see anything 
> comparable in any other format.

Look at spdif in wav.

> The problem is, the developer will use a standard demuxer or device to open 
> the streams (for example, a
> decklink, an mxf etc.), and then decide if he wants to process some of the 
> streams as regular pcm or as
> dolby E to be decoded. I may be wrong, but I don't see how the same workflow 
> could be obtained by
> creating a new separate demuxer.

This will work without any issue (just as it does for dca in wav).

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

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

Re: [FFmpeg-devel] [PATCH v2 1/2] swscale: Replace illegal vector keyword usage in altivec code

2019-08-08 Thread Carl Eugen Hoyos
Am Mi., 7. Aug. 2019 um 19:39 Uhr schrieb Daniel Kolesa :
>
> While this technically compiles in current ffmpeg, this is only
> because ffmpeg is compiled in strict ISO C mode, which disables
> the builtin 'vector' keyword for AltiVec/VSX. Instead this gets
> replaced with a macro inside altivec.h, which defines vector to
> be actually __vector, which accepts random types.
>
> Normally, the vector keyword should be used only with plain
> scalar non-typedef types, such as unsigned int. But we have the
> vec_(s|u)(8|16|32) macros, which can be used in a portable manner,
> in util_altivec.h in libavutil.
>
> This is also consistent with other AltiVec/VSX code elsewhere in
> the tree.
>
> Fixes #7861.

Since I cannot reproduce any issue with current FFmpeg on Power8
using gcc-8.3.1, at least the commit message has to be changed,
same for the other patch.

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avutil: Add Simple loop detector

2019-08-08 Thread Nicolas George
Lynne (12019-08-08):
> Its niche, we have very few places where there's a chance a loop will
> become infinite. Even then, they're likely all in lavc, and you can
> just put a non-public header there if there's more than a few. And
> right now, there's only one.

You argue that it does not NEED to be in lavu, but not that it SHOULD
note.

> Plus, its not really common av code, and don't let its name mislead
> you, its more of a hack.

I will disregard the insulting subtext of this sentence.

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 1/2] avutil: Add Simple loop detector

2019-08-08 Thread Lynne
Aug 8, 2019, 11:36 AM by geo...@nsup.org:

> Lynne (12019-08-08):
>
>> That's very niche and I don't think it belongs to lavu.
>>
>
> That's a single header with no compiled code.
>
>> Having codec specific code is better.
>>
>
> Why? Why risk bug duplication and maintenance burden?
>

Its niche, we have very few places where there's a chance a loop will become 
infinite. Even then, they're likely all in lavc, and you can just put a 
non-public header there if there's more than a few. And right now, there's only 
one.
Plus, its not really common av code, and don't let its name mislead you, its 
more of a hack.
___
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 v3 3/6] avformat/s337m: Make available as subdemuxer

2019-08-08 Thread Gaullier Nicolas
>> +int avpriv_s337m_probe_stream(void *avc, AVIOContext *pb, AVStream **st, 
>> int size);
>Sorry for not commenting earlier:
You're welcome, a few days is not that much, particularly in the middle of the 
summer!
>This is to the best of my knowledge not acceptable (to have a public function 
>for a particular format), instead create a new demuxer that supports this raw 
>format.
S337m is a very particular format though: potentially, it may be probed within 
any pcm stream, I don't see anything comparable in any other format.
The problem is, the developer will use a standard demuxer or device to open the 
streams (for example, a decklink, an mxf etc.), and then decide if he wants to 
process some of the streams as regular pcm or as dolby E to be decoded. I may 
be wrong, but I don't see how the same workflow could be obtained by creating a 
new separate demuxer.
Nicolas
___
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 v3 3/6] avformat/s337m: Make available as subdemuxer

2019-08-08 Thread Gaullier Nicolas
>Ah, so it's time and not phase? Renaming the #defines to make that clearer 
>would be nice. Other than that, this isn't a huge issue
I assume the start of the packet to be synched with the start of "a" video 
frame, I think there is no use case where pcm and video are not synced, at 
least when dolby E is concerned.
So, DOLBY_E_PHASE_MIN/MAX are phase and well named I think.
Concerning S337M_PHASE_PROBE_MIN that I renamed 
S337M_PROBE_GUARDBAND_MIN_BYTES, this is still a phase, a kind of safe guard 
phase, to make even more unlikely to have a wrong detection. But the question 
is to determine if this phase should be specified in milliseconds or just in 
raw bytes (or another man could say in number of samples whether there are 16 
or 24 bits). There may be other approaches, but if we consider strictly the 
risk of statistical match, it is related to the number of raw bytes, this is 
why I choosed raw bytes at the end and thus the name 
S337M_PROBE_GUARDBAND_MIN_BYTES looks good to me.
Furthermore, at the end, this S337M_PROBE_GUARDBAND_MIN_BYTES is zero for now 
(so whatever the unit), and in my experience, this is generally required as 
there are some programs which indeed have a zero-phase Dolby E (and BTW it 
appears some softwares doesn't like it). Taking the worst case scenario (16 
bits), the sync code takes 4 bytes, so the raw probability is only 1/2^32 (and 
even less taking into account that usually broadcast programs starts with a 
little bit of silence). So anyway, maybe I took too much care on this, but at 
least here this is explicit in the code, I think.

Nicolas
___
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 1/2] lavf/avio: add a ffio_realloc_buf API for AVIO buffer realloc

2019-08-08 Thread Jun Zhao
From: tomajsjiang 

Add new API ffio_realloc_buf for AVIO buffer realloc.

Signed-off-by: Zhongxing Jiang 
---
 libavformat/avio_internal.h |9 +
 libavformat/aviobuf.c   |   31 +++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h
index 04c1ad5..eb628ac 100644
--- a/libavformat/avio_internal.h
+++ b/libavformat/avio_internal.h
@@ -87,6 +87,15 @@ int ffio_read_size(AVIOContext *s, unsigned char *buf, int 
size);
 int ffio_set_buf_size(AVIOContext *s, int buf_size);
 
 /**
+ * Reallocate a given buffer for AVIOContext.
+ *
+ * @param s the AVIOContext to realloc.
+ * @param buf_size required new buffer size.
+ * @return 0 on success, a negative AVERROR on failure.
+ */
+int ffio_realloc_buf(AVIOContext *s, int buf_size);
+
+/**
  * Ensures that the requested seekback buffer size will be available
  *
  * Will ensure that when reading sequentially up to buf_size, seeking
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 2d01102..3b59180 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -1093,6 +1093,37 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size)
 return 0;
 }
 
+int ffio_realloc_buf(AVIOContext *s, int buf_size)
+{
+uint8_t *buffer;
+int data_size;
+
+if (!s->buffer_size)
+return ffio_set_buf_size(s, buf_size);
+
+if (buf_size <= s->buffer_size)
+return 0;
+
+buffer = av_malloc(buf_size);
+if (!buffer)
+return AVERROR(ENOMEM);
+
+data_size = s->write_flag ? (s->buf_ptr - s->buffer) : (s->buf_end - 
s->buf_ptr);
+if (data_size > 0)
+memcpy(buffer, s->write_flag ? s->buffer : s->buf_ptr, data_size);
+av_free(s->buffer);
+s->buffer = buffer;
+s->orig_buffer_size = buf_size;
+s->buffer_size = buf_size;
+s->buf_ptr = s->write_flag ? (s->buffer + data_size) : s->buffer;
+if (s->write_flag)
+s->buf_ptr_max = s->buffer + data_size;
+
+s->buf_end = s->write_flag ? (s->buffer + s->buffer_size) : (s->buf_ptr + 
data_size);
+
+return 0;
+}
+
 static int url_resetbuf(AVIOContext *s, int flags)
 {
 av_assert1(flags == AVIO_FLAG_WRITE || flags == AVIO_FLAG_READ);
-- 
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] lavf/utils: fix error like "offset 0x1f85: partial file"

2019-08-08 Thread Jun Zhao
From: tomajsjiang 

fix error like "offset 0x1f85: partial file", the root cause is when
read the mp4 file from http, and the moov in the end of the mp4 file,
reconfig the buffer will drop some data.

Signed-off-by: Jun Zhao 
Signed-off-by: Zhongxing Jiang 
---
 libavformat/utils.c |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 6c6f4e1..b57e680 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2136,7 +2136,13 @@ void ff_configure_buffers_for_index(AVFormatContext *s, 
int64_t time_tolerance)
 /* XXX This could be adjusted depending on protocol*/
 if (s->pb->buffer_size < pos_delta && pos_delta < (1<<24)) {
 av_log(s, AV_LOG_VERBOSE, "Reconfiguring buffers to size %"PRId64"\n", 
pos_delta);
-ffio_set_buf_size(s->pb, pos_delta);
+
+/* realloc the buffer and the original data will be retained */
+if (ffio_realloc_buf(s->pb, pos_delta)) {
+av_log(s, AV_LOG_ERROR, "Realloc buffer fail.\n");
+return;
+}
+
 s->pb->short_seek_threshold = FFMAX(s->pb->short_seek_threshold, 
pos_delta/2);
 }
 
-- 
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 v3 3/6] avformat/s337m: Make available as subdemuxer

2019-08-08 Thread Tomas Härdin
tor 2019-08-08 klockan 10:28 + skrev Gaullier Nicolas:
> > > +if (pos < size - 9 && pos >=
> > > S337M_PROBE_GUARDBAND_MIN_BYTES) 
> > I think this 9 should be an 11 or 12..
> Indeed, thank you, my mistake.
> 
> > This isn't quite what I meant by turning it into an integer test :)
> > this will likely just be rounded to zero. I meant that things could
> > likely be rearranged so there's no divisions, so the probing isn't
> > subject to the vaguaries of float >rounding
> On one side, dealing with a macro that contains a double
> (S337M_PHASE_PROBE_MIN) makes it impossible at the end to avoid a
> test involving float rounding (in my understanding, but I may be
> wrong, and I remember there are some helpers in ffmpeg to make it
> easier to avoid float rounding), or maybe I should have limited the
> digits and simply worked with an integer number of milliseconds, but
> that sounded a little bit overkill, together with the fact that the
> default value is still 0. so all of this is only in case a
> developer wants to change the #define.
> On the other side, I don't think it was such a good idea to specify
> this in seconds as for the dolby_e min/max. This value is just for
> assurance that there will be no wrong probing, and I thought that
> just byte count was more appropriate... and that makes it an integer
> test at the end :)
> So I replaced : 
>   if (pos < size - 9 && 
>   (s337m_phase = (double)pos * 4 / (*st)->codecpar-
> >bits_per_coded_sample / (*st)->codecpar->sample_rate) >=
> S337M_PHASE_PROBE_MIN) {
> With just simply :
>   if (pos >= S337M_PROBE_GUARDBAND_MIN_BYTES)
> And thus replaced S337M_PHASE_PROBE_MIN=0.000 by
> S337M_PROBE_GUARDBAND_MIN_BYTES=0.
> At the end, I don't see any cons to do that, and it is far most
> simplest.

Ah, so it's time and not phase? Renaming the #defines to make that
clearer would be nice. Other than that, this isn't a huge issue

/Tomas

___
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 v3 3/6] avformat/s337m: Make available as subdemuxer

2019-08-08 Thread Carl Eugen Hoyos
Am Di., 6. Aug. 2019 um 17:08 Uhr schrieb Nicolas Gaullier
:
>
> ---
>  libavformat/s337m.c | 64 
> -
>  libavformat/s337m.h | 64 
> +
>  2 files changed, 117 insertions(+), 11 deletions(-)
>  create mode 100644 libavformat/s337m.h

> diff --git a/libavformat/s337m.h b/libavformat/s337m.h
> new file mode 100644
> index 00..0f21a23a30
> --- /dev/null
> +++ b/libavformat/s337m.h
> @@ -0,0 +1,64 @@
> +/*
> + * Copyright (C) 2017 foo86
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#ifndef AVFORMAT_S337M_H
> +#define AVFORMAT_S337M_H
> +
> +#define MARKER_16LE 0x72F81F4E
> +#define MARKER_20LE 0x20876FF0E154
> +#define MARKER_24LE 0x72F8961F4EA5
> +
> +#define IS_16LE_MARKER(state)   ((state & 0x) == MARKER_16LE)
> +#define IS_20LE_MARKER(state)   ((state & 0xF0F0) == MARKER_20LE)
> +#define IS_24LE_MARKER(state)   ((state & 0x) == MARKER_24LE)
> +#define IS_LE_MARKER(state) (IS_16LE_MARKER(state) || 
> IS_20LE_MARKER(state) || IS_24LE_MARKER(state))
> +
> +#define S337M_MIN_OFFSET 1601*4
> +#define S337M_MAX_OFFSET 2002*6
> +
> +#define S337M_PROBE_GUARDBAND_MIN_BYTES 0
> +#define DOLBY_E_PHASE_MIN   0.000610
> +#define DOLBY_E_PHASE_MAX   0.001050
> +
> +/**
> + * Detect s337m packets in a PCM_S16LE/S24LE stereo stream
> + * If found, the codec of the stream is updated
> + * Requires a single sample with enough (S337M_PROBE_GUARDBAND_MIN_BYTES) 
> and clean (set to zero) guard band
> + * @param avc For av_log
> + * @param pb Associated IO context
> + * @param st Streams
> + * @param size Maximum IO read size available for probing at current position
> + * @return = 0 if no error encountered (even if no s337m was found)
> + */

> +int avpriv_s337m_probe_stream(void *avc, AVIOContext *pb, AVStream **st, int 
> size);

Sorry for not commenting earlier:
This is to the best of my knowledge not acceptable (to have a public
function for a
particular format), instead create a new demuxer that supports this raw format.

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avutil: Add Simple loop detector

2019-08-08 Thread Nicolas George
Lynne (12019-08-08):
> That's very niche and I don't think it belongs to lavu.

That's a single header with no compiled code.

> Having codec specific code is better.

Why? Why risk bug duplication and maintenance burden?

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 1/2] avutil: Add Simple loop detector

2019-08-08 Thread Lynne
Aug 8, 2019, 9:36 AM by mich...@niedermayer.cc:

> This provides an alternative to retry counters.
> Useful if there is no reasonable maximum number of iterations and
> no ordering that naturally avoids loops.
>

That's very niche and I don't think it belongs to lavu.
Having codec specific code is better.
___
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 v3 3/6] avformat/s337m: Make available as subdemuxer

2019-08-08 Thread Gaullier Nicolas
>> +if (pos < size - 9 && pos >= S337M_PROBE_GUARDBAND_MIN_BYTES) 
>I think this 9 should be an 11 or 12..
Indeed, thank you, my mistake.

>This isn't quite what I meant by turning it into an integer test :) this will 
>likely just be rounded to zero. I meant that things could likely be rearranged 
>so there's no divisions, so the probing isn't subject to the vaguaries of 
>float >rounding
On one side, dealing with a macro that contains a double 
(S337M_PHASE_PROBE_MIN) makes it impossible at the end to avoid a test 
involving float rounding (in my understanding, but I may be wrong, and I 
remember there are some helpers in ffmpeg to make it easier to avoid float 
rounding), or maybe I should have limited the digits and simply worked with an 
integer number of milliseconds, but that sounded a little bit overkill, 
together with the fact that the default value is still 0. so all of this is 
only in case a developer wants to change the #define.
On the other side, I don't think it was such a good idea to specify this in 
seconds as for the dolby_e min/max. This value is just for assurance that there 
will be no wrong probing, and I thought that just byte count was more 
appropriate... and that makes it an integer test at the end :)
So I replaced : 
  if (pos < size - 9 && 
  (s337m_phase = (double)pos * 4 / (*st)->codecpar->bits_per_coded_sample / 
(*st)->codecpar->sample_rate) >= S337M_PHASE_PROBE_MIN) {
With just simply :
  if (pos >= S337M_PROBE_GUARDBAND_MIN_BYTES)
And thus replaced S337M_PHASE_PROBE_MIN=0.000 by 
S337M_PROBE_GUARDBAND_MIN_BYTES=0.
At the end, I don't see any cons to do that, and it is far most simplest.

> +#define DOLBY_E_PHASE_MIN   0.000610
> +#define DOLBY_E_PHASE_MAX   0.001050
>Where do these phase values come from? Is there a spec somewhere?
https://www.dolby.com/us/en/technologies/dolby-e-line-position.pdf

Nicolas
___
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] MpegTS contribution question

2019-08-08 Thread Anthony Delannoy
Hi,

I'm currently doing my first contribution to ffmpeg by adding EPG support
in the mpegts format.
For now, i succeeded to add support for EIT table and majority of its
descriptors and can read/export EPG
events in a .csv file.
But I don't know on how to organize it now. Do I make a new codec for epg
and a data stream? Do I keep those
information « hidden » and present them only in metadatas plus functions
api to export them?

For those who wants to see where I am at:
https://github.com/spnngl/FFmpeg/tree/epg2

Some remarks:
  * For now I use linked list to store EPG events but I may change for
something simpler.
  * I made separate descriptors code to be able to use it on others tables
later. I want to add NIT table
  support and maybe others if i succeed to finish EPG.
  * EPG/descriptors files are all in libavformat for now, they need to be
moved

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avutil: Add Simple loop detector

2019-08-08 Thread Nicolas George
Michael Niedermayer (12019-08-08):
> This provides an alternative to retry counters.
> Useful if there is no reasonable maximum number of iterations and
> no ordering that naturally avoids loops.
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  doc/APIchanges|  3 ++
>  libavutil/Makefile|  1 +
>  libavutil/loop_detector.h | 71 +++
>  3 files changed, 75 insertions(+)
>  create mode 100644 libavutil/loop_detector.h
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 6603a8229e..eee4c30ec5 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil: 2017-10-21
>  
>  API changes, most recent first:
>  
> +2019-XX-XX - XX - lavu 56.XX.XXX - loop_detector.h
> +  Add loop_detector.h, av_is_loop(), AVSimpleLoopDetector
> +
>  2019-07-27 - xx - lavu 56.33.100 - tx.h
>Add AV_TX_DOUBLE_FFT and AV_TX_DOUBLE_MDCT
>  
> diff --git a/libavutil/Makefile b/libavutil/Makefile
> index 57e6e3d7e8..0b77fa6347 100644
> --- a/libavutil/Makefile
> +++ b/libavutil/Makefile
> @@ -48,6 +48,7 @@ HEADERS = adler32.h 
> \
>intreadwrite.h\
>lfg.h \
>log.h \
> +  loop_detector.h   \
>macros.h  \
>mathematics.h \
>mastering_display_metadata.h  \
> diff --git a/libavutil/loop_detector.h b/libavutil/loop_detector.h
> new file mode 100644
> index 00..6f8643495a
> --- /dev/null
> +++ b/libavutil/loop_detector.h
> @@ -0,0 +1,71 @@
> +/*
> + * Copyright (C) 2019 Michael Niedermayer (mich...@niedermayer.cc)
> + *
> + * 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
> + */
> +
> +
> +/**
> + * @file
> + * Utilties for detecting infinite loops
> + * @author Michael Niedermayer 
> + */
> +
> +#ifndef AVUTIL_LOOP_DETECTOR_H
> +#define AVUTIL_LOOP_DETECTOR_H
> +
> +typedef struct AVSimpleLoopDetector {
> +uint64_t count;
> +uint64_t state;
> +} AVSimpleLoopDetector;
> +
> +/**
> + * Checks if the list of states provided by the user fell into a cycle.
> + *

> + * To initialize or reset the detector, the context is simply memset to 0.

I suggest:

#define AV_SIMPLE_LOOP_DETECTOR_INIT {0}

so we can extend it if needs be.

> + * This detector requires only 16bytes of context and minimal computations
> + * per iteration. In exchange for this simplicity it takes a few iterations
> + * into a loop before it is detected.
> + * No deallocation or memory allocation is needed.
> + *
> + * @param c The context, initialy and to reset, it is simply memset to 0.
> + *  It is only 16bytes so as to be lightweight and not poison any
> + *  data cache.
> + *

> + * @param state The loop state, when this falls into a cycle the detector
> + *  will after a few iterations return 1.
> + *
> + * @param max_iterations
> + *  after this many iterations the detector will return 1 
> regardless
> + *  of it falling into a cycle.

Even with the code, I do not manage to understand exactly what it means,
in particular what the state is. The example uses a single state, so any
cycle is trivial.

> + *
> + * @return 1 if a loop is detected, 0 otherwise, no errors are possible.
> + * The code will always return 1 once it returned 1 until its reset.
> + */
> +static inline int av_is_loop(AVSimpleLoopDetector *c, uint64_t state, 
> uint64_t max_iterations)
> +{
> +if (c->count && c->state == state)
> +c->count = max_iterations;
> +if (c->count >= max_iterations)
> +return 1;
> +c->count ++;
> +if (!(c->count & (c->count - 1)))
> +c->state = state;
> +return 0;
> +}
> +
> +#endif /* AVUTIL_LOOP_DETECTOR_H */

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing 

Re: [FFmpeg-devel] libavcodec: add timeshift bitstream filter [v3]

2019-08-08 Thread Nicolas George
Andreas Håkon (12019-08-08):
> > setpts or setts, similar to lavfi.

> Then I proposse these two alternatives:
> 
> 1) "editpts_bsf"
> 2) "setpts_bsf"
> 
> The "_bsf" is not real, only to differenciate (here) from other filters.
> Which one do you prefer?

editpts has no similarity with lavfi. Users would need to remember if it
is filters <-> set and bsf <-> edit or filters <-> edit and bsf <-> set.
Better have a single name.

Bitstream filters and lavfi are not in the same namespace, therefore the
suffix is unneeded.


Gyan (12019-08-08):
> This BSF only allows to apply a fixed offset whereas the setpts filter
> allows arbitrary expressions. Unless someone is planning to extend this
> BSF,  the current candidate is more apt.

At some point, somebody will implement generic expression eval. When
that happens, it will be better if they can just add an option to the
existing filter rather than creating a whole new filter, deprecating the
existing one, etc.

Key idea: long term planning.

Therefore, I am for setpts (dts is just secondary), with a mention in
the documentation:

# Unlike the setpts filter in libavfilter, this filter currently can
# only apply a constant offset.

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] DSD improvements

2019-08-08 Thread Carl Eugen Hoyos
Am Fr., 2. Aug. 2019 um 09:00 Uhr schrieb Paul B Mahol :
> patches attached.

I see nice and reasonable results, only tested with both patches applied.
(Roughly doubled decoding speed at roughly twice cpu load, very little
slowdown for -threads 1 compared to unpatched FFmpeg)

Thank you, Carl Eugen
___
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] libavcodec: add timeshift bitstream filter [v3]

2019-08-08 Thread Gyan



On 08-08-2019 02:16 PM, Nicolas George wrote:

Alexander Strasser (12019-08-08):

Maybe others have better suggestions.

setpts or setts, similar to lavfi.


This BSF only allows to apply a fixed offset whereas the setpts filter 
allows arbitrary expressions. Unless someone is planning to extend this 
BSF,  the current candidate is more apt.


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] libavcodec: add timeshift bitstream filter [v3]

2019-08-08 Thread Andreas Håkon
Hi Nicolas,

‐‐‐ Original Message ‐‐‐
On Thursday, 8 de August de 2019 10:46, Nicolas George  wrote:

> Alexander Strasser (12019-08-08):
>
> > Maybe others have better suggestions.
>
> setpts or setts, similar to lavfi.

Then I proposse these two alternatives:

1) "editpts_bsf"
2) "setpts_bsf"

The "_bsf" is not real, only to differenciate (here) from other filters.
Which one do you prefer?


> Although in lavfi I have a vague intention of merging all the set*
> filters into a single one.

OK.


Regards.
A.H.

---

___
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] libavcodec: add timeshift bitstream filter [v3]

2019-08-08 Thread Nicolas George
Alexander Strasser (12019-08-08):
> Maybe others have better suggestions.

setpts or setts, similar to lavfi.

Although in lavfi I have a vague intention of merging all the set*
filters into a single one.

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

[FFmpeg-devel] [PATCH 2/2] avcodec/tiff: Detect infinite retry loop

2019-08-08 Thread Michael Niedermayer
Fixes: Timeout (Infinite -> 26ms)
Fixes: 
15706/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5114674904825856

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

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index c520d7df83..e3bdd8612e 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -37,6 +37,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/imgutils.h"
+#include "libavutil/loop_detector.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
 #include "bytestream.h"
@@ -1407,6 +1408,7 @@ static int decode_frame(AVCodecContext *avctx,
 GetByteContext stripsizes;
 GetByteContext stripdata;
 int retry_for_subifd, retry_for_page;
+AVSimpleLoopDetector loop_detector = {0};
 
 bytestream2_init(>gb, avpkt->data, avpkt->size);
 
@@ -1467,6 +1469,10 @@ again:
 av_log(avctx, AV_LOG_ERROR, "IFD offset is greater than image 
size\n");
 return AVERROR_INVALIDDATA;
 }
+if (av_is_loop(_detector, off, INT64_MAX)) {
+av_log(avctx, AV_LOG_ERROR, "too many retries\n");
+return AVERROR_INVALIDDATA;
+}
 s->sub_ifd = 0;
 goto again;
 }
-- 
2.22.0

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

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

Re: [FFmpeg-devel] [PATCH 3/3] avformat/avio: remove 4k limit from avio_printf

2019-08-08 Thread Nicolas George
Marton Balint (12019-08-07):
> The function returns an int so it can't signal writing longer strings that
> that.

Yet, replacing an arbitrary limit by another arbitrary limit, however
high, seems very wrong.

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

[FFmpeg-devel] [PATCH 1/2] avutil: Add Simple loop detector

2019-08-08 Thread Michael Niedermayer
This provides an alternative to retry counters.
Useful if there is no reasonable maximum number of iterations and
no ordering that naturally avoids loops.

Signed-off-by: Michael Niedermayer 
---
 doc/APIchanges|  3 ++
 libavutil/Makefile|  1 +
 libavutil/loop_detector.h | 71 +++
 3 files changed, 75 insertions(+)
 create mode 100644 libavutil/loop_detector.h

diff --git a/doc/APIchanges b/doc/APIchanges
index 6603a8229e..eee4c30ec5 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2019-XX-XX - XX - lavu 56.XX.XXX - loop_detector.h
+  Add loop_detector.h, av_is_loop(), AVSimpleLoopDetector
+
 2019-07-27 - xx - lavu 56.33.100 - tx.h
   Add AV_TX_DOUBLE_FFT and AV_TX_DOUBLE_MDCT
 
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 57e6e3d7e8..0b77fa6347 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -48,6 +48,7 @@ HEADERS = adler32.h   
  \
   intreadwrite.h\
   lfg.h \
   log.h \
+  loop_detector.h   \
   macros.h  \
   mathematics.h \
   mastering_display_metadata.h  \
diff --git a/libavutil/loop_detector.h b/libavutil/loop_detector.h
new file mode 100644
index 00..6f8643495a
--- /dev/null
+++ b/libavutil/loop_detector.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2019 Michael Niedermayer (mich...@niedermayer.cc)
+ *
+ * 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
+ */
+
+
+/**
+ * @file
+ * Utilties for detecting infinite loops
+ * @author Michael Niedermayer 
+ */
+
+#ifndef AVUTIL_LOOP_DETECTOR_H
+#define AVUTIL_LOOP_DETECTOR_H
+
+typedef struct AVSimpleLoopDetector {
+uint64_t count;
+uint64_t state;
+} AVSimpleLoopDetector;
+
+/**
+ * Checks if the list of states provided by the user fell into a cycle.
+ *
+ * To initialize or reset the detector, the context is simply memset to 0.
+ * This detector requires only 16bytes of context and minimal computations
+ * per iteration. In exchange for this simplicity it takes a few iterations
+ * into a loop before it is detected.
+ * No deallocation or memory allocation is needed.
+ *
+ * @param c The context, initialy and to reset, it is simply memset to 0.
+ *  It is only 16bytes so as to be lightweight and not poison any
+ *  data cache.
+ *
+ * @param state The loop state, when this falls into a cycle the detector
+ *  will after a few iterations return 1.
+ *
+ * @param max_iterations
+ *  after this many iterations the detector will return 1 
regardless
+ *  of it falling into a cycle.
+ *
+ * @return 1 if a loop is detected, 0 otherwise, no errors are possible.
+ * The code will always return 1 once it returned 1 until its reset.
+ */
+static inline int av_is_loop(AVSimpleLoopDetector *c, uint64_t state, uint64_t 
max_iterations)
+{
+if (c->count && c->state == state)
+c->count = max_iterations;
+if (c->count >= max_iterations)
+return 1;
+c->count ++;
+if (!(c->count & (c->count - 1)))
+c->state = state;
+return 0;
+}
+
+#endif /* AVUTIL_LOOP_DETECTOR_H */
-- 
2.22.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".