[FFmpeg-devel] [PATCH 1/2] examples/filtering_audio: added loop for draining the filtergraph

2018-01-23 Thread Tobias Rapp
Signed-off-by: Tobias Rapp 
---
 doc/examples/filtering_audio.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/doc/examples/filtering_audio.c b/doc/examples/filtering_audio.c
index 18d6ca2..070d0cb3 100644
--- a/doc/examples/filtering_audio.c
+++ b/doc/examples/filtering_audio.c
@@ -280,6 +280,25 @@ int main(int argc, char **argv)
 }
 av_packet_unref(&packet);
 }
+if (ret == AVERROR_EOF) {
+/* signal EOF to the filtergraph */
+if (av_buffersrc_add_frame_flags(buffersrc_ctx, NULL, 0) < 0) {
+av_log(NULL, AV_LOG_ERROR, "Error while closing the 
filtergraph\n");
+goto end;
+}
+
+/* pull remaining frames from the filtergraph */
+while (1) {
+ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
+if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
+break;
+if (ret < 0)
+goto end;
+print_frame(filt_frame);
+av_frame_unref(filt_frame);
+}
+}
+
 end:
 avfilter_graph_free(&filter_graph);
 avcodec_free_context(&dec_ctx);
-- 
2.7.4


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


[FFmpeg-devel] [PATCH 2/2] examples/filtering_video: added loop for draining the filtergraph

2018-01-23 Thread Tobias Rapp
Signed-off-by: Tobias Rapp 
---
 doc/examples/filtering_video.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/doc/examples/filtering_video.c b/doc/examples/filtering_video.c
index 9b607ba..be00a1b 100644
--- a/doc/examples/filtering_video.c
+++ b/doc/examples/filtering_video.c
@@ -276,6 +276,25 @@ int main(int argc, char **argv)
 }
 av_packet_unref(&packet);
 }
+if (ret == AVERROR_EOF) {
+/* signal EOF to the filtergraph */
+if (av_buffersrc_add_frame_flags(buffersrc_ctx, NULL, 0) < 0) {
+av_log(NULL, AV_LOG_ERROR, "Error while closing the 
filtergraph\n");
+goto end;
+}
+
+/* pull remaining frames from the filtergraph */
+while (1) {
+ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
+if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
+break;
+if (ret < 0)
+goto end;
+display_frame(filt_frame, buffersink_ctx->inputs[0]->time_base);
+av_frame_unref(filt_frame);
+}
+}
+
 end:
 avfilter_graph_free(&filter_graph);
 avcodec_free_context(&dec_ctx);
-- 
2.7.4


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


[FFmpeg-devel] [PATCH v2] libopus: support disabling phase inversion.

2018-01-23 Thread Menno
Renamed the option. I looked into adding support on the decoder side but things
look a bit different there (e.g. there aren't any cli params set up yet.)

Is it OK to merge this first and I can work on the decoder later?


Signed-off-by: Menno 
---
 doc/encoders.texi   |  5 +
 libavcodec/libopusenc.c | 14 ++
 2 files changed, 19 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 6a410a8cb6..c5dfc646d9 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -981,6 +981,11 @@ Other values include 0 for mono and stereo, 1 for surround 
sound with masking
 and LFE bandwidth optimizations, and 255 for independent streams with an
 unspecified channel layout.
 
+@item apply_phase_inv (N.A.) (requires libopus >= 1.2)
+If set to 0, disables the use of phase inversion for intensity stereo,
+improving the quality of mono downmixes, but slightly reducing normal stereo
+quality. The default is 1 (phase inversion enabled).
+
 @end table
 
 @anchor{libshine}
diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
index b449497d15..4ae81b0bb2 100644
--- a/libavcodec/libopusenc.c
+++ b/libavcodec/libopusenc.c
@@ -39,6 +39,9 @@ typedef struct LibopusEncOpts {
 int packet_size;
 int max_bandwidth;
 int mapping_family;
+#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST
+int apply_phase_inv;
+#endif
 } LibopusEncOpts;
 
 typedef struct LibopusEncContext {
@@ -154,6 +157,14 @@ static int libopus_configure_encoder(AVCodecContext 
*avctx, OpusMSEncoder *enc,
"Unable to set maximum bandwidth: %s\n", 
opus_strerror(ret));
 }
 
+#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST
+ret = opus_multistream_encoder_ctl(enc,
+   
OPUS_SET_PHASE_INVERSION_DISABLED(!opts->apply_phase_inv));
+if (ret != OPUS_OK)
+av_log(avctx, AV_LOG_WARNING,
+   "Unable to set phase inversion: %s\n",
+   opus_strerror(ret));
+#endif
 return OPUS_OK;
 }
 
@@ -530,6 +541,9 @@ static const AVOption libopus_options[] = {
 { "on", "Use variable bit rate", 0, AV_OPT_TYPE_CONST, { 
.i64 = 1 }, 0, 0, FLAGS, "vbr" },
 { "constrained","Use constrained VBR",   0, AV_OPT_TYPE_CONST, { 
.i64 = 2 }, 0, 0, FLAGS, "vbr" },
 { "mapping_family", "Channel Mapping Family",  
OFFSET(mapping_family), AV_OPT_TYPE_INT,   { .i64 = -1 },   -1,  255,  FLAGS, 
"mapping_family" },
+#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST
+{ "apply_phase_inv", "Apply intensity stereo phase inversion", 
OFFSET(apply_phase_inv), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
+#endif
 { NULL },
 };
 
-- 
2.16.1

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


Re: [FFmpeg-devel] [PATCH] avdevice/decklink_dec: Extract 1080i and NTSC VANC

2018-01-23 Thread Devin Heitmueller
Hi Ray,

> On Jan 22, 2018, at 11:20 PM, Ray Tiley  wrote:
> 
> I'm reading 334-1:2017 Sec 4
> "When the ANC packets defined in this standard are carried in a high
> definition signal, they shall be carried in the Y stream."
> 
> I couldn't find anywhere in the document where it calls out standard
> definition

Right, so my understanding was that allowing the ability to use both luma and 
chroma was a result of having less space in the VANC to hold data, compared to 
HD resolutions where that is much less likely to be an issue.  That said, I’ve 
never seen an implementation that actually puts it in the chroma.

> 
> Conversation is here:
> https://video-dev.slack.com/archives/C0XKDDH5Y/p151614155574 
>  with
> kier...@obe.tv  who I believe is in the ffmpeg-devel 
> IRC.
> 

Ah, ok.  That’s Kieran.  He’s really knowledgable in this area, although I 
cannot see the conversation you’ve linked to as it seems that room is only 
accessible by people with email accounts from certain domains.

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


Re: [FFmpeg-devel] [PATCH v3 4/4] avformat/libopenmpt: Probe file format from file data if possible

2018-01-23 Thread Jörn Heusipp


On 01/11/2018 09:11 AM, Jörn Heusipp wrote:

Signed-off-by: Jörn Heusipp 
---
  libavformat/libopenmpt.c | 57 
  1 file changed, 57 insertions(+)


Does anyone have any further comments on patches 3/4 and 4/4?
Carl Eugen Hoyos suggested that more comments from other developers 
would be useful, and I agree. I would also prefer to receive more 
feedback before getting patch 4/4 merged.


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


Re: [FFmpeg-devel] [PATCH] avformat: add option to parse/store ID3 PRIV tags in metadata.

2018-01-23 Thread Moritz Barsnick
On Wed, Jan 17, 2018 at 16:34:39 -0800, rshaf...@tunein.com wrote:

If you have to post one more update anyway, some formal comments from
me:

> +char * escaped, * key;

"*" attaches to the right-hand term.

> +}
> \ No newline at end of file

Please do add this newline. :-)

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


Re: [FFmpeg-devel] [PATCH v2] libopus: support disabling phase inversion.

2018-01-23 Thread Moritz Barsnick
On Tue, Jan 23, 2018 at 13:50:41 +0100, Menno wrote:
> +@item apply_phase_inv (N.A.) (requires libopus >= 1.2)

What does the "N.A." stand for? Does it have a technical meaning?

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


Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input

