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

Ari Koivula ari at koivu.la
Thu Jan 28 22:17:07 CET 2016


I'm not quite sure if I'm going about this interlacing thing correctly, so
I figured I should send in a patch and ask.

Is AV_CODEC_FLAG_INTERLACED_DCT the correct flag to look at? There is also
AV_CODEC_FLAG_INTERLACED_ME, but libx264 uses only DCT.

Is outputting more than one picture per frame ok? I figured outputting two
fields isn't really any different from outputting two slices,

Also, I forgot to mention that most decoders don't deinterlace field coded
HEVC, so if you test this feature you will get only the fields unless you
decode with HM.

-Ari

On Thu, Jan 28, 2016 at 11:03 PM, Ari Koivula <ari at koivu.la> wrote:

> 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