Re: [FFmpeg-devel] [PATCH 1/2] lavc/libkvazaar: switch to ff_alloc_packet2

2017-11-09 Thread Arttu Ylä-Outinen

LGTM
___
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-19 Thread Arttu Ylä-Outinen

On 2016-01-18 15:46, Nicolas George wrote:


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



Thanks. I'll change that to EINVAL and apply the patch tomorrow if there 
are no other issues.


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


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

2016-01-15 Thread Arttu Ylä-Outinen
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 <arttu.yla-outi...@tut.fi>
---
 configure   | 2 +-
 libavcodec/libkvazaar.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 7cef6f5..1b004db 100755
--- a/configure
+++ b/configure
@@ -5452,7 +5452,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..87b802f 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -75,8 +75,8 @@ 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);
+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] configure: Require libkvazaar < 0.7

2015-10-14 Thread Arttu Ylä-Outinen
On 2015-10-14 13:19, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch for release/2.8 is supposed to fix ticket #4925, completely
> untested.
> 
> Please comment, Carl Eugen

> +enabled libkvazaar&& require_pkg_config "kvazaar < 0.7.0" kvazaar 
> kvazaar.h kvz_api_get

There is an extra "kvazaar" between 0.7.0 and kvazaar.h. It should be

enabled libkvazaar && require_pkg_config "kvazaar < 0.7.0" kvazaar.h 
kvz_api_get

instead. With that change, the patch seems to fix the problem in #4925.

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


Re: [FFmpeg-devel] [PATCH v2 0/8] libkvazaar improvements

2015-10-07 Thread Arttu Ylä-Outinen

On 2015-09-29 16:29, Arttu Ylä-Outinen wrote:

These patches fix some problems in libkvazaar encoder and update it to work
with the latest git version of Kvazaar. Most notable changes are setting
pts, dts and keyframe flag on the output packets and fixing the calculation
of the framerate.

v2: Add libkvazaar version check and fix descriptions of patches
 "libkvazaar: Fix setting target bitrate" and
 "doc/encoders: Fix libkvazaar documentation."

Thanks for the comments!

Arttu Ylä-Outinen (8):
   libkvazaar: Update to work with the latest version
   configure: Add version check for libkvazaar
   libkvazaar: Remove unnecessary NULL checks
   libkvazaar: Replace asserts with proper errors
   libkvazaar: Set pts and dts
   libkvazaar: Use av_image_copy for copying pixels
   libkvazaar: Fix setting framerate
   doc/encoders: Fix libkvazaar documentation

  configure   |2 ++
  doc/encoders.texi   |3 --
  libavcodec/libkvazaar.c |   80 ++-
  3 files changed, 60 insertions(+), 25 deletions(-)



Is it OK if I push these (with the v3 of the second patch)?

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


Re: [FFmpeg-devel] [PATCH v2 2/8] configure: Add version check for libkvazaar

2015-09-30 Thread Arttu Ylä-Outinen

On 2015-09-29 22:42, Hendrik Leppkes wrote:

On Tue, Sep 29, 2015 at 9:39 PM, Carl Eugen Hoyos  wrote:

Clément Bœsch  pkh.me> writes:


+ { check_cpp_condition kvazaar.h "KVZ_API_VERSION >= 7" ||
+   die "ERROR: kvazaar API version must be at least 7."; }

Can you do something like require_pkg_config "kvazaar >= 1.2.3" instead?

Please don't!
This only adds an unneeded requirement (and a regression)
to the library

It already requires pkg-config, all Clement is asking to also use it
to check the version, which makes a lot of sense.
Its also much more visible for users. API versions aren't meaningful
to users, while actual library versions are.


I'll change the patch to use pkg-config for the version check then.

Thanks for the comments.

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


[FFmpeg-devel] [PATCH v3 2/8] configure: Add version check for libkvazaar

2015-09-30 Thread Arttu Ylä-Outinen
Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outi...@tut.fi>
---
v3: Use pkg-config for checking the version.

v2: Add this patch.
---
 configure |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 361c024..ad4d71c 100755
--- a/configure
+++ b/configure
@@ -5272,7 +5272,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 kvazaar.h kvz_api_get
+enabled libkvazaar&& require_pkg_config "kvazaar >= 0.7.0" 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
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH v2 3/8] libkvazaar: Remove unnecessary NULL checks

