Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-02 Thread Nicolas George
Le duodi 12 brumaire, an CCXXVI, Felix Matouschek a écrit :
> I've written an indev for Android devices to allow capturing their builtin
> cameras.
> What needs to be done to merge this?

Thanks for the patch. It looks very interesting. Before considering
merging, there are a few technical point to address. See inline comments
below.

> From b21fc8729ef2e1d9867dd7652f2c6173378e4910 Mon Sep 17 00:00:00 2001
> From: Felix Matouschek 
> Date: Tue, 24 Oct 2017 13:11:23 +0200
> Subject: [PATCH] Add android_capture indev
> To: ffmpeg-devel@ffmpeg.org
> 
> This commit adds an indev for Android devices on API level 24+ which
> uses the Android NDK Camera2 API to capture video from builtin cameras
> 
> Signed-off-by: Felix Matouschek 
> ---
>  configure |   6 +
>  libavdevice/Makefile  |   1 +
>  libavdevice/alldevices.c  |   1 +

>  libavdevice/android_capture.c | 782 
> ++

When reading the subject of the mail, I first thought it would be about
screen capture. Furthermore, there is code for audio, but it is not
connected to anything, and it does not seem that the android API
connects audio and video together.

For all these reasons, I suggest you name this device maybe
android_camera, and keep android_mic for audio capture.

>  libavdevice/android_capture.h |  77 +

This header is only used once, it does not need to be separate.

>  5 files changed, 867 insertions(+)
>  create mode 100644 libavdevice/android_capture.c
>  create mode 100644 libavdevice/android_capture.h
> 
> diff --git a/configure b/configure
> index 7a53bc76c7..e2165f2ff9 100755
> --- a/configure
> +++ b/configure
> @@ -3068,6 +3068,8 @@ xmv_demuxer_select="riffdec"
>  xwma_demuxer_select="riffdec"
>  
>  # indevs / outdevs
> +android_capture_indev_deps="android mediandk camera2ndk pthreads"
> +android_capture_indev_extralibs="-landroid -lmediandk -lcamera2ndk"
>  alsa_indev_deps="alsa"
>  alsa_outdev_deps="alsa"
>  avfoundation_indev_deps="avfoundation corevideo coremedia pthreads"
> @@ -5836,6 +5838,10 @@ check_lib shell32  "windows.h shellapi.h" 
> CommandLineToArgvW   -lshell32
>  check_lib wincrypt "windows.h wincrypt.h" CryptGenRandom   -ladvapi32
>  check_lib psapi"windows.h psapi.h"GetProcessMemoryInfo -lpsapi
>  
> +check_lib android android/native_window.h ANativeWindow_acquire -landroid
> +check_lib mediandk "stdint.h media/NdkImage.h" AImage_delete -lmediandk
> +check_lib camera2ndk "stdbool.h stdint.h camera/NdkCameraManager.h" 
> ACameraManager_create -lcamera2ndk
> +
>  enabled appkit   && check_apple_framework AppKit
>  enabled audiotoolbox && check_apple_framework AudioToolbox
>  enabled avfoundation && check_apple_framework AVFoundation
> diff --git a/libavdevice/Makefile b/libavdevice/Makefile
> index 8228d62147..aa01dd7e24 100644
> --- a/libavdevice/Makefile
> +++ b/libavdevice/Makefile
> @@ -14,6 +14,7 @@ OBJS-$(CONFIG_SHARED)+= reverse.o
>  # input/output devices
>  OBJS-$(CONFIG_ALSA_INDEV)+= alsa_dec.o alsa.o timefilter.o
>  OBJS-$(CONFIG_ALSA_OUTDEV)   += alsa_enc.o alsa.o
> +OBJS-$(CONFIG_ANDROID_CAPTURE_INDEV) += android_capture.o
>  OBJS-$(CONFIG_AVFOUNDATION_INDEV)+= avfoundation.o
>  OBJS-$(CONFIG_BKTR_INDEV)+= bktr.o
>  OBJS-$(CONFIG_CACA_OUTDEV)   += caca.o
> diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
> index b767b6a718..6cd57aa88a 100644
> --- a/libavdevice/alldevices.c
> +++ b/libavdevice/alldevices.c
> @@ -42,6 +42,7 @@ static void register_all(void)
>  {
>  /* devices */
>  REGISTER_INOUTDEV(ALSA, alsa);
> +REGISTER_INDEV   (ANDROID_CAPTURE,  android_capture);
>  REGISTER_INDEV   (AVFOUNDATION, avfoundation);
>  REGISTER_INDEV   (BKTR, bktr);
>  REGISTER_OUTDEV  (CACA, caca);
> diff --git a/libavdevice/android_capture.c b/libavdevice/android_capture.c
> new file mode 100644
> index 00..be0dee8f81
> --- /dev/null
> +++ b/libavdevice/android_capture.c
> @@ -0,0 +1,782 @@
> +/*
> + * Android camera/microphone input source via Android NDK APIs (Audio yet to 
> be implemented)
> + *
> + * Copyright (C) 2017 Felix Matouschek
> + *
> + * 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
> + * Foundat

[FFmpeg-devel] [PATCH] avfilter: slice processing for geq

2017-11-02 Thread Marc-Antoine ARNAUD



0001-avfilter-slice-processing-for-geq.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avformat/hlsenc: reindent hlsenc code

2017-11-02 Thread Steven Liu
2017-11-02 7:52 GMT+08:00 Steven Liu :
> Signed-off-by: Steven Liu 
> ---
>  libavformat/hlsenc.c | 52 
> ++--
>  1 file changed, 26 insertions(+), 26 deletions(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 6d573db094..5ea9d216a4 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1444,36 +1444,36 @@ static int hls_write_header(AVFormatContext *s)
>  }
>
>  if (hls->segment_type == SEGMENT_TYPE_FMP4) {
> -if (av_strcasecmp(hls->fmp4_init_filename, "init.mp4")) {
> -hls->base_output_dirname = av_malloc(fmp4_init_filename_len);
> -if (!hls->base_output_dirname) {
> -ret = AVERROR(ENOMEM);
> -goto fail;
> -}
> -av_strlcpy(hls->base_output_dirname, hls->fmp4_init_filename, 
> fmp4_init_filename_len);
> -} else {
> -if (basename_size > 0) {
> -hls->base_output_dirname = av_malloc(basename_size);
> +if (av_strcasecmp(hls->fmp4_init_filename, "init.mp4")) {
> +hls->base_output_dirname = av_malloc(fmp4_init_filename_len);
> +if (!hls->base_output_dirname) {
> +ret = AVERROR(ENOMEM);
> +goto fail;
> +}
> +av_strlcpy(hls->base_output_dirname, hls->fmp4_init_filename, 
> fmp4_init_filename_len);
>  } else {
> -hls->base_output_dirname = 
> av_malloc(strlen(hls->fmp4_init_filename));
> -}
> -if (!hls->base_output_dirname) {
> -ret = AVERROR(ENOMEM);
> -goto fail;
> -}
> +if (basename_size > 0) {
> +hls->base_output_dirname = av_malloc(basename_size);
> +} else {
> +hls->base_output_dirname = 
> av_malloc(strlen(hls->fmp4_init_filename));
> +}
> +if (!hls->base_output_dirname) {
> +ret = AVERROR(ENOMEM);
> +goto fail;
> +}
>
> -if (basename_size > 0) {
> -av_strlcpy(hls->base_output_dirname, s->filename, basename_size);
> -p = strrchr(hls->base_output_dirname, '/');
> -}
> -if (p) {
> -*(p + 1) = '\0';
> -av_strlcat(hls->base_output_dirname, hls->fmp4_init_filename, 
> basename_size);
> -} else {
> -av_strlcpy(hls->base_output_dirname, hls->fmp4_init_filename, 
> fmp4_init_filename_len);
> +if (basename_size > 0) {
> +av_strlcpy(hls->base_output_dirname, s->filename, 
> basename_size);
> +p = strrchr(hls->base_output_dirname, '/');
> +}
> +if (p) {
> +*(p + 1) = '\0';
> +av_strlcat(hls->base_output_dirname, 
> hls->fmp4_init_filename, basename_size);
> +} else {
> +av_strlcpy(hls->base_output_dirname, 
> hls->fmp4_init_filename, fmp4_init_filename_len);
> +}
>  }
>  }
> -}
>
>  if (!hls->use_localtime) {
>  ret = sls_flag_check_duration_size_index(hls);
> --
> 2.11.0 (Apple Git-81)
>
>
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

pushed,

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


Re: [FFmpeg-devel] [PATCH 1/2] avformat/hlsenc: check hls segment mode for ignore the init filename

2017-11-02 Thread Steven Liu
2017-11-02 7:52 GMT+08:00 Steven Liu :
> ignore the fmp4_init_filename when in normal hls segment mode
>
> Signed-off-by: Steven Liu 
> ---
>  libavformat/hlsenc.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 0ea93480a5..6d573db094 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1443,6 +1443,7 @@ static int hls_write_header(AVFormatContext *s)
>  }
>  }
>
> +if (hls->segment_type == SEGMENT_TYPE_FMP4) {
>  if (av_strcasecmp(hls->fmp4_init_filename, "init.mp4")) {
>  hls->base_output_dirname = av_malloc(fmp4_init_filename_len);
>  if (!hls->base_output_dirname) {
> @@ -1472,6 +1473,7 @@ static int hls_write_header(AVFormatContext *s)
>  av_strlcpy(hls->base_output_dirname, hls->fmp4_init_filename, 
> fmp4_init_filename_len);
>  }
>  }
> +}
>
>  if (!hls->use_localtime) {
>  ret = sls_flag_check_duration_size_index(hls);
> --
> 2.11.0 (Apple Git-81)
>
>
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

pushed,

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


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-02 Thread Moritz Barsnick
In addition to Nicolas's, further (style) comments:

> Subject: [PATCH] Add android_capture indev
More like:
avdevice: add android_capture [or android_camera] indev

>  configure |   6 +
>  libavdevice/Makefile  |   1 +
>  libavdevice/alldevices.c  |   1 +
>  libavdevice/android_capture.c | 782 
> ++
>  libavdevice/android_capture.h |  77 +
>  5 files changed, 867 insertions(+)
>  create mode 100644 libavdevice/android_capture.c
>  create mode 100644 libavdevice/android_capture.h

A Changelog entry, documentation in doc/indevs.texi, and a libavdevice
version bump need to be added.

>  # indevs / outdevs
> +android_capture_indev_deps="android mediandk camera2ndk pthreads"
> +android_capture_indev_extralibs="-landroid -lmediandk -lcamera2ndk"
>  alsa_indev_deps="alsa"
>  alsa_outdev_deps="alsa"

Alphabetical order.

> +av_log(avctx, AV_LOG_ERROR, "Error %d on camera with id %s.\n", error,
> +ACameraDevice_getId(device));

As Nicolas suggested, can you stringify the error codes?

> +av_log(avctx, AV_LOG_ERROR,
> +"Failed to get camera id list, camera_status_t: %d.\n", ret);

camera_status_t seems like an internal naming. (Also media_status_t and
the likes.) Not sure whether other words would be better. Without
stringification, it's only useful to the developer anyway.

> +av_log(avctx, AV_LOG_ERROR,
> +"real-time buffer of [%s input] too full or near too full 
> (%d%% of size: %d [rtbufsize parameter])! frame dropped!\n",
> +stream_name, buffer_fullness, avctx->max_picture_buffer);

I (personally) mislike exclamation marks in messages.

> +{ "sample_rate", "set audio sample rate", OFFSET(sample_rate), 
> AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, DEC },
> +{ "sample_size", "set audio sample size", OFFSET(sample_size), 
> AV_OPT_TYPE_INT, {.i64 = 0}, 0, 16, DEC },
> +{ "channels", "set number of audio channels, such as 1 or 2", 
> OFFSET(channels), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, DEC },
> +{ "audio_buffer_size", "set audio device buffer latency size in 
> milliseconds (default is the device's default)", OFFSET(audio_buffer_size), 
> AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, DEC },

While these aren't being used, don't expose them. (Will disappear
anyway if you split the functionality.)

> +.long_name  = NULL_IF_CONFIG_SMALL("Android camera/microphone input 
> source via Android NDK APIs (Audio yet to be implemented)"),

Perhaps a bit verbose, but if you split it up into video and audio as
suggested by Nicolas, you can shorten it. (I'm not sure "via Android
NDK APIs" is the correct to present.)

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


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-02 Thread Daniel Kučera
2017-11-02 13:42 GMT+01:00 Felix Matouschek :
> Hello,
>
> I've written an indev for Android devices to allow capturing their builtin
> cameras.
> What needs to be done to merge this?
>
> Greetings,
> Felix
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Looking forrward to this to be included. Just one note:

+if (ctx->video_device_number < camera_ids->numCameras) {
+ctx->camera_id = av_strdup(
+camera_ids->cameraIds[ctx->video_device_number]);
+} else {
+av_log(avctx, AV_LOG_ERROR, "No camera with number %d available.\n",
+ctx->video_device_number);
+return AVERROR(ENXIO);
+}

some devices have cameras which are unlisted - this condition makes
them unusable.


-- 

S pozdravom / Best regards
Daniel Kucera.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavfi/paletteuse: fix to support transparency

2017-11-02 Thread Bjorn Roche
On Sat, Oct 28, 2017 at 11:18 AM, Clément Bœsch  wrote:

> On Mon, Oct 23, 2017 at 07:12:57PM -0400, Bjorn Roche wrote:
> > This patch enables paletteuse to identify the transparency in incoming
> > video and tag transparent pixels on outgoing video with the correct
> > index from the palette.
> >
> > This requires tracking the transparency index in the palette,
> > establishing an alpha threshold below which a pixel is considered
> > transparent and above which the pixel is considered opaque, and
> > additional changes to track the alpha value throughout the conversion
> > process.
> >
> > This change is a partial fix for https://trac.ffmpeg.org/ticket/4443
> > However, animated GIFs are still output incorrectly due to a bug
> > in gif optimization which does not correctly handle transparency.
> > ---
> >  doc/filters.texi|   7 ++
> >  libavfilter/vf_paletteuse.c | 195 --
> --
>
> patch applied. I took the liberty to make the following changes before
> pushing:
>
> - fix spacing issues around () you forgot to fix
>

Sorry. It's the exact opposite of how I usually do it, so I can't even see
it :(


> - rename "threshold" into "alpha_threshold"
>

Much better.


> - move the option documentation in the appropriate place (it was between
>   diff_mode and one of its constant)
>

Cool. Thanks.


>
> Thanks for the patch, and sorry about the delay.
>

Thanks for everyone's help and feedback!

bjorn

-- 


Bjorn Roche

Sr. Video Pipeline Engineer

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


Re: [FFmpeg-devel] [PATCH] fix for transparencies in animated gifs (requires feedback)

2017-11-02 Thread Bjorn Roche
> - I don’t know if/how to update the FATE tests.


Can anyone comment on this? Do I update the tests in the same patch or
separate that?

-- 


Bjorn Roche

Sr. Video Pipeline Engineer

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


Re: [FFmpeg-devel] [PATCH] avfilter: initial macroblock types export and visualization

2017-11-02 Thread Ronald S. Bultje
Hi,

On Thu, Nov 2, 2017 at 7:52 AM, Paul B Mahol  wrote:

> On 11/2/17, Michael Niedermayer  wrote:
> > Hi
> >
> > On Sat, Oct 28, 2017 at 07:43:05AM -0400, Ronald S. Bultje wrote:
> >> Hi,
> >>
> >> On Fri, Oct 27, 2017 at 10:14 PM, Michael Niedermayer <
> >> mich...@niedermayer.cc> wrote:
> >>
> >> > On Fri, Oct 27, 2017 at 10:03:54PM +0200, Paul B Mahol wrote:
> >> > > Signed-off-by: Paul B Mahol 
> >> > > ---
> >> > >  libavcodec/mpegvideo.c |  10 +
> >> > >  libavfilter/vf_codecview.c | 105 ++
> >> > +++
> >> > >  libavutil/frame.h  |   4 ++
> >> > >  3 files changed, 119 insertions(+)
> >> >
> >> > First, thanks for working on this.
> >> >
> >> >
> >> > [...]
> >> >
> >> > > diff --git a/libavutil/frame.h b/libavutil/frame.h
> >> > > index fef558ea2f..8481dc080b 100644
> >> > > --- a/libavutil/frame.h
> >> > > +++ b/libavutil/frame.h
> >> > > @@ -141,6 +141,10 @@ enum AVFrameSideDataType {
> >> > >   * metadata key entry "name".
> >> > >   */
> >> > >  AV_FRAME_DATA_ICC_PROFILE,
> >> > > +/**
> >> > > + * Macroblock types exported by some codecs.
> >> > > + */
> >> > > +AV_FRAME_DATA_MACROBLOCK_TYPES,
> >> > >  };
> >> > >
> >> >
> >> > This makes the internal data of the decoder part of the ABI and API of
> >> > libavcodec and libavfilter
> >> > and its undocumented
> >> >
> >> > do people prefer to make the internal data part of the ABI, document
> >> > it and ensure it does not change till the next bump
> >> >
> >> [..]
> >>
> >> > or is there some other option iam missing ?
> >> >
> >>
> >> I noted this on IRC also. A third option is to not document it and
> >> consider
> >> it codec-specific.
> >>
> >> (Codec-specific implies "ABI/API unstable" and subject to change -
> "don't
> >> mix versions".)
> >
> > If you say the interface is "ABI/API unstable" then we cannot use it
> > from another lib like libavfilter. So this would not work.
>
> I disagree.


I'd like to speak in solutions, not problems. We can simply prepend a
version number to the flags and ensure versions match. That makes it easy
to break "ABI" (and if versions don't match, simply display an error
message and tell the user to not mix versions since this is considered an
unstable feature).

By no means can we set the current ABI of this feature in stone, we're
trying to fix it, not keep it. I appreciate Paul's effort to moving this
forward and think his work pushes it in the right direction.

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


Re: [FFmpeg-devel] [PATCH] fix for transparencies in animated gifs (requires feedback)

2017-11-02 Thread Moritz Barsnick
On Thu, Nov 02, 2017 at 11:45:20 -0400, Bjorn Roche wrote:
> > - I don’t know if/how to update the FATE tests.
> 
> Can anyone comment on this? Do I update the tests in the same patch or
> separate that?

Your patch is not allowed to break fate. If the fate results are
correct references, then fate is catching an error in your patch which
you need to correct. If the change in fate is expected (implied by the
patch), then you need to change the fate results or adapt the fate test
within the same patch.

New additional fate tests are welcome (or preferred? not sure) as
separate patches.

How to update fate:
There's a web (or wiki) page about that, and James wrote this excellent
stuff recently (perhaps not related to your quest here):
http://ffmpeg.org/pipermail/ffmpeg-devel/2017-October/217473.html

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


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-02 Thread Thomas Volkert
On 02.11.2017 16:20, Daniel Kučera wrote:
> 2017-11-02 13:42 GMT+01:00 Felix Matouschek :
>> Hello,
>>
>> I've written an indev for Android devices to allow capturing their builtin
>> cameras.
>> What needs to be done to merge this?
>>
>> Greetings,
>> Felix
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
> Looking forrward to this to be included. 

+ 1

Best regards,
Thomas.

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


[FFmpeg-devel] [PATCH] avcodec/cngdec: Fix integer clipping

2017-11-02 Thread Michael Niedermayer
Fixes: runtime error: value -36211.7 is outside the range of representable 
values of type 'short'
Fixes: 2992/clusterfuzz-testcase-6649611793989632

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

diff --git a/libavcodec/cngdec.c b/libavcodec/cngdec.c
index 1e884f3c33..28432ac719 100644
--- a/libavcodec/cngdec.c
+++ b/libavcodec/cngdec.c
@@ -153,7 +153,7 @@ static int cng_decode_frame(AVCodecContext *avctx, void 
*data,
 return ret;
 buf_out = (int16_t *)frame->data[0];
 for (i = 0; i < avctx->frame_size; i++)
-buf_out[i] = p->filter_out[i + p->order];
+buf_out[i] = av_clip_int16(p->filter_out[i + p->order]);
 memcpy(p->filter_out, p->filter_out + avctx->frame_size,
p->order * sizeof(*p->filter_out));
 
-- 
2.14.2

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


[FFmpeg-devel] [PATCH] snowenc: fix use of deprecated API

2017-11-02 Thread ffmpeg
From: Nicolas Frattaroli 

Replace avcodec_get_chroma_sub_sample with the recommended
av_pix_fmt_get_chroma_sub_sample, which fixes a compilation warning.
---
 libavcodec/snowenc.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index e7d670ac10..4fec377591 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -22,6 +22,7 @@
 #include "libavutil/libm.h"
 #include "libavutil/log.h"
 #include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
 #include "avcodec.h"
 #include "internal.h"
 #include "snow_dwt.h"
@@ -127,7 +128,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
 av_log(avctx, AV_LOG_ERROR, "pixel format not supported\n");
 return AVERROR_PATCHWELCOME;
 }
-avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_h_shift, 
&s->chroma_v_shift);
+
+ret = av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_h_shift,
+   &s->chroma_v_shift);
+if (ret) {
+av_log(avctx, AV_LOG_ERROR, "pixel format invalid or unknown\n");
+return ret;
+}
 
 ff_set_cmp(&s->mecc, s->mecc.me_cmp, s->avctx->me_cmp);
 ff_set_cmp(&s->mecc, s->mecc.me_sub_cmp, s->avctx->me_sub_cmp);
-- 
2.14.3

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


Re: [FFmpeg-devel] libavcodec/als: remove check for predictor order of a block

2017-11-02 Thread Umair Khan
Hi,

On Fri, Oct 20, 2017 at 1:44 AM, Ronald S. Bultje  wrote:
>
> Hi,
>
> On Thu, Oct 19, 2017 at 4:03 PM, Umair Khan  wrote:
>
> > I tried decoding the file in both the cases and I don't see any
> > address related error in the console while decoding. Following is the
> > output after I apply the patch :-
> >
> [..]
>
> > Is there something which I'm missing?
> >
>
> You need to run under valgrind or compile with address sanitizer support:
> configure --toolchain=gcc-asan or --toolchain=clang-asan, depending on the
> name of clang on your system.

Thanks for the help. I was finally able to reproduce the error.

I have been trying to debug this heap-buffer-overflow error for some
days. I have finally found the source of the issue at least.

https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/alsdec.c#L934

raw_samples pointer is overflowing inside that loop. I haven't thought
of a proper fix for this yet. I'll look at the documentation to
understand the logic first.

However, in case someone (Thilo?) already has some idea on fixing it,
that'd be great.

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


Re: [FFmpeg-devel] [PATCH] web/template_head2: Remove net neutrality script

2017-11-02 Thread Lou Logan
On Wed, Nov 1, 2017, at 03:52 PM, Michael Niedermayer wrote:
> The loss of net neutrality may also be annoying and distracting, and
> may be harder to fix than with a patch.

We don't need yet another daily reminder of how completely shitty the
current US administration is.

For the record, yes, I did contact my non-representatives, but not
because a popup told me to.

I would prefer it if the site did not involve politics.

I implemented a client side solution using an ad blocker, so consider
this patch dropped.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Added HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2017-11-02 Thread Mironov, Mikhail
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of mmironov
> Sent: October 31, 2017 3:39 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] Added HW H.264 and HEVC encoding for AMD GPUs
> based on AMF SDK
> 
> From 8640b995634f827eb39ae87bcbe2c1992d8140f2 Mon Sep 17 00:00:00
> 2001
> From: mmironov 
> Date: Fri, 27 Oct 2017 13:03:15 -0400
> Subject: [PATCH] Added: HW accelerated H.264 and HEVC encoding for AMD
> GPUs
>  based on AMF SDK
> 
> Signed-off-by: mmironov 
> ---
>  Changelog|3 +-
>  compat/amd/amfsdkenc.h   | 1753
> ++
>  configure|   25 +
>  libavcodec/Makefile  |4 +
>  libavcodec/allcodecs.c   |2 +
>  libavcodec/amfenc.c  |  513 ++
>  libavcodec/amfenc.h  |  136 
>  libavcodec/amfenc_h264.c |  368 ++
>  libavcodec/amfenc_hevc.c |  296 
>  libavcodec/version.h |4 +-
>  10 files changed, 3101 insertions(+), 3 deletions(-)
>  create mode 100644 compat/amd/amfsdkenc.h
>  create mode 100644 libavcodec/amfenc.c
>  create mode 100644 libavcodec/amfenc.h
>  create mode 100644 libavcodec/amfenc_h264.c
>  create mode 100644 libavcodec/amfenc_hevc.c
> 
> diff --git a/Changelog b/Changelog
> index 6592d86..f0d22fa 100644
> --- a/Changelog
> +++ b/Changelog

Don’t want to push but is it possible that this submit was skipped?
Thanks, Mikhail 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] diracdec: fix deprecated API usage

2017-11-02 Thread Nicolas Frattaroli
avcodec_get_chroma_sub_sample is deprecated and generates a warning
during build, so av_pix_fmt_get_chroma_sub_sample is used

Signed-off-by: Nicolas Frattaroli 
---
 libavcodec/diracdec.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index 0abb8b0599..7f83ed47f2 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -26,6 +26,7 @@
  * @author Marco Gerards , David Conrad, Jordi Ortiz 

  */
 
+#include "libavutil/pixdesc.h"
 #include "libavutil/thread.h"
 #include "avcodec.h"
 #include "get_bits.h"
@@ -1927,7 +1928,10 @@ static int get_buffer_with_edge(AVCodecContext *avctx, 
AVFrame *f, int flags)
 {
 int ret, i;
 int chroma_x_shift, chroma_y_shift;
-avcodec_get_chroma_sub_sample(avctx->pix_fmt, &chroma_x_shift, 
&chroma_y_shift);
+ret = av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_x_shift,
+   &chroma_y_shift);
+if (ret)
+return ret;
 
 f->width  = avctx->width  + 2 * EDGE_WIDTH;
 f->height = avctx->height + 2 * EDGE_WIDTH + 2;
@@ -2126,7 +2130,11 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, 
const uint8_t *buf, int
 
 s->pshift = s->bit_depth > 8;
 
-avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_x_shift, 
&s->chroma_y_shift);
+ret = av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt,
+   &s->chroma_x_shift,
+   &s->chroma_y_shift);
+if (ret)
+return ret;
 
 ret = alloc_sequence_buffers(s);
 if (ret < 0)
-- 
2.14.3

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


Re: [FFmpeg-devel] [PATCH]tests/fate: Fix fitsdec-gbrap16 on big-endian hardware

2017-11-02 Thread Michael Niedermayer
On Wed, Nov 01, 2017 at 09:41:58PM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes fate-fitsdec on big-endian.
> 
> Please comment, Carl Eugen

>  b/tests/fate/fits.mak  |4 ++--
>  b/tests/ref/fate/fitsdec-gbrap16le |6 ++
>  tests/ref/fate/fitsdec-gbrap16 |6 --
>  3 files changed, 8 insertions(+), 8 deletions(-)
> c39c8f21e9d3b2c15b6ac9ed9e7b2d0b864b4863  
> 0001-tests-fate-Fix-fitsdec-gbrap16-test-on-big-endian-ha.patch
> From 61032df04a35d7cc939fa41e71ee3f882c3658c3 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos 
> Date: Wed, 1 Nov 2017 21:39:33 +0100
> Subject: [PATCH] tests/fate: Fix fitsdec-gbrap16 test on big-endian hardware.

LGTM

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes


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


Re: [FFmpeg-devel] [PATCH] Fix quadratic memory use in ff_h2645_extract_rbsp() when multiple NALUs exist in packet.

2017-11-02 Thread Kieran Kunhya
>
> The idea would be that there would only be one uint8_t buffer and the
> 2000 entries from te pool would point into that.
> So as a larger NAL shifts through the 2000 the pointers would get
> distributed differently but the size would not grow
> Any variable size buffer the H2645NAL needs would be such a "shared"
> buffer
>
> I dont know if theres anything that would make this non trivial to
> implement.
>

I have tried this using the following patch but it does not work:
https://www.irccloud.com/pastebin/qobTcW9d/

Nothing obviously seems wrong so I suspect it's not possible to do this
whilst reusing the code between decoder and parser.
The old code use to write to a per-slice context, not a per packet one so
this might be related.

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


Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Refine edit list start seek, based on PTS computed from CTTS.

2017-11-02 Thread Michael Niedermayer
On Tue, Oct 31, 2017 at 04:45:00PM -0700, Sasi Inguva wrote:
> Attaching the fate sample.

uploaded

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


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


Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index.

2017-11-02 Thread Michael Niedermayer
On Wed, Nov 01, 2017 at 02:27:50PM -0700, Sasi Inguva wrote:
> Pls find attached, the FATE sample.

uplaoded

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

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


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


Re: [FFmpeg-devel] Support for h264/SVC over RTP and SVC base layer decoding in h264

2017-11-02 Thread Michael Niedermayer
On Wed, Nov 01, 2017 at 05:49:48PM +, Breeden, Joshua wrote:
> > No but I wonder if the variables "y" and "t" can have more useful names
> > (that may or may not make the comment unneeded),
> 
> I've made the variable names more self-explanatory and condensed the comments
> 
> > Please do not remove the empty line.
> 
> And fixed this as well.
> 
> Thanks,
> 
> Joshua Breeden

>  h264.h   |1 +
>  h264_parse.c |6 ++
>  2 files changed, 7 insertions(+)
> b92e905eedab047e752f8e539f9bafff0e0dba09  
> 0001-Parse-NAL-type-15-subset-SPS-in-H.264-extradata.patch
> From 65b33b5ed716712118d6cc9a9a0b3b6c260daa03 Mon Sep 17 00:00:00 2001
> From: Joshua Breeden 
> Date: Wed, 1 Nov 2017 13:27:20 -0400
> Subject: [PATCH 1/2] Parse NAL type 15 (subset SPS) in H.264 extradata

can you add a fate test for this ?

(i assume a test for rtp would be hard but if not, that would be
 welcome too)

thx

[...]

-- 
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: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Fix quadratic memory use in ff_h2645_extract_rbsp() when multiple NALUs exist in packet.

2017-11-02 Thread Derek Buitenhuis
On 11/2/2017 10:48 PM, Kieran Kunhya wrote:
> I have tried this using the following patch but it does not work:
> https://www.irccloud.com/pastebin/qobTcW9d/
> 
> Nothing obviously seems wrong so I suspect it's not possible to do this
> whilst reusing the code between decoder and parser.
> The old code use to write to a per-slice context, not a per packet one so
> this might be related.

As discussed on IRC, the issue was dangling pointers due to the realloc.

It can be allocated based on the full packet size, outside the function,
or on first call, I think.

Aside:

Do we have some preferred way to address the cumulative memory issue
I mentioned in my previous mail, or is it a DNC situation? I haven't
thought of a good way to solve that - only stuff like going back
to in-place NAL parsing, or shrinking the buffer after some time based
on some metric (ew...).

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


Re: [FFmpeg-devel] [PATCH] Fix quadratic memory use in ff_h2645_extract_rbsp() when multiple NALUs exist in packet.

2017-11-02 Thread Hendrik Leppkes
On Fri, Nov 3, 2017 at 12:38 AM, Derek Buitenhuis
 wrote:
> On 11/2/2017 10:48 PM, Kieran Kunhya wrote:
>> I have tried this using the following patch but it does not work:
>> https://www.irccloud.com/pastebin/qobTcW9d/
>>
>> Nothing obviously seems wrong so I suspect it's not possible to do this
>> whilst reusing the code between decoder and parser.
>> The old code use to write to a per-slice context, not a per packet one so
>> this might be related.
>
> As discussed on IRC, the issue was dangling pointers due to the realloc.
>
> It can be allocated based on the full packet size, outside the function,
> or on first call, I think.
>
> Aside:
>
> Do we have some preferred way to address the cumulative memory issue
> I mentioned in my previous mail, or is it a DNC situation? I haven't
> thought of a good way to solve that - only stuff like going back
> to in-place NAL parsing, or shrinking the buffer after some time based
> on some metric (ew...).
>

Personally I don't think the problem of a single buffer getting way
too large is a huge problem, at least it should not accumulate and
keep growing. Its also not a "new" problem, the old code would've
suffered from the same issue as well, since it also cached the rbsp
buffer - just only one, not multiple.

Another option would be to re-arrange the API to keep it shared but go
back to an iterator-style parsing of the NALs. Parse one, process it,
parse the next. That way you can also avoid the issue with a multitude
of NAL structs being allocated and sitting there forever.
Obviously H264 would be compatible with that, as its how it was used
before. I didn't check HEVC, however.

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


[FFmpeg-devel] [PATCH] lavf/mov.c: Refine edit list start seek, based on PTS computed from CTTS.

2017-11-02 Thread Sasi Inguva
Partially fixes t/6699.
---
 libavformat/mov.c| 129 +++
 tests/fate/mov.mak   |   8 +++
 tests/ref/fate/mov-ibi-elst-starts-b |  33 +
 3 files changed, 127 insertions(+), 43 deletions(-)
 create mode 100644 tests/ref/fate/mov-ibi-elst-starts-b

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 60f0228e2d..7954db6e47 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3014,34 +3014,99 @@ static int get_edit_list_entry(MOVContext *mov,
 }
 
 /**
- * Find the closest previous frame to the timestamp, in e_old index
+ * Find the closest previous frame to the timestamp_pts, in e_old index
  * entries. Searching for just any frame / just key frames can be controlled by
  * last argument 'flag'.
- * Returns the index of the entry in st->index_entries if successful,
- * else returns -1.
+ * Note that if ctts_data is not NULL, we will always search for a key frame
+ * irrespective of the value of 'flag'. If we don't find any keyframe, we will
+ * return the first frame of the video.
+ *
+ * Here the timestamp_pts is considered to be a presentation timestamp and
+ * the timestamp of index entries are considered to be decoding timestamps.
+ *
+ * Returns 0 if successful in finding a frame, else returns -1.
+ * Places the found index corresponding output arg.
+ *
+ * If ctts_old is not NULL, then refines the searched entry by searching
+ * backwards from the found timestamp, to find the frame with correct PTS.
+ *
+ * Places the found ctts_index and ctts_sample in corresponding output args.
  */
