[FFmpeg-devel] [PATCH] libkvazaar: add support for interlaced coding

Ari Koivula ari at koivu.la
Thu Jan 28 22:03:25 CET 2016


Tell libkvazaar to use field coding when -flags +ildct is detected,
resulting in two pictures being output for every frame instead of
one.

Signed-off-by: Ari Koivula <ari at koivu.la>
---
 configure               |  2 +-
 libavcodec/libkvazaar.c | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 629029e..06e3093 100755
--- a/configure
+++ b/configure
@@ -5487,7 +5487,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.8.1" kvazaar.h kvz_api_get
+enabled libkvazaar        && require_pkg_config "kvazaar >= 0.8.3" 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 79fde41..92aef50 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -86,6 +86,10 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx)
     cfg->vui.sar_width  = avctx->sample_aspect_ratio.num;
     cfg->vui.sar_height = avctx->sample_aspect_ratio.den;
 
+    if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
+        cfg->source_scan_type = KVZ_INTERLACING_TFF;
+    }
+
     if (ctx->kvz_params) {
         AVDictionary *dict = NULL;
         if (!av_dict_parse_string(&dict, ctx->kvz_params, "=", ",", 0)) {
@@ -194,6 +198,14 @@ static int libkvazaar_encode(AVCodecContext *avctx,
             goto done;
         }
 
+        if (ctx->config->source_scan_type != KVZ_INTERLACING_NONE) {
+            if (frame->top_field_first) {
+                input_pic->interlacing = KVZ_INTERLACING_TFF;
+            } else {
+                input_pic->interlacing = KVZ_INTERLACING_BFF;
+            }
+        }
+
         // Copy pixels from frame to input_pic.
         {
             int dst_linesizes[4] = {
-- 
1.9.1



More information about the ffmpeg-devel mailing list