2018-01-23 Thread Mironov, Mikhail
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: January 22, 2018 6:57 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input
> 
> ---
> This allows passing OpenCL frames to AMF without a download/upload step
> to get around AMD's lack of support for D3D11 mapping.
> 
> For example:
> 
> ./ffmpeg -hwaccel dxva2 -hwaccel_output_format dxva2_vld -i input.mp4 -an
> -vf
> 'hwmap=derive_device=opencl,program_opencl=source=examples.cl:kernel=
> rotate_image' -c:v h264_amf output.mp4
> 
> * I can't find any documentation or examples for these functions, so I'm
> guessing a bit exactly how they are meant to work.  In particular, there are
> some locking functions which I have ignored because I have no idea under
> what circumstances something might want to be locked.
> * I tried to write common parts with D3D11, but I might well have broken
> D3D11 support in the process - it doesn't work at all for me so I can't test 
> it.
> * Not sure how to get non-NV12 to work.  I may be missing something, or it
> may just not be there - the trace messages suggest it doesn't like the width 
> of
> RGB0 or the second plane of GRAY8.
> 
> - Mark
> 
> 
>  libavcodec/amfenc.c | 178 +++-
> 
>  libavcodec/amfenc.h |   1 +
>  2 files changed, 123 insertions(+), 56 deletions(-)
> 
> diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c index
> 89a10ff253..220cdd278f 100644
> --- a/libavcodec/amfenc.c
> +++ b/libavcodec/amfenc.c
> @@ -24,6 +24,9 @@
>  #if CONFIG_D3D11VA
>  #include "libavutil/hwcontext_d3d11va.h"
>  #endif
> +#if CONFIG_OPENCL
> +#include "libavutil/hwcontext_opencl.h"
> +#endif
>  #include "libavutil/mem.h"
>  #include "libavutil/pixdesc.h"
>  #include "libavutil/time.h"
> @@ -51,6 +54,9 @@ const enum AVPixelFormat ff_amf_pix_fmts[] = {  #if
> CONFIG_D3D11VA
>  AV_PIX_FMT_D3D11,
>  #endif
> +#if CONFIG_OPENCL
> +AV_PIX_FMT_OPENCL,
> +#endif
>  AV_PIX_FMT_NONE
>  };
> 
> @@ -69,6 +75,7 @@ static const FormatMap format_map[] =
>  { AV_PIX_FMT_YUV420P,AMF_SURFACE_YUV420P },
>  { AV_PIX_FMT_YUYV422,AMF_SURFACE_YUY2 },
>  { AV_PIX_FMT_D3D11,  AMF_SURFACE_NV12 },
> +{ AV_PIX_FMT_OPENCL, AMF_SURFACE_NV12 },
>  };
> 
> 
> @@ -154,8 +161,9 @@ static int amf_load_library(AVCodecContext *avctx)
> 
>  static int amf_init_context(AVCodecContext *avctx)  {
> -AmfContext *ctx = avctx->priv_data;
> -AMF_RESULT  res = AMF_OK;
> +AmfContext *ctx = avctx->priv_data;
> +AMF_RESULT res;
> +AVHWDeviceContext *hwdev = NULL;
> 
>  // configure AMF logger
>  // the return of these functions indicates old state and do not affect
> behaviour @@ -173,59 +181,91 @@ static int
> amf_init_context(AVCodecContext *avctx)
> 
>  res = ctx->factory->pVtbl->CreateContext(ctx->factory, &ctx->context);
>  AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN,
> "CreateContext() failed with error %d\n", res);
> -// try to reuse existing DX device
> -#if CONFIG_D3D11VA
> +
> +// Attempt to initialise from an existing D3D11 or OpenCL device.
>  if (avctx->hw_frames_ctx) {
> -AVHWFramesContext *device_ctx = (AVHWFramesContext*)avctx-
> >hw_frames_ctx->data;
> -if (device_ctx->device_ctx->type == AV_HWDEVICE_TYPE_D3D11VA) {
> -if (amf_av_to_amf_format(device_ctx->sw_format) !=
> AMF_SURFACE_UNKNOWN) {
> -if (device_ctx->device_ctx->hwctx) {
> -AVD3D11VADeviceContext *device_d3d11 =
> (AVD3D11VADeviceContext *)device_ctx->device_ctx->hwctx;
> -res = ctx->context->pVtbl->InitDX11(ctx->context, 
> device_d3d11-
> >device, AMF_DX11_1);
> -if (res == AMF_OK) {
> -ctx->hw_frames_ctx = 
> av_buffer_ref(avctx->hw_frames_ctx);
> -if (!ctx->hw_frames_ctx) {
> -return AVERROR(ENOMEM);
> -}
> -} else {
> -if(res == AMF_NOT_SUPPORTED)
> -av_log(avctx, AV_LOG_INFO, "avctx->hw_frames_ctx 
> has
> D3D11 device which doesn't have D3D11VA interface, switching to
> default\n");
> -else
> -av_log(avctx, AV_LOG_INFO, "avctx->hw_frames_ctx 
> has
> non-AMD device, switching to default\n");
> -}
> -}
> -} else {
> -av_log(avctx, AV_LOG_INFO, "avctx->hw_frames_ctx has format
> not uspported by AMF, switching to default\n");
> -}
> +AVHWFramesContext *hwfc =
> + (AVHWFramesContext*)avctx->hw_frames_ctx->data;
> +
> +if (amf_av_to_amf_format(hwfc->sw_format) ==
> AMF_SURFACE_UNKNOWN) {
> +av_log(avctx, AV_LOG_VERBOSE, "Input hardware frame forma

Re: [FFmpeg-devel] [PATCH v2] libopus: support disabling phase inversion.

2018-01-23 Thread Menno de Gier
On Tue, Jan 23, 2018 at 3:50 PM, Moritz Barsnick  wrote:

> On Tue, Jan 23, 2018 at 13:50:41 +0100, Menno wrote:
> > +@item apply_phase_inv (N.A.) (requires libopus >= 1.2)
>
> What does the "N.A." stand for? Does it have a technical meaning?


It's the `opusenc` equivalent option, but in this case (and a few others)
it's Not Applicable.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input

2018-01-23 Thread Mironov, Mikhail
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mironov, Mikhail
> Sent: January 23, 2018 10:04 AM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input
> 
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> > Of Mark Thompson
> > Sent: January 22, 2018 6:57 PM
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Subject: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input
> >
> > ---
> > This allows passing OpenCL frames to AMF without a download/upload
> > step to get around AMD's lack of support for D3D11 mapping.
> >
> > For example:
> >
> > ./ffmpeg -hwaccel dxva2 -hwaccel_output_format dxva2_vld -i input.mp4
> > -an -vf
> >
> 'hwmap=derive_device=opencl,program_opencl=source=examples.cl:kernel=
> > rotate_image' -c:v h264_amf output.mp4
> >
> > * I can't find any documentation or examples for these functions, so
> > I'm guessing a bit exactly how they are meant to work.  In particular,
> > there are some locking functions which I have ignored because I have
> > no idea under what circumstances something might want to be locked.
> > * I tried to write common parts with D3D11, but I might well have
> > broken
> > D3D11 support in the process - it doesn't work at all for me so I can't 
> > test it.
> > * Not sure how to get non-NV12 to work.  I may be missing something,
> > or it may just not be there - the trace messages suggest it doesn't
> > like the width of
> > RGB0 or the second plane of GRAY8.
> >
> > - Mark
> >
> >
> >  libavcodec/amfenc.c | 178
> > +++-
> > 
> >  libavcodec/amfenc.h |   1 +
> >  2 files changed, 123 insertions(+), 56 deletions(-)
> >
> > diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c index
> > 89a10ff253..220cdd278f 100644
> > --- a/libavcodec/amfenc.c
> > +++ b/libavcodec/amfenc.c
> > @@ -24,6 +24,9 @@
> >  #if CONFIG_D3D11VA
> >  #include "libavutil/hwcontext_d3d11va.h"
> >  #endif
> > +#if CONFIG_OPENCL
> > +#include "libavutil/hwcontext_opencl.h"
> > +#endif
> >  #include "libavutil/mem.h"
> >  #include "libavutil/pixdesc.h"
> >  #include "libavutil/time.h"
> > @@ -51,6 +54,9 @@ const enum AVPixelFormat ff_amf_pix_fmts[] = {  #if
> > CONFIG_D3D11VA
> >  AV_PIX_FMT_D3D11,
> >  #endif
> > +#if CONFIG_OPENCL
> > +AV_PIX_FMT_OPENCL,
> > +#endif
> >  AV_PIX_FMT_NONE
> >  };
> >
> > @@ -69,6 +75,7 @@ static const FormatMap format_map[] =
> >  { AV_PIX_FMT_YUV420P,AMF_SURFACE_YUV420P },
> >  { AV_PIX_FMT_YUYV422,AMF_SURFACE_YUY2 },
> >  { AV_PIX_FMT_D3D11,  AMF_SURFACE_NV12 },
> > +{ AV_PIX_FMT_OPENCL, AMF_SURFACE_NV12 },
> >  };
> >
> >
> > @@ -154,8 +161,9 @@ static int amf_load_library(AVCodecContext *avctx)
> >
> >  static int amf_init_context(AVCodecContext *avctx)  {
> > -AmfContext *ctx = avctx->priv_data;
> > -AMF_RESULT  res = AMF_OK;
> > +AmfContext *ctx = avctx->priv_data;
> > +AMF_RESULT res;
> > +AVHWDeviceContext *hwdev = NULL;
> >
> >  // configure AMF logger
> >  // the return of these functions indicates old state and do not
> > affect behaviour @@ -173,59 +181,91 @@ static int
> > amf_init_context(AVCodecContext *avctx)
> >
> >  res = ctx->factory->pVtbl->CreateContext(ctx->factory, &ctx->context);
> >  AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN,
> > "CreateContext() failed with error %d\n", res);
> > -// try to reuse existing DX device
> > -#if CONFIG_D3D11VA
> > +
> > +// Attempt to initialise from an existing D3D11 or OpenCL device.
> >  if (avctx->hw_frames_ctx) {
> > -AVHWFramesContext *device_ctx = (AVHWFramesContext*)avctx-
> > >hw_frames_ctx->data;
> > -if (device_ctx->device_ctx->type == AV_HWDEVICE_TYPE_D3D11VA) {
> > -if (amf_av_to_amf_format(device_ctx->sw_format) !=
> > AMF_SURFACE_UNKNOWN) {
> > -if (device_ctx->device_ctx->hwctx) {
> > -AVD3D11VADeviceContext *device_d3d11 =
> > (AVD3D11VADeviceContext *)device_ctx->device_ctx->hwctx;
> > -res = ctx->context->pVtbl->InitDX11(ctx->context,
> device_d3d11-
> > >device, AMF_DX11_1);
> > -if (res == AMF_OK) {
> > -ctx->hw_frames_ctx = 
> > av_buffer_ref(avctx->hw_frames_ctx);
> > -if (!ctx->hw_frames_ctx) {
> > -return AVERROR(ENOMEM);
> > -}
> > -} else {
> > -if(res == AMF_NOT_SUPPORTED)
> > -av_log(avctx, AV_LOG_INFO, 
> > "avctx->hw_frames_ctx has
> > D3D11 device which doesn't have D3D11VA interface, switching to
> > default\n");
> > -else
> > -av_log(avctx, AV_LOG_INFO, 
> > "

Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input

2018-01-23 Thread Mark Thompson
On 23/01/18 15:04, Mironov, Mikhail wrote:
>> -Original Message-
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
>> Of Mark Thompson
>> Sent: January 22, 2018 6:57 PM
>> To: FFmpeg development discussions and patches > de...@ffmpeg.org>
>> Subject: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input
>>
>> ---
>> This allows passing OpenCL frames to AMF without a download/upload step
>> to get around AMD's lack of support for D3D11 mapping.
>>
>> For example:
>>
>> ./ffmpeg -hwaccel dxva2 -hwaccel_output_format dxva2_vld -i input.mp4 -an
>> -vf
>> 'hwmap=derive_device=opencl,program_opencl=source=examples.cl:kernel=
>> rotate_image' -c:v h264_amf output.mp4
>>
>> * I can't find any documentation or examples for these functions, so I'm
>> guessing a bit exactly how they are meant to work.  In particular, there are
>> some locking functions which I have ignored because I have no idea under
>> what circumstances something might want to be locked.
>> * I tried to write common parts with D3D11, but I might well have broken
>> D3D11 support in the process - it doesn't work at all for me so I can't test 
>> it.
>> * Not sure how to get non-NV12 to work.  I may be missing something, or it
>> may just not be there - the trace messages suggest it doesn't like the width 
>> of
>> RGB0 or the second plane of GRAY8.
>>
>> - Mark
>>
>>
>>  libavcodec/amfenc.c | 178 +++-
>> 
>>  libavcodec/amfenc.h |   1 +
>>  2 files changed, 123 insertions(+), 56 deletions(-)
>>
>> diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c index
>> 89a10ff253..220cdd278f 100644
>> --- a/libavcodec/amfenc.c
>> +++ b/libavcodec/amfenc.c
>> @@ -24,6 +24,9 @@
>>  #if CONFIG_D3D11VA
>>  #include "libavutil/hwcontext_d3d11va.h"
>>  #endif
>> +#if CONFIG_OPENCL
>> +#include "libavutil/hwcontext_opencl.h"
>> +#endif
>>  #include "libavutil/mem.h"
>>  #include "libavutil/pixdesc.h"
>>  #include "libavutil/time.h"
>> @@ -51,6 +54,9 @@ const enum AVPixelFormat ff_amf_pix_fmts[] = {  #if
>> CONFIG_D3D11VA
>>  AV_PIX_FMT_D3D11,
>>  #endif
>> +#if CONFIG_OPENCL
>> +AV_PIX_FMT_OPENCL,
>> +#endif
>>  AV_PIX_FMT_NONE
>>  };
>>
>> @@ -69,6 +75,7 @@ static const FormatMap format_map[] =
>>  { AV_PIX_FMT_YUV420P,AMF_SURFACE_YUV420P },
>>  { AV_PIX_FMT_YUYV422,AMF_SURFACE_YUY2 },
>>  { AV_PIX_FMT_D3D11,  AMF_SURFACE_NV12 },
>> +{ AV_PIX_FMT_OPENCL, AMF_SURFACE_NV12 },
>>  };
>>
>>
>> @@ -154,8 +161,9 @@ static int amf_load_library(AVCodecContext *avctx)
>>
>>  static int amf_init_context(AVCodecContext *avctx)  {
>> -AmfContext *ctx = avctx->priv_data;
>> -AMF_RESULT  res = AMF_OK;
>> +AmfContext *ctx = avctx->priv_data;
>> +AMF_RESULT res;
>> +AVHWDeviceContext *hwdev = NULL;
>>
>>  // configure AMF logger
>>  // the return of these functions indicates old state and do not affect
>> behaviour @@ -173,59 +181,91 @@ static int
>> amf_init_context(AVCodecContext *avctx)
>>
>>  res = ctx->factory->pVtbl->CreateContext(ctx->factory, &ctx->context);
>>  AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN,
>> "CreateContext() failed with error %d\n", res);
>> -// try to reuse existing DX device
>> -#if CONFIG_D3D11VA
>> +
>> +// Attempt to initialise from an existing D3D11 or OpenCL device.
>>  if (avctx->hw_frames_ctx) {
>> -AVHWFramesContext *device_ctx = (AVHWFramesContext*)avctx-
>>> hw_frames_ctx->data;
>> -if (device_ctx->device_ctx->type == AV_HWDEVICE_TYPE_D3D11VA) {
>> -if (amf_av_to_amf_format(device_ctx->sw_format) !=
>> AMF_SURFACE_UNKNOWN) {
>> -if (device_ctx->device_ctx->hwctx) {
>> -AVD3D11VADeviceContext *device_d3d11 =
>> (AVD3D11VADeviceContext *)device_ctx->device_ctx->hwctx;
>> -res = ctx->context->pVtbl->InitDX11(ctx->context, 
>> device_d3d11-
>>> device, AMF_DX11_1);
>> -if (res == AMF_OK) {
>> -ctx->hw_frames_ctx = 
>> av_buffer_ref(avctx->hw_frames_ctx);
>> -if (!ctx->hw_frames_ctx) {
>> -return AVERROR(ENOMEM);
>> -}
>> -} else {
>> -if(res == AMF_NOT_SUPPORTED)
>> -av_log(avctx, AV_LOG_INFO, 
>> "avctx->hw_frames_ctx has
>> D3D11 device which doesn't have D3D11VA interface, switching to
>> default\n");
>> -else
>> -av_log(avctx, AV_LOG_INFO, 
>> "avctx->hw_frames_ctx has
>> non-AMD device, switching to default\n");
>> -}
>> -}
>> -} else {
>> -av_log(avctx, AV_LOG_INFO, "avctx->hw_frames_ctx has format
>> not uspported by AMF, switching to default\n");
>> -}
>> +AVHWFramesContext *hwfc =
>> + (AVHWFramesContext*)avctx->hw_frames_ctx->data;

Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input

2018-01-23 Thread Mironov, Mikhail
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: January 23, 2018 10:21 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input
> 
> On 23/01/18 15:04, Mironov, Mikhail wrote:
> >> -Original Message-
> >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> >> Of Mark Thompson
> >> Sent: January 22, 2018 6:57 PM
> >> To: FFmpeg development discussions and patches  >> de...@ffmpeg.org>
> >> Subject: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input
> >>
> >> ---
> >> This allows passing OpenCL frames to AMF without a download/upload
> >> step to get around AMD's lack of support for D3D11 mapping.
> >>
> >> For example:
> >>
> >> ./ffmpeg -hwaccel dxva2 -hwaccel_output_format dxva2_vld -i input.mp4
> >> -an -vf
> >>
> 'hwmap=derive_device=opencl,program_opencl=source=examples.cl:kernel=
> >> rotate_image' -c:v h264_amf output.mp4
> >>
> >> * I can't find any documentation or examples for these functions, so
> >> I'm guessing a bit exactly how they are meant to work.  In
> >> particular, there are some locking functions which I have ignored
> >> because I have no idea under what circumstances something might want
> to be locked.
> >> * I tried to write common parts with D3D11, but I might well have
> >> broken
> >> D3D11 support in the process - it doesn't work at all for me so I can't 
> >> test
> it.
> >> * Not sure how to get non-NV12 to work.  I may be missing something,
> >> or it may just not be there - the trace messages suggest it doesn't
> >> like the width of
> >> RGB0 or the second plane of GRAY8.
> >>
> >> - Mark
> >>
> >>
> >>  libavcodec/amfenc.c | 178
> >> +++-
> >> 
> >>  libavcodec/amfenc.h |   1 +
> >>  2 files changed, 123 insertions(+), 56 deletions(-)
> >>
> >> diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c index
> >> 89a10ff253..220cdd278f 100644
> >> --- a/libavcodec/amfenc.c
> >> +++ b/libavcodec/amfenc.c
> >> @@ -24,6 +24,9 @@
> >>  #if CONFIG_D3D11VA
> >>  #include "libavutil/hwcontext_d3d11va.h"
> >>  #endif
> >> +#if CONFIG_OPENCL
> >> +#include "libavutil/hwcontext_opencl.h"
> >> +#endif
> >>  #include "libavutil/mem.h"
> >>  #include "libavutil/pixdesc.h"
> >>  #include "libavutil/time.h"
> >> @@ -51,6 +54,9 @@ const enum AVPixelFormat ff_amf_pix_fmts[] = {  #if
> >> CONFIG_D3D11VA
> >>  AV_PIX_FMT_D3D11,
> >>  #endif
> >> +#if CONFIG_OPENCL
> >> +AV_PIX_FMT_OPENCL,
> >> +#endif
> >>  AV_PIX_FMT_NONE
> >>  };
> >>
> >> @@ -69,6 +75,7 @@ static const FormatMap format_map[] =
> >>  { AV_PIX_FMT_YUV420P,AMF_SURFACE_YUV420P },
> >>  { AV_PIX_FMT_YUYV422,AMF_SURFACE_YUY2 },
> >>  { AV_PIX_FMT_D3D11,  AMF_SURFACE_NV12 },
> >> +{ AV_PIX_FMT_OPENCL, AMF_SURFACE_NV12 },
> >>  };
> >>
> >>
> >> @@ -154,8 +161,9 @@ static int amf_load_library(AVCodecContext
> >> *avctx)
> >>
> >>  static int amf_init_context(AVCodecContext *avctx)  {
> >> -AmfContext *ctx = avctx->priv_data;
> >> -AMF_RESULT  res = AMF_OK;
> >> +AmfContext *ctx = avctx->priv_data;
> >> +AMF_RESULT res;
> >> +AVHWDeviceContext *hwdev = NULL;
> >>
> >>  // configure AMF logger
> >>  // the return of these functions indicates old state and do not
> >> affect behaviour @@ -173,59 +181,91 @@ static int
> >> amf_init_context(AVCodecContext *avctx)
> >>
> >>  res = ctx->factory->pVtbl->CreateContext(ctx->factory, &ctx->context);
> >>  AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN,
> >> "CreateContext() failed with error %d\n", res);
> >> -// try to reuse existing DX device
> >> -#if CONFIG_D3D11VA
> >> +
> >> +// Attempt to initialise from an existing D3D11 or OpenCL device.
> >>  if (avctx->hw_frames_ctx) {
> >> -AVHWFramesContext *device_ctx = (AVHWFramesContext*)avctx-
> >>> hw_frames_ctx->data;
> >> -if (device_ctx->device_ctx->type == AV_HWDEVICE_TYPE_D3D11VA)
> {
> >> -if (amf_av_to_amf_format(device_ctx->sw_format) !=
> >> AMF_SURFACE_UNKNOWN) {
> >> -if (device_ctx->device_ctx->hwctx) {
> >> -AVD3D11VADeviceContext *device_d3d11 =
> >> (AVD3D11VADeviceContext *)device_ctx->device_ctx->hwctx;
> >> -res = ctx->context->pVtbl->InitDX11(ctx->context,
> device_d3d11-
> >>> device, AMF_DX11_1);
> >> -if (res == AMF_OK) {
> >> -ctx->hw_frames_ctx = av_buffer_ref(avctx-
> >hw_frames_ctx);
> >> -if (!ctx->hw_frames_ctx) {
> >> -return AVERROR(ENOMEM);
> >> -}
> >> -} else {
> >> -if(res == AMF_NOT_SUPPORTED)
> >> -av_log(avctx, AV_LOG_INFO, 
> >> "avctx->hw_frames_ctx has
> >> D3D11 device which doesn't have D3D11VA interface, 

Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input

2018-01-23 Thread Mironov, Mikhail
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: January 23, 2018 10:21 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input
> 
> On 23/01/18 15:04, Mironov, Mikhail wrote:
> >> -Original Message-
> >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> >> Of Mark Thompson
> >> Sent: January 22, 2018 6:57 PM
> >> To: FFmpeg development discussions and patches  >> de...@ffmpeg.org>
> >> Subject: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input
> >>
> >> ---
> >> This allows passing OpenCL frames to AMF without a download/upload
> >> step to get around AMD's lack of support for D3D11 mapping.
> >>
> >> For example:
> >>
> >> ./ffmpeg -hwaccel dxva2 -hwaccel_output_format dxva2_vld -i input.mp4
> >> -an -vf
> >>
> 'hwmap=derive_device=opencl,program_opencl=source=examples.cl:kernel=
> >> rotate_image' -c:v h264_amf output.mp4
> >>
> >> * I can't find any documentation or examples for these functions, so
> >> I'm guessing a bit exactly how they are meant to work.  In
> >> particular, there are some locking functions which I have ignored
> >> because I have no idea under what circumstances something might want
> to be locked.
> >> * I tried to write common parts with D3D11, but I might well have
> >> broken
> >> D3D11 support in the process - it doesn't work at all for me so I can't 
> >> test
> it.
> >> * Not sure how to get non-NV12 to work.  I may be missing something,
> >> or it may just not be there - the trace messages suggest it doesn't
> >> like the width of
> >> RGB0 or the second plane of GRAY8.
> >>
> >> - Mark
> >>
> >>
> >>  libavcodec/amfenc.c | 178
> >> +++-
> >> 
> >>  libavcodec/amfenc.h |   1 +
> >>  2 files changed, 123 insertions(+), 56 deletions(-)
> >>
> >> diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c index
> >> 89a10ff253..220cdd278f 100644
> >> --- a/libavcodec/amfenc.c
> >> +++ b/libavcodec/amfenc.c
> >> @@ -24,6 +24,9 @@
> >>  #if CONFIG_D3D11VA
> >>  #include "libavutil/hwcontext_d3d11va.h"
> >>  #endif
> >> +#if CONFIG_OPENCL
> >> +#include "libavutil/hwcontext_opencl.h"
> >> +#endif
> >>  #include "libavutil/mem.h"
> >>  #include "libavutil/pixdesc.h"
> >>  #include "libavutil/time.h"
> >> @@ -51,6 +54,9 @@ const enum AVPixelFormat ff_amf_pix_fmts[] = {  #if
> >> CONFIG_D3D11VA
> >>  AV_PIX_FMT_D3D11,
> >>  #endif
> >> +#if CONFIG_OPENCL
> >> +AV_PIX_FMT_OPENCL,
> >> +#endif
> >>  AV_PIX_FMT_NONE
> >>  };
> >>
> >> @@ -69,6 +75,7 @@ static const FormatMap format_map[] =
> >>  { AV_PIX_FMT_YUV420P,AMF_SURFACE_YUV420P },
> >>  { AV_PIX_FMT_YUYV422,AMF_SURFACE_YUY2 },
> >>  { AV_PIX_FMT_D3D11,  AMF_SURFACE_NV12 },
> >> +{ AV_PIX_FMT_OPENCL, AMF_SURFACE_NV12 },
> >>  };
> >>
> >>
> >> @@ -154,8 +161,9 @@ static int amf_load_library(AVCodecContext
> >> *avctx)
> >>
> >>  static int amf_init_context(AVCodecContext *avctx)  {
> >> -AmfContext *ctx = avctx->priv_data;
> >> -AMF_RESULT  res = AMF_OK;
> >> +AmfContext *ctx = avctx->priv_data;
> >> +AMF_RESULT res;
> >> +AVHWDeviceContext *hwdev = NULL;
> >>
> >>  // configure AMF logger
> >>  // the return of these functions indicates old state and do not
> >> affect behaviour @@ -173,59 +181,91 @@ static int
> >> amf_init_context(AVCodecContext *avctx)
> >>
> >>  res = ctx->factory->pVtbl->CreateContext(ctx->factory, &ctx->context);
> >>  AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN,
> >> "CreateContext() failed with error %d\n", res);
> >> -// try to reuse existing DX device
> >> -#if CONFIG_D3D11VA
> >> +
> >> +// Attempt to initialise from an existing D3D11 or OpenCL device.
> >>  if (avctx->hw_frames_ctx) {
> >> -AVHWFramesContext *device_ctx = (AVHWFramesContext*)avctx-
> >>> hw_frames_ctx->data;
> >> -if (device_ctx->device_ctx->type == AV_HWDEVICE_TYPE_D3D11VA)
> {
> >> -if (amf_av_to_amf_format(device_ctx->sw_format) !=
> >> AMF_SURFACE_UNKNOWN) {
> >> -if (device_ctx->device_ctx->hwctx) {
> >> -AVD3D11VADeviceContext *device_d3d11 =
> >> (AVD3D11VADeviceContext *)device_ctx->device_ctx->hwctx;
> >> -res = ctx->context->pVtbl->InitDX11(ctx->context,
> device_d3d11-
> >>> device, AMF_DX11_1);
> >> -if (res == AMF_OK) {
> >> -ctx->hw_frames_ctx = av_buffer_ref(avctx-
> >hw_frames_ctx);
> >> -if (!ctx->hw_frames_ctx) {
> >> -return AVERROR(ENOMEM);
> >> -}
> >> -} else {
> >> -if(res == AMF_NOT_SUPPORTED)
> >> -av_log(avctx, AV_LOG_INFO, 
> >> "avctx->hw_frames_ctx has
> >> D3D11 device which doesn't have D3D11VA interface, 

Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input

2018-01-23 Thread Mark Thompson
On 23/01/18 15:14, Mironov, Mikhail wrote:
>> -Original Message-
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
>> Of Mironov, Mikhail
>> Sent: January 23, 2018 10:04 AM
>> To: FFmpeg development discussions and patches > de...@ffmpeg.org>
>> Subject: Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input
>>
>>> -Original Message-
>>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
>>> Of Mark Thompson
>>> Sent: January 22, 2018 6:57 PM
>>> To: FFmpeg development discussions and patches >> de...@ffmpeg.org>
>>> Subject: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input
>>>
>>> ---
>>> This allows passing OpenCL frames to AMF without a download/upload
>>> step to get around AMD's lack of support for D3D11 mapping.
>>>
>>> For example:
>>>
>>> ./ffmpeg -hwaccel dxva2 -hwaccel_output_format dxva2_vld -i input.mp4
>>> -an -vf
>>>
>> 'hwmap=derive_device=opencl,program_opencl=source=examples.cl:kernel=
>>> rotate_image' -c:v h264_amf output.mp4
>>>
>>> * I can't find any documentation or examples for these functions, so
>>> I'm guessing a bit exactly how they are meant to work.  In particular,
>>> there are some locking functions which I have ignored because I have
>>> no idea under what circumstances something might want to be locked.
>>> * I tried to write common parts with D3D11, but I might well have
>>> broken
>>> D3D11 support in the process - it doesn't work at all for me so I can't 
>>> test it.
>>> * Not sure how to get non-NV12 to work.  I may be missing something,
>>> or it may just not be there - the trace messages suggest it doesn't
>>> like the width of
>>> RGB0 or the second plane of GRAY8.
>>>
>>> - Mark
>>>
>>>
>>>  libavcodec/amfenc.c | 178
>>> +++-
>>> 
>>>  libavcodec/amfenc.h |   1 +
>>>  2 files changed, 123 insertions(+), 56 deletions(-)
>>>
>>> diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c index
>>> 89a10ff253..220cdd278f 100644
>>> --- a/libavcodec/amfenc.c
>>> +++ b/libavcodec/amfenc.c
>>> @@ -24,6 +24,9 @@
>>>  #if CONFIG_D3D11VA
>>>  #include "libavutil/hwcontext_d3d11va.h"
>>>  #endif
>>> +#if CONFIG_OPENCL
>>> +#include "libavutil/hwcontext_opencl.h"
>>> +#endif
>>>  #include "libavutil/mem.h"
>>>  #include "libavutil/pixdesc.h"
>>>  #include "libavutil/time.h"
>>> @@ -51,6 +54,9 @@ const enum AVPixelFormat ff_amf_pix_fmts[] = {  #if
>>> CONFIG_D3D11VA
>>>  AV_PIX_FMT_D3D11,
>>>  #endif
>>> +#if CONFIG_OPENCL
>>> +AV_PIX_FMT_OPENCL,
>>> +#endif
>>>  AV_PIX_FMT_NONE
>>>  };
>>>
>>> @@ -69,6 +75,7 @@ static const FormatMap format_map[] =
>>>  { AV_PIX_FMT_YUV420P,AMF_SURFACE_YUV420P },
>>>  { AV_PIX_FMT_YUYV422,AMF_SURFACE_YUY2 },
>>>  { AV_PIX_FMT_D3D11,  AMF_SURFACE_NV12 },
>>> +{ AV_PIX_FMT_OPENCL, AMF_SURFACE_NV12 },
>>>  };
>>>
>>>
>>> @@ -154,8 +161,9 @@ static int amf_load_library(AVCodecContext *avctx)
>>>
>>>  static int amf_init_context(AVCodecContext *avctx)  {
>>> -AmfContext *ctx = avctx->priv_data;
>>> -AMF_RESULT  res = AMF_OK;
>>> +AmfContext *ctx = avctx->priv_data;
>>> +AMF_RESULT res;
>>> +AVHWDeviceContext *hwdev = NULL;
>>>
>>>  // configure AMF logger
>>>  // the return of these functions indicates old state and do not
>>> affect behaviour @@ -173,59 +181,91 @@ static int
>>> amf_init_context(AVCodecContext *avctx)
>>>
>>>  res = ctx->factory->pVtbl->CreateContext(ctx->factory, &ctx->context);
>>>  AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN,
>>> "CreateContext() failed with error %d\n", res);
>>> -// try to reuse existing DX device
>>> -#if CONFIG_D3D11VA
>>> +
>>> +// Attempt to initialise from an existing D3D11 or OpenCL device.
>>>  if (avctx->hw_frames_ctx) {
>>> -AVHWFramesContext *device_ctx = (AVHWFramesContext*)avctx-
 hw_frames_ctx->data;
>>> -if (device_ctx->device_ctx->type == AV_HWDEVICE_TYPE_D3D11VA) {
>>> -if (amf_av_to_amf_format(device_ctx->sw_format) !=
>>> AMF_SURFACE_UNKNOWN) {
>>> -if (device_ctx->device_ctx->hwctx) {
>>> -AVD3D11VADeviceContext *device_d3d11 =
>>> (AVD3D11VADeviceContext *)device_ctx->device_ctx->hwctx;
>>> -res = ctx->context->pVtbl->InitDX11(ctx->context,
>> device_d3d11-
 device, AMF_DX11_1);
>>> -if (res == AMF_OK) {
>>> -ctx->hw_frames_ctx = 
>>> av_buffer_ref(avctx->hw_frames_ctx);
>>> -if (!ctx->hw_frames_ctx) {
>>> -return AVERROR(ENOMEM);
>>> -}
>>> -} else {
>>> -if(res == AMF_NOT_SUPPORTED)
>>> -av_log(avctx, AV_LOG_INFO, 
>>> "avctx->hw_frames_ctx has
>>> D3D11 device which doesn't have D3D11VA interface, switching to
>>> default\n");
>>> -else
>>> - 

Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input

2018-01-23 Thread Mironov, Mikhail
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: January 23, 2018 10:41 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input
> 
> On 23/01/18 15:14, Mironov, Mikhail wrote:
> >> -Original Message-
> >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> >> Of Mironov, Mikhail
> >> Sent: January 23, 2018 10:04 AM
> >> To: FFmpeg development discussions and patches  >> de...@ffmpeg.org>
> >> Subject: Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL
> >> input
> >>
> >>> -Original Message-
> >>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> >>> Behalf Of Mark Thompson
> >>> Sent: January 22, 2018 6:57 PM
> >>> To: FFmpeg development discussions and patches  >>> de...@ffmpeg.org>
> >>> Subject: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input
> >>>
> >>> ---
> >>> This allows passing OpenCL frames to AMF without a download/upload
> >>> step to get around AMD's lack of support for D3D11 mapping.
> >>>
> >>> For example:
> >>>
> >>> ./ffmpeg -hwaccel dxva2 -hwaccel_output_format dxva2_vld -i
> >>> input.mp4 -an -vf
> >>>
> >>
> 'hwmap=derive_device=opencl,program_opencl=source=examples.cl:kernel=
> >>> rotate_image' -c:v h264_amf output.mp4
> >>>
> >>> * I can't find any documentation or examples for these functions, so
> >>> I'm guessing a bit exactly how they are meant to work.  In
> >>> particular, there are some locking functions which I have ignored
> >>> because I have no idea under what circumstances something might want
> to be locked.
> >>> * I tried to write common parts with D3D11, but I might well have
> >>> broken
> >>> D3D11 support in the process - it doesn't work at all for me so I can't 
> >>> test
> it.
> >>> * Not sure how to get non-NV12 to work.  I may be missing something,
> >>> or it may just not be there - the trace messages suggest it doesn't
> >>> like the width of
> >>> RGB0 or the second plane of GRAY8.
> >>>
> >>> - Mark
> >>>
> >>>
> >>>  libavcodec/amfenc.c | 178
> >>> +++-
> >>> 
> >>>  libavcodec/amfenc.h |   1 +
> >>>  2 files changed, 123 insertions(+), 56 deletions(-)
> >>>
> >>> diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c index
> >>> 89a10ff253..220cdd278f 100644
> >>> --- a/libavcodec/amfenc.c
> >>> +++ b/libavcodec/amfenc.c
> >>> @@ -24,6 +24,9 @@
> >>>  #if CONFIG_D3D11VA
> >>>  #include "libavutil/hwcontext_d3d11va.h"
> >>>  #endif
> >>> +#if CONFIG_OPENCL
> >>> +#include "libavutil/hwcontext_opencl.h"
> >>> +#endif
> >>>  #include "libavutil/mem.h"
> >>>  #include "libavutil/pixdesc.h"
> >>>  #include "libavutil/time.h"
> >>> @@ -51,6 +54,9 @@ const enum AVPixelFormat ff_amf_pix_fmts[] = {
> >>> #if CONFIG_D3D11VA
> >>>  AV_PIX_FMT_D3D11,
> >>>  #endif
> >>> +#if CONFIG_OPENCL
> >>> +AV_PIX_FMT_OPENCL,
> >>> +#endif
> >>>  AV_PIX_FMT_NONE
> >>>  };
> >>>
> >>> @@ -69,6 +75,7 @@ static const FormatMap format_map[] =
> >>>  { AV_PIX_FMT_YUV420P,AMF_SURFACE_YUV420P },
> >>>  { AV_PIX_FMT_YUYV422,AMF_SURFACE_YUY2 },
> >>>  { AV_PIX_FMT_D3D11,  AMF_SURFACE_NV12 },
> >>> +{ AV_PIX_FMT_OPENCL, AMF_SURFACE_NV12 },
> >>>  };
> >>>
> >>>
> >>> @@ -154,8 +161,9 @@ static int amf_load_library(AVCodecContext
> >>> *avctx)
> >>>
> >>>  static int amf_init_context(AVCodecContext *avctx)  {
> >>> -AmfContext *ctx = avctx->priv_data;
> >>> -AMF_RESULT  res = AMF_OK;
> >>> +AmfContext *ctx = avctx->priv_data;
> >>> +AMF_RESULT res;
> >>> +AVHWDeviceContext *hwdev = NULL;
> >>>
> >>>  // configure AMF logger
> >>>  // the return of these functions indicates old state and do not
> >>> affect behaviour @@ -173,59 +181,91 @@ static int
> >>> amf_init_context(AVCodecContext *avctx)
> >>>
> >>>  res = ctx->factory->pVtbl->CreateContext(ctx->factory, 
> >>> &ctx->context);
> >>>  AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN,
> >>> "CreateContext() failed with error %d\n", res);
> >>> -// try to reuse existing DX device
> >>> -#if CONFIG_D3D11VA
> >>> +
> >>> +// Attempt to initialise from an existing D3D11 or OpenCL device.
> >>>  if (avctx->hw_frames_ctx) {
> >>> -AVHWFramesContext *device_ctx = (AVHWFramesContext*)avctx-
>  hw_frames_ctx->data;
> >>> -if (device_ctx->device_ctx->type == AV_HWDEVICE_TYPE_D3D11VA)
> {
> >>> -if (amf_av_to_amf_format(device_ctx->sw_format) !=
> >>> AMF_SURFACE_UNKNOWN) {
> >>> -if (device_ctx->device_ctx->hwctx) {
> >>> -AVD3D11VADeviceContext *device_d3d11 =
> >>> (AVD3D11VADeviceContext *)device_ctx->device_ctx->hwctx;
> >>> -res = ctx->context->pVtbl->InitDX11(ctx->context,
> >> device_d3d11-
>  device, AMF_DX11_1);
> >>> -if (res == AMF_OK) {
> >>> -

Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input

2018-01-23 Thread Mark Thompson
On 23/01/18 15:31, Mironov, Mikhail wrote:
>> -Original Message-
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
>> Of Mark Thompson
>> Sent: January 23, 2018 10:21 AM
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input
>>
>> On 23/01/18 15:04, Mironov, Mikhail wrote:
 -Original Message-
 From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
>> Behalf
 Of Mark Thompson
 Sent: January 22, 2018 6:57 PM
 To: FFmpeg development discussions and patches >>> de...@ffmpeg.org>
 Subject: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input

 ---
 This allows passing OpenCL frames to AMF without a download/upload
 step to get around AMD's lack of support for D3D11 mapping.

 For example:

 ./ffmpeg -hwaccel dxva2 -hwaccel_output_format dxva2_vld -i input.mp4
 -an -vf

>> 'hwmap=derive_device=opencl,program_opencl=source=examples.cl:kernel=
 rotate_image' -c:v h264_amf output.mp4

 * I can't find any documentation or examples for these functions, so
 I'm guessing a bit exactly how they are meant to work.  In
 particular, there are some locking functions which I have ignored
 because I have no idea under what circumstances something might want
>> to be locked.
 * I tried to write common parts with D3D11, but I might well have
 broken
 D3D11 support in the process - it doesn't work at all for me so I can't 
 test
>> it.
 * Not sure how to get non-NV12 to work.  I may be missing something,
 or it may just not be there - the trace messages suggest it doesn't
 like the width of
 RGB0 or the second plane of GRAY8.

 - Mark


  libavcodec/amfenc.c | 178
 +++-
 
  libavcodec/amfenc.h |   1 +
  2 files changed, 123 insertions(+), 56 deletions(-)

 ...
>>>
>>> AMF encoder works via D3D9 or D3D11 only. AMF OpenCL support is done
>>> for possible integration with external image processing. Passing regular
>> OpenCL 2D images will cause mapping to system memory and copy.
>>> The fast way is to use interop:
>>> - Allocate last processing NV12 surface as D3D11 texture
>>> - iterop it into OpenCL
>>
>> This step doesn't work - AMD has no support for mapping NV12 D3D11
>> textures to OpenCL.  (That's why I wrote the patch at all.)
> 
> It does via OCL D3D11 Media extension. I use it inside AMF. 
> But for fast results the surface must be allocated with shared handle.

Where can I find details of that extension?  Currently we use the standard 
cl_khr_d3d11_sharing extension, which combines with Intel's 
cl_intel_d3d11_nv12_media_sharing for NV12 support (see code in 
hwcontext_opencl.c).

Allocating with shared handle (MISC_SHARED flags) is fine, Intel has that as a 
hard requirement and fails without it.

>>
>> Does D3D9 also work?  That does have the necessary support, but would
>> admittedly end up with the same multiple-mapping ugliness as does D3D9 ->
>> OpenCL -> D3D9 -> libmfx on Intel.
> 
> D3D9 also works more or less the same as D3D11.

Ok, thank you.

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


Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input

2018-01-23 Thread Mironov, Mikhail
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: January 23, 2018 10:50 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input
> 
> On 23/01/18 15:31, Mironov, Mikhail wrote:
> >> -Original Message-
> >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> >> Of Mark Thompson
> >> Sent: January 23, 2018 10:21 AM
> >> To: ffmpeg-devel@ffmpeg.org
> >> Subject: Re: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL
> >> input
> >>
> >> On 23/01/18 15:04, Mironov, Mikhail wrote:
>  -Original Message-
>  From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> >> Behalf
>  Of Mark Thompson
>  Sent: January 22, 2018 6:57 PM
>  To: FFmpeg development discussions and patches   de...@ffmpeg.org>
>  Subject: [FFmpeg-devel] [RFC] amfenc: Add support for OpenCL input
> 
>  ---
>  This allows passing OpenCL frames to AMF without a download/upload
>  step to get around AMD's lack of support for D3D11 mapping.
> 
>  For example:
> 
>  ./ffmpeg -hwaccel dxva2 -hwaccel_output_format dxva2_vld -i
>  input.mp4 -an -vf
> 
> >>
> 'hwmap=derive_device=opencl,program_opencl=source=examples.cl:kernel=
>  rotate_image' -c:v h264_amf output.mp4
> 
>  * I can't find any documentation or examples for these functions,
>  so I'm guessing a bit exactly how they are meant to work.  In
>  particular, there are some locking functions which I have ignored
>  because I have no idea under what circumstances something might
>  want
> >> to be locked.
>  * I tried to write common parts with D3D11, but I might well have
>  broken
>  D3D11 support in the process - it doesn't work at all for me so I
>  can't test
> >> it.
>  * Not sure how to get non-NV12 to work.  I may be missing
>  something, or it may just not be there - the trace messages suggest
>  it doesn't like the width of
>  RGB0 or the second plane of GRAY8.
> 
>  - Mark
> 
> 
>   libavcodec/amfenc.c | 178
>  +++-
>  
>   libavcodec/amfenc.h |   1 +
>   2 files changed, 123 insertions(+), 56 deletions(-)
> 
>  ...
> >>>
> >>> AMF encoder works via D3D9 or D3D11 only. AMF OpenCL support is
> done
> >>> for possible integration with external image processing. Passing
> >>> regular
> >> OpenCL 2D images will cause mapping to system memory and copy.
> >>> The fast way is to use interop:
> >>> - Allocate last processing NV12 surface as D3D11 texture
> >>> - iterop it into OpenCL
> >>
> >> This step doesn't work - AMD has no support for mapping NV12 D3D11
> >> textures to OpenCL.  (That's why I wrote the patch at all.)
> >
> > It does via OCL D3D11 Media extension. I use it inside AMF.
> > But for fast results the surface must be allocated with shared handle.
> 
> Where can I find details of that extension?  Currently we use the standard
> cl_khr_d3d11_sharing extension, which combines with Intel's
> cl_intel_d3d11_nv12_media_sharing for NV12 support (see code in
> hwcontext_opencl.c).

This Khronos D3D11 extension:
https://www.khronos.org/registry/OpenCL/sdk/2.0/docs/man/xhtml/clCreateFromD3D11Texture2DKHR.html

The only problem with this extension is that it does not allow to split NV12 
into two images: R and RG. I know this this is awkward but you can use AMF for 
such interop and split. 

> 
> Allocating with shared handle (MISC_SHARED flags) is fine, Intel has that as a
> hard requirement and fails without it.
> 

AMD will not fail but will do additional copies.

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


Re: [FFmpeg-devel] GSoC 2018

2018-01-23 Thread Pascal Massimino
Hi,

sorry for coming late to the game...

On Tue, Jan 9, 2018 at 10:27 AM, Thilo Borgmann 
wrote:

> Hi folks,
>
> yet again, the registration for Google Summer of Code 2018 has opened.
>
> Like in the previous years, we've setup an ideas page in our wiki:
> https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2018
>
> Same procedure as every year - we need to define more interesting tasks
> for students to apply for and fellow developers to mentor them. So please
> feel free to suggest a project and volunteer as mentor or backup mentor as
> you see fit. You are welcome to edit the wiki directly or just post your
> suggestion here.
>

Anyone interested in a project  around completing the animated-WebP support
in ffmpeg?
Hooking up libwebpmux / libwebpdemux libraries would be helpful.
There was a request some times ago:
https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2017-October/218547.html

I can help with the libwebp interfacing.

thx
skal/


>
> Please keep in mind that a potential student should be able to finish the
> project successfully in time.
>
> GSoC offers a lot of potential gain for FFmpeg as it brings in new
> contributors that might become active developers in our community
> afterwards. So dedicating some of our time to mentor as many projects as we
> should be in our best interest.
>
> The application deadline is January 23th which is exactly two weeks from
> now. Therefore, let's try to define new tasks soon.
>
> Thanks,
> Thilo
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat: add option to parse/store ID3 PRIV tags in metadata.

2018-01-23 Thread rshaffer
From: Richard Shaffer 

Enables getting access to ID3 PRIV tags from the command-line or metadata API
when demuxing. The PRIV owner is stored as the metadata key prepended with
"id3v2_priv.", and the data is stored as the metadata value. As PRIV tags may
contain arbitrary data, non-printable characters, including NULL bytes, are
escaped as \xXX.

Similarly, any metadata tags that begin with "id3v2_priv." are inserted as ID3
PRIV tags into the output (assuming the format supports ID3). \xXX sequences in
the value are un-escaped to their byte value.
---
Whitespace changes re Moritz' comments on code format.

 libavformat/id3v2.c| 48 
 libavformat/id3v2.h| 15 +
 libavformat/id3v2enc.c | 60 ++
 libavformat/utils.c|  2 ++
 4 files changed, 125 insertions(+)

diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 6c216ba7a2..b80178d67a 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -33,6 +33,7 @@
 #endif
 
 #include "libavutil/avstring.h"
+#include "libavutil/bprint.h"
 #include "libavutil/dict.h"
 #include "libavutil/intreadwrite.h"
 #include "avio_internal.h"
@@ -1224,3 +1225,50 @@ end:
 av_freep(&chapters);
 return ret;
 }
+
+int ff_id3v2_parse_priv_dict(AVDictionary **metadata, ID3v2ExtraMeta 
**extra_meta)
+{
+ID3v2ExtraMeta *cur;
+int dict_flags = AV_DICT_DONT_OVERWRITE | AV_DICT_DONT_STRDUP_KEY | 
AV_DICT_DONT_STRDUP_VAL;
+
+for (cur = *extra_meta; cur; cur = cur->next) {
+if (!strcmp(cur->tag, "PRIV")) {
+ID3v2ExtraMetaPRIV *priv = cur->data;
+AVBPrint bprint;
+char *escaped, *key;
+int i, ret;
+
+if ((key = av_asprintf(ID3v2_PRIV_METADATA_PREFIX "%s", 
priv->owner)) == NULL) {
+return AVERROR(ENOMEM);
+}
+
+av_bprint_init(&bprint, priv->datasize + 1, 
AV_BPRINT_SIZE_UNLIMITED);
+
+for (i = 0; i < priv->datasize; i++) {
+if (priv->data[i] < 32 || priv->data[i] > 126 || priv->data[i] 
== '\\') {
+av_bprintf(&bprint, "\\x%02x", priv->data[i]);
+} else {
+av_bprint_chars(&bprint, priv->data[i], 1);
+}
+}
+
+if ((ret = av_bprint_finalize(&bprint, &escaped)) < 0) {
+av_free(key);
+return ret;
+}
+
+if ((ret = av_dict_set(metadata, key, escaped, dict_flags)) < 0) {
+av_free(key);
+av_free(escaped);
+return ret;
+}
+}
+}
+
+return 0;
+}
+
+int ff_id3v2_parse_priv(AVFormatContext *s, ID3v2ExtraMeta **extra_meta)
+{
+return ff_id3v2_parse_priv_dict(&s->metadata, extra_meta);
+}
diff --git a/libavformat/id3v2.h b/libavformat/id3v2.h
index 5e64ead096..9de0bee374 100644
--- a/libavformat/id3v2.h
+++ b/libavformat/id3v2.h
@@ -39,6 +39,8 @@
 #define ID3v2_FLAG_ENCRYPTION  0x0004
 #define ID3v2_FLAG_COMPRESSION 0x0008
 
+#define ID3v2_PRIV_METADATA_PREFIX "id3v2_priv."
+
 enum ID3v2Encoding {
 ID3v2_ENCODING_ISO8859  = 0,
 ID3v2_ENCODING_UTF16BOM = 1,
@@ -167,6 +169,19 @@ int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta 
**extra_meta);
  */
 int ff_id3v2_parse_chapters(AVFormatContext *s, ID3v2ExtraMeta **extra_meta);
 
+/**
+ * Parse PRIV tags into a dictionary. The PRIV owner is the metadata key. The
+ * PRIV data is the value, with non-printable characters escaped.
+ */
+int ff_id3v2_parse_priv_dict(AVDictionary **d, ID3v2ExtraMeta **extra_meta);
+
+/**
+ * Add metadata for all PRIV tags in the ID3v2 header. The PRIV owner is the
+ * metadata key. The PRIV data is the value, with non-printable characters
+ * escaped.
+ */
+int ff_id3v2_parse_priv(AVFormatContext *s, ID3v2ExtraMeta **extra_meta);
+
 extern const AVMetadataConv ff_id3v2_34_metadata_conv[];
 extern const AVMetadataConv ff_id3v2_4_metadata_conv[];
 
diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c
index 14de76ac06..ffe358f019 100644
--- a/libavformat/id3v2enc.c
+++ b/libavformat/id3v2enc.c
@@ -96,6 +96,59 @@ static int id3v2_put_ttag(ID3v2EncContext *id3, AVIOContext 
*avioc, const char *
 return len + ID3v2_HEADER_SIZE;
 }
 
+/**
+ * Write a priv frame with owner and data. 'key' is the owner prepended with
+ * ID3v2_PRIV_METADATA_PREFIX. 'data' is provided as a string. Any \xXX
+ * (where 'X' is a valid hex digit) will be unescaped to the byte value.
+ */
+static int id3v2_put_priv(ID3v2EncContext *id3, AVIOContext *avioc, const char 
*key, const char *data)
+{
+int len;
+uint8_t *pb;
+AVIOContext *dyn_buf;
+
+if (!av_strstart(key, ID3v2_PRIV_METADATA_PREFIX, &key)) {
+return 0;
+}
+
+if (avio_open_dyn_buf(&dyn_buf) < 0)
+return AVERROR(ENOMEM);
+
+// owner + null byte.
+avio_write(dyn_buf, key, strlen(key) + 1);
+
+while (*data) {
+if (av_strstart(

[FFmpeg-devel] [PATCH] fate: add id3v2 tests

2018-01-23 Thread rshaffer
From: Richard Shaffer 

Adds basic unit tests for parsing and writing ID3v2 tags.
---
This requires the patch to "add option to parse/store ID3 PRIV tags in
metadata."

 libavformat/Makefile |   3 +-
 libavformat/tests/.gitignore |   1 +
 libavformat/tests/id3v2.c| 229 +++
 tests/fate/libavformat.mak   |   4 +
 tests/ref/fate/id3v2 |   4 +
 5 files changed, 240 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/tests/id3v2.c
 create mode 100644 tests/ref/fate/id3v2

diff --git a/libavformat/Makefile b/libavformat/Makefile
index de0de921c2..753edd9cd5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -609,7 +609,8 @@ SLIBOBJS-$(HAVE_GNU_WINDRES) += avformatres.o
 SKIPHEADERS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh.h
 SKIPHEADERS-$(CONFIG_NETWORK)+= network.h rtsp.h
 
-TESTPROGS = seek\
+TESTPROGS = id3v2   \
+seek\
 url \
 #   async   \
 
diff --git a/libavformat/tests/.gitignore b/libavformat/tests/.gitignore
index 7ceb7a356b..5a06704afd 100644
--- a/libavformat/tests/.gitignore
+++ b/libavformat/tests/.gitignore
@@ -1,4 +1,5 @@
 /fifo_muxer
+/id3v2
 /movenc
 /noproxy
 /rtmpdh
diff --git a/libavformat/tests/id3v2.c b/libavformat/tests/id3v2.c
new file mode 100644
index 00..9efd0f9011
--- /dev/null
+++ b/libavformat/tests/id3v2.c
@@ -0,0 +1,229 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+
+#include "libavformat/avio.h"
+#include "libavformat/avio_internal.h"
+#include "libavformat/id3v2.h"
+#include "libavutil/dict.h"
+
+static int tag_equal(AVDictionary *meta, const char * tag, const char * value)
+{
+int failures = 0;
+AVDictionaryEntry *entry = av_dict_get(meta, tag, NULL, 0);
+if (!entry) {
+failures++;
+fprintf(stderr, "expected metadata tag '%s' not found\n", tag);
+}
+if (strcmp(entry->value, value)) {
+failures++;
+fprintf(stderr, "metadata tag '%s' has value '%s'; expected '%s'\n",
+tag, entry->value, value);
+}
+return failures;
+}
+
+static int test_id3v2_read()
+{
+uint8_t buf[] = {
+'I', 'D', '3', /*ver*/ 4, 0, /*flags*/ 0, /*size*/ 0, 0, 0, 53,
+
+'T', 'I', 'T', '2', /*size*/ 0, 0, 0, 12, /*flags*/ 0, 0, /*utf8*/ 3,
+'T', 'e', 's', 't', ' ', 'T', 'i', 't', 'l', 'e', 0,
+
+'P', 'R', 'I', 'V', /* size */ 0, 0, 0, 21, /*flags*/ 0, 0,
+'t', 'e', 's', 't', 'o', 'w', 'n', 'e', 'r', 0,
+'t', 'e', 's', 't', 'd', 'a', 't', 'a', /*some extra data*/ 0, 1, 2,
+};
+int failures = 0;
+AVIOContext io;
+AVDictionary *meta = NULL;
+ID3v2ExtraMeta *extra_meta = NULL;
+
+ffio_init_context(&io, buf, sizeof(buf), 0, NULL, NULL, NULL, NULL);
+
+ff_id3v2_read_dict(&io, &meta, ID3v2_DEFAULT_MAGIC, &extra_meta);
+ff_id3v2_parse_priv_dict(&meta, &extra_meta);
+
+failures += tag_equal(meta, "title", "Test Title");
+failures += tag_equal(meta, ID3v2_PRIV_METADATA_PREFIX "testowner",
+ "testdata\\x00\\x01\\x02");
+
+av_dict_free(&meta);
+ff_id3v2_free_extra_meta(&extra_meta);
+return failures;
+}
+
+static int check_header(const uint8_t *buf, size_t buflen, const char * magic, 
int version, int size)
+{
+int failures = 0;
+int i, s;
+if (buflen < 10) {
+fprintf(stderr, "id3v2 wrote short header\n");
+return 1;
+}
+if (memcmp(buf, magic, 3)) {
+failures++;
+fprintf(stderr, "id3v2 wrote magic '%.3s'; expected '%s'\n", magic, 
buf);
+}
+if (buf[3] != version || buf[4] != 0) {
+failures++;
+fprintf(stderr, "id3v2 wrote version %d.%d; expected 4.0\n", buf[3], 
buf[4]);
+}
+if (buf[5]) {
+failures++;
+fprintf(stderr, "id3v2 wrote flags %#x; expected 0x0\n", buf[5]);
+}
+for (i = 6, s = 0; i < 10; i++) {
+if (buf[i] & 0x80) {
+failures++;
+ 

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/hevc_cabac: Move prefix check in coeff_abs_level_remaining_decode() down

2018-01-23 Thread Michael Niedermayer
On Tue, Jan 16, 2018 at 12:37:27AM +0100, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/hevc_cabac.c | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)

applied

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

If you drop bombs on a foreign country and kill a hundred thousand
innocent people, expect your government to call the consequence
"unprovoked inhuman terrorist attacks" and use it to justify dropping
more bombs and killing more people. The technology changed, the idea is old.


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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/hevc_cabac: Check prefix so as to avoid invalid shifts in coeff_abs_level_remaining_decode()

2018-01-23 Thread Michael Niedermayer
On Tue, Jan 16, 2018 at 12:37:28AM +0100, Michael Niedermayer wrote:
> I suspect that this can be limited tighter, but i failed to find anything
> in the spec that would confirm that.
> 
> Fixes: 4833/clusterfuzz-testcase-minimized-5302840101699584
> Fixes: runtime error: left shift of 134217730 by 4 places cannot be 
> represented in type 'int'
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/hevc_cabac.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply this in a few days unless someone wants me to wait

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf


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


Re: [FFmpeg-devel] [PATCH] avutil/aes_ctr: Add method to set 16-byte IV.

2018-01-23 Thread Michael Niedermayer
On Mon, Jan 08, 2018 at 02:12:43PM -0800, Jacob Trimble wrote:
> Signed-off-by: Jacob Trimble 
> ---
>  doc/APIchanges| 3 +++
>  libavutil/aes_ctr.c   | 6 ++
>  libavutil/aes_ctr.h   | 7 ++-
>  libavutil/tests/aes_ctr.c | 2 +-
>  libavutil/version.h   | 2 +-
>  5 files changed, 17 insertions(+), 3 deletions(-)

will apply

thanks

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

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire


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


Re: [FFmpeg-devel] [PATCH] avcodec/dxtory: Fix bits left checks

2018-01-23 Thread Michael Niedermayer
On Mon, Jan 22, 2018 at 10:25:21PM +0100, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 4863/clusterfuzz-testcase-6347354178322432
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/dxtory.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)

applied

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

You can kill me, but you cannot change the truth.


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


Re: [FFmpeg-devel] [PATCH] fate: add id3v2 tests

2018-01-23 Thread wm4
On Tue, 23 Jan 2018 09:54:38 -0800
rshaf...@tunein.com wrote:

> From: Richard Shaffer 
> 
> Adds basic unit tests for parsing and writing ID3v2 tags.
> ---
> This requires the patch to "add option to parse/store ID3 PRIV tags in
> metadata."
> 
>  libavformat/Makefile |   3 +-
>  libavformat/tests/.gitignore |   1 +
>  libavformat/tests/id3v2.c| 229 
> +++
>  tests/fate/libavformat.mak   |   4 +
>  tests/ref/fate/id3v2 |   4 +
>  5 files changed, 240 insertions(+), 1 deletion(-)
>  create mode 100644 libavformat/tests/id3v2.c
>  create mode 100644 tests/ref/fate/id3v2
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index de0de921c2..753edd9cd5 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -609,7 +609,8 @@ SLIBOBJS-$(HAVE_GNU_WINDRES) += avformatres.o
>  SKIPHEADERS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh.h
>  SKIPHEADERS-$(CONFIG_NETWORK)+= network.h rtsp.h
>  
> -TESTPROGS = seek\
> +TESTPROGS = id3v2   \
> +seek\
>  url \
>  #   async   \
>  
> diff --git a/libavformat/tests/.gitignore b/libavformat/tests/.gitignore
> index 7ceb7a356b..5a06704afd 100644
> --- a/libavformat/tests/.gitignore
> +++ b/libavformat/tests/.gitignore
> @@ -1,4 +1,5 @@
>  /fifo_muxer
> +/id3v2
>  /movenc
>  /noproxy
>  /rtmpdh
> diff --git a/libavformat/tests/id3v2.c b/libavformat/tests/id3v2.c
> new file mode 100644
> index 00..9efd0f9011
> --- /dev/null
> +++ b/libavformat/tests/id3v2.c
> @@ -0,0 +1,229 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include 
> +#include 
> +
> +#include "libavformat/avio.h"
> +#include "libavformat/avio_internal.h"
> +#include "libavformat/id3v2.h"
> +#include "libavutil/dict.h"
> +
> +static int tag_equal(AVDictionary *meta, const char * tag, const char * 
> value)
> +{
> +int failures = 0;
> +AVDictionaryEntry *entry = av_dict_get(meta, tag, NULL, 0);
> +if (!entry) {
> +failures++;
> +fprintf(stderr, "expected metadata tag '%s' not found\n", tag);
> +}
> +if (strcmp(entry->value, value)) {
> +failures++;
> +fprintf(stderr, "metadata tag '%s' has value '%s'; expected '%s'\n",
> +tag, entry->value, value);
> +}
> +return failures;
> +}
> +
> +static int test_id3v2_read()

In C, functions with no arguments need to use (void). Just using () has
the legacy meaning of "accepts any arguments", which should never be
used.

> +{
> +uint8_t buf[] = {
> +'I', 'D', '3', /*ver*/ 4, 0, /*flags*/ 0, /*size*/ 0, 0, 0, 53,
> +
> +'T', 'I', 'T', '2', /*size*/ 0, 0, 0, 12, /*flags*/ 0, 0, /*utf8*/ 3,
> +'T', 'e', 's', 't', ' ', 'T', 'i', 't', 'l', 'e', 0,
> +
> +'P', 'R', 'I', 'V', /* size */ 0, 0, 0, 21, /*flags*/ 0, 0,
> +'t', 'e', 's', 't', 'o', 'w', 'n', 'e', 'r', 0,
> +'t', 'e', 's', 't', 'd', 'a', 't', 'a', /*some extra data*/ 0, 1, 2,
> +};
> +int failures = 0;
> +AVIOContext io;
> +AVDictionary *meta = NULL;
> +ID3v2ExtraMeta *extra_meta = NULL;
> +
> +ffio_init_context(&io, buf, sizeof(buf), 0, NULL, NULL, NULL, NULL);
> +
> +ff_id3v2_read_dict(&io, &meta, ID3v2_DEFAULT_MAGIC, &extra_meta);
> +ff_id3v2_parse_priv_dict(&meta, &extra_meta);
> +
> +failures += tag_equal(meta, "title", "Test Title");
> +failures += tag_equal(meta, ID3v2_PRIV_METADATA_PREFIX "testowner",
> + "testdata\\x00\\x01\\x02");
> +
> +av_dict_free(&meta);
> +ff_id3v2_free_extra_meta(&extra_meta);
> +return failures;
> +}
> +
> +static int check_header(const uint8_t *buf, size_t buflen, const char * 
> magic, int version, int size)
> +{
> +int failures = 0;
> +int i, s;
> +if (buflen < 10) {
> +fprintf(stderr, "id3v2 wrote short header\n");
> +return 1;
> +}
> +if (memcmp(buf, magic, 3)) {
> +f

Re: [FFmpeg-devel] [PATCH] MAINTAINERS: Adding myself as dashenc maintainer

2018-01-23 Thread Michael Niedermayer
On Sun, Jan 21, 2018 at 09:56:12AM +0530, Karthick J wrote:
> From: Karthick Jeyapal 
> 
> If somebody else wants to maintain dashenc either now or in future,
> I am absolutely fine with giving up this responsibility anytime.
> But till then we need a maintainer for dashenc, and I am volunteering for 
> that task.
> ---
>  MAINTAINERS | 1 +
>  1 file changed, 1 insertion(+)

applied

thanks

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

It is what and why we do it that matters, not just one of them.


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


Re: [FFmpeg-devel] GSoC 2018

2018-01-23 Thread Carl Eugen Hoyos
2018-01-23 18:27 GMT+01:00 Pascal Massimino :

> Anyone interested in a project  around completing the animated-WebP
> support in ffmpeg?

Please consider to add the project and yourself as mentor
in the wiki:
https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2018

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


Re: [FFmpeg-devel] [PATCH 3/4] lavfi/procamp_vaapi: fix the green output issue.

2018-01-23 Thread Carl Eugen Hoyos
2018-01-23 5:33 GMT+01:00 Jun Zhao :

> -procamp_params[i].type   = VAProcFilterColorBalance;

> +procamp_params[i].type   = VAProcFilterColorBalance;

Please split this patch, so that functional change and re-indentation
of a large block do not happen in the same patch: This not only
makes reviewing easier, it also simplifies understanding the
patch at a later time.

While there, I suggest you post one patch to change the typos
in all files without non-typo changes.

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


Re: [FFmpeg-devel] GSoC 2018

2018-01-23 Thread James Almer
On 1/23/2018 2:27 PM, Pascal Massimino wrote:
> Hi,
> 
> sorry for coming late to the game...
> 
> On Tue, Jan 9, 2018 at 10:27 AM, Thilo Borgmann 
> wrote:
> 
>> Hi folks,
>>
>> yet again, the registration for Google Summer of Code 2018 has opened.
>>
>> Like in the previous years, we've setup an ideas page in our wiki:
>> https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2018
>>
>> Same procedure as every year - we need to define more interesting tasks
>> for students to apply for and fellow developers to mentor them. So please
>> feel free to suggest a project and volunteer as mentor or backup mentor as
>> you see fit. You are welcome to edit the wiki directly or just post your
>> suggestion here.
>>
> 
> Anyone interested in a project  around completing the animated-WebP support
> in ffmpeg?
> Hooking up libwebpmux / libwebpdemux libraries would be helpful.

The WebPAnimEncoder API from libwebpmux is already supported to encode
animated WebP (libwebp_anim encoder). The native muxer writes the
packets untouched in that case instead of writing the ANIM headers itself.

> There was a request some times ago:
> https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2017-October/218547.html
> 
> I can help with the libwebp interfacing.
> 
> thx
> skal/

Ideally, a GSoC project would add ANIM support to the native decoder
rather than adding a new decoder based on the WebPAnimDecoder
libwebpdemux API, but at least one of the two should definitely be
implemented.

Thanks.

> 
> 
>>
>> Please keep in mind that a potential student should be able to finish the
>> project successfully in time.
>>
>> GSoC offers a lot of potential gain for FFmpeg as it brings in new
>> contributors that might become active developers in our community
>> afterwards. So dedicating some of our time to mentor as many projects as we
>> should be in our best interest.
>>
>> The application deadline is January 23th which is exactly two weeks from
>> now. Therefore, let's try to define new tasks soon.
>>
>> Thanks,
>> Thilo
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 

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


Re: [FFmpeg-devel] [PATCH 3/4] lavfi/procamp_vaapi: fix the green output issue.

2018-01-23 Thread Jun Zhao


On 2018/1/24 7:52, Carl Eugen Hoyos wrote:
> 2018-01-23 5:33 GMT+01:00 Jun Zhao :
>
>> -procamp_params[i].type   = VAProcFilterColorBalance;
>> +procamp_params[i].type   = VAProcFilterColorBalance;
> Please split this patch, so that functional change and re-indentation
> of a large block do not happen in the same patch: This not only
> makes reviewing easier, it also simplifies understanding the
> patch at a later time.
>
> While there, I suggest you post one patch to change the typos
> in all files without non-typo changes.
Thanks the suggestion and comments, carl, will submit V2 follow.
>
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] rtmp: Plug leak if sending bytes read report fails.

2018-01-23 Thread Josh Allmann
---
 libavformat/rtmpproto.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index faf2a6f244..b741e421af 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -2431,8 +2431,10 @@ static int get_packet(URLContext *s, int for_header)
 rt->bytes_read += ret;
 if (rt->bytes_read - rt->last_bytes_read > rt->receive_report_size) {
 av_log(s, AV_LOG_DEBUG, "Sending bytes read report\n");
-if ((ret = gen_bytes_read(s, rt, rpkt.timestamp + 1)) < 0)
+if ((ret = gen_bytes_read(s, rt, rpkt.timestamp + 1)) < 0) {
+ff_rtmp_packet_destroy(&rpkt);
 return ret;
+}
 rt->last_bytes_read = rt->bytes_read;
 }
 
-- 
2.14.2

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


Re: [FFmpeg-devel] [PATCH] fate: add id3v2 tests

2018-01-23 Thread Richard Shaffer
On Tue, Jan 23, 2018 at 2:32 PM, wm4  wrote:

>
> I think this test program is pretty nice, though usually we try to get
> by with running the "ffmpeg" utility to test the libs. Having a
> relatively big program to test some obscure functionality might have a
> maintenance burden. I'm not sure how others feel about it; if nobody
> has a strong opinion on this I'll probably apply this in a week or so.
>

It's definitely not my desire to create a maintenance burden for anyone. I
used the ffmpeg utility initially to test my changes, and I'm sure that
shell scripting would have been easier than writing a C program.

There were pretty good templates for other test programs, but I didn't come
across a collection of shell scripts or Makefile targets that seemed to
illustrate a clear pattern. I'll look a little harder. If there is a
pointer to an example test, though, that would probably be useful.

Thanks,

-Richard

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


[FFmpeg-devel] [PATCH] avformat/hlsenc: Check ret on avformat_write_header

2018-01-23 Thread Brendan McGrath
Encoding currently fails when using hls_ts_options with the fmp4
segment type.

This is due to the fact that avformat_write_header does not process
the passed options when the avformat is already initialized.

When using fmp4, the hls_ts_options are parsed and the avformat
initialized within hls_mux_init.

This patch checks the return of avformat_write_header so that if
it is greater than zero (indicating the avformat is already
initialized) then it does not error.

Signed-off-by: Brendan McGrath 
---
I'm not sure if hls_ts_options is supposed to be used with fmp4 as the
description is currently:
hls_ts_options E... set hls mpegts list of options for the 
container format used for hls

If it is (and the code within hls_mux_init seems to indicate that it is) - then 
this
patch fixes that (and the next will change the description - perhaps the option 
should
be renamed too?).

I also considered checking if ret was < 0 and erroring immediately rather than 
relying
on av_dict_count. But I wasn't sure if that check had been intentionally left 
out
so the av_dict_free would take place.

Let me know if the preference is for another if statement for ret < 0.

 libavformat/hlsenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 42e437f..d83d3b9 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1878,7 +1878,7 @@ static int hls_write_header(AVFormatContext *s)
 
 av_dict_copy(&options, hls->format_options, 0);
 ret = avformat_write_header(vs->avf, &options);
-if (av_dict_count(options)) {
+if (ret <= 0 && av_dict_count(options)) {
 av_log(s, AV_LOG_ERROR, "Some of provided format options in '%s' 
are not recognized\n", hls->format_options_str);
 ret = AVERROR(EINVAL);
 av_dict_free(&options);
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH] fate: add id3v2 tests

2018-01-23 Thread wm4
On Tue, 23 Jan 2018 17:03:26 -0800
Richard Shaffer  wrote:

> On Tue, Jan 23, 2018 at 2:32 PM, wm4  wrote:
> 
> >
> > I think this test program is pretty nice, though usually we try to get
> > by with running the "ffmpeg" utility to test the libs. Having a
> > relatively big program to test some obscure functionality might have a
> > maintenance burden. I'm not sure how others feel about it; if nobody
> > has a strong opinion on this I'll probably apply this in a week or so.
> >  
> 
> It's definitely not my desire to create a maintenance burden for anyone. I
> used the ffmpeg utility initially to test my changes, and I'm sure that
> shell scripting would have been easier than writing a C program.
> 
> There were pretty good templates for other test programs, but I didn't come
> across a collection of shell scripts or Makefile targets that seemed to
> illustrate a clear pattern. I'll look a little harder. If there is a
> pointer to an example test, though, that would probably be useful.

Most FATE tests use some sort of ffmpeg CLI invocation via shell, but
it's pretty cryptic. Not sure what's a good example.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] fate: add id3v2 tests

2018-01-23 Thread James Almer
On 1/23/2018 10:46 PM, wm4 wrote:
> On Tue, 23 Jan 2018 17:03:26 -0800
> Richard Shaffer  wrote:
> 
>> On Tue, Jan 23, 2018 at 2:32 PM, wm4  wrote:
>>
>>>
>>> I think this test program is pretty nice, though usually we try to get
>>> by with running the "ffmpeg" utility to test the libs. Having a
>>> relatively big program to test some obscure functionality might have a
>>> maintenance burden. I'm not sure how others feel about it; if nobody
>>> has a strong opinion on this I'll probably apply this in a week or so.
>>>  
>>
>> It's definitely not my desire to create a maintenance burden for anyone. I
>> used the ffmpeg utility initially to test my changes, and I'm sure that
>> shell scripting would have been easier than writing a C program.
>>
>> There were pretty good templates for other test programs, but I didn't come
>> across a collection of shell scripts or Makefile targets that seemed to
>> illustrate a clear pattern. I'll look a little harder. If there is a
>> pointer to an example test, though, that would probably be useful.
> 
> Most FATE tests use some sort of ffmpeg CLI invocation via shell, but
> it's pretty cryptic. Not sure what's a good example.

ffprobe -show_format is probably best for an id3v2 tag. Add a new
probeformat() function to fate-run.sh like

probeformat(){
run ffprobe${PROGSUF} -show_format -v 0 "$@"
}

Then call it with the sample in question a argument. See how exif.mak
uses probeframes().
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH V2 1/3] lavfi/vf_xxx_vaapi: fix typo.

2018-01-23 Thread Jun Zhao
V2: split the patches as carl's comments
From 6e6b2cdf8f7f8e0452ab93834f35671e91b922da Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Wed, 24 Jan 2018 08:40:59 +0800
Subject: [PATCH V2 1/3] lavfi/vf_xxx_vaapi: fix typo.

Signed-off-by: Jun Zhao 
---
 libavfilter/vf_deinterlace_vaapi.c | 2 +-
 libavfilter/vf_misc_vaapi.c| 4 ++--
 libavfilter/vf_procamp_vaapi.c | 2 +-
 libavfilter/vf_scale_vaapi.c   | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_deinterlace_vaapi.c 
b/libavfilter/vf_deinterlace_vaapi.c
index 9700f85817..f7a262d0c6 100644
--- a/libavfilter/vf_deinterlace_vaapi.c
+++ b/libavfilter/vf_deinterlace_vaapi.c
@@ -33,7 +33,7 @@
 #define MAX_REFERENCES 8
 
 typedef struct DeintVAAPIContext {
-VAAPIVPPContext vpp_ctx; // must be the first fileld
+VAAPIVPPContext vpp_ctx; // must be the first field
 
 intmode;
 intfield_rate;
diff --git a/libavfilter/vf_misc_vaapi.c b/libavfilter/vf_misc_vaapi.c
index 316f15e38b..c60b7b0c48 100644
--- a/libavfilter/vf_misc_vaapi.c
+++ b/libavfilter/vf_misc_vaapi.c
@@ -38,13 +38,13 @@
 #define SHARPNESS_DEFAULT  44
 
 typedef struct DenoiseVAAPIContext {
-VAAPIVPPContext vpp_ctx; // must be the first fileld
+VAAPIVPPContext vpp_ctx; // must be the first field
 
 int denoise; // enable denoise algo.
 } DenoiseVAAPIContext;
 
 typedef struct SharpnessVAAPIContext {
-VAAPIVPPContext vpp_ctx; // must be the first fileld
+VAAPIVPPContext vpp_ctx; // must be the first field
 
 int sharpness;   // enable sharpness.
 } SharpnessVAAPIContext;
diff --git a/libavfilter/vf_procamp_vaapi.c b/libavfilter/vf_procamp_vaapi.c
index 10f9a6ba0c..aad76aa371 100644
--- a/libavfilter/vf_procamp_vaapi.c
+++ b/libavfilter/vf_procamp_vaapi.c
@@ -47,7 +47,7 @@
 #define EPSILON   0.1F
 
 typedef struct ProcampVAAPIContext {
-VAAPIVPPContext vpp_ctx; // must be the first fileld
+VAAPIVPPContext vpp_ctx; // must be the first field
 
 float bright;
 float hue;
diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
index d349ff0f90..c19e23ccd0 100644
--- a/libavfilter/vf_scale_vaapi.c
+++ b/libavfilter/vf_scale_vaapi.c
@@ -31,7 +31,7 @@
 #include "vaapi_vpp.h"
 
 typedef struct ScaleVAAPIContext {
-VAAPIVPPContext vpp_ctx; // must be the first fileld
+VAAPIVPPContext vpp_ctx; // must be the first field
 
 char *output_format_string;
 
-- 
2.14.1

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


[FFmpeg-devel] [PATCH V2 2/3] lavfi/procamp_vaapi: fix the green video issue if without arguments.

2018-01-23 Thread Jun Zhao

From 1d3b388c313881e931928dc4049896265919725d Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Wed, 24 Jan 2018 09:28:24 +0800
Subject: [PATCH V2 2/3] lavfi/procamp_vaapi: fix the green video issue if
 without arguments.

Fix the green output issue when use procamp_vaapi without any
arguments, now if use procamp_vaapi without any arguments, will use
the default value to setting procamp_vaapi.

Signed-off-by: Jun Zhao 
---
 libavfilter/vf_procamp_vaapi.c | 73 ++
 1 file changed, 31 insertions(+), 42 deletions(-)

diff --git a/libavfilter/vf_procamp_vaapi.c b/libavfilter/vf_procamp_vaapi.c
index aad76aa371..45a3120b23 100644
--- a/libavfilter/vf_procamp_vaapi.c
+++ b/libavfilter/vf_procamp_vaapi.c
@@ -44,8 +44,6 @@
 #define SATURATION_MAX   10.0F
 #define SATURATION_DEFAULT1.0F
 
-#define EPSILON   0.1F
-
 typedef struct ProcampVAAPIContext {
 VAAPIVPPContext vpp_ctx; // must be the first field
 
@@ -65,11 +63,6 @@ static float map(float x, float in_min, float in_max, float 
out_min, float out_m
 return (float)output;
 }
 
-static int fequal(float a, float b)
-{
-return fabs(a-b) < EPSILON;
-}
-
 static int procamp_vaapi_build_filter_params(AVFilterContext *avctx)
 {
 VAAPIVPPContext *vpp_ctx = avctx->priv;
@@ -93,41 +86,37 @@ static int 
procamp_vaapi_build_filter_params(AVFilterContext *avctx)
 return AVERROR(EIO);
 }
 
-if (!fequal(ctx->bright, BRIGHTNESS_DEFAULT)) {
-procamp_params[i].type   = VAProcFilterColorBalance;
-procamp_params[i].attrib = VAProcColorBalanceBrightness;
-procamp_params[i].value  = map(ctx->bright, BRIGHTNESS_MIN, 
BRIGHTNESS_MAX,
-   
procamp_caps[VAProcColorBalanceBrightness-1].range.min_value,
-   
procamp_caps[VAProcColorBalanceBrightness-1].range.max_value);
-i++;
-}
-
-if (!fequal(ctx->contrast, CONTRAST_DEFAULT)) {
-procamp_params[i].type   = VAProcFilterColorBalance;
-procamp_params[i].attrib = VAProcColorBalanceContrast;
-procamp_params[i].value  = map(ctx->contrast, CONTRAST_MIN, 
CONTRAST_MAX,
-   
procamp_caps[VAProcColorBalanceContrast-1].range.min_value,
-   
procamp_caps[VAProcColorBalanceContrast-1].range.max_value);
-i++;
-}
-
-if (!fequal(ctx->hue, HUE_DEFAULT)) {
-procamp_params[i].type   = VAProcFilterColorBalance;
-procamp_params[i].attrib = VAProcColorBalanceHue;
-procamp_params[i].value  = map(ctx->hue, HUE_MIN, HUE_MAX,
-   
procamp_caps[VAProcColorBalanceHue-1].range.min_value,
-   
procamp_caps[VAProcColorBalanceHue-1].range.max_value);
-i++;
-}
-
-if (!fequal(ctx->saturation, SATURATION_DEFAULT)) {
-procamp_params[i].type   = VAProcFilterColorBalance;
-procamp_params[i].attrib = VAProcColorBalanceSaturation;
-procamp_params[i].value  = map(ctx->saturation, SATURATION_MIN, 
SATURATION_MAX,
-   
procamp_caps[VAProcColorBalanceSaturation-1].range.min_value,
-   
procamp_caps[VAProcColorBalanceSaturation-1].range.max_value);
-i++;
-}
+/* brightness */
+procamp_params[i].type   = VAProcFilterColorBalance;
+procamp_params[i].attrib = VAProcColorBalanceBrightness;
+procamp_params[i].value  = map(ctx->bright, BRIGHTNESS_MIN, BRIGHTNESS_MAX,
+   
procamp_caps[VAProcColorBalanceBrightness-1].range.min_value,
+   
procamp_caps[VAProcColorBalanceBrightness-1].range.max_value);
+i++;
+
+/* contrast */
+procamp_params[i].type   = VAProcFilterColorBalance;
+procamp_params[i].attrib = VAProcColorBalanceContrast;
+procamp_params[i].value  = map(ctx->contrast, CONTRAST_MIN, CONTRAST_MAX,
+   
procamp_caps[VAProcColorBalanceContrast-1].range.min_value,
+   
procamp_caps[VAProcColorBalanceContrast-1].range.max_value);
+i++;
+
+/* hue */
+procamp_params[i].type   = VAProcFilterColorBalance;
+procamp_params[i].attrib = VAProcColorBalanceHue;
+procamp_params[i].value  = map(ctx->hue, HUE_MIN, HUE_MAX,
+   
procamp_caps[VAProcColorBalanceHue-1].range.min_value,
+   
procamp_caps[VAProcColorBalanceHue-1].range.max_value);
+i++;
+
+/* saturation */
+procamp_params[i].type   = VAProcFilterColorBalance;
+procamp_params[i].attrib = VAProcColorBalanceSaturation;
+procamp_params[i].value  = map(ctx->saturation, SATURATION_MIN, 
SATURATION_MAX,
+   
procamp_caps[VAProcColorBalanceSaturation-1].range.min_value,
+   
procamp_caps[VAPro

[FFmpeg-devel] [PATCH V2 3/3] lavfi/misc_vaapi: use default value setting if without arguments.

2018-01-23 Thread Jun Zhao

From 7a4a53fcc5a9b31b11818976dc02ea8e004d2c5a Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Wed, 24 Jan 2018 09:32:50 +0800
Subject: [PATCH V2 3/3] lavfi/misc_vaapi: use default value setting if without
 arguments.

Signed-off-by: Jun Zhao 
---
 libavfilter/vf_misc_vaapi.c | 64 +
 1 file changed, 30 insertions(+), 34 deletions(-)

diff --git a/libavfilter/vf_misc_vaapi.c b/libavfilter/vf_misc_vaapi.c
index c60b7b0c48..8b179fe215 100644
--- a/libavfilter/vf_misc_vaapi.c
+++ b/libavfilter/vf_misc_vaapi.c
@@ -71,24 +71,22 @@ static int 
denoise_vaapi_build_filter_params(AVFilterContext *avctx)
 
 VAProcFilterParameterBuffer denoise;
 
-if (ctx->denoise != DENOISE_DEFAULT) {
-vas = vaQueryVideoProcFilterCaps(vpp_ctx->hwctx->display, 
vpp_ctx->va_context,
- VAProcFilterNoiseReduction,
- &caps, &num_caps);
-if (vas != VA_STATUS_SUCCESS) {
-av_log(avctx, AV_LOG_ERROR, "Failed to query denoise caps "
-   "context: %d (%s).\n", vas, vaErrorStr(vas));
-return AVERROR(EIO);
-}
-
-denoise.type  = VAProcFilterNoiseReduction;
-denoise.value =  map(ctx->denoise, DENOISE_MIN, DENOISE_MAX,
- caps.range.min_value,
- caps.range.max_value);
-ff_vaapi_vpp_make_param_buffers(avctx, VAProcFilterParameterBufferType,
-&denoise, sizeof(denoise), 1);
+vas = vaQueryVideoProcFilterCaps(vpp_ctx->hwctx->display, 
vpp_ctx->va_context,
+ VAProcFilterNoiseReduction,
+ &caps, &num_caps);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(avctx, AV_LOG_ERROR, "Failed to query denoise caps "
+   "context: %d (%s).\n", vas, vaErrorStr(vas));
+return AVERROR(EIO);
 }
 
+denoise.type  = VAProcFilterNoiseReduction;
+denoise.value =  map(ctx->denoise, DENOISE_MIN, DENOISE_MAX,
+ caps.range.min_value,
+ caps.range.max_value);
+ff_vaapi_vpp_make_param_buffers(avctx, VAProcFilterParameterBufferType,
+&denoise, sizeof(denoise), 1);
+
 return 0;
 }
 
@@ -104,26 +102,24 @@ static int 
sharpness_vaapi_build_filter_params(AVFilterContext *avctx)
 
 VAProcFilterParameterBuffer sharpness;
 
-if (ctx->sharpness != SHARPNESS_DEFAULT) {
-vas = vaQueryVideoProcFilterCaps(vpp_ctx->hwctx->display, 
vpp_ctx->va_context,
- VAProcFilterSharpening,
- &caps, &num_caps);
-if (vas != VA_STATUS_SUCCESS) {
-av_log(avctx, AV_LOG_ERROR, "Failed to query sharpness caps "
-   "context: %d (%s).\n", vas, vaErrorStr(vas));
-return AVERROR(EIO);
-}
-
-sharpness.type  = VAProcFilterSharpening;
-sharpness.value = map(ctx->sharpness,
-  SHARPNESS_MIN, SHARPNESS_MAX,
-  caps.range.min_value,
-  caps.range.max_value);
-ff_vaapi_vpp_make_param_buffers(avctx,
-VAProcFilterParameterBufferType,
-&sharpness, sizeof(sharpness), 1);
+vas = vaQueryVideoProcFilterCaps(vpp_ctx->hwctx->display, 
vpp_ctx->va_context,
+ VAProcFilterSharpening,
+ &caps, &num_caps);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(avctx, AV_LOG_ERROR, "Failed to query sharpness caps "
+   "context: %d (%s).\n", vas, vaErrorStr(vas));
+return AVERROR(EIO);
 }
 
+sharpness.type  = VAProcFilterSharpening;
+sharpness.value = map(ctx->sharpness,
+  SHARPNESS_MIN, SHARPNESS_MAX,
+  caps.range.min_value,
+  caps.range.max_value);
+ff_vaapi_vpp_make_param_buffers(avctx,
+VAProcFilterParameterBufferType,
+&sharpness, sizeof(sharpness), 1);
+
 return 0;
 }
 
-- 
2.14.1

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


Re: [FFmpeg-devel] [PATCH] avformat: add option to parse/store ID3 PRIV tags in metadata.

2018-01-23 Thread wm4
On Tue, 23 Jan 2018 09:39:53 -0800
rshaf...@tunein.com wrote:

> From: Richard Shaffer 
> 
> Enables getting access to ID3 PRIV tags from the command-line or metadata API
> when demuxing. The PRIV owner is stored as the metadata key prepended with
> "id3v2_priv.", and the data is stored as the metadata value. As PRIV tags may
> contain arbitrary data, non-printable characters, including NULL bytes, are
> escaped as \xXX.
> 
> Similarly, any metadata tags that begin with "id3v2_priv." are inserted as ID3
> PRIV tags into the output (assuming the format supports ID3). \xXX sequences 
> in
> the value are un-escaped to their byte value.
> ---
> Whitespace changes re Moritz' comments on code format.
> 
>  libavformat/id3v2.c| 48 
>  libavformat/id3v2.h| 15 +
>  libavformat/id3v2enc.c | 60 
> ++
>  libavformat/utils.c|  2 ++
>  4 files changed, 125 insertions(+)
> 
> diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
> index 6c216ba7a2..b80178d67a 100644
> --- a/libavformat/id3v2.c
> +++ b/libavformat/id3v2.c
> @@ -33,6 +33,7 @@
>  #endif
>  
>  #include "libavutil/avstring.h"
> +#include "libavutil/bprint.h"
>  #include "libavutil/dict.h"
>  #include "libavutil/intreadwrite.h"
>  #include "avio_internal.h"
> @@ -1224,3 +1225,50 @@ end:
>  av_freep(&chapters);
>  return ret;
>  }
> +
> +int ff_id3v2_parse_priv_dict(AVDictionary **metadata, ID3v2ExtraMeta 
> **extra_meta)
> +{
> +ID3v2ExtraMeta *cur;
> +int dict_flags = AV_DICT_DONT_OVERWRITE | AV_DICT_DONT_STRDUP_KEY | 
> AV_DICT_DONT_STRDUP_VAL;
> +
> +for (cur = *extra_meta; cur; cur = cur->next) {
> +if (!strcmp(cur->tag, "PRIV")) {
> +ID3v2ExtraMetaPRIV *priv = cur->data;
> +AVBPrint bprint;
> +char *escaped, *key;
> +int i, ret;
> +
> +if ((key = av_asprintf(ID3v2_PRIV_METADATA_PREFIX "%s", 
> priv->owner)) == NULL) {
> +return AVERROR(ENOMEM);
> +}
> +
> +av_bprint_init(&bprint, priv->datasize + 1, 
> AV_BPRINT_SIZE_UNLIMITED);
> +
> +for (i = 0; i < priv->datasize; i++) {
> +if (priv->data[i] < 32 || priv->data[i] > 126 || 
> priv->data[i] == '\\') {
> +av_bprintf(&bprint, "\\x%02x", priv->data[i]);
> +} else {
> +av_bprint_chars(&bprint, priv->data[i], 1);
> +}
> +}
> +
> +if ((ret = av_bprint_finalize(&bprint, &escaped)) < 0) {
> +av_free(key);
> +return ret;
> +}
> +
> +if ((ret = av_dict_set(metadata, key, escaped, dict_flags)) < 0) 
> {
> +av_free(key);
> +av_free(escaped);
> +return ret;
> +}
> +}
> +}
> +
> +return 0;
> +}
> +
> +int ff_id3v2_parse_priv(AVFormatContext *s, ID3v2ExtraMeta **extra_meta)
> +{
> +return ff_id3v2_parse_priv_dict(&s->metadata, extra_meta);
> +}
> diff --git a/libavformat/id3v2.h b/libavformat/id3v2.h
> index 5e64ead096..9de0bee374 100644
> --- a/libavformat/id3v2.h
> +++ b/libavformat/id3v2.h
> @@ -39,6 +39,8 @@
>  #define ID3v2_FLAG_ENCRYPTION  0x0004
>  #define ID3v2_FLAG_COMPRESSION 0x0008
>  
> +#define ID3v2_PRIV_METADATA_PREFIX "id3v2_priv."
> +
>  enum ID3v2Encoding {
>  ID3v2_ENCODING_ISO8859  = 0,
>  ID3v2_ENCODING_UTF16BOM = 1,
> @@ -167,6 +169,19 @@ int ff_id3v2_parse_apic(AVFormatContext *s, 
> ID3v2ExtraMeta **extra_meta);
>   */
>  int ff_id3v2_parse_chapters(AVFormatContext *s, ID3v2ExtraMeta **extra_meta);
>  
> +/**
> + * Parse PRIV tags into a dictionary. The PRIV owner is the metadata key. The
> + * PRIV data is the value, with non-printable characters escaped.
> + */
> +int ff_id3v2_parse_priv_dict(AVDictionary **d, ID3v2ExtraMeta **extra_meta);
> +
> +/**
> + * Add metadata for all PRIV tags in the ID3v2 header. The PRIV owner is the
> + * metadata key. The PRIV data is the value, with non-printable characters
> + * escaped.
> + */
> +int ff_id3v2_parse_priv(AVFormatContext *s, ID3v2ExtraMeta **extra_meta);
> +
>  extern const AVMetadataConv ff_id3v2_34_metadata_conv[];
>  extern const AVMetadataConv ff_id3v2_4_metadata_conv[];
>  
> diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c
> index 14de76ac06..ffe358f019 100644
> --- a/libavformat/id3v2enc.c
> +++ b/libavformat/id3v2enc.c
> @@ -96,6 +96,59 @@ static int id3v2_put_ttag(ID3v2EncContext *id3, 
> AVIOContext *avioc, const char *
>  return len + ID3v2_HEADER_SIZE;
>  }
>  
> +/**
> + * Write a priv frame with owner and data. 'key' is the owner prepended with
> + * ID3v2_PRIV_METADATA_PREFIX. 'data' is provided as a string. Any \xXX
> + * (where 'X' is a valid hex digit) will be unescaped to the byte value.
> + */
> +static int id3v2_put_priv(ID3v2EncContext *id3, AVIOContext *avioc, const 
> char *key, const char *data)
> +{
> +

[FFmpeg-devel] [PATCH 1/2] avcodec/hevc_ps: Check log2_sao_offset_scale_*

2018-01-23 Thread Michael Niedermayer
Fixes: 4868/clusterfuzz-testcase-minimized-6236542906400768
Fixes: runtime error: shift exponent 126 is too large for 32-bit type 'int'

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

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 4787312cfa..746c96b17e 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1324,6 +1324,17 @@ static int pps_range_extensions(GetBitContext *gb, 
AVCodecContext *avctx,
 pps->log2_sao_offset_scale_luma = get_ue_golomb_long(gb);
 pps->log2_sao_offset_scale_chroma = get_ue_golomb_long(gb);
 
+if (   pps->log2_sao_offset_scale_luma   > FFMAX(sps->bit_depth- 
10, 0)
+|| pps->log2_sao_offset_scale_chroma > FFMAX(sps->bit_depth_chroma - 
10, 0)
+) {
+av_log(avctx, AV_LOG_ERROR,
+"log2 sao offset scales (%d %d) are invalid\n",
+   pps->log2_sao_offset_scale_luma,
+   pps->log2_sao_offset_scale_chroma
+  );
+return AVERROR_INVALIDDATA;
+}
+
 return(0);
 }
 
-- 
2.15.1

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


[FFmpeg-devel] [PATCH 2/2] avcodec/mjpegdec: Fix integer overflow in DC dequantization

2018-01-23 Thread Michael Niedermayer
Fixes: runtime error: signed integer overflow: -65535 * 65312 cannot be 
represented in type 'int'
Fixes: 4900/clusterfuzz-testcase-minimized-5769019744321536

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

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index e005dd0cd3..5055ee2826 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -715,7 +715,7 @@ static int decode_block(MJpegDecodeContext *s, int16_t 
*block, int component,
 av_log(s->avctx, AV_LOG_ERROR, "error dc\n");
 return AVERROR_INVALIDDATA;
 }
-val = val * quant_matrix[0] + s->last_dc[component];
+val = val * (unsigned)quant_matrix[0] + s->last_dc[component];
 val = av_clip_int16(val);
 s->last_dc[component] = val;
 block[0] = val;
-- 
2.15.1

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/hevc_ps: Check log2_sao_offset_scale_*

2018-01-23 Thread wm4
On Wed, 24 Jan 2018 04:34:49 +0100
Michael Niedermayer  wrote:

> Fixes: 4868/clusterfuzz-testcase-minimized-6236542906400768
> Fixes: runtime error: shift exponent 126 is too large for 32-bit type 'int'
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/hevc_ps.c | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
> index 4787312cfa..746c96b17e 100644
> --- a/libavcodec/hevc_ps.c
> +++ b/libavcodec/hevc_ps.c
> @@ -1324,6 +1324,17 @@ static int pps_range_extensions(GetBitContext *gb, 
> AVCodecContext *avctx,
>  pps->log2_sao_offset_scale_luma = get_ue_golomb_long(gb);
>  pps->log2_sao_offset_scale_chroma = get_ue_golomb_long(gb);
>  
> +if (   pps->log2_sao_offset_scale_luma   > FFMAX(sps->bit_depth- 
> 10, 0)
> +|| pps->log2_sao_offset_scale_chroma > FFMAX(sps->bit_depth_chroma - 
> 10, 0)
> +) {
> +av_log(avctx, AV_LOG_ERROR,
> +"log2 sao offset scales (%d %d) are invalid\n",
> +   pps->log2_sao_offset_scale_luma,
> +   pps->log2_sao_offset_scale_chroma
> +  );
> +return AVERROR_INVALIDDATA;
> +}
> +
>  return(0);
>  }
>  

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/hevc_ps: Check log2_sao_offset_scale_*

2018-01-23 Thread James Almer
On 1/24/2018 12:34 AM, Michael Niedermayer wrote:
> Fixes: 4868/clusterfuzz-testcase-minimized-6236542906400768
> Fixes: runtime error: shift exponent 126 is too large for 32-bit type 'int'
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/hevc_ps.c | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
> index 4787312cfa..746c96b17e 100644
> --- a/libavcodec/hevc_ps.c
> +++ b/libavcodec/hevc_ps.c
> @@ -1324,6 +1324,17 @@ static int pps_range_extensions(GetBitContext *gb, 
> AVCodecContext *avctx,
>  pps->log2_sao_offset_scale_luma = get_ue_golomb_long(gb);
>  pps->log2_sao_offset_scale_chroma = get_ue_golomb_long(gb);
>  
> +if (   pps->log2_sao_offset_scale_luma   > FFMAX(sps->bit_depth- 
> 10, 0)
> +|| pps->log2_sao_offset_scale_chroma > FFMAX(sps->bit_depth_chroma - 
> 10, 0)
> +) {
> +av_log(avctx, AV_LOG_ERROR,
> +"log2 sao offset scales (%d %d) are invalid\n",
> +   pps->log2_sao_offset_scale_luma,
> +   pps->log2_sao_offset_scale_chroma
> +  );
> +return AVERROR_INVALIDDATA;

Wouldn't it be better to just port the h264 and hevc decoder to use the
cbs API at this point? It correctly does a range check for every
sps/vps/pps/slice value already.

Otherwise you'll be adding a lot of range checks as oss-fuzz finds an
ubsan testcase for them.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] GSoC 2018

2018-01-23 Thread Thilo Borgmann
Am 24.01.18 um 00:38 schrieb Carl Eugen Hoyos:
> 2018-01-23 18:27 GMT+01:00 Pascal Massimino :
> 
>> Anyone interested in a project  around completing the animated-WebP
>> support in ffmpeg?
> 
> Please consider to add the project and yourself as mentor
> in the wiki:
> https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2018

+1. Please add it to the wiki as soon as it is well defined (incl backup mentor 
and qual task, please).

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


[FFmpeg-devel] [PATCH 1/3] hls: do not allow fallback to generic seeking

2018-01-23 Thread wm4
This makes little sense due to how HLS works, and only causes some
additional annoyances if the HLS read_seek function fails (for example
if it's a live stream). It was most likely unintended.
---
I guess in theory, this might allow skipping forward a bit, but let's be
honest, API users are better off to implement such things manually if
they want it. It also didn't actually work for me and only caused stupid
behavior.
---
 libavformat/hls.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 950cc4c3bd..ff7bdecc93 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -2333,6 +2333,7 @@ AVInputFormat ff_hls_demuxer = {
 .long_name  = NULL_IF_CONFIG_SMALL("Apple HTTP Live Streaming"),
 .priv_class = &hls_class,
 .priv_data_size = sizeof(HLSContext),
+.flags  = AVFMT_NOGENSEARCH,
 .read_probe = hls_probe,
 .read_header= hls_read_header,
 .read_packet= hls_read_packet,
-- 
2.15.1

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


[FFmpeg-devel] [PATCH 3/3] hls: don't print a certain warning if playlist loading is aborted

2018-01-23 Thread wm4
AVERROR_EXIT happens when the user's interrupt callback signals that
playback should be aborted. In this case, the demuxer shouldn't print a
warning, as it's expected that all network accesses are stopped.
---
 libavformat/hls.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 6e1a2e3f1e..02e764f932 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1422,8 +1422,9 @@ reload:
 if (!v->finished &&
 av_gettime_relative() - v->last_load_time >= reload_interval) {
 if ((ret = parse_playlist(c, v->url, v, NULL)) < 0) {
-av_log(v->parent, AV_LOG_WARNING, "Failed to reload playlist 
%d\n",
-   v->index);
+if (ret != AVERROR_EXIT)
+av_log(v->parent, AV_LOG_WARNING, "Failed to reload 
playlist %d\n",
+   v->index);
 return ret;
 }
 /* If we need to reload the playlist again below (if
-- 
2.15.1

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


[FFmpeg-devel] [PATCH 2/3] avformat, hls: add a flag to signal unavailability of seeking

2018-01-23 Thread wm4
The seek function can just return an error if seeking is unavailable,
but often this is too late. Add a flag that signals that the stream is
unseekable, and use it in HLS.
---
Basically, this is equivalent to being a live stream. In theory, EVENT
playlists can be live streams, but they have full retention of all
segments, so the flag would not be set in that case.
---
 doc/APIchanges | 3 +++
 libavformat/avformat.h | 5 +
 libavformat/hls.c  | 8 ++--
 libavformat/version.h  | 4 ++--
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index c27f104c95..59e3b20c08 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2018-01-xx - xxx - lavf 58.6.100 - avformat.h
+  Add AVFMTCTX_UNSEEKABLE (for HLS demuxer).
+
 2018-xx-xx - xxx - lavu 56.9.100 - aes_ctr.h
   Add method to set the 16-byte IV.
 
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index e5740be2b4..60ab9fbc80 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1275,6 +1275,11 @@ typedef struct AVProgram {
 
 #define AVFMTCTX_NOHEADER  0x0001 /**< signal that no header is present
  (streams are added dynamically) */
+#define AVFMTCTX_UNSEEKABLE0x0002 /**< signal that the stream is definitely
+ not seekable, and attempts to call the
+ seek function will fail. For some
+ network protocols (e.g. HLS), this can
+ change dynamically at runtime. */
 
 typedef struct AVChapter {
 int id; ///< unique ID to identify the chapter
diff --git a/libavformat/hls.c b/libavformat/hls.c
index ff7bdecc93..6e1a2e3f1e 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -930,6 +930,11 @@ fail:
 av_free(new_url);
 if (close_in)
 ff_format_io_close(c->ctx, &in);
+c->ctx->ctx_flags = c->ctx->ctx_flags & ~(unsigned)AVFMTCTX_UNSEEKABLE;
+if (!c->n_variants || !c->variants[0]->n_playlists ||
+!(c->variants[0]->playlists[0]->finished ||
+  c->variants[0]->playlists[0]->type == PLS_TYPE_EVENT))
+c->ctx->ctx_flags |= AVFMTCTX_UNSEEKABLE;
 return ret;
 }
 
@@ -2213,8 +2218,7 @@ static int hls_read_seek(AVFormatContext *s, int 
stream_index,
 int stream_subdemuxer_index;
 int64_t first_timestamp, seek_timestamp, duration;
 
-if ((flags & AVSEEK_FLAG_BYTE) ||
-!(c->variants[0]->playlists[0]->finished || 
c->variants[0]->playlists[0]->type == PLS_TYPE_EVENT))
+if ((flags & AVSEEK_FLAG_BYTE) || (c->ctx->ctx_flags & 
AVFMTCTX_UNSEEKABLE))
 return AVERROR(ENOSYS);
 
 first_timestamp = c->first_timestamp == AV_NOPTS_VALUE ?
diff --git a/libavformat/version.h b/libavformat/version.h
index 148fc75faa..5ff8a89ae0 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,8 +32,8 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR   5
-#define LIBAVFORMAT_VERSION_MICRO 101
+#define LIBAVFORMAT_VERSION_MINOR   6
+#define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
-- 
2.15.1

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