2015-09-29 Thread Arttu Ylä-Outinen
Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outi...@tut.fi>
---
 libavcodec/libkvazaar.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 7430e0a..aaaf1f7 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -106,8 +106,8 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx)
 cfg = NULL;
 
 done:
-if (cfg) api->config_destroy(cfg);
-if (enc) api->encoder_close(enc);
+api->config_destroy(cfg);
+api->encoder_close(enc);
 
 return retval;
 }
@@ -215,8 +215,8 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 }
 
 done:
-if (img_in) ctx->api->picture_free(img_in);
-if (data_out) ctx->api->chunk_free(data_out);
+ctx->api->picture_free(img_in);
+ctx->api->chunk_free(data_out);
 return retval;
 }
 
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH v2 7/8] libkvazaar: Fix setting framerate

2015-09-29 Thread Arttu Ylä-Outinen
The divisor and dividend in the equation had been swapped, making the
result the inverse of the actual framerate.

Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outi...@tut.fi>
---
v2: Fix error in the commit message (bitrate --> framerate).
---
 libavcodec/libkvazaar.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 0879844..0cf890f 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -73,7 +73,7 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx)
 cfg->width = avctx->width;
 cfg->height = avctx->height;
 cfg->framerate =
-  (double)(avctx->time_base.num * avctx->ticks_per_frame) / 
avctx->time_base.den;
+  avctx->time_base.den / (double)(avctx->time_base.num * 
avctx->ticks_per_frame);
 cfg->threads = avctx->thread_count;
 cfg->target_bitrate = avctx->bit_rate;
 cfg->vui.sar_width = avctx->sample_aspect_ratio.num;
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH v2 8/8] doc/encoders: Fix libkvazaar documentation

2015-09-29 Thread Arttu Ylä-Outinen
The -threads option is ignored with libkvazaar since it does not have
any of the AV_CODEC_CAP_{FRAME,SLICE,AUTO}_THREADS capabilities. This
commit removes the incorrect documentation as well as the no-op of
setting the number of threads in libkvazaar encoder.

Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outi...@tut.fi>
---
v2: Rewrite the commit message to communicate why the parameter did not
work and that the patch also touches libkvazaar.c.
---
 doc/encoders.texi   |3 ---
 libavcodec/libkvazaar.c |1 -
 2 files changed, 4 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 3550bcc..bf364fd 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -2397,9 +2397,6 @@ configuration. You need to explicitly configure the build 
with
 @item b
 Set target video bitrate in bit/s and enable rate control.
 
-@item threads
-Set number of encoding threads.
-
 @item kvazaar-params
 Set kvazaar parameters as a list of @var{name}=@var{value} pairs separated
 by commas (,). See kvazaar documentation for a list of options.
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 0cf890f..3000f6a 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -74,7 +74,6 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx)
 cfg->height = avctx->height;
 cfg->framerate =
   avctx->time_base.den / (double)(avctx->time_base.num * 
avctx->ticks_per_frame);
-cfg->threads = avctx->thread_count;
 cfg->target_bitrate = avctx->bit_rate;
 cfg->vui.sar_width = avctx->sample_aspect_ratio.num;
 cfg->vui.sar_height = avctx->sample_aspect_ratio.den;
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH v2 4/8] libkvazaar: Replace asserts with proper errors

2015-09-29 Thread Arttu Ylä-Outinen
Changes function libkvazaar_encode to return proper error codes instead
of crashing when the video dimensions or pixel format change in the
middle of encoding.

Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outi...@tut.fi>
---
 libavcodec/libkvazaar.c |   24 +---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index aaaf1f7..a15700a 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -26,6 +26,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/dict.h"
 #include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
 #include "avcodec.h"
 #include "internal.h"
 
@@ -149,9 +150,26 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 if (frame) {
 int i = 0;
 
-av_assert0(frame->width == ctx->config->width);
-av_assert0(frame->height == ctx->config->height);
-av_assert0(frame->format == avctx->pix_fmt);
+if (frame->width != ctx->config->width ||
+frame->height != ctx->config->height) {
+av_log(avctx, AV_LOG_ERROR,
+   "Changing video dimensions during encoding is not 
supported. "
+   "(changed from %dx%d to %dx%d)\n",
+   ctx->config->width, ctx->config->height,
+   frame->width, frame->height);
+retval = AVERROR_INVALIDDATA;
+goto done;
+}
+
+if (frame->format != avctx->pix_fmt) {
+av_log(avctx, AV_LOG_ERROR,
+   "Changing pixel format during encoding is not supported. "
+   "(changed from %s to %s)\n",
+   av_get_pix_fmt_name(avctx->pix_fmt),
+   av_get_pix_fmt_name(frame->format));
+retval = AVERROR_INVALIDDATA;
+goto done;
+}
 
 // Allocate input picture for kvazaar.
 img_in = ctx->api->picture_alloc(frame->width, frame->height);
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH v2 6/8] libkvazaar: Use av_image_copy for copying pixels

2015-09-29 Thread Arttu Ylä-Outinen
Replaces a for loop for copying pixels by a call to av_image_copy.

Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outi...@tut.fi>
---
 libavcodec/libkvazaar.c |   24 +++-
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 9c59cad..0879844 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -24,6 +24,7 @@
 #include 
 
 #include "libavutil/avassert.h"
+#include "libavutil/imgutils.h"
 #include "libavutil/dict.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
@@ -149,8 +150,6 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 *got_packet_ptr = 0;
 
 if (frame) {
-int i = 0;
-
 if (frame->width != ctx->config->width ||
 frame->height != ctx->config->height) {
 av_log(avctx, AV_LOG_ERROR,
@@ -181,17 +180,16 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 }
 
 // Copy pixels from frame to img_in.
-for (i = 0; i < 3; ++i) {
-uint8_t *dst = img_in->data[i];
-uint8_t *src = frame->data[i];
-int width = (i == 0) ? frame->width : (frame->width / 2);
-int height = (i == 0) ? frame->height : (frame->height / 2);
-int y = 0;
-for (y = 0; y < height; ++y) {
-memcpy(dst, src, width);
-src += frame->linesize[i];
-dst += width;
-}
+{
+int dst_linesizes[4] = {
+  frame->width,
+  frame->width / 2,
+  frame->width / 2,
+  0
+};
+av_image_copy(img_in->data, dst_linesizes,
+  frame->data, frame->linesize,
+  frame->format, frame->width, frame->height);
 }
 
 img_in->pts = frame->pts;
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH v2 5/8] libkvazaar: Set pts and dts

2015-09-29 Thread Arttu Ylä-Outinen
Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outi...@tut.fi>
---
 libavcodec/libkvazaar.c |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index a15700a..9c59cad 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -141,6 +141,7 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 
 kvz_data_chunk *data_out = NULL;
 uint32_t len_out = 0;
+kvz_picture *recon_pic = NULL;
 kvz_frame_info frame_info;
 
 LibkvazaarContext *ctx = avctx->priv_data;
@@ -192,11 +193,13 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 dst += width;
 }
 }
+
+img_in->pts = frame->pts;
 }
 
 if (!ctx->api->encoder_encode(ctx->encoder, img_in,
   _out, _out,
-  NULL, NULL,
+  _pic, NULL,
   _info)) {
 av_log(avctx, AV_LOG_ERROR, "Failed to encode frame.\n");
 retval = AVERROR_EXTERNAL;
@@ -223,6 +226,9 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 ctx->api->chunk_free(data_out);
 data_out = NULL;
 
+avpkt->pts = recon_pic->pts;
+avpkt->dts = recon_pic->dts;
+
 avpkt->flags = 0;
 // IRAP VCL NAL unit types span the range
 // [BLA_W_LP (16), RSV_IRAP_VCL23 (23)].
@@ -234,6 +240,7 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 
 done:
 ctx->api->picture_free(img_in);
+ctx->api->picture_free(recon_pic);
 ctx->api->chunk_free(data_out);
 return retval;
 }
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH v2 0/8] libkvazaar improvements

2015-09-29 Thread Arttu Ylä-Outinen
These patches fix some problems in libkvazaar encoder and update it to work
with the latest git version of Kvazaar. Most notable changes are setting
pts, dts and keyframe flag on the output packets and fixing the calculation
of the framerate.

v2: Add libkvazaar version check and fix descriptions of patches
"libkvazaar: Fix setting target bitrate" and
"doc/encoders: Fix libkvazaar documentation."

Thanks for the comments!

Arttu Ylä-Outinen (8):
  libkvazaar: Update to work with the latest version
  configure: Add version check for libkvazaar
  libkvazaar: Remove unnecessary NULL checks
  libkvazaar: Replace asserts with proper errors
  libkvazaar: Set pts and dts
  libkvazaar: Use av_image_copy for copying pixels
  libkvazaar: Fix setting framerate
  doc/encoders: Fix libkvazaar documentation

 configure   |2 ++
 doc/encoders.texi   |3 --
 libavcodec/libkvazaar.c |   80 ++-
 3 files changed, 60 insertions(+), 25 deletions(-)

-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH v2 1/8] libkvazaar: Update to work with the latest version

2015-09-29 Thread Arttu Ylä-Outinen
Function encoder_encode in Kvazaar API was changed to have new output
parameters: source picture and frame info. Frame info is used to set the
keyframe flag and source picture is ignored.

Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outi...@tut.fi>
---
 libavcodec/libkvazaar.c |   16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 9fb5be7..7430e0a 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -137,8 +137,11 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 {
 int retval = 0;
 kvz_picture *img_in = NULL;
+
 kvz_data_chunk *data_out = NULL;
 uint32_t len_out = 0;
+kvz_frame_info frame_info;
+
 LibkvazaarContext *ctx = avctx->priv_data;
 
 *got_packet_ptr = 0;
@@ -173,7 +176,10 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 }
 }
 
-if (!ctx->api->encoder_encode(ctx->encoder, img_in, _out, _out, 
NULL)) {
+if (!ctx->api->encoder_encode(ctx->encoder, img_in,
+  _out, _out,
+  NULL, NULL,
+  _info)) {
 av_log(avctx, AV_LOG_ERROR, "Failed to encode frame.\n");
 retval = AVERROR_EXTERNAL;
 goto done;
@@ -198,6 +204,14 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 
 ctx->api->chunk_free(data_out);
 data_out = NULL;
+
+avpkt->flags = 0;
+// IRAP VCL NAL unit types span the range
+// [BLA_W_LP (16), RSV_IRAP_VCL23 (23)].
+if (frame_info.nal_unit_type >= KVZ_NAL_BLA_W_LP &&
+frame_info.nal_unit_type <= KVZ_NAL_RSV_IRAP_VCL23) {
+avpkt->flags |= AV_PKT_FLAG_KEY;
+}
 }
 
 done:
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH v2 2/8] configure: Add version check for libkvazaar

2015-09-29 Thread Arttu Ylä-Outinen
Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outi...@tut.fi>
---
v2: Add this patch.
---
 configure |2 ++
 1 file changed, 2 insertions(+)

diff --git a/configure b/configure
index b572d59..30576c1 100755
--- a/configure
+++ b/configure
@@ -5272,6 +5272,8 @@ enabled libgsm&& { for gsm_hdr in "gsm.h" 
"gsm/gsm.h"; do
done || die "ERROR: libgsm not found"; }
 enabled libilbc   && require libilbc ilbc.h WebRtcIlbcfix_InitDecode 
-lilbc
 enabled libkvazaar&& require_pkg_config kvazaar kvazaar.h kvz_api_get
+ { check_cpp_condition kvazaar.h "KVZ_API_VERSION 
>= 7" ||
+   die "ERROR: kvazaar API version must be at 
least 7."; }
 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
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH 1/7] libkvazaar: Update to work with the latest version

2015-09-28 Thread Arttu Ylä-Outinen
Function encoder_encode in Kvazaar API was changed to have new output
parameters: source picture and frame info. Frame info is used to set the
keyframe flag and source picture is ignored.

Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outi...@tut.fi>
---
 libavcodec/libkvazaar.c |   16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 9fb5be7..7430e0a 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -137,8 +137,11 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 {
 int retval = 0;
 kvz_picture *img_in = NULL;
+
 kvz_data_chunk *data_out = NULL;
 uint32_t len_out = 0;
+kvz_frame_info frame_info;
+
 LibkvazaarContext *ctx = avctx->priv_data;
 
 *got_packet_ptr = 0;
@@ -173,7 +176,10 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 }
 }
 
-if (!ctx->api->encoder_encode(ctx->encoder, img_in, _out, _out, 
NULL)) {
+if (!ctx->api->encoder_encode(ctx->encoder, img_in,
+  _out, _out,
+  NULL, NULL,
+  _info)) {
 av_log(avctx, AV_LOG_ERROR, "Failed to encode frame.\n");
 retval = AVERROR_EXTERNAL;
 goto done;
@@ -198,6 +204,14 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 
 ctx->api->chunk_free(data_out);
 data_out = NULL;
+
+avpkt->flags = 0;
+// IRAP VCL NAL unit types span the range
+// [BLA_W_LP (16), RSV_IRAP_VCL23 (23)].
+if (frame_info.nal_unit_type >= KVZ_NAL_BLA_W_LP &&
+frame_info.nal_unit_type <= KVZ_NAL_RSV_IRAP_VCL23) {
+avpkt->flags |= AV_PKT_FLAG_KEY;
+}
 }
 
 done:
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH 3/7] libkvazaar: Replace asserts with proper errors

2015-09-28 Thread Arttu Ylä-Outinen
Changes function libkvazaar_encode to return proper error codes instead
of crashing when the video dimensions or pixel format change in the
middle of encoding.

Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outi...@tut.fi>
---
 libavcodec/libkvazaar.c |   24 +---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index aaaf1f7..a15700a 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -26,6 +26,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/dict.h"
 #include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
 #include "avcodec.h"
 #include "internal.h"
 
@@ -149,9 +150,26 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 if (frame) {
 int i = 0;
 
-av_assert0(frame->width == ctx->config->width);
-av_assert0(frame->height == ctx->config->height);
-av_assert0(frame->format == avctx->pix_fmt);
+if (frame->width != ctx->config->width ||
+frame->height != ctx->config->height) {
+av_log(avctx, AV_LOG_ERROR,
+   "Changing video dimensions during encoding is not 
supported. "
+   "(changed from %dx%d to %dx%d)\n",
+   ctx->config->width, ctx->config->height,
+   frame->width, frame->height);
+retval = AVERROR_INVALIDDATA;
+goto done;
+}
+
+if (frame->format != avctx->pix_fmt) {
+av_log(avctx, AV_LOG_ERROR,
+   "Changing pixel format during encoding is not supported. "
+   "(changed from %s to %s)\n",
+   av_get_pix_fmt_name(avctx->pix_fmt),
+   av_get_pix_fmt_name(frame->format));
+retval = AVERROR_INVALIDDATA;
+goto done;
+}
 
 // Allocate input picture for kvazaar.
 img_in = ctx->api->picture_alloc(frame->width, frame->height);
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH 2/7] libkvazaar: Remove unnecessary NULL checks

2015-09-28 Thread Arttu Ylä-Outinen
Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outi...@tut.fi>
---
 libavcodec/libkvazaar.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 7430e0a..aaaf1f7 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -106,8 +106,8 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx)
 cfg = NULL;
 
 done:
-if (cfg) api->config_destroy(cfg);
-if (enc) api->encoder_close(enc);
+api->config_destroy(cfg);
+api->encoder_close(enc);
 
 return retval;
 }
@@ -215,8 +215,8 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 }
 
 done:
-if (img_in) ctx->api->picture_free(img_in);
-if (data_out) ctx->api->chunk_free(data_out);
+ctx->api->picture_free(img_in);
+ctx->api->chunk_free(data_out);
 return retval;
 }
 
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH 4/7] libkvazaar: Set pts and dts

2015-09-28 Thread Arttu Ylä-Outinen
Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outi...@tut.fi>
---
 libavcodec/libkvazaar.c |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index a15700a..9c59cad 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -141,6 +141,7 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 
 kvz_data_chunk *data_out = NULL;
 uint32_t len_out = 0;
+kvz_picture *recon_pic = NULL;
 kvz_frame_info frame_info;
 
 LibkvazaarContext *ctx = avctx->priv_data;
@@ -192,11 +193,13 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 dst += width;
 }
 }
+
+img_in->pts = frame->pts;
 }
 
 if (!ctx->api->encoder_encode(ctx->encoder, img_in,
   _out, _out,
-  NULL, NULL,
+  _pic, NULL,
   _info)) {
 av_log(avctx, AV_LOG_ERROR, "Failed to encode frame.\n");
 retval = AVERROR_EXTERNAL;
@@ -223,6 +226,9 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 ctx->api->chunk_free(data_out);
 data_out = NULL;
 
+avpkt->pts = recon_pic->pts;
+avpkt->dts = recon_pic->dts;
+
 avpkt->flags = 0;
 // IRAP VCL NAL unit types span the range
 // [BLA_W_LP (16), RSV_IRAP_VCL23 (23)].
@@ -234,6 +240,7 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 
 done:
 ctx->api->picture_free(img_in);
+ctx->api->picture_free(recon_pic);
 ctx->api->chunk_free(data_out);
 return retval;
 }
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH 5/7] libkvazaar: Use av_image_copy for copying pixels

2015-09-28 Thread Arttu Ylä-Outinen
Replaces a for loop for copying pixels by a call to av_image_copy.

Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outi...@tut.fi>
---
 libavcodec/libkvazaar.c |   24 +++-
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 9c59cad..0879844 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -24,6 +24,7 @@
 #include 
 
 #include "libavutil/avassert.h"
+#include "libavutil/imgutils.h"
 #include "libavutil/dict.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
@@ -149,8 +150,6 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 *got_packet_ptr = 0;
 
 if (frame) {
-int i = 0;
-
 if (frame->width != ctx->config->width ||
 frame->height != ctx->config->height) {
 av_log(avctx, AV_LOG_ERROR,
@@ -181,17 +180,16 @@ static int libkvazaar_encode(AVCodecContext *avctx,
 }
 
 // Copy pixels from frame to img_in.
-for (i = 0; i < 3; ++i) {
-uint8_t *dst = img_in->data[i];
-uint8_t *src = frame->data[i];
-int width = (i == 0) ? frame->width : (frame->width / 2);
-int height = (i == 0) ? frame->height : (frame->height / 2);
-int y = 0;
-for (y = 0; y < height; ++y) {
-memcpy(dst, src, width);
-src += frame->linesize[i];
-dst += width;
-}
+{
+int dst_linesizes[4] = {
+  frame->width,
+  frame->width / 2,
+  frame->width / 2,
+  0
+};
+av_image_copy(img_in->data, dst_linesizes,
+  frame->data, frame->linesize,
+  frame->format, frame->width, frame->height);
 }
 
 img_in->pts = frame->pts;
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH 0/7] libkvazaar improvements

2015-09-28 Thread Arttu Ylä-Outinen
These patches fix some problems in libkvazaar encoder and update it to work
with the latest git version of Kvazaar. Most notable changes are setting
pts, dts and keyframe flag on the output packets and fixing the calculation
of the target bitrate.

Arttu Ylä-Outinen (7):
  libkvazaar: Update to work with the latest version
  libkvazaar: Remove unnecessary NULL checks
  libkvazaar: Replace asserts with proper errors
  libkvazaar: Set pts and dts
  libkvazaar: Use av_image_copy for copying pixels
  libkvazaar: Fix setting target bitrate
  doc/encoders: Fix libkvazaar documentation

 doc/encoders.texi   |3 --
 libavcodec/libkvazaar.c |   80 ++-
 2 files changed, 58 insertions(+), 25 deletions(-)

-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH 7/7] doc/encoders: Fix libkvazaar documentation

2015-09-28 Thread Arttu Ylä-Outinen
Removes the -threads option from libkvazaar documentation since it does
not work with libkvazaar.

Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outi...@tut.fi>
---
 doc/encoders.texi   |3 ---
 libavcodec/libkvazaar.c |1 -
 2 files changed, 4 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 3550bcc..bf364fd 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -2397,9 +2397,6 @@ configuration. You need to explicitly configure the build 
with
 @item b
 Set target video bitrate in bit/s and enable rate control.
 
-@item threads
-Set number of encoding threads.
-
 @item kvazaar-params
 Set kvazaar parameters as a list of @var{name}=@var{value} pairs separated
 by commas (,). See kvazaar documentation for a list of options.
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 0cf890f..3000f6a 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -74,7 +74,6 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx)
 cfg->height = avctx->height;
 cfg->framerate =
   avctx->time_base.den / (double)(avctx->time_base.num * 
avctx->ticks_per_frame);
-cfg->threads = avctx->thread_count;
 cfg->target_bitrate = avctx->bit_rate;
 cfg->vui.sar_width = avctx->sample_aspect_ratio.num;
 cfg->vui.sar_height = avctx->sample_aspect_ratio.den;
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH 6/7] libkvazaar: Fix setting target bitrate

2015-09-28 Thread Arttu Ylä-Outinen
The divisor and dividend in the equation had been swapped, making the
result the inverse of the actual bitrate.

Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outi...@tut.fi>
---
 libavcodec/libkvazaar.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 0879844..0cf890f 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -73,7 +73,7 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx)
 cfg->width = avctx->width;
 cfg->height = avctx->height;
 cfg->framerate =
-  (double)(avctx->time_base.num * avctx->ticks_per_frame) / 
avctx->time_base.den;
+  avctx->time_base.den / (double)(avctx->time_base.num * 
avctx->ticks_per_frame);
 cfg->threads = avctx->thread_count;
 cfg->target_bitrate = avctx->bit_rate;
 cfg->vui.sar_width = avctx->sample_aspect_ratio.num;
-- 
1.7.9.5

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


Re: [FFmpeg-devel] [PATCH 6/7] libkvazaar: Fix setting target bitrate

2015-09-28 Thread Arttu Ylä-Outinen

On 2015-09-28 15:11, Carl Eugen Hoyos wrote:

Arttu Ylä-Outinen  tut.fi> writes:


The divisor and dividend in the equation had been swapped,
making the result the inverse of the actual bitrate.
  cfg->framerate =
-  (double)(avctx->time_base.num * avctx->ticks_per_frame) /
avctx->time_base.den;
+  avctx->time_base.den / (double)(avctx->time_base.num *
avctx->ticks_per_frame);

The patch description and the patch do not
match - framerate != bitrate - or do I misunderstand?


Whoops, it is an error in the description.

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


Re: [FFmpeg-devel] [PATCH 7/7] doc/encoders: Fix libkvazaar documentation

2015-09-28 Thread Arttu Ylä-Outinen

On 2015-09-28 15:12, Carl Eugen Hoyos wrote:

Arttu Ylä-Outinen  tut.fi> writes:


Removes the -threads option from libkvazaar documentation
since it does not work with libkvazaar.

Why?
(Is this something that has to be fixed in FFmpeg?)


The -threads option is ignored and the thread_count field of the 
AVCodecContext is always set to one because libkvazaar does not have any 
of the codec capabilities AV_CODEC_CAP_{FRAME,SLICE,AUTO}_THREADS.



-cfg->threads = avctx->thread_count;

Please clarify in the description that the patch is not
documentation (-only).


I'll fix the description.

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


Re: [FFmpeg-devel] [PATCH 1/7] libkvazaar: Update to work with the latest version

2015-09-28 Thread Arttu Ylä-Outinen

On 2015-09-28 15:09, Carl Eugen Hoyos wrote:

I believe the patch is missing a change to configure:
Please make sure that configure --enable-libkvazaar
fails if compilation would fail later because a too
old version of libkvazaar is installed.


Okay, I'll add a version check.

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


[FFmpeg-devel] [PATCH] configure: Use pkg-config for libkvazaar.

2015-08-18 Thread Arttu Ylä-Outinen
Signed-off-by: Arttu Ylä-Outinen arttu.yla-outi...@tut.fi
---
 configure |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 55cc7fb..3fa37b7 100755
--- a/configure
+++ b/configure
@@ -5226,7 +5226,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 libilbcrequire libilbc ilbc.h WebRtcIlbcfix_InitDecode 
-lilbc
-enabled libkvazaar require2 libkvazaar kvazaar.h kvz_api_get 
-lkvazaar
+enabled libkvazaar require_pkg_config kvazaar 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
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH] MAINTAINERS: add myself as libkvazaar maintainer

2015-07-15 Thread Arttu Ylä-Outinen
Signed-off-by: Arttu Ylä-Outinen arttu.yla-outi...@tut.fi
---
 MAINTAINERS |1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index fa9e966..c5c6572 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -200,6 +200,7 @@ Codecs:
   libcelt_dec.c Nicolas George
   libdirac* David Conrad
   libgsm.c  Michel Bardiaux
+  libkvazaar.c  Arttu Ylä-Outinen
   libopenjpeg.c Jaikrishnan Menon
   libopenjpegenc.c  Michael Bradshaw
   libschroedinger*  David Conrad
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH] avcodec: add libkvazaar HECV encoder

2015-07-13 Thread Arttu Ylä-Outinen
Signed-off-by: Arttu Ylä-Outinen arttu.yla-outi...@tut.fi
---
 Changelog   |1 +
 configure   |4 +
 doc/encoders.texi   |   24 +
 doc/general.texi|   10 +-
 libavcodec/Makefile |1 +
 libavcodec/allcodecs.c  |1 +
 libavcodec/libkvazaar.c |  248 +++
 libavcodec/version.h|2 +-
 8 files changed, 289 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/libkvazaar.c

