[FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: Fix 3 'discards qualifiers' clang compiler warnings

2017-06-05 Thread Patrick Earnest
This email should have the patch. Sorry for the duplicate.

When compiled by clang, libavcodec/videotoolboxenc.c produces three 'discards 
qualifiers' warnings. 
Changing type of nums[2] from void * to CFNumberRef silences the first two 
warnings.
Adding a pointer (numsptr) to nums[2], and using that in CFArrayCreate silences 
the third warning.

Signed-off-by: Patrick Earnest 
---
 libavcodec/videotoolboxenc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 638f278cd0..4cc4fbfef4 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -904,7 +904,8 @@ static int vtenc_create_encoder(AVCodecContext   *avctx,
 CFArrayRef   data_rate_limits;
 int64_t  bytes_per_second_value = 0;
 int64_t  one_second_value = 0;
-void *nums[2];
+CFNumberRef  nums[2];
+void *numsptr = nums;
 
 int status = VTCompressionSessionCreate(kCFAllocatorDefault,
 avctx->width,
@@ -962,7 +963,7 @@ static int vtenc_create_encoder(AVCodecContext   *avctx,
 nums[0] = bytes_per_second;
 nums[1] = one_second;
 data_rate_limits = CFArrayCreate(kCFAllocatorDefault,
- nums,
+ numsptr,
  2,
  &kCFTypeArrayCallBacks);
 
-- 
2.11.0 (Apple Git-81)

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


Re: [FFmpeg-devel] [PATCH 3/3] avformat: set the default whitelist to disable hls

2017-06-05 Thread Hendrik Leppkes
On Tue, Jun 6, 2017 at 4:59 AM, Michael Niedermayer
 wrote:
>>
>> The issue is about subsets of the URL space. Files from one URL should
>> be allowed to access data from URLs in the same relevant subset (same
>> subdirectory or same web server maybe?), but not outside.
>
> What percentage of hls files out in the wild does this work with ?
>
>

If you implement this over HTTP, you also need to implement CORS
(Cross Origin Resouce Sharing), which is a defined mechanism to break
these static rules when you need/want to load content from other
domains.
Many web-based HLS players basically require this so the browser can
access the files.

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


[FFmpeg-devel] [PATCH] libavutil/eval: Add round function to expression parser

2017-06-05 Thread Kevin Mark
We have floor, ceil, and trunc. Let's add round.

Signed-off-by: Kevin Mark 
---
 doc/utils.texi   | 3 +++
 libavutil/eval.c | 5 -
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/doc/utils.texi b/doc/utils.texi
index 1734439459..d65bdf0b0e 100644
--- a/doc/utils.texi
+++ b/doc/utils.texi
@@ -914,6 +914,9 @@ various input values that the expression can access through
 @code{ld(0)}. When the expression evaluates to 0 then the
 corresponding input value will be returned.
 
+@item round(expr)
+Round the value of expression @var{expr} to the nearest integer. For example, 
"round(1.5)" is "2.0".
+
 @item sin(x)
 Compute sine of @var{x}.
 
diff --git a/libavutil/eval.c b/libavutil/eval.c
index 7e866155db..638259adef 100644
--- a/libavutil/eval.c
+++ b/libavutil/eval.c
@@ -153,7 +153,7 @@ struct AVExpr {
 e_squish, e_gauss, e_ld, e_isnan, e_isinf,
 e_mod, e_max, e_min, e_eq, e_gt, e_gte, e_lte, e_lt,
 e_pow, e_mul, e_div, e_add,
-e_last, e_st, e_while, e_taylor, e_root, e_floor, e_ceil, e_trunc,
+e_last, e_st, e_while, e_taylor, e_root, e_floor, e_ceil, e_trunc, 
e_round,
 e_sqrt, e_not, e_random, e_hypot, e_gcd,
 e_if, e_ifnot, e_print, e_bitand, e_bitor, e_between, e_clip, e_atan2
 } type;
@@ -189,6 +189,7 @@ static double eval_expr(Parser *p, AVExpr *e)
 case e_floor:  return e->value * floor(eval_expr(p, e->param[0]));
 case e_ceil :  return e->value * ceil (eval_expr(p, e->param[0]));
 case e_trunc:  return e->value * trunc(eval_expr(p, e->param[0]));
+case e_round:  return e->value * round(eval_expr(p, e->param[0]));
 case e_sqrt:   return e->value * sqrt (eval_expr(p, e->param[0]));
 case e_not:return e->value * (eval_expr(p, e->param[0]) == 0);
 case e_if: return e->value * (eval_expr(p, e->param[0]) ? 
eval_expr(p, e->param[1]) :
@@ -440,6 +441,7 @@ static int parse_primary(AVExpr **e, Parser *p)
 else if (strmatch(next, "floor" )) d->type = e_floor;
 else if (strmatch(next, "ceil"  )) d->type = e_ceil;
 else if (strmatch(next, "trunc" )) d->type = e_trunc;
+else if (strmatch(next, "round" )) d->type = e_round;
 else if (strmatch(next, "sqrt"  )) d->type = e_sqrt;
 else if (strmatch(next, "not"   )) d->type = e_not;
 else if (strmatch(next, "pow"   )) d->type = e_pow;
@@ -637,6 +639,7 @@ static int verify_expr(AVExpr *e)
 case e_floor:
 case e_ceil:
 case e_trunc:
+case e_round:
 case e_sqrt:
 case e_not:
 case e_random:
-- 
2.13.0

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


Re: [FFmpeg-devel] [PATCH 3/3] avformat: set the default whitelist to disable hls

2017-06-05 Thread Michael Niedermayer
On Mon, Jun 05, 2017 at 05:33:29PM +0200, Nicolas George wrote:
> Le septidi 17 prairial, an CCXXV, Michael Niedermayer a écrit :
[...]
> > You dont need to convince me that the extension check or changes
> > within just hls are not a complete solution. Iam quite well aware
> > of this. This is intended to stop an existing exploit and variants of
> > it in practice and do so quickly.
> 
> It depends on the severity of the threat. This one seems quite minor and
> far-fetched, and thus I think we could take our time to fix it properly.
> We all have noticed that temporary quick-and-dirty fixes usually stay
> here a long time unless whoever implemented them is actively working on
> a real fix.

I disagree that the issue is minor and far fetched.

The exploit that i have was successfully used against multiple
companies (it was a demonstration and AFAIK no harm was done).
That same attack works against all recent releases.

My oppinion was and is that a exploit working basically on 100% of
targets and can leak private information is a serious issue.

I think that if argumentation continues to center around the
lack of importance of this issue then we should try to bring some
outside security experts into this discussion.


[...]
> Still, after having spent a few hours in a train without proper network
> access, and with someone actually interested in listening, I could give
> it some thought.
> 
> I will start by explaining why protocol_whitelist is bad.
> 
> First, it is a string. Enough with strings used as data structures! That
> is inefficient, inconvenient and a maintenance nightmare since extending
> or fixing the syntax will likely be considered an API break by some.
> 
> Second, the issue never was about protocols. ~/tmp/playlist.m3u8 should
> not be allowed to access ../.firefox/cookies.txt (Firefox protects us
> from that by adding a salt in the path, but not all sensitive files are
> protected that way, this is only an illustrative example), and that
> applies to local files, to SMB shares or to SFTP clients;

> http://www.example.com/playlist.m3u8 should not be allowed to access
> http://localhost:631/, yet they are both HTTP.

yes but its worse than this
http://www.example.com:631/playlist.m3u8
and
http://www.example.com:631

can already screw you, if you are not carefull. The reason is the DNS
lookups. these 2 uses can lookup to different IPs, one could be on
the LAN the other the attackers server
If you want to prevent this, I think you need to implement a global
DNS cache. Technically that can be done and i belive browsers are
doing this and doing this for the reason above. iam no browser expert
though it just all fits together ...


> 
> The issue is about subsets of the URL space. Files from one URL should
> be allowed to access data from URLs in the same relevant subset (same
> subdirectory or same web server maybe?), but not outside.

What percentage of hls files out in the wild does this work with ?


> 
> Of course, the protocol is part of the URL. But not all protocols are
> like that: file://, http://, ssh:// are part of the URL, while concat:,
> crypto:, subfile: are not and should be transparent for the mechanism. I
> will call the formers "URL protocols" and the laters "utility
> protocols".
> 
> So let us get rid of that protocol_whitelist and replace it with an
> actual data structure, designed to encode a subset of the URL space. Let
> us call it AVSecurityClearance, at least for the rest of this mail.
> 
> Now, there is something done right with protocol_whitelist: it is, as it
> should be, a property of muxers, demuxers and protocols (and anything
> else that would be allowed to access external data) and must be
> inherited when a component opens another component (demuxer -> protocol,
> or demuxer -> slave demuxer, or protocol -> slave protocol, etc.).
> AVSecurityClearance should work the same way.
> 
> Now, how should we implement that data structure? I do not know!
> 

> Maybe we can restrict it to subsets that are a sub-hierarchy: "anything
> below http://www.example.com/music/";.

a file /home/jane/fromweb.hls
should not be allowed to access /home/jane/.ssh/
which would be a sudirectory


> 
> But I suspect AVSecurityClearance will need to be polymorphic: the
> structure of data is not necessarily the same for all protocols.
> 
> If AVSecurityClearance is polymorphic, then implementing union and
> intersection operators is quite easy.
> 
> A few considerations about hierarchy. Some protocols have a host part.
> The syntax of DNS domains is hierarchical from right to left, unlike the
> syntax for file paths. It must be handled separately. The port part
> needs a special treatment too: which ones are closer to
> http://example.com/: http://www.example.com/ or
> http://example.com:8080/? Or maybe they are to be considered all
> separate.
> 
> Also, URLs with numerical IP addresses require a special treatment; we
> do not want to implement a whois client, so we will have to tre

[FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: Fix 3 'discards qualifiers' clang compiler warnings

2017-06-05 Thread Patrick Earnest
When compiled by clang, libavcodec/videotoolboxenc.c produces three warnings:
libavcodec/videotoolboxenc.c:962:13: warning: assigning to 'void *' from 
'CFNumberRef' (aka 'const struct __CFNumber *') discards qualifiers 
[-Wincompatible-pointer-types-discards-qualifiers]
nums[0] = bytes_per_second;
^ 
libavcodec/videotoolboxenc.c:963:13: warning: assigning to 'void *' from 
'CFNumberRef' (aka 'const struct __CFNumber *') discards qualifiers 
[-Wincompatible-pointer-types-discards-qualifiers]
nums[1] = one_second;
^ ~~
libavcodec/videotoolboxenc.c:965:38: warning: passing 'void *[2]' to parameter 
of type 'const void **' discards qualifiers in nested pointer types 
[-Wincompatible-pointer-types-discards-qualifiers]
 nums,
 ^~~~
/System/Library/Frameworks/CoreFoundation.framework/Headers/CFArray.h:174:65: 
note: passing argument to parameter 'values' here
CFArrayRef CFArrayCreate(CFAllocatorRef allocator, const void **values, CFIndex 
numValues, const CFArrayCallBacks *callBacks);

^
3 warnings generated.

Changing type of nums[2] from void * to CFNumberRef silences the first two 
warnings.
Adding a pointer (numsptr) to nums[2], and using that in CFArrayCreate silences 
the third warning.

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


Re: [FFmpeg-devel] [PATCH] Add spherical_mapping command-line argument to ffmpeg.

2017-06-05 Thread Vittorio Giovara
On Mon, Jun 5, 2017 at 4:46 PM Aaron Colwell  wrote
> Attached a new patch that fixes a bug and the indentation in the previous
> patch. This should be good now. Sorry for the spam.
>
> Aaron
>
> On Mon, Jun 5, 2017 at 12:32 PM Aaron Colwell  wrote:
> [...]

Yeah this version looks much better, thanks for the update.
-- 
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v3] lavc: add mpeg2 decoder/hwaccel to mediacodec

2017-06-05 Thread Aman Gupta
From: Aman Gupta 

Android TV and FireOS hardware supports mpeg2 hardware decoding via MediaCodec.
---
 configure |  2 ++
 libavcodec/Makefile   |  1 +
 libavcodec/allcodecs.c|  2 ++
 libavcodec/mediacodecdec.c| 40 ++-
 libavcodec/mediacodecdec_common.c |  7 +++
 5 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 72060ef0e9..5816de2398 100755
--- a/configure
+++ b/configure
@@ -2656,6 +2656,7 @@ mpeg2_d3d11va_hwaccel_deps="d3d11va"
 mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
 mpeg2_dxva2_hwaccel_deps="dxva2"
 mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
+mpeg2_mediacodec_hwaccel_deps="mediacodec"
 mpeg2_mmal_hwaccel_deps="mmal"
 mpeg2_qsv_hwaccel_deps="libmfx"
 mpeg2_qsv_hwaccel_select="qsvdec_mpeg2"
@@ -2762,6 +2763,7 @@ mpeg1_vdpau_decoder_select="mpeg1video_decoder"
 mpeg2_crystalhd_decoder_select="crystalhd"
 mpeg2_cuvid_decoder_deps="cuda cuvid"
 mpeg2_mmal_decoder_deps="mmal"
+mpeg2_mediacodec_decoder_deps="mediacodec"
 mpeg2_qsv_decoder_deps="libmfx"
 mpeg2_qsv_decoder_select="qsvdec mpeg2_qsv_hwaccel"
 mpeg2_qsv_encoder_deps="libmfx"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 0818950ad9..a752f87ef5 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -423,6 +423,7 @@ OBJS-$(CONFIG_MPEG2_QSV_DECODER)   += qsvdec_other.o
 OBJS-$(CONFIG_MPEG2_QSV_ENCODER)   += qsvenc_mpeg2.o
 OBJS-$(CONFIG_MPEG2VIDEO_DECODER)  += mpeg12dec.o mpeg12.o mpeg12data.o
 OBJS-$(CONFIG_MPEG2VIDEO_ENCODER)  += mpeg12enc.o mpeg12.o
+OBJS-$(CONFIG_MPEG2_MEDIACODEC_DECODER) += mediacodecdec.o
 OBJS-$(CONFIG_MPEG2_VAAPI_ENCODER) += vaapi_encode_mpeg2.o
 OBJS-$(CONFIG_MPEG4_DECODER)   += xvididct.o
 OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 89fadcd2fa..4373ebd975 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -96,6 +96,7 @@ static void register_all(void)
 REGISTER_HWACCEL(MPEG2_VAAPI,   mpeg2_vaapi);
 REGISTER_HWACCEL(MPEG2_VDPAU,   mpeg2_vdpau);
 REGISTER_HWACCEL(MPEG2_VIDEOTOOLBOX, mpeg2_videotoolbox);
+REGISTER_HWACCEL(MPEG2_MEDIACODEC,  mpeg2_mediacodec);
 REGISTER_HWACCEL(MPEG4_CUVID,   mpeg4_cuvid);
 REGISTER_HWACCEL(MPEG4_MEDIACODEC,  mpeg4_mediacodec);
 REGISTER_HWACCEL(MPEG4_MMAL,mpeg4_mmal);
@@ -257,6 +258,7 @@ static void register_all(void)
 REGISTER_DECODER(MPEG2_MMAL,mpeg2_mmal);
 REGISTER_DECODER(MPEG2_CRYSTALHD,   mpeg2_crystalhd);
 REGISTER_DECODER(MPEG2_QSV, mpeg2_qsv);
+REGISTER_DECODER(MPEG2_MEDIACODEC,  mpeg2_mediacodec);
 REGISTER_DECODER(MSA1,  msa1);
 REGISTER_DECODER(MSCC,  mscc);
 REGISTER_DECODER(MSMPEG4V1, msmpeg4v1);
diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index ccfcb4b9ce..5bdeb6c1d7 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -1,5 +1,5 @@
 /*
- * Android MediaCodec H.264 / H.265 / MPEG-4 / VP8 / VP9 decoders
+ * Android MediaCodec MPEG-2 / H.264 / H.265 / MPEG-4 / VP8 / VP9 decoders
  *
  * Copyright (c) 2015-2016 Matthieu Bouron 
  *
@@ -267,6 +267,19 @@ done:
 }
 #endif
 
+#if CONFIG_MPEG2_MEDIACODEC_DECODER
+static int mpeg2_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
+{
+int ret = 0;
+
+if (avctx->extradata) {
+ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, 
avctx->extradata_size);
+}
+
+return ret;
+}
+#endif
+
 #if CONFIG_MPEG4_MEDIACODEC_DECODER
 static int mpeg4_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
 {
@@ -333,6 +346,15 @@ static av_cold int mediacodec_decode_init(AVCodecContext 
*avctx)
 goto done;
 break;
 #endif
+#if CONFIG_MPEG2_MEDIACODEC_DECODER
+case AV_CODEC_ID_MPEG2VIDEO:
+codec_mime = "video/mpeg2";
+
+ret = mpeg2_set_extradata(avctx, format);
+if (ret < 0)
+goto done;
+break;
+#endif
 #if CONFIG_MPEG4_MEDIACODEC_DECODER
 case AV_CODEC_ID_MPEG4:
 codec_mime = "video/mp4v-es",
@@ -575,6 +597,22 @@ AVCodec ff_hevc_mediacodec_decoder = {
 };
 #endif
 
+#if CONFIG_MPEG2_MEDIACODEC_DECODER
+AVCodec ff_mpeg2_mediacodec_decoder = {
+.name   = "mpeg2_mediacodec",
+.long_name  = NULL_IF_CONFIG_SMALL("MPEG-2 Android MediaCodec 
decoder"),
+.type   = AVMEDIA_TYPE_VIDEO,
+.id = AV_CODEC_ID_MPEG2VIDEO,
+.priv_data_size = sizeof(MediaCodecH264DecContext),
+.init   = mediacodec_decode_init,
+.decode = mediacodec_decode_frame,
+.flush  = mediacodec_decode_flush,
+.close  = mediacodec_decode_close,
+.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING,
+.caps_internal  = FF_CODEC_CAP_SETS_PKT_DTS,
+};
+#endif
+
 #if CONFIG_MPEG4_MEDIACODEC_DECODE

[FFmpeg-devel] [PATCH] vf_colorspace: Add support for gbr color space

2017-06-05 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara 
---
 libavfilter/vf_colorspace.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index 0024505a44..0b1bc81f99 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -183,6 +183,13 @@ static const double ycgco_matrix[3][3] =
 {  0.5,  0,   -0.5  },
 };
 
+static const double gbr_matrix[3][3] =
+{
+{ 0,1,   0   },
+{ 0,   -0.5, 0.5 },
+{ 0.5, -0.5, 0   },
+};
+
 /*
  * All constants explained in e.g. 
https://linuxtv.org/downloads/v4l-dvb-apis/ch02s06.html
  * The older ones (bt470bg/m) are also explained in their respective ITU docs
@@ -196,6 +203,7 @@ static const struct LumaCoefficients 
luma_coefficients[AVCOL_SPC_NB] = {
 [AVCOL_SPC_BT709]  = { 0.2126, 0.7152, 0.0722 },
 [AVCOL_SPC_SMPTE240M]  = { 0.212,  0.701,  0.087  },
 [AVCOL_SPC_YCOCG]  = { 0.25,   0.5,0.25   },
+[AVCOL_SPC_RGB]= { 1,  1,  1  },
 [AVCOL_SPC_BT2020_NCL] = { 0.2627, 0.6780, 0.0593 },
 [AVCOL_SPC_BT2020_CL]  = { 0.2627, 0.6780, 0.0593 },
 };
@@ -222,6 +230,9 @@ static void fill_rgb2yuv_table(const struct 
LumaCoefficients *coeffs,
 if (coeffs->cr == 0.25 && coeffs->cg == 0.5 && coeffs->cb == 0.25) {
 memcpy(rgb2yuv, ycgco_matrix, sizeof(double) * 9);
 return;
+} else if (coeffs->cr == 1 && coeffs->cg == 1 && coeffs->cb == 1) {
+memcpy(rgb2yuv, gbr_matrix, sizeof(double) * 9);
+return;
 }
 
 rgb2yuv[0][0] = coeffs->cr;
@@ -1074,6 +1085,7 @@ static const AVOption colorspace_options[] = {
 ENUM("smpte170m",   AVCOL_SPC_SMPTE170M,   "csp"),
 ENUM("smpte240m",   AVCOL_SPC_SMPTE240M,   "csp"),
 ENUM("ycgco",   AVCOL_SPC_YCGCO,   "csp"),
+ENUM("gbr", AVCOL_SPC_RGB, "csp"),
 ENUM("bt2020ncl",   AVCOL_SPC_BT2020_NCL,  "csp"),
 
 { "range",  "Output color range",
-- 
2.12.0

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


Re: [FFmpeg-devel] [PATCH v2] lavc: add mpeg2 decoder/hwaccel to mediacodec

2017-06-05 Thread Aman Gupta
On Mon, Jun 5, 2017 at 1:29 PM, Aman Gupta  wrote:

> From: Aman Gupta 
>
> Android TV and FireOS hardware supports mpeg2 hardware decoding via
> MediaCodec.
> ---
>  configure |  2 ++
>  libavcodec/Makefile   |  1 +
>  libavcodec/allcodecs.c|  2 ++
>  libavcodec/mediacodecdec.c| 23 ++-
>  libavcodec/mediacodecdec_common.c |  7 +++
>  5 files changed, 34 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index 72060ef0e9..5816de2398 100755
> --- a/configure
> +++ b/configure
> @@ -2656,6 +2656,7 @@ mpeg2_d3d11va_hwaccel_deps="d3d11va"
>  mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
>  mpeg2_dxva2_hwaccel_deps="dxva2"
>  mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
> +mpeg2_mediacodec_hwaccel_deps="mediacodec"
>  mpeg2_mmal_hwaccel_deps="mmal"
>  mpeg2_qsv_hwaccel_deps="libmfx"
>  mpeg2_qsv_hwaccel_select="qsvdec_mpeg2"
> @@ -2762,6 +2763,7 @@ mpeg1_vdpau_decoder_select="mpeg1video_decoder"
>  mpeg2_crystalhd_decoder_select="crystalhd"
>  mpeg2_cuvid_decoder_deps="cuda cuvid"
>  mpeg2_mmal_decoder_deps="mmal"
> +mpeg2_mediacodec_decoder_deps="mediacodec"
>  mpeg2_qsv_decoder_deps="libmfx"
>  mpeg2_qsv_decoder_select="qsvdec mpeg2_qsv_hwaccel"
>  mpeg2_qsv_encoder_deps="libmfx"
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 0818950ad9..a752f87ef5 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -423,6 +423,7 @@ OBJS-$(CONFIG_MPEG2_QSV_DECODER)   +=
> qsvdec_other.o
>  OBJS-$(CONFIG_MPEG2_QSV_ENCODER)   += qsvenc_mpeg2.o
>  OBJS-$(CONFIG_MPEG2VIDEO_DECODER)  += mpeg12dec.o mpeg12.o
> mpeg12data.o
>  OBJS-$(CONFIG_MPEG2VIDEO_ENCODER)  += mpeg12enc.o mpeg12.o
> +OBJS-$(CONFIG_MPEG2_MEDIACODEC_DECODER) += mediacodecdec.o
>  OBJS-$(CONFIG_MPEG2_VAAPI_ENCODER) += vaapi_encode_mpeg2.o
>  OBJS-$(CONFIG_MPEG4_DECODER)   += xvididct.o
>  OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 89fadcd2fa..4373ebd975 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -96,6 +96,7 @@ static void register_all(void)
>  REGISTER_HWACCEL(MPEG2_VAAPI,   mpeg2_vaapi);
>  REGISTER_HWACCEL(MPEG2_VDPAU,   mpeg2_vdpau);
>  REGISTER_HWACCEL(MPEG2_VIDEOTOOLBOX, mpeg2_videotoolbox);
> +REGISTER_HWACCEL(MPEG2_MEDIACODEC,  mpeg2_mediacodec);
>  REGISTER_HWACCEL(MPEG4_CUVID,   mpeg4_cuvid);
>  REGISTER_HWACCEL(MPEG4_MEDIACODEC,  mpeg4_mediacodec);
>  REGISTER_HWACCEL(MPEG4_MMAL,mpeg4_mmal);
> @@ -257,6 +258,7 @@ static void register_all(void)
>  REGISTER_DECODER(MPEG2_MMAL,mpeg2_mmal);
>  REGISTER_DECODER(MPEG2_CRYSTALHD,   mpeg2_crystalhd);
>  REGISTER_DECODER(MPEG2_QSV, mpeg2_qsv);
> +REGISTER_DECODER(MPEG2_MEDIACODEC,  mpeg2_mediacodec);
>  REGISTER_DECODER(MSA1,  msa1);
>  REGISTER_DECODER(MSCC,  mscc);
>  REGISTER_DECODER(MSMPEG4V1, msmpeg4v1);
> diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
> index ccfcb4b9ce..2c9bb033e2 100644
> --- a/libavcodec/mediacodecdec.c
> +++ b/libavcodec/mediacodecdec.c
> @@ -1,5 +1,5 @@
>  /*
> - * Android MediaCodec H.264 / H.265 / MPEG-4 / VP8 / VP9 decoders
> + * Android MediaCodec MPEG-2 / H.264 / H.265 / MPEG-4 / VP8 / VP9 decoders
>   *
>   * Copyright (c) 2015-2016 Matthieu Bouron  >
>   *
> @@ -333,6 +333,11 @@ static av_cold int mediacodec_decode_init(AVCodecContext
> *avctx)
>  goto done;
>  break;
>  #endif
> +#if CONFIG_MPEG2_MEDIACODEC_DECODER
> +case AV_CODEC_ID_MPEG2VIDEO:
> +codec_mime = "video/mpeg2";
>

It seems we need to pass more information into the decoder, like the other
codecs do, using csd-0. Currently, I'm receiving the following error trying
to decode mpeg2:

  E/ACodec: [OMX.MTK.VIDEO.DECODER.MPEG2] ERROR(0x80001005)

According to
https://stackoverflow.com/questions/23687232/android-mediacodec-usage-for-decoding-mpeg2-video-stream/23698038
we need to pass in the sequence header and sequence header extension,
however I'm not sure how to pull this out of the avctx.


> +break;
> +#endif
>  #if CONFIG_MPEG4_MEDIACODEC_DECODER
>  case AV_CODEC_ID_MPEG4:
>  codec_mime = "video/mp4v-es",
> @@ -575,6 +580,22 @@ AVCodec ff_hevc_mediacodec_decoder = {
>  };
>  #endif
>
> +#if CONFIG_MPEG2_MEDIACODEC_DECODER
> +AVCodec ff_mpeg2_mediacodec_decoder = {
> +.name   = "mpeg2_mediacodec",
> +.long_name  = NULL_IF_CONFIG_SMALL("MPEG-2 Android MediaCodec
> decoder"),
> +.type   = AVMEDIA_TYPE_VIDEO,
> +.id = AV_CODEC_ID_MPEG2VIDEO,
> +.priv_data_size = sizeof(MediaCodecH264DecContext),
> +.init   = mediacodec_decode_init,
> +.decode = mediacodec_decode_frame,
> +.flush  = mediacodec_decode_flush,
> +.close  = mediacodec_decode_close,
> 

Re: [FFmpeg-devel] [PATCH] Add spherical_mapping command-line argument to ffmpeg.

2017-06-05 Thread Aaron Colwell
Attached a new patch that fixes a bug and the indentation in the previous
patch. This should be good now. Sorry for the spam.

Aaron

On Mon, Jun 5, 2017 at 12:32 PM Aaron Colwell  wrote:

> Comments below..
>
> On Mon, Jun 5, 2017 at 12:02 PM Vittorio Giovara <
> vittorio.giov...@gmail.com> wrote:
>
>> Hey Aaron
>> > This allows adding AVSphericalMapping information to files
>> > that don't already have it.
>> > ---
>> >  ffmpeg.h  |   3 ++
>> >  ffmpeg_opt.c  |  29 -
>> >  libavutil/spherical.c | 113
>> ++
>> >  libavutil/spherical.h |  14 +++
>> >  4 files changed, 158 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/ffmpeg.h b/ffmpeg.h
>> > index a806445e0d..43a28d874f 100644
>> > --- a/ffmpeg.h
>> > +++ b/ffmpeg.h
>> > @@ -44,6 +44,7 @@
>> >  #include "libavutil/fifo.h"
>> >  #include "libavutil/pixfmt.h"
>> >  #include "libavutil/rational.h"
>> > +#include "libavutil/spherical.h"
>> >  #include "libavutil/threadmessage.h"
>> >
>> >  #include "libswresample/swresample.h"
>> > @@ -228,6 +229,8 @@ typedef struct OptionsContext {
>> >  intnb_time_bases;
>> >  SpecifierOpt *enc_time_bases;
>> >  intnb_enc_time_bases;
>> > +SpecifierOpt *spherical_mappings;
>> > +intnb_spherical_mappings;
>> >  } OptionsContext;
>> >
>> >  typedef struct InputFilter {
>> > diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
>> > index c997ea8faf..666b3791b7 100644
>> > --- a/ffmpeg_opt.c
>> > +++ b/ffmpeg_opt.c
>> > @@ -1514,12 +1514,29 @@ static void
>> check_streamcopy_filters(OptionsContext *o, AVFormatContext *oc,
>> >  }
>> >  }
>> >
>> > +static int set_spherical_mapping(const char* opt, AVStream* st) {
>> > +  size_t spherical_mapping_size = 0;
>> > +  AVSphericalMapping *spherical_mapping = NULL;
>> > +
>> > +  int ret = av_spherical_parse_option(opt, &spherical_mapping,
>> > +  &spherical_mapping_size);
>> > +  if (ret >= 0) {
>> > +ret = av_stream_add_side_data(st, AV_PKT_DATA_SPHERICAL,
>> spherical_mapping, spherical_mapping_size);
>> > +
>> > +if (ret < 0) {
>> > +  av_freep(&spherical_mapping);
>> > +}
>> > +  }
>> > +
>> > +  return ret;
>> > +}
>> > +
>> >  static OutputStream *new_video_stream(OptionsContext *o,
>> AVFormatContext *oc, int source_index)
>> >  {
>> >  AVStream *st;
>> >  OutputStream *ost;
>> >  AVCodecContext *video_enc;
>> > -char *frame_rate = NULL, *frame_aspect_ratio = NULL;
>> > +char *frame_rate = NULL, *frame_aspect_ratio = NULL,
>> *spherical_mapping = NULL;
>> >
>> >  ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO, source_index);
>> >  st  = ost->st;
>> > @@ -1546,6 +1563,12 @@ static OutputStream
>> *new_video_stream(OptionsContext *o, AVFormatContext *oc, in
>> >
>> >  MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc,
>> st);
>> >  MATCH_PER_STREAM_OPT(filters,str, ost->filters,oc,
>> st);
>> > +MATCH_PER_STREAM_OPT(spherical_mappings, str, spherical_mapping,
>> oc, st);
>> > +
>> > +if (spherical_mapping && set_spherical_mapping(spherical_mapping,
>> st) < 0) {
>> > +av_log(NULL, AV_LOG_FATAL, "Invalid spherical_mapping: %s\n",
>> spherical_mapping);
>> > +exit_program(1);
>> > +}
>> >
>> >  if (!ost->stream_copy) {
>> >  const char *p = NULL;
>> > @@ -3569,6 +3592,10 @@ const OptionDef options[] = {
>> >  "automatically insert correct rotate filters" },
>> >  { "hwaccel_lax_profile_check", OPT_BOOL | OPT_EXPERT,
>>   { &hwaccel_lax_profile_check},
>> >  "attempt to decode anyway if HW accelerated decoder's
>> supported profiles do not exactly match the stream" },
>> > +{ "spherical_mapping", OPT_VIDEO | HAS_ARG  | OPT_STRING |
>> OPT_SPEC |
>> > +   OPT_OUTPUT,
>>{ .off = OFFSET(spherical_mappings) },
>> > +"set spherical mapping for video stream", "spherical_mapping"
>> },
>> > +
>> >
>> >  /* audio options */
>> >  { "aframes",OPT_AUDIO | HAS_ARG  | OPT_PERFILE |
>> OPT_OUTPUT,   { .func_arg = opt_audio_frames },
>>
>> this part looks ok
>>
>> > diff --git a/libavutil/spherical.c b/libavutil/spherical.c
>> > index 4be55f36cf..508584d61f 100644
>> > --- a/libavutil/spherical.c
>> > +++ b/libavutil/spherical.c
>> > @@ -19,6 +19,7 @@
>> >   */
>> >
>> >  #include "mem.h"
>> > +#include "opt.h"
>> >  #include "spherical.h"
>> >
>> >  AVSphericalMapping *av_spherical_alloc(size_t *size)
>> > @@ -77,3 +78,115 @@ int av_spherical_from_name(const char *name)
>> >
>> >  return -1;
>> >  }
>> > +
>> > +static const char *spherical_mapping_context_to_name(void *ptr)
>> > +{
>> > +return "spherical_mapping";
>> > +}
>> > +
>> > +typedef struct {
>> > +const AVClass* spherical_class;
>> > +int projection;
>> > +
>> > +double yaw;
>> > +double pitch;
>> > +double roll;
>> > +
>> >

Re: [FFmpeg-devel] [PATCH] Add spherical_mapping command-line argument to ffmpeg.

2017-06-05 Thread Aaron Colwell
Comments below..

On Mon, Jun 5, 2017 at 12:02 PM Vittorio Giovara 
wrote:

> Hey Aaron
> > This allows adding AVSphericalMapping information to files
> > that don't already have it.
> > ---
> >  ffmpeg.h  |   3 ++
> >  ffmpeg_opt.c  |  29 -
> >  libavutil/spherical.c | 113
> ++
> >  libavutil/spherical.h |  14 +++
> >  4 files changed, 158 insertions(+), 1 deletion(-)
> >
> > diff --git a/ffmpeg.h b/ffmpeg.h
> > index a806445e0d..43a28d874f 100644
> > --- a/ffmpeg.h
> > +++ b/ffmpeg.h
> > @@ -44,6 +44,7 @@
> >  #include "libavutil/fifo.h"
> >  #include "libavutil/pixfmt.h"
> >  #include "libavutil/rational.h"
> > +#include "libavutil/spherical.h"
> >  #include "libavutil/threadmessage.h"
> >
> >  #include "libswresample/swresample.h"
> > @@ -228,6 +229,8 @@ typedef struct OptionsContext {
> >  intnb_time_bases;
> >  SpecifierOpt *enc_time_bases;
> >  intnb_enc_time_bases;
> > +SpecifierOpt *spherical_mappings;
> > +intnb_spherical_mappings;
> >  } OptionsContext;
> >
> >  typedef struct InputFilter {
> > diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
> > index c997ea8faf..666b3791b7 100644
> > --- a/ffmpeg_opt.c
> > +++ b/ffmpeg_opt.c
> > @@ -1514,12 +1514,29 @@ static void
> check_streamcopy_filters(OptionsContext *o, AVFormatContext *oc,
> >  }
> >  }
> >
> > +static int set_spherical_mapping(const char* opt, AVStream* st) {
> > +  size_t spherical_mapping_size = 0;
> > +  AVSphericalMapping *spherical_mapping = NULL;
> > +
> > +  int ret = av_spherical_parse_option(opt, &spherical_mapping,
> > +  &spherical_mapping_size);
> > +  if (ret >= 0) {
> > +ret = av_stream_add_side_data(st, AV_PKT_DATA_SPHERICAL,
> spherical_mapping, spherical_mapping_size);
> > +
> > +if (ret < 0) {
> > +  av_freep(&spherical_mapping);
> > +}
> > +  }
> > +
> > +  return ret;
> > +}
> > +
> >  static OutputStream *new_video_stream(OptionsContext *o,
> AVFormatContext *oc, int source_index)
> >  {
> >  AVStream *st;
> >  OutputStream *ost;
> >  AVCodecContext *video_enc;
> > -char *frame_rate = NULL, *frame_aspect_ratio = NULL;
> > +char *frame_rate = NULL, *frame_aspect_ratio = NULL,
> *spherical_mapping = NULL;
> >
> >  ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO, source_index);
> >  st  = ost->st;
> > @@ -1546,6 +1563,12 @@ static OutputStream
> *new_video_stream(OptionsContext *o, AVFormatContext *oc, in
> >
> >  MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc,
> st);
> >  MATCH_PER_STREAM_OPT(filters,str, ost->filters,oc,
> st);
> > +MATCH_PER_STREAM_OPT(spherical_mappings, str, spherical_mapping,
> oc, st);
> > +
> > +if (spherical_mapping && set_spherical_mapping(spherical_mapping,
> st) < 0) {
> > +av_log(NULL, AV_LOG_FATAL, "Invalid spherical_mapping: %s\n",
> spherical_mapping);
> > +exit_program(1);
> > +}
> >
> >  if (!ost->stream_copy) {
> >  const char *p = NULL;
> > @@ -3569,6 +3592,10 @@ const OptionDef options[] = {
> >  "automatically insert correct rotate filters" },
> >  { "hwaccel_lax_profile_check", OPT_BOOL | OPT_EXPERT,
>   { &hwaccel_lax_profile_check},
> >  "attempt to decode anyway if HW accelerated decoder's supported
> profiles do not exactly match the stream" },
> > +{ "spherical_mapping", OPT_VIDEO | HAS_ARG  | OPT_STRING | OPT_SPEC
> |
> > +   OPT_OUTPUT,
>  { .off = OFFSET(spherical_mappings) },
> > +"set spherical mapping for video stream", "spherical_mapping" },
> > +
> >
> >  /* audio options */
> >  { "aframes",OPT_AUDIO | HAS_ARG  | OPT_PERFILE |
> OPT_OUTPUT,   { .func_arg = opt_audio_frames },
>
> this part looks ok
>
> > diff --git a/libavutil/spherical.c b/libavutil/spherical.c
> > index 4be55f36cf..508584d61f 100644
> > --- a/libavutil/spherical.c
> > +++ b/libavutil/spherical.c
> > @@ -19,6 +19,7 @@
> >   */
> >
> >  #include "mem.h"
> > +#include "opt.h"
> >  #include "spherical.h"
> >
> >  AVSphericalMapping *av_spherical_alloc(size_t *size)
> > @@ -77,3 +78,115 @@ int av_spherical_from_name(const char *name)
> >
> >  return -1;
> >  }
> > +
> > +static const char *spherical_mapping_context_to_name(void *ptr)
> > +{
> > +return "spherical_mapping";
> > +}
> > +
> > +typedef struct {
> > +const AVClass* spherical_class;
> > +int projection;
> > +
> > +double yaw;
> > +double pitch;
> > +double roll;
> > +
> > +int64_t bound_left;
> > +int64_t bound_top;
> > +int64_t bound_right;
> > +int64_t bound_bottom;
> > +
> > +int64_t padding;
> > +} SphericalMappingContext;
> > +
> > +#define OFFSET(x) offsetof(SphericalMappingContext, x)
> > +#define DEFAULT 0
> > +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
> > +
> > +static const AVOption spherical_mapping_options[]

[FFmpeg-devel] [PATCH] libavformat/cache: don't treat 0 as EOF

2017-06-05 Thread Daniel Kucera
Signed-off-by: Daniel Kucera 
---
 libavformat/cache.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/cache.c b/libavformat/cache.c
index 6aabca2e78..66bbbf54c9 100644
--- a/libavformat/cache.c
+++ b/libavformat/cache.c
@@ -201,7 +201,7 @@ static int cache_read(URLContext *h, unsigned char *buf, 
int size)
 }
 
 r = ffurl_read(c->inner, buf, size);
-if (r == 0 && size>0) {
+if (r == AVERROR_EOF && size>0) {
 c->is_true_eof = 1;
 av_assert0(c->end >= c->logical_pos);
 }
@@ -263,7 +263,7 @@ resolve_eof:
 if (whence == SEEK_SET)
 size = FFMIN(sizeof(tmp), pos - c->logical_pos);
 ret = cache_read(h, tmp, size);
-if (ret == 0 && whence == SEEK_END) {
+if (ret == AVERROR_EOF && whence == SEEK_END) {
 av_assert0(c->is_true_eof);
 goto resolve_eof;
 }
-- 
2.11.0

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


Re: [FFmpeg-devel] [PATCH] Add spherical_mapping command-line argument to ffmpeg.

2017-06-05 Thread Vittorio Giovara
Hey Aaron
> This allows adding AVSphericalMapping information to files
> that don't already have it.
> ---
>  ffmpeg.h  |   3 ++
>  ffmpeg_opt.c  |  29 -
>  libavutil/spherical.c | 113 
> ++
>  libavutil/spherical.h |  14 +++
>  4 files changed, 158 insertions(+), 1 deletion(-)
>
> diff --git a/ffmpeg.h b/ffmpeg.h
> index a806445e0d..43a28d874f 100644
> --- a/ffmpeg.h
> +++ b/ffmpeg.h
> @@ -44,6 +44,7 @@
>  #include "libavutil/fifo.h"
>  #include "libavutil/pixfmt.h"
>  #include "libavutil/rational.h"
> +#include "libavutil/spherical.h"
>  #include "libavutil/threadmessage.h"
>
>  #include "libswresample/swresample.h"
> @@ -228,6 +229,8 @@ typedef struct OptionsContext {
>  intnb_time_bases;
>  SpecifierOpt *enc_time_bases;
>  intnb_enc_time_bases;
> +SpecifierOpt *spherical_mappings;
> +intnb_spherical_mappings;
>  } OptionsContext;
>
>  typedef struct InputFilter {
> diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
> index c997ea8faf..666b3791b7 100644
> --- a/ffmpeg_opt.c
> +++ b/ffmpeg_opt.c
> @@ -1514,12 +1514,29 @@ static void check_streamcopy_filters(OptionsContext 
> *o, AVFormatContext *oc,
>  }
>  }
>
> +static int set_spherical_mapping(const char* opt, AVStream* st) {
> +  size_t spherical_mapping_size = 0;
> +  AVSphericalMapping *spherical_mapping = NULL;
> +
> +  int ret = av_spherical_parse_option(opt, &spherical_mapping,
> +  &spherical_mapping_size);
> +  if (ret >= 0) {
> +ret = av_stream_add_side_data(st, AV_PKT_DATA_SPHERICAL, 
> spherical_mapping, spherical_mapping_size);
> +
> +if (ret < 0) {
> +  av_freep(&spherical_mapping);
> +}
> +  }
> +
> +  return ret;
> +}
> +
>  static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext 
> *oc, int source_index)
>  {
>  AVStream *st;
>  OutputStream *ost;
>  AVCodecContext *video_enc;
> -char *frame_rate = NULL, *frame_aspect_ratio = NULL;
> +char *frame_rate = NULL, *frame_aspect_ratio = NULL, *spherical_mapping 
> = NULL;
>
>  ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO, source_index);
>  st  = ost->st;
> @@ -1546,6 +1563,12 @@ static OutputStream *new_video_stream(OptionsContext 
> *o, AVFormatContext *oc, in
>
>  MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st);
>  MATCH_PER_STREAM_OPT(filters,str, ost->filters,oc, st);
> +MATCH_PER_STREAM_OPT(spherical_mappings, str, spherical_mapping, oc, st);
> +
> +if (spherical_mapping && set_spherical_mapping(spherical_mapping, st) < 
> 0) {
> +av_log(NULL, AV_LOG_FATAL, "Invalid spherical_mapping: %s\n", 
> spherical_mapping);
> +exit_program(1);
> +}
>
>  if (!ost->stream_copy) {
>  const char *p = NULL;
> @@ -3569,6 +3592,10 @@ const OptionDef options[] = {
>  "automatically insert correct rotate filters" },
>  { "hwaccel_lax_profile_check", OPT_BOOL | OPT_EXPERT,
> { &hwaccel_lax_profile_check},
>  "attempt to decode anyway if HW accelerated decoder's supported 
> profiles do not exactly match the stream" },
> +{ "spherical_mapping", OPT_VIDEO | HAS_ARG  | OPT_STRING | OPT_SPEC |
> +   OPT_OUTPUT,   
> { .off = OFFSET(spherical_mappings) },
> +"set spherical mapping for video stream", "spherical_mapping" },
> +
>
>  /* audio options */
>  { "aframes",OPT_AUDIO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT, 
>   { .func_arg = opt_audio_frames },

this part looks ok

> diff --git a/libavutil/spherical.c b/libavutil/spherical.c
> index 4be55f36cf..508584d61f 100644
> --- a/libavutil/spherical.c
> +++ b/libavutil/spherical.c
> @@ -19,6 +19,7 @@
>   */
>
>  #include "mem.h"
> +#include "opt.h"
>  #include "spherical.h"
>
>  AVSphericalMapping *av_spherical_alloc(size_t *size)
> @@ -77,3 +78,115 @@ int av_spherical_from_name(const char *name)
>
>  return -1;
>  }
> +
> +static const char *spherical_mapping_context_to_name(void *ptr)
> +{
> +return "spherical_mapping";
> +}
> +
> +typedef struct {
> +const AVClass* spherical_class;
> +int projection;
> +
> +double yaw;
> +double pitch;
> +double roll;
> +
> +int64_t bound_left;
> +int64_t bound_top;
> +int64_t bound_right;
> +int64_t bound_bottom;
> +
> +int64_t padding;
> +} SphericalMappingContext;
> +
> +#define OFFSET(x) offsetof(SphericalMappingContext, x)
> +#define DEFAULT 0
> +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
> +
> +static const AVOption spherical_mapping_options[] = {
> +{ "projection", "projection", OFFSET(projection), AV_OPT_TYPE_INT,
> +{ .i64 = -1 }, -1, AV_SPHERICAL_EQUIRECTANGULAR_TILE, FLAGS, 
> "projection" },
> +{ "equirectangular", "equirectangular projection", OFFSET(projection), 
> AV_OPT_TYPE_CONST,
> +{ .i64 = AV_SPH

[FFmpeg-devel] [PATCH] libavformat/avio: fix retry_transfer_wrapper return value on error

2017-06-05 Thread Daniel Kucera
Signed-off-by: Daniel Kucera 
---
 libavformat/avio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 1e79c9dd5c..909cad564f 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -394,7 +394,7 @@ static inline int retry_transfer_wrapper(URLContext *h, 
uint8_t *buf,
 av_usleep(1000);
 }
 } else if (ret < 1)
-return (ret < 0 && ret != AVERROR_EOF) ? ret : len;
+return ret;
 if (ret) {
 fast_retries = FFMAX(fast_retries, 2);
 wait_since = 0;
-- 
2.11.0

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


[FFmpeg-devel] [PATCH] libavformat/file: return AVERROR_EOF on EOF

2017-06-05 Thread Daniel Kucera
Signed-off-by: Daniel Kucera 
---
 libavformat/file.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/file.c b/libavformat/file.c
index 264542a36a..1fb83851c0 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -112,6 +112,8 @@ static int file_read(URLContext *h, unsigned char *buf, int 
size)
 ret = read(c->fd, buf, size);
 if (ret == 0 && c->follow)
 return AVERROR(EAGAIN);
+if (ret == 0)
+return AVERROR_EOF; 
 return (ret == -1) ? AVERROR(errno) : ret;
 }
 
-- 
2.11.0

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


[FFmpeg-devel] [PATCH] libavformat/subfile: return AVERROR_EOF on EOF

2017-06-05 Thread Daniel Kucera
Signed-off-by: Daniel Kucera 
---
 libavformat/subfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/subfile.c b/libavformat/subfile.c
index fa971e1902..497cf85211 100644
--- a/libavformat/subfile.c
+++ b/libavformat/subfile.c
@@ -102,7 +102,7 @@ static int subfile_read(URLContext *h, unsigned char *buf, 
int size)
 int ret;
 
 if (rest <= 0)
-return 0;
+return AVERROR_EOF;
 size = FFMIN(size, rest);
 ret = ffurl_read(c->h, buf, size);
 if (ret >= 0)
-- 
2.11.0

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


[FFmpeg-devel] [PATCH] libavformat/wtvdec: return AVERROR_EOF on EOF

2017-06-05 Thread Daniel Kucera
Signed-off-by: Daniel Kucera 
---
 libavformat/wtvdec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index 3ac4501306..ee19fd84da 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -65,7 +65,7 @@ static int64_t seek_by_sector(AVIOContext *pb, int64_t 
sector, int64_t offset)
 }
 
 /**
- * @return bytes read, 0 on end of file, or <0 on error
+ * @return bytes read, AVERROR_EOF on end of file, or <0 on error
  */
 static int wtvfile_read_packet(void *opaque, uint8_t *buf, int buf_size)
 {
@@ -76,7 +76,7 @@ static int wtvfile_read_packet(void *opaque, uint8_t *buf, 
int buf_size)
 if (wf->error || pb->error)
 return -1;
 if (wf->position >= wf->length || avio_feof(pb))
-return 0;
+return AVERROR_EOF;
 
 buf_size = FFMIN(buf_size, wf->length - wf->position);
 while(nread < buf_size) {
-- 
2.11.0

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


[FFmpeg-devel] [PATCH] libavformat/wtvdec: return AVERROR_EOF on EOF

2017-06-05 Thread Daniel Kucera
---
 libavformat/wtvdec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index 3ac4501306..ee19fd84da 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -65,7 +65,7 @@ static int64_t seek_by_sector(AVIOContext *pb, int64_t 
sector, int64_t offset)
 }
 
 /**
- * @return bytes read, 0 on end of file, or <0 on error
+ * @return bytes read, AVERROR_EOF on end of file, or <0 on error
  */
 static int wtvfile_read_packet(void *opaque, uint8_t *buf, int buf_size)
 {
@@ -76,7 +76,7 @@ static int wtvfile_read_packet(void *opaque, uint8_t *buf, 
int buf_size)
 if (wf->error || pb->error)
 return -1;
 if (wf->position >= wf->length || avio_feof(pb))
-return 0;
+return AVERROR_EOF;
 
 buf_size = FFMIN(buf_size, wf->length - wf->position);
 while(nread < buf_size) {
-- 
2.11.0

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


Re: [FFmpeg-devel] [PATCH] libavcodec/vp9: ipred_dl_32x32_16 avx2 implementation

2017-06-05 Thread James Almer
On 6/4/2017 2:52 PM, Ilia Valiakhmetov wrote:
> vp9_diag_downleft_32x32_8bpp_c: 580.2
> vp9_diag_downleft_32x32_8bpp_sse2: 75.6
> vp9_diag_downleft_32x32_8bpp_ssse3: 73.7
> vp9_diag_downleft_32x32_8bpp_avx: 72.7
> vp9_diag_downleft_32x32_10bpp_c: 1101.2
> vp9_diag_downleft_32x32_10bpp_sse2: 145.4
> vp9_diag_downleft_32x32_10bpp_ssse3: 137.5
> vp9_diag_downleft_32x32_10bpp_avx: 134.8
> vp9_diag_downleft_32x32_10bpp_avx2: 94.0
> vp9_diag_downleft_32x32_12bpp_c: 1108.5
> vp9_diag_downleft_32x32_12bpp_sse2: 145.5
> vp9_diag_downleft_32x32_12bpp_ssse3: 137.3
> vp9_diag_downleft_32x32_12bpp_avx: 135.2
> vp9_diag_downleft_32x32_12bpp_avx2: 94.0
> 
> ~30% faster than avx implementation

Nice.

> 
> ---
>  libavcodec/x86/vp9dsp_init_16bpp.c|  2 ++
>  libavcodec/x86/vp9intrapred_16bpp.asm | 63 
> +++
>  2 files changed, 65 insertions(+)
> 
> diff --git a/libavcodec/x86/vp9dsp_init_16bpp.c 
> b/libavcodec/x86/vp9dsp_init_16bpp.c
> index 4576ff1..d1b8fcd 100644
> --- a/libavcodec/x86/vp9dsp_init_16bpp.c
> +++ b/libavcodec/x86/vp9dsp_init_16bpp.c
> @@ -52,6 +52,7 @@ decl_ipred_fns(dc,  16, mmxext, sse2);
>  decl_ipred_fns(dc_top,  16, mmxext, sse2);
>  decl_ipred_fns(dc_left, 16, mmxext, sse2);
>  decl_ipred_fn(dl,   16, 16, avx2);
> +decl_ipred_fn(dl,   32, 16, avx2);
>  
>  #define decl_ipred_dir_funcs(type) \
>  decl_ipred_fns(type, 16, sse2,  sse2); \
> @@ -135,6 +136,7 @@ av_cold void ff_vp9dsp_init_16bpp_x86(VP9DSPContext *dsp)
>  init_fpel_func(1, 1,  64, avg, _16, avx2);
>  init_fpel_func(0, 1, 128, avg, _16, avx2);
>  init_ipred_func(dl, DIAG_DOWN_LEFT, 16, 16, avx2);
> +init_ipred_func(dl, DIAG_DOWN_LEFT, 32, 16, avx2);
>  }
>  
>  #endif /* HAVE_YASM */
> diff --git a/libavcodec/x86/vp9intrapred_16bpp.asm 
> b/libavcodec/x86/vp9intrapred_16bpp.asm
> index 212e413..5cd6a3e 100644
> --- a/libavcodec/x86/vp9intrapred_16bpp.asm
> +++ b/libavcodec/x86/vp9intrapred_16bpp.asm
> @@ -861,6 +861,7 @@ cglobal vp9_ipred_dl_16x16_16, 2, 4, 5, dst, stride, l, a
>  DEFINE_ARGS dst, stride, stride3, cnt
>  mov   cntd, 2
>  lea   stride3q, [strideq*3]
> +

Trailing whitespaces.

>  .loop:
>  mova  [dstq+strideq*0], m0
>  vpalignrm3, m2, m0, 2
> @@ -884,6 +885,68 @@ cglobal vp9_ipred_dl_16x16_16, 2, 4, 5, dst, stride, l, a
>  dec   cntd
>  jg .loop
>  RET
> +

Same.

> +cglobal vp9_ipred_dl_32x32_16, 2, 6, 7, dst, stride, l, a
> +movifnidn   aq, amp
> +movam0, [aq+mmsize*0+ 0]   ; abcdefghijklmnop
> +movam1, [aq+mmsize*1+ 0]   ; qrstuvwxyz012345
> +vpbroadcastw   xm4, [aq+mmsize*1+30]   ; 
> +vperm2i128  m5, m0, m1, q0201  ; ijklmnopqrstuvwx
> +vpalignrm2, m5, m0, 2  ; bcdefghijklmnopq
> +vpalignrm3, m5, m0, 4  ; cdefghijklmnopqr
> +LOWPASS  0,  2,  3 ; BCDEFGHIJKLMNOPQ
> +vperm2i128  m5, m1, m4, q0201  ; yz012345
> +vpalignrm2, m5, m1, 2  ; rstuvwxyz0123455
> +vpalignrm3, m5, m1, 4  ; stuvwxyz01234555
> +LOWPASS  1,  2,  3 ; RSTUVWXYZ..5
> +vperm2i128  m2, m1, m4, q0201  ; Z..5
> +vperm2i128  m5, m0, m1, q0201  ; JKLMNOPQRSTUVWXY
> +DEFINE_ARGS dst, stride, stride3, cnt
> +lea   stride3q, [strideq*3]
> +mov   cntd, 4
> +

Same.

Ronald can fix them before pushing (I think the git hooks would prevent
him to push this with them anyway), so no need to resend a fixed patch.
Just keep it in mind for future patchsets. Same with tabs on files other
than Makefile stuff.

> +.loop:
> +mova   [dstq+strideq*0 + 0], m0
> +mova   [dstq+strideq*0 +32], m1
> +vpalignr m3, m5, m0, 2
> +vpalignr m4, m2, m1, 2
> +mova   [dstq+strideq*1 + 0], m3
> +mova   [dstq+strideq*1 +32], m4
> +vpalignr m3, m5, m0, 4
> +vpalignr m4, m2, m1, 4
> +mova   [dstq+strideq*2 + 0], m3
> +mova   [dstq+strideq*2 +32], m4
> +vpalignr m3, m5, m0, 6
> +vpalignr m4, m2, m1, 6
> +mova   [dstq+stride3q*1+ 0], m3
> +mova   [dstq+stride3q*1+32], m4
> +leadstq, [dstq+strideq*4]
> +vpalignr m3, m5, m0, 8
> +vpalignr m4, m2, m1, 8
> +mova   [dstq+strideq*0 + 0], m3
> +mova   [dstq+strideq*0 +32], m4
> +vpalignr m3, m5, m0, 10
> +vpalignr m4, m2, m1, 10
> +mova   [dstq+strideq*1 + 0], m3
> +mova   [dstq+strideq*1 +32], m4
> +vpalignr m3, m5, m0, 1

[FFmpeg-devel] [PATCH v2] lavc: add mpeg2 decoder/hwaccel to mediacodec

2017-06-05 Thread Aman Gupta
From: Aman Gupta 

Android TV and FireOS hardware supports mpeg2 hardware decoding via MediaCodec.
---
 configure |  2 ++
 libavcodec/Makefile   |  1 +
 libavcodec/allcodecs.c|  2 ++
 libavcodec/mediacodecdec.c| 23 ++-
 libavcodec/mediacodecdec_common.c |  7 +++
 5 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 72060ef0e9..5816de2398 100755
--- a/configure
+++ b/configure
@@ -2656,6 +2656,7 @@ mpeg2_d3d11va_hwaccel_deps="d3d11va"
 mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
 mpeg2_dxva2_hwaccel_deps="dxva2"
 mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
+mpeg2_mediacodec_hwaccel_deps="mediacodec"
 mpeg2_mmal_hwaccel_deps="mmal"
 mpeg2_qsv_hwaccel_deps="libmfx"
 mpeg2_qsv_hwaccel_select="qsvdec_mpeg2"
@@ -2762,6 +2763,7 @@ mpeg1_vdpau_decoder_select="mpeg1video_decoder"
 mpeg2_crystalhd_decoder_select="crystalhd"
 mpeg2_cuvid_decoder_deps="cuda cuvid"
 mpeg2_mmal_decoder_deps="mmal"
+mpeg2_mediacodec_decoder_deps="mediacodec"
 mpeg2_qsv_decoder_deps="libmfx"
 mpeg2_qsv_decoder_select="qsvdec mpeg2_qsv_hwaccel"
 mpeg2_qsv_encoder_deps="libmfx"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 0818950ad9..a752f87ef5 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -423,6 +423,7 @@ OBJS-$(CONFIG_MPEG2_QSV_DECODER)   += qsvdec_other.o
 OBJS-$(CONFIG_MPEG2_QSV_ENCODER)   += qsvenc_mpeg2.o
 OBJS-$(CONFIG_MPEG2VIDEO_DECODER)  += mpeg12dec.o mpeg12.o mpeg12data.o
 OBJS-$(CONFIG_MPEG2VIDEO_ENCODER)  += mpeg12enc.o mpeg12.o
+OBJS-$(CONFIG_MPEG2_MEDIACODEC_DECODER) += mediacodecdec.o
 OBJS-$(CONFIG_MPEG2_VAAPI_ENCODER) += vaapi_encode_mpeg2.o
 OBJS-$(CONFIG_MPEG4_DECODER)   += xvididct.o
 OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 89fadcd2fa..4373ebd975 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -96,6 +96,7 @@ static void register_all(void)
 REGISTER_HWACCEL(MPEG2_VAAPI,   mpeg2_vaapi);
 REGISTER_HWACCEL(MPEG2_VDPAU,   mpeg2_vdpau);
 REGISTER_HWACCEL(MPEG2_VIDEOTOOLBOX, mpeg2_videotoolbox);
+REGISTER_HWACCEL(MPEG2_MEDIACODEC,  mpeg2_mediacodec);
 REGISTER_HWACCEL(MPEG4_CUVID,   mpeg4_cuvid);
 REGISTER_HWACCEL(MPEG4_MEDIACODEC,  mpeg4_mediacodec);
 REGISTER_HWACCEL(MPEG4_MMAL,mpeg4_mmal);
@@ -257,6 +258,7 @@ static void register_all(void)
 REGISTER_DECODER(MPEG2_MMAL,mpeg2_mmal);
 REGISTER_DECODER(MPEG2_CRYSTALHD,   mpeg2_crystalhd);
 REGISTER_DECODER(MPEG2_QSV, mpeg2_qsv);
+REGISTER_DECODER(MPEG2_MEDIACODEC,  mpeg2_mediacodec);
 REGISTER_DECODER(MSA1,  msa1);
 REGISTER_DECODER(MSCC,  mscc);
 REGISTER_DECODER(MSMPEG4V1, msmpeg4v1);
diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index ccfcb4b9ce..2c9bb033e2 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -1,5 +1,5 @@
 /*
- * Android MediaCodec H.264 / H.265 / MPEG-4 / VP8 / VP9 decoders
+ * Android MediaCodec MPEG-2 / H.264 / H.265 / MPEG-4 / VP8 / VP9 decoders
  *
  * Copyright (c) 2015-2016 Matthieu Bouron 
  *
@@ -333,6 +333,11 @@ static av_cold int mediacodec_decode_init(AVCodecContext 
*avctx)
 goto done;
 break;
 #endif
+#if CONFIG_MPEG2_MEDIACODEC_DECODER
+case AV_CODEC_ID_MPEG2VIDEO:
+codec_mime = "video/mpeg2";
+break;
+#endif
 #if CONFIG_MPEG4_MEDIACODEC_DECODER
 case AV_CODEC_ID_MPEG4:
 codec_mime = "video/mp4v-es",
@@ -575,6 +580,22 @@ AVCodec ff_hevc_mediacodec_decoder = {
 };
 #endif
 
+#if CONFIG_MPEG2_MEDIACODEC_DECODER
+AVCodec ff_mpeg2_mediacodec_decoder = {
+.name   = "mpeg2_mediacodec",
+.long_name  = NULL_IF_CONFIG_SMALL("MPEG-2 Android MediaCodec 
decoder"),
+.type   = AVMEDIA_TYPE_VIDEO,
+.id = AV_CODEC_ID_MPEG2VIDEO,
+.priv_data_size = sizeof(MediaCodecH264DecContext),
+.init   = mediacodec_decode_init,
+.decode = mediacodec_decode_frame,
+.flush  = mediacodec_decode_flush,
+.close  = mediacodec_decode_close,
+.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING,
+.caps_internal  = FF_CODEC_CAP_SETS_PKT_DTS,
+};
+#endif
+
 #if CONFIG_MPEG4_MEDIACODEC_DECODER
 AVCodec ff_mpeg4_mediacodec_decoder = {
 .name   = "mpeg4_mediacodec",
diff --git a/libavcodec/mediacodecdec_common.c 
b/libavcodec/mediacodecdec_common.c
index 2ec25c581d..1263188d34 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -766,6 +766,13 @@ AVHWAccel ff_hevc_mediacodec_hwaccel = {
 .pix_fmt = AV_PIX_FMT_MEDIACODEC,
 };
 
+AVHWAccel ff_mpeg2_mediacodec_hwaccel = {
+.name= "mediacodec",
+.type= AVMEDIA_TYPE_VIDEO,
+.id  = AV_CODEC_ID_MPEG2VIDEO,
+.pix_fmt = AV_PIX_FMT_MEDIACO

[FFmpeg-devel] [PATCH] Add spherical_mapping command-line argument to ffmpeg.

2017-06-05 Thread Aaron Colwell
Add spherical_mapping command-line argument to ffmpeg.

This allows adding AVSphericalMapping information to files
that don't already have it.
From eaa84a5f86d37e7de8bd0d6f72a308af57f3ef1d Mon Sep 17 00:00:00 2001
From: Aaron Colwell 
Date: Fri, 2 Jun 2017 16:11:21 -0700
Subject: [PATCH] Add spherical_mapping command-line argument to ffmpeg.

This allows adding AVSphericalMapping information to files
that don't already have it.
---
 ffmpeg.h  |   3 ++
 ffmpeg_opt.c  |  29 -
 libavutil/spherical.c | 113 ++
 libavutil/spherical.h |  14 +++
 4 files changed, 158 insertions(+), 1 deletion(-)

diff --git a/ffmpeg.h b/ffmpeg.h
index a806445e0d..43a28d874f 100644
--- a/ffmpeg.h
+++ b/ffmpeg.h
@@ -44,6 +44,7 @@
 #include "libavutil/fifo.h"
 #include "libavutil/pixfmt.h"
 #include "libavutil/rational.h"
+#include "libavutil/spherical.h"
 #include "libavutil/threadmessage.h"
 
 #include "libswresample/swresample.h"
@@ -228,6 +229,8 @@ typedef struct OptionsContext {
 intnb_time_bases;
 SpecifierOpt *enc_time_bases;
 intnb_enc_time_bases;
+SpecifierOpt *spherical_mappings;
+intnb_spherical_mappings;
 } OptionsContext;
 
 typedef struct InputFilter {
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index c997ea8faf..666b3791b7 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -1514,12 +1514,29 @@ static void check_streamcopy_filters(OptionsContext *o, AVFormatContext *oc,
 }
 }
 
+static int set_spherical_mapping(const char* opt, AVStream* st) {
+  size_t spherical_mapping_size = 0;
+  AVSphericalMapping *spherical_mapping = NULL;
+
+  int ret = av_spherical_parse_option(opt, &spherical_mapping,
+  &spherical_mapping_size);
+  if (ret >= 0) {
+ret = av_stream_add_side_data(st, AV_PKT_DATA_SPHERICAL, spherical_mapping, spherical_mapping_size);
+
+if (ret < 0) {
+  av_freep(&spherical_mapping);
+}
+  }
+
+  return ret;
+}
+
 static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, int source_index)
 {
 AVStream *st;
 OutputStream *ost;
 AVCodecContext *video_enc;
-char *frame_rate = NULL, *frame_aspect_ratio = NULL;
+char *frame_rate = NULL, *frame_aspect_ratio = NULL, *spherical_mapping = NULL;
 
 ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO, source_index);
 st  = ost->st;
@@ -1546,6 +1563,12 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in
 
 MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st);
 MATCH_PER_STREAM_OPT(filters,str, ost->filters,oc, st);
+MATCH_PER_STREAM_OPT(spherical_mappings, str, spherical_mapping, oc, st);
+
+if (spherical_mapping && set_spherical_mapping(spherical_mapping, st) < 0) {
+av_log(NULL, AV_LOG_FATAL, "Invalid spherical_mapping: %s\n", spherical_mapping);
+exit_program(1);
+}
 
 if (!ost->stream_copy) {
 const char *p = NULL;
@@ -3569,6 +3592,10 @@ const OptionDef options[] = {
 "automatically insert correct rotate filters" },
 { "hwaccel_lax_profile_check", OPT_BOOL | OPT_EXPERT,{ &hwaccel_lax_profile_check},
 "attempt to decode anyway if HW accelerated decoder's supported profiles do not exactly match the stream" },
+{ "spherical_mapping", OPT_VIDEO | HAS_ARG  | OPT_STRING | OPT_SPEC |
+   OPT_OUTPUT,   { .off = OFFSET(spherical_mappings) },
+"set spherical mapping for video stream", "spherical_mapping" },
+
 
 /* audio options */
 { "aframes",OPT_AUDIO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT,   { .func_arg = opt_audio_frames },
diff --git a/libavutil/spherical.c b/libavutil/spherical.c
index 4be55f36cf..508584d61f 100644
--- a/libavutil/spherical.c
+++ b/libavutil/spherical.c
@@ -19,6 +19,7 @@
  */
 
 #include "mem.h"
+#include "opt.h"
 #include "spherical.h"
 
 AVSphericalMapping *av_spherical_alloc(size_t *size)
@@ -77,3 +78,115 @@ int av_spherical_from_name(const char *name)
 
 return -1;
 }
+
+static const char *spherical_mapping_context_to_name(void *ptr)
+{
+return "spherical_mapping";
+}
+
+typedef struct {
+const AVClass* spherical_class;
+int projection;
+
+double yaw;
+double pitch;
+double roll;
+
+int64_t bound_left;
+int64_t bound_top;
+int64_t bound_right;
+int64_t bound_bottom;
+
+int64_t padding;
+} SphericalMappingContext;
+
+#define OFFSET(x) offsetof(SphericalMappingContext, x)
+#define DEFAULT 0
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
+
+static const AVOption spherical_mapping_options[] = {
+{ "projection", "projection", OFFSET(projection), AV_OPT_TYPE_INT,
+{ .i64 = -1 }, -1, AV_SPHERICAL_EQUIRECTANGULAR_TILE, FLAGS, "projection" },
+{ "equirectangular", "equirectangular projection", OFFSET(projection), AV_OPT_TYPE_CONST,
+  

Re: [FFmpeg-devel] [PATCH] cmdutils: add log time info into report log file

2017-06-05 Thread Nicolas George
Le quintidi 15 prairial, an CCXXV, Steven Liu a écrit :
> I get some problem of the log output:
> 
> 1. the log output by multiple av_log to one line,
>  for example:
>  av_log(NULL, "major_brand :");
>  av_log(NULL, "isom\n");
>  then if add the time to the line head, it will output looks like 
> this:
>  [1496470846077636] - major_brand :
> [1496470846077643] - isom[1496470846077650] -

Yes, you will have to come up with a solution for that. Maybe look how
the [component @ 0xaddress] prefix is added.

(But I also think we should try and get rid of these construct, make
av_log() more "send a complete message to the user" and less "print
something to the terminal", because the latter only works when there is
actually a terminal.)

>  2. but if add the time to the end of line, it maybe need control
> right alignment

Aligning to the right would be a terrible idea. And impossible on top of
that, since any later line can be longer and invalidate the alignment.

>  3. maybe the better solution is add the time into line head when
> the log level big than AV_LOG_WARNING ?

I do not think that changing the format depending on the log level is a
good idea. And it does not help anyway.

Regards,

-- 
  Nicola George


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


Re: [FFmpeg-devel] [PATCH 2/3] avcodec/utils: Fix several integer overflows.

2017-06-05 Thread Nicolas George
Le sextidi 16 prairial, an CCXXV, Ronald S. Bultje a écrit :
> This reminds me of g_return_val_if_fail in glib, and in some situations
> it's quite sensible and helpful.

I think so too.

But g_return_val_if_fail() has a flaw: it prints a warning and returns,
at least with default builds of the library. A lot of applications
developers ignore these warnings when they have no obvious adverse
drawbacks. A crash is better IMHO.

Note that I am only advocating a crash for invalid uses of the API that
are obvious and easy to check, like:

* @param foo  pointer to return value, must not be NULL

because it is easy for the application to wrap it and make the test:

int frobnicate_or_bail(type *foo) {
if (foo == NULL) {
warn("I'm afraid I can't do that");
return ERROR_INVALID;
}
return frobnicate(foo);
}

My main argument is that it is almost always unnecessary: when the
argument to a function must not be NULL, it is usually because the
natural way of calling the function yields a non-NULL pointer. For
example, in this particular case, the natural way of calling the
function is probably "ret = frobnicate(&value);".

The same goes for seek: when you call "seek(fd, pos, SEEK_SET);", you do
not need to check that SEEK_SET is a valid value: it is. I would even
argue that fd should get the same treatment, since an application doing
things on a fd without knowing if it is valid is broken and may
overwrite precious files (crashing will prevent that). On the other
hand, the application cannot easily check if fd is seekable or if pos is
valid: these conditions must cause an error return code, not a crash.

Regards,

-- 
  Nicolas George


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


[FFmpeg-devel] [PATCH] avformat/file: increase max packet size to 256k for written files

2017-06-05 Thread Marton Balint
Another huge performance improvement when using SMB/CIFS as output.

Signed-off-by: Marton Balint 
---
 libavformat/file.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavformat/file.c b/libavformat/file.c
index 264542a36a..ae7231a484 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -227,6 +227,11 @@ static int file_open(URLContext *h, const char *filename, 
int flags)
 
 h->is_streamed = !fstat(fd, &st) && S_ISFIFO(st.st_mode);
 
+/* Buffer writes more than the default 32k to improve throughput especially
+ * with networked file systems */
+if (!h->is_streamed && flags & AVIO_FLAG_WRITE)
+h->max_packet_size = 262144;
+
 return 0;
 }
 
-- 
2.12.3

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


Re: [FFmpeg-devel] [PATCH] libavformat/aviobuf.c: don't treat 0 from read_packet as EOF

2017-06-05 Thread Nicolas George
Le sextidi 16 prairial, an CCXXV, Daniel Kučera a écrit :
> Ok, I see only suggestions and ideas here. If you have any exact
> request for change in my patch, let me know.

I am not your foreman or anything like that, it is not my place to order
you around.

What I can tell you is that patches need to be good to be applied, and a
patch that makes the code more complex when it could make it simpler
cannot be considered good. Of course "when it could make it simpler" is
only speculation, but if somebody objects based on it, you will need to
convince them otherwise, and for that you will probably need to have
tried doing it that way.

Furthermore, patches that make the code simpler are more likely to get
quick reviews and eventually approval, because simpler code is also
easier to review.

And finally, I can tell you that a patch that breaks receiving empty
packets for packet protocols cannot be accepted.

> Btw, I suggest to include all these changes in one patch so there
> won't be any single commit, which would be broken.

And I strongly advise otherwise. The changes to make protocols return
AVERROR_EOF instead of 0 are good and necessary all by themselves,
individually and without the framework changes to catch the 0 return
values. I am pretty confident that they do not break anything.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH 3/3] avformat: set the default whitelist to disable hls

2017-06-05 Thread Nicolas George
Le septidi 17 prairial, an CCXXV, Michael Niedermayer a écrit :
> thats "ad hominem"

I am sorry, I did not realize it was, please forgive me and allow me to
reformulate.

The pattern is: someone is made aware of a minor security exploit in
parts of the code not their direct responsibility. Nonetheless, that
someone rushes and designs and implements a fix that only blocks that
particular exploit and its close cousins without fixing the actual
underlying security issue, and that has a lot of drawbacks on top of
that. I think I am allowed to call that a "bad fix".

We had two instances quoted in this discussion. I think there were
others (possibly not security related) but I cannot pinpoint them.

In both cases, the someone was you. This is not ad-hominem, just a fact,
and part of the pattern.

Maybe you have a tendency to behave that way, but that is not for me to
say, and it would really be ad-hominem. Let us not talk about it.

Maybe your special place in the project pushes you to doing that. I hope
you agree this is not ad-hominem. Maybe ad-positionem.

Maybe people notice it more when you are doing it.

Maybe it was just a coincidence.

Maybe a little bit of each.

Anyway, let us agree to all try and avoid that pattern and not dwell on
it.

> You dont need to convince me that the extension check or changes
> within just hls are not a complete solution. Iam quite well aware
> of this. This is intended to stop an existing exploit and variants of
> it in practice and do so quickly.

It depends on the severity of the threat. This one seems quite minor and
far-fetched, and thus I think we could take our time to fix it properly.
We all have noticed that temporary quick-and-dirty fixes usually stay
here a long time unless whoever implemented them is actively working on
a real fix.

Now, as I said, I have no special knowledge making me a good candidate
for working on a fix. I know how Perl's taint check works, but it will
not suit our needs. I know vaguely how Firefox avoids cross-site
information leak, but not in enough detail to serve as a base for a
design. I know nothing about Windows security zones.

Still, after having spent a few hours in a train without proper network
access, and with someone actually interested in listening, I could give
it some thought.

I will start by explaining why protocol_whitelist is bad.

First, it is a string. Enough with strings used as data structures! That
is inefficient, inconvenient and a maintenance nightmare since extending
or fixing the syntax will likely be considered an API break by some.

Second, the issue never was about protocols. ~/tmp/playlist.m3u8 should
not be allowed to access ../.firefox/cookies.txt (Firefox protects us
from that by adding a salt in the path, but not all sensitive files are
protected that way, this is only an illustrative example), and that
applies to local files, to SMB shares or to SFTP clients;
http://www.example.com/playlist.m3u8 should not be allowed to access
http://localhost:631/, yet they are both HTTP.

The issue is about subsets of the URL space. Files from one URL should
be allowed to access data from URLs in the same relevant subset (same
subdirectory or same web server maybe?), but not outside.

Of course, the protocol is part of the URL. But not all protocols are
like that: file://, http://, ssh:// are part of the URL, while concat:,
crypto:, subfile: are not and should be transparent for the mechanism. I
will call the formers "URL protocols" and the laters "utility
protocols".

So let us get rid of that protocol_whitelist and replace it with an
actual data structure, designed to encode a subset of the URL space. Let
us call it AVSecurityClearance, at least for the rest of this mail.

Now, there is something done right with protocol_whitelist: it is, as it
should be, a property of muxers, demuxers and protocols (and anything
else that would be allowed to access external data) and must be
inherited when a component opens another component (demuxer -> protocol,
or demuxer -> slave demuxer, or protocol -> slave protocol, etc.).
AVSecurityClearance should work the same way.

Now, how should we implement that data structure? I do not know!

Maybe we can restrict it to subsets that are a sub-hierarchy: "anything
below http://www.example.com/music/";.

But I suspect AVSecurityClearance will need to be polymorphic: the
structure of data is not necessarily the same for all protocols.

If AVSecurityClearance is polymorphic, then implementing union and
intersection operators is quite easy.

A few considerations about hierarchy. Some protocols have a host part.
The syntax of DNS domains is hierarchical from right to left, unlike the
syntax for file paths. It must be handled separately. The port part
needs a special treatment too: which ones are closer to
http://example.com/: http://www.example.com/ or
http://example.com:8080/? Or maybe they are to be considered all
separate.

Also, URLs with numerical IP addresses require a special treatme

Re: [FFmpeg-devel] [PATCH] fate: add fate-adts-id3v1-demux

2017-06-05 Thread James Almer
On 6/5/2017 11:33 AM, Hendrik Leppkes wrote:
> On Mon, Jun 5, 2017 at 4:29 PM, James Almer  wrote:
>> On 6/4/2017 8:49 PM, Michael Niedermayer wrote:
>>> On Sun, Jun 04, 2017 at 01:08:39PM -0300, James Almer wrote:
 This test the demuxer discarding non ADTS frames at the beginning and
 end of the input.

 As a side effect, this commit also enables fate-adts-demux, which was
 accidentally disabled in 324f0fbff1245f9e9e1dda29ecb03138a2de287d.

 Signed-off-by: James Almer 
 ---
 Sample is in http://0x0.st/6gI.aac
>>>
>>> uploaded, we can change it though if a smaller file is wanted before
>>> the test is pushed
>>
>> Well, i want it mainly because framecrc is much more informative and
>> clearly reflects what this patch fixed, unlike crc.
>> Since the sample i posted above is 130 frames long it would make a huge
>> framecrc ref file, so my question was if a small sample that probes with
>> a score of 1 is a good idea for the test or too fragile.
>>
> 
> If its not really a probe test, you could just set a fixed format and
> avoid any issues from that entirely.
> 
> - Hendrik

Alright, i'll do that.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] fate: add fate-adts-id3v1-demux

2017-06-05 Thread Hendrik Leppkes
On Mon, Jun 5, 2017 at 4:29 PM, James Almer  wrote:
> On 6/4/2017 8:49 PM, Michael Niedermayer wrote:
>> On Sun, Jun 04, 2017 at 01:08:39PM -0300, James Almer wrote:
>>> This test the demuxer discarding non ADTS frames at the beginning and
>>> end of the input.
>>>
>>> As a side effect, this commit also enables fate-adts-demux, which was
>>> accidentally disabled in 324f0fbff1245f9e9e1dda29ecb03138a2de287d.
>>>
>>> Signed-off-by: James Almer 
>>> ---
>>> Sample is in http://0x0.st/6gI.aac
>>
>> uploaded, we can change it though if a smaller file is wanted before
>> the test is pushed
>
> Well, i want it mainly because framecrc is much more informative and
> clearly reflects what this patch fixed, unlike crc.
> Since the sample i posted above is 130 frames long it would make a huge
> framecrc ref file, so my question was if a small sample that probes with
> a score of 1 is a good idea for the test or too fragile.
>

If its not really a probe test, you could just set a fixed format and
avoid any issues from that entirely.

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


Re: [FFmpeg-devel] [PATCH] fate: add fate-adts-id3v1-demux

2017-06-05 Thread James Almer
On 6/4/2017 8:49 PM, Michael Niedermayer wrote:
> On Sun, Jun 04, 2017 at 01:08:39PM -0300, James Almer wrote:
>> This test the demuxer discarding non ADTS frames at the beginning and
>> end of the input.
>>
>> As a side effect, this commit also enables fate-adts-demux, which was
>> accidentally disabled in 324f0fbff1245f9e9e1dda29ecb03138a2de287d.
>>
>> Signed-off-by: James Almer 
>> ---
>> Sample is in http://0x0.st/6gI.aac
> 
> uploaded, we can change it though if a smaller file is wanted before
> the test is pushed

Well, i want it mainly because framecrc is much more informative and
clearly reflects what this patch fixed, unlike crc.
Since the sample i posted above is 130 frames long it would make a huge
framecrc ref file, so my question was if a small sample that probes with
a score of 1 is a good idea for the test or too fragile.

> 
> test passes on linux x86 32/64 arm, mips and mingw32/64
> 
> thx
> 
> [...]
> 
> 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 

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


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

2017-06-05 Thread Moritz Barsnick
I can't comment on the rest (and still really like the concept), but
just this:

> +Allowed values are positive integers between @code{1} and @code{65535}.

This maximum value is no longer correct.

> +Allowed values are positive integers between @code{1} and @code{step},
> +where @code{1} corresponds to no motion blur, and @code{step}
> +corresponds to maximal motion blur.

Just wondering: Isn't this also useful for a slideshow-like
transition/fade, not just for motion blur? (I'm saying: If so, the user
needs to know.) I think I need to build and test it, to see if it fits
my needs. ;)

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


[FFmpeg-devel] opensource investigation for a new solution

2017-06-05 Thread Cristian Lorenzetto
we are thinking to develop a MediaSource(MSE technology) object for the
browsers not having it (IE , Safari).
It permits pratically to add sequential chunks to a buffer for playing a
video/audio.
For doing it we need a javascript decoder permitting to add chunks of a
file/stream and receive frames we can render with canvas at specific rate.

There are opensource projects  converted ffmpeg from c language to
javascript and used the lib for render a video passing a entire file.
No one for now was able to make the same thing for a generic stream.

We are trying to do it, but we need a support by you for understanding how
use ffmpeg for doing it.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [WIP] [PATCH 0/6] sse2/xmm version of 8-bit simple_idct

2017-06-05 Thread Ronald S. Bultje
Hi,

On Mon, Jun 5, 2017 at 7:23 AM, James Darnley  wrote:

> I forgot to mention in my cover letter that although the dct test
> passes, fate does not.  As I mentioned on IRC, changing them causes
> errors elsewhere in fate.  I am currently looking into this problem and
> I'm sure I will speak to you or others about it.


I'll have a look at this.

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


Re: [FFmpeg-devel] [PATCH] libavcodec/vp9: ipred_dl_32x32_16 avx2 implementation

2017-06-05 Thread Ronald S. Bultje
Hi,

On Sun, Jun 4, 2017 at 1:52 PM, Ilia Valiakhmetov 
wrote:

> vp9_diag_downleft_32x32_8bpp_c: 580.2
> vp9_diag_downleft_32x32_8bpp_sse2: 75.6
> vp9_diag_downleft_32x32_8bpp_ssse3: 73.7
> vp9_diag_downleft_32x32_8bpp_avx: 72.7
> vp9_diag_downleft_32x32_10bpp_c: 1101.2
> vp9_diag_downleft_32x32_10bpp_sse2: 145.4
> vp9_diag_downleft_32x32_10bpp_ssse3: 137.5
> vp9_diag_downleft_32x32_10bpp_avx: 134.8
> vp9_diag_downleft_32x32_10bpp_avx2: 94.0
> vp9_diag_downleft_32x32_12bpp_c: 1108.5
> vp9_diag_downleft_32x32_12bpp_sse2: 145.5
> vp9_diag_downleft_32x32_12bpp_ssse3: 137.3
> vp9_diag_downleft_32x32_12bpp_avx: 135.2
> vp9_diag_downleft_32x32_12bpp_avx2: 94.0
>
> ~30% faster than avx implementation
>
> ---
>  libavcodec/x86/vp9dsp_init_16bpp.c|  2 ++
>  libavcodec/x86/vp9intrapred_16bpp.asm | 63 ++
> +
>  2 files changed, 65 insertions(+)


LGTM. I'll keep for comments for another few hours before I push.

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


Re: [FFmpeg-devel] [PATCH] avformat/hls: Check local file extensions

2017-06-05 Thread Michael Niedermayer
On Mon, Jun 05, 2017 at 11:13:06AM +0200, Paul B Mahol wrote:
> On 6/5/17, Michael Niedermayer  wrote:
> > On Sat, Jun 03, 2017 at 09:20:04PM +0200, Michael Niedermayer wrote:
> >> This reduces the attack surface of local file-system
> >> information leaking.
> >>
> >> It prevents the existing exploit leading to an information leak. As
> >> well as similar hypothetical attacks.
> >>
> >> Leaks of information from files and symlinks ending in common multimedia
> >> extensions
> >> are still possible. But files with sensitive information like private keys
> >> and passwords
> >> generally do not use common multimedia filename extensions.
> >> It does not stop leaks via remote addresses in the LAN.
> >>
> >> The existing exploit depends on a specific decoder as well.
> >> It does appear though that the exploit should be possible with any
> >> decoder.
> >> The problem is that as long as sensitive information gets into the
> >> decoder,
> >> the output of the decoder becomes sensitive as well.
> >> The only obvious solution is to prevent access to sensitive information.
> >> Or to
> >> disable hls or possibly some of its feature. More complex solutions like
> >> checking the path to limit access to only subdirectories of the hls path
> >> may
> >> work as an alternative. But such solutions are fragile and tricky to
> >> implement
> >> portably and would not stop every possible attack nor would they work with
> >> all
> >> valid hls files.
> >>
> >> Developers have expressed their dislike / objected to disabling hls by
> >> default as well
> >> as disabling hls with local files. There also where objections against
> >> restricting
> >> remote url file extensions. This here is a less robust but also lower
> >> inconvenience solution.
> >> It can be applied stand alone or together with other solutions.
> >>
> >> Found-by: Emil Lerner and Pavel Cheremushkin
> >> Reported-by: Thierry Foucu 
> >>
> >> Signed-off-by: Michael Niedermayer 
> >> ---
> >>  libavformat/hls.c | 18 +-
> >>  1 file changed, 17 insertions(+), 1 deletion(-)
> >
> > Applied with the author name joke suggested by nicolas
> 
> This is joke, please revert this.

ok, done


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

Avoid a single point of failure, be that a person or equipment.


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


Re: [FFmpeg-devel] [WIP] [PATCH 0/6] sse2/xmm version of 8-bit simple_idct

2017-06-05 Thread James Darnley
To answer the couple of questions that were asked over the weekend.

Rostislav, about the performance.  I can see how to force a particular
IDCT implementation for real world decoding (the -idct option) but the
MPEG2 HD sample I've been working with mostly uses the "idct add"
function which doesn't exist for the functions in simple_idct10.asm.  So
for a next best thing, these are the results from the dct testing
utility over several runs.

> SIMPLE-C:  9124.8 ± 7.52
> SIMPLE-MMX:   11281.9 ± 32.67
> SIMPLE-SSE2:  15453.3 ± 78.86 (the adaption in the first 3 patches)
> SIMPLE8-SSE2: 15684.2 ± 7.52 (from simple_idct10.asm)
> SIMPLE8-AVX:  15398.4 ± 6.36 (simple_idct10.asm again)

I will try to get some real world results, eventually.

Ronald, yes.  I was thinking that the first 3 could be ignored if I can
get the latter patches to work correctly (pass fate that is).

I forgot to mention in my cover letter that although the dct test
passes, fate does not.  As I mentioned on IRC, changing them causes
errors elsewhere in fate.  I am currently looking into this problem and
I'm sure I will speak to you or others about it.

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


[FFmpeg-devel] [PATCH 2/2] libavfilter/scale2ref: Maintain main input's DAR

2017-06-05 Thread Kevin Mark
The scale2ref filter will now maintain the DAR of the main input and
not the DAR of the reference input. This previous behavior was deemed
counterintuitive for most (all?) use-cases.

Before:
scale2ref=iw/4:ow/mdar
in  w:320 h:240 fmt:rgb24 sar:1/1
ref w:640 h:360 fmt:rgb24 sar:1/1
out w:160 h:120 fmt:rgb24 sar:4/3 flags:0x2
SAR: ((120 * 640) / (160 * 360)) * (1 / 1) = 4 / 3
DAR: (160 / 120) * (4 / 3) = 16 / 9
(main out now same DAR as ref)

Now:
scale2ref=iw/4:ow/mdar
in  w:320 h:240 fmt:rgb24 sar:1/1
ref w:640 h:360 fmt:rgb24 sar:1/1
out w:160 h:120 fmt:rgb24 sar:1/1 flags:0x2
SAR: ((120 * 320) / (160 * 240)) * (1 / 1) = 1 / 1
DAR: (160 / 120) * (1 / 1) = 4 / 3
(main out same DAR as main in)

The scale2ref FATE test has also been updated.

Signed-off-by: Kevin Mark 
---
 libavfilter/vf_scale.c  | 6 +++---
 tests/ref/fate/filter-scale2ref_keep_aspect | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 9232bc4439..5e55f9344b 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -337,10 +337,10 @@ static int config_props(AVFilterLink *outlink)
 }
 }
 
-if (inlink->sample_aspect_ratio.num){
-outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h * 
inlink->w, outlink->w * inlink->h}, inlink->sample_aspect_ratio);
+if (inlink0->sample_aspect_ratio.num){
+outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h * 
inlink0->w, outlink->w * inlink0->h}, inlink0->sample_aspect_ratio);
 } else
-outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
+outlink->sample_aspect_ratio = inlink0->sample_aspect_ratio;
 
 if (ctx->filter == &ff_vf_scale2ref) {
 av_log(ctx, AV_LOG_VERBOSE, "in  w:%d h:%d fmt:%s sar:%d/%d\n",
diff --git a/tests/ref/fate/filter-scale2ref_keep_aspect 
b/tests/ref/fate/filter-scale2ref_keep_aspect
index ca03277446..8dd0dbb13b 100644
--- a/tests/ref/fate/filter-scale2ref_keep_aspect
+++ b/tests/ref/fate/filter-scale2ref_keep_aspect
@@ -5,7 +5,7 @@
 #media_type 0: video
 #codec_id 0: rawvideo
 #dimensions 0: 160x120
-#sar 0: 4/3
+#sar 0: 1/1
 #stream#, dts,pts, duration, size, hash
 0,  0,  0,1,57600, 9a19c23dc3a557786840d0098606d5f1
 0,  1,  1,1,57600, e6fbdabaf1bb0d28afc648ed4d27e9f0
-- 
2.13.0

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


[FFmpeg-devel] [PATCH 1/2] libavfilter/scale: More descriptive in/ref/out logging

2017-06-05 Thread Kevin Mark
This change makes it more clear when using the scale and scale2ref
filters what is actually happening. The old format did not
differentiate between scale and scale2ref which would make it seem
that, when using scale2ref, the ref was what was truly being scaled.

Old format for both scale and scale2ref:

w:640 h:360 fmt:rgb24 sar:1/1 -> w:160 h:120 fmt:rgb24 sar:4/3 flags:0x2

The left side is the input and the right side is the output. While
this is sufficiently clear for scale, for scale2ref it appears to
conflate the main input with the reference input. To be fair that is
exactly what the code is doing (and on purpose) but that's not a very
intuitive implementation detail to expose to the user. Now that the
main input's constants are exposed in scale2ref it makes even more
sense to correct this.

New format for scale:

in  w:320 h:240 fmt:rgb24 sar:1/1
out w:80 h:60 fmt:rgb24 sar:1/1 flags:0xc

New format for scale2ref:

in  w:320 h:240 fmt:rgb24 sar:1/1
ref w:640 h:360 fmt:rgb24 sar:1/1
out w:160 h:120 fmt:rgb24 sar:4/3 flags:0x2

The increase in clarity is self-evident.

Signed-off-by: Kevin Mark 
---
 libavfilter/vf_scale.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index c59ac6b0ea..9232bc4439 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -342,9 +342,18 @@ static int config_props(AVFilterLink *outlink)
 } else
 outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
 
-av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s sar:%d/%d -> w:%d h:%d 
fmt:%s sar:%d/%d flags:0x%0x\n",
-   inlink ->w, inlink ->h, av_get_pix_fmt_name( inlink->format),
-   inlink->sample_aspect_ratio.num, inlink->sample_aspect_ratio.den,
+if (ctx->filter == &ff_vf_scale2ref) {
+av_log(ctx, AV_LOG_VERBOSE, "in  w:%d h:%d fmt:%s sar:%d/%d\n",
+   inlink0->w, inlink0->h, av_get_pix_fmt_name(inlink0->format),
+   inlink0->sample_aspect_ratio.num, 
inlink0->sample_aspect_ratio.den);
+}
+
+av_log(ctx, AV_LOG_VERBOSE, "%s w:%d h:%d fmt:%s sar:%d/%d\n",
+   ctx->filter == &ff_vf_scale2ref ? "ref" : "in ",
+   inlink->w, inlink->h, av_get_pix_fmt_name(inlink->format),
+   inlink->sample_aspect_ratio.num, inlink->sample_aspect_ratio.den);
+
+av_log(ctx, AV_LOG_VERBOSE, "out w:%d h:%d fmt:%s sar:%d/%d flags:0x%0x\n",
outlink->w, outlink->h, av_get_pix_fmt_name(outlink->format),
outlink->sample_aspect_ratio.num, outlink->sample_aspect_ratio.den,
scale->flags);
-- 
2.13.0

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


Re: [FFmpeg-devel] [PATCH] avformat/hls: Check local file extensions

2017-06-05 Thread Michael Niedermayer
On Mon, Jun 05, 2017 at 08:26:34AM +0200, Nicolas George wrote:
> Le septidi 17 prairial, an CCXXV, Michael Niedermayer a écrit :
> > Applied with the author name joke suggested by nicolas
> 
> Despite Hendrik's objection?

I have of course talked with hendrik before pushing. It was him who
suggested to limit the check to local files as done in the last
posted and applied patch

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct answer.


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


Re: [FFmpeg-devel] [PATCH] avformat/hls: Check local file extensions

2017-06-05 Thread Paul B Mahol
On 6/5/17, Michael Niedermayer  wrote:
> On Sat, Jun 03, 2017 at 09:20:04PM +0200, Michael Niedermayer wrote:
>> This reduces the attack surface of local file-system
>> information leaking.
>>
>> It prevents the existing exploit leading to an information leak. As
>> well as similar hypothetical attacks.
>>
>> Leaks of information from files and symlinks ending in common multimedia
>> extensions
>> are still possible. But files with sensitive information like private keys
>> and passwords
>> generally do not use common multimedia filename extensions.
>> It does not stop leaks via remote addresses in the LAN.
>>
>> The existing exploit depends on a specific decoder as well.
>> It does appear though that the exploit should be possible with any
>> decoder.
>> The problem is that as long as sensitive information gets into the
>> decoder,
>> the output of the decoder becomes sensitive as well.
>> The only obvious solution is to prevent access to sensitive information.
>> Or to
>> disable hls or possibly some of its feature. More complex solutions like
>> checking the path to limit access to only subdirectories of the hls path
>> may
>> work as an alternative. But such solutions are fragile and tricky to
>> implement
>> portably and would not stop every possible attack nor would they work with
>> all
>> valid hls files.
>>
>> Developers have expressed their dislike / objected to disabling hls by
>> default as well
>> as disabling hls with local files. There also where objections against
>> restricting
>> remote url file extensions. This here is a less robust but also lower
>> inconvenience solution.
>> It can be applied stand alone or together with other solutions.
>>
>> Found-by: Emil Lerner and Pavel Cheremushkin
>> Reported-by: Thierry Foucu 
>>
>> Signed-off-by: Michael Niedermayer 
>> ---
>>  libavformat/hls.c | 18 +-
>>  1 file changed, 17 insertions(+), 1 deletion(-)
>
> Applied with the author name joke suggested by nicolas

This is joke, please revert this.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel