[FFmpeg-devel] [PATCH] checkasm: add fixed_dsp tests

2016-01-18 Thread James Almer
Signed-off-by: James Almer 
---
 tests/checkasm/Makefile|   3 +
 tests/checkasm/checkasm.c  |   3 +
 tests/checkasm/checkasm.h  |   1 +
 tests/checkasm/fixed_dsp.c | 169 +
 4 files changed, 176 insertions(+)
 create mode 100644 tests/checkasm/fixed_dsp.c

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index e38d15b..698ceef 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -11,7 +11,10 @@ AVCODECOBJS-$(CONFIG_PIXBLOCKDSP) += pixblockdsp.o
 AVCODECOBJS-$(CONFIG_V210_ENCODER) += v210enc.o
 AVCODECOBJS-$(CONFIG_VP9_DECODER) += vp9dsp.o
 
+AVUTILOBJS += fixed_dsp.o
+
 CHECKASMOBJS-$(CONFIG_AVCODEC) += $(AVCODECOBJS-yes)
+CHECKASMOBJS-$(CONFIG_AVUTIL)  += $(AVUTILOBJS)
 
 
 -include $(SRC_PATH)/tests/checkasm/$(ARCH)/Makefile
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 7f2cf8e..1da085c 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -58,6 +58,9 @@ static const struct {
 const char *name;
 void (*func)(void);
 } tests[] = {
+#if CONFIG_AVUTIL
+{ "fixed_dsp", checkasm_check_fixed_dsp },
+#endif
 #if CONFIG_AVCODEC
 #if CONFIG_ALAC_DECODER
 { "alacdsp", checkasm_check_alacdsp },
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 69416e9..dc3519d 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -33,6 +33,7 @@
 void checkasm_check_alacdsp(void);
 void checkasm_check_bswapdsp(void);
 void checkasm_check_dcadsp(void);
+void checkasm_check_fixed_dsp(void);
 void checkasm_check_flacdsp(void);
 void checkasm_check_fmtconvert(void);
 void checkasm_check_h264pred(void);
diff --git a/tests/checkasm/fixed_dsp.c b/tests/checkasm/fixed_dsp.c
new file mode 100644
index 000..ac7a0b4
--- /dev/null
+++ b/tests/checkasm/fixed_dsp.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2015 James Almer
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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 "checkasm.h"
+#include "libavutil/common.h"
+#include "libavutil/fixed_dsp.h"
+#include "libavutil/internal.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mem.h"
+
+#define BUF_SIZE 256
+
+#define randomize_buffers()   \
+do {  \
+int i;\
+for (i = 0; i < BUF_SIZE; i++) {  \
+src0[i] = sign_extend(rnd(), 24); \
+src1[i] = sign_extend(rnd(), 24); \
+src2[i] = sign_extend(rnd(), 24); \
+} \
+} while (0)
+
+static void check_vector_fmul(const int *src0, const int *src1, const char 
*name)
+{
+LOCAL_ALIGNED_32(int, ref, [BUF_SIZE]);
+LOCAL_ALIGNED_32(int, new, [BUF_SIZE]);
+
+declare_func(void, int *dst, const int *src0, const int *src1, int len);
+
+call_ref(ref, src0, src1, BUF_SIZE);
+call_new(new, src0, src1, BUF_SIZE);
+if (memcmp(ref, new, BUF_SIZE * sizeof(int)))
+fail();
+bench_new(new, src0, src1, BUF_SIZE);
+
+report(name);
+}
+
+static void check_vector_fmul_window_scaled(const int32_t *src0, const int32_t 
*src1, const int32_t *win)
+{
+LOCAL_ALIGNED_16(int16_t, ref, [BUF_SIZE]);
+LOCAL_ALIGNED_16(int16_t, new, [BUF_SIZE]);
+
+declare_func(void, int16_t *dst, const int32_t *src0, const int32_t *src1, 
const int32_t *win, int len, uint8_t bits);
+
+call_ref(ref, src0, src1, win, BUF_SIZE / 2, 2);
+call_new(new, src0, src1, win, BUF_SIZE / 2, 2);
+if (memcmp(ref, new, BUF_SIZE * sizeof(int16_t)))
+fail();
+bench_new(new, src0, src1, win, BUF_SIZE / 2, 2);
+
+report("vector_fmul_window_scaled");
+}
+
+static void check_vector_fmul_window(const int32_t *src0, const int32_t *src1, 
const int32_t *win)
+{
+LOCAL_ALIGNED_32(int32_t, ref, [BUF_SIZE]);
+LOCAL_ALIGNED_32(int32_t, new, [BUF_SIZE]);
+
+declare_func(void, int32_t *dst, const int32_t *src0, const int32_t *src1, 
const int32_t *win, int len);
+
+call_ref(ref, src0, src1, win, BUF_SIZE / 2);
+call_new(new, src0, src1, win, BUF_SIZE / 2);
+if (memcmp(ref, new, BUF_SIZE * sizeof(int32_t)))
+fail();
+bench_new(new, src0, src1, win, BUF_SIZE / 2);
+
+report("vector_fmul_window");
+}
+
+static void check_v

[FFmpeg-devel] [PATCH v2] lavf/qtpalette: Fix incorrect palettes

2016-01-18 Thread Mats Peterson

Minor changes.

Mats
>From 02aba0be72a6d84873a9eabf1669e921f771c738 Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Tue, 19 Jan 2016 03:38:15 +0100
Subject: [PATCH v2] lavf/qtpalette: Fix incorrect palettes

This patch corrects the colors of the 2 and 4 bpp palettes.

---
 libavformat/qtpalette.h |   34 ++
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/libavformat/qtpalette.h b/libavformat/qtpalette.h
index b2bd360..016e91f 100644
--- a/libavformat/qtpalette.h
+++ b/libavformat/qtpalette.h
@@ -31,29 +31,31 @@ static const uint8_t ff_qt_default_palette_2[2 * 3] = {
   0x00, 0x00, 0x00
 };
 
+/* From a screenshot of the "Monitors & Sound" control panel in Mac OS 7.5.5 */
 static const uint8_t ff_qt_default_palette_4[4 * 3] = {
-  0x93, 0x65, 0x5E,
   0xFF, 0xFF, 0xFF,
-  0xDF, 0xD0, 0xAB,
+  0xAC, 0xAC, 0xAC,
+  0x55, 0x55, 0x55,
   0x00, 0x00, 0x00
 };
 
+/* From a screenshot of the "Monitors & Sound" control panel in Mac OS 7.5.5 */
 static const uint8_t ff_qt_default_palette_16[16 * 3] = {
-  0xFF, 0xFB, 0xFF,
-  0xEF, 0xD9, 0xBB,
-  0xE8, 0xC9, 0xB1,
-  0x93, 0x65, 0x5E,
-  0xFC, 0xDE, 0xE8,
-  0x9D, 0x88, 0x91,
   0xFF, 0xFF, 0xFF,
-  0xFF, 0xFF, 0xFF,
-  0xFF, 0xFF, 0xFF,
-  0x47, 0x48, 0x37,
-  0x7A, 0x5E, 0x55,
-  0xDF, 0xD0, 0xAB,
-  0xFF, 0xFB, 0xF9,
-  0xE8, 0xCA, 0xC5,
-  0x8A, 0x7C, 0x77,
+  0xFC, 0xF3, 0x05,
+  0xFF, 0x64, 0x02,
+  0xDD, 0x08, 0x06,
+  0xF2, 0x08, 0x84,
+  0x46, 0x00, 0xA5,
+  0x00, 0x00, 0xD4,
+  0x02, 0xAB, 0xEA,
+  0x1F, 0xB7, 0x14,
+  0x00, 0x64, 0x11,
+  0x56, 0x2C, 0x05,
+  0x90, 0x71, 0x3A,
+  0xC0, 0xC0, 0xC0,
+  0x80, 0x80, 0x80,
+  0x40, 0x40, 0x40,
   0x00, 0x00, 0x00
 };
 
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH] checkasm: add videodsp emulated_edge_mc test.

2016-01-18 Thread Michael Niedermayer
On Mon, Jan 18, 2016 at 10:53:52AM -0500, Ronald S. Bultje wrote:
> ---
>  tests/checkasm/Makefile   |  1 +
>  tests/checkasm/checkasm.c |  3 ++
>  tests/checkasm/checkasm.h |  1 +
>  tests/checkasm/videodsp.c | 89 
> +++
>  4 files changed, 94 insertions(+)
>  create mode 100644 tests/checkasm/videodsp.c

tested on linux32 & 64 mingw32 & 64
fate passes

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


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


Re: [FFmpeg-devel] [PATCH v3 1/5] libavutil: some VAAPI infrastructure

2016-01-18 Thread Mark Thompson
On 19/01/16 00:18, Michael Niedermayer wrote:
> On Mon, Jan 18, 2016 at 10:49:51PM +, Mark Thompson wrote:
>>
>> ---
>>  configure  |   4 +
>>  libavutil/Makefile |   1 +
>>  libavutil/vaapi.c  | 497 
>> +
>>  libavutil/vaapi.h  | 123 +
>>  4 files changed, 625 insertions(+)
>>  create mode 100644 libavutil/vaapi.c
>>  create mode 100644 libavutil/vaapi.h
> 
> breaks build
> make distclean ; ./configure && make -j12
> ...
> 
> CC  libavutil/time.o
> CC  libavutil/timecode.o
> CC  libavutil/tree.o
> CC  libavutil/twofish.o
> CC  libavutil/utils.o
> CC  libavutil/vaapi.o
> CC  libavutil/x86/cpu.o
> In file included from libavutil/vaapi.c:23:0:
> libavutil/vaapi.h:63:5: error: unknown type name ‘VASurfaceAttrib’
> libavutil/vaapi.c: In function ‘vaapi_create_surfaces’:
> libavutil/vaapi.c:59:28: warning: passing argument 5 of ‘vaCreateSurfaces’ 
> makes integer from pointer without a cast [enabled by default]
> /usr/include/va/va.h:432:10: note: expected ‘int’ but argument is of type 
> ‘VASurfaceID *’
> libavutil/vaapi.c:59:28: warning: passing argument 6 of ‘vaCreateSurfaces’ 
> makes pointer from integer without a cast [enabled by default]
> /usr/include/va/va.h:432:10: note: expected ‘VASurfaceID *’ but argument is 
> of type ‘unsigned int’
> libavutil/vaapi.c:59:28: error: too many arguments to function 
> ‘vaCreateSurfaces’
> /usr/include/va/va.h:432:10: note: declared here
> libavutil/vaapi.c: In function ‘ff_vaapi_copy_to_surface’:
> libavutil/vaapi.c:447:9: error: ‘VA_FOURCC_BGRX’ undeclared (first use in 
> this function)
> libavutil/vaapi.c:447:9: note: each undeclared identifier is reported only 
> once for each function it appears in
> make: *** [libavutil/vaapi.o] Error 1
> make: *** Waiting for unfinished jobs
> 

Given the old vaCreateSurfaces you must have libva < 1.2.  libva >= 1.6 was 
stated as the requirement for now in the first email, though even done properly 
your setup would have everything here disabled at configure time.

I think the configure test will be looking for libva 1.2.1 / VAAPI 0.34 for 
most of this and libva 1.6.0 / VAAPI 0.37 for H.265 (with suitable ifdefs), 
though more testing is needed to know that those do actually always work.  (I 
have been using libva 1.6.2 / VAAPI 0.38.)

I'll write something sensible for that test and associated conditionals in the 
next version, even if it isn't exactly correct.

- Mark

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


Re: [FFmpeg-devel] [PATCH]lavc/mjpegdec: Only set SAR if resolution is available

2016-01-18 Thread Michael Niedermayer
On Tue, Jan 19, 2016 at 12:33:40AM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes ticket #4479 here.
> 
> Please comment, Carl Eugen

if w/h is set at that point then their values may be unrelated to the
actual w/h values thus the set_sar there is wrong even if w/h is set

the patch is fine, iam not sure if the call shouldnt be (re)moved
though
moving it might be somewhat non trivial

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data


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


Re: [FFmpeg-devel] [PATCH v3 1/5] libavutil: some VAAPI infrastructure

2016-01-18 Thread Michael Niedermayer
On Mon, Jan 18, 2016 at 10:49:51PM +, Mark Thompson wrote:
> 
> ---
>  configure  |   4 +
>  libavutil/Makefile |   1 +
>  libavutil/vaapi.c  | 497 
> +
>  libavutil/vaapi.h  | 123 +
>  4 files changed, 625 insertions(+)
>  create mode 100644 libavutil/vaapi.c
>  create mode 100644 libavutil/vaapi.h

breaks build
make distclean ; ./configure && make -j12
...

CC  libavutil/time.o
CC  libavutil/timecode.o
CC  libavutil/tree.o
CC  libavutil/twofish.o
CC  libavutil/utils.o
CC  libavutil/vaapi.o
CC  libavutil/x86/cpu.o
In file included from libavutil/vaapi.c:23:0:
libavutil/vaapi.h:63:5: error: unknown type name ‘VASurfaceAttrib’
libavutil/vaapi.c: In function ‘vaapi_create_surfaces’:
libavutil/vaapi.c:59:28: warning: passing argument 5 of ‘vaCreateSurfaces’ 
makes integer from pointer without a cast [enabled by default]
/usr/include/va/va.h:432:10: note: expected ‘int’ but argument is of type 
‘VASurfaceID *’
libavutil/vaapi.c:59:28: warning: passing argument 6 of ‘vaCreateSurfaces’ 
makes pointer from integer without a cast [enabled by default]
/usr/include/va/va.h:432:10: note: expected ‘VASurfaceID *’ but argument is of 
type ‘unsigned int’
libavutil/vaapi.c:59:28: error: too many arguments to function 
‘vaCreateSurfaces’
/usr/include/va/va.h:432:10: note: declared here
libavutil/vaapi.c: In function ‘ff_vaapi_copy_to_surface’:
libavutil/vaapi.c:447:9: error: ‘VA_FOURCC_BGRX’ undeclared (first use in this 
function)
libavutil/vaapi.c:447:9: note: each undeclared identifier is reported only once 
for each function it appears in
make: *** [libavutil/vaapi.o] Error 1
make: *** Waiting for unfinished jobs


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

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates


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


[FFmpeg-devel] [PATCH v3 2/2] ffplay: Toggle full screen when double-clicking the video window with the left mouse button.

2016-01-18 Thread Vittorio Gambaletta (VittGam)
Now that the seek only happens with the right mouse button, it makes
sense to toggle full screen when double-clicking with the left mouse
button, like other video players do.

Signed-off-by: Vittorio Gambaletta 

---
 Changelog |1 +
 ffplay.c  |   10 ++
 2 files changed, 11 insertions(+)

diff --git a/Changelog b/Changelog
index d458991..59bfbb1 100644
--- a/Changelog
+++ b/Changelog
@@ -55,6 +55,7 @@ version :
 - spectrumsynth filter
 - ahistogram filter
 - only seek with the right mouse button in ffplay
+- toggle full screen when double-clicking with the left mouse button in ffplay
 
 
 version 2.8:
diff --git a/ffplay.c b/ffplay.c
index 2fa7165..5b473e9 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -3473,6 +3473,16 @@ static void event_loop(VideoState *cur_stream)
 do_exit(cur_stream);
 break;
 }
+if (event.button.button == SDL_BUTTON_LEFT) {
+static int64_t last_mouse_left_click = 0;
+if (av_gettime_relative() - last_mouse_left_click <= 50) {
+toggle_full_screen(cur_stream);
+cur_stream->force_refresh = 1;
+last_mouse_left_click = 0;
+} else {
+last_mouse_left_click = av_gettime_relative();
+}
+}
 case SDL_MOUSEMOTION:
 if (cursor_hidden) {
 SDL_ShowCursor(1);
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v3 1/2] ffplay: Seek only when pressing the right mouse button on the video window.

2016-01-18 Thread Vittorio Gambaletta (VittGam)
Seeking by clicking on the video window can be annoying, because
the user might click on it accidentally while eg. trying to get
focus on it, and ffplay seeks instead.

This commit changes that behaviour to seek only when the right
mouse button is used to click and drag on the window.

Signed-off-by: Vittorio Gambaletta 

---
 Changelog |1 +
 ffplay.c  |4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index ed18cf1..d458991 100644
--- a/Changelog
+++ b/Changelog
@@ -54,6 +54,7 @@ version :
 - libstagefright support removed
 - spectrumsynth filter
 - ahistogram filter
+- only seek with the right mouse button in ffplay
 
 
 version 2.8:
diff --git a/ffplay.c b/ffplay.c
index d2e3dc6..2fa7165 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -3480,9 +3480,11 @@ static void event_loop(VideoState *cur_stream)
 }
 cursor_last_shown = av_gettime_relative();
 if (event.type == SDL_MOUSEBUTTONDOWN) {
+if (event.button.button != SDL_BUTTON_RIGHT)
+break;
 x = event.button.x;
 } else {
-if (event.motion.state != SDL_PRESSED)
+if (!(event.motion.state & SDL_BUTTON_RMASK))
 break;
 x = event.motion.x;
 }
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH]lavc/mjpegdec: Only set SAR if resolution is available

2016-01-18 Thread Carl Eugen Hoyos
Hi!

Attached patch fixes ticket #4479 here.

Please comment, Carl Eugen
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index b1c5b67..0e95ebd 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1653,7 +1653,8 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
 
 s->avctx->sample_aspect_ratio.num = get_bits(&s->gb, 16);
 s->avctx->sample_aspect_ratio.den = get_bits(&s->gb, 16);
-ff_set_sar(s->avctx, s->avctx->sample_aspect_ratio);
+if (s->avctx->width > 0 && s->avctx->height > 0)
+ff_set_sar(s->avctx, s->avctx->sample_aspect_ratio);
 
 if (s->avctx->debug & FF_DEBUG_PICT_INFO)
 av_log(s->avctx, AV_LOG_INFO,
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavutil: add mastering display metadata sidedata

2016-01-18 Thread Michael Niedermayer
On Sat, Jan 16, 2016 at 04:19:38PM -0800, Neil Birkbeck wrote:
> Adding mastering display metadata struct to avutil. The mastering display 
> metadata contains information 
> about the mastering display color volume (SMPTE 2086:2014). 
> 
> This info comes from HEVC in the SEI_TYPE_MASTERING_DISPLAY_INFO and is soon 
> to be included in MKV:
> https://mailarchive.ietf.org/arch/search/?email_list=cellar&gbt=1&index=sZyfPTM-QY69P-0omfOIiTN622o
> so it is similar to SEI FPA / stereo_mode in MKV and as such this patch 
> follows how AVStereo3D is implemented.
> 
> I'll add support to HEVC in a follow-up (and MKV when spec is approved).
> 
> Signed-off-by: Neil Birkbeck 
> ---
>  libavutil/Makefile |  2 +
>  libavutil/frame.h  |  7 ++-
>  libavutil/mastering_display_metadata.c | 43 +
>  libavutil/mastering_display_metadata.h | 87 
> ++
>  libavutil/version.h|  2 +-
>  5 files changed, 139 insertions(+), 2 deletions(-)
>  create mode 100644 libavutil/mastering_display_metadata.c
>  create mode 100644 libavutil/mastering_display_metadata.h
> 
> diff --git a/libavutil/Makefile b/libavutil/Makefile
> index bf8c713..65b2d25 100644
> --- a/libavutil/Makefile
> +++ b/libavutil/Makefile
> @@ -38,6 +38,7 @@ HEADERS = adler32.h 
> \
>log.h \
>macros.h  \
>mathematics.h \
> +  mastering_display_metadata.h  \
>md5.h \
>mem.h \
>motion_vector.h   \
> @@ -115,6 +116,7 @@ OBJS = adler32.o  
>   \
> log.o\
> log2_tab.o   \
> mathematics.o\
> +   mastering_display_metadata.o \
> md5.o\
> mem.o\
> murmur3.o\
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index 9c6061a..308355b 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -106,12 +106,17 @@ enum AVFrameSideDataType {
>   * @endcode
>   */
>  AV_FRAME_DATA_SKIP_SAMPLES,
> -
>  /**
>   * This side data must be associated with an audio frame and corresponds 
> to
>   * enum AVAudioServiceType defined in avcodec.h.
>   */
>  AV_FRAME_DATA_AUDIO_SERVICE_TYPE,

> +/**
> + * Mastering display metadata associated with a video frame. The payload 
> is
> + * an AVMasteringDisplayMetadata type and contains information about the
> + * mastering display color volume.
> + */
> +AV_FRAME_DATA_MASTERING_DISPLAY_METADATA

will this always stay the same or could it require to be extended in
the future ?
if future extensions may occur then it should be documented how that
would work. Would fields be added to the end of the struct ?
If so how would this be detected ?

C does not gurantee the sizeof to change for the addition of fields
for example these 2 are both 8bytes on x86-64
typedef struct X { int a; char b; }X;
typedef struct Y { int a; char b; char c; }Y;

defining the meaning of the sidedata byte per byte avoids the problem
of detectability it also makes the function endian and ABI independant
and would allow passing it bytewise between computers, no idea how
much thats a real world use case though

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

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


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


Re: [FFmpeg-devel] [PATCH] configure: disable -Wunused-const-variable

2016-01-18 Thread James Almer
On 1/18/2016 7:56 PM, Michael Niedermayer wrote:
> On Mon, Jan 18, 2016 at 04:29:35PM -0300, James Almer wrote:
>> The option became too aggressive with GCC 6, generating nearly 500
>> warnings from static const variables defined in assorted headers
>>
>> Signed-off-by: James Almer 
>> ---
>> Compare 
>> http://fate.ffmpeg.org/report.cgi?time=20150921041049&slot=x86_64-archlinux-gcc-experimental
>> with 
>> http://fate.ffmpeg.org/report.cgi?time=20150923012551&slot=x86_64-archlinux-gcc-experimental
>>
>>  configure | 1 +
>>  1 file changed, 1 insertion(+)
> 
> LGTM
> 
> thx

Pushed.

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


[FFmpeg-devel] [PATCH v3 5/5] libavfilter: VAAPI surface converter

2016-01-18 Thread Mark Thompson

---
 configure   |   1 +
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_vaapi_conv.c | 480 
 4 files changed, 483 insertions(+)
 create mode 100644 libavfilter/vf_vaapi_conv.c

diff --git a/configure b/configure
index 9da8e8b..71c0bc0 100755
--- a/configure
+++ b/configure
@@ -2913,6 +2913,7 @@ stereo3d_filter_deps="gpl"
 subtitles_filter_deps="avformat avcodec libass"
 super2xsai_filter_deps="gpl"
 tinterlace_filter_deps="gpl"
+vaapi_conv_filter_deps="vaapi"
 vidstabdetect_filter_deps="libvidstab"
 vidstabtransform_filter_deps="libvidstab"
 pixfmts_super2xsai_test_deps="super2xsai_filter"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index e3e3561..9a4ca12 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -246,6 +246,7 @@ OBJS-$(CONFIG_TRANSPOSE_FILTER)  += 
vf_transpose.o
 OBJS-$(CONFIG_TRIM_FILTER)   += trim.o
 OBJS-$(CONFIG_UNSHARP_FILTER)+= vf_unsharp.o
 OBJS-$(CONFIG_USPP_FILTER)   += vf_uspp.o
+OBJS-$(CONFIG_VAAPI) += vf_vaapi_conv.o
 OBJS-$(CONFIG_VECTORSCOPE_FILTER)+= vf_vectorscope.o
 OBJS-$(CONFIG_VFLIP_FILTER)  += vf_vflip.o
 OBJS-$(CONFIG_VIDSTABDETECT_FILTER)  += vidstabutils.o 
vf_vidstabdetect.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 1faf393..cfbfdca 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -266,6 +266,7 @@ void avfilter_register_all(void)
 REGISTER_FILTER(TRIM,   trim,   vf);
 REGISTER_FILTER(UNSHARP,unsharp,vf);
 REGISTER_FILTER(USPP,   uspp,   vf);
+REGISTER_FILTER(VAAPI_CONV, vaapi_conv, vf);
 REGISTER_FILTER(VECTORSCOPE,vectorscope,vf);
 REGISTER_FILTER(VFLIP,  vflip,  vf);
 REGISTER_FILTER(VIDSTABDETECT,  vidstabdetect,  vf);
diff --git a/libavfilter/vf_vaapi_conv.c b/libavfilter/vf_vaapi_conv.c
new file mode 100644
index 000..5180e7c
--- /dev/null
+++ b/libavfilter/vf_vaapi_conv.c
@@ -0,0 +1,480 @@
+/*
+ * VAAPI converter (scaling and colour conversion).
+ *
+ * Copyright (C) 2016 Mark Thompson 
+ *
+ * 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 "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+
+#include "libavutil/avassert.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/vaapi.h"
+
+#include 
+
+typedef struct VAAPIConvContext {
+const AVClass *class;
+
+AVVAAPIHardwareContext *hardware_context;
+AVVAAPIPipelineConfig va_config;
+AVVAAPIPipelineContext va_context;
+int pipeline_initialised;
+
+int input_is_vaapi;
+AVVAAPISurfaceConfig input_config;
+AVVAAPISurfaceConfig output_config;
+
+int output_width;
+int output_height;
+
+struct {
+int64_t hardware_context;
+int output_size[2];
+} options;
+
+} VAAPIConvContext;
+
+
+static int vaapi_conv_query_formats(AVFilterContext *avctx)
+{
+VAAPIConvContext *ctx = avctx->priv;
+VAStatus vas;
+VAConfigAttrib rt_format = {
+.type = VAConfigAttribRTFormat
+};
+enum AVPixelFormat pix_fmt_list[16] = {
+AV_PIX_FMT_VAAPI,
+};
+int pix_fmt_count = 1, err;
+
+#if 0
+// The Intel driver doesn't return anything useful here - it only
+// declares support for YUV 4:2:0 formats, despite working perfectly
+// with 32-bit RGB ones.  Given another usable platform, this will
+// need to be updated.
+vas = vaGetConfigAttributes(ctx->hardware_context->display,
+VAProfileNone, VAEntrypointVideoProc,
+&rt_format, 1);
+#else
+vas = VA_STATUS_SUCCESS;
+rt_format.value = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_RGB32;
+#endif
+if(vas != VA_STATUS_SUCCESS) {
+av_log(ctx, AV_LOG_ERROR, "Failed to get config attributes: "
+   "%d (%s).\n", vas, vaErrorStr(vas));
+} else {
+if(rt_format.value & VA_RT_FORMAT_YUV420) {
+av_log(ctx, AV_LOG_DEBUG, "YUV420 formats supported.\n");
+pix_fmt_list[pix_fmt_count++] = AV_PIX_FMT_YUV420P;
+  

Re: [FFmpeg-devel] [PATCH] configure: disable -Wunused-const-variable

2016-01-18 Thread Michael Niedermayer
On Mon, Jan 18, 2016 at 04:29:35PM -0300, James Almer wrote:
> The option became too aggressive with GCC 6, generating nearly 500
> warnings from static const variables defined in assorted headers
> 
> Signed-off-by: James Almer 
> ---
> Compare 
> http://fate.ffmpeg.org/report.cgi?time=20150921041049&slot=x86_64-archlinux-gcc-experimental
> with 
> http://fate.ffmpeg.org/report.cgi?time=20150923012551&slot=x86_64-archlinux-gcc-experimental
> 
>  configure | 1 +
>  1 file changed, 1 insertion(+)

LGTM

thx

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

DNS cache poisoning attacks, popular search engine, Google internet authority
dont be evil, please


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


[FFmpeg-devel] [PATCH v3 4/5] libavcodec: VAAPI H.265 encoder

2016-01-18 Thread Mark Thompson

---
 configure   |1 +
 libavcodec/Makefile |1 +
 libavcodec/allcodecs.c  |1 +
 libavcodec/vaapi_enc_hevc.c | 1625 +++
 4 files changed, 1628 insertions(+)
 create mode 100644 libavcodec/vaapi_enc_hevc.c

diff --git a/configure b/configure
index a31d65e..9da8e8b 100755
--- a/configure
+++ b/configure
@@ -2519,6 +2519,7 @@ hevc_dxva2_hwaccel_select="hevc_decoder"
 hevc_qsv_hwaccel_deps="libmfx"
 hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC"
 hevc_vaapi_hwaccel_select="hevc_decoder"
+hevc_vaapi_encoder_deps="vaapi"
 hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC"
 hevc_vdpau_hwaccel_select="hevc_decoder"
 mpeg_vdpau_decoder_deps="vdpau"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 06b3c48..a5e1cab 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -311,6 +311,7 @@ OBJS-$(CONFIG_HEVC_DECODER)+= hevc.o hevc_mvs.o 
hevc_ps.o hevc_sei.o
   hevcdsp.o hevc_filter.o hevc_parse.o 
hevc_data.o
 OBJS-$(CONFIG_HEVC_QSV_DECODER)+= qsvdec_h2645.o
 OBJS-$(CONFIG_HEVC_QSV_ENCODER)+= qsvenc_hevc.o hevc_ps_enc.o 
hevc_parse.o
+OBJS-$(CONFIG_HEVC_VAAPI_ENCODER)  += vaapi_enc_hevc.o
 OBJS-$(CONFIG_HNM4_VIDEO_DECODER)  += hnm4video.o
 OBJS-$(CONFIG_HQ_HQA_DECODER)  += hq_hqa.o hq_hqadata.o hq_hqadsp.o \
   canopus.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 0d07087..a25da5b 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -203,6 +203,7 @@ void avcodec_register_all(void)
 REGISTER_ENCDEC (HAP,   hap);
 REGISTER_DECODER(HEVC,  hevc);
 REGISTER_DECODER(HEVC_QSV,  hevc_qsv);
+REGISTER_ENCODER(HEVC_VAAPI,hevc_vaapi);
 REGISTER_DECODER(HNM4_VIDEO,hnm4_video);
 REGISTER_DECODER(HQ_HQA,hq_hqa);
 REGISTER_DECODER(HQX,   hqx);
diff --git a/libavcodec/vaapi_enc_hevc.c b/libavcodec/vaapi_enc_hevc.c
new file mode 100644
index 000..885f1c8
--- /dev/null
+++ b/libavcodec/vaapi_enc_hevc.c
@@ -0,0 +1,1625 @@
+/*
+ * VAAPI H.265 encoder.
+ *
+ * Copyright (C) 2016 Mark Thompson 
+ *
+ * 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 "avcodec.h"
+#include "golomb.h"
+#include "put_bits.h"
+
+#include "hevc.h"
+
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/vaapi.h"
+
+#define MAX_DPB_PICS 16
+#define INPUT_PICS   2
+
+#define bool unsigned char
+#define MAX_ST_REF_PIC_SETS  32
+#define MAX_LAYERS1
+
+
+// This structure contains all possibly-useful per-sequence syntax elements
+// which are not already contained in the various VAAPI structures.
+typedef struct VAAPIHEVCEncodeMiscSequenceParams {
+
+// Parameter set IDs.
+unsigned int video_parameter_set_id;
+unsigned int seq_parameter_set_id;
+
+// Layering.
+unsigned int vps_max_layers_minus1;
+unsigned int vps_max_sub_layers_minus1;
+bool vps_temporal_id_nesting_flag;
+unsigned int vps_max_layer_id;
+unsigned int vps_num_layer_sets_minus1;
+unsigned int sps_max_sub_layers_minus1;
+bool sps_temporal_id_nesting_flag;
+bool layer_id_included_flag[MAX_LAYERS][64];
+
+// Profile/tier/level parameters.
+bool general_profile_compatibility_flag[32];
+bool general_progressive_source_flag;
+bool general_interlaced_source_flag;
+bool general_non_packed_constraint_flag;
+bool general_frame_only_constraint_flag;
+bool general_inbld_flag;
+
+// Decode/display ordering parameters.
+unsigned int log2_max_pic_order_cnt_lsb_minus4;
+bool vps_sub_layer_ordering_info_present_flag;
+unsigned int vps_max_dec_pic_buffering_minus1[MAX_LAYERS];
+unsigned int vps_max_num_reorder_pics[MAX_LAYERS];
+unsigned int vps_max_latency_increase_plus1[MAX_LAYERS];
+bool sps_sub_layer_ordering_info_present_flag;
+unsigned int sps_max_dec_pic_buffering_minus1[MAX_LAYERS];
+unsigned int sps_max_num_reorder_pics[MAX_LAYERS];
+unsigned int sps_max_latency_increase_plus1[MAX_LAYERS];
+
+// Timing information.
+bool vps_timing_info_present_flag;
+   

[FFmpeg-devel] [PATCH v3 3/5] libavcodec: VAAPI H.264 encoder

2016-01-18 Thread Mark Thompson

---
 configure   |   1 +
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/vaapi_enc_h264.c | 968 
 4 files changed, 971 insertions(+)
 create mode 100644 libavcodec/vaapi_enc_h264.c

diff --git a/configure b/configure
index 1c77015..a31d65e 100755
--- a/configure
+++ b/configure
@@ -2499,6 +2499,7 @@ h264_mmal_encoder_deps="mmal"
 h264_qsv_hwaccel_deps="libmfx"
 h264_vaapi_hwaccel_deps="vaapi"
 h264_vaapi_hwaccel_select="h264_decoder"
+h264_vaapi_encoder_deps="vaapi"
 h264_vda_decoder_deps="vda"
 h264_vda_decoder_select="h264_decoder"
 h264_vda_hwaccel_deps="vda"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index b9ffdb9..06b3c48 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -303,6 +303,7 @@ OBJS-$(CONFIG_H264_MMAL_DECODER)   += mmaldec.o
 OBJS-$(CONFIG_H264_VDA_DECODER)+= vda_h264_dec.o
 OBJS-$(CONFIG_H264_QSV_DECODER)+= qsvdec_h2645.o
 OBJS-$(CONFIG_H264_QSV_ENCODER)+= qsvenc_h264.o
+OBJS-$(CONFIG_H264_VAAPI_ENCODER)  += vaapi_enc_h264.o
 OBJS-$(CONFIG_HAP_DECODER) += hapdec.o hap.o
 OBJS-$(CONFIG_HAP_ENCODER) += hapenc.o hap.o
 OBJS-$(CONFIG_HEVC_DECODER)+= hevc.o hevc_mvs.o hevc_ps.o 
hevc_sei.o \
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 2128546..0d07087 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -199,6 +199,7 @@ void avcodec_register_all(void)
 #if FF_API_VDPAU
 REGISTER_DECODER(H264_VDPAU,h264_vdpau);
 #endif
+REGISTER_ENCODER(H264_VAAPI,h264_vaapi);
 REGISTER_ENCDEC (HAP,   hap);
 REGISTER_DECODER(HEVC,  hevc);
 REGISTER_DECODER(HEVC_QSV,  hevc_qsv);
diff --git a/libavcodec/vaapi_enc_h264.c b/libavcodec/vaapi_enc_h264.c
new file mode 100644
index 000..7e09f80
--- /dev/null
+++ b/libavcodec/vaapi_enc_h264.c
@@ -0,0 +1,968 @@
+/*
+ * VAAPI H.264 encoder.
+ *
+ * Copyright (C) 2016 Mark Thompson 
+ *
+ * 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 "avcodec.h"
+#include "golomb.h"
+#include "put_bits.h"
+
+#include "h264.h"
+
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/vaapi.h"
+
+#include 
+
+#define DPB_FRAMES  16
+#define INPUT_FRAMES 2
+
+typedef struct VAAPIH264EncodeFrame {
+AVFrame avframe;
+VASurfaceID surface_id;
+
+int frame_num;
+enum {
+FRAME_TYPE_I,
+FRAME_TYPE_P,
+FRAME_TYPE_B,
+} type;
+
+VAPictureH264 pic;
+VAEncSliceParameterBufferH264 params;
+VABufferID params_id;
+
+VABufferID coded_data_id;
+
+struct VAAPIH264EncodeFrame *refp, *refb;
+} VAAPIH264EncodeFrame;
+
+typedef struct VAAPIH264EncodeContext {
+const AVClass *class;
+
+AVVAAPIHardwareContext *hardware_context;
+AVVAAPIPipelineConfig va_config;
+AVVAAPIPipelineContext va_codec;
+
+AVVAAPISurfaceConfig input_config;
+AVVAAPISurfaceConfig output_config;
+
+VAProfile va_profile;
+int level;
+int rc_mode;
+int width;
+int height;
+
+VAEncSequenceParameterBufferH264 seq_params;
+VABufferID seq_params_id;
+
+VAEncMiscParameterRateControl rc_params;
+VAEncMiscParameterBuffer rc_params_buffer;
+VABufferID rc_params_id;
+
+VAEncPictureParameterBufferH264 pic_params;
+VABufferID pic_params_id;
+
+int frame_num;
+
+VAAPIH264EncodeFrame dpb[DPB_FRAMES];
+int current_frame;
+int previous_frame;
+
+struct {
+int64_t hardware_context;
+
+const char *profile;
+const char *level;
+int qp;
+int idr_interval;
+} options;
+
+} VAAPIH264EncodeContext;
+
+
+static int vaapi_h264_render_packed_header(VAAPIH264EncodeContext *ctx, int 
type,
+   char *data, size_t bit_len)
+{
+VAStatus vas;
+VABufferID id_list[2];
+VAEncPackedHeaderParameterBuffer buffer = {
+.type = type,
+.bit_length = bit_len,
+.has_emulation_bytes = 0,
+};
+
+vas = vaCreateBuffer(ctx->hardware_context->display, 
ctx->va_codec.context_id,
+ VAEncPackedHeaderParameterBufferType,
+ size

[FFmpeg-devel] [PATCH v3 2/5] ffmpeg: initialisation code for VAAPI, hwaccel helper

2016-01-18 Thread Mark Thompson

---
 Makefile   |   1 +
 ffmpeg.c   |   5 +
 ffmpeg.h   |   5 +
 ffmpeg_opt.c   |  14 ++
 ffmpeg_vaapi.c | 622 +
 5 files changed, 647 insertions(+)
 create mode 100644 ffmpeg_vaapi.c

diff --git a/Makefile b/Makefile
index 7836a20..be1d2ca 100644
--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,7 @@ OBJS-ffmpeg-$(CONFIG_VDA) += ffmpeg_videotoolbox.o
 endif
 OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += ffmpeg_videotoolbox.o
 OBJS-ffmpeg-$(CONFIG_LIBMFX)  += ffmpeg_qsv.o
+OBJS-ffmpeg-$(CONFIG_VAAPI)   += ffmpeg_vaapi.o
 OBJS-ffserver += ffserver_config.o

 TESTTOOLS   = audiogen videogen rotozoom tiny_psnr tiny_ssim base64
diff --git a/ffmpeg.c b/ffmpeg.c
index 1f4277c..e76879a 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2603,6 +2603,11 @@ static int init_output_stream(OutputStream *ost, char 
*error, int error_len)
 !av_dict_get(ost->encoder_opts, "ab", NULL, 0))
 av_dict_set(&ost->encoder_opts, "b", "128000", 0);

+#if CONFIG_VAAPI
+if(ost->enc->type == AVMEDIA_TYPE_VIDEO)
+vaapi_hardware_set_options(&ost->encoder_opts);
+#endif
+
 if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 
0) {
 if (ret == AVERROR_EXPERIMENTAL)
 abort_codec_experimental(codec, 1);
diff --git a/ffmpeg.h b/ffmpeg.h
index 20322b0..2134213 100644
--- a/ffmpeg.h
+++ b/ffmpeg.h
@@ -65,6 +65,7 @@ enum HWAccelID {
 HWACCEL_VDA,
 HWACCEL_VIDEOTOOLBOX,
 HWACCEL_QSV,
+HWACCEL_VAAPI,
 };

 typedef struct HWAccel {
@@ -577,5 +578,9 @@ int vda_init(AVCodecContext *s);
 int videotoolbox_init(AVCodecContext *s);
 int qsv_init(AVCodecContext *s);
 int qsv_transcode_init(OutputStream *ost);
+int vaapi_decode_init(AVCodecContext *s);
+
+int vaapi_hardware_init(const char *device);
+int vaapi_hardware_set_options(AVDictionary **dict);

 #endif /* FFMPEG_H */
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 9b341cf..47ac467 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -82,6 +82,9 @@ const HWAccel hwaccels[] = {
 #if CONFIG_LIBMFX
 { "qsv",   qsv_init,   HWACCEL_QSV,   AV_PIX_FMT_QSV },
 #endif
+#if CONFIG_VAAPI
+{ "vaapi", vaapi_decode_init, HWACCEL_VAAPI, AV_PIX_FMT_VAAPI },
+#endif
 { 0 },
 };

@@ -442,6 +445,13 @@ static int opt_sdp_file(void *optctx, const char *opt, 
const char *arg)
 return 0;
 }

+static int opt_vaapi(void *optctx, const char *opt, const char *arg)
+{
+if(vaapi_hardware_init(arg))
+exit_program(1);
+return 0;
+}
+
 /**
  * Parse a metadata specifier passed as 'arg' parameter.
  * @param arg  metadata string to parse
@@ -3438,5 +3448,9 @@ const OptionDef options[] = {
 { "dn", OPT_BOOL | OPT_VIDEO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off 
= OFFSET(data_disable) },
 "disable data" },

+#if CONFIG_VAAPI
+{ "vaapi", HAS_ARG, { .func_arg = opt_vaapi }, "set VAAPI hardware 
context" },
+#endif
+
 { NULL, },
 };
diff --git a/ffmpeg_vaapi.c b/ffmpeg_vaapi.c
new file mode 100644
index 000..e04532c
--- /dev/null
+++ b/ffmpeg_vaapi.c
@@ -0,0 +1,622 @@
+/*
+ * VAAPI helper for hardware-accelerated decoding.
+ *
+ * Copyright (C) 2016 Mark Thompson 
+ *
+ * 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 "ffmpeg.h"
+
+#include "libavutil/avassert.h"
+#include "libavutil/avconfig.h"
+#include "libavutil/buffer.h"
+#include "libavutil/frame.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixfmt.h"
+#include "libavutil/thread.h"
+#include "libavutil/vaapi.h"
+
+#include "libavcodec/vaapi.h"
+
+#include 
+#include 
+
+
+static AVClass vaapi_class = {
+.class_name = "VAAPI/driver",
+.item_name  = av_default_item_name,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+
+#define DEFAULT_SURFACES 20
+
+typedef struct VAAPIDecoderContext {
+const AVClass *class;
+
+AVVAAPIHardwareContext *hardware_context;
+AVVAAPIPipelineConfig config;
+AVVAAPIPipelineContext codec;
+AVVAAPISurfaceConfig output;
+
+int codec_initialised;
+
+AVFrame output_frame;
+} VAAPIDecoderContext;
+
+
+static int vaapi_get_buffer(AVCodecContext *s, AVFrame *frame, int flags)
+{
+InputStream *ist = s-

[FFmpeg-devel] [PATCH v3 1/5] libavutil: some VAAPI infrastructure

2016-01-18 Thread Mark Thompson

---
 configure  |   4 +
 libavutil/Makefile |   1 +
 libavutil/vaapi.c  | 497 +
 libavutil/vaapi.h  | 123 +
 4 files changed, 625 insertions(+)
 create mode 100644 libavutil/vaapi.c
 create mode 100644 libavutil/vaapi.h

diff --git a/configure b/configure
index 7cef6f5..1c77015 100755
--- a/configure
+++ b/configure
@@ -5739,6 +5739,10 @@ enabled vaapi && enabled xlib &&
 check_lib2 "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 &&
 enable vaapi_x11

+enabled vaapi &&
+check_lib2 "va/va.h va/va_drm.h" vaGetDisplayDRM -lva -lva-drm &&
+enable vaapi_drm
+
 enabled vdpau &&
 check_cpp_condition vdpau/vdpau.h "defined 
VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
 disable vdpau
diff --git a/libavutil/Makefile b/libavutil/Makefile
index bf8c713..8025f9f 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -146,6 +146,7 @@ OBJS-$(!HAVE_ATOMICS_NATIVE)+= atomic.o 
\

 OBJS-$(CONFIG_LZO)  += lzo.o
 OBJS-$(CONFIG_OPENCL)   += opencl.o opencl_internal.o
+OBJS-$(CONFIG_VAAPI)+= vaapi.o

 OBJS += $(COMPAT_OBJS:%=../compat/%)

diff --git a/libavutil/vaapi.c b/libavutil/vaapi.c
new file mode 100644
index 000..8a9a524
--- /dev/null
+++ b/libavutil/vaapi.c
@@ -0,0 +1,497 @@
+/*
+ * VAAPI helper functions.
+ *
+ * Copyright (C) 2016 Mark Thompson 
+ *
+ * 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 "vaapi.h"
+
+#include "avassert.h"
+#include "imgutils.h"
+#include "pixfmt.h"
+
+
+void av_vaapi_lock_hardware_context(AVVAAPIHardwareContext *ctx)
+{
+if(ctx->lock)
+ctx->lock();
+}
+
+void av_vaapi_unlock_hardware_context(AVVAAPIHardwareContext *ctx)
+{
+if(ctx->unlock)
+ctx->unlock();
+}
+
+
+static const AVClass vaapi_pipeline_class = {
+.class_name = "VAAPI/pipeline",
+.item_name  = av_default_item_name,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+static int vaapi_create_surfaces(AVVAAPIPipelineContext *ctx,
+ AVVAAPISurfaceConfig *config,
+ AVVAAPISurface *surfaces,
+ VASurfaceID *ids)
+{
+VAStatus vas;
+int i;
+
+vas = vaCreateSurfaces(ctx->hardware_context->display, config->rt_format,
+   config->width, config->height, ids, config->count,
+   config->attributes, config->attribute_count);
+if(vas != VA_STATUS_SUCCESS) {
+av_log(ctx, AV_LOG_ERROR, "Failed to create "
+   "surfaces: %d (%s).\n", vas, vaErrorStr(vas));
+return AVERROR(EINVAL);
+}
+
+for(i = 0; i < config->count; i++) {
+surfaces[i].id   = ids[i];
+surfaces[i].refcount = 0;
+surfaces[i].hardware_context = ctx->hardware_context;
+surfaces[i].config   = config;
+}
+
+return 0;
+}
+
+static void vaapi_destroy_surfaces(AVVAAPIPipelineContext *ctx,
+   AVVAAPISurfaceConfig *config,
+   AVVAAPISurface *surfaces,
+   VASurfaceID *ids)
+{
+VAStatus vas;
+int i;
+
+for(i = 0; i < config->count; i++) {
+av_assert0(surfaces[i].id == ids[i]);
+if(surfaces[i].refcount > 0)
+av_log(ctx, AV_LOG_WARNING, "Destroying surface %#x which is "
+   "still in use.\n", surfaces[i].id);
+av_assert0(surfaces[i].hardware_context == ctx->hardware_context);
+av_assert0(surfaces[i].config == config);
+}
+
+vas = vaDestroySurfaces(ctx->hardware_context->display,
+ids, config->count);
+if(vas != VA_STATUS_SUCCESS) {
+av_log(ctx, AV_LOG_ERROR, "Failed to destroy surfaces: "
+   "%d (%s).\n", vas, vaErrorStr(vas));
+}
+}
+
+int ff_vaapi_pipeline_init(AVVAAPIPipelineContext *ctx,
+   AVVAAPIHardwareContext *hw_ctx,
+   AVVAAPIPipelineConfig *config,
+   AVVAAPISurfaceConfig *input,
+   AVVAAPISurfaceConfig *output)
+{
+VAStatus vas;
+int err;
+
+// Currently this only supp

[FFmpeg-devel] [PATCH v3 0/5] VAAPI support infrastructure, encoders

2016-01-18 Thread Mark Thompson

Hi,

Following* is another attempt, eliminating all global state (and making the 
user set it up instead).

* Patch 1 loses all of the initialisation code while changing the hardware 
context structure to both be compatible with the one currently used by the 
decoder and to support locking.

* Patch 2 adds the initialisation code in a simpler form, and hacks it rather 
nastily into the ffmpeg driver in order to demonstrate this all working (a new 
top-level option -vaapi).  The hwaccel helper stays the same.  The setup here 
is not sensible yet, it needs to be integrated more coherently.

* Patches 3-5 are essentially the same as before, except they now receive the 
hardware context through a user-set option rather than from global state.


Problems:

* The decoder should also be updated to lock its use of the hardware context, 
but I have not done that here due to compatibility concerns.

* The vaapi filter doesn't actually work from the ffmpeg driver now - I'm not 
seeing how to pass the required extra option into the filter graph without 
ridiculous hackery.

* It still needs libva at least 1.6 to build at all (ran into this trying to 
build on Ubuntu 14.04; no H.265 in headers means it doesn't build at all).


Decode and encode:

./ffmpeg -vaapi :0 -hwaccel vaapi -i in.mp4 -an -c:v vaapi_h264 -qp 26 
-idr_interval 120 out.mp4


Comments invited.

Thanks,

- Mark


(*Or .)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] lavf/segment: add support for specifying clock time offset

2016-01-18 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 doc/muxers.texi   | 10 ++
 libavformat/segment.c | 11 ++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index a308d3d..c304221 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1100,6 +1100,16 @@ to create files at 12:00 o'clock, 12:15, 12:30, etc.
 
 Default value is "0".
 
+@item segment_clocktime_offset @var{duration}
+By setting this option you can delay the segment splitting times with the
+specified duration when using @option{segment_atclocktime}.
+
+For example with @option{segment_time} set to "900" and
+@option{segment_clocktime_offset} set to "300" this makes it possible to
+create files at 12:05, 12:20, 12:35, etc.
+
+Default value is "0".
+
 @item segment_time_delta @var{delta}
 Specify the accuracy time when selecting the start time for a
 segment, expressed as a duration specification. Default value is "0".
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 0c1f633..bf7a8fc 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -82,6 +82,7 @@ typedef struct SegmentContext {
 int   list_size;   ///< number of entries for the segment list file
 
 int use_clocktime;///< flag to cut segments at regular clock time
+int64_t clocktime_offset; //< clock offset for cutting the segments at 
regular clock time
 int64_t last_val;  ///< remember last time for wrap around detection
 int64_t last_cut;  ///< remember last cut
 int cut_pending;
@@ -633,6 +634,13 @@ static int seg_write_header(AVFormatContext *s)
seg->time_str);
 return ret;
 }
+if (seg->use_clocktime) {
+if (seg->time <= 0) {
+av_log(s, AV_LOG_ERROR, "Invalid segment_time\n");
+return AVERROR(EINVAL);
+}
+seg->clocktime_offset = seg->time - (seg->clocktime_offset % 
seg->time);
+}
 }
 
 if (seg->format_options_str) {
@@ -775,7 +783,7 @@ static int seg_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 time_t sec = avgt / 100;
 localtime_r(&sec, &ti);
 usecs = (int64_t)(ti.tm_hour * 3600 + ti.tm_min * 60 + ti.tm_sec) 
* 100 + (avgt % 100);
-wrapped_val = usecs % seg->time;
+wrapped_val = (usecs + seg->clocktime_offset) % seg->time;
 if (seg->last_cut != usecs && wrapped_val < seg->last_val) {
 seg->cut_pending = 1;
 seg->last_cut = usecs;
@@ -926,6 +934,7 @@ static const AVOption options[] = {
 { "hls", "Apple HTTP Live Streaming compatible", 0, AV_OPT_TYPE_CONST, 
{.i64=LIST_TYPE_M3U8 }, INT_MIN, INT_MAX, E, "list_type" },
 
 { "segment_atclocktime",  "set segment to be cut at clocktime",  
OFFSET(use_clocktime), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E},
+{ "segment_clocktime_offset", "set segment clocktime offset",
OFFSET(clocktime_offset), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, 86400, E},
 { "segment_time",  "set segment duration",   
OFFSET(time_str),AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,   E },
 { "segment_time_delta","set approximation value used for the segment 
times", OFFSET(time_delta), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, 0, E },
 { "segment_times", "set segment split time points",  
OFFSET(times_str),AV_OPT_TYPE_STRING,{.str = NULL},  0, 0,   E },
-- 
2.6.2

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


[FFmpeg-devel] [PATCH 2/2] lavf/segment: add new option segment_clocktime_wrap_duration

2016-01-18 Thread Marton Balint
This option can force the segmenter to only start a new segment if a packet
reaches the muxer whithin the specified duration after the segmenting clock
time, which makes it more resilient to backward local time jumps, such as leap
seconds or transition to standard time from daylight savings time.

Signed-off-by: Marton Balint 
---
 doc/muxers.texi   | 13 +
 libavformat/segment.c |  4 +++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index c304221..2ed468e 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1110,6 +1110,19 @@ create files at 12:05, 12:20, 12:35, etc.
 
 Default value is "0".
 
+@item segment_clocktime_wrap_duration @var{duration}
+By setting this option you can force the segmenter to only start a new segment
+if a packet reaches the muxer whithin the specified duration after the
+segmenting clock time. This way you can make the segmenter more resilient to
+backward local time jumps, such as leap seconds or transition to standard time
+from daylight savings time.
+
+Assuming that the delay between the packets of your source is less than 0.5
+second you can detect a leap second by specifying 0.5 as the duration.
+
+Default is the maximum possible duration which means starting a new segment
+regardless of the elapsed time since the last clock time.
+
 @item segment_time_delta @var{delta}
 Specify the accuracy time when selecting the start time for a
 segment, expressed as a duration specification. Default value is "0".
diff --git a/libavformat/segment.c b/libavformat/segment.c
index bf7a8fc..d92b9c3 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -83,6 +83,7 @@ typedef struct SegmentContext {
 
 int use_clocktime;///< flag to cut segments at regular clock time
 int64_t clocktime_offset; //< clock offset for cutting the segments at 
regular clock time
+int64_t clocktime_wrap_duration; //< wrapping duration considered for 
starting a new segment
 int64_t last_val;  ///< remember last time for wrap around detection
 int64_t last_cut;  ///< remember last cut
 int cut_pending;
@@ -784,7 +785,7 @@ static int seg_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 localtime_r(&sec, &ti);
 usecs = (int64_t)(ti.tm_hour * 3600 + ti.tm_min * 60 + ti.tm_sec) 
* 100 + (avgt % 100);
 wrapped_val = (usecs + seg->clocktime_offset) % seg->time;
-if (seg->last_cut != usecs && wrapped_val < seg->last_val) {
+if (seg->last_cut != usecs && wrapped_val < seg->last_val && 
wrapped_val < seg->clocktime_wrap_duration) {
 seg->cut_pending = 1;
 seg->last_cut = usecs;
 }
@@ -935,6 +936,7 @@ static const AVOption options[] = {
 
 { "segment_atclocktime",  "set segment to be cut at clocktime",  
OFFSET(use_clocktime), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E},
 { "segment_clocktime_offset", "set segment clocktime offset",
OFFSET(clocktime_offset), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, 86400, E},
+{ "segment_clocktime_wrap_duration", "set segment clocktime wrapping 
duration", OFFSET(clocktime_wrap_duration), AV_OPT_TYPE_DURATION, {.i64 = 
INT_MAX}, 0, INT_MAX, E},
 { "segment_time",  "set segment duration",   
OFFSET(time_str),AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,   E },
 { "segment_time_delta","set approximation value used for the segment 
times", OFFSET(time_delta), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, 0, E },
 { "segment_times", "set segment split time points",  
OFFSET(times_str),AV_OPT_TYPE_STRING,{.str = NULL},  0, 0,   E },
-- 
2.6.2

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


Re: [FFmpeg-devel] DVB Teletext to HLS Wbvtt Subtitles

2016-01-18 Thread Aman Gupta
ffmpeg has a webvtt encoder and decoder already. You can use this command
to convert mpeg2 closed captions into webvtt:

  ffmpeg -f lavfi -i 'movie=input.mpg[out0+subcc]' -map s out.vtt

Aman

On Mon, Jan 18, 2016 at 7:25 AM, Sébastien Cramatte 
wrote:

> Hi,
>
> We are working on an IPTv project using FFMPEG.
> Now we stream Live TV channels  in HLS format.
>
> We need to add Webvtt subtitles but as fare as I known Ffmpeg doesn't
> support it yet.
> We have make some lab test using CCExtractor +  Home made Webvtt  perl
> segmenter  and it works but  we are
> unable to sync subtitles with video/audio.
>
> We have seen that exists some Webvtt  patch for FFMpeg but I don't know if
> this code works or not.
>
> Basically we need to get DVB Mpeg2 TS  subtitles track  and   output it
> as  webvtt hls   directly with FFMpeg at same time as video / audios tracks.
> We are searching to hire a guy  that can achieve this job for us.
>
> Regards,
>
> Sebastien
>
>
> ___
> 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] lavf/qtpalette: Fix incorrect palettes

2016-01-18 Thread Mats Peterson

On 01/18/2016 11:19 AM, Mats Peterson wrote:

This patch corrects the colors of the 2 and 4 bpp palettes. Compare the
output of the two files below in QuickTime in Win or Mac with the FFmpeg
output, before and after the patch is applied (the second file is not so
obvious, but the 4 bpp palette is incorrect nevertheless):

https://drive.google.com/open?id=0B3_pEBoLs0faZUc4VEVwalhGSE0

https://drive.google.com/open?id=0B3_pEBoLs0facHJkWnhvYXdtbms

Mats



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



ping

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


[FFmpeg-devel] [PATCH] configure: disable -Wunused-const-variable

2016-01-18 Thread James Almer
The option became too aggressive with GCC 6, generating nearly 500
warnings from static const variables defined in assorted headers

Signed-off-by: James Almer 
---
Compare 
http://fate.ffmpeg.org/report.cgi?time=20150921041049&slot=x86_64-archlinux-gcc-experimental
with 
http://fate.ffmpeg.org/report.cgi?time=20150923012551&slot=x86_64-archlinux-gcc-experimental

 configure | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure b/configure
index cdf07ae..4dcb27b 100755
--- a/configure
+++ b/configure
@@ -5780,6 +5780,7 @@ check_disable_warning -Wno-parentheses
 check_disable_warning -Wno-switch
 check_disable_warning -Wno-format-zero-length
 check_disable_warning -Wno-pointer-sign
+check_disable_warning -Wno-unused-const-variable
 
 # add some linker flags
 check_ldflags -Wl,--warn-common
-- 
2.7.0

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


[FFmpeg-devel] [PATCH] avfilter: add afftfilter

2016-01-18 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 configure |   3 +
 doc/filters.texi  |  77 +
 libavfilter/Makefile  |   1 +
 libavfilter/af_afftfilt.c | 396 ++
 libavfilter/allfilters.c  |   1 +
 5 files changed, 478 insertions(+)
 create mode 100644 libavfilter/af_afftfilt.c

diff --git a/configure b/configure
index cdf07ae..b74ea9f 100755
--- a/configure
+++ b/configure
@@ -2840,6 +2840,8 @@ unix_protocol_deps="sys_un_h"
 unix_protocol_select="network"
 
 # filters
+afftfilt_filter_deps="avcodec"
+afftfilt_filter_select="fft"
 amovie_filter_deps="avcodec avformat"
 aresample_filter_deps="swresample"
 ass_filter_deps="libass"
@@ -6063,6 +6065,7 @@ done
 enabled zlib && add_cppflags -DZLIB_CONST
 
 # conditional library dependencies, in linking order
+enabled afftfilt_filter && prepend avfilter_deps "avcodec"
 enabled amovie_filter   && prepend avfilter_deps "avformat avcodec"
 enabled aresample_filter&& prepend avfilter_deps "swresample"
 enabled asyncts_filter  && prepend avfilter_deps "avresample"
diff --git a/doc/filters.texi b/doc/filters.texi
index d8e3317..1a03995 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -733,6 +733,83 @@ afade=t=out:st=875:d=25
 @end example
 @end itemize
 
+@section afftfilt
+Apply arbitrary expressions to samples in frequency domain
+
+@table @option
+@item real
+Set frequency domain real expression for each separate channel separated
+by '|'. Default is "1".
+If the number of input channels is greater than the number of
+expressions, the last specified expression is used for the remaining
+output channels.
+
+@item imag
+Set frequency domain imaginary expression for each separate channel
+separated by '|'. If not set, @var{real} option is used.
+
+Each expression in @var{real} and @var{imag} can contain the following
+constants:
+
+@table @option
+@item sr
+sample rate
+
+@item b
+current frequency bin number
+
+@item nb
+number of available bins
+
+@item ch
+channel number of the current expression
+
+@item chs
+number of channels
+
+@item pts
+current frame pts
+@end table
+
+@item win_size
+Set window size.
+
+It accepts the following values:
+@table @samp
+@item w16
+@item w32
+@item w64
+@item w128
+@item w256
+@item w512
+@item w1024
+@item w2048
+@item w4096
+@item w8192
+@item w16384
+@item w32768
+@item w65536
+@end table
+Default is @code{w4096}
+
+@item win_func
+Set window function. Default is @code{hann}.
+
+@item overlap
+Set window overlap. If set to 1, the recommended overlap for selected
+window function will be picked. Default is @code{0.75}.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Increase first 50 bins by 0.1 and lower all other frequencies by factor of 10:
+@example
+afftfilt="1.1*between(b\,0\,50)+0.1*between(b\,50\,f)"
+@end example
+@end itemize
+
 @anchor{aformat}
 @section aformat
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index e3e3561..242f56d 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -29,6 +29,7 @@ OBJS-$(CONFIG_ACROSSFADE_FILTER) += af_afade.o
 OBJS-$(CONFIG_ADELAY_FILTER) += af_adelay.o
 OBJS-$(CONFIG_AECHO_FILTER)  += af_aecho.o
 OBJS-$(CONFIG_AEMPHASIS_FILTER)  += af_aemphasis.o
+OBJS-$(CONFIG_AFFTFILT_FILTER)   += af_afftfilt.o window_func.o
 OBJS-$(CONFIG_ANEQUALIZER_FILTER)+= af_anequalizer.o
 OBJS-$(CONFIG_AEVAL_FILTER)  += aeval.o
 OBJS-$(CONFIG_AFADE_FILTER)  += af_afade.o
diff --git a/libavfilter/af_afftfilt.c b/libavfilter/af_afftfilt.c
new file mode 100644
index 000..9643627
--- /dev/null
+++ b/libavfilter/af_afftfilt.c
@@ -0,0 +1,396 @@
+/*
+ * Copyright (c) 2016 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License,
+ * or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/audio_fifo.h"
+#include "libavutil/avstring.h"
+#include "libavfilter/internal.h"
+#include "libavutil/common.h"
+#include "libavutil/opt.h"
+#include "libavcodec/avfft.h"
+#include "libavutil/eval.h"
+#include "audio.h"
+#include "window_func.h"
+
+typedef struct AFFTFiltContext {
+const AVClass *class;
+char *real_str;
+char *img_str;
+int fft_bits;
+
+FFTContext *fft, *ifft;
+FFTComplex **

Re: [FFmpeg-devel] [PATCH] videodsp: fix 1-byte overread in top/bottom READ_NUM_BYTES iterations.

2016-01-18 Thread Ronald S. Bultje
Hi,

On Mon, Jan 18, 2016 at 10:44 AM, Michael Niedermayer <
mich...@niedermayer.cc> wrote:

> On Sat, Jan 16, 2016 at 02:44:47PM -0500, Ronald S. Bultje wrote:
> > This can overread (either before start or beyond end) of the buffer in
> > Nx1 (i.e. height=1) images.
> >
> > Fixes mozilla bug 1240080.
> > ---
> >  libavcodec/x86/videodsp.asm | 21 ++---
> >  1 file changed, 6 insertions(+), 15 deletions(-)
>
> probably ok but iam not confident that i would spot a bug in this
> code if there was one


TY, pushed.

The second patch (videodsp checkasm) is meant to assist in bug-finding by
doing full-coverage runs - i.e. height=1 and alternate edge conditions
(which fate-$codec doesn't really test) - under asan or valgrind.

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


[FFmpeg-devel] [PATCH] checkasm: add videodsp emulated_edge_mc test.

2016-01-18 Thread Ronald S. Bultje
---
 tests/checkasm/Makefile   |  1 +
 tests/checkasm/checkasm.c |  3 ++
 tests/checkasm/checkasm.h |  1 +
 tests/checkasm/videodsp.c | 89 +++
 4 files changed, 94 insertions(+)
 create mode 100644 tests/checkasm/videodsp.c

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index e38d15b..301c2e2 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -10,6 +10,7 @@ AVCODECOBJS-$(CONFIG_JPEG2000_DECODER) += jpeg2000dsp.o
 AVCODECOBJS-$(CONFIG_PIXBLOCKDSP) += pixblockdsp.o
 AVCODECOBJS-$(CONFIG_V210_ENCODER) += v210enc.o
 AVCODECOBJS-$(CONFIG_VP9_DECODER) += vp9dsp.o
+AVCODECOBJS-$(CONFIG_VIDEODSP) += videodsp.o
 
 CHECKASMOBJS-$(CONFIG_AVCODEC) += $(AVCODECOBJS-yes)
 
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 7f2cf8e..07ac972 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -93,6 +93,9 @@ static const struct {
 #if CONFIG_VP9_DECODER
 { "vp9dsp", checkasm_check_vp9dsp },
 #endif
+#if CONFIG_VIDEODSP
+{ "videodsp", checkasm_check_videodsp },
+#endif
 #endif
 { NULL }
 };
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 69416e9..aeffc2e 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -42,6 +42,7 @@ void checkasm_check_pixblockdsp(void);
 void checkasm_check_synth_filter(void);
 void checkasm_check_v210enc(void);
 void checkasm_check_vp9dsp(void);
+void checkasm_check_videodsp(void);
 
 void *checkasm_check_func(void *func, const char *name, ...) 
av_printf_format(2, 3);
 int checkasm_bench_func(void);
diff --git a/tests/checkasm/videodsp.c b/tests/checkasm/videodsp.c
new file mode 100644
index 000..0a4424a
--- /dev/null
+++ b/tests/checkasm/videodsp.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2016 Ronald S. Bultje 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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 "checkasm.h"
+#include "libavcodec/videodsp.h"
+#include "libavutil/internal.h"
+#include "libavutil/intreadwrite.h"
+
+#define randomize_buffers(w, h) \
+do {\
+int i;  \
+for (i = 0; i < w * h * sizeof(*src0); i += 4)  \
+AV_WN32A(((uint8_t *) src0) + i, rnd());\
+} while (0)
+
+#define iter_1d(type, fix, fix_val, var, var_start, var_end)\
+for (fix = fix_val, var = var_start; var <= var_end; var++) {   \
+call_ref((type *) dst0, (const type *) (src0 + y * pw + x), \
+ bw * sizeof(type), pw * sizeof(type),  \
+ bw, bh, x, y, pw, ph); \
+call_new((type *) dst1, (const type *) (src1 + y * pw + x), \
+ bw * sizeof(type), pw * sizeof(type),  \
+ bw, bh, x, y, pw, ph); \
+if (memcmp(dst0, dst1, bw * bh * sizeof(type))) \
+fail(); \
+bench_new((type *) dst1, (const type *) (src1 + y * pw + x),\
+  bw * sizeof(type), pw * sizeof(type), \
+  bw, bh, x, y, pw, ph);\
+}
+
+#define check_emu_edge_size(type, src_w, src_h, dst_w, dst_h)   \
+do {\
+LOCAL_ALIGNED_16(type, src0, [src_w * src_h]);  \
+LOCAL_ALIGNED_16(type, src1, [src_w * src_h]);  \
+int bw = dst_w, bh = dst_h; \
+int pw = src_w, ph = src_h; \
+int y, x;   \
+randomize_buffers(src_w, src_h);\
+memcpy(src1, src0, pw * ph * sizeof(type)); \
+iter_1d(type, y, 0 - src_h, x, 0 - src_w, src_w - 0);   \
+iter_1d(type, x, src_w - 0, y, 0 - src_h, src_h - 0);   \
+iter_1d(type, y, src_h - 0, x, 0 - src_w, src_w - 0);   \
+iter_1d(type, x, 0 - src_w, y, 0 - src_h, src_h - 0);   \
+} while (0)
+
+#define check_emu_edge(type)\
+do {

Re: [FFmpeg-devel] [PATCH] videodsp: fix 1-byte overread in top/bottom READ_NUM_BYTES iterations.

2016-01-18 Thread Michael Niedermayer
On Sat, Jan 16, 2016 at 02:44:47PM -0500, Ronald S. Bultje wrote:
> This can overread (either before start or beyond end) of the buffer in
> Nx1 (i.e. height=1) images.
> 
> Fixes mozilla bug 1240080.
> ---
>  libavcodec/x86/videodsp.asm | 21 ++---
>  1 file changed, 6 insertions(+), 15 deletions(-)

probably ok but iam not confident that i would spot a bug in this
code if there was one

[...]
-- 
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


[FFmpeg-devel] DVB Teletext to HLS Wbvtt Subtitles

2016-01-18 Thread Sébastien Cramatte
Hi,

We are working on an IPTv project using FFMPEG. 
Now we stream Live TV channels  in HLS format.

We need to add Webvtt subtitles but as fare as I known Ffmpeg doesn't support 
it yet.
We have make some lab test using CCExtractor +  Home made Webvtt  perl 
segmenter  and it works but  we are 
unable to sync subtitles with video/audio.

We have seen that exists some Webvtt  patch for FFMpeg but I don't know if this 
code works or not.

Basically we need to get DVB Mpeg2 TS  subtitles track  and   output it  as  
webvtt hls   directly with FFMpeg at same time as video / audios tracks.
We are searching to hire a guy  that can achieve this job for us.

Regards,

Sebastien


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


Re: [FFmpeg-devel] [PATCH v3] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime video

2016-01-18 Thread Mats Peterson

On 01/18/2016 03:14 PM, Michael Niedermayer wrote:
 Specification for details.


applied

thanks

If grave complaints arise, we can always resort to something else. 
Thanks, Michael.


Mats

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


[FFmpeg-devel] [PATCH] avfilter: add streamselect filter

2016-01-18 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---

Partially working, it can switch video only and audio only streams.
I'm thinking about doing only one single output of single media type,
so there would be astreamselect and streamselect filter.
I don't think current behaviour is possible, or even useful if not too
complicated.

Comments welcome!

---
 libavfilter/Makefile   |   1 +
 libavfilter/allfilters.c   |   1 +
 libavfilter/avf_streamselect.c | 328 +
 3 files changed, 330 insertions(+)
 create mode 100644 libavfilter/avf_streamselect.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index e3e3561..5bc4c35 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -292,6 +292,7 @@ OBJS-$(CONFIG_SHOWVOLUME_FILTER) += 
avf_showvolume.o
 OBJS-$(CONFIG_SHOWWAVES_FILTER)  += avf_showwaves.o
 OBJS-$(CONFIG_SHOWWAVESPIC_FILTER)   += avf_showwaves.o
 OBJS-$(CONFIG_SPECTRUMSYNTH_FILTER)  += vaf_spectrumsynth.o 
window_func.o
+OBJS-$(CONFIG_STREAMSELECT_FILTER)   += avf_streamselect.o
 
 # multimedia sources
 OBJS-$(CONFIG_AMOVIE_FILTER) += src_movie.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 1faf393..ac01b06 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -312,6 +312,7 @@ void avfilter_register_all(void)
 REGISTER_FILTER(SHOWWAVES,  showwaves,  avf);
 REGISTER_FILTER(SHOWWAVESPIC,   showwavespic,   avf);
 REGISTER_FILTER(SPECTRUMSYNTH,  spectrumsynth,  vaf);
+REGISTER_FILTER(STREAMSELECT,   streamselect,   avf);
 
 /* multimedia sources */
 REGISTER_FILTER(AMOVIE, amovie, avsrc);
diff --git a/libavfilter/avf_streamselect.c b/libavfilter/avf_streamselect.c
new file mode 100644
index 000..4adf78e
--- /dev/null
+++ b/libavfilter/avf_streamselect.c
@@ -0,0 +1,328 @@
+/*
+ * 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 "libavutil/avstring.h"
+#include "libavutil/internal.h"
+#include "libavutil/opt.h"
+#include "avfilter.h"
+#include "audio.h"
+#include "formats.h"
+#include "framesync.h"
+#include "internal.h"
+#include "video.h"
+
+typedef struct StreamSelectContext {
+const AVClass *class;
+char *in_str;
+char *out_str;
+char *map_str;
+int *map;
+int nb_map;
+AVFrame **frames;
+FFFrameSync fs;
+} StreamSelectContext;
+
+#define OFFSET(x) offsetof(StreamSelectContext, x)
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
+static const AVOption streamselect_options[] = {
+{ "in",  "input streams definition",  OFFSET(in_str),  
AV_OPT_TYPE_STRING, {.str=NULL}, .flags=FLAGS },
+{ "out", "output streams definition", OFFSET(out_str), 
AV_OPT_TYPE_STRING, {.str=NULL}, .flags=FLAGS },
+{ "map", "input indexes to remap to outputs", OFFSET(map_str), 
AV_OPT_TYPE_STRING, {.str=NULL}, .flags=FLAGS },
+{ NULL }
+};
+
+AVFILTER_DEFINE_CLASS(streamselect);
+
+static int filter_frame(AVFilterLink *inlink, AVFrame *in)
+{
+StreamSelectContext *s = inlink->dst->priv;
+return ff_framesync_filter_frame(&s->fs, inlink, in);
+}
+
+static int process_frame(FFFrameSync *fs)
+{
+AVFilterContext *ctx = fs->parent;
+StreamSelectContext *s = fs->opaque;
+AVFrame **in = s->frames;
+int i, j, ret = 0;
+
+for (i = 0; i < ctx->nb_inputs; i++) {
+if ((ret = ff_framesync_get_frame(&s->fs, i, &in[i], 0)) < 0)
+return ret;
+}
+
+for (j = 0; j < ctx->nb_inputs; j++) {
+for (i = 0; i < s->nb_map; i++) {
+if (s->map[i] == j) {
+AVFrame *out = av_frame_clone(in[j]);
+
+if (!out)
+return AVERROR(ENOMEM);
+
+out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, 
ctx->outputs[i]->time_base);
+ret = ff_filter_frame(ctx->outputs[i], out);
+}
+}
+}
+
+return ret;
+}
+
+static int request_frame(AVFilterLink *outlink)
+{
+StreamSelectContext *s = outlink->src->priv;
+return ff_framesync_request_frame(&s->fs, outlink);
+}
+
+static int config_input(AVFilterLink *inlink)
+{
+AVFilterContext *ctx = inlink->dst;
+StreamSelectContext *s = ctx-

Re: [FFmpeg-devel] [PATCH v3] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime video

2016-01-18 Thread Michael Niedermayer
On Sun, Jan 17, 2016 at 10:50:42PM +0100, Mats Peterson wrote:
> Alright Michael, I'm not entirely sure of what I'm doing regarding
> the FFALIGN(avctx->width, 32), but at least the two odd-width (113
> and 129 pixels) 1 bpp files that failed to render correctly with the
> last patch now seem to be OK. Please give it a try. Original
> description follows:
> 
> Match the use of AV_PIX_FMT_PAL8 for 1-bit QuickTime Animation in
> lavc/qtrle. To reiterate, 1-bit video is not necessary black & white
> in QuickTime, merely bi-level. The two colors can be any color. The
> palette, either included in the sample description, or the default
> Macintosh palette (black & white for 1-bit video) will be set in
> lavf/qtpalette. See the QuickTime File Format Specification for
> details.
> 
> Mats
> 
> -- 
> Mats Peterson
> http://matsp888.no-ip.org/~mats/

>  raw.c|4 ++--
>  rawdec.c |   31 ++-
>  2 files changed, 24 insertions(+), 11 deletions(-)
> 3e94120d14979d5c9c477dc67d055e15597f899e  
> 0001-lavf-rawdec-Use-AV_PIX_FMT_PAL8-for-1-bit-raw-QuickT.patch
> From 6c6d2650faf82a9c2fe5c1463b1795117a13863c Mon Sep 17 00:00:00 2001
> From: Mats Peterson 
> Date: Sun, 17 Jan 2016 22:27:52 +0100
> Subject: [PATCH v3] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime 
> video
> 
> Match the use of AV_PIX_FMT_PAL8 for 1-bit QuickTime Animation in
> lavc/qtrle. To reiterate, 1-bit video is not necessary black & white in
> QuickTime, merely bi-level. The two colors can be any color. The palette,
> either included in the sample description, or the default Macintosh
> palette (black & white for 1-bit video) will be set in lavf/qtpalette.
> See the QuickTime File Format Specification for details.

applied

thanks

[...]

-- 
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: add automatic bitstream filtering

2016-01-18 Thread Moritz Barsnick
On Thu, Jan 14, 2016 at 18:29:42 -0600, Rodger Combs wrote:
> > Rodger's commits also introduced *_init() functions for each format.
> > I don't understand whether that is necessary. These patches work
> > for me just as they are.
> The init functions are required because avpriv_set_pts_info is called
> in write_header. Since this can affect operations that take place
> before write_header is called when delayed, it needs to be done
> earlier. This is probably also true of any other change to the
> AVFormatContext or AVStreams that could affect interleaving or
> related operations.

Ak, okay, that makes sense. Well, that makes this integration too
difficult for myself at the time being. If anyone else is willing to
help or take a stab, go ahead. I might come back to this later.

Patches dropped.

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


Re: [FFmpeg-devel] [PATCH] libkvazaar: Set frame rate as a rational number

2016-01-18 Thread Nicolas George
Le nonidi 29 nivôse, an CCXXIV, Arttu Ylä-Outinen a écrit :
> On 2016-01-16 03:31, Michael Niedermayer wrote:
> 
> >its probably rather unlikely but the multiplication could overflow
> 
> Thanks for taking a look. I attached an updated patch which checks for
> overflow before multiplying.
> 
> - Arttu
> 

> >From 0a8a1a1fffd008d43ec601b7e0a5ed22c2c1f784 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= 
> Date: Fri, 15 Jan 2016 13:47:10 +0200
> Subject: [PATCH v2] libkvazaar: Set frame rate as a rational number
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> Updates libkvazaar to pass the exact frame rate to Kvazaar by setting
> the numerator and denominator separately instead of a single floating
> point number. The exact frame rate is needed for writing timing info to
> the bitstream.
> 
> Requires Kvazaar version 0.8.1.
> 
> Signed-off-by: Arttu Yl??-Outinen 
> ---
>  configure   | 2 +-
>  libavcodec/libkvazaar.c | 9 +++--
>  2 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/configure b/configure
> index cdf07ae..5ee26cf 100755
> --- a/configure
> +++ b/configure
> @@ -5454,7 +5454,7 @@ enabled libgsm&& { for gsm_hdr in "gsm.h" 
> "gsm/gsm.h"; do
> check_lib "${gsm_hdr}" gsm_create -lgsm 
> && break;
> done || die "ERROR: libgsm not found"; }
>  enabled libilbc   && require libilbc ilbc.h WebRtcIlbcfix_InitDecode 
> -lilbc
> -enabled libkvazaar&& require_pkg_config "kvazaar >= 0.7.1" kvazaar.h 
> kvz_api_get
> +enabled libkvazaar&& require_pkg_config "kvazaar >= 0.8.1" kvazaar.h 
> kvz_api_get
>  enabled libmfx&& require_pkg_config libmfx "mfx/mfxvideo.h" 
> MFXInit
>  enabled libmodplug&& require_pkg_config libmodplug 
> libmodplug/modplug.h ModPlug_Load
>  enabled libmp3lame&& require "libmp3lame >= 3.98.3" lame/lame.h 
> lame_set_VBR_quality -lmp3lame
> diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
> index e58405d..8cbc4b0 100644
> --- a/libavcodec/libkvazaar.c
> +++ b/libavcodec/libkvazaar.c
> @@ -75,8 +75,13 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx)
>  cfg->width  = avctx->width;
>  cfg->height = avctx->height;
>  
> -cfg->framerate =
> -  avctx->time_base.den / (double)(avctx->time_base.num * 
> avctx->ticks_per_frame);
> +if (avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) {
> +av_log(avctx, AV_LOG_ERROR,
> +   "Could not set framerate for kvazaar: integer overflow\n");

> +return AVERROR(EOVERFLOW);

EOVERFLOW does not exist on some windows versions. IIRC, we usually use
EINVAL in this kind of case.

> +}
> +cfg->framerate_num   = avctx->time_base.den;
> +cfg->framerate_denom = avctx->time_base.num * avctx->ticks_per_frame;
>  cfg->target_bitrate = avctx->bit_rate;
>  cfg->vui.sar_width  = avctx->sample_aspect_ratio.num;
>  cfg->vui.sar_height = avctx->sample_aspect_ratio.den;

Regards,

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


Re: [FFmpeg-devel] [PATCH] libkvazaar: Set frame rate as a rational number

2016-01-18 Thread Arttu Ylä-Outinen

On 2016-01-16 03:31, Michael Niedermayer wrote:


its probably rather unlikely but the multiplication could overflow


Thanks for taking a look. I attached an updated patch which checks for 
overflow before multiplying.


- Arttu

>From 0a8a1a1fffd008d43ec601b7e0a5ed22c2c1f784 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= 
Date: Fri, 15 Jan 2016 13:47:10 +0200
Subject: [PATCH v2] libkvazaar: Set frame rate as a rational number
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Updates libkvazaar to pass the exact frame rate to Kvazaar by setting
the numerator and denominator separately instead of a single floating
point number. The exact frame rate is needed for writing timing info to
the bitstream.

Requires Kvazaar version 0.8.1.

Signed-off-by: Arttu Ylä-Outinen 
---
 configure   | 2 +-
 libavcodec/libkvazaar.c | 9 +++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index cdf07ae..5ee26cf 100755
--- a/configure
+++ b/configure
@@ -5454,7 +5454,7 @@ enabled libgsm&& { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
check_lib "${gsm_hdr}" gsm_create -lgsm && break;
done || die "ERROR: libgsm not found"; }
 enabled libilbc   && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
-enabled libkvazaar&& require_pkg_config "kvazaar >= 0.7.1" kvazaar.h kvz_api_get
+enabled libkvazaar&& require_pkg_config "kvazaar >= 0.8.1" kvazaar.h kvz_api_get
 enabled libmfx&& require_pkg_config libmfx "mfx/mfxvideo.h" MFXInit
 enabled libmodplug&& require_pkg_config libmodplug libmodplug/modplug.h ModPlug_Load
 enabled libmp3lame&& require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index e58405d..8cbc4b0 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -75,8 +75,13 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx)
 cfg->width  = avctx->width;
 cfg->height = avctx->height;
 
-cfg->framerate =
-  avctx->time_base.den / (double)(avctx->time_base.num * avctx->ticks_per_frame);
+if (avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) {
+av_log(avctx, AV_LOG_ERROR,
+   "Could not set framerate for kvazaar: integer overflow\n");
+return AVERROR(EOVERFLOW);
+}
+cfg->framerate_num   = avctx->time_base.den;
+cfg->framerate_denom = avctx->time_base.num * avctx->ticks_per_frame;
 cfg->target_bitrate = avctx->bit_rate;
 cfg->vui.sar_width  = avctx->sample_aspect_ratio.num;
 cfg->vui.sar_height = avctx->sample_aspect_ratio.den;
-- 
2.7.0

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


Re: [FFmpeg-devel] [PATCH 0/7] x86inc: Sync changes from x264

2016-01-18 Thread Ronald S. Bultje
Hi,

On Sun, Jan 17, 2016 at 5:59 PM, Henrik Gramner  wrote:

> The following patches were recently pushed to x264.
>
> Geza Lore (1):
>   x86inc: Add debug symbols indicating sizes of compiled functions
>
> Henrik Gramner (6):
>   x86inc: Be more verbose in assertion failures
>   x86inc: Improve FMA instruction handling
>   x86inc: Preserve arguments when allocating stack space
>   x86inc: Use more consistent indentation
>   x86inc: Simplify AUTO_REP_RET
>   x86inc: Avoid creating unnecessary local labels


Except for my comment on "x86inc: Preserve arguments when allocating stack
space", all patches LGTM.

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


Re: [FFmpeg-devel] [PATCH v4] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime video

2016-01-18 Thread Mats Peterson

On 01/18/2016 01:45 PM, Mats Peterson wrote:

And please note that this 1 bpp to pal8 conversion doesn't affect AVI,
only QuickTime. AVI will still use AV_PIX_FMT_MONOWHITE. At least until
someone decides otherwise.


There's nothing that says that 1 bpp raw AVI can't have a palette as 
well, but I have limited myself to modifying the QuickTime part.


Mats

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


Re: [FFmpeg-devel] [PATCH v4] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime video

2016-01-18 Thread Mats Peterson

On 01/18/2016 01:25 PM, Mats Peterson wrote:

Or just use version 3 of the patch, by the way.


And please note that this 1 bpp to pal8 conversion doesn't affect AVI, 
only QuickTime. AVI will still use AV_PIX_FMT_MONOWHITE. At least until 
someone decides otherwise.


Mats

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


Re: [FFmpeg-devel] [PATCH v4] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime video

2016-01-18 Thread Mats Peterson

On 01/18/2016 01:20 PM, Mats Peterson wrote:

On 01/18/2016 01:17 PM, Michael Niedermayer wrote:

the question is which way its faster, i dont know it. Only testing
can tell


Without testing, I guess was can keep the old way of doing it? I'm
already restoring it here. Yes or no?

Mats

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


Or just use version 3 of the patch, by the way.

Mats

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v4] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime video

2016-01-18 Thread Mats Peterson

On 01/18/2016 01:17 PM, Michael Niedermayer wrote:

the question is which way its faster, i dont know it. Only testing
can tell

Without testing, I guess was can keep the old way of doing it? I'm 
already restoring it here. Yes or no?


Mats

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


Re: [FFmpeg-devel] [PATCH v4] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime video

2016-01-18 Thread Michael Niedermayer
On Mon, Jan 18, 2016 at 12:37:58PM +0100, Mats Peterson wrote:
> On 01/18/2016 12:35 PM, Michael Niedermayer wrote:
> >>>
> >>Pure logic tells me it's faster to just increment than involve a
> >>series of multiplications.
> >
> >its not so simple
> >
> >theres a optimizing compiler between you and the CPU
> >the multiplication is a shift really, and the compiler may very well
> >change this to dst++, buf++ and buf < buf_end
> >or it might use something like p[8*i] and q[i]
> >i++ and a i<=0 check, the 8* can on some architectures be free as
> >part of addressing memory
> >
> >if you are interrested in optimizing code see
> >http://www.agner.org/optimize/
> >
> >and intels Intel 64 and IA-32 Architectures Software Developers Manual
> >is invaluable as a reference but not useable for other purposes than
> >as a reference (its too huge)
> >
> 
> I almost expected that answer, Michael. And I do know there's a lot
> going on behind the scenes. But how much is another question. And
> don't you think it's cleaner to just increment a variable here? Or
> should I revert to the old stuff?

the question is which way its faster, i dont know it. Only testing
can tell

also either way it should be in a seperate patch

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

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


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


Re: [FFmpeg-devel] [PATCH v4] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime video

2016-01-18 Thread Mats Peterson

On 01/18/2016 12:07 PM, Mats Peterson wrote:

Unfortunately there is no "pal2" pixel format in FFmpeg...


Should be pal1 of course.

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


Re: [FFmpeg-devel] [PATCH v4] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime video

2016-01-18 Thread Mats Peterson

On 01/18/2016 12:35 PM, Michael Niedermayer wrote:



Pure logic tells me it's faster to just increment than involve a
series of multiplications.


its not so simple

theres a optimizing compiler between you and the CPU
the multiplication is a shift really, and the compiler may very well
change this to dst++, buf++ and buf < buf_end
or it might use something like p[8*i] and q[i]
i++ and a i<=0 check, the 8* can on some architectures be free as
part of addressing memory

if you are interrested in optimizing code see
http://www.agner.org/optimize/

and intels Intel 64 and IA-32 Architectures Software Developers Manual
is invaluable as a reference but not useable for other purposes than
as a reference (its too huge)



I almost expected that answer, Michael. And I do know there's a lot 
going on behind the scenes. But how much is another question. And don't 
you think it's cleaner to just increment a variable here? Or should I 
revert to the old stuff?


Mats

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


Re: [FFmpeg-devel] [PATCH v4] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime video

2016-01-18 Thread Michael Niedermayer
On Mon, Jan 18, 2016 at 12:18:09PM +0100, Mats Peterson wrote:
> On 01/18/2016 12:02 PM, Michael Niedermayer wrote:
> 
> >thats unrelated and should be in a seperate patch if it is faster
> >if its not faster it should not be done
> >
> >you can test the speed with START/STOP_TIMER
> >
> Pure logic tells me it's faster to just increment than involve a
> series of multiplications.

its not so simple

theres a optimizing compiler between you and the CPU
the multiplication is a shift really, and the compiler may very well
change this to dst++, buf++ and buf < buf_end
or it might use something like p[8*i] and q[i]
i++ and a i<=0 check, the 8* can on some architectures be free as
part of addressing memory

if you are interrested in optimizing code see
http://www.agner.org/optimize/

and intels Intel 64 and IA-32 Architectures Software Developers Manual
is invaluable as a reference but not useable for other purposes than
as a reference (its too huge)

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

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 


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


Re: [FFmpeg-devel] [PATCH v4] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime video

2016-01-18 Thread Mats Peterson

On 01/18/2016 12:23 PM, Michael Niedermayer wrote:


1bpp could be used by qtrle too if the palette allows it

but then qtrle implies mov (with a possible palette)
raw does not imply mov so its possible that it is not intended to be
paletted



Well, perhaps so. But people will have to get used to it then, as long 
as we don't have a pal2 pixel format. It can't be monow anyway.


Mats

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


Re: [FFmpeg-devel] [PATCH v4] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime video

2016-01-18 Thread Michael Niedermayer
On Mon, Jan 18, 2016 at 12:06:17PM +0100, Mats Peterson wrote:
> On 01/18/2016 12:02 PM, Michael Niedermayer wrote:
> >the decoder should check the palette, and if it differs from
> >black+white use PAL8
> >users quite possible could complain if monochrome raw files suddenly
> >become 8 times as large when its not needed
> 
> Well, there were no problems using pal8 all over for 1 bpp video in
> lavc/qtrle, so why should it matter now? The fact is 1 bpp video in
> QuickTime is NEVER monochrome, it is always palettized, even if the
> palette is only 2 colors of black & white.

1bpp could be used by qtrle too if the palette allows it

but then qtrle implies mov (with a possible palette)
raw does not imply mov so its possible that it is not intended to be
paletted

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

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle


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


Re: [FFmpeg-devel] [PATCH v4] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime video

2016-01-18 Thread Mats Peterson

On 01/18/2016 12:02 PM, Michael Niedermayer wrote:


thats unrelated and should be in a seperate patch if it is faster
if its not faster it should not be done

you can test the speed with START/STOP_TIMER

Pure logic tells me it's faster to just increment than involve a series 
of multiplications.


Mats

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


Re: [FFmpeg-devel] [PATCH v4] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime video

2016-01-18 Thread Mats Peterson

On 01/18/2016 12:06 PM, Mats Peterson wrote:

Well, there were no problems using pal8 all over for 1 bpp video in
lavc/qtrle, so why should it matter now? The fact is 1 bpp video in
QuickTime is NEVER monochrome, it is always palettized, even if the
palette is only 2 colors of black & white.

Mats

Unfortunately there is no "pal2" pixel format in FFmpeg...

Mats

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


Re: [FFmpeg-devel] [PATCH v4] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime video

2016-01-18 Thread Mats Peterson

On 01/18/2016 12:02 PM, Michael Niedermayer wrote:

the decoder should check the palette, and if it differs from
black+white use PAL8
users quite possible could complain if monochrome raw files suddenly
become 8 times as large when its not needed


Well, there were no problems using pal8 all over for 1 bpp video in 
lavc/qtrle, so why should it matter now? The fact is 1 bpp video in 
QuickTime is NEVER monochrome, it is always palettized, even if the 
palette is only 2 colors of black & white.


Mats

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


Re: [FFmpeg-devel] [PATCH v4] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime video

2016-01-18 Thread Michael Niedermayer
On Mon, Jan 18, 2016 at 08:43:50AM +0100, Mats Peterson wrote:
> Eliminated some calculations inside loops.
> 
> Mats

>  raw.c|4 ++--
>  rawdec.c |   49 +++--
>  2 files changed, 33 insertions(+), 20 deletions(-)
> fc79f935e8da23cc724a5a766e81b1fee6fa0f49  
> 0001-lavc-rawdec-Use-AV_PIX_FMT_PAL8-for-1-bit-raw-QuickT.patch
> From e836bfee99b6de39acfe023c3a50b4e5b53f82e1 Mon Sep 17 00:00:00 2001
> From: Mats Peterson 
> Date: Mon, 18 Jan 2016 08:40:57 +0100
> Subject: [PATCH v4] lavc/rawdec: Use AV_PIX_FMT_PAL8 for 1-bit raw QuickTime 
> video
> 
> Match the use of AV_PIX_FMT_PAL8 for 1-bit QuickTime Animation in
> lavc/qtrle. To reiterate, 1-bit video is not necessary black & white in
> QuickTime, merely bi-level. The two colors can be any color. The palette,
> either included in the sample description, or the default Macintosh
> palette (black & white for 1-bit video) will be set in lavf/qtpalette.
> See the QuickTime File Format Specification for details.
> 
> ---
>  libavcodec/raw.c|4 ++--
>  libavcodec/rawdec.c |   49 +++--
>  2 files changed, 33 insertions(+), 20 deletions(-)
> 
> diff --git a/libavcodec/raw.c b/libavcodec/raw.c
> index cda70ac..3f2cc11 100644
> --- a/libavcodec/raw.c
> +++ b/libavcodec/raw.c
> @@ -255,13 +255,13 @@ const PixelFormatTag avpriv_pix_fmt_bps_avi[] = {
>  };
>  
>  const PixelFormatTag avpriv_pix_fmt_bps_mov[] = {
> -{ AV_PIX_FMT_MONOWHITE, 1 },
> +{ AV_PIX_FMT_PAL8,  1 },
>  { AV_PIX_FMT_PAL8,  2 },
>  { AV_PIX_FMT_PAL8,  4 },
>  { AV_PIX_FMT_PAL8,  8 },
>  { AV_PIX_FMT_RGB555BE, 16 },
>  { AV_PIX_FMT_RGB24,24 },
>  { AV_PIX_FMT_ARGB, 32 },
> -{ AV_PIX_FMT_MONOWHITE,33 },
> +{ AV_PIX_FMT_PAL8, 33 },
>  { AV_PIX_FMT_NONE,  0 },

the decoder should check the palette, and if it differs from
black+white use PAL8
users quite possible could complain if monochrome raw files suddenly
become 8 times as large when its not needed


>  };
> diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
> index 50cee39..0f765af 100644
> --- a/libavcodec/rawdec.c
> +++ b/libavcodec/rawdec.c
> @@ -41,7 +41,7 @@ typedef struct RawVideoContext {
>  AVBufferRef *palette;
>  int frame_size;  /* size of the frame in bytes */
>  int flip;
> -int is_2_4_bpp; // 2 or 4 bpp raw in avi/mov
> +int is_1_2_4_bpp; // 1 bpp raw in mov, and 2 or 4 bpp raw in avi/mov
>  int is_yuv2;
>  int is_lt_16bpp; // 16bpp pixfmt and bits_per_coded_sample < 16
>  int tff;
> @@ -159,12 +159,13 @@ static int raw_decode(AVCodecContext *avctx, void 
> *data, int *got_frame,
>  
>  AVFrame   *frame   = data;
>  
> -if ((avctx->bits_per_coded_sample == 4 || avctx->bits_per_coded_sample 
> == 2) &&
> +if ((avctx->bits_per_coded_sample == 4 || avctx->bits_per_coded_sample 
> == 2
> +|| avctx->bits_per_coded_sample == 1) &&
>  avctx->pix_fmt == AV_PIX_FMT_PAL8 &&
> (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))) {
> -context->is_2_4_bpp = 1;
> +context->is_1_2_4_bpp = 1;
>  context->frame_size = av_image_get_buffer_size(avctx->pix_fmt,
> -   FFALIGN(avctx->width, 
> 16),
> +   FFALIGN(avctx->width, 
> 32),
> avctx->height, 1);
>  } else {
>  context->is_lt_16bpp = av_get_bits_per_pixel(desc) == 16 && 
> avctx->bits_per_coded_sample && avctx->bits_per_coded_sample < 16;
> @@ -174,7 +175,7 @@ static int raw_decode(AVCodecContext *avctx, void *data, 
> int *got_frame,
>  if (context->frame_size < 0)
>  return context->frame_size;
>  
> -need_copy = !avpkt->buf || context->is_2_4_bpp || context->is_yuv2 || 
> context->is_lt_16bpp;
> +need_copy = !avpkt->buf || context->is_1_2_4_bpp || context->is_yuv2 || 
> context->is_lt_16bpp;
>  
>  frame->pict_type= AV_PICTURE_TYPE_I;
>  frame->key_frame= 1;
> @@ -201,26 +202,38 @@ static int raw_decode(AVCodecContext *avctx, void 
> *data, int *got_frame,
>  if (!frame->buf[0])
>  return AVERROR(ENOMEM);
>  
> -//2bpp and 4bpp raw in avi and mov (yes this is ugly ...)
> -if (context->is_2_4_bpp) {
> -int i;
> +// 1 bpp raw in mov, and 2 or 4 bpp raw in avi/mov
> +if (context->is_1_2_4_bpp) {
> +int i, j = 0;
>  uint8_t *dst = frame->buf[0]->data;
>  buf_size = context->frame_size - AVPALETTE_SIZE;


>  if (avctx->bits_per_coded_sample == 4) {
> -for (i = 0; 2 * i + 1 < buf_size && isize; i++) {
> -dst[2 * i + 0] = buf[i] >> 4;
> -dst[2 * i + 1] = buf[i] & 15;
> +for (i = 0; j + 1 < buf_size && isize; i++) {
> +dst[j++] = buf[i] >> 4;
> +dst[j

Re: [FFmpeg-devel] [PATCH] avfilter: add afftfilter

2016-01-18 Thread Michael Niedermayer
On Sat, Jan 16, 2016 at 09:09:21PM +0100, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
[...]
> +static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
> +{
> +AVFilterContext *ctx = inlink->dst;
> +AVFilterLink *outlink = ctx->outputs[0];
> +AFFTFiltContext *s = ctx->priv;
> +const int window_size = s->window_size;
> +const float f = 1. / window_size;
> +double values[VAR_VARS_NB];
> +AVFrame *out, *in = NULL;
> +int ch, n, ret, i, j, k;
> +int start = s->start, end = s->end;
> +
> +av_audio_fifo_write(s->fifo, (void **)frame->extended_data, 
> frame->nb_samples);
> +av_frame_free(&frame);
> +
> +while (av_audio_fifo_size(s->fifo) >= window_size) {
> +in = ff_get_audio_buffer(outlink, window_size);
> +if (!in)
> +return AVERROR(ENOMEM);
> +
> +ret = av_audio_fifo_peek(s->fifo, (void **)in->extended_data, 
> window_size);
> +if (ret < 0)
> +break;
> +
> +for (ch = 0; ch < inlink->channels; ch++) {
> +const float *src = (float *)in->extended_data[ch];
> +FFTComplex *fft_data = s->fft_data[ch];
> +
> +for (n = 0; n < in->nb_samples; n++) {
> +fft_data[n].re = src[n] * s->window_func_lut[n];
> +fft_data[n].im = 0;
> +}
> +
> +for (; n < window_size; n++) {
> +fft_data[n].re = 0;
> +fft_data[n].im = 0;
> +}
> +}
> +
> +values[VAR_PTS] = s->pts;
> +values[VAR_SAMPLE_RATE] = inlink->sample_rate;
> +values[VAR_CHANNELS]= inlink->channels;
> +
> +for (ch = 0; ch < inlink->channels; ch++) {
> +FFTComplex *fft_data = s->fft_data[ch];
> +float *buf = (float *)s->buffer->extended_data[ch];
> +int x;
> +
> +values[VAR_CHANNEL] = ch;
> +
> +av_fft_permute(s->fft, fft_data);
> +av_fft_calc(s->fft, fft_data);
> +
> +for (n = 0; n < window_size / 2; n++) {
> +float ff;
> +
> +values[VAR_BIN] = n;
> +
> +ff = av_expr_eval(s->expr[ch], values, s);
> +fft_data[n].re *= ff;
> +fft_data[n].im *= ff;

if you use a complex valued FFT then allowing complex values from the
user somehow could make sense
maybe a real / imag expr


> +}
> +
> +for (n = window_size / 2 + 1, x = window_size / 2 - 1; n < 
> window_size; n++, x--) {
> +fft_data[n].re =  fft_data[x].re;
> +fft_data[n].im = -fft_data[x].im;
> +}
> +
> +av_fft_permute(s->ifft, fft_data);
> +av_fft_calc(s->ifft, fft_data);
> +
> +start = s->start;
> +end = s->end;
> +k = end;

> +for (i = 0, j = start; j < k && i < window_size; i++, j++) {
> +buf[j] += s->fft_data[ch][i].re * f;
> +}
> +
> +for (; i < window_size; i++, j++) {
> +buf[j] = s->fft_data[ch][i].re * f;
> +}

rescaling by a constant can likely be merged into something
(window or expr based coeffs)

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

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides


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


[FFmpeg-devel] [PATCH] lavf/qtpalette: Fix incorrect palettes

2016-01-18 Thread Mats Peterson
This patch corrects the colors of the 2 and 4 bpp palettes. Compare the 
output of the two files below in QuickTime in Win or Mac with the FFmpeg 
output, before and after the patch is applied (the second file is not so 
obvious, but the 4 bpp palette is incorrect nevertheless):


https://drive.google.com/open?id=0B3_pEBoLs0faZUc4VEVwalhGSE0

https://drive.google.com/open?id=0B3_pEBoLs0facHJkWnhvYXdtbms

Mats

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 5c8eac83f0fdc32c7d0ab43fffc33d63e16fdbb7 Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Mon, 18 Jan 2016 11:11:30 +0100
Subject: [PATCH] lavf/qtpalette: Fix incorrect palettes

This patch corrects the colors of the 2 and 4 bpp palettes.

---
 libavformat/qtpalette.h |   34 ++
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/libavformat/qtpalette.h b/libavformat/qtpalette.h
index b2bd360..10d0cf1 100644
--- a/libavformat/qtpalette.h
+++ b/libavformat/qtpalette.h
@@ -31,29 +31,31 @@ static const uint8_t ff_qt_default_palette_2[2 * 3] = {
   0x00, 0x00, 0x00
 };
 
+/* Obviously uses grays, judging by the Mac or Windows display */
 static const uint8_t ff_qt_default_palette_4[4 * 3] = {
-  0x93, 0x65, 0x5E,
   0xFF, 0xFF, 0xFF,
-  0xDF, 0xD0, 0xAB,
+  0xAA, 0xAA, 0xAA,
+  0x55, 0x55, 0x55,
   0x00, 0x00, 0x00
 };
 
+/* From the table (*not* the image) at https://en.wikipedia.org/wiki/List_of_software_palettes#Apple_Macintosh_default_16-color_palette */
 static const uint8_t ff_qt_default_palette_16[16 * 3] = {
-  0xFF, 0xFB, 0xFF,
-  0xEF, 0xD9, 0xBB,
-  0xE8, 0xC9, 0xB1,
-  0x93, 0x65, 0x5E,
-  0xFC, 0xDE, 0xE8,
-  0x9D, 0x88, 0x91,
   0xFF, 0xFF, 0xFF,
-  0xFF, 0xFF, 0xFF,
-  0xFF, 0xFF, 0xFF,
-  0x47, 0x48, 0x37,
-  0x7A, 0x5E, 0x55,
-  0xDF, 0xD0, 0xAB,
-  0xFF, 0xFB, 0xF9,
-  0xE8, 0xCA, 0xC5,
-  0x8A, 0x7C, 0x77,
+  0xFB, 0xF3, 0x05,
+  0xFF, 0x64, 0x03,
+  0xDD, 0x09, 0x07,
+  0xF2, 0x08, 0x84,
+  0x47, 0x00, 0xA5,
+  0x00, 0x00, 0xD3,
+  0x02, 0xAB, 0xEA,
+  0x1F, 0xB7, 0x14,
+  0x00, 0x64, 0x12,
+  0x56, 0x2C, 0x05,
+  0x90, 0x71, 0x3A,
+  0xC0, 0xC0, 0xC0,
+  0x80, 0x80, 0x80,
+  0x40, 0x40, 0x40,
   0x00, 0x00, 0x00
 };
 
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH]lavc/x264: Improve level setting

2016-01-18 Thread Carl Eugen Hoyos
Nicolas George  nsup.org> writes:

> Le nonidi 29 nivôse, an CCXXIV, Carl Eugen Hoyos a écrit :
> > The original patch (that does not care about tail 
> > since it can't be reached anyway) uses atoi().
> > Is that not ok?
> 
> atoi() has undefined behaviours in case of error 

How can I produce an error here?

> and has a trivial replacement that works best

Please elaborate.

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


Re: [FFmpeg-devel] [PATCH 1/5] libavutil: Some VAAPI infrastructure

2016-01-18 Thread Xiaolei Yu
On 01/18/2016 03:52 AM, Mark Thompson wrote:
> On 17/01/16 19:46, Mark Thompson wrote:
>> On 17/01/16 18:46, wm4 wrote:
>>>
>>> There are two issues:
>>> 1. global state in libav* which is not synchronized
>>> 2. thread-safety within
>>>
>>> 1. is is completely unacceptable, because it can trigger undefined
>>> behavior if there is more than 1 libav* user in the same process. I'm
>>> not really convinced that a "device string" is really reliably unique
>>> enough that it won't be a problem across library users. (For example,
>>> it's entirely possible enough to open 2 X11 Displays to the same X
>>> server using the same display name.)
>>
>> Ok, I'm happy with the first part of that (and that it is fixable by a
>> simple lock around the connection initialisation, assuming this code
>> stays in libavutil).
>>
>> Can you offer an example where the device strings actually create a
>> problem?
>>
>> Multiple users within the same process /must/ be given the same
>> connection if they ask for the same device, because we have no way to
>> distinguish different sets of instances which want to be able to work
>> together.  Equally, two connections to the same device under different
>> names are acceptably different, because they won't have come from the
>> same instance set.
> 
> Right, I see the problem.  The user will want to do something with the 
> surface they get back under the same X11 display handle.  We can't call 
> XOpenDisplay() in that case: the user has to be able to pass their own handle 
> in.  So we need some other way to register that connection.
> 
>>
>>> With 2. it's a bit more complicated. There should probably indeed be
>>> something like a big lock around all uses of the same VADisplay, as
>>> long as libva exhibits this problem.
>>
>> This is straightforward to do, if tedious.
>>
>> Can you explain the ABI and API constraints on changes to existing
>> structures?
>>
>> For the existing decoders (and their users) to work, it will require
>> either:
>> (a) a global list of connections somewhere to map VADisplay to lock
>> or
>> (b) an additional member in struct vaapi_context to point to the lock.
>>
>> If ABI and API compatibility is required for existing users then (b) is
>> out, and we have to have the global list (suitably locked).
>>
>> If we can break both then the right answer is probably to pass
>> hwaccel_context to encoders as well, and add a similar field to
>> AVFilterContext to use there too.
>>
>> If ABI compatibility is required but an API break is allowed then we
>> could do horrible things to hack (b) into working.  For example, replace
>> the VADisplay pointer in the first member of struct vaapi_context to
>> instead point at a new structure which contains some magic bytes at the
>> start.  If the magic bytes are where that pointer goes then we are using
>> the new API and can lock using that, and if they are not found then it
>> was a user-provided VADisplay and no locking is required.
>>
>> - Mark
>>
>>
>> PS:  I have no attachment to this piece of code (around connection
>> initialisation) at all; it was just required to make everything else
>> work.  If you want to suggest a better and completely different approach
>> then I am happy to throw it all away and start again.
>>

I think you can supply VADisplay to AVCodecContext through av_opt_ptr and
leave its initialization to user.

> 
> ___
> 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