diff --git a/Changelog b/Changelog
index ccd8d4a..a4451f9 100644
--- a/Changelog
+++ b/Changelog
@@ -15,6 +15,7 @@ version next:
 - adrawgraph audio and drawgraph video filter
 - removegrain video filter
 - Intel QSV-accelerated MPEG-2 video and HEVC encoding
+- libkvazaar HEVC encoder
 
 
 version 2.7:
diff --git a/configure b/configure
index 88ee936..5616b59 100755
--- a/configure
+++ b/configure
@@ -222,6 +222,7 @@ External library support:
   --enable-libgsm  enable GSM de/encoding via libgsm [no]
   --enable-libiec61883 enable iec61883 via libiec61883 [no]
   --enable-libilbc enable iLBC de/encoding via libilbc [no]
+  --enable-libkvazaar  enable HEVC encoding via libkvazaar [no]
   --enable-libmfx  enable HW acceleration through libmfx
   --enable-libmodplug  enable ModPlug via libmodplug [no]
   --enable-libmp3lame  enable MP3 encoding via libmp3lame [no]
@@ -1386,6 +1387,7 @@ EXTERNAL_LIBRARY_LIST=
 libgsm
 libiec61883
 libilbc
+libkvazaar
 libmfx
 libmodplug
 libmp3lame
@@ -2464,6 +2466,7 @@ libgsm_ms_decoder_deps=libgsm
 libgsm_ms_encoder_deps=libgsm
 libilbc_decoder_deps=libilbc
 libilbc_encoder_deps=libilbc
+libkvazaar_encoder_deps=libkvazaar
 libmodplug_demuxer_deps=libmodplug
 libmp3lame_encoder_deps=libmp3lame
 libmp3lame_encoder_select=audio_frame_queue
@@ -5152,6 +5155,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 libilbcrequire libilbc ilbc.h WebRtcIlbcfix_InitDecode 
-lilbc
+enabled libkvazaar require2 libkvazaar kvazaar.h kvz_api_get 
-lkvazaar
 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/doc/encoders.texi b/doc/encoders.texi
index 5946644..6e50a90 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -2315,6 +2315,30 @@ Setting a higher @option{bits_per_mb} limit will improve 
the speed.
 For the fastest encoding speed set the @option{qscale} parameter (4 is the
 recommended value) and do not set a size constraint.
 
+@section libkvazaar
+
+Kvazaar H.265/HEVC encoder.
+
+Requires the presence of the libkvazaar headers and library during
+configuration. You need to explicitly configure the build with
+@option{--enable-libkvazaar}.
+
+@subsection Options
+
+@table @option
+
+@item b
+Set target video bitrate in bit/s and enable rate control.
+
+@item threads
+Set number of encoding threads.
+
+@item kvazaar-params
+Set kvazaar parameters as a list of @var{name}=@var{value} pairs separated
+by commas (,). See kvazaar documentation for a list of options.
+
+@end table
+
 @c man end VIDEO ENCODERS
 
 @chapter Subtitles Encoders
diff --git a/doc/general.texi b/doc/general.texi
index 5089c36..dc22d90 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -145,6 +145,14 @@ x265 is under the GNU Public License Version 2 or later
 details), you must upgrade FFmpeg's license to GPL in order to use it.
 @end float
 
+@section kvazaar
+
+FFmpeg can make use of the kvazaar library for HEVC encoding.
+
+Go to @url{https://github.com/ultravideo/kvazaar} and follow the
+instructions for installing the library. Then pass
+@code{--enable-libkvazaar} to configure to enable it.
+
 @section libilbc
 
 iLBC is a narrowband speech codec that has been made freely available
@@ -688,7 +696,7 @@ following image formats are supported:
 @item H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10  @tab  E  @tab  X
 @tab encoding supported through external library libx264 and OpenH264
 @item HEVC   @tab  X  @tab  X
-@tab encoding supported through the external library libx265
+@tab encoding supported through external library libx265 and libkvazaar
 @item HNM version 4  @tab @tab  X
 @item HuffYUV@tab  X  @tab  X
 @item HuffYUV FFmpeg variant @tab  X  @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 70755f6..b7fe1c9 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -768,6 +768,7 @@ OBJS-$(CONFIG_LIBGSM_MS_DECODER)  += libgsmdec.o
 OBJS-$(CONFIG_LIBGSM_MS_ENCODER)  += libgsmenc.o
 OBJS-$(CONFIG_LIBILBC_DECODER)+= libilbc.o
 OBJS