-static int64_t find_prev_closest_index(AVStream *st,
-   AVIndexEntry *e_old,
-   int nb_old,
-   int64_t timestamp,
-   int flag)
+static int find_prev_closest_index(AVStream *st,
+   AVIndexEntry *e_old,
+   int nb_old,
+   MOVStts* ctts_data,
+   int64_t ctts_count,
+   int64_t timestamp_pts,
+   int flag,
+   int64_t* index,
+   int64_t* ctts_index,
+   int64_t* ctts_sample)
 {
+MOVStreamContext *msc = st->priv_data;
 AVIndexEntry *e_keep = st->index_entries;
 int nb_keep = st->nb_index_entries;
-int64_t found = -1;
 int64_t i = 0;
+int64_t index_ctts_count;
+
+av_assert0(index);
+
+// If dts_shift > 0, then all the index timestamps will have to be offset 
by
+// at least dts_shift amount to obtain PTS.
+// Hence we decrement the searched timestamp_pts by dts_shift to find the 
closest index element.
+if (msc->dts_shift > 0) {
+timestamp_pts -= msc->dts_shift;
+}
 
 st->index_entries = e_old;
 st->nb_index_entries = nb_old;
-found = av_index_search_timestamp(st, timestamp, flag | 
AVSEEK_FLAG_BACKWARD);
+*index = av_index_search_timestamp(st, timestamp_pts, flag | 
AVSEEK_FLAG_BACKWARD);
 
 // Keep going backwards in the index entries until the timestamp is the 
same.
-if (found >= 0) {
-for (i = found; i > 0 && e_old[i].timestamp == e_old[i - 1].timestamp;
+if (*index >= 0) {
+for (i = *index; i > 0 && e_old[i].timestamp == e_old[i - 1].timestamp;
  i--) {
 if ((flag & AVSEEK_FLAG_ANY) ||
 (e_old[i - 1].flags & AVINDEX_KEYFRAME)) {
-found = i - 1;
+*index = i - 1;
+}
+}
+}
+
+// If we have CTTS then refine the search, by searching backwards over PTS
+// computed by adding corresponding CTTS durations to index timestamps.
+if (ctts_data && *index >= 0) {
+av_assert0(ctts_index);
+av_assert0(ctts_sample);
+// Find out the ctts_index for the found frame.
+*ctts_index = 0;
+*ctts_sample = 0;
+for (index_ctts_count = 0; index_ctts_count < *index; 
index_ctts_count++) {
+if (*ctts_index < ctts_count) {
+(*ctts_sample)++;
+if (ctts_data[*ctts_index].count == *ctts_sample) {
+(*ctts_index)++;
+*ctts_sample = 0;
+}
+}
+}
+
+while (*index >= 0 && (*ctts_index) >= 0) {
+// Find a "key frame" with PTS <= timestamp_pts (So that we can 
decode B-frames correctly).
+// No need to add dts_shift to the timestamp here becase 
timestamp_pts has already been
+// compensated by dts_shift above.
+if ((e_old[*index].timestamp + ctts_data[*ctts_index].duration) <= 
timestamp_pts &&
+(e_old[*index].flags & AVINDEX_KEYFRAME)) {
+break;
+}
+
+(*index)--;
+  

Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Refine edit list start seek, based on PTS computed from CTTS.

2017-11-02 Thread Sasi Inguva
Modified the comment for find_prev_index function. Thx.

On Thu, Nov 2, 2017 at 4:22 PM, Michael Niedermayer 
wrote:

> On Tue, Oct 31, 2017 at 04:45:00PM -0700, Sasi Inguva wrote:
> > Attaching the fate sample.
>
> uploaded
>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: slice processing for geq

2017-11-02 Thread Michael Niedermayer
On Thu, Nov 02, 2017 at 02:04:33PM +, Marc-Antoine ARNAUD wrote:
> 

>  vf_geq.c |  126 
> ---
>  1 file changed, 89 insertions(+), 37 deletions(-)
> b0379f3d7f1d9660e209fe491f48fd7f70113615  
> 0001-avfilter-slice-processing-for-geq.patch
> From c4bdf956e7f8b91b03f16bdf80b30058a117aae2 Mon Sep 17 00:00:00 2001
> From: Marc-Antoine Arnaud 
> Date: Thu, 2 Nov 2017 12:25:46 +0100
> Subject: [PATCH] avfilter: slice processing for geq

> Content-Type: text/x-patch; charset="utf-8"
> Content-Transfer-Encoding: base64

hmm


> 
> ---
>  libavfilter/vf_geq.c | 126 
> ---
>  1 file changed, 89 insertions(+), 37 deletions(-)

breaks:
./ffplay  matrixbench_mpeg2.mpg  -vf 'geq=b=b(X\,Y)-r(X\,Y)'

looks like possibly something related to strides

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

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable


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


Re: [FFmpeg-devel] [PATCH] diracdec: fix deprecated API usage

2017-11-02 Thread James Almer
On 11/2/2017 7:39 PM, Nicolas Frattaroli wrote:
> avcodec_get_chroma_sub_sample is deprecated and generates a warning
> during build, so av_pix_fmt_get_chroma_sub_sample is used
> 
> Signed-off-by: Nicolas Frattaroli 
> ---
>  libavcodec/diracdec.c | 12 ++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
> index 0abb8b0599..7f83ed47f2 100644
> --- a/libavcodec/diracdec.c
> +++ b/libavcodec/diracdec.c
> @@ -26,6 +26,7 @@
>   * @author Marco Gerards , David Conrad, Jordi Ortiz 
> 
>   */
>  
> +#include "libavutil/pixdesc.h"
>  #include "libavutil/thread.h"
>  #include "avcodec.h"
>  #include "get_bits.h"
> @@ -1927,7 +1928,10 @@ static int get_buffer_with_edge(AVCodecContext *avctx, 
> AVFrame *f, int flags)
>  {
>  int ret, i;
>  int chroma_x_shift, chroma_y_shift;
> -avcodec_get_chroma_sub_sample(avctx->pix_fmt, &chroma_x_shift, 
> &chroma_y_shift);
> +ret = av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_x_shift,
> +   &chroma_y_shift);
> +if (ret)
> +return ret;
>  
>  f->width  = avctx->width  + 2 * EDGE_WIDTH;
>  f->height = avctx->height + 2 * EDGE_WIDTH + 2;
> @@ -2126,7 +2130,11 @@ static int dirac_decode_data_unit(AVCodecContext 
> *avctx, const uint8_t *buf, int
>  
>  s->pshift = s->bit_depth > 8;
>  
> -avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_x_shift, 
> &s->chroma_y_shift);
> +ret = av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt,
> +   &s->chroma_x_shift,
> +   &s->chroma_y_shift);
> +if (ret)
> +return ret;
>  
>  ret = alloc_sequence_buffers(s);
>  if (ret < 0)

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


[FFmpeg-devel] [PATCH] avcodec/mips: Improve avc avg mc 20, 21 and 23 msa functions

2017-11-02 Thread kaustubh.raste
From: Kaustubh Raste 

Load the specific destination bytes instead of MSA load and pack.
Remove unused macros and functions.

Signed-off-by: Kaustubh Raste 
---
 libavcodec/mips/h264qpel_msa.c | 1274 ++--
 1 file changed, 834 insertions(+), 440 deletions(-)

diff --git a/libavcodec/mips/h264qpel_msa.c b/libavcodec/mips/h264qpel_msa.c
index 3df72f5..dd11f00 100644
--- a/libavcodec/mips/h264qpel_msa.c
+++ b/libavcodec/mips/h264qpel_msa.c
@@ -21,30 +21,6 @@
 #include "libavutil/mips/generic_macros_msa.h"
 #include "h264dsp_mips.h"
 
-#define AVC_CALC_DPADD_H_6PIX_2COEFF_SH(in0, in1, in2, in3, in4, in5)\
-( {  \
-v4i32 tmp0_m, tmp1_m;\
-v8i16 out0_m, out1_m, out2_m, out3_m;\
-v8i16 minus5h_m = __msa_ldi_h(-5);   \
-v8i16 plus20h_m = __msa_ldi_h(20);   \
- \
-ILVRL_H2_SW(in5, in0, tmp0_m, tmp1_m);   \
- \
-tmp0_m = __msa_hadd_s_w((v8i16) tmp0_m, (v8i16) tmp0_m); \
-tmp1_m = __msa_hadd_s_w((v8i16) tmp1_m, (v8i16) tmp1_m); \
- \
-ILVRL_H2_SH(in1, in4, out0_m, out1_m);   \
-DPADD_SH2_SW(out0_m, out1_m, minus5h_m, minus5h_m, tmp0_m, tmp1_m);  \
-ILVRL_H2_SH(in2, in3, out2_m, out3_m);   \
-DPADD_SH2_SW(out2_m, out3_m, plus20h_m, plus20h_m, tmp0_m, tmp1_m);  \
- \
-SRARI_W2_SW(tmp0_m, tmp1_m, 10); \
-SAT_SW2_SW(tmp0_m, tmp1_m, 7);   \
-out0_m = __msa_pckev_h((v8i16) tmp1_m, (v8i16) tmp0_m);  \
- \
-out0_m;  \
-} )
-
 static const uint8_t luma_mask_arr[16 * 8] = {
 /* 8 width cases */
 0, 5, 1, 6, 2, 7, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12,
@@ -75,44 +51,6 @@ static const uint8_t luma_mask_arr[16 * 8] = {
 DPADD_SB2_SH(tmp0_m, tmp1_m, plus20b_m, plus20b_m, out1, out2);  \
 }
 
-#define AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(vec0, vec1, vec2, vec3, vec4, vec5)  
\
-( {
\
-v4i32 tmp1_m;  
\
-v8i16 tmp2_m, tmp3_m;  
\
-v8i16 minus5h_m = __msa_ldi_h(-5); 
\
-v8i16 plus20h_m = __msa_ldi_h(20); 
\
-   
\
-tmp1_m = (v4i32) __msa_ilvr_h((v8i16) vec5, (v8i16) vec0); 
\
-tmp1_m = __msa_hadd_s_w((v8i16) tmp1_m, (v8i16) tmp1_m);   
\
-   
\
-ILVR_H2_SH(vec1, vec4, vec2, vec3, tmp2_m, tmp3_m);
\
-DPADD_SH2_SW(tmp2_m, tmp3_m, minus5h_m, plus20h_m, tmp1_m, tmp1_m);
\
-   
\
-tmp1_m = __msa_srari_w(tmp1_m, 10);
\
-tmp1_m = __msa_sat_s_w(tmp1_m, 7); 
\
-   
\
-tmp2_m = __msa_pckev_h((v8i16) tmp1_m, (v8i16) tmp1_m);
\
-   
\
-tmp2_m;
\
-} )
-
-#define AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1,  \
-mask0, mask1, mask2) \
-( {  \
-v8i16 hz_out_m;  \
-v16i8 vec0_m, vec1_m, vec2_m;\
-v16i8 minus5b_m = __msa_ldi_b(-5);   \
-v16i8 plus20b_m = __msa_ldi_b(20);   \
- \
-vec0_m = __msa_vshf_b((v16i8) mask0, (v16i8) src1, (v16i8) src0);\
-hz_out_m = __msa_hadd_s_h(vec0_m, vec0_m);   \
- \
-   

[FFmpeg-devel] [PATCH] avcodec/mips: Improve hevc bi 4 tap hz and vt mc msa functions

2017-11-02 Thread kaustubh.raste
From: Kaustubh Raste 

Use global mask buffer for appropriate mask load.

Signed-off-by: Kaustubh Raste 
---
 libavcodec/mips/hevc_mc_bi_msa.c |  428 +++---
 1 file changed, 210 insertions(+), 218 deletions(-)

diff --git a/libavcodec/mips/hevc_mc_bi_msa.c b/libavcodec/mips/hevc_mc_bi_msa.c
index 9c03ef8..e9c9184 100644
--- a/libavcodec/mips/hevc_mc_bi_msa.c
+++ b/libavcodec/mips/hevc_mc_bi_msa.c
@@ -2183,7 +2183,7 @@ static void hevc_hz_bi_4t_4x2_msa(uint8_t *src0_ptr,
 v8i16 filt0, filt1;
 v16i8 src0, src1, dst0, vec0, vec1;
 v8i16 in0, in1;
-v16i8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 16, 17, 17, 18, 18, 19, 19, 20 };
+v16i8 mask0 = LD_SB(&ff_hevc_mask_arr[16]);
 v16i8 mask1;
 v8i16 tmp0;
 v8i16 filter_vec, const_vec;
@@ -2226,7 +2226,8 @@ static void hevc_hz_bi_4t_4x4_msa(uint8_t *src0_ptr,
 v8i16 filt0, filt1;
 v16i8 src0, src1, src2, src3, dst0, vec0, vec1;
 v8i16 in0, in1, in2, in3;
-v16i8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 16, 17, 17, 18, 18, 19, 19, 20 };
+v16i8 vec2, vec3;
+v16i8 mask0 = LD_SB(&ff_hevc_mask_arr[16]);
 v16i8 mask1;
 v8i16 tmp0, tmp1;
 v8i16 filter_vec, const_vec;
@@ -2247,12 +2248,12 @@ static void hevc_hz_bi_4t_4x4_msa(uint8_t *src0_ptr,
 ILVR_D2_SH(in1, in0, in3, in2, in0, in1);
 XORI_B4_128_SB(src0, src1, src2, src3);
 
-VSHF_B2_SB(src0, src1, src0, src1, mask0, mask1, vec0, vec1);
 tmp0 = const_vec;
-DPADD_SB2_SH(vec0, vec1, filt0, filt1, tmp0, tmp0);
-VSHF_B2_SB(src2, src3, src2, src3, mask0, mask1, vec0, vec1);
 tmp1 = const_vec;
-DPADD_SB2_SH(vec0, vec1, filt0, filt1, tmp1, tmp1);
+VSHF_B2_SB(src0, src1, src2, src3, mask0, mask0, vec0, vec1);
+VSHF_B2_SB(src0, src1, src2, src3, mask1, mask1, vec2, vec3);
+DPADD_SB4_SH(vec0, vec1, vec2, vec3, filt0, filt0, filt1, filt1, tmp0, 
tmp1,
+ tmp0, tmp1);
 HEVC_BI_RND_CLIP2(in0, in1, tmp0, tmp1, 7, tmp0, tmp1);
 dst0 = __msa_pckev_b((v16i8) tmp1, (v16i8) tmp0);
 
@@ -2273,8 +2274,8 @@ static void hevc_hz_bi_4t_4x8multiple_msa(uint8_t 
*src0_ptr,
 v16i8 src0, src1, src2, src3, src4, src5, src6, src7;
 v16i8 dst0, dst1;
 v8i16 in0, in1, in2, in3, in4, in5, in6, in7;
-v16i8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 16, 17, 17, 18, 18, 19, 19, 20 };
-v16i8 mask1, vec0, vec1;
+v16i8 mask0 = LD_SB(&ff_hevc_mask_arr[16]);
+v16i8 mask1, vec0, vec1, vec2, vec3;
 v8i16 tmp0, tmp1, tmp2, tmp3;
 v8i16 filter_vec, const_vec;
 
@@ -2300,18 +2301,18 @@ static void hevc_hz_bi_4t_4x8multiple_msa(uint8_t 
*src0_ptr,
 ILVR_D2_SH(in5, in4, in7, in6, in2, in3);
 XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7);
 
-VSHF_B2_SB(src0, src1, src0, src1, mask0, mask1, vec0, vec1);
 tmp0 = const_vec;
-DPADD_SB2_SH(vec0, vec1, filt0, filt1, tmp0, tmp0);
-VSHF_B2_SB(src2, src3, src2, src3, mask0, mask1, vec0, vec1);
 tmp1 = const_vec;
-DPADD_SB2_SH(vec0, vec1, filt0, filt1, tmp1, tmp1);
-VSHF_B2_SB(src4, src5, src4, src5, mask0, mask1, vec0, vec1);
 tmp2 = const_vec;
-DPADD_SB2_SH(vec0, vec1, filt0, filt1, tmp2, tmp2);
-VSHF_B2_SB(src6, src7, src6, src7, mask0, mask1, vec0, vec1);
 tmp3 = const_vec;
-DPADD_SB2_SH(vec0, vec1, filt0, filt1, tmp3, tmp3);
+VSHF_B2_SB(src0, src1, src2, src3, mask0, mask0, vec0, vec1);
+VSHF_B2_SB(src4, src5, src6, src7, mask0, mask0, vec2, vec3);
+DPADD_SB4_SH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, tmp0,
+ tmp1, tmp2, tmp3);
+VSHF_B2_SB(src0, src1, src2, src3, mask1, mask1, vec0, vec1);
+VSHF_B2_SB(src4, src5, src6, src7, mask1, mask1, vec2, vec3);
+DPADD_SB4_SH(vec0, vec1, vec2, vec3, filt1, filt1, filt1, filt1, tmp0,
+ tmp1, tmp2, tmp3);
 
 HEVC_BI_RND_CLIP4(in0, in1, in2, in3,
   tmp0, tmp1, tmp2, tmp3, 7, tmp0, tmp1, tmp2, tmp3);
@@ -2357,9 +2358,9 @@ static void hevc_hz_bi_4t_6w_msa(uint8_t *src0_ptr,
 v8i16 filt0, filt1;
 v16i8 src0, src1, src2, src3;
 v8i16 in0, in1, in2, in3;
-v16i8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
+v16i8 mask0 = LD_SB(&ff_hevc_mask_arr[0]);
 v16i8 mask1;
-v16i8 vec0, vec1;
+v16i8 vec0, vec1, vec2, vec3;
 v8i16 dst0, dst1, dst2, dst3;
 v8i16 filter_vec, const_vec;
 
@@ -2380,18 +2381,18 @@ static void hevc_hz_bi_4t_6w_msa(uint8_t *src0_ptr,
 src1_ptr += (4 * src2_stride);
 XORI_B4_128_SB(src0, src1, src2, src3);
 
-VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1);
 dst0 = const_vec;
-DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst0, dst0);
-VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec0, vec1);
 dst1 = const_vec;
-DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst1, dst1);
-VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec

[FFmpeg-devel] [PATCH] avcodec/mips: Improve hevc bi wgt 4 tap hz and vt mc msa functions

2017-11-02 Thread kaustubh.raste
From: Kaustubh Raste 

Use global mask buffer for appropriate mask load.

Signed-off-by: Kaustubh Raste 
---
 libavcodec/mips/hevc_mc_biw_msa.c |  587 -
 1 file changed, 247 insertions(+), 340 deletions(-)

diff --git a/libavcodec/mips/hevc_mc_biw_msa.c 
b/libavcodec/mips/hevc_mc_biw_msa.c
index 75c1c7a..0e5f8a0 100644
--- a/libavcodec/mips/hevc_mc_biw_msa.c
+++ b/libavcodec/mips/hevc_mc_biw_msa.c
@@ -2633,22 +2633,21 @@ static void hevc_hz_biwgt_4t_4x2_msa(uint8_t *src0_ptr,
  uint8_t *dst,
  int32_t dst_stride,
  const int8_t *filter,
- int32_t height,
  int32_t weight0,
  int32_t weight1,
  int32_t offset0,
  int32_t offset1,
  int32_t rnd_val)
 {
-int32_t offset, weight;
+int32_t offset, weight, constant;
 v8i16 filt0, filt1;
 v16i8 src0, src1;
 v8i16 in0, in1;
-v16i8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 16, 17, 17, 18, 18, 19, 19, 20 };
+v16i8 mask0 = LD_SB(&ff_hevc_mask_arr[16]);
 v16i8 mask1, vec0, vec1;
 v8i16 dst0;
 v4i32 dst0_r, dst0_l;
-v8i16 filter_vec, const_vec;
+v8i16 out0, filter_vec;
 v4i32 weight_vec, offset_vec, rnd_vec;
 
 src0_ptr -= 1;
@@ -2661,9 +2660,10 @@ static void hevc_hz_biwgt_4t_4x2_msa(uint8_t *src0_ptr,
 offset = (offset0 + offset1) << rnd_val;
 weight0 = weight0 & 0x;
 weight = weight0 | (weight1 << 16);
+constant = 128 * weight1;
+constant <<= 6;
+offset += constant;
 
-const_vec = __msa_ldi_h(128);
-const_vec <<= 6;
 offset_vec = __msa_fill_w(offset);
 weight_vec = __msa_fill_w(weight);
 rnd_vec = __msa_fill_w(rnd_val + 1);
@@ -2674,18 +2674,16 @@ static void hevc_hz_biwgt_4t_4x2_msa(uint8_t *src0_ptr,
 XORI_B2_128_SB(src0, src1);
 
 VSHF_B2_SB(src0, src1, src0, src1, mask0, mask1, vec0, vec1);
-dst0 = const_vec;
-DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst0, dst0);
+dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1);
 
 ILVRL_H2_SW(dst0, in0, dst0_r, dst0_l);
 dst0_r = __msa_dpadd_s_w(offset_vec, (v8i16) dst0_r, (v8i16) weight_vec);
 dst0_l = __msa_dpadd_s_w(offset_vec, (v8i16) dst0_l, (v8i16) weight_vec);
 SRAR_W2_SW(dst0_r, dst0_l, rnd_vec);
-dst0_r = CLIP_SW_0_255(dst0_r);
-dst0_l = CLIP_SW_0_255(dst0_l);
-
-HEVC_PCK_SW_SB2(dst0_l, dst0_r, dst0_r);
-ST4x2_UB(dst0_r, dst, dst_stride);
+dst0_r = (v4i32) __msa_pckev_h((v8i16) dst0_l, (v8i16) dst0_r);
+out0 = CLIP_SH_0_255(dst0_r);
+out0 = (v8i16) __msa_pckev_b((v16i8) out0, (v16i8) out0);
+ST4x2_UB(out0, dst, dst_stride);
 }
 
 static void hevc_hz_biwgt_4t_4x4_msa(uint8_t *src0_ptr,
@@ -2695,22 +2693,21 @@ static void hevc_hz_biwgt_4t_4x4_msa(uint8_t *src0_ptr,
  uint8_t *dst,
  int32_t dst_stride,
  const int8_t *filter,
- int32_t height,
  int32_t weight0,
  int32_t weight1,
  int32_t offset0,
  int32_t offset1,
  int32_t rnd_val)
 {
-int32_t offset, weight;
+int32_t offset, weight, constant;
 v8i16 filt0, filt1;
 v16i8 src0, src1, src2, src3;
-v16i8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 16, 17, 17, 18, 18, 19, 19, 20 };
+v16i8 mask0 = LD_SB(&ff_hevc_mask_arr[16]);
 v16i8 mask1;
 v8i16 dst0, dst1;
 v16i8 vec0, vec1;
 v8i16 in0, in1, in2, in3;
-v8i16 filter_vec, const_vec;
+v8i16 filter_vec;
 v4i32 weight_vec, offset_vec, rnd_vec;
 
 src0_ptr -= 1;
@@ -2724,9 +2721,10 @@ static void hevc_hz_biwgt_4t_4x4_msa(uint8_t *src0_ptr,
 offset = (offset0 + offset1) << rnd_val;
 weight0 = weight0 & 0x;
 weight = weight0 | (weight1 << 16);
+constant = 128 * weight1;
+constant <<= 6;
+offset += constant;
 
-const_vec = __msa_ldi_h(128);
-const_vec <<= 6;
 offset_vec = __msa_fill_w(offset);
 weight_vec = __msa_fill_w(weight);
 rnd_vec = __msa_fill_w(rnd_val + 1);
@@ -2737,11 +2735,9 @@ static void hevc_hz_biwgt_4t_4x4_msa(uint8_t *src0_ptr,
 ILVR_D2_SH(in1, in0, in3, in2, in0, in1);
 
 VSHF_B2_SB(src0, src1, src0, src1, mask0, mask1, vec0, vec1);
-dst0 = const_vec;
-DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst0, dst0);
+dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1);
 VSHF_B2_SB(src2, src3, src2, src3, mask0, mask1, vec0, vec1);
-dst1 = const_vec;
-DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst1, dst1);
+dst1 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1);
   

[FFmpeg-devel] GoPro Cineform open sourced

2017-11-02 Thread Robert Krüger
For anyone who hasn't stumbled over this yet:

https://gopro.com/news/gopro-open-sources-the-cineform-codec

Might be a target for integration (it includes an encoder) or contain clues
for ffmpeg's own decoder.

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


Re: [FFmpeg-devel] [PATCH 1/2] avformat/hlsenc: fix base_output_dirname is null when basename_size is 0 bug

2017-11-02 Thread Marton Balint


On Thu, 2 Nov 2017, Liu Steven wrote:




在 2017年11月2日,上午3:18,Marton Balint  写道:


On Wed, 1 Nov 2017, Marton Balint wrote:



On Sun, 29 Oct 2017, Liu Steven wrote:




在 2017年10月26日,上午7:54,Steven Liu  写道:
fix ticket id: #6777
when use argument hls_segment_filename, the basename_size will be 0
Signed-off-by: Steven Liu 
---
libavformat/hlsenc.c | 16 +++-
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 418f153c6f..55ce800c5a 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1335,6 +1335,7 @@ static int hls_write_header(AVFormatContext *s)
  AVDictionary *options = NULL;
  int basename_size = 0;
  int vtt_basename_size = 0;
+int fmp4_init_filename_len = strlen(hls->fmp4_init_filename) + 1;

  if (hls->segment_type == SEGMENT_TYPE_FMP4) {
  pattern = "%d.m4s";
@@ -1445,7 +1446,6 @@ static int hls_write_header(AVFormatContext *s)
  }

  if (av_strcasecmp(hls->fmp4_init_filename, "init.mp4")) {
-int fmp4_init_filename_len = strlen(hls->fmp4_init_filename) + 1;
  hls->base_output_dirname = av_malloc(fmp4_init_filename_len);
  if (!hls->base_output_dirname) {
  ret = AVERROR(ENOMEM);
@@ -1453,19 +1453,25 @@ static int hls_write_header(AVFormatContext *s)
  }
  av_strlcpy(hls->base_output_dirname, hls->fmp4_init_filename, 

fmp4_init_filename_len);

  } else {
-hls->base_output_dirname = av_malloc(basename_size);
+if (basename_size > 0) {
+hls->base_output_dirname = av_malloc(basename_size);
+} else {
+hls->base_output_dirname = 

av_malloc(strlen(hls->fmp4_init_filename));

+}
  if (!hls->base_output_dirname) {
  ret = AVERROR(ENOMEM);
  goto fail;
  }
-av_strlcpy(hls->base_output_dirname, s->filename, basename_size);
-p = strrchr(hls->base_output_dirname, '/');
+if (basename_size > 0) {
+av_strlcpy(hls->base_output_dirname, s->filename, 

basename_size);

+p = strrchr(hls->base_output_dirname, '/');
+}
  if (p) {
  *(p + 1) = '\0';
  av_strlcat(hls->base_output_dirname, hls->fmp4_init_filename, 

basename_size);

  } else {
-av_strlcpy(hls->base_output_dirname, hls->fmp4_init_filename, 

basename_size);
+av_strlcpy(hls->base_output_dirname, hls->fmp4_init_filename, 

fmp4_init_filename_len);

  }
  }
--
2.11.0 (Apple Git-81)


Applied!



This breaks fate-filter-hls-append, ffmpeg crashes or infinite loops for me:

==8410== Invalid write of size 1
==8410==at 0x102DD63: av_strlcpy (avstring.c:89)
==8410==by 0x6627D9: hls_write_header (hlsenc.c:1474)
==8410==by 0x6BD7E1: write_header_internal (mux.c:466)
==8410==by 0x6BF678: avformat_write_header (mux.c:519)
==8410==by 0x4A74D8: check_init_output_file (ffmpeg.c:2933)
==8410==by 0x4A8A55: init_output_stream.constprop.22 (ffmpeg.c:3572)
==8410==by 0x4AC645: reap_filters (ffmpeg.c:1424)
==8410==by 0x48F45E: transcode_step (ffmpeg.c:4540)
==8410==by 0x48F45E: transcode (ffmpeg.c:4584)
==8410==by 0x48F45E: main (ffmpeg.c:4790)
==8410==  Address 0xb3ded28 is 0 bytes after a block of size 8 alloc'd
==8410==at 0x4C2B5D0: memalign (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==8410==by 0x4C2B6E7: posix_memalign (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==8410==by 0x1044809: av_malloc (mem.c:87)
==8410==by 0x661DC0: hls_write_header (hlsenc.c:1459)
==8410==by 0x6BD7E1: write_header_internal (mux.c:466)
==8410==by 0x6BF678: avformat_write_header (mux.c:519)
==8410==by 0x4A74D8: check_init_output_file (ffmpeg.c:2933)
==8410==by 0x4A8A55: init_output_stream.constprop.22 (ffmpeg.c:3572)
==8410==by 0x4AC645: reap_filters (ffmpeg.c:1424)
==8410==by 0x48F45E: transcode_step (ffmpeg.c:4540)
==8410==by 0x48F45E: transcode (ffmpeg.c:4584)
==8410==by 0x48F45E: main (ffmpeg.c:4790)
==8410==


The above trace is for the offending commit, here is one for the current git 
master:

==8580== Invalid write of size 1
==8580==at 0x102CD13: av_strlcpy (avstring.c:89)
==8580==by 0x661B19: hls_write_header (hlsenc.c:1472)
==8580==by 0x6BD751: write_header_internal (mux.c:466)
==8580==by 0x6BF5E8: avformat_write_header (mux.c:519)
==8580==by 0x4A5058: check_init_output_file (ffmpeg.c:2939)
==8580==by 0x4A65D5: init_output_stream.constprop.23 (ffmpeg.c:3578)
==8580==by 0x4AABB5: reap_filters (ffmpeg.c:1424)
==8580==by 0x4AFFF8: transcode_step (ffmpeg.c:4546)
==8580==by 0x4AFFF8: transcode (ffmpeg.c:4590)
==8580==by 0x48DF41: main (ffmpeg.c:4796)
==8580==  Address 0xb3debe8 is 0 bytes after a block of size 8 alloc'd
==8580==at 0x4C2B5D0: memalign (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==8580==by 0x4C2B6E7: posix_memalign (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==8580==by 0x

Re: [FFmpeg-devel] [PATCH] avcodec/mmaldec: use zero-copy for AV_PIX_FMT_MMAL

2017-11-02 Thread Wang Bin


获取 Outlook for Android



发件人: Wang Bin
发送时间: 11月2日星期四 16:40
主题: Re: [FFmpeg-devel] [PATCH] avcodec/mmaldec: use zero-copy for 
AV_PIX_FMT_MMAL
收件人: FFmpeg development discussions and patches




获取 Outlook for Android

From: ffmpeg-devel  on behalf of wm4 

Sent: Monday, September 4, 2017 6:04:22 PM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH] avcodec/mmaldec: use zero-copy for 
AV_PIX_FMT_MMAL

On Sun,  3 Sep 2017 15:44:36 +0300
Yevhen Kyriukha  wrote:

> Signed-off-by: Yevhen Kyriukha 
> ---
>  libavcodec/mmaldec.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
> index 0b1195dc3e..19ca6ce7e7 100644
> --- a/libavcodec/mmaldec.c
> +++ b/libavcodec/mmaldec.c
> @@ -295,6 +295,8 @@ static int ffmal_update_format(AVCodecContext *avctx)
>  goto fail;
>
>  if (avctx->pix_fmt == AV_PIX_FMT_MMAL) {
> +if ((status = mmal_port_parameter_set_boolean(decoder->output[0], 
> MMAL_PARAMETER_ZERO_COPY, 1)))
> +goto fail;
>  format_out->encoding = MMAL_ENCODING_OPAQUE;
>  } else {
>  format_out->encoding_variant = format_out->encoding = 
> MMAL_ENCODING_I420;
> @@ -332,7 +334,8 @@ static int ffmal_update_format(AVCodecContext *avctx)
>  FFMAX(decoder->output[0]->buffer_size_min, 
> decoder->output[0]->buffer_size_recommended);
>  decoder->output[0]->buffer_num =
>  FFMAX(decoder->output[0]->buffer_num_min, 
> decoder->output[0]->buffer_num_recommended) + ctx->extra_buffers;
> -ctx->pool_out->pool = mmal_pool_create(decoder->output[0]->buffer_num,
> +ctx->pool_out->pool = mmal_port_pool_create(decoder->output[0],
> +   decoder->output[0]->buffer_num,
> decoder->output[0]->buffer_size);
>  if (!ctx->pool_out->pool) {
>  ret = AVERROR(ENOMEM);

Why the change, and what are the implications? (The commit message
should contain this.)
___
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] avcodec/mmaldec: use zero-copy for AV_PIX_FMT_MMAL

2017-11-02 Thread Wang Bin


?? Outlook for Android


From: ffmpeg-devel  on behalf of wm4 

Sent: Monday, September 4, 2017 6:04:22 PM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH] avcodec/mmaldec: use zero-copy for 
AV_PIX_FMT_MMAL

On Sun,  3 Sep 2017 15:44:36 +0300
Yevhen Kyriukha  wrote:

> Signed-off-by: Yevhen Kyriukha 
> ---
>  libavcodec/mmaldec.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
> index 0b1195dc3e..19ca6ce7e7 100644
> --- a/libavcodec/mmaldec.c
> +++ b/libavcodec/mmaldec.c
> @@ -295,6 +295,8 @@ static int ffmal_update_format(AVCodecContext *avctx)
>  goto fail;
>
>  if (avctx->pix_fmt == AV_PIX_FMT_MMAL) {
> +if ((status = mmal_port_parameter_set_boolean(decoder->output[0], 
> MMAL_PARAMETER_ZERO_COPY, 1)))
> +goto fail;
>  format_out->encoding = MMAL_ENCODING_OPAQUE;
>  } else {
>  format_out->encoding_variant = format_out->encoding = 
> MMAL_ENCODING_I420;
> @@ -332,7 +334,8 @@ static int ffmal_update_format(AVCodecContext *avctx)
>  FFMAX(decoder->output[0]->buffer_size_min, 
> decoder->output[0]->buffer_size_recommended);
>  decoder->output[0]->buffer_num =
>  FFMAX(decoder->output[0]->buffer_num_min, 
> decoder->output[0]->buffer_num_recommended) + ctx->extra_buffers;
> -ctx->pool_out->pool = mmal_pool_create(decoder->output[0]->buffer_num,
> +ctx->pool_out->pool = mmal_port_pool_create(decoder->output[0],
> +   decoder->output[0]->buffer_num,
> decoder->output[0]->buffer_size);
>  if (!ctx->pool_out->pool) {
>  ret = AVERROR(ENOMEM);

Why the change, and what are the implications? (The commit message
should contain this.)
___
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] avcodec/mmaldec: use zero-copy forAV_PIX_FMT_MMAL

2017-11-02 Thread wbsecg1

> On Sun, 3 Sep 2017 15:44:36 +0300
Yevhen Kyriukha  wrote:
>
>> Signed-off-by: Yevhen Kyriukha 
>> —
>> libavcodec/mmaldec.c | 5 -
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>> 
>> diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
>> index 0b1195dc3e..19ca6ce7e7 100644
>> --- a/libavcodec/mmaldec.c
>> +++ b/libavcodec/mmaldec.c
>> @@ -295,6 +295,8 @@ static int ffmal_update_format(AVCodecContext *avctx)
>> goto fail;
>>  
>> if (avctx->pix_fmt == AV_PIX_FMT_MMAL) {
>> + if ((status = mmal_port_parameter_set_boolean(decoder->output[0], 
>> MMAL_PARAMETER_ZERO_COPY, 1)))
>> + goto fail;
>> format_out->encoding = MMAL_ENCODING_OPAQUE;
>> } else {
>> format_out->encoding_variant = format_out->encoding = MMAL_ENCODING_I420;
>> @@ -332,7 +334,8 @@ static int ffmal_update_format(AVCodecContext *avctx)
>> FFMAX(decoder->output[0]->buffer_size_min, 
>> decoder->output[0]->buffer_size_recommended);
>> decoder->output[0]->buffer_num =
>> FFMAX(decoder->output[0]->buffer_num_min, 
>> decoder->output[0]->buffer_num_recommended) + ctx->extra_buffers;
>> - ctx->pool_out->pool = mmal_pool_create(decoder->output[0]->buffer_num,
>> + ctx->pool_out->pool = mmal_port_pool_create(decoder->output[0],
>> + decoder->output[0]->buffer_num,
>> decoder->output[0]->buffer_size);
>> if (!ctx->pool_out->pool) {
>> ret = AVERROR(ENOMEM);

> Why the change, and what are the implications? (The commit message
> should contain this.)

I have confirmed with this patch EGLImage can be created from decoded mmal 
buffer. It’s really useful for players.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat: add TiVo ty demuxer

2017-11-02 Thread Paul B Mahol
On 11/2/17, Michael Niedermayer  wrote:
> On Wed, Nov 01, 2017 at 02:40:27PM +0100, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavformat/Makefile |   1 +
>>  libavformat/allformats.c |   1 +
>>  libavformat/ty.c | 775
>> +++
>>  3 files changed, 777 insertions(+)
>>  create mode 100644 libavformat/ty.c
>
> [...]
>
>> +static int64_t get_pts(const uint8_t *buf)
>> +{
>> +int a = buf[0] & 0xe >> 1;
>> +int b = AV_RB16(buf + 1);
>> +int c = AV_RB16(buf + 3);
>> +
>> +if (!(1 & a & b & c))
>> +return AV_NOPTS_VALUE;
>> +
>> +a >>= 1;
>> +b >>= 1;
>> +c >>= 1;
>> +return (((uint64_t)a) << 30) | (b << 15) | c;
>> +}
>
> duplicate of ff_parse_pes_pts()
>
> i didnt check most of the code but seeing this, i wonder how much
> more mpeg demuxing this duplicates ?

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


Re: [FFmpeg-devel] [PATCH] avfilter: initial macroblock types export and visualization

2017-11-02 Thread Michael Niedermayer
Hi

On Sat, Oct 28, 2017 at 07:43:05AM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> On Fri, Oct 27, 2017 at 10:14 PM, Michael Niedermayer <
> mich...@niedermayer.cc> wrote:
> 
> > On Fri, Oct 27, 2017 at 10:03:54PM +0200, Paul B Mahol wrote:
> > > Signed-off-by: Paul B Mahol 
> > > ---
> > >  libavcodec/mpegvideo.c |  10 +
> > >  libavfilter/vf_codecview.c | 105 ++
> > +++
> > >  libavutil/frame.h  |   4 ++
> > >  3 files changed, 119 insertions(+)
> >
> > First, thanks for working on this.
> >
> >
> > [...]
> >
> > > diff --git a/libavutil/frame.h b/libavutil/frame.h
> > > index fef558ea2f..8481dc080b 100644
> > > --- a/libavutil/frame.h
> > > +++ b/libavutil/frame.h
> > > @@ -141,6 +141,10 @@ enum AVFrameSideDataType {
> > >   * metadata key entry "name".
> > >   */
> > >  AV_FRAME_DATA_ICC_PROFILE,
> > > +/**
> > > + * Macroblock types exported by some codecs.
> > > + */
> > > +AV_FRAME_DATA_MACROBLOCK_TYPES,
> > >  };
> > >
> >
> > This makes the internal data of the decoder part of the ABI and API of
> > libavcodec and libavfilter
> > and its undocumented
> >
> > do people prefer to make the internal data part of the ABI, document
> > it and ensure it does not change till the next bump
> >
> [..]
> 
> > or is there some other option iam missing ?
> >
> 
> I noted this on IRC also. A third option is to not document it and consider
> it codec-specific.
> 
> (Codec-specific implies "ABI/API unstable" and subject to change - "don't
> mix versions".)

If you say the interface is "ABI/API unstable" then we cannot use it
from another lib like libavfilter. So this would not work.


> 
> > or design a new interface, document it and convert to it?
> 
> I think we'd all prefer this, but this requires someone to do the work.
> Exciting!

how generic do we want this to be ?
do we have a volunteer to implement this ? because IMO the volunteer
doing the work should be the one primarly deciding how generic to do
this ...

16x16 MB only, or any size ?
first level of subdivision only or multi level ?
only H/V divisions at 50% points or any points, what about divisions by
non 90° angles?
what about non square or non rectangular MBs ?


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

Modern terrorism, a quick summary: Need oil, start war with country that
has oil, kill hundread thousand in war. Let country fall into chaos,
be surprised about raise of fundamantalists. Drop more bombs, kill more
people, be surprised about them taking revenge and drop even more bombs
and strip your own citizens of their rights and freedoms. to be continued


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


Re: [FFmpeg-devel] [PATCH 1/2] lavfi: check links properties after configuring them.

2017-11-02 Thread Nicolas George
Le primidi 11 brumaire, an CCXXVI, Clement Boesch a écrit :
> My bad, you're right, I was looking at the wrong header with the same
> variable names. Dismiss my comment.

Ok, series pushed.

> I'd say that a counter is unlikely to require a sign vs unsigned
> optimization (and if it does and we know the counter is positive only, we
> can explicit it with bit shifts etc). OTOH, the compiler will always have
> to assume an overflow can happen if the initial counter value comes from
> another variable, and you can't do much to hint it about it. Assuming a
> loop overflow has IMO much more impact of what the compiler can do in the
> general logic of the loop. But that's pure speculation from me.

I find the conclusion that lying to the compiler would help it make the
code faster it hard to swallow.

I think the real logic is this: unsigned, since they have a much simpler
semantic, have been optimized efficiently by compilers for a long time.
Recently, compilers have learned to use undefined behaviours to optimize
signed further, almost as much as unsigned. But not better.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_tile: remove limit of max tile size

2017-11-02 Thread Nicolas George
Le decadi 10 brumaire, an CCXXVI, Paul B Mahol a écrit :
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/vf_tile.c | 17 +
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/libavfilter/vf_tile.c b/libavfilter/vf_tile.c
> index 87e0b940cf..8eb0dc2097 100644
> --- a/libavfilter/vf_tile.c
> +++ b/libavfilter/vf_tile.c
> @@ -23,6 +23,7 @@
>   * tile video filter
>   */
>  
> +#include "libavutil/imgutils.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/pixdesc.h"
>  #include "avfilter.h"
> @@ -44,8 +45,6 @@ typedef struct TileContext {
>  uint8_t rgba_color[4];
>  } TileContext;
>  
> -#define REASONABLE_SIZE 1024
> -
>  #define OFFSET(x) offsetof(TileContext, x)
>  #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
>  
> @@ -68,12 +67,21 @@ static av_cold int init(AVFilterContext *ctx)
>  {
>  TileContext *tile = ctx->priv;
>  
> -if (tile->w > REASONABLE_SIZE || tile->h > REASONABLE_SIZE) {

> +if (tile->w > UINT32_MAX / tile->h) {

All the variables are of type unsigned, not uint32_t; therefore, the
correct limit would be UINT_MAX.

>  av_log(ctx, AV_LOG_ERROR, "Tile size %ux%u is insane.\n",
> tile->w, tile->h);
>  return AVERROR(EINVAL);
>  }
>  
> +if (tile->padding) {
> +if ((tile->w - 1 > (UINT32_MAX - 2 * tile->margin) / tile->padding) 
> ||
> +(tile->h - 1 > (UINT32_MAX - 2 * tile->margin) / tile->padding)) 
> {
> +av_log(ctx, AV_LOG_ERROR, "Combination of Tile size %ux%u, 
> padding %d and margin %d overflows.\n",
> +   tile->w, tile->h, tile->padding, tile->margin);
> +return AVERROR(EINVAL);
> +}
> +}
> +
>  if (tile->nb_frames == 0) {
>  tile->nb_frames = tile->w * tile->h;
>  } else if (tile->nb_frames > tile->w * tile->h) {
> @@ -116,7 +124,7 @@ static int config_props(AVFilterLink *outlink)
>  ff_draw_init(&tile->draw, inlink->format, 0);
>  ff_draw_color(&tile->draw, &tile->blank, tile->rgba_color);
>  

> -return 0;
> +return av_image_check_size2(outlink->w, outlink->h, INT64_MAX, 
> inlink->format, 0, ctx);

This is no longer necessary now it is done for all filters.

>  }
>  
>  static void get_current_tile_pos(AVFilterContext *ctx, unsigned *x, unsigned 
> *y)
> @@ -142,6 +150,7 @@ static void draw_blank_frame(AVFilterContext *ctx, 
> AVFrame *out_buf)
>x0, y0, inlink->w, inlink->h);
>  tile->current++;
>  }
> +
>  static int end_last_frame(AVFilterContext *ctx)
>  {
>  TileContext *tile = ctx->priv;

LGTM now. Thanks for your efforts.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] avfilter: initial macroblock types export and visualization

2017-11-02 Thread Paul B Mahol
On 11/2/17, Michael Niedermayer  wrote:
> Hi
>
> On Sat, Oct 28, 2017 at 07:43:05AM -0400, Ronald S. Bultje wrote:
>> Hi,
>>
>> On Fri, Oct 27, 2017 at 10:14 PM, Michael Niedermayer <
>> mich...@niedermayer.cc> wrote:
>>
>> > On Fri, Oct 27, 2017 at 10:03:54PM +0200, Paul B Mahol wrote:
>> > > Signed-off-by: Paul B Mahol 
>> > > ---
>> > >  libavcodec/mpegvideo.c |  10 +
>> > >  libavfilter/vf_codecview.c | 105 ++
>> > +++
>> > >  libavutil/frame.h  |   4 ++
>> > >  3 files changed, 119 insertions(+)
>> >
>> > First, thanks for working on this.
>> >
>> >
>> > [...]
>> >
>> > > diff --git a/libavutil/frame.h b/libavutil/frame.h
>> > > index fef558ea2f..8481dc080b 100644
>> > > --- a/libavutil/frame.h
>> > > +++ b/libavutil/frame.h
>> > > @@ -141,6 +141,10 @@ enum AVFrameSideDataType {
>> > >   * metadata key entry "name".
>> > >   */
>> > >  AV_FRAME_DATA_ICC_PROFILE,
>> > > +/**
>> > > + * Macroblock types exported by some codecs.
>> > > + */
>> > > +AV_FRAME_DATA_MACROBLOCK_TYPES,
>> > >  };
>> > >
>> >
>> > This makes the internal data of the decoder part of the ABI and API of
>> > libavcodec and libavfilter
>> > and its undocumented
>> >
>> > do people prefer to make the internal data part of the ABI, document
>> > it and ensure it does not change till the next bump
>> >
>> [..]
>>
>> > or is there some other option iam missing ?
>> >
>>
>> I noted this on IRC also. A third option is to not document it and
>> consider
>> it codec-specific.
>>
>> (Codec-specific implies "ABI/API unstable" and subject to change - "don't
>> mix versions".)
>
> If you say the interface is "ABI/API unstable" then we cannot use it
> from another lib like libavfilter. So this would not work.

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


[FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-02 Thread Felix Matouschek

Hello,

I've written an indev for Android devices to allow capturing their 
builtin cameras.

What needs to be done to merge this?

Greetings,
FelixFrom b21fc8729ef2e1d9867dd7652f2c6173378e4910 Mon Sep 17 00:00:00 2001
From: Felix Matouschek 
Date: Tue, 24 Oct 2017 13:11:23 +0200
Subject: [PATCH] Add android_capture indev
To: ffmpeg-devel@ffmpeg.org

This commit adds an indev for Android devices on API level 24+ which
uses the Android NDK Camera2 API to capture video from builtin cameras

Signed-off-by: Felix Matouschek 
---
 configure |   6 +
 libavdevice/Makefile  |   1 +
 libavdevice/alldevices.c  |   1 +
 libavdevice/android_capture.c | 782 ++
 libavdevice/android_capture.h |  77 +
 5 files changed, 867 insertions(+)
 create mode 100644 libavdevice/android_capture.c
 create mode 100644 libavdevice/android_capture.h

diff --git a/configure b/configure
index 7a53bc76c7..e2165f2ff9 100755
--- a/configure
+++ b/configure
@@ -3068,6 +3068,8 @@ xmv_demuxer_select="riffdec"
 xwma_demuxer_select="riffdec"
 
 # indevs / outdevs
+android_capture_indev_deps="android mediandk camera2ndk pthreads"
+android_capture_indev_extralibs="-landroid -lmediandk -lcamera2ndk"
 alsa_indev_deps="alsa"
 alsa_outdev_deps="alsa"
 avfoundation_indev_deps="avfoundation corevideo coremedia pthreads"
@@ -5836,6 +5838,10 @@ check_lib shell32  "windows.h shellapi.h" CommandLineToArgvW   -lshell32
 check_lib wincrypt "windows.h wincrypt.h" CryptGenRandom   -ladvapi32
 check_lib psapi"windows.h psapi.h"GetProcessMemoryInfo -lpsapi
 
+check_lib android android/native_window.h ANativeWindow_acquire -landroid
+check_lib mediandk "stdint.h media/NdkImage.h" AImage_delete -lmediandk
+check_lib camera2ndk "stdbool.h stdint.h camera/NdkCameraManager.h" ACameraManager_create -lcamera2ndk
+
 enabled appkit   && check_apple_framework AppKit
 enabled audiotoolbox && check_apple_framework AudioToolbox
 enabled avfoundation && check_apple_framework AVFoundation
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index 8228d62147..aa01dd7e24 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -14,6 +14,7 @@ OBJS-$(CONFIG_SHARED)+= reverse.o
 # input/output devices
 OBJS-$(CONFIG_ALSA_INDEV)+= alsa_dec.o alsa.o timefilter.o
 OBJS-$(CONFIG_ALSA_OUTDEV)   += alsa_enc.o alsa.o
+OBJS-$(CONFIG_ANDROID_CAPTURE_INDEV) += android_capture.o
 OBJS-$(CONFIG_AVFOUNDATION_INDEV)+= avfoundation.o
 OBJS-$(CONFIG_BKTR_INDEV)+= bktr.o
 OBJS-$(CONFIG_CACA_OUTDEV)   += caca.o
diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index b767b6a718..6cd57aa88a 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -42,6 +42,7 @@ static void register_all(void)
 {
 /* devices */
 REGISTER_INOUTDEV(ALSA, alsa);
+REGISTER_INDEV   (ANDROID_CAPTURE,  android_capture);
 REGISTER_INDEV   (AVFOUNDATION, avfoundation);
 REGISTER_INDEV   (BKTR, bktr);
 REGISTER_OUTDEV  (CACA, caca);
diff --git a/libavdevice/android_capture.c b/libavdevice/android_capture.c
new file mode 100644
index 00..be0dee8f81
--- /dev/null
+++ b/libavdevice/android_capture.c
@@ -0,0 +1,782 @@
+/*
+ * Android camera/microphone input source via Android NDK APIs (Audio yet to be implemented)
+ *
+ * Copyright (C) 2017 Felix Matouschek
+ *
+ * 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 
+
+#include 
+#include 
+#include 
+
+#include "libavformat/internal.h"
+#include "libavutil/avstring.h"
+#include "libavutil/display.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
+
+#include "android_capture.h"
+#include "version.h"
+
+/* This image format is available on all Android devices
+ * supporting the Camera2 API */
+#define IMAGE_FORMAT_ANDROID AIMAGE_FORMAT_YUV_420_888
+#define IMAGE_FORMAT_FFMPEG AV_PIX_FMT_YUV420P
+#define IMAGE_NUM_PLANES 3
+
+#define MAX_BUF_COUNT 2
+#define VIDEO_STREAM_ID 0
+#define VIDEO_TIMEBASE 10
+#define AUDIO_STREAM_ID 1
+
+static int parse_token_to_int(char *token, int *out)
+{
+long l;
+